@dmitryvim/form-builder 0.5.3 → 0.5.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 +1 -1
- package/dist/browser/formbuilder.min.js +111 -111
- package/dist/browser/formbuilder.v0.5.4.min.js +1490 -0
- package/dist/cjs/index.cjs +139 -62
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +121 -57
- package/dist/esm/index.js.map +1 -1
- package/dist/form-builder.js +111 -111
- package/dist/types/components/container.d.ts +1 -1
- package/dist/types/instance/FormBuilderInstance.d.ts +19 -1
- package/dist/types/types/state.d.ts +7 -0
- package/dist/types/utils/helpers.d.ts +16 -4
- package/package.json +1 -1
- package/dist/browser/formbuilder.v0.5.3.min.js +0 -1490
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.locale||"en",o=t.config.translations[r],a=t.config.translations.en;let
|
|
1
|
+
var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.locale||"en",o=t.config.translations[r],a=t.config.translations.en;let l=(o==null?void 0:o[e])||(a==null?void 0:a[e])||e;if(n)for(const[i,c]of Object.entries(n))l=l.replace(new RegExp(`\\{${i}\\}`,"g"),String(c));return l}function ae(e,t,n){return e.readonly===!0||t.config.readonly===!0||(n==null?void 0:n.inheritedReadonly)===!0}function Je(e){return e&&typeof e=="object"&&e.constructor===Object}function se(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function wt(e,t){if(e.key)return e.key;const n=t.syntheticElementIds.get(e);if(n!==void 0)return n;const r=`fb-synthetic-${t.syntheticElementIdCounter++}`;return t.syntheticElementIds.set(e,r),r}function De(e,t){return e?`${e}.${t}`:t}function nt(e,t){if(!t)return[];const n=e.querySelectorAll("[data-container-item]");return Array.from(n).filter(r=>{const o=r.getAttribute("data-container-item")||"";return o.startsWith(`${t}[`)?/^\[\d+\]$/.test(o.slice(t.length)):!1})}function we(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function xr(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Zt(e){return e==null?"":JSON.stringify(e)}function Ct(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function Et(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=Zt(t),n}function wr(e,t,n){(e.minLength!=null||e.maxLength!=null)&&(e.minLength!=null&&e.maxLength!=null?t.push(k("hintLengthRange",n,{min:e.minLength,max:e.maxLength})):e.maxLength!=null?t.push(k("hintMaxLength",n,{max:e.maxLength})):e.minLength!=null&&t.push(k("hintMinLength",n,{min:e.minLength})))}function Cr(e,t,n){(e.min!=null||e.max!=null)&&(e.min!=null&&e.max!=null?t.push(k("hintValueRange",n,{min:e.min,max:e.max})):e.max!=null?t.push(k("hintMaxValue",n,{max:e.max})):e.min!=null&&t.push(k("hintMinValue",n,{min:e.min})))}function Er(e,t,n){var r;const o=(r=e.maxSize)!=null?r:e.maxSizeMB;o&&o!==1/0&&t.push(k("hintMaxSize",n,{size:o}))}function kr(e,t,n){var r;(r=e.accept)!=null&&r.extensions&&t.push(k("hintFormats",n,{formats:e.accept.extensions.map(o=>o.toUpperCase()).join(",")}))}function $r(e,t,n){e.pattern&&t.push(k("hintPattern",n,{pattern:e.pattern}))}function Le(e,t){const n=[];return wr(e,n,t),e.type!=="slider"&&Cr(e,n,t),Er(e,n,t),kr(e,n,t),$r(e,n,t),n.join(" \u2022 ")}function kt(e){const t=[];if(!e||typeof e!="object")return t.push("Schema must be an object"),t;if(!Array.isArray(e.elements))return t.push("Schema missing elements array"),t;if("columns"in e&&e.columns!==void 0){const i=e.columns,c=[1,2,3,4];(!Number.isInteger(i)||!c.includes(i))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${i})`)}if("prefillHints"in e&&e.prefillHints){const i=e.prefillHints;Array.isArray(i)&&i.forEach((c,s)=>{if((!c.label||typeof c.label!="string")&&t.push(`schema.prefillHints[${s}] must have a 'label' property of type string`),!c.values||typeof c.values!="object")t.push(`schema.prefillHints[${s}] must have a 'values' property of type object`);else for(const f in c.values)e.elements.some(d=>d.key===f)||t.push(`schema.prefillHints[${s}] references non-existent field "${f}"`)})}function n(i,c,s){if("columns"in i&&i.columns!==void 0){const f=i.columns,d=[1,2,3,4];(!Number.isInteger(f)||!d.includes(f))&&s.push(`${c}: columns must be 1, 2, 3, or 4 (got ${f})`)}if("displayMode"in i&&i.displayMode!==void 0){const f=i.displayMode;f!=="stack"&&f!=="slides"&&s.push(`${c}: displayMode must be "stack" or "slides" (got ${JSON.stringify(f)})`)}}function r(i,c){var s,f;const d=new Set;for(const u of i)if(u.type==="richinput"&&u.flatOutput){const p=u,m=(s=p.textKey)!=null?s:"text",b=(f=p.filesKey)!=null?f:"files";for(const g of i)g!==u&&(g.key===m&&t.push(`${c}: RichInput "${u.key}" flatOutput textKey "${m}" collides with element key "${g.key}"`),g.key===b&&t.push(`${c}: RichInput "${u.key}" flatOutput filesKey "${b}" collides with element key "${g.key}"`));d.has(m)&&t.push(`${c}: RichInput "${u.key}" flatOutput textKey "${m}" collides with another flatOutput key`),d.has(b)&&t.push(`${c}: RichInput "${u.key}" flatOutput filesKey "${b}" collides with another flatOutput key`),d.add(m),d.add(b)}else u.key&&(d.has(u.key)&&t.push(`${c}: Element key "${u.key}" collides with a flatOutput richinput key`),d.add(u.key))}function o(i,c,s){var f,d;const u=i;if(u.type==="group"){if(!Je(u.repeat))return;a(c,(f=u.repeat)==null?void 0:f.min,(d=u.repeat)==null?void 0:d.max,"repeat.min","repeat.max",u.required===!0,s);return}(u.multiple===!0||u.type==="files")&&a(c,u.minCount,u.maxCount,"minCount","maxCount",u.required===!0,s)}function a(i,c,s,f,d,u,p){for(const[E,h]of[[f,c],[d,s]])h!==void 0&&typeof h!="number"&&p.push(`${i}: ${E} must be a number (got ${typeof h})`);const m=typeof c=="number"?c:void 0,b=typeof s=="number"?s:void 0;b!==void 0&&(b<0||Number.isNaN(b))&&p.push(`${i}: ${d} must be a non-negative number or Infinity (got ${b})`),m!==void 0&&(m<0||!Number.isFinite(m))&&p.push(`${i}: ${f} must be a finite non-negative number (got ${m})`);const g=m!=null?m:u?1:void 0;if(g!==void 0&&b!==void 0&&g>b){const E=m!==void 0?`${f} (${m})`:`required: true (implies ${f} 1)`;p.push(`${i}: ${E} cannot be greater than ${d} (${b})`)}}function l(i,c){i.forEach((s,f)=>{const d=`${c}[${f}]`;if(s.type||t.push(`${d}: missing type`),!s.key&&s.type!=="markdown"&&t.push(`${d}: missing key`),o(s,d,t),s.type==="number"&&"decimals"in s){const u=s.decimals;u!==void 0&&(!Number.isInteger(u)||u<0)&&t.push(`${d}: decimals must be a non-negative integer (got ${JSON.stringify(u)})`)}if(s.type==="markdown"){const u=s.content;typeof u!="string"&&t.push(`${d}: markdown element requires "content" to be a string (got ${u===null?"null":typeof u})`)}if(s.enableIf){const u=s.enableIf;(!u.key||typeof u.key!="string")&&t.push(`${d}: enableIf must have a 'key' property of type string`),"equals"in u||t.push(`${d}: enableIf must have at least one operator (equals, etc.)`)}if(s.type==="group"&&"elements"in s&&s.elements&&l(s.elements,`${d}.elements`),s.type==="container"&&s.elements){if(n(s,d,t),"prefillHints"in s&&s.prefillHints){const u=s.prefillHints;Array.isArray(u)&&u.forEach((p,m)=>{if((!p.label||typeof p.label!="string")&&t.push(`${d}: prefillHints[${m}] must have a 'label' property of type string`),!p.values||typeof p.values!="object")t.push(`${d}: prefillHints[${m}] must have a 'values' property of type object`);else for(const b in p.values)s.elements.some(g=>g.key===b)||t.push(`container "${s.key}": prefillHints[${m}] references non-existent field "${b}"`)})}l(s.elements,`${d}.elements`),r(s.elements,`${d}.elements`)}if(s.type==="select"&&s.options){const u=s.default;u!=null&&u!==""&&(s.options.some(p=>p.value===u)||t.push(`${d}: default "${u}" not in options`))}})}return Array.isArray(e.elements)&&(l(e.elements,"elements"),r(e.elements,"elements")),t}function rt(e,t){if(!e||typeof e!="object")return;const n=t.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return;let r=e;for(const o of n){if(r==null)return;if(o.startsWith("[")&&o.endsWith("]")){const a=parseInt(o.slice(1,-1),10);if(!Array.isArray(r)||isNaN(a))return;r=r[a]}else r=r[o]}return r}function je(e,t,n){var r;if(!e||!e.key)throw new Error("Invalid enableIf condition: must have a 'key' property");const o=(r=e.scope)!=null?r:"relative";let a;if(o==="relative")a=n!=null?n:t;else if(o==="absolute")a=t;else throw new Error(`Invalid enableIf scope: must be "relative" or "absolute" (got "${o}")`);const l=rt(a,e.key);if("equals"in e)return Sr(l,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function Sr(e,t){if(e===t)return!0;if(e==null||t==null)return e===t;if(typeof e!=typeof t)return!1;if(typeof e=="object"&&typeof t=="object")try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){if(n instanceof TypeError&&(n.message.includes("circular")||n.message.includes("cyclic")))return console.warn("deepEqual: Circular reference detected in enableIf comparison, using reference equality"),e===t;throw n}return e===t}function Ce(e){const t=e.getAttribute("name");if(!t)return;const n=(e.ownerDocument||document).getElementById(`error-${t}`);n&&n.remove()}const Qt='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>';function Lr(e){if(e.head.querySelector("[data-fb-theming-hooks]"))return;const t=e.createElement("style");t.setAttribute("data-fb-theming-hooks",""),t.textContent=`
|
|
2
2
|
[data-fb-slide-card] {
|
|
3
3
|
background: var(--fb-slide-card-bg);
|
|
4
4
|
box-shadow: var(--fb-slide-card-shadow);
|
|
@@ -110,7 +110,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
110
110
|
/* .fb-size-md uses defaults \u2014 no override needed */
|
|
111
111
|
.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
112
|
.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
|
|
113
|
+
`,e.head.appendChild(t)}function ot(e,t={}){var n;e.style.overflow="hidden",e.style.resize="none";const r=Math.max(1,(n=t.minRows)!=null?n:1),o=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(r,o);const a=()=>{if(!e.isConnected)return;e.style.height="";const c=getComputedStyle(e),s=parseFloat(c.borderTopWidth||"0")+parseFloat(c.borderBottomWidth||"0"),f=parseFloat(c.lineHeight||"0")||parseFloat(c.fontSize||"0")*1.5||20,d=parseFloat(c.paddingTop||"0")+parseFloat(c.paddingBottom||"0"),u=f*r+d+s;if(e.value===""){e.style.height=`${u}px`;return}const p=e.scrollHeight+s;e.style.height=`${Math.max(p,u)}px`};if(e.addEventListener("input",a),setTimeout(()=>{e.isConnected&&a()},0),typeof ResizeObserver=="undefined")return;let l=-1;const i=new ResizeObserver(c=>{var s,f,d,u,p;if(!e.isConnected){i.disconnect();return}const m=c[0],b=(p=(u=(f=(s=m==null?void 0:m.contentBoxSize)==null?void 0:s[0])==null?void 0:f.inlineSize)!=null?u:(d=m==null?void 0:m.contentRect)==null?void 0:d.width)!=null?p:0;b!==l&&(l=b,a())});i.observe(e)}function en(e){e.addEventListener("keydown",t=>{t.key==="Enter"&&t.preventDefault()}),e.addEventListener("paste",t=>{var n,r,o,a;const l=(r=(n=t.clipboardData)==null?void 0:n.getData("text"))!=null?r:"";if(!/[\r\n]/.test(l))return;t.preventDefault();const i=l.replace(/[\r\n]+/g," "),c=(o=e.selectionStart)!=null?o:e.value.length,s=(a=e.selectionEnd)!=null?a:e.value.length,f=e.value.slice(0,c),d=e.value.slice(s);e.value=f+i+d;const u=c+i.length;e.setSelectionRange(u,u),e.dispatchEvent(new Event("input",{bubbles:!0}))})}function Te(e,t){const n=e.querySelector(":scope > [data-fb-label-row]");n&&n.appendChild(t)}function ze(e,t,n={}){var r;const o=(r=n.label)!=null?r:"",a=n.showCounter!==!1,l=document.createElement("div");l.className="fb-add-row",l.style.cssText="display:flex;align-items:stretch;width:100%;margin-top:4px;";const i=document.createElement("button");i.type="button",i.className=`add-${e}-btn`,i.style.cssText=`
|
|
114
114
|
flex: 1 1 auto;
|
|
115
115
|
display: inline-flex;
|
|
116
116
|
align-items: center;
|
|
@@ -126,12 +126,12 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
126
126
|
font-family: var(--fb-font-family);
|
|
127
127
|
cursor: pointer;
|
|
128
128
|
transition: border-color var(--fb-transition-duration), color var(--fb-transition-duration), background-color var(--fb-transition-duration);
|
|
129
|
-
`,
|
|
129
|
+
`,i.textContent=o?`+ ${o}`:"+",i.addEventListener("mouseenter",()=>{i.disabled||(i.style.borderStyle="solid",i.style.backgroundColor="var(--fb-background-hover-color)")}),i.addEventListener("mouseleave",()=>{i.style.borderStyle="dashed",i.style.backgroundColor="transparent"}),i.onclick=t;const c=document.createElement("span");return c.className="fb-add-counter",c.style.cssText=`
|
|
130
130
|
margin-left: auto;
|
|
131
131
|
font-size: var(--fb-font-size-small, 0.875rem);
|
|
132
132
|
color: var(--fb-text-secondary-color);
|
|
133
133
|
font-weight: 400;
|
|
134
|
-
`,a||(
|
|
134
|
+
`,a||(c.style.display="none"),l.appendChild(i),{row:l,button:i,counter:c,update:(s,f)=>{const d=s>=f;l.style.display=d?"none":"flex",i.style.display=d?"none":"inline-flex",i.disabled=d,a&&(c.textContent=`${s}/${f===1/0?"\u221E":f}`)}}}function Tr(e,t={}){var n;const r=(n=t.label)!=null?n:"",o=document.createElement("button");o.type="button",o.className="add-container-btn fb-slide-add",o.style.cssText=`
|
|
135
135
|
display: flex;
|
|
136
136
|
flex-direction: column;
|
|
137
137
|
align-items: center;
|
|
@@ -163,12 +163,12 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
163
163
|
line-height: 1;
|
|
164
164
|
color: inherit;
|
|
165
165
|
transition: inherit;
|
|
166
|
-
`,a.textContent="+",o.appendChild(a),r){const
|
|
166
|
+
`,a.textContent="+",o.appendChild(a),r){const i=document.createElement("span");i.textContent=r,o.appendChild(i)}o.addEventListener("mouseenter",()=>{o.disabled||(o.style.borderStyle="solid",o.style.backgroundColor="var(--fb-background-hover-color)")}),o.addEventListener("mouseleave",()=>{o.style.borderStyle="dashed",o.style.backgroundColor="transparent"}),o.onclick=e;const l=document.createElement("span");return l.className="fb-add-counter",l.style.cssText=`
|
|
167
167
|
margin-left: auto;
|
|
168
168
|
font-size: var(--fb-font-size-small, 0.875rem);
|
|
169
169
|
color: var(--fb-text-secondary-color);
|
|
170
170
|
font-weight: 400;
|
|
171
|
-
`,{tile:o,counter:
|
|
171
|
+
`,{tile:o,counter:l,update:(i,c)=>{const s=i>=c;o.style.display=s?"none":"flex",o.disabled=s,l.textContent=`${i}/${c===1/0?"\u221E":c}`}}}function tn(e,t=!1){e.style.cssText=`
|
|
172
172
|
background-color: var(--fb-action-bg-color);
|
|
173
173
|
color: var(--fb-action-text-color);
|
|
174
174
|
border: var(--fb-border-width) solid var(--fb-action-border-color);
|
|
@@ -178,7 +178,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
178
178
|
border-radius: var(--fb-border-radius);
|
|
179
179
|
transition: all var(--fb-transition-duration);
|
|
180
180
|
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
|
|
181
|
+
`,e.addEventListener("mouseenter",()=>{e.style.backgroundColor="var(--fb-action-hover-bg-color)",e.style.borderColor="var(--fb-action-hover-border-color)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor="var(--fb-action-bg-color)",e.style.borderColor="var(--fb-action-border-color)"})}function Ar(e){if(e.head.querySelector("[data-fb-chip-styles]"))return;const t=e.createElement("style");t.setAttribute("data-fb-chip-styles",""),t.textContent=`
|
|
182
182
|
.fb-chip-list { display: flex; flex-direction: column; gap: 2px; }
|
|
183
183
|
.fb-chip {
|
|
184
184
|
display: flex;
|
|
@@ -243,7 +243,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
243
243
|
background: var(--fb-background-hover-color, #f1f5f9);
|
|
244
244
|
}
|
|
245
245
|
.fb-chip-remove:disabled { opacity: 0 !important; pointer-events: none; }
|
|
246
|
-
`,e.head.appendChild(t)}function
|
|
246
|
+
`,e.head.appendChild(t)}function lt(e,t){const n=document.createElement("span");n.className="char-counter",n.style.cssText=`
|
|
247
247
|
margin-top: 4px;
|
|
248
248
|
padding-right: 12px;
|
|
249
249
|
text-align: right;
|
|
@@ -252,11 +252,11 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
252
252
|
color: var(--fb-error-color);
|
|
253
253
|
pointer-events: none;
|
|
254
254
|
display: none;
|
|
255
|
-
`;const r=()=>{const o=t.value.length,a=e.maxLength;a!=null&&o>a?(n.textContent=`${o}/${a}`,n.style.display="block"):(n.textContent="",n.style.display="none")};return t.addEventListener("input",r),r(),n}function
|
|
255
|
+
`;const r=()=>{const o=t.value.length,a=e.maxLength;a!=null&&o>a?(n.textContent=`${o}/${a}`,n.style.display="block"):(n.textContent="",n.style.display="none")};return t.addEventListener("input",r),r(),n}function Fr(e,t,n,r){var o;const a=t.state,l=ae(e,a,t),i=document.createElement("div");i.style.cssText="position: relative;";const c=!l&&(e.minLength!=null||e.maxLength!=null),s=document.createElement("textarea");if(s.rows=1,s.className="w-full rounded-lg",s.style.cssText=`
|
|
256
256
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
257
257
|
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
258
258
|
border-radius: var(--fb-border-radius);
|
|
259
|
-
background-color: ${
|
|
259
|
+
background-color: ${l?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
|
|
260
260
|
color: var(--fb-text-color);
|
|
261
261
|
font-size: var(--fb-font-size);
|
|
262
262
|
font-family: var(--fb-font-family);
|
|
@@ -268,35 +268,35 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
268
268
|
overflow: hidden;
|
|
269
269
|
word-break: break-word;
|
|
270
270
|
overflow-wrap: anywhere;
|
|
271
|
-
`,s.name=r,s.placeholder=(o=e.placeholder)!=null?o:"
|
|
271
|
+
`,s.name=r,s.placeholder=(o=e.placeholder)!=null?o:k("placeholderText",a),s.value=t.prefill[e.key]||e.default||"",s.readOnly=l,en(s),ot(s),l||(s.addEventListener("focus",()=>{s.style.borderColor="var(--fb-border-focus-color)",s.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",s.style.outlineOffset="0"}),s.addEventListener("blur",()=>{s.style.borderColor="var(--fb-border-color)",s.style.outline="none"}),s.addEventListener("mouseenter",()=>{document.activeElement!==s&&(s.style.borderColor="var(--fb-border-hover-color)")}),s.addEventListener("mouseleave",()=>{document.activeElement!==s&&(s.style.borderColor="var(--fb-border-color)")})),!l&&t.instance){const f=()=>{const d=s.value===""?null:s.value;t.instance.triggerOnChange(r,d)};s.addEventListener("blur",f),s.addEventListener("input",f)}if(i.appendChild(s),c){const f=lt(e,s);i.appendChild(f)}n.appendChild(i)}function zr(e,t,n,r){var o,a;const l=t.state,i=ae(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:e.required?1:0,d=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"");Ar(document);const u=document.createElement("div");u.className="fb-chip-list",n.appendChild(u);function p(){u.querySelectorAll(".fb-chip-input").forEach((h,y)=>{h.name=`${r}[${y}]`;const v=h.closest(".fb-chip"),C=v==null?void 0:v.nextElementSibling;C&&C.classList.contains("error-message")&&(C.id=`error-${h.name}`)})}function m(h=""){const y=document.createElement("div");y.className="fb-chip";const v=document.createElement("span");v.className="fb-chip-dot",v.setAttribute("aria-hidden","true"),y.appendChild(v);const C=document.createElement("textarea");if(C.rows=1,C.className="fb-chip-input",C.value=h,C.placeholder=e.placeholder||k("placeholderText",l),C.readOnly=i,y.appendChild(C),!i&&t.instance){const w=()=>{t.instance.triggerOnChange(C.name,C.value===""?null:C.value)};C.addEventListener("blur",w),C.addEventListener("input",w)}if(en(C),ot(C),!i){const w=document.createElement("button");w.type="button",w.className="fb-chip-remove",w.setAttribute("aria-label",k("removeElement",l)),w.innerHTML=Qt,w.onclick=()=>{var x;const S=u.querySelectorAll(".fb-chip"),z=Array.prototype.indexOf.call(S,y);if(z<0||S.length<=f)return;s.splice(z,1);const ee=y.nextElementSibling;ee&&ee.classList.contains("error-message")&&ee.remove(),y.remove(),p(),E(),b(),(x=t.instance)==null||x.triggerOnChange(r)},y.appendChild(w)}return u.appendChild(y),p(),y}function b(){if(i)return;const h=u.querySelectorAll(".fb-chip").length<=f;u.querySelectorAll(".fb-chip-remove").forEach(y=>{y.disabled=h})}let g=null;if(!i){const h=ze("text",()=>{var y;s.push(e.default||""),m(e.default||""),E(),b(),(y=t.instance)==null||y.triggerOnChange(r)},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){g&&g(s.length,d)}s.forEach(h=>m(h)),E(),b()}function nn(e,t,n){var r,o,a;const l=[],{scopeRoot:i,skipValidation:c}=n,s=(d,u)=>{var p,m,b;if(!d)return;const g=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let E=document.getElementById(g);if(u){if(d.classList.add("invalid"),d.title=u,!E){E=document.createElement("div"),E.id=g,E.className="error-message",E.style.cssText=`
|
|
272
272
|
color: var(--fb-error-color);
|
|
273
273
|
font-size: var(--fb-font-size-small);
|
|
274
274
|
margin-top: 0.25rem;
|
|
275
|
-
`;const h=((p=
|
|
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=`
|
|
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
|
-
`,s.name=r,s.placeholder=(o=e.placeholder)!=null?o:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",s.value=t.prefill[e.key]||e.default||"",s.readOnly=
|
|
280
|
+
`,s.name=r,s.placeholder=(o=e.placeholder)!=null?o:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",s.value=t.prefill[e.key]||e.default||"",s.readOnly=i,!i&&t.instance){const f=()=>{const d=s.value===""?null:s.value;t.instance.triggerOnChange(r,d)};s.addEventListener("blur",f),s.addEventListener("input",f)}if(ot(s,{minRows:(a=e.rows)!=null?a:1}),c.appendChild(s),!i&&(e.minLength!=null||e.maxLength!=null)){const f=lt(e,s);c.appendChild(f)}n.appendChild(c)}function Nr(e,t,n,r){var o,a;const l=t.state,i=ae(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:e.required?1:0,d=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"");const u=document.createElement("div");u.className="fb-row",n.appendChild(u);function p(){u.querySelectorAll(".multiple-textarea-item").forEach((h,y)=>{const v=h.querySelector("textarea");v&&(v.name=`${r}[${y}]`)})}function m(h="",y=-1){var v;const C=document.createElement("div");C.className="multiple-textarea-item";const w=document.createElement("div");w.style.cssText="position: relative;";const x=document.createElement("textarea");if(x.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",x.style.cssText=`
|
|
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
|
-
`,x.placeholder=e.placeholder||k("placeholderText",
|
|
285
|
+
`,x.placeholder=e.placeholder||k("placeholderText",l),x.value=h,x.readOnly=i,!i&&t.instance){const S=()=>{const z=x.value===""?null:x.value;t.instance.triggerOnChange(x.name,z)};x.addEventListener("blur",S),x.addEventListener("input",S)}if(ot(x,{minRows:(v=e.rows)!=null?v:1}),w.appendChild(x),!i&&(e.minLength!=null||e.maxLength!=null)){const S=lt(e,x);w.appendChild(S)}return C.appendChild(w),y===-1?u.appendChild(C):u.insertBefore(C,u.children[y]),p(),C}function b(){if(i)return;const h=u.querySelectorAll(".multiple-textarea-item"),y=h.length;h.forEach(v=>{let C=v.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn mt-1 px-2 py-1 text-red-600 hover:bg-red-50 rounded text-sm",C.innerHTML="\u2715",C.onclick=()=>{var x;const S=Array.from(u.children).indexOf(v);u.children.length>f&&(s.splice(S,1),v.remove(),p(),E(),b(),(x=t.instance)==null||x.triggerOnChange(r))},v.appendChild(C));const w=y<=f;C.disabled=w,C.style.opacity=w?"0.5":"1",C.style.pointerEvents=w?"none":"auto"})}let g=null;if(!i){const h=ze("textarea",()=>{var y;s.push(e.default||""),m(e.default||""),E(),b(),(y=t.instance)==null||y.triggerOnChange(r)},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){g&&g(s.length,d)}s.forEach(h=>m(h)),E(),b()}function Ir(e,t,n){return nn(e,t,n)}function Rr(e,t,n,r){rn(e,t,n,r);const{scopeRoot:o}=r;if(e.multiple)o.querySelectorAll(`textarea[name^="${t}["]`).forEach(a=>{a.dispatchEvent(new Event("input"))});else{const a=o.querySelector(`textarea[name="${t}"]`);a&&a.dispatchEvent(new Event("input"))}}function qr(e){const t="fb-number-stepper-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
|
|
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 Br(e,t,n){var r;qr(e.ownerDocument);const o=(r=t.step)!=null?r:1,a=t.min,l=t.max,i=document.createElement("div");i.className="fb-stepper",i.style.cssText=`
|
|
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 c=(s,f)=>{const d=document.createElement("button");return d.type="button",d.textContent=s,d.tabIndex=-1,d.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?(d.disabled=!0,d.style.opacity="0.5"):d.addEventListener("click",u=>{var p;u.preventDefault();const m=parseFloat(e.value),b=Number.isFinite(m)?m:(p=a!=null?a:t.default)!=null?p:0;let g=parseFloat((b+f*o).toPrecision(12));a!=null&&(g=Math.max(a,g)),l!=null&&(g=Math.min(l,g)),e.value=String(g),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}),d};return e.classList.add("fb-stepper-input"),e.style.cssText=`
|
|
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
|
+
`,i.appendChild(c("\u2212",-1)),i.appendChild(e),i.appendChild(c("+",1)),i}function on(e,t){const n=document.createElement("span");n.className="number-range-hint",n.style.cssText=`
|
|
322
322
|
position: absolute;
|
|
323
323
|
top: 50%;
|
|
324
324
|
transform: translateY(-50%);
|
|
@@ -328,35 +328,35 @@ 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 a="";r!=null&&o!=null?a=`${r} \u2013 ${o}`:o!=null?a=`\u2264${o}`:r!=null&&(a=`\u2265${r}`),n.textContent=a;const
|
|
331
|
+
`;const r=e.min,o=e.max;let a="";r!=null&&o!=null?a=`${r} \u2013 ${o}`:o!=null?a=`\u2264${o}`:r!=null&&(a=`\u2265${r}`),n.textContent=a;const l=()=>{const i=t.value?parseFloat(t.value):null;if(i!=null){const c=r!=null&&i<r,s=o!=null&&i>o;n.style.color=c||s?"var(--fb-error-color)":"var(--fb-text-secondary-color)"}else n.style.color="var(--fb-text-secondary-color)"};return t.addEventListener("input",l),l(),n}function Hr(e,t,n,r){const o=t.state,a=ae(e,o,t),l=document.createElement("div");l.style.cssText="position: relative;";const i=document.createElement("input");if(i.type="number",i.name=r,i.placeholder=e.placeholder||"0",e.min!==void 0&&(i.min=e.min.toString()),e.max!==void 0&&(i.max=e.max.toString()),e.step!==void 0&&(i.step=e.step.toString()),i.value=t.prefill[e.key]||e.default||"",i.readOnly=a,e.stepper||(i.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",i.style.cssText=`
|
|
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
|
-
`),!a&&t.instance){const
|
|
337
|
+
`),!a&&t.instance){const c=()=>{const s=i.value?parseFloat(i.value):null;t.instance.triggerOnChange(r,s)};i.addEventListener("blur",c),i.addEventListener("input",c)}if(e.stepper)l.appendChild(Br(i,e,a));else if(l.appendChild(i),!a&&(e.min!=null||e.max!=null)){const c=on(e,i);l.appendChild(c)}n.appendChild(l)}function Dr(e,t,n,r){var o,a;const l=t.state,i=ae(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:e.required?1:0,d=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"");const u=document.createElement("div");u.className="fb-row",n.appendChild(u);function p(){u.querySelectorAll(".multiple-number-item").forEach((h,y)=>{const v=h.querySelector("input");v&&(v.name=`${r}[${y}]`)})}function m(h="",y=-1){const v=document.createElement("div");v.className="multiple-number-item flex items-center gap-2";const C=document.createElement("div");C.style.cssText="position: relative; flex: 1;";const w=document.createElement("input");if(w.type="number",w.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",w.style.cssText=`
|
|
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||"0",e.min!==void 0&&(w.min=e.min.toString()),e.max!==void 0&&(w.max=e.max.toString()),e.step!==void 0&&(w.step=e.step.toString()),w.value=h.toString(),w.readOnly=
|
|
343
|
+
`,w.placeholder=e.placeholder||"0",e.min!==void 0&&(w.min=e.min.toString()),e.max!==void 0&&(w.max=e.max.toString()),e.step!==void 0&&(w.step=e.step.toString()),w.value=h.toString(),w.readOnly=i,!i&&t.instance){const x=()=>{const S=w.value?parseFloat(w.value):null;t.instance.triggerOnChange(w.name,S)};w.addEventListener("blur",x),w.addEventListener("input",x)}if(C.appendChild(w),!i&&(e.min!=null||e.max!=null)){const x=on(e,w);C.appendChild(x)}return v.appendChild(C),y===-1?u.appendChild(v):u.insertBefore(v,u.children[y]),p(),v}function b(){if(i)return;const h=u.querySelectorAll(".multiple-number-item"),y=h.length;h.forEach(v=>{let C=v.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",C.innerHTML="\u2715",C.onclick=()=>{var x;const S=Array.from(u.children).indexOf(v);u.children.length>f&&(s.splice(S,1),v.remove(),p(),E(),b(),(x=t.instance)==null||x.triggerOnChange(r))},v.appendChild(C));const w=y<=f;C.disabled=w,C.style.opacity=w?"0.5":"1",C.style.pointerEvents=w?"none":"auto"})}let g=null;if(!i){const h=ze("number",()=>{var y;s.push(e.default||""),m(e.default||""),E(),b(),(y=t.instance)==null||y.triggerOnChange(r)},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){g&&g(s.length,d)}s.forEach(h=>m(h)),E(),b()}function jr(e,t,n){var r,o,a;const l=[],{scopeRoot:i,skipValidation:c}=n,s=(d,u)=>{var p,m;if(!d)return;const b=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(b);u?(d.classList.add("invalid"),d.title=u,g||(g=document.createElement("div"),g.id=b,g.className="error-message",g.style.cssText=`
|
|
344
344
|
color: var(--fb-error-color);
|
|
345
345
|
font-size: var(--fb-font-size-small);
|
|
346
346
|
margin-top: 0.25rem;
|
|
347
|
-
`,
|
|
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=`
|
|
348
348
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
349
349
|
font-size: var(--fb-font-size);
|
|
350
350
|
font-family: var(--fb-font-family);
|
|
351
|
-
`,
|
|
351
|
+
`,l.name=r,l.disabled=a,(e.options||[]).forEach(i=>{const c=document.createElement("option");c.value=i.value,c.textContent=i.label,(t.prefill[e.key]||e.default)===i.value&&(c.selected=!0),l.appendChild(c)}),!a&&t.instance){const i=()=>{t.instance.triggerOnChange(r,l.value)};l.addEventListener("change",i)}if(n.appendChild(l),!a){const i=document.createElement("p");i.className="text-xs text-gray-500 mt-1",i.textContent=Le(e,o),n.appendChild(i)}}function Pr(e,t,n,r){var o,a,l,i;const c=t.state,s=ae(e,c,t),f=t.prefill[e.key]||[],d=Array.isArray(f)?[...f]:[],u=(o=e.minCount)!=null?o:e.required?1:0,p=(a=e.maxCount)!=null?a:1/0;for(;d.length<u;)d.push(e.default||((i=(l=e.options)==null?void 0:l[0])==null?void 0:i.value)||"");const m=document.createElement("div");m.className="fb-row",n.appendChild(m);function b(){m.querySelectorAll(".multiple-select-item").forEach((v,C)=>{const w=v.querySelector("select");w&&(w.name=`${r}[${C}]`)})}function g(v="",C=-1){const w=document.createElement("div");w.className="multiple-select-item flex items-center gap-2";const x=document.createElement("select");if(x.className="flex-1 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",x.style.cssText=`
|
|
352
352
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
353
353
|
font-size: var(--fb-font-size);
|
|
354
354
|
font-family: var(--fb-font-family);
|
|
355
|
-
`,x.disabled=s,(e.options||[]).forEach(S=>{const z=document.createElement("option");z.value=S.value,z.textContent=S.label,
|
|
355
|
+
`,x.disabled=s,(e.options||[]).forEach(S=>{const z=document.createElement("option");z.value=S.value,z.textContent=S.label,v===S.value&&(z.selected=!0),x.appendChild(z)}),!s&&t.instance){const S=()=>{t.instance.triggerOnChange(x.name,x.value)};x.addEventListener("change",S)}return w.appendChild(x),C===-1?m.appendChild(w):m.insertBefore(w,m.children[C]),b(),w}function E(){if(s)return;const v=m.querySelectorAll(".multiple-select-item"),C=v.length;v.forEach(w=>{let x=w.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",x.innerHTML="\u2715",x.onclick=()=>{var z;const ee=Array.from(m.children).indexOf(w);m.children.length>u&&(d.splice(ee,1),w.remove(),b(),y(),E(),(z=t.instance)==null||z.triggerOnChange(r))},w.appendChild(x));const S=C<=u;x.disabled=S,x.style.opacity=S?"0.5":"1",x.style.pointerEvents=S?"none":"auto"})}let h=null;if(!s){const v=ze("select",()=>{var C,w,x;const S=e.default||((w=(C=e.options)==null?void 0:C[0])==null?void 0:w.value)||"";d.push(S),g(S),y(),E(),(x=t.instance)==null||x.triggerOnChange(r)},{label:e.addLabel});h=v.update,Te(n,v.counter),n.appendChild(v.row)}function y(){h&&h(d.length,p)}if(d.forEach(v=>g(v)),y(),E(),!s){const v=document.createElement("p");v.className="text-xs text-gray-500 mt-1",v.textContent=Le(e,c),n.appendChild(v)}}function Wr(e,t,n){var r;const o=[],{scopeRoot:a,skipValidation:l}=n,i=(s,f)=>{var d,u;if(!s)return;const p=`error-${s.getAttribute("name")||Math.random().toString(36).substring(7)}`;let m=document.getElementById(p);f?(s.classList.add("invalid"),s.title=f,m||(m=document.createElement("div"),m.id=p,m.className="error-message",m.style.cssText=`
|
|
356
356
|
color: var(--fb-error-color);
|
|
357
357
|
font-size: var(--fb-font-size-small);
|
|
358
358
|
margin-top: 0.25rem;
|
|
359
|
-
`,s.nextSibling?(
|
|
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=`
|
|
360
360
|
display: inline-flex;
|
|
361
361
|
align-items: center;
|
|
362
362
|
gap: 8px;
|
|
@@ -381,7 +381,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
381
381
|
font-size: var(--fb-font-size-small);
|
|
382
382
|
opacity: 0.7;
|
|
383
383
|
font-variant-numeric: tabular-nums;
|
|
384
|
-
`,n.appendChild(o)}return n}function sn(e,t,n,r,o){const a=e.options||[],
|
|
384
|
+
`,n.appendChild(o)}return n}function sn(e,t,n,r,o){const a=e.options||[],l=a.some(s=>s.subtitle||s.iconUrl),i=document.createElement("div");i.className="fb-switcher-group",i.style.cssText=l?`
|
|
385
385
|
display: flex;
|
|
386
386
|
flex-direction: row;
|
|
387
387
|
flex-wrap: wrap;
|
|
@@ -390,7 +390,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
390
390
|
display: inline-flex;
|
|
391
391
|
flex-direction: row;
|
|
392
392
|
flex-wrap: nowrap;
|
|
393
|
-
`;const
|
|
393
|
+
`;const c=[];return a.forEach((s,f)=>{let d;l?d=Kr(s,r):(d=document.createElement("button"),d.type="button",d.className="fb-switcher-btn",d.dataset.value=s.value,d.textContent=s.label,d.style.cssText=`
|
|
394
394
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
395
395
|
font-size: var(--fb-font-size);
|
|
396
396
|
border-width: var(--fb-border-width);
|
|
@@ -400,21 +400,21 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
400
400
|
white-space: nowrap;
|
|
401
401
|
line-height: 1.25;
|
|
402
402
|
outline: none;
|
|
403
|
-
`,a.length===1?
|
|
403
|
+
`,a.length===1?d.style.borderRadius="var(--fb-border-radius)":f===0?(d.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",d.style.borderRightWidth="0"):f===a.length-1?d.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(d.style.borderRadius="0",d.style.borderRightWidth="0")),s.value===t?it(d,l):at(d,l),r||(d.addEventListener("click",()=>{n.value=s.value,c.forEach(u=>{u.dataset.value===s.value?it(u,l):at(u,l)}),o&&o(s.value)}),d.addEventListener("mouseenter",()=>{n.value!==s.value&&(d.style.backgroundColor="var(--fb-background-hover-color)")}),d.addEventListener("mouseleave",()=>{n.value!==s.value&&(d.style.backgroundColor=l?"var(--fb-background-color)":"transparent")})),c.push(d),i.appendChild(d)}),i}function _r(e,t,n,r){var o,a;const l=t.state,i=String((a=(o=t.prefill[e.key])!=null?o:e.default)!=null?a:""),c=document.createElement("input");c.type="hidden",c.name=r,c.value=i;const s=ae(e,l,t),f=!s&&t.instance?u=>{t.instance.triggerOnChange(r,u)}:null,d=sn(e,i,c,s,f);if(n.appendChild(c),n.appendChild(d),!s){const u=document.createElement("p");u.className="text-xs text-gray-500 mt-1",u.textContent=Le(e,l),n.appendChild(u)}}function Jr(e,t,n,r){var o,a,l,i;const c=t.state,s=t.prefill[e.key]||[],f=Array.isArray(s)?[...s]:[],d=(o=e.minCount)!=null?o:e.required?1:0,u=(a=e.maxCount)!=null?a:1/0;for(;f.length<d;)f.push(e.default||((i=(l=e.options)==null?void 0:l[0])==null?void 0:i.value)||"");const p=ae(e,c,t),m=document.createElement("div");m.className="fb-row",n.appendChild(m);function b(){m.querySelectorAll(".multiple-switcher-item").forEach((v,C)=>{const w=v.querySelector("input[type=hidden]");w&&(w.name=`${r}[${C}]`)})}function g(v="",C=-1){const w=C===-1?m.children.length:C,x=`${r}[${w}]`,S=document.createElement("div");S.className="multiple-switcher-item flex items-center gap-2";const z=document.createElement("input");z.type="hidden",z.name=x,z.value=v,S.appendChild(z);const ee=!p&&t.instance?H=>{t.instance.triggerOnChange(z.name,H)}:null,K=sn(e,v,z,p,ee);return S.appendChild(K),C===-1?m.appendChild(S):m.insertBefore(S,m.children[C]),b(),S}function E(){if(p)return;const v=m.querySelectorAll(".multiple-switcher-item"),C=v.length;v.forEach(w=>{let x=w.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 rounded",x.style.cssText=`
|
|
404
404
|
color: var(--fb-error-color);
|
|
405
405
|
background-color: transparent;
|
|
406
406
|
transition: background-color var(--fb-transition-duration);
|
|
407
|
-
`,x.innerHTML="\u2715",x.addEventListener("mouseenter",()=>{x.style.backgroundColor="var(--fb-background-hover-color)"}),x.addEventListener("mouseleave",()=>{x.style.backgroundColor="transparent"}),x.onclick=()=>{const
|
|
407
|
+
`,x.innerHTML="\u2715",x.addEventListener("mouseenter",()=>{x.style.backgroundColor="var(--fb-background-hover-color)"}),x.addEventListener("mouseleave",()=>{x.style.backgroundColor="transparent"}),x.onclick=()=>{var z;const ee=Array.from(m.children).indexOf(w);m.children.length>d&&(f.splice(ee,1),w.remove(),b(),y(),E(),(z=t.instance)==null||z.triggerOnChange(r))},w.appendChild(x));const S=C<=d;x.disabled=S,x.style.opacity=S?"0.5":"1",x.style.pointerEvents=S?"none":"auto"})}let h=null;if(!p){const v=ze("switcher",()=>{var C,w,x;const S=e.default||((w=(C=e.options)==null?void 0:C[0])==null?void 0:w.value)||"";f.push(S),g(S),y(),E(),(x=t.instance)==null||x.triggerOnChange(r)},{label:e.addLabel});h=v.update,Te(n,v.counter),n.appendChild(v.row)}function y(){h&&h(f.length,u)}if(f.forEach(v=>g(v)),y(),E(),!p){const v=document.createElement("p");v.className="text-xs text-gray-500 mt-1",v.textContent=Le(e,c),n.appendChild(v)}}function Xr(e,t,n){var r;const o=[],{scopeRoot:a,skipValidation:l}=n,i=(f,d)=>{var u,p;if(!f)return;const m=`error-${f.getAttribute("name")||Math.random().toString(36).substring(7)}`;let b=document.getElementById(m);d?(f.classList.add("invalid"),f.title=d,b||(b=document.createElement("div"),b.id=m,b.className="error-message",b.style.cssText=`
|
|
408
408
|
color: var(--fb-error-color);
|
|
409
409
|
font-size: var(--fb-font-size-small);
|
|
410
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=
|
|
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=`
|
|
412
412
|
.fb-toggle {
|
|
413
413
|
position: relative;
|
|
414
414
|
display: inline-block;
|
|
415
|
-
width: ${
|
|
416
|
-
height: ${
|
|
417
|
-
border-radius: ${
|
|
415
|
+
width: ${cn}px;
|
|
416
|
+
height: ${Xe}px;
|
|
417
|
+
border-radius: ${Xe}px;
|
|
418
418
|
background: var(--fb-border-color);
|
|
419
419
|
transition: background-color var(--fb-transition-duration);
|
|
420
420
|
flex-shrink: 0;
|
|
@@ -422,8 +422,8 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
422
422
|
.fb-toggle::after {
|
|
423
423
|
content: "";
|
|
424
424
|
position: absolute;
|
|
425
|
-
top: ${(
|
|
426
|
-
left: ${(
|
|
425
|
+
top: ${(Xe-Oe)/2}px;
|
|
426
|
+
left: ${(Xe-Oe)/2}px;
|
|
427
427
|
width: ${Oe}px;
|
|
428
428
|
height: ${Oe}px;
|
|
429
429
|
border-radius: 50%;
|
|
@@ -435,7 +435,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
435
435
|
background: var(--fb-primary-color);
|
|
436
436
|
}
|
|
437
437
|
.fb-toggle.fb-on::after {
|
|
438
|
-
transform: translateX(${
|
|
438
|
+
transform: translateX(${cn-Oe-(Xe-Oe)}px);
|
|
439
439
|
}
|
|
440
440
|
.fb-toggle-row {
|
|
441
441
|
display: flex;
|
|
@@ -488,7 +488,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
488
488
|
font-family: serif;
|
|
489
489
|
cursor: help;
|
|
490
490
|
}
|
|
491
|
-
`,e.head.appendChild(n)}function
|
|
491
|
+
`,e.head.appendChild(n)}function $t(e){return typeof e=="boolean"?e:typeof e=="string"?e==="true"||e==="on"||e==="1":!1}function Zr(e,t,n,r){var o;Gr(document);const a=t.state,l=ae(e,a,t),i=t.prefill[e.key],c=$t(i!==void 0?i:e.default),s=document.createElement("input");s.type="hidden",s.name=r,s.value=c?"true":"false";const f=document.createElement("div");f.className="fb-toggle-row",f.setAttribute("role","switch"),f.setAttribute("aria-checked",c?"true":"false"),l?f.setAttribute("aria-disabled","true"):f.tabIndex=0;const d=document.createElement("span");d.className="fb-toggle"+(c?" fb-on":""),d.setAttribute("aria-hidden","true"),f.appendChild(d);const u=document.createElement("div");u.className="fb-toggle-text";const p=document.createElement("div");if(p.className="fb-toggle-title",p.appendChild(document.createTextNode((o=e.label)!=null?o:"")),e.description){const m=document.createElement("span");m.className="fb-toggle-info",m.textContent="i",m.title=e.description,p.appendChild(m)}if(u.appendChild(p),e.hint){const m=document.createElement("div");m.className="fb-toggle-subtitle",m.textContent=e.hint,u.appendChild(m)}if(f.appendChild(u),!l){const m=()=>{const b=s.value!=="true";s.value=b?"true":"false",d.classList.toggle("fb-on",b),f.setAttribute("aria-checked",b?"true":"false"),t.instance&&t.instance.triggerOnChange(r,b)};f.addEventListener("click",b=>{var g;(g=b.target)!=null&&g.classList.contains("fb-toggle-info")||m()}),f.addEventListener("keydown",b=>{(b.key===" "||b.key==="Enter")&&(b.preventDefault(),m())})}n.appendChild(s),n.appendChild(f)}function Qr(e,t,n){var r;const{scopeRoot:o}=n,a=o.querySelector(`input[type="hidden"][name="${t}"]`),l=(r=a==null?void 0:a.value)!=null?r:"";return{value:$t(l),errors:[]}}function eo(e,t,n,r){var o;const{scopeRoot:a}=r,l=a.querySelector(`input[type="hidden"][name="${t}"]`);if(!l)return;const i=$t(n);l.value=i?"true":"false";const c=(o=l.parentElement)==null?void 0:o.querySelector(".fb-toggle-row");if(c){c.setAttribute("aria-checked",i?"true":"false");const s=c.querySelector(".fb-toggle");s&&s.classList.toggle("fb-on",i)}}function Re(e){return e?typeof e=="object"&&Array.isArray(e.extensions)?e.extensions.map(t=>t.toLowerCase()):typeof e=="string"?e.split(",").map(t=>t.trim()).filter(t=>t.startsWith(".")).map(t=>t.substring(1).toLowerCase()):[]:[]}function Ue(e,t){var n,r;if(t.length===0)return!0;const o=(r=(n=e.split(".").pop())==null?void 0:n.toLowerCase())!=null?r:"";return t.includes(o)}function dn(e,t){return t===1/0?!0:e<=t*1024*1024}function st(e,t){return dn(e.size,t)}function Ye(e){return e?typeof e=="string"?[]:Array.isArray(e.mime)?e.mime.map(t=>t.toLowerCase()):[]:[]}function Ge(e,t){if(t.length===0)return!0;const n=e.toLowerCase();return t.some(r=>{if(r.endsWith("/*")){const o=r.slice(0,-1);return n.startsWith(o)}return n===r})}function to(e){var t;const n=(t=(e.split("/").pop()||"file").split(".").pop())==null?void 0:t.toLowerCase();if(n){if(["jpg","jpeg","png","gif","webp"].includes(n))return`image/${n==="jpg"?"jpeg":n}`;if(["mp4","webm","mov","avi"].includes(n))return`video/${n==="mov"?"quicktime":n}`}return"application/octet-stream"}function ct(e,t){if(t.has(e))return;const n=e.split("/").pop()||"file";t.set(e,{name:n,type:to(e),size:0,uploadedAt:new Date,file:void 0,inferredFromExtension:!0})}function St(e,t){for(const n of e)ct(n,t)}const un="fb-file-styles";function $e(){if(typeof document=="undefined"||document.getElementById(un))return;const e=document.createElement("style");if(e.id=un,e.setAttribute("data-fb-file-styles","true"),e.textContent=`
|
|
492
492
|
@keyframes fb-spin { to { transform: rotate(360deg); } }
|
|
493
493
|
|
|
494
494
|
/* \u2500\u2500\u2500 Checker background utility \u2500\u2500\u2500 */
|
|
@@ -979,12 +979,12 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
979
979
|
color: var(--fb-error-color);
|
|
980
980
|
font-size: var(--fb-font-size-small);
|
|
981
981
|
margin-top: 0.25rem;
|
|
982
|
-
`,a.textContent=t,(r=e.closest("[data-files-wrapper]"))==null||r.appendChild(a)}function Ze(e){var t;const n=(t=e.closest("[data-files-wrapper]"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}function
|
|
982
|
+
`,a.textContent=t,(r=e.closest("[data-files-wrapper]"))==null||r.appendChild(a)}function Ze(e){var t;const n=(t=e.closest("[data-files-wrapper]"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}function no(e,t,n){const r=e.querySelector(".delete-overlay");r&&r.remove();const o=document.createElement("div");o.className="delete-overlay absolute inset-0 bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center";const a=document.createElement("button");a.className="bg-red-600 text-white px-3 py-1 rounded text-sm hover:bg-red-700 transition-colors",a.textContent=k("removeElement",t),a.onclick=l=>{l.stopPropagation(),n()},o.appendChild(a),e.appendChild(o)}function ro(e,t){$e();const n=fn();n.classList.add("fb-tile-uploading"),n.className+=" fb-uploading-tile";const r=e.length>10?e.substring(0,8)+"\u2026":e;return n.innerHTML=`
|
|
983
983
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:4px;">
|
|
984
984
|
<div class="fb-spinner"></div>
|
|
985
985
|
<div class="fb-tile-label">${se(r)}</div>
|
|
986
986
|
<div class="fb-tile-uploading-text">${se(k("uploadingFile",t))}</div>
|
|
987
|
-
</div>`,n}function
|
|
987
|
+
</div>`,n}function Lt(e){var t,n,r;const o=e.querySelector(".fb-multi-grid");if(o)return o;const a=e.querySelector(".fb-tiles-wrap");if(a)return a;(t=e.querySelector(".fb-file-dropzone"))==null||t.remove(),(n=e.querySelector(".fb-wide-tile"))==null||n.remove(),(r=e.querySelector(".fb-multi-outer"))==null||r.remove();const l=document.createElement("div");l.className="fb-tiles-wrap",l.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";const i=document.createElement("div");return i.className="fb-tile fb-tile-add",i.innerHTML="+",l.appendChild(i),e.appendChild(l),l}function Tt(e,t,n){e.innerHTML=`
|
|
988
988
|
<div class="flex flex-col items-center justify-center h-full text-gray-400">
|
|
989
989
|
<svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
|
|
990
990
|
<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"/>
|
|
@@ -992,9 +992,9 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
992
992
|
<div class="text-sm text-center">${se(k("clickDragText",t))}</div>
|
|
993
993
|
|
|
994
994
|
</div>
|
|
995
|
-
`}const pn=new WeakMap;function dt(e,t){const n=pn.get(e);n&&(e.removeEventListener("dragover",n.dragover),e.removeEventListener("dragleave",n.dragleave),e.removeEventListener("drop",n.drop));const r=
|
|
995
|
+
`}const pn=new WeakMap;function dt(e,t){const n=pn.get(e);n&&(e.removeEventListener("dragover",n.dragover),e.removeEventListener("dragleave",n.dragleave),e.removeEventListener("drop",n.drop));const r=l=>{l.preventDefault(),e.classList.add("border-blue-500","bg-blue-50")},o=l=>{l.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50")},a=l=>{var i;l.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50");const c=(i=l.dataTransfer)==null?void 0:i.files;c&&t(c)};e.addEventListener("dragover",r),e.addEventListener("dragleave",o),e.addEventListener("drop",a),pn.set(e,{dragover:r,dragleave:o,drop:a})}const oo='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',lo='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',io='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"/></svg>',ao='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',so='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function co(e,t){return!!(e.config.downloadFile||e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function uo(e,t){return!!(e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function At(e){const{canRemove:t,removeHandler:n,state:r,resourceId:o,fileName:a,meta:l,replaceHandler:i,libraryHandler:c}=e,s=document.createElement("div");s.className="fb-tile-actions";const f=(d,u,p)=>{const m=document.createElement("button");return m.type="button",m.className=`fb-tile-action-btn ${p}`,m.innerHTML=d,m.title=u,m.setAttribute("aria-label",u),m.addEventListener("click",b=>{b.stopPropagation()}),m};if(i){const d=f(ao,k("replaceFile",r),"fb-tile-action-replace");d.addEventListener("click",()=>i()),s.appendChild(d)}if(c){const d=f(so,k("fromLibrary",r),"fb-tile-action-library");d.addEventListener("click",()=>c()),s.appendChild(d)}if(co(r,l)){const d=f(oo,k("downloadFile",r),"fb-tile-action-download");d.addEventListener("click",()=>{fo(o,a,r,l)}),s.appendChild(d)}if(uo(r,l)){const d=f(lo,k("openInNewTab",r),"fb-tile-action-open");d.addEventListener("click",()=>{po(o,r,l).catch(u=>{console.error("Open failed:",u)})}),s.appendChild(d)}if(t&&n){const d=f(io,k("removeElement",r),"fb-tile-action-remove");d.addEventListener("click",()=>{n()}),s.appendChild(d)}return s}const ut=new WeakMap;function Ft(e){let t=ut.get(e);return t||(t=URL.createObjectURL(e),ut.set(e,t)),t}function qe(e){if(!e)return;const t=ut.get(e);t&&(URL.revokeObjectURL(t),ut.delete(e))}function fo(e,t,n,r){if(n.config.downloadFile){n.config.downloadFile(e,t);return}if((r==null?void 0:r.file)instanceof File){xn(r.file,t||r.file.name);return}yn(e,t,n).catch(o=>{console.error("Download failed:",o)})}async function po(e,t,n){let r=null;t.config.getDownloadUrl?r=t.config.getDownloadUrl(e):t.config.getThumbnail?r=await t.config.getThumbnail(e):(n==null?void 0:n.file)instanceof File&&(r=Ft(n.file)),r&&window.open(r,"_blank")}let Ee=null,Me=null,Be=null,ft=null;function mo(){if(!Ee){Ee=document.createElement("div"),Ee.className="fb-tile-zoom-preview";const e=document.createElement("img");e.className="fb-tile-zoom-preview-img",Ee.appendChild(e),Ee.addEventListener("mouseenter",hn),Ee.addEventListener("mouseleave",mn)}return Ee}function ho(e,t){const n=t.getBoundingClientRect(),r=350,o=6,a=8;let l;n.top-r-o>=a?l=n.top-r-o:n.bottom+o+r+a<=window.innerHeight?l=n.bottom+o:l=Math.max(a,Math.min(window.innerHeight-r-a,n.top));let i=n.left+n.width/2-r/2;i=Math.max(a,Math.min(window.innerWidth-r-a,i)),e.style.top=`${l}px`,e.style.left=`${i}px`}function mn(){Be!==null&&clearTimeout(Be),Be=setTimeout(()=>{Be=null,bn()},100)}function hn(){Be!==null&&(clearTimeout(Be),Be=null)}function bn(){Me!==null&&(clearTimeout(Me),Me=null),Ee&&Ee.parentNode&&(Ee.classList.remove("fb-tile-zoom-preview--visible"),Ee.parentNode.removeChild(Ee)),ft=null}function zt(e,t,n,r){e.dataset.zoomSrc=t,e.dataset.zoomAlt=n,e.addEventListener("mouseenter",()=>{hn(),ft!==e&&bn(),ft=e,Me=setTimeout(()=>{Me=null;const o=mo(),a=o.querySelector(".fb-tile-actions");a&&a.remove();const l=o.querySelector(".fb-tile-zoom-preview-img");l.src=t,l.alt=n,r&&(o.appendChild(r.cloneNode(!0)),bo(o.querySelector(".fb-tile-actions"),r)),o.style.pointerEvents="auto",ho(o,e),document.body.appendChild(o),o.getBoundingClientRect(),o.classList.add("fb-tile-zoom-preview--visible")},200)}),e.addEventListener("mouseleave",()=>{Me!==null?(clearTimeout(Me),Me=null,ft=null):mn()})}function bo(e,t){const n=Array.from(t.querySelectorAll(".fb-tile-action-btn"));Array.from(e.querySelectorAll(".fb-tile-action-btn")).forEach((r,o)=>{const a=n[o];a&&r.addEventListener("click",l=>{l.stopPropagation(),a.click()})})}function go(e,t,n,r){const o=document.createElement("img");o.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",o.alt=n||k("previewAlt",r);const a=new FileReader;a.onload=l=>{var i;o.src=((i=l.target)==null?void 0:i.result)||""},a.readAsDataURL(t),e.appendChild(o)}function vo(e,t){e.onclick=null;const n=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(n,e),n}function yo(e,t,n,r,o,a){const l=URL.createObjectURL(t),i=vo(e);return i.innerHTML=`
|
|
996
996
|
<div class="fb-video-preview-wrap">
|
|
997
|
-
<video style="width:100%;height:100%;object-fit:contain;" controls preload="auto" muted src="${
|
|
997
|
+
<video style="width:100%;height:100%;object-fit:contain;" controls preload="auto" muted src="${l}">
|
|
998
998
|
${se(k("videoNotSupported",o))}
|
|
999
999
|
</video>
|
|
1000
1000
|
<div class="fb-video-btn-overlay">
|
|
@@ -1006,59 +1006,59 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1006
1006
|
</button>
|
|
1007
1007
|
</div>
|
|
1008
1008
|
</div>
|
|
1009
|
-
`,
|
|
1009
|
+
`,xo(i,r,o,a),i}function xo(e,t,n,r){const o=e.querySelector(".change-file-btn");o&&(o.onclick=l=>{var i;l.stopPropagation(),(i=r==null?void 0:r.picker)==null||i.click()});const a=e.querySelector(".delete-file-btn");a&&(a.onclick=l=>{l.stopPropagation(),wo(e,t,n,r)})}function wo(e,t,n,r){var o;n.resourceIndex.delete(t);const a=(o=e.parentElement)==null?void 0:o.querySelector('input[type="hidden"]');a&&(a.value=""),r!=null&&r.fileUploadHandler&&(e.onclick=r.fileUploadHandler),e.innerHTML=`
|
|
1010
1010
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
|
|
1011
1011
|
<svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
|
|
1012
1012
|
<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
1013
|
</svg>
|
|
1014
1014
|
<div style="font-size:0.875rem;text-align:center;">${se(k("clickDragText",n))}</div>
|
|
1015
1015
|
</div>
|
|
1016
|
-
`,r!=null&&r.setupDrop&&r.setupDrop(e)}function
|
|
1016
|
+
`,r!=null&&r.setupDrop&&r.setupDrop(e)}function gn(e,t,n){no(e,n,()=>{var r;n.resourceIndex.delete(t);const o=(r=e.parentElement)==null?void 0:r.querySelector('input[type="hidden"]');o&&(o.value=""),e.innerHTML=`
|
|
1017
1017
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
|
|
1018
1018
|
<svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
|
|
1019
1019
|
<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
1020
|
</svg>
|
|
1021
1021
|
<div style="font-size:0.875rem;text-align:center;">${se(k("clickDragText",n))}</div>
|
|
1022
1022
|
</div>
|
|
1023
|
-
`})}async function
|
|
1023
|
+
`})}async function Co(e,t,n,r,o,a,l){var i,c,s;!t.file||!(t.file instanceof File)||((i=t.type)!=null&&i.startsWith("image/")?go(e,t.file,n,a):(c=t.type)!=null&&c.startsWith("video/")?e=yo(e,t.file,t.type,r,a,l):e.innerHTML=`<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);"><div style="font-size:36px;margin-bottom:0.5rem;">\u{1F4C1}</div><div style="font-size:0.875rem;">${se(n)}</div></div>`,!o&&!((s=t.type)!=null&&s.startsWith("video/"))&&gn(e,r,a))}function Eo(e,t,n){const r=document.createElement("video");r.style.cssText="width:100%;height:100%;object-fit:contain;",r.controls=!0,r.preload="metadata",r.muted=!0,r.src=t,r.appendChild(document.createTextNode(k("videoNotSupported",n))),e.appendChild(r)}async function ko(e,t,n,r,o){var a;if(!o.config.getThumbnail){Tt(e,o);return}try{const l=await o.config.getThumbnail(t);if(l)if(we(e),(a=r==null?void 0:r.type)!=null&&a.startsWith("video/"))Eo(e,l,o);else{const i=document.createElement("img");i.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",i.alt=n||k("previewAlt",o),i.src=l,e.appendChild(i)}else Tt(e,o)}catch(l){console.error("Failed to get thumbnail:",l),e.innerHTML=`
|
|
1024
1024
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
|
|
1025
1025
|
<svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
|
|
1026
1026
|
<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
1027
|
</svg>
|
|
1028
1028
|
<div style="font-size:0.875rem;text-align:center;">${se(n||k("previewUnavailable",o))}</div>
|
|
1029
1029
|
</div>
|
|
1030
|
-
`}}async function
|
|
1031
|
-
<img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${se(
|
|
1030
|
+
`}}async function Mt(e,t,n,r={}){var o;const{fileName:a="",isReadonly:l=!1,deps:i=null}=r;if(!l&&i&&(!i.picker||!i.fileUploadHandler||!i.dragHandler))throw new Error("renderFilePreview: missing deps {picker, fileUploadHandler, dragHandler}");we(e);const c=n.resourceIndex.get(t);if(c&&c.file&&c.file instanceof File)await Co(e,c,a,t,l,n,i);else{await ko(e,t,a,c,n);const s=(o=c==null?void 0:c.type)==null?void 0:o.startsWith("video/");!l&&!s&&gn(e,t,n)}}function $o(e,t,n){var r;if(n)return n;if((r=t==null?void 0:t.name)!=null&&r.includes("."))return t.name;const o=e.includes("/")?e.split("/").pop():e;return o!=null&&o.includes(".")?o:""}async function Nt(e,t,n,r={}){var o,a;const l=t.resourceIndex.get(e),i=$o(e,l,n),{canRemove:c=!1,removeHandler:s=null}=r,f=((o=l==null?void 0:l.type)==null?void 0:o.startsWith("image/"))||!!i.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/),d=((a=l==null?void 0:l.type)==null?void 0:a.startsWith("video/"))||!!i.toLowerCase().match(/\.(mp4|webm|avi|mov)$/),u=fn();u.classList.add("fb-tile-resource"),u.style.cursor="pointer",i&&(u.title=i);const p=(l==null?void 0:l.file)instanceof File?Ft(l.file):null,m=async()=>t.config.getDownloadUrl?t.config.getDownloadUrl(e):t.config.getThumbnail?t.config.getThumbnail(e):p;u.onclick=async()=>{const h=await m();h?window.open(h,"_blank"):t.config.downloadFile?t.config.downloadFile(e,i):yn(e,i,t).catch(y=>{console.error("Download failed:",y)})};const b=At({canRemove:c,removeHandler:s,state:t,resourceId:e,fileName:i,meta:l}),g=async()=>{if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);if(h)return h}catch(h){}return p},E=()=>{u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>',u.appendChild(b)};if(f){const h=await g();if(h){const y=document.createElement("img");y.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",y.alt=i,y.src=h,u.appendChild(y),u.appendChild(b),zt(u,h,i,b)}else E()}else if(d)if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);h?(u.innerHTML=`
|
|
1031
|
+
<img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${se(i)}" src="${h}">
|
|
1032
1032
|
<div class="fb-video-overlay">
|
|
1033
1033
|
<div class="fb-play-btn" style="width:22px;height:22px;">
|
|
1034
1034
|
<svg width="10" height="12" viewBox="0 0 10 12" fill="currentColor"><path d="M0 0l10 6-10 6z"/></svg>
|
|
1035
1035
|
</div>
|
|
1036
|
-
</div>`,u.appendChild(b)):(u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',u.appendChild(b))}catch(h){u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',u.appendChild(b)}else u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',u.appendChild(b);else{if(t.config.getThumbnail)try{const y=await t.config.getThumbnail(e);if(y){const
|
|
1036
|
+
</div>`,u.appendChild(b)):(u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',u.appendChild(b))}catch(h){u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',u.appendChild(b)}else u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',u.appendChild(b);else{if(t.config.getThumbnail)try{const y=await t.config.getThumbnail(e);if(y){const v=document.createElement("img");return v.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",v.alt=i||e,v.src=y,u.appendChild(v),u.appendChild(b),u}}catch(y){}const h=i?`<div class="fb-tile-label">${se(i.length>10?i.substring(0,8)+"\u2026":i)}</div>
|
|
1037
1037
|
<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M19 9h-4V3H9v6H5l7 7 7-7zm-7 9H5v2h14v-2h-7z"/></svg>`:"";u.innerHTML=`
|
|
1038
1038
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
|
|
1039
1039
|
<div style="font-size:36px;">\u{1F4C1}</div>
|
|
1040
1040
|
${h}
|
|
1041
|
-
</div>`,u.appendChild(b)}return u}async function
|
|
1042
|
-
<video style="width:100%;height:100%;" preload="metadata" muted src="${
|
|
1041
|
+
</div>`,u.appendChild(b)}return u}async function So(e,t,n,r){var o,a,l;const i=n.resourceIndex.get(t),c=(a=(o=i==null?void 0:i.name)!=null?o:t.split("/").pop())!=null?a:"",s=(l=r.onRemove)!=null?l:null,f=await Nt(t,n,c,{canRemove:!0,removeHandler:s});e.className="file-preview-container",e.removeAttribute("style"),we(e),e.appendChild(f)}async function vn(e,t,n,r,o){var a,l;if((a=n==null?void 0:n.type)!=null&&a.startsWith("image/")){if(n.file&&n.file instanceof File){const i=document.createElement("img");i.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",i.alt=n.name,i.src=Ft(n.file),e.appendChild(i),zt(e,i.src,n.name,o!=null?o:null)}else if(r.config.getThumbnail)try{const i=await r.config.getThumbnail(t);if(i){const c=document.createElement("img");c.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",c.alt=n.name,c.src=i,e.appendChild(c),zt(e,i,n.name,o!=null?o:null)}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>'}catch(i){const c=i instanceof Error?i:new Error(String(i));r.config.onThumbnailError&&r.config.onThumbnailError(c,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>';o&&e.appendChild(o)}else if((l=n==null?void 0:n.type)!=null&&l.startsWith("video/")){if(n.file&&n.file instanceof File){const i=URL.createObjectURL(n.file);e.innerHTML=`
|
|
1042
|
+
<video style="width:100%;height:100%;" preload="metadata" muted src="${i}"></video>
|
|
1043
1043
|
<div class="fb-video-overlay">
|
|
1044
1044
|
<div class="fb-play-btn" style="width:20px;height:20px;">
|
|
1045
1045
|
<svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
|
|
1046
1046
|
</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="${se(n.name)}" src="${
|
|
1047
|
+
</div>`}else if(r.config.getThumbnail)try{const i=await r.config.getThumbnail(t);i?e.innerHTML=`
|
|
1048
|
+
<img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${se(n.name)}" src="${i}">
|
|
1049
1049
|
<div class="fb-video-overlay">
|
|
1050
1050
|
<div class="fb-play-btn" style="width:20px;height:20px;">
|
|
1051
1051
|
<svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
|
|
1052
1052
|
</div>
|
|
1053
|
-
</div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(
|
|
1053
|
+
</div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(i){const c=i instanceof Error?i:new Error(String(i));r.config.onThumbnailError&&r.config.onThumbnailError(c,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>';o&&e.appendChild(o)}else Lo(e,t,n,o)}function Lo(e,t,n,r){var o,a;const l=(a=(o=n==null?void 0:n.name)!=null?o:t.split("/").pop())!=null?a:"";l&&(e.title=l);const i=l?`<div style="font-size:11px;line-height:1.2;text-align:center;color:var(--fb-text-secondary-color,#6b7280);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${se(l)}</div>`:"";e.innerHTML=`
|
|
1054
1054
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
|
|
1055
1055
|
<div style="font-size:36px;">\u{1F4C1}</div>
|
|
1056
|
-
${
|
|
1057
|
-
</div>`,r&&e.appendChild(r)}async function yn(e,t,n){try{let r=null;if(n.config.getDownloadUrl?r=n.config.getDownloadUrl(e):n.config.getThumbnail&&(r=await n.config.getThumbnail(e)),r){const o=r.startsWith("http")?r:new URL(r,window.location.href).href,a=await fetch(o);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);const
|
|
1056
|
+
${i}
|
|
1057
|
+
</div>`,r&&e.appendChild(r)}async function yn(e,t,n){try{let r=null;if(n.config.getDownloadUrl?r=n.config.getDownloadUrl(e):n.config.getThumbnail&&(r=await n.config.getThumbnail(e)),r){const o=r.startsWith("http")?r:new URL(r,window.location.href).href,a=await fetch(o);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);const l=await a.blob();xn(l,t)}else throw new Error("No download URL available for resource")}catch(r){const o=r instanceof Error?r:new Error(String(r));throw n.config.onDownloadError&&n.config.onDownloadError(o,e,t),console.error(`File download failed for ${t}:`,o),o}}function xn(e,t){try{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>{URL.revokeObjectURL(n)},100)}catch(n){throw new Error(`Blob download failed: ${n.message}`,{cause:n})}}async function wn(e,t){if(!t.config.uploadFile)throw new Error("No upload handler configured. Set uploadHandler via FormBuilder.setUploadHandler()");try{const n=await t.config.uploadFile(e);if(typeof n!="string")throw new Error("Upload handler must return a string resource ID");return n}catch(n){const r=n instanceof Error?n:new Error(String(n));t.config.onUploadError&&t.config.onUploadError(r,e);const o=new Error(`File upload failed: ${r.message}`);throw o.cause=r,o}}async function To(e){var t,n,r;const{file:o,container:a,fieldName:l,state:i,deps:c=null,instance:s=null,allowedExtensions:f=[],allowedMimes:d=[],maxSizeMB:u=1/0}=e;if(!Ue(o.name,f)){const h=f.join(", ");Se(a,k("invalidFileExtension",i,{name:o.name,formats:h}));return}if(!Ge(o.type,d)){const h=d.join(", ");Se(a,k("invalidFileMime",i,{name:o.name,type:o.type,mimes:h}));return}if(!st(o,u)){Se(a,k("fileTooLarge",i,{name:o.name,maxSize:u}));return}Ze(a);const p=(t=a.parentElement)==null?void 0:t.querySelector('input[type="hidden"]'),m=(p==null?void 0:p.value)||null;$e(),a.innerHTML=`
|
|
1058
1058
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:6px;">
|
|
1059
1059
|
<div class="fb-spinner"></div>
|
|
1060
|
-
<div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${se(k("uploadingFile",
|
|
1061
|
-
</div>`;let b;try{b=await wn(o,l)}catch(h){throw m&&d!=null&&d.onAfterUpload?d.onAfterUpload(a,m):d!=null&&d.onRemove?d.onRemove():Lt(a,l),h}l.resourceIndex.set(b,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:o}),m&&m!==b&&qe((n=l.resourceIndex.get(m))==null?void 0:n.file);let v=p;v||(v=document.createElement("input"),v.type="hidden",v.name=i,(r=a.parentElement)==null||r.appendChild(v)),v.value=b;const E=o.type.startsWith("video/");!E&&d!=null&&d.onAfterUpload?d.onAfterUpload(a,b):!E&&d?Eo(a,b,l,d).catch(console.error):zt(a,b,l,{fileName:o.name,isReadonly:!1,deps:d}).catch(console.error),s&&!l.config.readonly&&s.triggerOnChange(i,b)}function So(e,t,n,r){const o=e.filter(m=>!Ue(m.name,n.allowedExtensions)),a=e.filter(m=>Ue(m.name,n.allowedExtensions)),i=a.filter(m=>!Ge(m.type,n.allowedMimes)),l=a.filter(m=>Ge(m.type,n.allowedMimes)),d=l.filter(m=>!at(m,n.maxSize)),s=l.filter(m=>at(m,n.maxSize)),f=n.maxCount===1/0?s.length:Math.max(0,n.maxCount-t),c=s.slice(0,f),u=s.length-c.length,p=[];if(o.length>0){const m=n.allowedExtensions.join(", "),b=o.map(v=>v.name).join(", ");p.push(k("invalidFileExtension",r,{name:b,formats:m}))}if(i.length>0){const m=n.allowedMimes.join(", "),b=i.map(v=>v.name).join(", ");p.push(k("invalidFileMime",r,{name:b,type:i.map(v=>v.type).join(", "),mimes:m}))}if(d.length>0){const m=d.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:c,errorMessage:p.join(" \u2022 ")}}async function Lo(e){var t;const{accepted:n,listEl:r,state:o,shouldHideAddTile:a,buildSuccessTile:i,prepareForUpload:l}=e;if(r&&a){const f=St(r),c=(t=f.querySelector(".fb-multi-add-tile-js"))!=null?t:f.querySelector(".fb-tile-add");c&&(c.style.display="none")}l==null||l();const d=new Array(n.length).fill(null),s=[];return await Promise.allSettled(n.map(async(f,c)=>{const u=eo(f.name,o);r&&St(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}),d[c]=p,i&&u.parentNode?u.replaceWith(i(p)):u.remove()}catch(p){const m=p instanceof Error?p:new Error(String(p)),b=m.cause,v=b instanceof Error?b:b!==void 0?new Error(String(b)):m;s.push({file:f,error:v}),u.remove()}})),{failures:s,orderedIds:d}}function To(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:i,constraints:l,pathKey:d,instance:s,buildSuccessTile:f,prepareForUpload:c,coordinator:u}=e,{accepted:p,errorMessage:m}=So(t,u.getOccupiedCount(),l,a);r&&(m?Se(r,m):Ze(r));const b=u.beginBatch(p.length),v=u.getOccupiedCount()>=l.maxCount,{failures:E,orderedIds:h}=await Lo({accepted:p,listEl:n,state:a,shouldHideAddTile:v,buildSuccessTile:f,prepareForUpload:c});b.setResults(h),s&&d&&!a.config.readonly&&s.triggerOnChange(d,o);const{wasLast:y}=b.end();if(y&&i(),r){const g=To(m,E,a);g?Se(r,g):Ze(r)}}function Ao(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 Fo(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 l=Re(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:[],a=r.map(l=>l.toLowerCase());if(a.length===0&&o.length===0)return;const i={};return a.length>0&&(i.extensions=a),o.length>0&&(i.mime=o),i}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 cn(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 zo(e){var t;const{state:n,element:r,wrapper:o,fieldPath:a,resourceIds:i,maxCount:l,updateCallback:d,instance:s,coordinator:f,list:c,buildSuccessTile:u}=e;if(!n.config.pickExistingFiles)return;const p=Re(r.accept),m=Xe(r.accept),b=(t=r.maxSize)!=null?t:1/0,v=f.getAllKnownRids(),E=new Set(v),h=l===1/0?1/0:Math.max(0,l-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:v})}catch(H){Se(o,Sn(H,n));return}if(y.length===0)return;const g=new Set,C=y.filter(H=>E.has(H.resourceId)||g.has(H.resourceId)?!1:(g.add(H.resourceId),!0)).filter(H=>kn(H,p,m,b,n)===null),w=l===1/0?C.length:Math.max(0,l-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:l}));return}Ze(o),S>0&&Se(o,k("filesLimitExceeded",n,{skipped:S,max:l}));for(const H of x)$n(H,n);const z=x.map(H=>H.resourceId),ae=f.beginBatch(x.length);ae.setResults(z),n.config.readonly||s.triggerOnChange(a,i);const{wasLast:K}=ae.end();if(K)d();else{const H=St(c);for(const V of z)H.appendChild(u(V))}}async function Mo(e,t,n,r,o,a,i,l){var d,s;if(!e.config.pickExistingFiles)return;const f=Re(t.accept),c=Xe(t.accept),u=(d=t.maxSize)!=null?d: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,c,u,e);if(b!==null){Se(n,b);return}Ze(n),$n(m,e);let v=r.querySelector('input[type="hidden"]');v||(v=document.createElement("input"),v.type="hidden",v.name=o,r.appendChild(v));const E=v.value||null;E&&E!==m.resourceId&&qe((s=e.resourceIndex.get(E))==null?void 0:s.file),v.value=m.resourceId,await i(m.resourceId),e.config.readonly||l.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 No(e,t,n,r,o,a,i){var l;st(e,o.resourceIndex);const d=o.resourceIndex.get(e);(l=d==null?void 0:d.type)!=null&&l.startsWith("video/")?zt(t,e,o,{fileName:e,isReadonly:!1,deps:a}).catch(console.error):Nt(t,e,o,a,i);const s=document.createElement("input");s.type="hidden",s.name=n,s.value=e,r.appendChild(s)}function Io(e,t,n,r,o=!1,a=""){$e();const i=document.createElement("div");i.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 d=document.createElement("span");d.style.cssText="width:36px;height:36px;display:block;flex-shrink:0;",d.innerHTML=Ln,l.appendChild(d);const s=document.createElement("div");if(s.className="fb-wide-tile-label",s.style.cssText="font-size:14px;font-weight:600;",s.textContent=k(o?"dropToUpload":"clickDragText",e),l.appendChild(s),a){const f=document.createElement("div");f.style.cssText="font-size:11px;opacity:0.65;margin-top:2px;",f.textContent=a,l.appendChild(f)}if(l.onclick=f=>{f.stopPropagation(),n()},i.appendChild(l),t&&r){const f=document.createElement("button");f.type="button",f.className="fb-wide-tile-library fb-file-library-card";const c=document.createElement("span");c.className="fb-wide-tile-library-icon",c.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",c.innerHTML=Tn,f.appendChild(c);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()},i.appendChild(f)}return An(i,{onEnter:()=>{const f=i.querySelector(".fb-wide-tile-label");f&&(f.textContent=k("dropToUpload",e))},onLeave:()=>{const f=i.querySelector(".fb-wide-tile-label");f&&(f.textContent=k("clickDragText",e))},activeClass:"fb-drag-over"}),i}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 Nt(e,t,n,r,o){var a,i;const l=n.resourceIndex.get(t);if((a=l==null?void 0:l.type)!=null&&a.startsWith("video/")){zt(e,t,n,{fileName:(i=l==null?void 0:l.name)!=null?i:"",isReadonly:!1,deps:r}).catch(console.error);return}$e();const d=document.createElement("div");d.className="fb-multi-outer fb-multi-has-files";const s=document.createElement("div");s.className="fb-multi-grid fb-tiles-wrap",d.appendChild(s);const f=It(t,n,!!r.onRemove,r.onRemove?()=>{var c;return(c=r.onRemove)==null?void 0:c.call(r)}:null,o);for(s.appendChild(f),e.className="file-preview-container",e.removeAttribute("style");e.firstChild;)e.removeChild(e.firstChild);e.appendChild(d)}function Ro(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 i=document.createElement("button");i.type="button",i.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=Ln,i.appendChild(l);const d=document.createElement("span");if(d.className="fb-multi-add-label",d.style.cssText="font-size:11px;font-weight:600;",d.textContent=k(o?"dropToUpload":"clickDragTextMultiple",e),i.appendChild(d),i.onclick=s=>{s.stopPropagation(),n()},a.appendChild(i),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 c=document.createElement("span");c.style.cssText="width:14px;height:14px;display:block;flex-shrink:0;",c.innerHTML=Tn,f.appendChild(c),f.appendChild(document.createTextNode(k("fromLibrary",e))),f.onclick=u=>{u.stopPropagation(),r()},a.appendChild(f)}return a}function It(e,t,n,r,o){var a,i,l;$e();const d=t.resourceIndex.get(e),s=document.createElement("div");s.className="fb-preview-tile fb-checker fb-tile-resource resource-pill",s.dataset.resourceId=e;const f=Tt({canRemove:n&&r!==null,removeHandler:r,state:t,resourceId:e,fileName:(a=d==null?void 0:d.name)!=null?a:"",meta:d,replaceHandler:(i=o==null?void 0:o.replaceHandler)!=null?i:null,libraryHandler:(l=o==null?void 0:o.libraryHandler)!=null?l:null});return gn(s,e,d,t,f).catch(c=>{console.error("Failed to render tile:",c)}),s}function Fn(e=!1){const t=document.createElement("div");return t.className=`fb-multi-placeholder fb-checker${e?" fb-drag-over":""}`,t}function qo(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,Rt=new WeakMap;function zn(e){const t=Rt.get(e);t!==void 0&&(cancelAnimationFrame(t),Rt.delete(e))}function Bo(e){const t=Qe.get(e);t&&(t.disconnect(),Qe.delete(e)),zn(e),e.querySelectorAll(".fb-multi-placeholder").forEach(n=>n.remove())}function Ho(e){var t;const{container:n,rids:r,state:o,onRemove:a,maxCount:i,isReadonly:l=!1,onLibraryPick:d,onClearAll:s,openPicker:f}=e;$e();const c=n.closest("[data-files-wrapper]");c&&(c.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=i!=null?i:1/0,b=m!==1/0&&p.length>=m,v=!l&&typeof d=="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(l){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 ae=Tt({canRemove:!1,removeHandler:null,state:o,resourceId:x,fileName:(t=S==null?void 0:S.name)!=null?t:"",meta:S});gn(z,x,S,o,ae).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=It(x,o,a!==null,a?()=>a(x):null);y.appendChild(S)}if(!b){const w=Ro(o,v,E,d!=null?d:null);y.appendChild(w)}const g=p.length+(b?0:1),C=()=>{const w=getComputedStyle(y).gridTemplateColumns,x=w?w.split(" ").filter(Boolean).length:0;if(!x)return;const S=g%x,z=S===0?0:x-S,ae=m===1/0?z:Math.max(0,m-g),K=Math.min(z,ae),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>g)&&y.appendChild(Fn()),Rt.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=qo(o,p.length,s);w&&n.appendChild(w)}}function Do(e,t,n,r){var o,a;const i=t.state,l=document.createElement("div");l.className="fb-row",l.dataset.filesWrapper=r;const d=document.createElement("input");d.type="file",d.name=r,d.style.display="none",d.accept=Mn(e.accept);const s=document.createElement("div");s.className="file-preview-container";const f=t.prefill[e.key],c=Re(e.accept),u=Xe(e.accept),p=(o=e.maxSize)!=null?o:1/0,m={fileUploadHandler(){d.click()},dragHandler(h){h.length>0&&$o({file:h[0],container:s,fieldName:r,state:i,deps:v(),instance:t.instance,allowedExtensions:c,allowedMimes:u,maxSizeMB:p})},setupDrop(h){dt(h,m.dragHandler)},onRemove(){var h;const y=l.querySelector('input[type="hidden"]'),g=y==null?void 0:y.value;g&&qe((h=i.resourceIndex.get(g))==null?void 0:h.file),y&&(y.value=""),E()}},b=()=>{const h=!!(i.config.pickExistingFiles&&!e.disableLibrary);return{replaceHandler:i.config.uploadFile?()=>d.click():null,libraryHandler:h?()=>{Mo(i,e,s,l,r,r,async y=>{Nt(s,y,i,v(),b())},t.instance).catch(y=>{console.error("Library pick failed:",y)})}:null}},v=()=>({picker:d,fileUploadHandler:m.fileUploadHandler,dragHandler:m.dragHandler,setupDrop:m.setupDrop,onRemove:m.onRemove,onAfterUpload:(h,y)=>{Nt(h,y,i,v(),b())}}),E=()=>{for($e(),s.className="file-preview-container",s.removeAttribute("style");s.firstChild;)s.removeChild(s.firstChild);const h=b().libraryHandler,y=Io(i,h!==null,m.fileUploadHandler,h,!1,Le(e,i));s.appendChild(y),dt(s,m.dragHandler)};if(f){No(f,s,r,l,i,v(),b());const h=i.resourceIndex.get(f);(a=h==null?void 0:h.type)!=null&&a.startsWith("video/")&&dt(s,m.dragHandler)}else E();d.onchange=()=>{d.files&&d.files.length>0&&m.dragHandler(d.files)},l.appendChild(s),l.appendChild(d),n.appendChild(l)}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,i;const l=t.state,d=document.createElement("div");d.className="fb-row",d.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 c=document.createElement("div");c.className="files-list",d.appendChild(s),d.appendChild(f),f.appendChild(c);const u=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];$t(u,l.resourceIndex),d.dataset.resourceIds=JSON.stringify(u);const p={maxCount:o,allowedExtensions:Re(e.accept),allowedMimes:Xe(e.accept),maxSize:(i=(a=e.maxSize)!=null?a:e.maxSizeMB)!=null?i:1/0},m=()=>{s.click()},b=l.config.pickExistingFiles&&!e.disableLibrary?()=>{zo({state:l,element:e,wrapper:d,fieldPath:r,resourceIds:u,maxCount:o,updateCallback:v,instance:t.instance,coordinator:z,list:c,buildSuccessTile:ae}).catch(V=>{console.error("Library pick failed:",V)})}:null;function v(){const V=ie(e,l);Ho({container:c,rids:u,state:l,onRemove:V?null:te=>{var R,G;qe((R=l.resourceIndex.get(te))==null?void 0:R.file);const le=u.indexOf(te);le>-1&&u.splice(le,1),z.hasInFlightBatches()?(x.add(te),(G=c.querySelector(`[data-resource-id="${te}"]`))==null||G.remove(),d.dataset.resourceIds=JSON.stringify(u)):v(),t.instance&&r&&!l.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 te,R;for(const G of u)qe((te=l.resourceIndex.get(G))==null?void 0:te.file);if(u.splice(0),z.hasInFlightBatches()){const G=c.querySelectorAll("[data-resource-id]");for(const le of G){const pe=le.dataset.resourceId;pe&&(qe((R=l.resourceIndex.get(pe))==null?void 0:R.file),x.add(pe)),le.remove()}d.dataset.resourceIds=JSON.stringify(u)}else v();t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,u)},openPicker:m})}let E=0,h=0,y=0,g=0;const C=new Map,w=new Map,x=new Set,S=()=>{for(var V;C.has(g);){const te=g,R=C.get(te);C.delete(te),g+=1;const G=(V=w.get(te))!=null?V:0;w.delete(te),E-=G;for(const le of R)if(le!==null){if(x.has(le)){x.delete(le);continue}u.push(le)}}d.dataset.resourceIds=JSON.stringify(u)},z={getOccupiedCount:()=>u.length+E,getAllKnownRids:()=>{const V=[...u];for(const te of C.values())for(const R of te)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 te=y++;return w.set(te,V),{setResults:R=>{C.set(te,R),S()},end:()=>{h-=1;const R=h===0&&w.size===0;return R&&x.clear(),{wasLast:R}}}}},ae=V=>{const te=ie(e,l);return It(V,l,!te,te?null:()=>{var R,G,le;qe((R=l.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),(G=c.querySelector(`[data-resource-id="${V}"]`))==null||G.remove(),d.dataset.resourceIds=JSON.stringify(u)):v(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,u);return}x.add(V),(le=c.querySelector(`[data-resource-id="${V}"]`))==null||le.remove(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,u)})},K=()=>Bo(c),H={resourceIds:u,state:l,updateCallback:v,constraints:p,pathKey:r,instance:t.instance,buildSuccessTile:ae,prepareForUpload:K,coordinator:z};Ao({...H,filesContainer:f}),Fo({...H,filesPicker:s}),v(),n.appendChild(d)}function jo(e,t,n,r){Nn(e,t,n,r,1/0)}function Oo(e,t,n,r){var o;Nn(e,t,n,r,(o=e.maxCount)!=null?o:1/0)}function Uo(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 Po(e,t,n,r,o){var a,i;const l="minCount"in n&&(a=n.minCount)!=null?a:0,d="maxCount"in n&&(i=n.maxCount)!=null?i: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>d&&o.push(`${e}: ${k("maxFiles",r,{max:d})}`)}function In(e,t,n,r,o){var a,i;const l="accept"in n?n.accept:void 0,d=Re(l),s=Xe(l);if(d.length===0&&s.length===0)return;const f=d.join(", "),c=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(d.length>0&&!Ue(m,d)){o.push(`${e}: ${k("invalidFileExtension",r,{name:m,formats:f})}`);continue}if(s.length>0&&!(p!=null&&p.inferredFromExtension)){const b=(i=p==null?void 0:p.type)!=null?i:"";Ge(b,s)||o.push(`${e}: ${k("invalidFileMime",r,{name:m,type:b,mimes:c})}`)}}}function Rn(e,t,n,r,o){var a;const i="maxSize"in n&&(a=n.maxSize)!=null?a:1/0;if(i!==1/0)for(const l of t){const d=r.resourceIndex.get(l);d&&d.size>i*1024*1024&&o.push(`${e}: ${k("fileTooLarge",r,{name:d.name,maxSize:i})}`)}}function Wo(e,t,n){const{scopeRoot:r,skipValidation:o,path:a,state:i}=n,l=[],d=De(a,t),s=Uo(r,d);return o||(Po(t,s,e,i,l),In(t,s,e,i,l),Rn(t,s,e,i,l)),{value:s,errors:l}}function Vo(e,t,n){var r;const{scopeRoot:o,skipValidation:a,state:i}=n,l=[],d=o.querySelector(`input[name$="${t}"][type="hidden"]`),s=(r=d==null?void 0:d.value)!=null?r:"";return!a&&e.required&&s===""?(l.push(`${t}: ${k("required",i)}`),{value:null,errors:l}):(!a&&s!==""&&(In(t,[s],e,i,l),Rn(t,[s],e,i,l)),{value:s||null,errors:l})}function qn(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?Wo(e,t,n):Vo(e,t,n)}function Ko(e,t,n,r){const o=t.state,a=t.prefill[e.key],i=typeof a=="string"?a:"";if(i){$t([i],o.resourceIndex);const l=document.createElement("input");l.type="hidden",l.name=r,l.value=i,n.appendChild(l),Mt(i,o).then(d=>{d.classList.add("fb-single-readonly-filled","fb-readonly-tile","fb-checker"),n.appendChild(d)}).catch(console.error)}else n.appendChild(_o(o))}function _o(e){$e();const t=document.createElement("div");return t.style.cssText=`
|
|
1060
|
+
<div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${se(k("uploadingFile",i))}</div>
|
|
1061
|
+
</div>`;let b;try{b=await wn(o,i)}catch(h){throw m&&c!=null&&c.onAfterUpload?c.onAfterUpload(a,m):c!=null&&c.onRemove?c.onRemove():Tt(a,i),h}i.resourceIndex.set(b,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:o}),m&&m!==b&&qe((n=i.resourceIndex.get(m))==null?void 0:n.file);let g=p;g||(g=document.createElement("input"),g.type="hidden",g.name=l,(r=a.parentElement)==null||r.appendChild(g)),g.value=b;const E=o.type.startsWith("video/");!E&&c!=null&&c.onAfterUpload?c.onAfterUpload(a,b):!E&&c?So(a,b,i,c).catch(console.error):Mt(a,b,i,{fileName:o.name,isReadonly:!1,deps:c}).catch(console.error),s&&!i.config.readonly&&s.triggerOnChange(l,b)}function Ao(e,t,n,r){const o=e.filter(m=>!Ue(m.name,n.allowedExtensions)),a=e.filter(m=>Ue(m.name,n.allowedExtensions)),l=a.filter(m=>!Ge(m.type,n.allowedMimes)),i=a.filter(m=>Ge(m.type,n.allowedMimes)),c=i.filter(m=>!st(m,n.maxSize)),s=i.filter(m=>st(m,n.maxSize)),f=n.maxCount===1/0?s.length:Math.max(0,n.maxCount-t),d=s.slice(0,f),u=s.length-d.length,p=[];if(o.length>0){const m=n.allowedExtensions.join(", "),b=o.map(g=>g.name).join(", ");p.push(k("invalidFileExtension",r,{name:b,formats:m}))}if(l.length>0){const m=n.allowedMimes.join(", "),b=l.map(g=>g.name).join(", ");p.push(k("invalidFileMime",r,{name:b,type:l.map(g=>g.type).join(", "),mimes:m}))}if(c.length>0){const m=c.map(b=>b.name).join(", ");p.push(k("fileTooLarge",r,{name:m,maxSize:n.maxSize}))}return u>0&&p.push(k("filesLimitExceeded",r,{skipped:u,max:n.maxCount})),{accepted:d,errorMessage:p.join(" \u2022 ")}}async function Fo(e){var t;const{accepted:n,listEl:r,state:o,shouldHideAddTile:a,buildSuccessTile:l,prepareForUpload:i}=e;if(r&&a){const f=Lt(r),d=(t=f.querySelector(".fb-multi-add-tile-js"))!=null?t:f.querySelector(".fb-tile-add");d&&(d.style.display="none")}i==null||i();const c=new Array(n.length).fill(null),s=[];return await Promise.allSettled(n.map(async(f,d)=>{const u=ro(f.name,o);r&&Lt(r).appendChild(u);try{const p=await wn(f,o);o.resourceIndex.set(p,{name:f.name,type:f.type,size:f.size,uploadedAt:new Date,file:f}),c[d]=p,l&&u.parentNode?u.replaceWith(l(p)):u.remove()}catch(p){const m=p instanceof Error?p:new Error(String(p)),b=m.cause,g=b instanceof Error?b:b!==void 0?new Error(String(b)):m;s.push({file:f,error:g}),u.remove()}})),{failures:s,orderedIds:c}}function zo(e,t,n){if(t.length===0)return e;const r=t.map(o=>k("uploadFailed",n,{name:o.file.name,error:o.error.message})).join(" \u2022 ");return e?`${e} \u2022 ${r}`:r}async function Cn(e,t,n,r){const{resourceIds:o,state:a,updateCallback:l,constraints:i,pathKey:c,instance:s,buildSuccessTile:f,prepareForUpload:d,coordinator:u}=e,{accepted:p,errorMessage:m}=Ao(t,u.getOccupiedCount(),i,a);r&&(m?Se(r,m):Ze(r));const b=u.beginBatch(p.length),g=u.getOccupiedCount()>=i.maxCount,{failures:E,orderedIds:h}=await Fo({accepted:p,listEl:n,state:a,shouldHideAddTile:g,buildSuccessTile:f,prepareForUpload:d});b.setResults(h),s&&c&&!a.config.readonly&&s.triggerOnChange(c,o);const{wasLast:y}=b.end();if(y&&l(),r){const v=zo(m,E,a);v?Se(r,v):Ze(r)}}function Mo(e){const{filesContainer:t}=e;dt(t,async n=>{var r;const o=(r=t.querySelector(".files-list"))!=null?r:t;await Cn(e,Array.from(n),o,t)})}function No(e){const{filesPicker:t}=e;t.onchange=async()=>{var n,r;if(!t.files)return;const o=(n=t.closest("[data-files-wrapper]"))!=null?n:t.parentElement,a=(r=o==null?void 0:o.querySelector(".files-list"))!=null?r:null;await Cn(e,Array.from(t.files),a,o),t.value=""}}function En(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const i=Re(e.accept);return i.length>0?{extensions:i}:void 0}const r=(t=e.accept.extensions)!=null?t:[],o=(n=e.accept.mime)!=null?n:[],a=r.map(i=>i.toLowerCase());if(a.length===0&&o.length===0)return;const l={};return a.length>0&&(l.extensions=a),o.length>0&&(l.mime=o),l}function kn(e,t,n,r,o){if(!Ue(e.name,t)){const a=t.join(", ");return k("invalidFileExtension",o,{name:e.name,formats:a})}if(!Ge(e.type,n)){const a=n.join(", ");return k("invalidFileMime",o,{name:e.name,type:e.type,mimes:a})}return dn(e.size,r)?null:k("fileTooLarge",o,{name:e.name,maxSize:r})}function $n(e,t){var n;const r=t.resourceIndex.get(e.resourceId);t.resourceIndex.set(e.resourceId,{name:e.name,type:e.type,size:e.size,uploadedAt:(n=r==null?void 0:r.uploadedAt)!=null?n:new Date,file:r==null?void 0:r.file})}function Sn(e,t){return e instanceof Error&&e.message?e.message:k("pickerError",t)}async function Io(e){var t;const{state:n,element:r,wrapper:o,fieldPath:a,resourceIds:l,maxCount:i,updateCallback:c,instance:s,coordinator:f,list:d,buildSuccessTile:u}=e;if(!n.config.pickExistingFiles)return;const p=Re(r.accept),m=Ye(r.accept),b=(t=r.maxSize)!=null?t:1/0,g=f.getAllKnownRids(),E=new Set(g),h=i===1/0?1/0:Math.max(0,i-f.getOccupiedCount());let y;try{y=await n.config.pickExistingFiles({fieldPath:a,mode:"multiple",accept:En(r),maxSizeMB:b===1/0?void 0:b,remainingSlots:h===1/0?void 0:h,selectedResourceIds:g})}catch(H){Se(o,Sn(H,n));return}if(y.length===0)return;const v=new Set,C=y.filter(H=>E.has(H.resourceId)||v.has(H.resourceId)?!1:(v.add(H.resourceId),!0)).filter(H=>kn(H,p,m,b,n)===null),w=i===1/0?C.length:Math.max(0,i-f.getOccupiedCount()),x=C.slice(0,w),S=C.length-x.length;if(x.length===0){S>0&&Se(o,k("filesLimitExceeded",n,{skipped:S,max:i}));return}Ze(o),S>0&&Se(o,k("filesLimitExceeded",n,{skipped:S,max:i}));for(const H of x)$n(H,n);const z=x.map(H=>H.resourceId),ee=f.beginBatch(x.length);ee.setResults(z),n.config.readonly||s.triggerOnChange(a,l);const{wasLast:K}=ee.end();if(K)c();else{const H=Lt(d);for(const V of z)H.appendChild(u(V))}}async function Ro(e,t,n,r,o,a,l,i){var c,s;if(!e.config.pickExistingFiles)return;const f=Re(t.accept),d=Ye(t.accept),u=(c=t.maxSize)!=null?c:1/0;let p;try{p=await e.config.pickExistingFiles({fieldPath:a,mode:"single",accept:En(t),maxSizeMB:u===1/0?void 0:u,selectedResourceIds:[]})}catch(h){Se(n,Sn(h,e));return}if(p.length===0)return;const m=p[0],b=kn(m,f,d,u,e);if(b!==null){Se(n,b);return}Ze(n),$n(m,e);let g=r.querySelector('input[type="hidden"]');g||(g=document.createElement("input"),g.type="hidden",g.name=o,r.appendChild(g));const E=g.value||null;E&&E!==m.resourceId&&qe((s=e.resourceIndex.get(E))==null?void 0:s.file),g.value=m.resourceId,await l(m.resourceId),e.config.readonly||i.triggerOnChange(a,m.resourceId)}const Ln='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',Tn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function qo(e,t,n,r,o,a,l){var i;ct(e,o.resourceIndex);const c=o.resourceIndex.get(e);(i=c==null?void 0:c.type)!=null&&i.startsWith("video/")?Mt(t,e,o,{fileName:e,isReadonly:!1,deps:a}).catch(console.error):It(t,e,o,a,l);const s=document.createElement("input");s.type="hidden",s.name=n,s.value=e,r.appendChild(s)}function Bo(e,t,n,r,o=!1,a=""){$e();const l=document.createElement("div");l.className=`fb-wide-tile${t?" fb-file-card-row":""}${o?" fb-drag-over":""}`;const i=document.createElement("button");i.type="button",i.className="fb-wide-tile-upload fb-file-dropzone";const c=document.createElement("span");c.style.cssText="width:36px;height:36px;display:block;flex-shrink:0;",c.innerHTML=Ln,i.appendChild(c);const s=document.createElement("div");if(s.className="fb-wide-tile-label",s.style.cssText="font-size:14px;font-weight:600;",s.textContent=k(o?"dropToUpload":"clickDragText",e),i.appendChild(s),a){const f=document.createElement("div");f.style.cssText="font-size:11px;opacity:0.65;margin-top:2px;",f.textContent=a,i.appendChild(f)}if(i.onclick=f=>{f.stopPropagation(),n()},l.appendChild(i),t&&r){const f=document.createElement("button");f.type="button",f.className="fb-wide-tile-library fb-file-library-card";const d=document.createElement("span");d.className="fb-wide-tile-library-icon",d.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",d.innerHTML=Tn,f.appendChild(d);const u=document.createElement("div");u.className="fb-wide-tile-library-label",u.style.cssText="font-size:13px;font-weight:600;text-align:center;",u.textContent=k("fromLibrary",e),f.appendChild(u);const p=document.createElement("div");p.className="fb-wide-tile-library-hint",p.style.cssText="font-size:11px;opacity:0.75;text-align:center;",p.textContent=k("libraryHint",e),f.appendChild(p),f.onclick=m=>{m.stopPropagation(),r()},l.appendChild(f)}return An(l,{onEnter:()=>{const f=l.querySelector(".fb-wide-tile-label");f&&(f.textContent=k("dropToUpload",e))},onLeave:()=>{const f=l.querySelector(".fb-wide-tile-label");f&&(f.textContent=k("clickDragText",e))},activeClass:"fb-drag-over"}),l}function An(e,t){let n=0;e.addEventListener("dragover",r=>{r.preventDefault()}),e.addEventListener("dragenter",r=>{r.preventDefault(),n++,n===1&&(e.classList.add(t.activeClass),t.onEnter())}),e.addEventListener("dragleave",r=>{r.preventDefault(),n=Math.max(0,n-1),n===0&&(e.classList.remove(t.activeClass),t.onLeave())}),e.addEventListener("drop",()=>{n=0,e.classList.remove(t.activeClass),t.onLeave()})}function It(e,t,n,r,o){var a,l;const i=n.resourceIndex.get(t);if((a=i==null?void 0:i.type)!=null&&a.startsWith("video/")){Mt(e,t,n,{fileName:(l=i==null?void 0:i.name)!=null?l:"",isReadonly:!1,deps:r}).catch(console.error);return}$e();const c=document.createElement("div");c.className="fb-multi-outer fb-multi-has-files";const s=document.createElement("div");s.className="fb-multi-grid fb-tiles-wrap",c.appendChild(s);const f=Rt(t,n,!!r.onRemove,r.onRemove?()=>{var d;return(d=r.onRemove)==null?void 0:d.call(r)}:null,o);for(s.appendChild(f),e.className="file-preview-container",e.removeAttribute("style");e.firstChild;)e.removeChild(e.firstChild);e.appendChild(c)}function Ho(e,t,n,r,o=!1){const a=document.createElement("div");a.className=`fb-multi-add-tile fb-multi-add-tile-js${o?" fb-drag-over-tile":""}`;const l=document.createElement("button");l.type="button",l.className="fb-multi-add-upload fb-tile-add fb-file-dropzone";const i=document.createElement("span");i.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",i.innerHTML=Ln,l.appendChild(i);const c=document.createElement("span");if(c.className="fb-multi-add-label",c.style.cssText="font-size:11px;font-weight:600;",c.textContent=k(o?"dropToUpload":"clickDragTextMultiple",e),l.appendChild(c),l.onclick=s=>{s.stopPropagation(),n()},a.appendChild(l),t&&r){const s=document.createElement("div");s.className="fb-multi-add-divider",a.appendChild(s);const f=document.createElement("button");f.type="button",f.className="fb-multi-add-library fb-tile-add-library fb-file-library-card",f.setAttribute("aria-label",k("fromLibrary",e));const d=document.createElement("span");d.style.cssText="width:14px;height:14px;display:block;flex-shrink:0;",d.innerHTML=Tn,f.appendChild(d),f.appendChild(document.createTextNode(k("fromLibrary",e))),f.onclick=u=>{u.stopPropagation(),r()},a.appendChild(f)}return a}function Rt(e,t,n,r,o){var a,l,i;$e();const c=t.resourceIndex.get(e),s=document.createElement("div");s.className="fb-preview-tile fb-checker fb-tile-resource resource-pill",s.dataset.resourceId=e;const f=At({canRemove:n&&r!==null,removeHandler:r,state:t,resourceId:e,fileName:(a=c==null?void 0:c.name)!=null?a:"",meta:c,replaceHandler:(l=o==null?void 0:o.replaceHandler)!=null?l:null,libraryHandler:(i=o==null?void 0:o.libraryHandler)!=null?i:null});return vn(s,e,c,t,f).catch(d=>{console.error("Failed to render tile:",d)}),s}function Fn(e=!1){const t=document.createElement("div");return t.className=`fb-multi-placeholder fb-checker${e?" fb-drag-over":""}`,t}function Do(e,t,n){if(t<=1)return null;const r=document.createElement("div");r.className="fb-clear-all-row";const o=document.createElement("button");return o.type="button",o.className="fb-clear-all-btn",o.textContent=k("clearAll",e),o.onclick=a=>{a.stopPropagation(),window.confirm(k("clearAll",e)+"?")&&n()},r.appendChild(o),r}const Qe=new WeakMap,qt=new WeakMap;function zn(e){const t=qt.get(e);t!==void 0&&(cancelAnimationFrame(t),qt.delete(e))}function jo(e){const t=Qe.get(e);t&&(t.disconnect(),Qe.delete(e)),zn(e),e.querySelectorAll(".fb-multi-placeholder").forEach(n=>n.remove())}function Oo(e){var t;const{container:n,rids:r,state:o,onRemove:a,maxCount:l,isReadonly:i=!1,onLibraryPick:c,onClearAll:s,openPicker:f}=e;$e();const d=n.closest("[data-files-wrapper]");d&&(d.dataset.resourceIds=JSON.stringify(r!=null?r:[]));const u=Qe.get(n);for(u&&(u.disconnect(),Qe.delete(n)),zn(n);n.firstChild;)n.removeChild(n.firstChild);const p=r!=null?r:[],m=l!=null?l:1/0,b=m!==1/0&&p.length>=m,g=!i&&typeof c=="function",E=f!=null?f:(()=>{var w;const x=(w=n.closest("[data-files-wrapper]"))==null?void 0:w.querySelector('input[type="file"]');x&&x.click()});if(i){if(p.length===0){const w=document.createElement("div");w.className="fb-tile-empty-text",w.textContent=k("noFilesSelected",o),n.appendChild(w)}else{const w=document.createElement("div");w.className="fb-multi-readonly-grid",n.appendChild(w);for(const x of p){const S=o.resourceIndex.get(x),z=document.createElement("div");z.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",z.dataset.resourceId=x;const ee=At({canRemove:!1,removeHandler:null,state:o,resourceId:x,fileName:(t=S==null?void 0:S.name)!=null?t:"",meta:S});vn(z,x,S,o,ee).catch(console.error),z.onclick=async()=>{var K;let H=null;o.config.getDownloadUrl?H=o.config.getDownloadUrl(x):o.config.getThumbnail?H=await o.config.getThumbnail(x):(S==null?void 0:S.file)instanceof File&&(H=URL.createObjectURL(S.file)),H?window.open(H,"_blank"):o.config.downloadFile&&o.config.downloadFile(x,(K=S==null?void 0:S.name)!=null?K:"")},w.appendChild(z)}}return}const h=document.createElement("div");h.className=`fb-multi-outer${p.length>0?" fb-multi-has-files":""}`;const y=document.createElement("div");y.className="fb-multi-grid fb-tiles-wrap",h.appendChild(y),n.appendChild(h);for(let w=0;w<p.length;w++){const x=p[w],S=Rt(x,o,a!==null,a?()=>a(x):null);y.appendChild(S)}if(!b){const w=Ho(o,g,E,c!=null?c:null);y.appendChild(w)}const v=p.length+(b?0:1),C=()=>{const w=getComputedStyle(y).gridTemplateColumns,x=w?w.split(" ").filter(Boolean).length:0;if(!x)return;const S=v%x,z=S===0?0:x-S,ee=m===1/0?z:Math.max(0,m-v),K=Math.min(z,ee),H=y.querySelectorAll(".fb-multi-placeholder");if(H.length>K)for(let V=H.length-1;V>=K;V--)H[V].remove();else if(H.length<K)for(let V=H.length;V<K;V++)y.appendChild(Fn())};if((m===1/0||m>v)&&y.appendChild(Fn()),qt.set(n,requestAnimationFrame(C)),typeof ResizeObserver!="undefined"){const w=new ResizeObserver(()=>C());w.observe(y),Qe.set(n,w)}if(An(h,{activeClass:"fb-drag-over",onEnter:()=>{y.querySelectorAll(".fb-multi-placeholder").forEach(x=>{x.classList.add("fb-drag-over")});const w=y.querySelector(".fb-multi-add-tile-js");if(w){w.classList.add("fb-drag-over-tile");const x=w.querySelector(".fb-multi-add-label");x&&(x.textContent=k("dropToUpload",o))}},onLeave:()=>{y.querySelectorAll(".fb-multi-placeholder").forEach(x=>{x.classList.remove("fb-drag-over")});const w=y.querySelector(".fb-multi-add-tile-js");if(w){w.classList.remove("fb-drag-over-tile");const x=w.querySelector(".fb-multi-add-label");x&&(x.textContent=k("clickDragTextMultiple",o))}}}),s){const w=Do(o,p.length,s);w&&n.appendChild(w)}}function Uo(e,t,n,r){var o,a;const l=t.state,i=document.createElement("div");i.className="fb-row",i.dataset.filesWrapper=r;const c=document.createElement("input");c.type="file",c.name=r,c.style.display="none",c.accept=Mn(e.accept);const s=document.createElement("div");s.className="file-preview-container";const f=t.prefill[e.key],d=Re(e.accept),u=Ye(e.accept),p=(o=e.maxSize)!=null?o:1/0,m={fileUploadHandler(){c.click()},dragHandler(h){h.length>0&&To({file:h[0],container:s,fieldName:r,state:l,deps:g(),instance:t.instance,allowedExtensions:d,allowedMimes:u,maxSizeMB:p})},setupDrop(h){dt(h,m.dragHandler)},onRemove(){var h;const y=i.querySelector('input[type="hidden"]'),v=y==null?void 0:y.value;v&&qe((h=l.resourceIndex.get(v))==null?void 0:h.file),y&&(y.value=""),E()}},b=()=>{const h=!!(l.config.pickExistingFiles&&!e.disableLibrary);return{replaceHandler:l.config.uploadFile?()=>c.click():null,libraryHandler:h?()=>{Ro(l,e,s,i,r,r,async y=>{It(s,y,l,g(),b())},t.instance).catch(y=>{console.error("Library pick failed:",y)})}:null}},g=()=>({picker:c,fileUploadHandler:m.fileUploadHandler,dragHandler:m.dragHandler,setupDrop:m.setupDrop,onRemove:m.onRemove,onAfterUpload:(h,y)=>{It(h,y,l,g(),b())}}),E=()=>{for($e(),s.className="file-preview-container",s.removeAttribute("style");s.firstChild;)s.removeChild(s.firstChild);const h=b().libraryHandler,y=Bo(l,h!==null,m.fileUploadHandler,h,!1,Le(e,l));s.appendChild(y),dt(s,m.dragHandler)};if(f){qo(f,s,r,i,l,g(),b());const h=l.resourceIndex.get(f);(a=h==null?void 0:h.type)!=null&&a.startsWith("video/")&&dt(s,m.dragHandler)}else E();c.onchange=()=>{c.files&&c.files.length>0&&m.dragHandler(c.files)},i.appendChild(s),i.appendChild(c),n.appendChild(i)}function Mn(e){var t,n,r;return e?typeof e=="string"?e:[...(n=(t=e.extensions)==null?void 0:t.map(o=>`.${o}`))!=null?n:[],...(r=e.mime)!=null?r:[]].join(","):""}function Nn(e,t,n,r,o){var a,l;const i=t.state,c=document.createElement("div");c.className="fb-row",c.dataset.filesWrapper=r;const s=document.createElement("input");s.type="file",s.name=r,s.multiple=!0,s.style.display="none",s.accept=Mn(e.accept);const f=document.createElement("div");f.className="files-list-wrapper";const d=document.createElement("div");d.className="files-list",c.appendChild(s),c.appendChild(f),f.appendChild(d);const u=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];St(u,i.resourceIndex),c.dataset.resourceIds=JSON.stringify(u);const p={maxCount:o,allowedExtensions:Re(e.accept),allowedMimes:Ye(e.accept),maxSize:(l=(a=e.maxSize)!=null?a:e.maxSizeMB)!=null?l:1/0},m=()=>{s.click()},b=i.config.pickExistingFiles&&!e.disableLibrary?()=>{Io({state:i,element:e,wrapper:c,fieldPath:r,resourceIds:u,maxCount:o,updateCallback:g,instance:t.instance,coordinator:z,list:d,buildSuccessTile:ee}).catch(V=>{console.error("Library pick failed:",V)})}:null;function g(){const V=ae(e,i);Oo({container:d,rids:u,state:i,onRemove:V?null:ne=>{var R,_;qe((R=i.resourceIndex.get(ne))==null?void 0:R.file);const ie=u.indexOf(ne);ie>-1&&u.splice(ie,1),z.hasInFlightBatches()?(x.add(ne),(_=d.querySelector(`[data-resource-id="${ne}"]`))==null||_.remove(),c.dataset.resourceIds=JSON.stringify(u)):g(),t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,u)},maxCount:o<1/0?o:void 0,isReadonly:V,onLibraryPick:V?null:b,onClearAll:V?void 0:()=>{var ne,R;for(const _ of u)qe((ne=i.resourceIndex.get(_))==null?void 0:ne.file);if(u.splice(0),z.hasInFlightBatches()){const _=d.querySelectorAll("[data-resource-id]");for(const ie of _){const pe=ie.dataset.resourceId;pe&&(qe((R=i.resourceIndex.get(pe))==null?void 0:R.file),x.add(pe)),ie.remove()}c.dataset.resourceIds=JSON.stringify(u)}else g();t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,u)},openPicker:m})}let E=0,h=0,y=0,v=0;const C=new Map,w=new Map,x=new Set,S=()=>{for(var V;C.has(v);){const ne=v,R=C.get(ne);C.delete(ne),v+=1;const _=(V=w.get(ne))!=null?V:0;w.delete(ne),E-=_;for(const ie of R)if(ie!==null){if(x.has(ie)){x.delete(ie);continue}u.push(ie)}}c.dataset.resourceIds=JSON.stringify(u)},z={getOccupiedCount:()=>u.length+E,getAllKnownRids:()=>{const V=[...u];for(const ne of C.values())for(const R of ne)R!==null&&V.push(R);return V},hasInFlightBatches:()=>h>0||w.size>0,wasRemovedDuringBatch:V=>x.has(V),beginBatch:V=>{E+=V,h+=1;const ne=y++;return w.set(ne,V),{setResults:R=>{C.set(ne,R),S()},end:()=>{h-=1;const R=h===0&&w.size===0;return R&&x.clear(),{wasLast:R}}}}},ee=V=>{const ne=ae(e,i);return Rt(V,i,!ne,ne?null:()=>{var R,_,ie;qe((R=i.resourceIndex.get(V))==null?void 0:R.file);const pe=u.indexOf(V);if(pe>-1){u.splice(pe,1),z.hasInFlightBatches()?(x.add(V),(_=d.querySelector(`[data-resource-id="${V}"]`))==null||_.remove(),c.dataset.resourceIds=JSON.stringify(u)):g(),t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,u);return}x.add(V),(ie=d.querySelector(`[data-resource-id="${V}"]`))==null||ie.remove(),t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,u)})},K=()=>jo(d),H={resourceIds:u,state:i,updateCallback:g,constraints:p,pathKey:r,instance:t.instance,buildSuccessTile:ee,prepareForUpload:K,coordinator:z};Mo({...H,filesContainer:f}),No({...H,filesPicker:s}),g(),n.appendChild(c)}function Po(e,t,n,r){Nn(e,t,n,r,1/0)}function Wo(e,t,n,r){var o;Nn(e,t,n,r,(o=e.maxCount)!=null?o:1/0)}function Vo(e,t){const n=e.querySelector(`[data-files-wrapper="${t}"]`);if(!n)return[];const r=n.dataset.resourceIds;if(r===void 0)throw new Error(`readMultiFileResourceIds: [data-files-wrapper="${t}"] is missing data-resource-ids attribute. This is a render bug.`);const o=JSON.parse(r);if(!Array.isArray(o))throw new Error(`readMultiFileResourceIds: data-resource-ids on [data-files-wrapper="${t}"] is not a JSON array. Got: ${r}`);return o}function Ko(e,t,n,r,o){var a,l;const i="minCount"in n&&(a=n.minCount)!=null?a:0,c="maxCount"in n&&(l=n.maxCount)!=null?l:1/0;n.required&&t.length===0&&o.push(`${e}: ${k("required",r)}`),t.length<i&&o.push(`${e}: ${k("minFiles",r,{min:i})}`),t.length>c&&o.push(`${e}: ${k("maxFiles",r,{max:c})}`)}function In(e,t,n,r,o){var a,l;const i="accept"in n?n.accept:void 0,c=Re(i),s=Ye(i);if(c.length===0&&s.length===0)return;const f=c.join(", "),d=s.join(", ");for(const u of t){const p=r.resourceIndex.get(u),m=(a=p==null?void 0:p.name)!=null?a:u;if(c.length>0&&!Ue(m,c)){o.push(`${e}: ${k("invalidFileExtension",r,{name:m,formats:f})}`);continue}if(s.length>0&&!(p!=null&&p.inferredFromExtension)){const b=(l=p==null?void 0:p.type)!=null?l:"";Ge(b,s)||o.push(`${e}: ${k("invalidFileMime",r,{name:m,type:b,mimes:d})}`)}}}function Rn(e,t,n,r,o){var a;const l="maxSize"in n&&(a=n.maxSize)!=null?a:1/0;if(l!==1/0)for(const i of t){const c=r.resourceIndex.get(i);c&&c.size>l*1024*1024&&o.push(`${e}: ${k("fileTooLarge",r,{name:c.name,maxSize:l})}`)}}function _o(e,t,n){const{scopeRoot:r,skipValidation:o,path:a,state:l}=n,i=[],c=De(a,t),s=Vo(r,c);return o||(Ko(t,s,e,l,i),In(t,s,e,l,i),Rn(t,s,e,l,i)),{value:s,errors:i}}function Jo(e,t,n){var r;const{scopeRoot:o,skipValidation:a,state:l}=n,i=[],c=o.querySelector(`input[name="${t}"][type="hidden"]`),s=(r=c==null?void 0:c.value)!=null?r:"";return!a&&e.required&&s===""?(i.push(`${t}: ${k("required",l)}`),{value:null,errors:i}):(!a&&s!==""&&(In(t,[s],e,l,i),Rn(t,[s],e,l,i)),{value:s||null,errors:i})}function qn(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?_o(e,t,n):Jo(e,t,n)}function Xo(e,t,n,r){const o=t.state,a=t.prefill[e.key],l=typeof a=="string"?a:"";if(l){St([l],o.resourceIndex);const i=document.createElement("input");i.type="hidden",i.name=r,i.value=l,n.appendChild(i),Nt(l,o).then(c=>{c.classList.add("fb-single-readonly-filled","fb-readonly-tile","fb-checker"),n.appendChild(c)}).catch(console.error)}else n.appendChild(Yo(o))}function Yo(e){$e();const t=document.createElement("div");return t.style.cssText=`
|
|
1062
1062
|
height: 220px;
|
|
1063
1063
|
display:flex;
|
|
1064
1064
|
align-items:center;
|
|
@@ -1066,7 +1066,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1066
1066
|
background: repeating-linear-gradient(45deg, #fafafa 0 6px, #f3f4f6 6px 12px);
|
|
1067
1067
|
border-radius:0.75rem;
|
|
1068
1068
|
border:1px solid #e2e8f0;
|
|
1069
|
-
`,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${se(k("noFileSelected",e))}</div>`,t}function Bn(e,t,n,r,o){
|
|
1069
|
+
`,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${se(k("noFileSelected",e))}</div>`,t}function Bn(e,t,n,r,o){St(e,t.resourceIndex),$e();const a=document.createElement("div");if(a.dataset.filesWrapper=r,a.dataset.resourceIds=JSON.stringify(e),n.appendChild(a),e.length===0){const c=document.createElement("div");c.className="fb-tile-empty-text",c.textContent=k("noFilesSelected",t),a.appendChild(c);return}const l=document.createElement("div");l.className="fb-multi-readonly-grid",a.appendChild(l);const i=e.map(()=>{const c=document.createElement("div");return c.className="fb-readonly-tile fb-checker fb-tile",l.appendChild(c),c});for(let c=0;c<e.length;c++){const s=e[c],f=i[c],d=t.resourceIndex.get(s);Nt(s,t,d==null?void 0:d.name).then(u=>{u.classList.add("fb-readonly-tile","fb-checker","fb-tile-resource"),u.dataset.resourceId=s,f.replaceWith(u)}).catch(()=>{const u=document.createElement("div");u.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",u.dataset.resourceId=s,f.replaceWith(u)})}}function Go(e,t,n,r){const o=t.prefill[e.key],a=Array.isArray(o)?o:[];Bn(a,t.state,n,r)}function Zo(e,t,n,r){const o=t.prefill[e.key],a=Array.isArray(o)?o:[];Bn(a,t.state,n,r)}function Qo(e,t,n,r){ae(e,t.state,t)?Xo(e,t,n,r):Uo(e,t,n,r)}function el(e,t,n,r){ae(e,t.state,t)?Go(e,t,n,r):Po(e,t,n,r)}function tl(e,t,n,r){ae(e,t.state,t)?Zo(e,t,n,r):Wo(e,t,n,r)}function Hn(e,t,n,r){const{scopeRoot:o,state:a}=r;if(e.type==="files"||"multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateFileField: Expected array for multiple file field "${t}", got ${typeof n}`);return}n.forEach(i=>{i&&typeof i=="string"&&ct(i,a.resourceIndex)});const l=o.querySelector(`[data-files-wrapper="${t}"]`);l?l.dataset.resourceIds=JSON.stringify(n):console.warn(`updateFileField: [data-files-wrapper="${t}"] not found in DOM; data-resource-ids not updated`)}else{const l=o.querySelector(`input[name="${t}"][type="hidden"]`);if(!l){console.warn(`updateFileField: Hidden input not found for file field "${t}"`);return}l.value=n!=null?String(n):"",n&&typeof n=="string"&&(ct(n,a.resourceIndex),console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`))}}function Pe(e){return e?e.toUpperCase():"#000000"}function Bt(e){return/^#[0-9A-F]{6}$/i.test(e)||/^#[0-9A-F]{3}$/i.test(e)}function Dn(e){if(/^#[0-9A-F]{3}$/i.test(e)){const t=e[1],n=e[2],r=e[3];return`#${t}${t}${n}${n}${r}${r}`.toUpperCase()}return e.toUpperCase()}function jn(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=Pe(e),r=document.createElement("div");r.style.cssText=`
|
|
1070
1070
|
width: 32px;
|
|
1071
1071
|
height: 32px;
|
|
1072
1072
|
border-radius: var(--fb-border-radius);
|
|
@@ -1089,7 +1089,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1089
1089
|
cursor: pointer;
|
|
1090
1090
|
transition: border-color var(--fb-transition-duration) ease-in-out;
|
|
1091
1091
|
flex-shrink: 0;
|
|
1092
|
-
`;const
|
|
1092
|
+
`;const l=document.createElement("input");l.type="text",l.className="colour-hex-input",l.name=t,l.value=r,l.placeholder="#000000",l.style.cssText=`
|
|
1093
1093
|
width: 100px;
|
|
1094
1094
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
1095
1095
|
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
@@ -1099,43 +1099,43 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1099
1099
|
font-size: var(--fb-font-size);
|
|
1100
1100
|
font-family: var(--fb-font-family-mono, monospace);
|
|
1101
1101
|
transition: all var(--fb-transition-duration) ease-in-out;
|
|
1102
|
-
`;const
|
|
1102
|
+
`;const i=document.createElement("input");return i.type="color",i.className="colour-picker-hidden",i.value=r.toLowerCase(),i.style.cssText=`
|
|
1103
1103
|
position: absolute;
|
|
1104
1104
|
opacity: 0;
|
|
1105
1105
|
pointer-events: none;
|
|
1106
|
-
`,
|
|
1106
|
+
`,l.addEventListener("input",()=>{const c=l.value.trim();if(Bt(c)){const s=Dn(c);a.style.backgroundColor=s,i.value=s.toLowerCase(),l.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,s)}else l.classList.add("invalid")}),l.addEventListener("blur",()=>{const c=l.value.trim();if(Bt(c)){const s=Dn(c);l.value=s,a.style.backgroundColor=s,i.value=s.toLowerCase(),l.classList.remove("invalid")}}),i.addEventListener("change",()=>{const c=Pe(i.value);l.value=c,a.style.backgroundColor=c,n.instance&&n.instance.triggerOnChange(t,c)}),a.addEventListener("click",()=>{i.click()}),a.addEventListener("mouseenter",()=>{a.style.borderColor="var(--fb-border-hover-color)"}),a.addEventListener("mouseleave",()=>{a.style.borderColor="var(--fb-border-color)"}),l.addEventListener("focus",()=>{l.style.borderColor="var(--fb-border-focus-color)",l.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",l.style.outlineOffset="0"}),l.addEventListener("blur",()=>{l.style.borderColor="var(--fb-border-color)",l.style.outline="none"}),l.addEventListener("mouseenter",()=>{document.activeElement!==l&&(l.style.borderColor="var(--fb-border-hover-color)")}),l.addEventListener("mouseleave",()=>{document.activeElement!==l&&(l.style.borderColor="var(--fb-border-color)")}),o.appendChild(a),o.appendChild(l),o.appendChild(i),o}function nl(e,t,n,r){const o=t.state,a=ae(e,o,t),l=t.prefill[e.key]||e.default||"#000000";if(a){const i=jn(l);n.appendChild(i)}else{const i=On(l,r,t);n.appendChild(i)}if(!a){const i=document.createElement("p");i.className="mt-1",i.style.cssText=`
|
|
1107
1107
|
font-size: var(--fb-font-size-small);
|
|
1108
1108
|
color: var(--fb-text-secondary-color);
|
|
1109
|
-
`,
|
|
1109
|
+
`,i.textContent=Le(e,o),n.appendChild(i)}}function rl(e,t,n,r){var o,a;const l=t.state,i=ae(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:e.required?1:0,d=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"#000000");const u=document.createElement("div");u.className="fb-row",n.appendChild(u);function p(){u.querySelectorAll(".multiple-colour-item").forEach((h,y)=>{const v=h.querySelector("input");v&&(v.name=`${r}[${y}]`)})}function m(h="#000000",y=-1){const v=document.createElement("div");if(v.className="multiple-colour-item flex items-center gap-2",i){const C=jn(h);for(;C.firstChild;)v.appendChild(C.firstChild)}else{const C=`${r}[${u.children.length}]`,w=On(h,C,t);w.style.flex="1",v.appendChild(w)}return y===-1?u.appendChild(v):u.insertBefore(v,u.children[y]),p(),v}function b(){if(i)return;const h=u.querySelectorAll(".multiple-colour-item"),y=h.length;h.forEach(v=>{let C=v.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn px-2 py-1 rounded",C.style.cssText=`
|
|
1110
1110
|
color: var(--fb-error-color);
|
|
1111
1111
|
background-color: transparent;
|
|
1112
1112
|
transition: background-color var(--fb-transition-duration);
|
|
1113
|
-
`,C.innerHTML="\u2715",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{const
|
|
1113
|
+
`,C.innerHTML="\u2715",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{var x;const S=Array.from(u.children).indexOf(v);u.children.length>f&&(s.splice(S,1),v.remove(),p(),E(),b(),(x=t.instance)==null||x.triggerOnChange(r))},v.appendChild(C));const w=y<=f;C.disabled=w,C.style.opacity=w?"0.5":"1",C.style.pointerEvents=w?"none":"auto"})}let g=null;if(!i){const h=ze("colour",()=>{var y;const v=e.default||"#000000";s.push(v),m(v),E(),b(),(y=t.instance)==null||y.triggerOnChange(r)},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){g&&g(s.length,d)}if(s.forEach(h=>m(h)),E(),b(),!i){const h=document.createElement("p");h.className="mt-1",h.style.cssText=`
|
|
1114
1114
|
font-size: var(--fb-font-size-small);
|
|
1115
1115
|
color: var(--fb-text-secondary-color);
|
|
1116
|
-
`,h.textContent=Le(e,
|
|
1116
|
+
`,h.textContent=Le(e,l),n.appendChild(h)}}function ol(e,t,n){var r,o,a;const l=[],{scopeRoot:i,skipValidation:c}=n,s=(d,u)=>{var p,m;if(!d)return;const b=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(b);u?(d.classList.add("invalid"),d.title=u,g||(g=document.createElement("div"),g.id=b,g.className="error-message",g.style.cssText=`
|
|
1117
1117
|
color: var(--fb-error-color);
|
|
1118
1118
|
font-size: var(--fb-font-size-small);
|
|
1119
1119
|
margin-top: 0.25rem;
|
|
1120
|
-
`,
|
|
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=`
|
|
1121
1121
|
height: 6px;
|
|
1122
1122
|
border-radius: 3px;
|
|
1123
1123
|
background: linear-gradient(
|
|
1124
1124
|
to right,
|
|
1125
1125
|
var(--fb-primary-color) 0%,
|
|
1126
|
-
var(--fb-primary-color) ${(e-
|
|
1127
|
-
var(--fb-border-color) ${(e-
|
|
1126
|
+
var(--fb-primary-color) ${(e-d)/(u-d)*100}%,
|
|
1127
|
+
var(--fb-border-color) ${(e-d)/(u-d)*100}%,
|
|
1128
1128
|
var(--fb-border-color) 100%
|
|
1129
1129
|
);
|
|
1130
1130
|
outline: none;
|
|
1131
1131
|
transition: background 0.1s ease-in-out;
|
|
1132
1132
|
cursor: ${o?"not-allowed":"pointer"};
|
|
1133
1133
|
opacity: ${o?"0.6":"1"};
|
|
1134
|
-
`,
|
|
1134
|
+
`,c.appendChild(s);const m=document.createElement("div");m.className="flex justify-between",m.style.cssText=`
|
|
1135
1135
|
font-size: var(--fb-font-size-small);
|
|
1136
1136
|
color: var(--fb-text-secondary-color);
|
|
1137
1137
|
margin-top: 4px;
|
|
1138
|
-
`;const b=document.createElement("span");b.textContent=
|
|
1138
|
+
`;const b=document.createElement("span");b.textContent=d.toString();const g=document.createElement("span");g.textContent=u.toString(),m.appendChild(b),m.appendChild(g),c.appendChild(m);const E=document.createElement("span");if(E.className="slider-value",E.style.cssText=`
|
|
1139
1139
|
min-width: 60px;
|
|
1140
1140
|
text-align: right;
|
|
1141
1141
|
font-size: var(--fb-font-size);
|
|
@@ -1143,40 +1143,40 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1143
1143
|
font-family: var(--fb-font-family-mono, monospace);
|
|
1144
1144
|
font-weight: 500;
|
|
1145
1145
|
padding-top: 2px;
|
|
1146
|
-
`,E.textContent=e.toFixed(p<1?2:0),
|
|
1146
|
+
`,E.textContent=e.toFixed(p<1?2:0),i.appendChild(c),i.appendChild(E),l.appendChild(i),!o){const h=()=>{let y;if(f==="exponential"){const C=parseFloat(s.value)/1e3;y=Un(C,d,u),y=pt(y,p),y=Math.max(d,Math.min(u,y))}else y=parseFloat(s.value),y=pt(y,p);E.textContent=y.toFixed(p<1?2:0);const v=(y-d)/(u-d)*100;s.style.background=`linear-gradient(
|
|
1147
1147
|
to right,
|
|
1148
1148
|
var(--fb-primary-color) 0%,
|
|
1149
|
-
var(--fb-primary-color) ${
|
|
1150
|
-
var(--fb-border-color) ${
|
|
1149
|
+
var(--fb-primary-color) ${v}%,
|
|
1150
|
+
var(--fb-border-color) ${v}%,
|
|
1151
1151
|
var(--fb-border-color) 100%
|
|
1152
|
-
)`,r.instance&&r.instance.triggerOnChange(t,y)};s.addEventListener("input",h),s.addEventListener("change",h)}return
|
|
1152
|
+
)`,r.instance&&r.instance.triggerOnChange(t,y)};s.addEventListener("input",h),s.addEventListener("change",h)}return l}function il(e,t,n,r){var o;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const a=t.state,l=ae(e,a,t),i=e.default!==void 0?e.default:(e.min+e.max)/2,c=(o=t.prefill[e.key])!=null?o:i,s=Pn(c,r,e,t,l);if(n.appendChild(s),!l){const f=document.createElement("p");f.className="mt-1",f.style.cssText=`
|
|
1153
1153
|
font-size: var(--fb-font-size-small);
|
|
1154
1154
|
color: var(--fb-text-secondary-color);
|
|
1155
|
-
`,f.textContent=Le(e,a),n.appendChild(f)}}function
|
|
1155
|
+
`,f.textContent=Le(e,a),n.appendChild(f)}}function al(e,t,n,r){var o,a;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const l=t.state,i=ae(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:e.required?1:0,d=(a=e.maxCount)!=null?a:1/0,u=e.default!==void 0?e.default:(e.min+e.max)/2;for(;s.length<f;)s.push(u);const p=document.createElement("div");p.className="space-y-3",n.appendChild(p);function m(){p.querySelectorAll(".multiple-slider-item").forEach((y,v)=>{const C=y.querySelector("input[type=range]");C&&C.setAttribute("name",`${r}[${v}]`)})}function b(y=u,v=-1){const C=document.createElement("div");C.className="multiple-slider-item flex items-start gap-2";const w=`${r}[${p.children.length}]`,x=Pn(y,w,e,t,i);return x.style.flex="1",C.appendChild(x),v===-1?p.appendChild(C):p.insertBefore(C,p.children[v]),m(),C}function g(){if(i)return;const y=p.querySelectorAll(".multiple-slider-item"),v=y.length;y.forEach(C=>{let w=C.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn px-2 py-1 rounded",w.style.cssText=`
|
|
1156
1156
|
color: var(--fb-error-color);
|
|
1157
1157
|
background-color: transparent;
|
|
1158
1158
|
transition: background-color var(--fb-transition-duration);
|
|
1159
1159
|
margin-top: 8px;
|
|
1160
|
-
`,w.innerHTML="\u2715",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{const
|
|
1160
|
+
`,w.innerHTML="\u2715",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{var S;const z=Array.from(p.children).indexOf(C);p.children.length>f&&(s.splice(z,1),C.remove(),m(),h(),g(),(S=t.instance)==null||S.triggerOnChange(r))},C.appendChild(w));const x=v<=f;w.disabled=x,w.style.opacity=x?"0.5":"1",w.style.pointerEvents=x?"none":"auto"})}let E=null;if(!i){const y=ze("slider",()=>{var v;s.push(u),b(u),h(),g(),(v=t.instance)==null||v.triggerOnChange(r)},{label:e.addLabel});E=y.update,Te(n,y.counter),n.appendChild(y.row)}function h(){E&&E(s.length,d)}if(s.forEach(y=>b(y)),h(),g(),!i){const y=document.createElement("p");y.className="mt-1",y.style.cssText=`
|
|
1161
1161
|
font-size: var(--fb-font-size-small);
|
|
1162
1162
|
color: var(--fb-text-secondary-color);
|
|
1163
|
-
`,y.textContent=Le(e,
|
|
1163
|
+
`,y.textContent=Le(e,l),n.appendChild(y)}}function sl(e,t,n){var r,o,a;const l=[],{scopeRoot:i,skipValidation:c}=n;if(e.min===void 0||e.min===null)throw new Error(`Slider validation: field "${t}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider validation: field "${t}" requires "max" property`);const s=e.min,f=e.max,d=(r=e.step)!=null?r:1,u=e.scale||"linear",p=(b,g)=>{var E,h;if(!b)return;const y=`error-${b.getAttribute("name")||Math.random().toString(36).substring(7)}`;let v=document.getElementById(y);if(g){if(b.classList.add("invalid"),b.title=g,!v){v=document.createElement("div"),v.id=y,v.className="error-message",v.style.cssText=`
|
|
1164
1164
|
color: var(--fb-error-color);
|
|
1165
1165
|
font-size: var(--fb-font-size-small);
|
|
1166
1166
|
margin-top: 0.25rem;
|
|
1167
|
-
`;const C=b.closest(".slider-container");C&&C.nextSibling?(E=C.parentNode)==null||E.insertBefore(
|
|
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(
|
|
1168
1168
|
to right,
|
|
1169
1169
|
var(--fb-primary-color) 0%,
|
|
1170
|
-
var(--fb-primary-color) ${
|
|
1171
|
-
var(--fb-border-color) ${
|
|
1170
|
+
var(--fb-primary-color) ${g}%,
|
|
1171
|
+
var(--fb-border-color) ${g}%,
|
|
1172
1172
|
var(--fb-border-color) 100%
|
|
1173
|
-
)`}
|
|
1173
|
+
)`}d.classList.remove("invalid"),d.title="",Ce(d)}}),n.length!==f.length&&console.warn(`updateSliderField: Multiple field "${t}" has ${f.length} sliders but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const f=a.querySelector(`input[type="range"][name="${t}"]`);if(f&&n!==null&&n!==void 0){const d=Number(n);if(s==="exponential"){const p=Ht(d,l,i);f.value=(p*1e3).toString()}else f.value=d.toString();const u=f.closest(".slider-container");if(u){const p=u.querySelector(".slider-value");p&&(p.textContent=d.toFixed(c<1?2:0));const m=(d-l)/(i-l)*100;f.style.background=`linear-gradient(
|
|
1174
1174
|
to right,
|
|
1175
1175
|
var(--fb-primary-color) 0%,
|
|
1176
1176
|
var(--fb-primary-color) ${m}%,
|
|
1177
1177
|
var(--fb-border-color) ${m}%,
|
|
1178
1178
|
var(--fb-border-color) 100%
|
|
1179
|
-
)`}f.classList.remove("invalid"),f.title="",Ce(f)}}}function Wn(e){const t={};for(const n of e)n.key&&"default"in n&&n.default!==void 0&&(t[n.key]=n.default);return t}function Vn(e,t){return{...t,...e}}function
|
|
1179
|
+
)`}f.classList.remove("invalid"),f.title="",Ce(f)}}}function Wn(e){const t={};for(const n of e)n.key&&"default"in n&&n.default!==void 0&&(t[n.key]=n.default);return t}function Vn(e,t){return{...t,...e}}function Dt(e){const t={};return e.querySelectorAll("input, select, textarea").forEach(n=>{const r=n.getAttribute("name");r&&!r.includes("[")&&!r.includes(".")&&(n instanceof HTMLSelectElement?t[r]=n.value:n instanceof HTMLInputElement?n.type==="checkbox"?t[r]=n.checked:n.type==="radio"?n.checked&&(t[r]=n.value):n.dataset.hiddenField?t[r]=Ct(n.value):t[r]=n.value:n instanceof HTMLTextAreaElement&&(t[r]=n.value))}),t}let jt=null;function dl(e){jt=e}function Kn(e,t){if(!jt)throw new Error("renderElement not initialized. Import from components/index.ts");return jt(e,t)}function _n(e,t){if(!e.prefillHints||e.prefillHints.length===0)return null;const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",e.prefillHints.forEach((r,o)=>{const a=document.createElement("button");a.type="button",a.className="fb-prefill-hint",a.textContent=r.label,a.setAttribute("data-hint-values",JSON.stringify(r.values)),a.setAttribute("data-container-key",t),a.setAttribute("data-hint-index",String(o)),n.appendChild(a)}),n}function Jn(e,t,n,r){var o,a;const l=document.createElement("div");l.className="border border-gray-200 rounded-lg p-2 bg-gray-50",l.setAttribute("data-container",r);const i=document.createElement("div"),c=e.columns||1;c===1?i.className="fb-row":i.className=`grid grid-cols-${c} gap-2`;const s=ae(e,t.state,t);if(!s){const m=_n(e,r);m&&l.appendChild(m)}const f=Wn(e.elements),d=((o=t.prefill)==null?void 0:o[e.key])||{},u=Vn(d,f),p={path:De(t.path,e.key),prefill:u,formData:(a=t.formData)!=null?a:t.prefill,state:t.state,instance:t.instance,inheritedReadonly:s||t.inheritedReadonly};e.elements.forEach(m=>{var b,g;if(m.type!=="markdown"&&(m.hidden||m.type==="hidden")){const E=(g=(b=d[m.key])!=null?b:"default"in m?m.default:null)!=null?g:null;i.appendChild(Et(De(p.path,m.key),E))}else i.appendChild(Kn(m,p))}),l.appendChild(i),n.appendChild(l)}function ul(e){const t=e||1;return t===1?"fb-row":`grid grid-cols-${t} gap-2`}function fl(e,t,n,r){const o=document.createElement("button");o.type="button",o.className="fb-item-remove",o.setAttribute("aria-label",r?k("removeRowFrom",n,{label:r}):k("removeRow",n)),o.style.cssText=`
|
|
1180
1180
|
width: 24px;
|
|
1181
1181
|
height: 24px;
|
|
1182
1182
|
display: inline-flex;
|
|
@@ -1187,7 +1187,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1187
1187
|
border-radius: 4px;
|
|
1188
1188
|
cursor: pointer;
|
|
1189
1189
|
flex-shrink: 0;
|
|
1190
|
-
`,o.innerHTML=
|
|
1190
|
+
`,o.innerHTML=Qt,o.onclick=t,o.style.position="absolute",o.style.top="var(--fb-row-remove-inset, 8px)",o.style.right="var(--fb-row-remove-inset, 8px)",o.style.zIndex="1",e.style.position="relative",e.classList.add("fb-row-removable"),e.insertBefore(o,e.firstChild)}function Xn(e,t,n,r){var o,a,l,i;const c=t.state,s=ae(e,c,t),f=s||t.inheritedReadonly,d=document.createElement("div");d.className="border border-gray-200 rounded-lg p-2 bg-gray-50";const u=document.createElement("div"),p=e.displayMode==="slides";if(p?u.className="fb-container-slides":u.className="fb-row",!s){const R=_n(e,e.key);R&&d.appendChild(R)}const m=(o=e.minCount)!=null?o:0,b=(a=e.maxCount)!=null?a:1/0,g=Array.isArray((l=t.prefill)==null?void 0:l[e.key])?t.prefill[e.key]:null,E=Wn(e.elements);let h=0;const y=()=>h++,v=()=>Array.from(u.children).filter(R=>R.classList.contains("containerItem")),C=()=>v().length,w=R=>{var _;C()<=m||(R.remove(),ne(),(_=t.instance)==null||_.triggerOnChange(r))},x=(R,_,ie)=>{const pe={state:c,instance:t.instance,path:De(t.path,`${e.key}[${R}]`),prefill:Vn(_!=null?_:{},E),formData:ie,inheritedReadonly:f},me=document.createElement("div");me.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",me.setAttribute("data-container-item",pe.path),p&&me.setAttribute("data-fb-slide-card","");const Ae=document.createElement("div");return Ae.className=ul(p?void 0:e.columns),e.elements.forEach(xe=>{var $,I;if(xe.type!=="markdown"&&(xe.hidden||xe.type==="hidden")){const M=(I=($=_==null?void 0:_[xe.key])!=null?$:"default"in xe?xe.default:null)!=null?I:null;Ae.appendChild(Et(De(pe.path,xe.key),M))}else Ae.appendChild(Kn(xe,pe))}),me.appendChild(Ae),s||fl(me,()=>w(me),c,e.label),me},S=()=>{var R;if(C()>=b)return;const _=x(y(),null,c.formRoot?Dt(c.formRoot):{});z&&z.parentElement===u?u.insertBefore(_,z):u.appendChild(_),ne(),(R=t.instance)==null||R.triggerOnChange(r)};let z=null,ee=null,K=null;const H=()=>{if(!z)return;const R=v()[0];R&&R.offsetHeight>0&&(z.style.minHeight=`${R.offsetHeight}px`)},V=()=>{const R=C()<=m;v().forEach(_=>{const ie=Array.from(_.children).find(pe=>pe.classList.contains("fb-item-remove"));ie&&(ie.disabled=R)})},ne=()=>{const R=C();ee&&ee(R,b),K&&K(R,b),z&&H(),V()};if(g&&g.forEach(R=>{var _;u.appendChild(x(y(),R!=null?R:{},(_=t.formData)!=null?_:t.prefill))}),!s)for(;C()<m;)u.appendChild(x(y(),null,(i=t.formData)!=null?i:t.prefill));if(d.appendChild(u),!s)if(p){const R=Tr(S,{label:e.addLabel});z=R.tile,ee=R.update,Te(n,R.counter),u.appendChild(R.tile)}else{const R=ze("container",S,{label:e.addLabel});K=R.update,Te(n,R.counter),d.appendChild(R.row)}ne(),n.appendChild(d),z&&(typeof requestAnimationFrame=="function"?requestAnimationFrame(H):H())}let Ot=null;function pl(e){Ot=e}function Yn(e,t,n){if(!Ot)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return Ot(e,t,n)}function Gn(e,t,n){const r=[],{scopeRoot:o,skipValidation:a,path:l}=n;if(!("elements"in e))return{value:null,errors:r};const i=(c,s,f)=>{var d,u;if(a)return;const{state:p}=n,m="minCount"in f&&(d=f.minCount)!=null?d:0,b="maxCount"in f&&(u=f.maxCount)!=null?u:1/0;f.required&&s.length===0&&r.push(`${c}: ${k("required",p)}`),s.length<m&&r.push(`${c}: ${k("minItems",p,{min:m})}`),s.length>b&&r.push(`${c}: ${k("maxItems",p,{max:b})}`)};if("multiple"in e&&e.multiple){const c=[];return nt(o,t).forEach(s=>{const f={},d=(s.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),u=d?parseInt(d[1],10):0;e.elements.forEach(p=>{var m;if(p.enableIf)try{const E=(m=n.instance)!=null&&m.getState().formRoot?Dt(n.instance.getState().formRoot):{};if(!je(p.enableIf,E,f))return}catch(E){console.error(`Error evaluating enableIf for field "${p.key}" in container "${t}[${u}]":`,E)}const b=`${t}[${u}].${p.key}`,g=Yn({...p,key:b},{path:l},s);g.spread&&g.value!==null&&typeof g.value=="object"?Object.assign(f,g.value):!g.skip&&p.key&&(f[p.key]=g.value)}),c.push(f)}),i(t,c,e),{value:c,errors:r}}else{const c={},s=o.querySelector(`[data-container="${t}"]`)||o;return e.elements.forEach(f=>{var d;if(f.enableIf)try{const u=(d=n.instance)!=null&&d.getState().formRoot?Dt(n.instance.getState().formRoot):{};if(!je(f.enableIf,u,c))return}catch(u){console.error(`Error evaluating enableIf for field "${f.key}" in container "${t}":`,u)}{const u=`${t}.${f.key}`,p=Yn({...f,key:u},{path:l},s);p.spread&&p.value!==null&&typeof p.value=="object"?Object.assign(c,p.value):!p.skip&&f.key&&(c[f.key]=p.value)}}),{value:c,errors:r}}}function Zn(e,t,n,r){const{instance:o,scopeRoot:a}=r;if("elements"in e)if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateContainerField: Expected array for multiple container field "${t}", got ${typeof n}`);return}const l=nt(a,t);n.forEach((i,c)=>{var s;const f=(s=l[c])==null?void 0:s.getAttribute("data-container-item");Je(i)&&f&&e.elements.forEach(d=>{var u,p;if(d.type==="markdown"||!d.key)return;const m=`${f}.${d.key}`;if(d.type==="richinput"&&d.flatOutput){const b=d,g=(u=b.textKey)!=null?u:"text",E=(p=b.filesKey)!=null?p:"files",h=i,y={};g in h&&(y[g]=h[g]),E in h&&(y[E]=h[E]),Object.keys(y).length>0&&o.updateField(m,y)}else{const b=i[d.key];b!==void 0&&o.updateField(m,b)}})}),n.length!==l.length&&console.warn(`updateContainerField: Multiple container field "${t}" received ${n.length} items for ${l.length} rendered rows. Rows are not added or removed here \u2014 re-render for add/remove.`)}else{if(!Je(n)){console.warn(`updateContainerField: Expected object for container field "${t}", got ${typeof n}`);return}e.elements.forEach(l=>{var i,c;if(l.type==="markdown"||!l.key)return;const s=`${t}.${l.key}`;if(l.type==="richinput"&&l.flatOutput){const f=l,d=(i=f.textKey)!=null?i:"text",u=(c=f.filesKey)!=null?c:"files",p=n,m={};d in p&&(m[d]=p[d]),u in p&&(m[u]=p[u]),Object.keys(m).length>0&&o.updateField(s,m)}else{const f=n[l.key];f!==void 0&&o.updateField(s,f)}})}}function ml(e,t,n,r){var o,a;typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated and will be removed in a future version. Please use type: "container" with multiple: true instead. Field key: "${e.key}"`);const l={key:e.key,label:e.label,description:e.description,hint:e.hint,required:e.required,hidden:e.hidden,default:e.default,actions:e.actions,elements:e.elements,multiple:!!(e.repeat&&Je(e.repeat)),minCount:(o=e.repeat)==null?void 0:o.min,maxCount:(a=e.repeat)==null?void 0:a.max};l.multiple?Xn(l,t,n,r):Jn(l,t,n,r)}function Qn(e){var t,n;const r=e;return{type:"container",key:r.key,label:r.label,description:r.description,hint:r.hint,required:r.required,hidden:r.hidden,default:r.default,actions:r.actions,elements:r.elements,multiple:!!(r.repeat&&Je(r.repeat)),minCount:(t=r.repeat)==null?void 0:t.min,maxCount:(n=r.repeat)==null?void 0:n.max}}function hl(e,t,n){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field key: "${t}"`);const r=Qn(e);return Gn(r,t,n)}function bl(e,t,n,r){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field path: "${t}"`);const o=Qn(e);return Zn(o,t,n,r)}function gl(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function vl(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.top=="number"&&typeof t.left=="number"&&typeof t.bottom=="number"&&typeof t.right=="number"}function yl(e){return gl(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:vl(e)?e:null}function We(e){return e.map(yl).filter(t=>t!==null)}function er(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function Ut(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(o.top<0||o.left<0||o.bottom>=t||o.right>=n||o.top>o.bottom||o.left>o.right)return`Merge ${r} out of bounds`;for(let a=r+1;a<e.length;a++){const l=e[a];if(o.top<=l.bottom&&o.bottom>=l.top&&o.left<=l.right&&o.right>=l.left)return`Merges ${r} and ${a} overlap`}}return null}function tr(e,t,n){for(const r of n){if(r.top===e&&r.left===t)return null;if(e>=r.top&&e<=r.bottom&&t>=r.left&&t<=r.right)return r}return null}function mt(e,t,n){var r;return(r=n.find(o=>o.top===e&&o.left===t))!=null?r:null}function Ne(e){var t;if(!e.anchor)return null;const n=(t=e.focus)!=null?t:e.anchor;return{r1:Math.min(e.anchor.row,n.row),c1:Math.min(e.anchor.col,n.col),r2:Math.max(e.anchor.row,n.row),c2:Math.max(e.anchor.col,n.col)}}function Ve(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
|
|
1191
1191
|
position: absolute;
|
|
1192
1192
|
width: ${e.size}px;
|
|
1193
1193
|
height: ${e.size}px;
|
|
@@ -1207,7 +1207,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1207
1207
|
box-shadow: 0 1px 4px rgba(0,0,0,0.2);
|
|
1208
1208
|
transition: transform 0.1s, opacity 0.1s;
|
|
1209
1209
|
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
|
|
1210
|
+
`,t.addEventListener("mouseenter",()=>{t.style.transform="scale(1.15)"}),t.addEventListener("mouseleave",()=>{t.style.transform="scale(1)"}),t.addEventListener("click",n=>{n.stopPropagation(),e.onClick(n)}),t}function xl(e,t){const{cells:n,merges:r=[]}=e;if(n.length===0)return;const o=n[0].length,a=document.createElement("table");a.style.cssText=`
|
|
1211
1211
|
width: 100%;
|
|
1212
1212
|
border-collapse: collapse;
|
|
1213
1213
|
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
@@ -1215,13 +1215,13 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1215
1215
|
font-size: var(--fb-font-size);
|
|
1216
1216
|
font-family: var(--fb-font-family);
|
|
1217
1217
|
color: var(--fb-text-color);
|
|
1218
|
-
`,n.forEach((
|
|
1218
|
+
`,n.forEach((i,c)=>{var s,f;const d=(c===0?a.createTHead():(s=a.tBodies[0])!=null?s:a.createTBody()).insertRow();for(let u=0;u<o;u++){if(tr(c,u,r))continue;const p=mt(c,u,r),m=document.createElement(c===0?"th":"td");if(p){const b=p.bottom-p.top+1,g=p.right-p.left+1;b>1&&(m.rowSpan=b),g>1&&(m.colSpan=g)}m.textContent=(f=i[u])!=null?f:"",m.style.cssText=`
|
|
1219
1219
|
padding: 6px 10px;
|
|
1220
1220
|
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
1221
1221
|
text-align: left;
|
|
1222
1222
|
vertical-align: top;
|
|
1223
|
-
${
|
|
1224
|
-
`,
|
|
1223
|
+
${c===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
|
|
1224
|
+
`,d.appendChild(m)}});const l=document.createElement("div");l.style.cssText="overflow-x: auto; max-width: 100%;",l.appendChild(a),t.appendChild(l)}function wl(e,t,n,r,o,a){if(e.contentEditable==="true")return;e.contentEditable="true",e.focus();const l=document.createRange(),i=window.getSelection();l.selectNodeContents(e),l.collapse(!1),i==null||i.removeAllRanges(),i==null||i.addRange(l);function c(){var d;e.contentEditable="inherit";const u=r();u[t]&&(u[t][n]=(d=e.textContent)!=null?d:""),o()}function s(d){var u,p,m,b;const g=r(),E=(p=(u=g[0])==null?void 0:u.length)!=null?p:0;if(d.key==="Escape"){e.contentEditable="inherit",e.textContent=(b=(m=g[t])==null?void 0:m[n])!=null?b:"",e.removeEventListener("keydown",s),e.removeEventListener("blur",f);return}if(d.key==="Enter"&&!d.shiftKey){d.preventDefault(),d.stopPropagation(),c(),e.removeEventListener("keydown",s),e.removeEventListener("blur",f);const h=t+1<g.length?t+1:t;a(h,n);return}if(d.key==="Tab"){d.preventDefault(),d.stopPropagation(),c(),e.removeEventListener("keydown",s),e.removeEventListener("blur",f);let h=t,y=d.shiftKey?n-1:n+1;y<0&&(y=E-1,h=Math.max(0,t-1)),y>=E&&(y=0,h=Math.min(g.length-1,t+1)),a(h,y)}}function f(){e.contentEditable==="true"&&(c(),e.removeEventListener("keydown",s),e.removeEventListener("blur",f))}e.addEventListener("keydown",s),e.addEventListener("blur",f)}function Cl(){if(document.getElementById("fb-spin-keyframes"))return;const e=document.createElement("style");e.id="fb-spin-keyframes",e.textContent="@keyframes fb-spin { to { transform: rotate(360deg); } }",document.head.appendChild(e)}function El(e,t){Cl();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
|
|
1225
1225
|
position: absolute; top: 0; left: 0; right: 0; bottom: 0;
|
|
1226
1226
|
background: rgba(255,255,255,0.8); display: flex;
|
|
1227
1227
|
align-items: center; justify-content: center; flex-direction: column;
|
|
@@ -1230,13 +1230,13 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1230
1230
|
width: 24px; height: 24px; border: 3px solid var(--fb-border-color, #ccc);
|
|
1231
1231
|
border-top-color: var(--fb-primary-color, #0066cc); border-radius: 50%;
|
|
1232
1232
|
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
|
|
1233
|
+
`;const o=document.createElement("span");return o.textContent=t,o.style.cssText="font-size: var(--fb-font-size-small, 12px); color: var(--fb-text-color, #333);",n.appendChild(r),n.appendChild(o),e.appendChild(n),n}function kl(e,t,n,r,o){var a,l,i,c,s,f,d,u;const p=r.state,m=r.instance,b=e.mergeAllowed!==!1,g=(l=(a=e.fieldNames)==null?void 0:a.cells)!=null?l:"cells",E=(c=(i=e.fieldNames)==null?void 0:i.merges)!=null?c:"merges",h=t.cells.length>0?t.cells.map(A=>[...A]):er((s=e.rows)!=null?s:3,(f=e.columns)!=null?f:3);let y=t.merges?[...t.merges]:[];const v={anchor:null,focus:null,dragging:!1},C=document.createElement("input");C.type="hidden",C.name=n,C.value=JSON.stringify({[g]:h,[E]:y}),o.appendChild(C);function w(){C.value=JSON.stringify({[g]:h,[E]:y}),m&&m.triggerOnChange(n,{[g]:h,[E]:y})}C._applyExternalUpdate=A=>{h.length=0,A.cells.forEach(T=>h.push([...T])),y.length=0,A.merges&&A.merges.forEach(T=>y.push({...T})),v.anchor=null,v.focus=null,w(),N()};const x=document.createElement("div");x.style.cssText="position: relative; padding: 20px 20px 20px 24px; overflow-x: auto; max-width: 100%;";const S=document.createElement("table");S.style.cssText=`
|
|
1234
1234
|
border-collapse: collapse;
|
|
1235
1235
|
font-size: var(--fb-font-size);
|
|
1236
1236
|
font-family: var(--fb-font-family);
|
|
1237
1237
|
color: var(--fb-text-color);
|
|
1238
1238
|
table-layout: fixed;
|
|
1239
|
-
`,x.appendChild(S);const z=(u=(
|
|
1239
|
+
`,x.appendChild(S);const z=(u=(d=e.importAccept)==null?void 0:d.map(A=>`.${A.toLowerCase()}`))!=null?u:[];async function ee(A){var T,L,D;if(!p.config.parseTableFile)return;if(z.length>0){const F=A.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!z.includes(F))return}const j=El(x,k("tableImporting",p));try{const F=await p.config.parseTableFile(A),te=F.cells,U=(T=F.merges)!=null?T:[];if(U.length>0){const P=Ut(U,te.length,(D=(L=te[0])==null?void 0:L.length)!=null?D:0);if(P)throw new Error(P)}h.length=0,te.forEach(P=>h.push([...P])),y.length=0,U.forEach(P=>y.push({...P})),v.anchor=null,v.focus=null,w(),N()}catch(F){const te=F instanceof Error?F.message:String(F);console.error(k("tableImportError",p).replace("{error}",te))}finally{j.remove()}}if(e.importAccept&&p.config.parseTableFile){const A=document.createElement("button");A.type="button",A.title=k("tableImportFile",p),A.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"/></svg>',A.style.cssText=`
|
|
1240
1240
|
position: absolute; top: 2px; left: 2px;
|
|
1241
1241
|
width: 20px; height: 20px;
|
|
1242
1242
|
padding: 0;
|
|
@@ -1246,7 +1246,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1246
1246
|
background: transparent;
|
|
1247
1247
|
cursor: pointer;
|
|
1248
1248
|
z-index: 2;
|
|
1249
|
-
`,A.addEventListener("mouseenter",()=>{A.style.color="var(--fb-primary-color, #0066cc)"}),A.addEventListener("mouseleave",()=>{A.style.color="var(--fb-text-color, #999)"});const T=document.createElement("input");T.type="file",T.accept=z.join(","),T.style.display="none",x.appendChild(T),A.addEventListener("click",()=>{T.click()}),T.addEventListener("change",()=>{var D;const j=(D=T.files)==null?void 0:D[0];j&&
|
|
1249
|
+
`,A.addEventListener("mouseenter",()=>{A.style.color="var(--fb-primary-color, #0066cc)"}),A.addEventListener("mouseleave",()=>{A.style.color="var(--fb-text-color, #999)"});const T=document.createElement("input");T.type="file",T.accept=z.join(","),T.style.display="none",x.appendChild(T),A.addEventListener("click",()=>{T.click()}),T.addEventListener("change",()=>{var D;const j=(D=T.files)==null?void 0:D[0];j&&ee(j),T.value=""}),x.appendChild(A);let L=0;x.addEventListener("dragenter",D=>{D.preventDefault(),L++,L===1&&(x.style.outline="2px dashed var(--fb-primary-color, #0066cc)",x.style.outlineOffset="-2px")}),x.addEventListener("dragover",D=>{D.preventDefault(),D.dataTransfer&&(D.dataTransfer.dropEffect="copy")}),x.addEventListener("dragleave",D=>{D.preventDefault(),L--,L<=0&&(L=0,x.style.outline="",x.style.outlineOffset="")}),x.addEventListener("drop",D=>{var j,F;D.preventDefault(),L=0,x.style.outline="",x.style.outlineOffset="";const te=(F=(j=D.dataTransfer)==null?void 0:j.files)==null?void 0:F[0];te&&ee(te)})}o.appendChild(x);const K=document.createElement("div");K.style.cssText=`
|
|
1250
1250
|
position: fixed;
|
|
1251
1251
|
display: none;
|
|
1252
1252
|
background: white;
|
|
@@ -1267,8 +1267,8 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1267
1267
|
cursor: pointer;
|
|
1268
1268
|
white-space: nowrap;
|
|
1269
1269
|
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>${J.join("")}</table>`;(P=F.clipboardData)==null||P.setData("text/plain",he),(_=F.clipboardData)==null||_.setData("text/html",fe)},S.onpaste=F=>{var ee,U,P,_,X,O,Z,Y,oe;const Q=g.anchor;if(!Q)return;const J=(U=(ee=F.clipboardData)==null?void 0:ee.getData("text/plain"))!=null?U:"",he=J.includes(" ")||J.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((_=(P=fe.closest("td"))==null?void 0:P.getAttribute("data-row"))!=null?_:"0",10),Ie=parseInt((O=(X=fe.closest("td"))==null?void 0:X.getAttribute("data-col"))!=null?O:"0",10);h[be]&&(h[be][Ie]=(Z=fe.textContent)!=null?Z:"")}if(!J.trim())return;const W=J.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,ge=Q.col,ye=ue+W.length;for(;h.length<ye;)h.push(Array((oe=(Y=h[0])==null?void 0:Y.length)!=null?oe:1).fill(""));const ke=Math.max(...W.map(be=>be.length)),He=ge+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,si=ge+Ie;h[tt]&&(h[tt][si]=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 ne=[],re=[];const ce=Ve({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>xe()});ce.style.position="absolute",ce.style.display="none",x.appendChild(ce);const de=Ve({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>me()});de.style.position="absolute",de.style.display="none",x.appendChild(de);function ve(){var A,T;ne.forEach(U=>U.remove()),ne=[],re.forEach(U=>U.remove()),re=[];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 _=parseInt((A=P.getAttribute("data-col"))!=null?A:"0",10),X=Ve({label:"\xD7",title:k("tableRemoveColumn",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>$(_)});X.setAttribute("data-action","remove-col"),X.setAttribute("data-col",String(_)),X.style.position="absolute",X.style.display="none",x.appendChild(X),ne.push(X)}}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 _=P.querySelector("td[data-row]");if(!_)continue;const X=parseInt((T=_.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(X)});O.setAttribute("data-action","remove-row"),O.setAttribute("data-row",String(X)),O.style.position="absolute",O.style.display="none",x.appendChild(O),re.push(O)}}function j(U,P,_,X,O){var Z;const Y=O?Array.from(S.querySelectorAll("thead td[data-col]")):[];let oe=-1,Q=1/0,J=-1,he=-1,fe=1/0;for(let W=0;W<Y.length;W++){const ue=Y[W].getBoundingClientRect(),ge=(ue.left+ue.right)/2,ye=Math.abs(U-ge);ye<Q&&(Q=ye,oe=W);const ke=Math.abs(U-ue.right);ke<fe&&ke<20&&(fe=ke,J=ue.right-P.left+X,he=parseInt((Z=Y[W].getAttribute("data-col"))!=null?Z:"0",10))}ne.forEach((W,ue)=>{if(!O||ue!==oe){W.style.display="none";return}const ge=Y[ue].getBoundingClientRect(),ye=(ge.left+ge.right)/2-P.left+X;W.style.left=`${ye-8}px`,W.style.top="2px",W.style.display="flex"}),O&&he>=0?(q.style.display="flex",q.style.left=`${J-10}px`,q.style.top=`${_.top-P.top-10}px`,q.dataset.afterCol=String(he)):q.style.display="none"}function F(U,P,_,X,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 oe=-1,Q=1/0,J=-1,he=-1,fe=1/0;for(let W=0;W<Y.length;W++){const ue=Y[W].getBoundingClientRect(),ge=(ue.top+ue.bottom)/2,ye=Math.abs(U-ge);ye<Q&&(Q=ye,oe=W);const ke=Math.abs(U-ue.bottom);if(ke<fe&&ke<14){fe=ke,J=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)}}re.forEach((W,ue)=>{if(!O||ue!==oe){W.style.display="none";return}const ge=Y[ue].getBoundingClientRect(),ye=(ge.top+ge.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=`${J-10}px`,B.style.left=`${_.left-P.left+X-10}px`,B.dataset.afterRow=String(he)):B.style.display="none"}let ee=!1;x.onmousemove=U=>{const P=U.target;if(P.tagName==="BUTTON"&&P.parentElement===x||ee)return;ee=!0;const _=U.clientX,X=U.clientY;requestAnimationFrame(()=>{ee=!1;const O=x.getBoundingClientRect(),Z=S.getBoundingClientRect(),Y=x.scrollLeft,oe=X>=O.top&&X<Z.top+4,Q=_>=O.left&&_<Z.left+4,J=Math.min(Z.right,O.right),he=_>J-20&&_<=O.right,fe=X>Z.bottom-4&&X<=O.bottom+20;if(j(_,O,Z,Y,oe),F(X,O,Z,Y,Q),ce.style.display=he?"flex":"none",he&&(ce.style.left=`${O.right-O.left+Y-20}px`,ce.style.top=`${(Z.top+Z.bottom)/2-O.top-10}px`),de.style.display=fe?"flex":"none",fe){const W=(O.left+O.right)/2-O.left+Y;de.style.left=`${W-10}px`,de.style.top=`${Z.bottom-O.top-10}px`}})},x.onmouseleave=()=>{ne.forEach(U=>{U.style.display="none"}),re.forEach(U=>{U.style.display="none"}),q.style.display="none",B.style.display="none",ce.style.display="none",de.style.display="none"}}N()}function Cl(e){var t,n;return{cells:er((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function Ut(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function Pt(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function El(e,t,n,r){var o,a,i,l;const d=t.state,s=ie(e,d,t),f=t.prefill[e.key],c=(a=(o=e.fieldNames)==null?void 0:o.cells)!=null?a:"cells",u=(l=(i=e.fieldNames)==null?void 0:i.merges)!=null?l:"merges";let p;if(Ut(f))p={cells:f.cells,merges:f.merges?We(f.merges):[]};else if(f&&Pt(f,c)){const m=f[u];p={cells:f[c],merges:m?We(m):[]}}else if(Ut(e.default))p={cells:e.default.cells,merges:e.default.merges?We(e.default.merges):[]};else if(e.default&&Pt(e.default,c)){const m=e.default[u];p={cells:e.default[c],merges:m?We(m):[]}}else p=Cl(e);if(p.merges&&p.merges.length>0){const m=p.cells.length,b=m>0?p.cells[0].length:0,v=Ot(p.merges,m,b);v&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${v})`),p={...p,merges:[]})}s?vl(p,n):wl(e,p,r,t,n)}function kl(e,t,n){var r,o;const{scopeRoot:a,skipValidation:i}=n,l=[],d=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",s=a.querySelector(`[name="${t}"]`);if(!s)return{value:null,errors:l};let f;try{f=JSON.parse(s.value)}catch(c){return l.push(`${t}: invalid table data`),{value:null,errors:l}}if(!i&&e.required){const c=f[d];c!=null&&c.some(u=>u.some(p=>p.trim()!==""))||l.push(`${t}: ${k("required",n.state)}`)}return{value:f,errors:l}}function $l(e,t,n,r){var o,a,i,l;const{scopeRoot:d}=r,s=(a=(o=e.fieldNames)==null?void 0:o.cells)!=null?a:"cells",f=(l=(i=e.fieldNames)==null?void 0:i.merges)!=null?l:"merges",c=d.querySelector(`[name="${t}"]`);if(!c){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let u=null;if(Ut(n))u={cells:n.cells,merges:n.merges?We(n.merges):[]};else if(n&&Pt(n,s)){const p=n[f];u={cells:n[s],merges:p?We(p):[]}}u&&c._applyExternalUpdate?c._applyExternalUpdate(u):c.value=JSON.stringify(n)}function Sl(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(i=>{var l,d,s,f,c;if(!e.isConnected){a.disconnect();return}const u=i[0],p=(c=(f=(d=(l=u==null?void 0:u.contentBoxSize)==null?void 0:l[0])==null?void 0:d.inlineSize)!=null?f:(s=u==null?void 0:u.contentRect)==null?void 0:s.width)!=null?c:0;p!==o&&(o=p,r())});a.observe(e)}function Wt(e,t){var n,r,o,a;const i=new Map,l=new Map;for(const d of e){const s=t.resourceIndex.get(d),f=(n=s==null?void 0:s.name)!=null?n:d;l.set(f,((r=l.get(f))!=null?r:0)+1)}for(const d of e){const s=t.resourceIndex.get(d),f=(o=s==null?void 0:s.name)!=null?o:d;((a=l.get(f))!=null?a:1)>1&&s?i.set(d,`${f} (${vr(s.size)})`):i.set(d,f)}return i}function Vt(e){return e?e.type.startsWith("image/"):!1}function nr(e,t){const n=Wt(e,t),r=new Map;for(const o of e){const a=n.get(o);a&&r.set(a,o)}return r}function Kt(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function mt(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 i=e.slice(a,r);t.push({start:o,end:r,raw:e.slice(o,r),name:i})}}else r++;return t}function Ll(e,t){if(t.size===0)return[];const n=mt(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 Tl(e,t){const n=Ll(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=Wt(t,n),o=new Map;for(const d of t){const s=r.get(d);s&&o.set(d,s)}const a=mt(e);if(a.length===0)return e;let i="",l=0;for(const d of a){i+=e.slice(l,d.start);const s=o.get(d.name);s?i+=Kt(s):i+=d.raw,l=d.end}return i+=e.slice(l),i}function or(e,t,n,r){if(we(e),n!=null&&n.file&&Vt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const a=new FileReader;a.onload=i=>{var l;o.src=((l=i.target)==null?void 0:l.result)||""},a.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(a=>{var i;if(!a||!e.isConnected)return;const l=document.createElement("img");l.alt=(i=n==null?void 0:n.name)!=null?i:t,l.src=a,l.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",we(e),e.appendChild(l)}).catch(a=>{var i,l;(l=(i=r.config).onThumbnailError)==null||l.call(i,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&&Vt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const a=new FileReader;a.onload=i=>{var l;o.src=((l=i.target)==null?void 0:l.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 i=document.createElement("img");i.alt=(a=n==null?void 0:n.name)!=null?a:t,i.src=o,i.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",we(e),e.appendChild(i)}).catch(o=>{var a,i;(i=(a=r.config).onThumbnailError)==null||i.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,i=n.bottom+8,l=a>=4?a:i;e.style.left=`${o}px`,e.style.top=`${Math.max(4,l)}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=`
|
|
1270
|
+
`,L.addEventListener("mouseenter",()=>{L.style.background="var(--fb-background-hover-color)"}),L.addEventListener("mouseleave",()=>{L.style.background="transparent"}),L.addEventListener("click",()=>{ne(),T()}),L}function V(A,T){if(!b)return;K.innerHTML="",K.style.display="flex";const L=Ne(v),D=L&&(L.r1!==L.r2||L.c1!==L.c2),j=v.anchor&&mt(v.anchor.row,v.anchor.col,y);if(D&&K.appendChild(H(k("tableMergeCells",p),I)),j&&K.appendChild(H(k("tableSplitCell",p),M)),!K.firstChild){ne();return}const F=140,te=K.children.length*32+8,U=window.innerWidth,P=window.innerHeight,J=A+F>U?A-F:A,G=T+te>P?T-te:T;K.style.left=`${J}px`,K.style.top=`${G}px`}function ne(){K.style.display="none"}const R=new AbortController;document.addEventListener("mousedown",A=>{if(!o.isConnected){R.abort();return}K.contains(A.target)||ne()},{signal:R.signal});function _(){const A=Ne(v);S.querySelectorAll("td[data-row]").forEach(T=>{const L=parseInt(T.getAttribute("data-row")||"0",10),D=parseInt(T.getAttribute("data-col")||"0",10),j=v.anchor!==null&&v.anchor.row===L&&v.anchor.col===D,F=A!==null&&L>=A.r1&&L<=A.r2&&D>=A.c1&&D<=A.c2;T.style.outline=j?"2px solid var(--fb-primary-color, #0066cc)":"",T.style.outlineOffset=j?"-2px":"",L===0?T.style.backgroundColor="var(--fb-background-hover-color)":T.style.backgroundColor=F&&!j?"rgba(0,102,204,0.08)":""})}function ie(A,T){v.anchor={row:A,col:T},v.focus=null,_(),S.focus()}function pe(A,T){const L=S.querySelector(`td[data-row="${A}"][data-col="${T}"]`);if(!L)return;const D=L.querySelector("span");D&&(v.anchor={row:A,col:T},v.focus=null,_(),wl(D,A,T,()=>h,w,ie))}function me(A){var T;const L=h.length>0?h[0].length:(T=e.columns)!=null?T:3,D=Array(L).fill(""),j=A!==void 0?A+1:h.length;h.splice(j,0,D),y=y.map(F=>F.top>=j?{...F,top:F.top+1,bottom:F.bottom+1}:F.top<j&&F.bottom>=j?{...F,bottom:F.bottom+1}:F),w(),N()}function Ae(A){if(h.length<=1)return;const T=A!==void 0?A:v.anchor?v.anchor.row:h.length-1;y=y.map(L=>L.top===T&&L.bottom===T?null:L.top===T?{...L,bottom:L.bottom-1}:L.bottom===T?{...L,bottom:L.bottom-1}:L.top<T&&L.bottom>T?{...L,bottom:L.bottom-1}:L.top>T?{...L,top:L.top-1,bottom:L.bottom-1}:L).filter(L=>L!==null),h.splice(T,1),v.anchor&&v.anchor.row>=h.length&&(v.anchor={row:h.length-1,col:v.anchor.col}),w(),N()}function xe(A){var T,L;const D=A!==void 0?A+1:(L=(T=h[0])==null?void 0:T.length)!=null?L:0;h.forEach(j=>j.splice(D,0,"")),y=y.map(j=>j.left>=D?{...j,left:j.left+1,right:j.right+1}:j.left<D&&j.right>=D?{...j,right:j.right+1}:j),w(),N()}function $(A){if(h.length===0||h[0].length<=1)return;const T=A!==void 0?A:v.anchor?v.anchor.col:h[0].length-1;y=y.map(L=>L.left===T&&L.right===T?null:L.left===T?{...L,right:L.right-1}:L.right===T?{...L,right:L.right-1}:L.left<T&&L.right>T?{...L,right:L.right-1}:L.left>T?{...L,left:L.left-1,right:L.right-1}:L).filter(L=>L!==null),h.forEach(L=>L.splice(T,1)),v.anchor&&v.anchor.col>=h[0].length&&(v.anchor={row:v.anchor.row,col:h[0].length-1}),w(),N()}function I(){var A,T;if(!b)return;const L=Ne(v);if(!L)return;const{r1:D,c1:j,r2:F,c2:te}=L;if(D===F&&j===te)return;y=y.filter(O=>!(O.top<=F&&O.bottom>=D&&O.left<=te&&O.right>=j));const U=h[D][j];for(let O=D;O<=F;O++)for(let Z=j;Z<=te;Z++)(O!==D||Z!==j)&&(h[O][Z]="");h[D][j]=U;const P={top:D,left:j,bottom:F,right:te},J=[...y,P],G=Ut(J,h.length,(T=(A=h[0])==null?void 0:A.length)!=null?T:0);if(G){console.warn("Merge validation failed:",G);return}y.push(P),v.anchor={row:D,col:j},v.focus=null,w(),N()}function M(){if(!b||!v.anchor)return;const{row:A,col:T}=v.anchor,L=y.findIndex(D=>D.top===A&&D.left===T);L!==-1&&(y.splice(L,1),v.focus=null,w(),N())}function N(){var A,T;S.innerHTML="";const L=h.length,D=L>0?h[0].length:0,j=Ne(v);for(let F=0;F<L;F++){const te=(F===0?(A=S.tHead)!=null?A:S.createTHead():(T=S.tBodies[0])!=null?T:S.createTBody()).insertRow();for(let U=0;U<D;U++){if(tr(F,U,y))continue;const P=mt(F,U,y),J=document.createElement("td");if(J.setAttribute("data-row",String(F)),J.setAttribute("data-col",String(U)),P){const Q=P.bottom-P.top+1,X=P.right-P.left+1;Q>1&&(J.rowSpan=Q),X>1&&(J.colSpan=X)}const G=j!==null&&F>=j.r1&&F<=j.r2&&U>=j.c1&&U<=j.c2,O=v.anchor!==null&&v.anchor.row===F&&v.anchor.col===U;J.style.cssText=["border: var(--fb-border-width) solid var(--fb-border-color);","padding: 4px 8px;","min-width: 80px;","vertical-align: top;","cursor: text;","position: relative;",F===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":"",G&&!O?"background-color: rgba(0,102,204,0.08);":"",O?"outline: 2px solid var(--fb-primary-color, #0066cc); outline-offset: -2px;":""].join(" ");const Z=document.createElement("span");Z.textContent=h[F][U],Z.style.cssText="display: block; min-height: 1.4em; white-space: pre-wrap; word-break: break-word; outline: none;",J.appendChild(Z);const Y=F,le=U;J.addEventListener("mousedown",Q=>{if(Q.target.tagName!=="BUTTON"&&Q.target.contentEditable!=="true"){if(Q.button===2){const X=Ne(v);if(X&&Y>=X.r1&&Y<=X.r2&&le>=X.c1&&le<=X.c2)return}Q.shiftKey&&v.anchor?(Q.preventDefault(),v.focus={row:Y,col:le},v.dragging=!1,_()):(v.anchor={row:Y,col:le},v.focus=null,v.dragging=!0,_())}}),J.addEventListener("mouseup",Q=>{if(Q.target.tagName!=="BUTTON"&&v.dragging){v.dragging=!1;const X=Ne(v);(!X||X.r1===X.r2&&X.c1===X.c2)&&pe(Y,le)}}),J.addEventListener("mousemove",Q=>{if(v.dragging&&Q.buttons===1){const X=v.anchor;X&&(X.row!==Y||X.col!==le)&&(v.focus={row:Y,col:le},_())}}),J.addEventListener("contextmenu",Q=>{if(!b)return;const X=Ne(v),he=X&&(X.r1!==X.r2||X.c1!==X.c2),fe=v.anchor&&mt(v.anchor.row,v.anchor.col,y);(he||fe)&&(Q.preventDefault(),V(Q.clientX,Q.clientY))}),te.appendChild(J)}}ge(),S.setAttribute("tabindex","0"),S.onkeydown=F=>{var te,U;if(S.querySelector("[contenteditable='true']"))return;const P=v.anchor;if(!P)return;const J=h.length,G=J>0?h[0].length:0,O={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]};if(O[F.key]){F.preventDefault();const[Z,Y]=O[F.key],le=Math.max(0,Math.min(J-1,P.row+Z)),Q=Math.max(0,Math.min(G-1,P.col+Y));F.shiftKey?(v.focus={row:le,col:Q},_()):ie(le,Q);return}if(F.key==="Enter"){F.preventDefault(),pe(P.row,P.col);return}if(F.key==="Tab"){F.preventDefault();const Z=(U=(te=h[0])==null?void 0:te.length)!=null?U:0;let Y=P.row,le=F.shiftKey?P.col-1:P.col+1;le<0&&(le=Z-1,Y=Math.max(0,Y-1)),le>=Z&&(le=0,Y=Math.min(h.length-1,Y+1)),ie(Y,le);return}if(b&&F.key==="m"&&F.ctrlKey&&!F.shiftKey){F.preventDefault(),I();return}b&&F.key==="M"&&F.ctrlKey&&F.shiftKey&&(F.preventDefault(),M())},S.oncopy=F=>{var te,U,P,J;const G=Ne(v);if(!G)return;F.preventDefault();const{r1:O,c1:Z,r2:Y,c2:le}=G,Q=[],X=[];for(let W=O;W<=Y;W++){const ue=[],ve=[];for(let ye=Z;ye<=le;ye++){const ke=(U=(te=h[W])==null?void 0:te[ye])!=null?U:"";ue.push(ke);const He=ke.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");ve.push(`<td>${He}</td>`)}Q.push(ue.join(" ")),X.push(`<tr>${ve.join("")}</tr>`)}const he=Q.join(`
|
|
1271
|
+
`),fe=`<table>${X.join("")}</table>`;(P=F.clipboardData)==null||P.setData("text/plain",he),(J=F.clipboardData)==null||J.setData("text/html",fe)},S.onpaste=F=>{var te,U,P,J,G,O,Z,Y,le;const Q=v.anchor;if(!Q)return;const X=(U=(te=F.clipboardData)==null?void 0:te.getData("text/plain"))!=null?U:"",he=X.includes(" ")||X.split(/\r?\n/).filter(be=>be).length>1,fe=S.querySelector("[contenteditable='true']");if(fe&&!he)return;if(F.preventDefault(),fe){fe.contentEditable="inherit";const be=parseInt((J=(P=fe.closest("td"))==null?void 0:P.getAttribute("data-row"))!=null?J:"0",10),Ie=parseInt((O=(G=fe.closest("td"))==null?void 0:G.getAttribute("data-col"))!=null?O:"0",10);h[be]&&(h[be][Ie]=(Z=fe.textContent)!=null?Z:"")}if(!X.trim())return;const W=X.split(/\r?\n/).map(be=>be.split(" "));W.length>1&&W[W.length-1].length===1&&W[W.length-1][0]===""&&W.pop();const ue=Q.row,ve=Q.col,ye=ue+W.length;for(;h.length<ye;)h.push(Array((le=(Y=h[0])==null?void 0:Y.length)!=null?le:1).fill(""));const ke=Math.max(...W.map(be=>be.length)),He=ve+ke;if(h[0]&&He>h[0].length){const be=He-h[0].length;h.forEach(Ie=>{for(let tt=0;tt<be;tt++)Ie.push("")})}for(let be=0;be<W.length;be++)for(let Ie=0;Ie<W[be].length;Ie++){const tt=ue+be,di=ve+Ie;h[tt]&&(h[tt][di]=W[be][Ie])}w(),N()}}const q=Ve({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=q.dataset.afterCol)!=null?A:"0",10);xe(T)}});q.style.position="absolute",q.style.display="none",x.appendChild(q);const B=Ve({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=B.dataset.afterRow)!=null?A:"0",10);me(T)}});B.style.position="absolute",B.style.display="none",x.appendChild(B);let re=[],oe=[];const de=Ve({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>xe()});de.style.position="absolute",de.style.display="none",x.appendChild(de);const ce=Ve({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>me()});ce.style.position="absolute",ce.style.display="none",x.appendChild(ce);function ge(){var A,T;re.forEach(U=>U.remove()),re=[],oe.forEach(U=>U.remove()),oe=[];const L=h.length>0?h[0].length:0,D=h.length;if(L>1){const U=Array.from(S.querySelectorAll("thead td[data-col]"));for(const P of U){const J=parseInt((A=P.getAttribute("data-col"))!=null?A:"0",10),G=Ve({label:"\xD7",title:k("tableRemoveColumn",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>$(J)});G.setAttribute("data-action","remove-col"),G.setAttribute("data-col",String(J)),G.style.position="absolute",G.style.display="none",x.appendChild(G),re.push(G)}}if(D>1){const U=[...S.tHead?Array.from(S.tHead.rows):[],...S.tBodies[0]?Array.from(S.tBodies[0].rows):[]].filter(P=>P.querySelector("td[data-row]"));for(const P of U){const J=P.querySelector("td[data-row]");if(!J)continue;const G=parseInt((T=J.getAttribute("data-row"))!=null?T:"0",10),O=Ve({label:"\xD7",title:k("tableRemoveRow",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>Ae(G)});O.setAttribute("data-action","remove-row"),O.setAttribute("data-row",String(G)),O.style.position="absolute",O.style.display="none",x.appendChild(O),oe.push(O)}}function j(U,P,J,G,O){var Z;const Y=O?Array.from(S.querySelectorAll("thead td[data-col]")):[];let le=-1,Q=1/0,X=-1,he=-1,fe=1/0;for(let W=0;W<Y.length;W++){const ue=Y[W].getBoundingClientRect(),ve=(ue.left+ue.right)/2,ye=Math.abs(U-ve);ye<Q&&(Q=ye,le=W);const ke=Math.abs(U-ue.right);ke<fe&&ke<20&&(fe=ke,X=ue.right-P.left+G,he=parseInt((Z=Y[W].getAttribute("data-col"))!=null?Z:"0",10))}re.forEach((W,ue)=>{if(!O||ue!==le){W.style.display="none";return}const ve=Y[ue].getBoundingClientRect(),ye=(ve.left+ve.right)/2-P.left+G;W.style.left=`${ye-8}px`,W.style.top="2px",W.style.display="flex"}),O&&he>=0?(q.style.display="flex",q.style.left=`${X-10}px`,q.style.top=`${J.top-P.top-10}px`,q.dataset.afterCol=String(he)):q.style.display="none"}function F(U,P,J,G,O){var Z;const Y=[];if(O){if(S.tHead)for(const W of Array.from(S.tHead.rows))W.querySelector("td[data-row]")&&Y.push(W);if(S.tBodies[0])for(const W of Array.from(S.tBodies[0].rows))W.querySelector("td[data-row]")&&Y.push(W)}let le=-1,Q=1/0,X=-1,he=-1,fe=1/0;for(let W=0;W<Y.length;W++){const ue=Y[W].getBoundingClientRect(),ve=(ue.top+ue.bottom)/2,ye=Math.abs(U-ve);ye<Q&&(Q=ye,le=W);const ke=Math.abs(U-ue.bottom);if(ke<fe&&ke<14){fe=ke,X=ue.bottom-P.top;const He=Y[W].querySelector("td[data-row]");he=parseInt((Z=He==null?void 0:He.getAttribute("data-row"))!=null?Z:"0",10)}}oe.forEach((W,ue)=>{if(!O||ue!==le){W.style.display="none";return}const ve=Y[ue].getBoundingClientRect(),ye=(ve.top+ve.bottom)/2-P.top;W.style.left="4px",W.style.top=`${ye-8}px`,W.style.display="flex"}),O&&he>=0?(B.style.display="flex",B.style.top=`${X-10}px`,B.style.left=`${J.left-P.left+G-10}px`,B.dataset.afterRow=String(he)):B.style.display="none"}let te=!1;x.onmousemove=U=>{const P=U.target;if(P.tagName==="BUTTON"&&P.parentElement===x||te)return;te=!0;const J=U.clientX,G=U.clientY;requestAnimationFrame(()=>{te=!1;const O=x.getBoundingClientRect(),Z=S.getBoundingClientRect(),Y=x.scrollLeft,le=G>=O.top&&G<Z.top+4,Q=J>=O.left&&J<Z.left+4,X=Math.min(Z.right,O.right),he=J>X-20&&J<=O.right,fe=G>Z.bottom-4&&G<=O.bottom+20;if(j(J,O,Z,Y,le),F(G,O,Z,Y,Q),de.style.display=he?"flex":"none",he&&(de.style.left=`${O.right-O.left+Y-20}px`,de.style.top=`${(Z.top+Z.bottom)/2-O.top-10}px`),ce.style.display=fe?"flex":"none",fe){const W=(O.left+O.right)/2-O.left+Y;ce.style.left=`${W-10}px`,ce.style.top=`${Z.bottom-O.top-10}px`}})},x.onmouseleave=()=>{re.forEach(U=>{U.style.display="none"}),oe.forEach(U=>{U.style.display="none"}),q.style.display="none",B.style.display="none",de.style.display="none",ce.style.display="none"}}N()}function $l(e){var t,n;return{cells:er((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function Pt(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function Wt(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function Sl(e,t,n,r){var o,a,l,i;const c=t.state,s=ae(e,c,t),f=t.prefill[e.key],d=(a=(o=e.fieldNames)==null?void 0:o.cells)!=null?a:"cells",u=(i=(l=e.fieldNames)==null?void 0:l.merges)!=null?i:"merges";let p;if(Pt(f))p={cells:f.cells,merges:f.merges?We(f.merges):[]};else if(f&&Wt(f,d)){const m=f[u];p={cells:f[d],merges:m?We(m):[]}}else if(Pt(e.default))p={cells:e.default.cells,merges:e.default.merges?We(e.default.merges):[]};else if(e.default&&Wt(e.default,d)){const m=e.default[u];p={cells:e.default[d],merges:m?We(m):[]}}else p=$l(e);if(p.merges&&p.merges.length>0){const m=p.cells.length,b=m>0?p.cells[0].length:0,g=Ut(p.merges,m,b);g&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${g})`),p={...p,merges:[]})}s?xl(p,n):kl(e,p,r,t,n)}function Ll(e,t,n){var r,o;const{scopeRoot:a,skipValidation:l}=n,i=[],c=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",s=a.querySelector(`[name="${t}"]`);if(!s)return{value:null,errors:i};let f;try{f=JSON.parse(s.value)}catch(d){return i.push(`${t}: invalid table data`),{value:null,errors:i}}if(!l&&e.required){const d=f[c];d!=null&&d.some(u=>u.some(p=>p.trim()!==""))||i.push(`${t}: ${k("required",n.state)}`)}return{value:f,errors:i}}function Tl(e,t,n,r){var o,a,l,i;const{scopeRoot:c}=r,s=(a=(o=e.fieldNames)==null?void 0:o.cells)!=null?a:"cells",f=(i=(l=e.fieldNames)==null?void 0:l.merges)!=null?i:"merges",d=c.querySelector(`[name="${t}"]`);if(!d){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let u=null;if(Pt(n))u={cells:n.cells,merges:n.merges?We(n.merges):[]};else if(n&&Wt(n,s)){const p=n[f];u={cells:n[s],merges:p?We(p):[]}}u&&d._applyExternalUpdate?d._applyExternalUpdate(u):d.value=JSON.stringify(n)}function Al(e,t){e.style.overflow="hidden",e.style.resize="none";const n=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(3,n);const r=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`,t&&(t.style.height=`${e.scrollHeight}px`))};if(e.addEventListener("input",r),setTimeout(()=>{e.isConnected&&r()},0),typeof ResizeObserver=="undefined")return;let o=-1;const a=new ResizeObserver(l=>{var i,c,s,f,d;if(!e.isConnected){a.disconnect();return}const u=l[0],p=(d=(f=(c=(i=u==null?void 0:u.contentBoxSize)==null?void 0:i[0])==null?void 0:c.inlineSize)!=null?f:(s=u==null?void 0:u.contentRect)==null?void 0:s.width)!=null?d:0;p!==o&&(o=p,r())});a.observe(e)}function Vt(e,t){var n,r,o,a;const l=new Map,i=new Map;for(const c of e){const s=t.resourceIndex.get(c),f=(n=s==null?void 0:s.name)!=null?n:c;i.set(f,((r=i.get(f))!=null?r:0)+1)}for(const c of e){const s=t.resourceIndex.get(c),f=(o=s==null?void 0:s.name)!=null?o:c;((a=i.get(f))!=null?a:1)>1&&s?l.set(c,`${f} (${xr(s.size)})`):l.set(c,f)}return l}function Kt(e){return e?e.type.startsWith("image/"):!1}function nr(e,t){const n=Vt(e,t),r=new Map;for(const o of e){const a=n.get(o);a&&r.set(a,o)}return r}function _t(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function ht(e){const t=[],n=e.length;let r=0;for(;r<n;)if(e[r]==="@"){if(r>0&&!/\s/.test(e[r-1])){r++;continue}const o=r;if(r++,r<n&&e[r]==='"'){r++;let a="";for(;r<n&&e[r]!=='"';)e[r]==="\\"&&r+1<n?(a+=e[r+1],r+=2):(a+=e[r],r++);r<n&&e[r]==='"'&&(r++,(r>=n||/\s/.test(e[r]))&&t.push({start:o,end:r,raw:e.slice(o,r),name:a}))}else if(r<n&&!/\s/.test(e[r])){const a=r;for(;r<n&&!/\s/.test(e[r]);)r++;const l=e.slice(a,r);t.push({start:o,end:r,raw:e.slice(o,r),name:l})}}else r++;return t}function Fl(e,t){if(t.size===0)return[];const n=ht(e),r=[];for(const o of n){const a=t.get(o.name);a&&r.push({start:o.start,end:o.end,name:o.name,rid:a})}return r}function zl(e,t){const n=Fl(e,t);if(n.length===0)return e;let r="",o=0;for(const a of n)r+=e.slice(o,a.start),r+=`@${a.rid}`,o=a.end;return r+=e.slice(o),r}function rr(e,t,n){const r=Vt(t,n),o=new Map;for(const c of t){const s=r.get(c);s&&o.set(c,s)}const a=ht(e);if(a.length===0)return e;let l="",i=0;for(const c of a){l+=e.slice(i,c.start);const s=o.get(c.name);s?l+=_t(s):l+=c.raw,i=c.end}return l+=e.slice(i),l}function or(e,t,n,r){if(we(e),n!=null&&n.file&&Kt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const a=new FileReader;a.onload=l=>{var i;o.src=((i=l.target)==null?void 0:i.result)||""},a.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(a=>{var l;if(!a||!e.isConnected)return;const i=document.createElement("img");i.alt=(l=n==null?void 0:n.name)!=null?l:t,i.src=a,i.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",we(e),e.appendChild(i)}).catch(a=>{var l,i;(i=(l=r.config).onThumbnailError)==null||i.call(l,a,t)});const o=document.createElement("div");o.style.cssText="width: 100%; height: 100%; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',e.appendChild(o)}else{const o=document.createElement("div");if(o.style.cssText="width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px; box-sizing: border-box;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',n!=null&&n.name){const a=document.createElement("span");a.style.cssText="font-size: 9px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44px; color: var(--fb-text-color, #111827);",a.textContent=n.name,o.appendChild(a)}e.appendChild(o)}}function lr(e,t,n,r){if(we(e),n!=null&&n.file&&Kt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const a=new FileReader;a.onload=l=>{var i;o.src=((i=l.target)==null?void 0:i.result)||""},a.readAsDataURL(n.file),e.appendChild(o)}else r.config.getThumbnail&&r.config.getThumbnail(t).then(o=>{var a;if(!o||!e.isConnected)return;const l=document.createElement("img");l.alt=(a=n==null?void 0:n.name)!=null?a:t,l.src=o,l.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",we(e),e.appendChild(l)}).catch(o=>{var a,l;(l=(a=r.config).onThumbnailError)==null||l.call(a,o,t)})}function ir(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(4,Math.min(n.left+n.width/2-r.width/2,window.innerWidth-r.width-4)),a=n.top-r.height-8,l=n.bottom+8,i=a>=4?a:l;e.style.left=`${o}px`,e.style.top=`${Math.max(4,i)}px`}function ar(e,t,n){const r=n.resourceIndex.get(t),o=document.createElement("div");o.className="fb-richinput-portal-tooltip fb-richinput-mention-tooltip",o.style.cssText=`
|
|
1272
1272
|
position: fixed;
|
|
1273
1273
|
z-index: 99999;
|
|
1274
1274
|
background: #fff;
|
|
@@ -1279,7 +1279,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1279
1279
|
pointer-events: none;
|
|
1280
1280
|
min-width: 60px;
|
|
1281
1281
|
max-width: 140px;
|
|
1282
|
-
`;const a=document.createElement("div");return a.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",lr(a,t,r,n),o.appendChild(a),document.body.appendChild(o),ir(o,e),o}function sr(e,t){var n,r;const{rid:o,state:a,isReadonly:
|
|
1282
|
+
`;const a=document.createElement("div");return a.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",lr(a,t,r,n),o.appendChild(a),document.body.appendChild(o),ir(o,e),o}function sr(e,t){var n,r;const{rid:o,state:a,isReadonly:l,onMention:i,onRemove:c}=t,s=a.resourceIndex.get(o),f=(n=s==null?void 0:s.name)!=null?n:o,d=document.createElement("div");d.className="fb-richinput-portal-tooltip fb-richinput-file-tooltip",d.style.cssText=`
|
|
1283
1283
|
position: fixed;
|
|
1284
1284
|
z-index: 99999;
|
|
1285
1285
|
background: #fff;
|
|
@@ -1290,13 +1290,13 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1290
1290
|
pointer-events: auto;
|
|
1291
1291
|
min-width: 80px;
|
|
1292
1292
|
max-width: 260px;
|
|
1293
|
-
`;const u=document.createElement("div");u.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",lr(u,o,s,a),
|
|
1293
|
+
`;const u=document.createElement("div");u.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",lr(u,o,s,a),d.appendChild(u);const p=document.createElement("div");p.style.cssText="padding: 4px 6px 2px; font-size: 12px; color: var(--fb-text-color, #111827); word-break: break-word; border-top: 1px solid var(--fb-border-color, #d1d5db);",p.textContent=f,d.appendChild(p);const m=document.createElement("div");m.style.cssText="display: flex; align-items: center; gap: 2px; padding: 3px 4px 2px; border-top: 1px solid var(--fb-border-color, #d1d5db); justify-content: center;";const b="background: none; border: none; cursor: pointer; padding: 3px 5px; border-radius: 4px; color: var(--fb-text-muted-color, #6b7280); display: flex; align-items: center; transition: background 0.1s, color 0.1s;",g=h=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-text-color, #111827)"},E=h=>{h.style.background="none",h.style.color="var(--fb-text-muted-color, #6b7280)"};if(!l&&i){const h=document.createElement("button");h.type="button",h.title="Mention",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{y.stopPropagation(),i(),d.remove()}),m.appendChild(h)}if(a.config.downloadFile){const h=document.createElement("button");h.type="button",h.title="Download",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{var v,C;y.stopPropagation(),(C=(v=a.config).downloadFile)==null||C.call(v,o,f)}),m.appendChild(h)}if((r=a.config.getDownloadUrl)!=null?r:a.config.getThumbnail){const h=document.createElement("button");h.type="button",h.title="Open in new window",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{var v,C,w,x;if(y.stopPropagation(),a.config.getDownloadUrl){const S=a.config.getDownloadUrl(o);S?window.open(S,"_blank"):(C=(v=a.config).getThumbnail)==null||C.call(v,o).then(z=>{z&&window.open(z,"_blank")}).catch(()=>{})}else(x=(w=a.config).getThumbnail)==null||x.call(w,o).then(S=>{S&&window.open(S,"_blank")}).catch(()=>{})}),m.appendChild(h)}if(!l&&c){const h=document.createElement("button");h.type="button",h.title="Remove",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',h.addEventListener("mouseenter",()=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-error-color, #ef4444)"}),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{y.stopPropagation(),d.remove(),c()}),m.appendChild(h)}return m.children.length>0&&d.appendChild(m),document.body.appendChild(d),ir(d,e),d}function cr(){return{element:null,hideTimer:null}}function bt(e,t=150){e.hideTimer===null&&(e.hideTimer=setTimeout(()=>{e.hideTimer=null,e.element&&(e.element.remove(),e.element=null)},t))}function gt(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function Ke(e){return e&&e.remove(),null}function Ml(e){var t;const n=(t=e.selectionStart)!=null?t:0,r=e.value.slice(0,n);for(let o=r.length-1;o>=0;o--)if(r[o]==="@"){if(o===0||/\s/.test(r[o-1])){let a=r.slice(o+1);return a.startsWith('"')&&(a=a.slice(1)),{query:a,pos:o}}return null}return null}function dr(e,t,n){const r=e.toLowerCase();return t.filter(o=>{var a;return((a=n.get(o))!=null?a:o).toLowerCase().includes(r)})}const vt="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",ur="padding: 8px 40px 8px 10px;";function Nl(e,t,n,r,o){var a;const l=t.state,i=[...o.files],c={open:!1,query:"",triggerPos:-1,selectedIndex:0},s=new AbortController,f=document.createElement("input");f.type="hidden",f.name=r;function d(){var $,I;const M=x.value,N=nr(i,l),q=M?zl(M,N):null,B=($=e.textKey)!=null?$:"text",re=(I=e.filesKey)!=null?I:"files";return{[B]:M===""?null:q,[re]:[...i]}}function u(){f.value=JSON.stringify(d())}const p=document.createElement("div");p.className="fb-richinput-wrapper",p.style.cssText=`
|
|
1294
1294
|
position: relative;
|
|
1295
1295
|
border: 1px solid var(--fb-border-color, #d1d5db);
|
|
1296
1296
|
border-radius: 16px;
|
|
1297
1297
|
background: var(--fb-background-color, #f9fafb);
|
|
1298
1298
|
transition: box-shadow 0.15s, border-color 0.15s;
|
|
1299
|
-
`,p.addEventListener("focusin",()=>{p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("focusout",()=>{p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none"});const m=document.createElement("div");m.className="fb-richinput-error",m.style.cssText="display: none; color: var(--fb-error-color, #ef4444); font-size: var(--fb-font-size-small, 12px); padding: 4px 10px 6px;";let b=null;function
|
|
1299
|
+
`,p.addEventListener("focusin",()=>{p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("focusout",()=>{p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none"});const m=document.createElement("div");m.className="fb-richinput-error",m.style.cssText="display: none; color: var(--fb-error-color, #ef4444); font-size: var(--fb-font-size-small, 12px); padding: 4px 10px 6px;";let b=null;function g($){m.textContent=$,m.style.display="block",b&&clearTimeout(b),b=setTimeout(()=>{m.style.display="none",m.textContent="",b=null},5e3)}function E($){var I;const M=Re(e.accept);if(!Ue($.name,M)){const q=M.join(", ");return g(k("invalidFileExtension",l,{name:$.name,formats:q})),!1}const N=(I=e.maxSize)!=null?I:1/0;return st($,N)?!0:(g(k("fileTooLarge",l,{name:$.name,maxSize:N})),!1)}let h=0;p.addEventListener("dragenter",$=>{$.preventDefault(),h++,p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("dragover",$=>{$.preventDefault()}),p.addEventListener("dragleave",$=>{$.preventDefault(),h--,h<=0&&(h=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none")}),p.addEventListener("drop",$=>{var I,M;$.preventDefault(),h=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none";const N=(I=$.dataTransfer)==null?void 0:I.files;if(!N||!l.config.uploadFile)return;const q=(M=e.maxFiles)!=null?M:1/0;for(let B=0;B<N.length;B++){if(i.length>=q){g(k("filesLimitExceeded",l,{skipped:N.length-B,max:q}));break}E(N[B])&&Ae(N[B])}});const y=document.createElement("div");y.className="fb-richinput-files",y.style.cssText="display: none; flex-wrap: wrap; gap: 4px; padding: 6px 10px 0; align-items: center;";const v=document.createElement("input");v.type="file",v.multiple=!0,v.style.display="none",e.accept&&(typeof e.accept=="string"?v.accept=e.accept:v.accept=e.accept.extensions.map($=>$.startsWith(".")?$:`.${$}`).join(","));const C=document.createElement("div");C.style.cssText="position: relative;";const w=document.createElement("div");w.className="fb-richinput-backdrop",w.style.cssText=`
|
|
1300
1300
|
position: absolute;
|
|
1301
1301
|
top: 0; left: 0; right: 0; bottom: 0;
|
|
1302
1302
|
${ur}
|
|
@@ -1309,7 +1309,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1309
1309
|
border-radius: inherit;
|
|
1310
1310
|
box-sizing: border-box;
|
|
1311
1311
|
z-index: 2;
|
|
1312
|
-
`;const x=document.createElement("textarea");x.name=`${r}__text`,x.placeholder=e.placeholder||k("richinputPlaceholder",
|
|
1312
|
+
`;const x=document.createElement("textarea");x.name=`${r}__text`,x.placeholder=e.placeholder||k("richinputPlaceholder",l);const S=(a=o.text)!=null?a:"";x.value=S?rr(S,i,l):"",x.style.cssText=`
|
|
1313
1313
|
width: 100%;
|
|
1314
1314
|
${ur}
|
|
1315
1315
|
${vt}
|
|
@@ -1322,9 +1322,9 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1322
1322
|
position: relative;
|
|
1323
1323
|
z-index: 1;
|
|
1324
1324
|
caret-color: var(--fb-text-color, #111827);
|
|
1325
|
-
`,
|
|
1326
|
-
`;return}let N="",q=0;for(const B of M){N+=se($.slice(q,B.start));const
|
|
1327
|
-
`}const K=document.createElement("button");K.type="button",K.title=k("richinputAttachFile",
|
|
1325
|
+
`,Al(x,w),x.addEventListener("scroll",()=>{w.scrollTop=x.scrollTop});let z=null;w.addEventListener("mouseover",$=>{var I,M;const N=(M=(I=$.target).closest)==null?void 0:M.call(I,"mark");N!=null&&N.dataset.rid&&(z=Ke(z),z=ar(N,N.dataset.rid,l))}),w.addEventListener("mouseout",$=>{var I,M,N;if(!((M=(I=$.target).closest)!=null&&M.call(I,"mark")))return;const q=$.relatedTarget;(N=q==null?void 0:q.closest)!=null&&N.call(q,"mark")||(z=Ke(z))}),w.addEventListener("mousedown",$=>{var I,M;if(!((M=(I=$.target).closest)!=null&&M.call(I,"mark")))return;z=Ke(z);const N=w.querySelectorAll("mark");N.forEach(B=>B.style.pointerEvents="none");const q=document.elementFromPoint($.clientX,$.clientY);q&&q.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,clientX:$.clientX,clientY:$.clientY,button:$.button,buttons:$.buttons,detail:$.detail})),document.addEventListener("mouseup",()=>{N.forEach(B=>B.style.pointerEvents="auto")},{once:!0})});function ee(){const $=x.value,I=nr(i,l),M=ht($);if(M.length===0){w.innerHTML=se($)+`
|
|
1326
|
+
`;return}let N="",q=0;for(const B of M){N+=se($.slice(q,B.start));const re=I.get(B.name);re?N+=`<mark data-rid="${se(re)}" style="background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent); color: transparent; border-radius: 8px; padding: 0; border: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent), 0 0 0 3px color-mix(in srgb, var(--fb-primary-color, #0066cc) 30%, transparent); box-decoration-break: clone; -webkit-box-decoration-break: clone; pointer-events: auto; cursor: text;">${se($.slice(B.start,B.end))}</mark>`:N+=`<mark style="color: transparent; background: none; padding: 0; border: none; text-decoration-line: underline; text-decoration-style: wavy; text-decoration-color: rgba(239, 68, 68, 0.45); text-underline-offset: 2px;">${se($.slice(B.start,B.end))}</mark>`,q=B.end}N+=se($.slice(q)),w.innerHTML=N+`
|
|
1327
|
+
`}const K=document.createElement("button");K.type="button",K.title=k("richinputAttachFile",l),K.style.cssText=`
|
|
1328
1328
|
position: absolute;
|
|
1329
1329
|
right: 6px;
|
|
1330
1330
|
bottom: 6px;
|
|
@@ -1340,7 +1340,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1340
1340
|
justify-content: center;
|
|
1341
1341
|
color: var(--fb-text-muted-color, #9ca3af);
|
|
1342
1342
|
transition: color 0.15s, background 0.15s;
|
|
1343
|
-
`,K.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>',K.addEventListener("mouseenter",()=>{K.style.color="var(--fb-primary-color, #0066cc)",K.style.background="var(--fb-background-hover-color, #f3f4f6)"}),K.addEventListener("mouseleave",()=>{K.style.color="var(--fb-text-muted-color, #9ca3af)",K.style.background="transparent"}),K.addEventListener("click",()=>{var $;const I=($=e.maxFiles)!=null?$:1/0;if(
|
|
1343
|
+
`,K.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>',K.addEventListener("mouseenter",()=>{K.style.color="var(--fb-primary-color, #0066cc)",K.style.background="var(--fb-background-hover-color, #f3f4f6)"}),K.addEventListener("mouseleave",()=>{K.style.color="var(--fb-text-muted-color, #9ca3af)",K.style.background="transparent"}),K.addEventListener("click",()=>{var $;const I=($=e.maxFiles)!=null?$:1/0;if(i.length>=I){g(k("filesLimitExceeded",l,{skipped:1,max:I}));return}v.click()});const H=document.createElement("div");H.className="fb-richinput-dropdown",H.style.cssText=`
|
|
1344
1344
|
display: none;
|
|
1345
1345
|
position: absolute;
|
|
1346
1346
|
bottom: 100%;
|
|
@@ -1356,15 +1356,15 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1356
1356
|
overflow-y: auto;
|
|
1357
1357
|
margin-bottom: 4px;
|
|
1358
1358
|
${vt}
|
|
1359
|
-
`;function V(){return
|
|
1359
|
+
`;function V(){return Vt(i,l)}function ne($){we(H);const I=V();if($.length===0){H.style.display="none",c.open=!1;return}$.forEach((M,N)=>{var q;const B=l.resourceIndex.get(M),re=document.createElement("div");re.className="fb-richinput-dropdown-item",re.dataset.rid=M,re.style.cssText=`
|
|
1360
1360
|
padding: 5px 10px;
|
|
1361
1361
|
cursor: pointer;
|
|
1362
1362
|
color: var(--fb-text-color, #111827);
|
|
1363
|
-
background: ${N===
|
|
1363
|
+
background: ${N===c.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
|
|
1364
1364
|
display: flex;
|
|
1365
1365
|
align-items: center;
|
|
1366
1366
|
gap: 8px;
|
|
1367
|
-
`;const
|
|
1367
|
+
`;const oe=document.createElement("div");if(oe.style.cssText="width: 24px; height: 24px; border-radius: 4px; overflow: hidden; flex-shrink: 0; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",B!=null&&B.file&&Kt(B)){const ce=document.createElement("img");ce.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const ge=new FileReader;ge.onload=A=>{var T;ce.src=((T=A.target)==null?void 0:T.result)||""},ge.readAsDataURL(B.file),oe.appendChild(ce)}else l.config.getThumbnail&&l.config.getThumbnail(M).then(ce=>{if(!ce||!oe.isConnected)return;const ge=document.createElement("img");ge.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",ge.src=ce,we(oe),oe.appendChild(ge)}).catch(()=>{}),oe.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>';re.appendChild(oe);const de=document.createElement("span");de.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",de.textContent=(q=I.get(M))!=null?q:M,re.appendChild(de),H.appendChild(re)}),H.onmousemove=M=>{var N,q,B;const re=(q=(N=M.target).closest)==null?void 0:q.call(N,".fb-richinput-dropdown-item");if(!re)return;const oe=$.indexOf((B=re.dataset.rid)!=null?B:"");oe===-1||oe===c.selectedIndex||(H.querySelectorAll(".fb-richinput-dropdown-item").forEach((de,ce)=>{de.style.background=ce===oe?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),c.selectedIndex=oe)},H.onmousedown=M=>{var N,q;M.preventDefault(),M.stopPropagation();const B=(q=(N=M.target).closest)==null?void 0:q.call(N,".fb-richinput-dropdown-item");B!=null&&B.dataset.rid&&ie(B.dataset.rid)},H.style.display="block",c.open=!0}function R(){const $=Ml(x);if(!$){_();return}c.query=$.query,c.triggerPos=$.pos,c.selectedIndex=0;const I=V(),M=dr($.query,i,I);ne(M)}function _(){H.style.display="none",c.open=!1}function ie($){var I,M,N,q;const B=(N=(M=V().get($))!=null?M:(I=l.resourceIndex.get($))==null?void 0:I.name)!=null?N:$,re=(q=x.selectionStart)!=null?q:0,oe=x.value.slice(0,c.triggerPos),de=x.value.slice(re),ce=`${_t(B)} `;x.value=`${oe}${ce}${de}`;const ge=oe.length+ce.length;x.setSelectionRange(ge,ge),x.dispatchEvent(new Event("input")),_()}x.addEventListener("input",()=>{var $;ee(),u(),($=t.instance)==null||$.triggerOnChange(r,d()),i.length>0?R():_()});function pe(){H.querySelectorAll(".fb-richinput-dropdown-item").forEach(($,I)=>{$.style.background=I===c.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}x.addEventListener("keydown",$=>{if(!c.open)return;const I=V(),M=dr(c.query,i,I);$.key==="ArrowDown"?($.preventDefault(),c.selectedIndex=Math.min(c.selectedIndex+1,M.length-1),pe()):$.key==="ArrowUp"?($.preventDefault(),c.selectedIndex=Math.max(c.selectedIndex-1,0),pe()):$.key==="Enter"&&M.length>0?($.preventDefault(),ie(M[c.selectedIndex])):$.key==="Escape"&&_()}),document.addEventListener("click",$=>{!p.contains($.target)&&!H.contains($.target)&&_()},{signal:s.signal});function me(){if(we(y),i.length===0){y.style.display="none";return}y.style.display="flex",i.forEach($=>{const I=l.resourceIndex.get($),M=document.createElement("div");M.className="fb-richinput-file-thumb",M.style.cssText=`
|
|
1368
1368
|
position: relative;
|
|
1369
1369
|
width: 48px;
|
|
1370
1370
|
height: 48px;
|
|
@@ -1374,14 +1374,14 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1374
1374
|
flex-shrink: 0;
|
|
1375
1375
|
cursor: pointer;
|
|
1376
1376
|
background: #fff;
|
|
1377
|
-
`;const N=document.createElement("div");N.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",or(N,$,I,
|
|
1378
|
-
`:""}${
|
|
1377
|
+
`;const N=document.createElement("div");N.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",or(N,$,I,l),M.appendChild(N);const q=cr(),B=()=>{var oe,de,ce;const ge=(oe=x.selectionStart)!=null?oe:x.value.length,A=(ce=(de=V().get($))!=null?de:I==null?void 0:I.name)!=null?ce:$,T=x.value.slice(0,ge),L=x.value.slice(ge),D=`${T.length>0&&!/[\s\n]$/.test(T)?`
|
|
1378
|
+
`:""}${_t(A)} `;x.value=`${T}${D}${L}`;const j=ge+D.length;x.setSelectionRange(j,j),x.focus(),x.dispatchEvent(new Event("input"))},re=()=>{var oe;const de=i.indexOf($);de!==-1&&i.splice(de,1),me(),ee(),u(),(oe=t.instance)==null||oe.triggerOnChange(r,d())};M.addEventListener("mouseenter",()=>{gt(q),q.element||(q.element=sr(M,{rid:$,state:l,isReadonly:!1,onMention:B,onRemove:re}),q.element.addEventListener("mouseenter",()=>{gt(q)}),q.element.addEventListener("mouseleave",()=>{bt(q)}))}),M.addEventListener("mouseleave",()=>{bt(q)}),y.appendChild(M)})}function Ae($){if(!l.config.uploadFile)return;const I=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;l.resourceIndex.set(I,{name:$.name,type:$.type,size:$.size,uploadedAt:new Date,file:$}),i.push(I),me();const M=y.querySelectorAll(".fb-richinput-file-thumb"),N=M[M.length-1];N&&(N.style.opacity="0.5"),l.config.uploadFile($).then(q=>{var B;const re=i.indexOf(I);re!==-1&&(i[re]=q),l.resourceIndex.delete(I),l.resourceIndex.set(q,{name:$.name,type:$.type,size:$.size,uploadedAt:new Date,file:$}),me(),ee(),u(),(B=t.instance)==null||B.triggerOnChange(r,d())}).catch(q=>{var B,re;const oe=i.indexOf(I);oe!==-1&&i.splice(oe,1),l.resourceIndex.delete(I),me(),(re=(B=l.config).onUploadError)==null||re.call(B,q,$)})}if(v.addEventListener("change",()=>{var $;const I=v.files;if(!I||I.length===0)return;const M=($=e.maxFiles)!=null?$:1/0;for(let N=0;N<I.length;N++){if(i.length>=M){g(k("filesLimitExceeded",l,{skipped:I.length-N,max:M}));break}E(I[N])&&Ae(I[N])}v.value=""}),C.appendChild(w),C.appendChild(x),C.appendChild(K),C.appendChild(H),p.appendChild(y),p.appendChild(C),p.appendChild(m),e.minLength!=null||e.maxLength!=null){const $=document.createElement("div");$.style.cssText="position: relative; padding: 2px 10px 4px; text-align: right;";const I=lt(e,x);I.style.cssText=`
|
|
1379
1379
|
position: static;
|
|
1380
1380
|
display: inline-block;
|
|
1381
1381
|
font-size: var(--fb-font-size-small);
|
|
1382
1382
|
color: var(--fb-text-secondary-color);
|
|
1383
1383
|
pointer-events: none;
|
|
1384
|
-
`,$.appendChild(I),p.appendChild($)}p.appendChild(f),p.appendChild(
|
|
1384
|
+
`,$.appendChild(I),p.appendChild($)}p.appendChild(f),p.appendChild(v),u(),ee(),f._applyExternalUpdate=$=>{var I;const M=(I=$.text)!=null?I:"";x.value=M?rr(M,i,l):"",x.dispatchEvent(new Event("input")),i.length=0;for(const N of $.files)i.push(N);me(),ee(),u()},n.appendChild(p),me();const xe=new MutationObserver(()=>{p.isConnected||(s.abort(),z=Ke(z),xe.disconnect())});p.parentElement&&xe.observe(p.parentElement,{childList:!0})}function Il(e,t,n,r,o){var a,l;const i=t.state,{text:c,files:s}=o,f=new Map;for(const d of s){const u=i.resourceIndex.get(d);u!=null&&u.name&&f.set(d,u.name)}if(s.length>0){const d=document.createElement("div");d.style.cssText="display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px;",s.forEach(u=>{const p=i.resourceIndex.get(u),m=document.createElement("div");m.style.cssText=`
|
|
1385
1385
|
position: relative;
|
|
1386
1386
|
width: 48px; height: 48px;
|
|
1387
1387
|
border: 1px solid var(--fb-border-color, #d1d5db);
|
|
@@ -1390,12 +1390,12 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1390
1390
|
flex-shrink: 0;
|
|
1391
1391
|
background: #fff;
|
|
1392
1392
|
cursor: default;
|
|
1393
|
-
`;const b=document.createElement("div");b.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",or(b,u,p,
|
|
1393
|
+
`;const b=document.createElement("div");b.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",or(b,u,p,i),m.appendChild(b);const g=cr();m.addEventListener("mouseenter",()=>{gt(g),g.element||(g.element=sr(m,{rid:u,state:i,isReadonly:!0}),g.element.addEventListener("mouseenter",()=>{gt(g)}),g.element.addEventListener("mouseleave",()=>{bt(g)}))}),m.addEventListener("mouseleave",()=>{bt(g)}),d.appendChild(m)}),n.appendChild(d)}if(c){const d=document.createElement("div");d.style.cssText=`
|
|
1394
1394
|
${vt}
|
|
1395
1395
|
color: var(--fb-text-color, #111827);
|
|
1396
1396
|
white-space: pre-wrap;
|
|
1397
1397
|
word-break: break-word;
|
|
1398
|
-
`;const u=
|
|
1398
|
+
`;const u=ht(c).filter(p=>f.has(p.name)||[...f.values()].includes(p.name));if(u.length===0)d.textContent=c;else{let p=0;for(const m of u){m.start>p&&d.appendChild(document.createTextNode(c.slice(p,m.start)));const b=document.createElement("span");b.style.cssText=`
|
|
1399
1399
|
display: inline;
|
|
1400
1400
|
background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent);
|
|
1401
1401
|
color: var(--fb-primary-color, #0066cc);
|
|
@@ -1403,7 +1403,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1403
1403
|
padding: 1px 6px;
|
|
1404
1404
|
font-weight: 500;
|
|
1405
1405
|
cursor: default;
|
|
1406
|
-
`;const
|
|
1406
|
+
`;const g=f.has(m.name)?m.name:(a=[...f.entries()].find(([,h])=>h===m.name))==null?void 0:a[0],E=(l=f.get(m.name))!=null?l:m.name;if(b.textContent=`@${E}`,g){let h=null;const y=g;b.addEventListener("mouseenter",()=>{h=Ke(h),h=ar(b,y,i)}),b.addEventListener("mouseleave",()=>{h=Ke(h)})}d.appendChild(b),p=m.end}p<c.length&&d.appendChild(document.createTextNode(c.slice(p)))}n.appendChild(d)}if(!c&&s.length===0){const d=document.createElement("div");d.style.cssText="color: var(--fb-text-muted-color, #6b7280); font-size: var(--fb-font-size, 14px);",d.textContent="\u2014",n.appendChild(d)}}function Rl(e,t,n,r){var o,a,l,i;const c=t.state,s=ae(e,c,t),f=(o=e.textKey)!=null?o:"text",d=(a=e.filesKey)!=null?a:"files";let u;if(e.flatOutput){const p=t.prefill[f],m=t.prefill[d];u={text:typeof p=="string"?p:null,files:Array.isArray(m)?m:[]}}else{const p=t.prefill[e.key];if(p&&typeof p=="object"&&!Array.isArray(p)){const m=p,b=(l=m[f])!=null?l:m.text,g=(i=m[d])!=null?i:m.files;u={text:typeof b=="string"?b:null,files:Array.isArray(g)?g:[]}}else typeof p=="string"?u={text:p||null,files:[]}:u={text:null,files:[]}}for(const p of u.files)c.resourceIndex.has(p)||c.resourceIndex.set(p,{name:p,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(s)Il(e,t,n,r,u);else{if(!c.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);Nl(e,t,n,r,u)}}function ql(e,t,n){var r,o;const{scopeRoot:a,state:l,skipValidation:i}=n,c=[],s=(r=e.textKey)!=null?r:"text",f=(o=e.filesKey)!=null?o:"files",d=a.querySelector(`[name="${t}"]`);if(!d)return{value:null,errors:c};let u;try{const h=JSON.parse(d.value);if(h&&typeof h=="object"&&!Array.isArray(h))u=h;else return c.push(`${t}: invalid richinput data`),{value:null,errors:c}}catch(h){return c.push(`${t}: invalid richinput data`),{value:null,errors:c}}const p=u[s],m=u[f],b=p===null||typeof p=="string"?p:null,g=Array.isArray(m)?m:[],E={[s]:b!=null?b:null,[f]:g};if(!i){const h=!b||b.trim()==="",y=g.length===0;e.required&&h&&y&&c.push(`${t}: ${k("required",l)}`),!h&&b&&(e.minLength!=null&&b.length<e.minLength&&c.push(`${t}: ${k("minLength",l,{min:e.minLength})}`),e.maxLength!=null&&b.length>e.maxLength&&c.push(`${t}: ${k("maxLength",l,{max:e.maxLength})}`)),e.maxFiles!=null&&g.length>e.maxFiles&&c.push(`${t}: ${k("maxFiles",l,{max:e.maxFiles})}`)}return{value:E,errors:c,spread:!!e.flatOutput}}function Bl(e,t,n,r){var o,a,l,i;const{scopeRoot:c}=r,s=c.querySelector(`[name="${t}"]`);if(!s){console.warn(`updateRichInputField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let f=null;if(n&&typeof n=="object"&&!Array.isArray(n)){const d=n,u=(o=e.textKey)!=null?o:"text",p=(a=e.filesKey)!=null?a:"files",m=(l=d[u])!=null?l:d.text,b=(i=d[p])!=null?i:d.files;(m!==void 0||b!==void 0)&&(f={text:typeof m=="string"?m:null,files:Array.isArray(b)?b:[]})}f&&s._applyExternalUpdate?s._applyExternalUpdate(f):f&&(s.value=JSON.stringify(f))}const Hl={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function fr(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function et(e){return(e+"").replace(/"/g,""").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 a=t||{};let l=0,i,c,s,f,d;function u(m){const b=Hl[m[1]||""],g=r[r.length-1]===m;return b?b[1]?(g?r.pop():r.push(m),b[g?1:0]):b[0]:m}function p(){let m="";for(;r.length;)m+=u(r[r.length-1]);return m}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,(m,b,g)=>(a[b.toLowerCase()]=g,"")).replace(/^\n+|\n+$/g,"");s=n.exec(e);)c=e.substring(l,s.index),l=n.lastIndex,i=s[0],c.match(/[^\\](\\\\)*\\$/)||((d=s[3]||s[4])?i='<pre class="code '+(s[4]?"poetry":s[2].toLowerCase())+'"><code'+(s[2]?` class="language-${s[2].toLowerCase()}"`:"")+">"+fr(et(d).replace(/^\n+|\n+$/g,""))+"</code></pre>":(d=s[6])?(d.match(/\./)&&(s[5]=s[5].replace(/^\d+/gm,"")),f=Jt(fr(s[5].replace(/^\s*[>*+.-]/gm,""))),d===">"?d="blockquote":(d=d.match(/\./)?"ol":"ul",f=f.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),i="<"+d+">"+f+"</"+d+">"):s[8]?i=`<img src="${et(s[8])}" alt="${et(s[7])}">`:s[10]?(o=o.replace("<a>",`<a href="${et(s[11]||a[c.toLowerCase()])}">`),i=p()+"</a>"):s[9]?i="<a>":s[12]||s[14]?(d="h"+(s[14]?s[14].length:s[13]>"="?1:2),i="<"+d+">"+Jt(s[12]||s[15],a)+"</"+d+">"):s[16]?i="<code>"+et(s[16])+"</code>":(s[17]||s[1])&&(i=u(s[17]||"--"))),o+=c,o+=i;return(o+e.substring(l)+p()).replace(/^\n+|\n+$/g,"")}const pr="fb-markdown-styles";function Dl(){if(typeof document=="undefined"||document.getElementById(pr))return;const e=document.createElement("style");e.id=pr,e.setAttribute("data-fb-markdown-styles","true"),e.textContent=`
|
|
1407
1407
|
.fb-markdown {
|
|
1408
1408
|
font-family: var(--fb-font-family, inherit);
|
|
1409
1409
|
font-size: var(--fb-font-size, 1rem);
|
|
@@ -1480,11 +1480,11 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1480
1480
|
.fb-markdown strong { font-weight: var(--fb-font-weight-medium, 600); }
|
|
1481
1481
|
.fb-markdown em { font-style: italic; }
|
|
1482
1482
|
.fb-markdown s { text-decoration: line-through; }
|
|
1483
|
-
`,document.head.appendChild(e)}const Bl=["javascript:","data:","vbscript:","blob:"],Hl=["javascript:","vbscript:","blob:"];function Dl(e){return!!(Hl.some(t=>e.startsWith(t))||e.startsWith("data:")&&!e.startsWith("data:image/"))}function jl(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Ol(e){e.querySelectorAll("a[href]").forEach(t=>{var n;const r=((n=t.getAttribute("href"))!=null?n:"").trim().toLowerCase();Bl.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();Dl(r)&&t.setAttribute("src","")})}function Ul(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})`);ql();const r=document.createElement("div");r.className="fb-markdown";const o=jl(e.content);return r.innerHTML=_t(o),Ol(r),n.appendChild(r),r}function Pl(e,t,n){return{value:void 0,errors:[],skip:!0}}function Wl(e,t,n,r){}function Vl(e,t,n){var r;const{scopeRoot:o}=n,a=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`),i=(r=a==null?void 0:a.value)!=null?r:"";if(i===""){const l="default"in e?e.default:null;return{value:l!==void 0?l:null,errors:[]}}return{value:Qt(i),errors:[]}}function Kl(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 _l={text:{validate:rn,update:on},textarea:{validate:zr,update:Mr},number:{validate:Br,update:Hr},select:{validate:Or,update:Ur},switcher:{validate:Kr,update:_r},boolean:{validate:Xr,update:Gr,ownsLabel:!0},file:{validate:qn,update:Hn},files:{validate:qn,update:Hn},colour:{validate:tl,update:nl},slider:{validate:ll,update:il},container:{validate:Gn,update:Zn},group:{validate:fl,update:pl},table:{validate:kl,update:$l},richinput:{validate:Nl,update:Il},hidden:{validate:Vl,update:Kl},markdown:{validate:Pl,update:Wl}};function Jt(e){return _l[e]||null}function Jl(e,t,n){const r=Jt(e.type);return r&&r.validate?r.validate(e,t,n):null}function Yl(e,t,n,r){const o=Jt(e.type);return o&&o.update?(o.update(e,t,n,r),!0):!1}function Xl(e,t){const n=document.getElementById(e);if(!n)return;const r=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(f=>{f.classList.add("hidden")}),r)return;const o=t.getBoundingClientRect(),a=window.innerWidth,i=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const l=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let d=o.left,s=o.bottom+5;d+l.width>a&&(d=o.right-l.width),s+l.height>i&&(s=o.top-l.height-5),d<10&&(d=10),s<10&&(s=o.bottom+5),n.style.left=`${d}px`,n.style.top=`${s}px`,n.classList.remove("hidden"),setTimeout(()=>{n.classList.add("hidden")},25e3)}typeof document!="undefined"&&document.addEventListener("click",e=>{const t=e.target,n=t.closest("button")&&t.closest("button").onclick,r=t.closest('[id^="tooltip-"]');!n&&!r&&document.querySelectorAll('[id^="tooltip-"]').forEach(o=>{o.classList.add("hidden")})});function mr(e,t){var n,r,o;if(!e.enableIf)return!1;try{const a=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},i=((o=e.enableIf.scope)!=null?o:"relative")==="relative"&&t.path?t.prefill:void 0;return!je(e.enableIf,a,i)}catch(a){console.error(`Error evaluating enableIf for field "${e.key}":`,a)}return!1}function Gl(e,t){const n=t.querySelector(`[name="${e}"]`);if(n){if(n instanceof HTMLSelectElement)return n.value;if(n instanceof HTMLInputElement){if(n.type==="checkbox")return n.checked;if(n.type==="radio"){const r=t.querySelector(`[name="${e}"]:checked`);return r?r.value:void 0}else return n.value}else if(n instanceof HTMLTextAreaElement)return n.value}}function Zl(e,t){const n=e.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return{};const r={};let o=r;for(let i=0;i<n.length-1;i++){const l=n[i],d=n[i+1],s=d.startsWith("[")&&d.endsWith("]")?[]:{};if(l.startsWith("[")&&l.endsWith("]")){const f=parseInt(l.slice(1,-1),10);o[f]=s}else o[l]=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 gt(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,i=(r=a.scope)!=null?r:"relative",l=!n.path||n.path===""?"absolute":i,d=a.key,s=l==="relative"&&n.path?`${n.path}.${d}`:d,f=Gl(s,o),c=Zl(d,f),u=l==="relative"?{}:c,p=l==="relative"?c: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 hr(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,i=(r=a.scope)!=null?r:"relative",l=a.key;let d;i==="relative"&&n.path?d=`${n.path}.${l}`:d=l;const s=o.querySelector(`[name="${d}"]`);if(!s){const f=new MutationObserver(()=>{const c=o.querySelector(`[name="${d}"]`);c&&(c.addEventListener("change",()=>{gt(e,t,n)}),c.addEventListener("input",()=>{gt(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",()=>{gt(e,t,n)}),s.addEventListener("input",()=>{gt(e,t,n)})}function Ql(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 ei(e){const t=document.createElement("button");t.type="button",t.className="ml-2 text-gray-400 hover:text-gray-600",t.innerHTML='<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>';const n=`tooltip-${e.key}-${Math.random().toString(36).substr(2,9)}`,r=document.createElement("div");return r.id=n,r.className="hidden absolute z-50 bg-gray-200 text-gray-900 text-sm rounded-lg p-3 max-w-sm border border-gray-300 shadow-lg",r.style.position="fixed",r.textContent=e.description||e.hint||"Field information",document.body.appendChild(r),t.onclick=o=>{o.preventDefault(),o.stopPropagation(),Xl(n,t)},t}function ti(e){const t=document.createElement("div");t.className="flex items-center",t.style.marginBottom="var(--fb-label-margin-bottom, 2px)",t.dataset.fbLabelRow="";const n=Ql(e);if(t.appendChild(n),e.description||e.hint){const r=ei(e);t.appendChild(r)}return t}function ni(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?Tr(e,t,n,r):Lr(e,t,n,r);break;case"textarea":o?Fr(e,t,n,r):Ar(e,t,n,r);break;case"number":o?qr(e,t,n,r):Rr(e,t,n,r);break;case"select":o?jr(e,t,n,r):Dr(e,t,n,r);break;case"switcher":o?Vr(e,t,n,r):Wr(e,t,n,r);break;case"boolean":Yr(e,t,n,r);break;case"file":o?Zo(e,t,n,r):Xo(e,t,n,r);break;case"files":Go(e,t,n,r);break;case"colour":o?el(e,t,n,r):Qo(e,t,n,r);break;case"slider":o?ol(e,t,n,r):rl(e,t,n,r);break;case"group":ul(e,t,n,r);break;case"container":o?Yn(e,t,n):Jn(e,t,n,r);break;case"table":El(e,t,n,r);break;case"richinput":Ml(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 Yt(e,t){if(e.type==="markdown"){if(e.hidden===!0){const d=document.createElement("div");return d.style.display="none",d.setAttribute("data-fb-hidden-markdown","true"),d}const i=mr(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",xt(e,t.state)),l.setAttribute("data-fb-width",e.width||"full"),Ul(e,t,l),i&&(l.style.display="none",l.classList.add("fb-field-wrapper-disabled"),l.setAttribute("data-conditionally-disabled","true")),hr(l,e,t),l}const n=mr(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=Jt(e.type);if(!(o!=null&&o.ownsLabel)){const i=ti(e);r.appendChild(i)}const a=De(t.path,e.key);return ni(e,t,r,a),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),hr(r,e,t),r}al(Yt);const Xt={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 ri(e){const t={...Xt.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...Xt.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Xt,...e,translations:t},debounceTimer:null,prefill:{},syntheticElementIds:new WeakMap,syntheticElementIdCounter:0,enableIfObservers:new Set}}function oi(){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 li(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
|
|
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 si(e,t){Lr(e.ownerDocument||document);const n=ai(t);let r=e.querySelector("style[data-fb-theme]");r||(r=document.createElement("style"),r.setAttribute("data-fb-theme","true"),e.appendChild(r)),r.textContent=`
|
|
1485
1485
|
[data-fb-root="true"] {
|
|
1486
1486
|
${n}
|
|
1487
1487
|
}
|
|
1488
|
-
`}const
|
|
1488
|
+
`}const ci={default:_e,dark:{..._e,primaryColor:"#60a5fa",primaryHoverColor:"#3b82f6",borderColor:"#4b5563",borderHoverColor:"#6b7280",borderFocusColor:"#60a5fa",backgroundColor:"#1f2937",backgroundHoverColor:"#374151",backgroundReadonlyColor:"#111827",textColor:"#f9fafb",textSecondaryColor:"#9ca3af",textPlaceholderColor:"#6b7280",fileUploadBgColor:"#374151",fileUploadBorderColor:"#4b5563",fileUploadTextColor:"#9ca3af"},klein:{..._e,primaryColor:"#0066cc",primaryHoverColor:"#0052a3",errorColor:"#d32f2f",errorHoverColor:"#c62828",successColor:"#388e3c",borderColor:"#e0e0e0",borderHoverColor:"#bdbdbd",borderFocusColor:"#0066cc",borderRadius:"4px",fontSize:"16px",fontSizeSmall:"14px",fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif'},picaz:{..._e,primaryColor:"#2f5bea",primaryHoverColor:"#2349c8",primarySoftColor:"#eaf0ff",primarySoftHoverColor:"#d6e0ff",errorColor:"#ef4444",successColor:"#16a34a",accentColor:"#ffb020",accentSoftColor:"#fff7e6",accentBorderColor:"#fde7b5",accentTextColor:"#92400e",borderColor:"#e3e8f0",borderHoverColor:"#cdd6e3",borderFocusColor:"#2f5bea",borderStrongColor:"#cdd6e3",backgroundColor:"#ffffff",backgroundHoverColor:"#f3f7ff",pageBackgroundColor:"#f6f8fb",surfaceSoftColor:"#eef4ff",surfaceTintColor:"#f3f7ff",textColor:"#0f172a",textSecondaryColor:"#334155",textMutedColor:"#64748b",textFaintColor:"#94a3b8",textPlaceholderColor:"#94a3b8",buttonBgColor:"#2f5bea",buttonHoverBgColor:"#2349c8",fileUploadBgColor:"#fafcff",fileUploadBorderColor:"#cdd6e3",fileUploadHoverBorderColor:"#2f5bea",inputPaddingX:"14px",inputPaddingY:"11px",borderRadius:"12px",borderRadiusSmall:"8px",borderRadiusLarge:"16px",borderRadiusXLarge:"22px",fontFamily:'"Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',shadowCard:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",shadowPopover:"0 12px 32px -12px rgba(15,23,42,.18), 0 4px 12px -6px rgba(15,23,42,.08)",focusRingColor:"#2f5bea",slideCardBg:"linear-gradient(180deg, #f7f9fc 0%, #dde3ee 100%)",slideCardShadow:"none",slideCardRadius:"16px",labelSectionFontSize:"0.625rem",labelSectionLetterSpacing:"0.07em",labelSectionTextTransform:"uppercase"}};function Gt(e,t,n){const r=e.querySelectorAll(`[data-field-key="${t}"]`);for(const o of Array.from(r))if(o.closest("[data-container-item], [data-container]")===n)return o;return null}class xt{constructor(t){this.instanceId=ii(),this.state=li(t),this.state.config.verboseErrors&&(globalThis.__formBuilderInstances||(globalThis.__formBuilderInstances=new Set),globalThis.__formBuilderInstances.add(this.instanceId),globalThis.__formBuilderInstances.size>10&&console.warn(`[form-builder] ${globalThis.__formBuilderInstances.size} instances active. Possible memory leak - ensure you call destroy() when done.`))}getInstanceId(){return this.instanceId}getState(){return this.state}setFormRoot(t){this.state.formRoot=t}configure(t){Object.assign(this.state.config,t)}setUploadHandler(t){this.state.config.uploadFile=t}setDownloadHandler(t){this.state.config.downloadFile=t}setThumbnailHandler(t){this.state.config.getThumbnail=t}setActionHandler(t){this.state.config.actionHandler=t}setMode(t){this.state.config.readonly=t==="readonly"}setLocale(t){this.state.config.translations[t]&&(this.state.config.locale=t)}triggerOnChange(t,n){this.state.config.readonly||(this.state.debounceTimer!==null&&clearTimeout(this.state.debounceTimer),this.state.debounceTimer=setTimeout(()=>{const r=this.validateForm(!0);if(this.reevaluateConditionalFields(),this.state.config.onChange&&this.state.config.onChange(r),this.state.config.onFieldChange&&t!==void 0){const o=n!==void 0?n:this.resolveDomPathValue(r.data,t);this.state.config.onFieldChange(t,o,r)}this.state.debounceTimer=null},this.state.config.debounceMs))}resolveDomPathValue(t,n){let r=t,o="";for(const a of n.split(".")){if(r==null)return;const l=a.match(/^(.+)\[(\d+)\]$/);if(!l){o=o?`${o}.${a}`:a,r=r[a];continue}const i=l[1];o=o?`${o}.${i}`:i;const c=r[i];if(!Array.isArray(c))return;const s=this.state.formRoot?nt(this.state.formRoot,o):[];o=`${o}[${l[2]}]`;const f=s.findIndex(d=>d.getAttribute("data-container-item")===o);r=f>=0?c[f]:c[parseInt(l[2],10)]}return r}registerAction(t){if(!t||!t.value)throw new Error("Action must have a value property");this.state.externalActions||(this.state.externalActions=[]);const n=this.state.externalActions.findIndex(r=>r.value===t.value&&r.related_field===t.related_field);n>=0?this.state.externalActions[n]=t:this.state.externalActions.push(t)}findFormElementByFieldPath(t){if(!this.state.formRoot)return null;const n=this.state.formRoot.querySelector(`[name="${t}"]`);if(n)return n;const r=this.findSchemaElement(t);if(!r)return null;const o=this.state.formRoot.querySelectorAll(".fb-field-wrapper");for(const a of o){const l=r.label||r.key,i=a.querySelector("label");if(i&&(i.textContent===l||i.textContent===`${l}*`)){let c=a.querySelector(".field-placeholder");return c||(c=document.createElement("div"),c.className="field-placeholder",c.style.display="none",a.appendChild(c)),c}}return null}findSchemaElement(t){if(!this.state.schema||!this.state.schema.elements)return null;let n=this.state.schema.elements,r=null;const o=t.replace(/\[\d+\]/g,"").split(".").filter(Boolean);for(const a of o){if(r=n.find(l=>l.key===a)||null,!r)return null;"elements"in r&&r.elements&&(n=r.elements)}return r}resolveActionLabel(t,n,r,o=!1){if(r&&"actions"in r&&r.actions){const a=r.actions.find(l=>l.key===t);if(a&&a.label)return a.label}if(o&&this.state.schema&&"actions"in this.state.schema&&this.state.schema.actions){const a=this.state.schema.actions.find(l=>l.key===t);if(a&&a.label)return a.label}return n||t}renderFormLevelActions(t,n=[]){if(!this.state.formRoot)return;const r=this.state.formRoot.querySelector(".form-level-actions-container");r&&r.remove();const o=document.createElement("div");o.className="form-level-actions-container mt-3 pt-2 flex flex-wrap gap-2 justify-center",o.style.cssText=`
|
|
1489
1489
|
border-top: var(--fb-border-width) solid var(--fb-border-color);
|
|
1490
|
-
`,t.forEach(a=>{const i=document.createElement("button");i.type="button",nn(i,!0);const l=n.includes(a),d=this.resolveActionLabel(a.key,a.label,null,l);i.textContent=d,i.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(i)}),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,i)=>{const l=this.findFormElementByFieldPath(i);if(!l){console.warn(`External action: Could not find form element for field "${i}", treating as form-level actions`),r.push(...a);return}let d=l.closest(".fb-field-wrapper");if(d||(d=l.parentElement),!d){console.warn(`External action: Could not find wrapper for field "${i}"`);return}const s=d.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 c=this.findSchemaElement(i);a.forEach(u=>{const p=document.createElement("button");p.type="button",nn(p,!1);const m=this.resolveActionLabel(u.key,u.label,c);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)}),d.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 i=JSON.parse(r);for(const d in i){const s=o?d:`${a}.${d}`,f=i[d];this.updateField(s,f)}const l=n.closest(".fb-prefill-hints");l&&l.querySelectorAll('.fb-prefill-hint[aria-pressed="true"]').forEach(d=>d.removeAttribute("aria-pressed")),n.setAttribute("aria-pressed","true")}catch(i){console.error("Error parsing prefill hint values:",i)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-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=Et(n);if(a.length>0){console.error("Schema validation errors:",a);return}this.disconnectEnableIfObservers(),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"),ii(t,this.state.config.theme);const i=document.createElement("div");if(i.className="fb-row",n.prefillHints&&!this.state.config.readonly){const s=this.createRootPrefillHints(n.prefillHints);i.appendChild(s)}const l=document.createElement("div"),d=n.columns||1;d===1?l.className="fb-row":l.className=`grid grid-cols-${d} gap-2`,n.elements.forEach(s=>{var f,c;if(s.type!=="markdown"&&(s.hidden||s.type==="hidden")){const p=(c=(f=r==null?void 0:r[s.key])!=null?f:s.default)!=null?c:null;l.appendChild(Ct(s.key,p));return}const u=Yt(s,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});l.appendChild(u)}),i.appendChild(l),t.appendChild(i),this.state.config.readonly||t.addEventListener("click",this.handlePrefillHintClick.bind(this)),this.state.config.readonly&&this.state.externalActions&&Array.isArray(this.state.externalActions)&&this.renderExternalActions()}validateForm(t=!1){if(!this.state.schema||!this.state.formRoot)return{valid:!0,errors:[],data:{}};const n=[],r={},o=(a,i,l=null)=>{var d;const s=(d=a.key)!=null?d:"",f={scopeRoot:l||this.state.formRoot,state:this.state,instance:this,path:i.path,skipValidation:t},c=Jl(a,s,f);return c!==null?(n.push(...c.errors),{value:c.value,spread:!!c.spread,skip:!!c.skip}):(console.warn(`Unknown field type "${a.type}" for key "${s}"`),{value:null,spread:!1})};return cl(o),this.state.schema.elements.forEach(a=>{var i;if(a.enableIf)try{if(!je(a.enableIf,r))return}catch(l){console.error(`Error evaluating enableIf for field "${a.key}" during validation:`,l)}if(a.type!=="markdown")if(a.hidden||a.type==="hidden"){const l=this.state.formRoot.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${a.key}"]`),d=(i=l==null?void 0:l.value)!=null?i:"";d!==""?r[a.key]=Qt(d):r[a.key]=a.default!==void 0?a.default:null}else{const l=o(a,{path:""});if(l.skip)return;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,i=this.buildHiddenFieldsData(a.elements);Object.keys(i).length>0&&(o in n?typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])&&(n[o]={...n[o],...i}):n[o]=i)}}return n}buildFlatKeyMap(t){var n,r;const o=new Map;for(const a of t)if(a.type==="richinput"&&a.flatOutput){const i=a,l=(n=i.textKey)!=null?n:"text",d=(r=i.filesKey)!=null?r:"files";o.set(l,{schemaKey:a.key,role:"text"}),o.set(d,{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:""};Yl(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=xt(t,this.state);if(!n)return Gt(r,o,null);const a=n.match(/^(.+)\[(\d+)\]$/);if(a){const l=r.querySelector(`[data-container-item="${a[1]}[${a[2]}]"]`);return l?Gt(l,o,l):null}const i=r.querySelector(`[data-container="${n}"]`);return i?Gt(i,o,i):null}applyEnableIfVisibility(t,n,r,o,a,i){var l,d,s,f;try{const c=((l=t.enableIf.scope)!=null?l:"relative")==="relative"&&o?nt(i,o):void 0,u=je(t.enableIf,i,c),p=n.getAttribute("data-conditionally-disabled")==="true";if(u&&p){const m=o?nt(i,o):i,b=Yt(t,{path:r,prefill:m&&typeof m=="object"?m:{},formData:i,state:this.state,instance:this});(d=n.parentNode)==null||d.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",xt(t,this.state)),m.setAttribute("data-conditionally-disabled","true"),(s=n.parentNode)==null||s.replaceChild(m,n)}}catch(c){console.error(`Error re-evaluating enableIf for field "${(f=t.key)!=null?f:"<no key>"}" at path "${a}":`,c)}}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,o,a)=>{r.forEach(i=>{var l;const d=(l=i.key)!=null?l:"",s=o?`${o}.${d}`:d,f=a?`${a}.${d}`:d;if(i.enableIf){const c=this.findFieldWrapper(i,o);c&&this.applyEnableIfVisibility(i,c,o,a,s,t)}if((i.type==="container"||i.type==="group")&&"elements"in i&&i.elements){const c=i.key?nt(t,f):void 0;Array.isArray(c)?wt(this.state.formRoot,s).forEach((u,p)=>{const m=u.getAttribute("data-container-item")||"";n(i.elements,m,`${f}[${p}]`)}):n(i.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.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()}}function br(e){return new yt(e)}return typeof window!="undefined"&&(window.FormBuilder=yt,window.createFormBuilder=br,window.validateSchema=Et),Fe.FormBuilderInstance=yt,Fe.createFormBuilder=br,Fe.default=yt,Fe.defaultTheme=_e,Fe.exampleThemes=ai,Fe.validateSchema=Et,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe})({});
|
|
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})({});
|