@arudovwen/form-builder-react 1.4.30 → 1.4.31
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/dist/form-builder.es.js
CHANGED
|
@@ -2237,7 +2237,7 @@ function wn({
|
|
|
2237
2237
|
}, [u, i.id]), /* @__PURE__ */ n.jsx("div", { className: "custom-select", children: /* @__PURE__ */ n.jsx(
|
|
2238
2238
|
ii,
|
|
2239
2239
|
{
|
|
2240
|
-
value: s,
|
|
2240
|
+
value: s || [],
|
|
2241
2241
|
onChange: (h) => {
|
|
2242
2242
|
a(h), d == null || d(i.id, h);
|
|
2243
2243
|
},
|
|
@@ -2251,7 +2251,7 @@ function wn({
|
|
|
2251
2251
|
className: "custom-select__control field-control",
|
|
2252
2252
|
disabled: c,
|
|
2253
2253
|
children: [
|
|
2254
|
-
/* @__PURE__ */ n.jsx("span", { className: "custom-select__value", children: s.length > 0 ? r : /* @__PURE__ */ n.jsx("span", { className: "custom-select__placeholder", children: o != null ? o : " Select options" }) }),
|
|
2254
|
+
/* @__PURE__ */ n.jsx("span", { className: "custom-select__value", children: (s == null ? void 0 : s.length) > 0 ? r : /* @__PURE__ */ n.jsx("span", { className: "custom-select__placeholder", children: o != null ? o : " Select options" }) }),
|
|
2255
2255
|
/* @__PURE__ */ n.jsx("span", { className: "custom-select__icon", children: /* @__PURE__ */ n.jsx(W, { icon: "lucide:chevron-down" }) })
|
|
2256
2256
|
]
|
|
2257
2257
|
}
|
|
@@ -2689,16 +2689,16 @@ const G = ({
|
|
|
2689
2689
|
(s == null ? void 0 : s[e]) && /* @__PURE__ */ n.jsx("p", { className: "mt-1 text-sm text-red-600", children: (g = s[e]) == null ? void 0 : g.message })
|
|
2690
2690
|
] });
|
|
2691
2691
|
if (["checkbox", "radio"].includes(l)) {
|
|
2692
|
-
const y = p == null ? void 0 : p(e);
|
|
2692
|
+
const y = (p == null ? void 0 : p(e)) || null;
|
|
2693
2693
|
let j = !1;
|
|
2694
|
-
return y && (l === "checkbox" ? j = y == null ? void 0 : y.includes(r) : j = y == r), /* @__PURE__ */ n.jsxs("div", { className: "space-y-1", children: [
|
|
2694
|
+
return y && (y != null && y.length && l === "checkbox" ? j = y == null ? void 0 : y.includes(r) : j = y == r), /* @__PURE__ */ n.jsxs("div", { className: "space-y-1", children: [
|
|
2695
2695
|
/* @__PURE__ */ n.jsxs("label", { className: "flex items-center gap-3 cursor-pointer select-none", children: [
|
|
2696
2696
|
/* @__PURE__ */ n.jsx(
|
|
2697
2697
|
"input",
|
|
2698
2698
|
{
|
|
2699
2699
|
...x,
|
|
2700
2700
|
type: l,
|
|
2701
|
-
value: r,
|
|
2701
|
+
value: r || "",
|
|
2702
2702
|
disabled: v,
|
|
2703
2703
|
className: "peer sr-only"
|
|
2704
2704
|
}
|
package/dist/form-builder.umd.js
CHANGED
|
@@ -28,11 +28,11 @@ Check the top-level render call using <`+C+">.")}return N}}function Mn(v,N){{if(
|
|
|
28
28
|
<%s {...props} />
|
|
29
29
|
React keys must be passed directly to JSX without using spread:
|
|
30
30
|
let props = %s;
|
|
31
|
-
<%s key={someKey} {...props} />`,Si,Ne,Gs,Ne),En[Ne+Si]=!0}}return v===s?Ps(ae):Ls(ae),ae}}function Os(v,N,C){return Bn(v,N,C,!0)}function Is(v,N,C){return Bn(v,N,C,!1)}var Ds=Is,Ks=Os;Le.Fragment=s,Le.jsx=Ds,Le.jsxs=Ks}()),Le}var Bi;function Rn(){return Bi||(Bi=1,process.env.NODE_ENV==="production"?Re.exports=Kn():Re.exports=Gn()),Re.exports}var i=Rn();const le=b.createContext(void 0),Li={title:"",description:"",id:be.v4(),questionData:[],disabled:!1},Pi=({children:e})=>{const[n,o]=b.useState({}),[s,a]=b.useState({}),[t,l]=b.useState([Li]),[r,d]=b.useState(!1),[c,u]=b.useState(null),[g,p]=b.useState([0]),[h,y]=b.useState(""),f=b.useCallback(()=>{},[]),m=b.useCallback(()=>{const D=be.v4();l(M=>[...M,{...Li,id:D}]),u(D),p([t.length])},[t]),x=b.useCallback(D=>{l(M=>M.filter(T=>T.id!==D)),u(null)},[]),w=b.useCallback((D,M)=>{const T=t.find(I=>I.id===M),B=T==null?void 0:T.questionData.find(I=>I.id===D);B&&l(I=>I==null?void 0:I.map(Y=>Y.id===M?{...Y,questionData:Y.questionData.filter(J=>B.type==="grid"?J.gridId!==B.id&&J.id!==B.id:J.id!==D)}:Y))},[t,l]),k=b.useCallback((D,M)=>{const T=t.find(J=>J.id===M);if(!T)return;const B=T.questionData.findIndex(J=>J.id===D);if(B===-1)return;const I=T.questionData[B],Y=(J,oe={})=>({...JSON.parse(JSON.stringify(J)),id:be.v4(),...oe});l(J=>J==null?void 0:J.map(oe=>{var se;if(oe.id!==M)return oe;const O=[...oe.questionData];if(I.type==="grid"){const ve=(se=O==null?void 0:O.map((Z,de)=>({e:Z,i:de})).filter(({e:Z})=>Z.id===I.id||Z.gridId===I.id))==null?void 0:se.map(({i:Z})=>Z),pe=ve.length?Math.max(...ve)+1:B+1,fe=be.v4(),xe=Y(I,{});xe.id=fe;const R=O.filter(Z=>Z.gridId===I.id),z=R==null?void 0:R.map(Z=>Y(Z,{gridId:fe})),te=[...O.slice(0,pe),xe,...z,...O.slice(pe)];return{...oe,questionData:te}}else{const ve=Y(I,I.gridId?{gridId:I.gridId}:{}),pe=[...O.slice(0,B+1),ve,...O.slice(B+1)];return{...oe,questionData:pe}}}))},[t,l]),S=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>B.id===M?{...B,questionData:D}:B))},[]),A=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>B.id===M?{...B,questionData:[...B.questionData,D]}:B))},[]),_=b.useCallback((D,M,T)=>{l(B=>B==null?void 0:B.map(I=>I.id===M?{...I,questionData:[...I.questionData.slice(0,T),D,...I.questionData.slice(T)]}:I))},[]),j=b.useCallback((D,M,T)=>{l(B=>B==null?void 0:B.map(I=>{var Y;return I.id===T?{...I,questionData:(Y=I.questionData)==null?void 0:Y.map(J=>{var oe;return J.type==="grid"&&J.gridData?{...J,gridData:(oe=J.gridData)==null?void 0:oe.map((O,se)=>se===D?{...O,...M}:O).concat(D>=J.gridData.length?{...M}:[])}:J})}:I}))},[]),L=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>{var I;return B.id===M?{...B,questionData:(I=B.questionData)==null?void 0:I.map(Y=>Y.id===D.id?{...Y,...D}:Y)}:B}))},[]),Q=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>B.id===M?{...B,...D}:B))},[]),W=b.useMemo(()=>({formData:t,setFormData:l,handleDragStop:f,removeElement:w,elementData:s,setElementData:a,updateElementPosition:S,addElement:A,addElementInPosition:_,updateElement:L,addSection:m,removeSection:x,updateSection:Q,isDragging:r,setIsDragging:d,selectedSection:c,setSelectedSection:u,activeSections:g,setActiveSections:p,updateGridElement:j,answerData:n,setAnswerData:o,uploadUrl:h,setUploadUrl:y,duplicateElement:k}),[t,f,w,s,S,A,_,L,m,x,Q,r,c,g,j,n,h,k]);return i.jsx(le.Provider,{value:W,children:e})};function Oi(e){var n,o,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(n=0;n<a;n++)e[n]&&(o=Oi(e[n]))&&(s&&(s+=" "),s+=o)}else for(o in e)e[o]&&(s&&(s+=" "),s+=o);return s}function V(){for(var e,n,o=0,s="",a=arguments.length;o<a;o++)(e=arguments[o])&&(n=Oi(e))&&(s&&(s+=" "),s+=n);return s}function zn({type:e="calendar",className:n}){return i.jsx(i.Fragment,{children:e==="calendar"?i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[i.jsx("path",{d:"M6.66406 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M13.3359 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M2.91406 7.57495H17.0807",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M17.5 7.08341V14.1667C17.5 16.6667 16.25 18.3334 13.3333 18.3334H6.66667C3.75 18.3334 2.5 16.6667 2.5 14.1667V7.08341C2.5 4.58341 3.75 2.91675 6.66667 2.91675H13.3333C16.25 2.91675 17.5 4.58341 17.5 7.08341Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M13.0762 11.4167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M13.0762 13.9167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M9.99803 11.4167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M9.99803 13.9167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M6.91209 11.4167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M6.91209 13.9167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[i.jsx("path",{d:"M10 6.66663V10.8333",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M10.0026 18.3333C5.9776 18.3333 2.71094 15.0667 2.71094 11.0417C2.71094 7.01667 5.9776 3.75 10.0026 3.75C14.0276 3.75 17.2943 7.01667 17.2943 11.0417",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M7.5 1.66663H12.5",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M12.4141 15.4167V14.4501C12.4141 13.2584 13.2641 12.7667 14.2974 13.3667L15.1307 13.8501L15.9641 14.3334C16.9974 14.9334 16.9974 15.9084 15.9641 16.5084L15.1307 16.9917L14.2974 17.4751C13.2641 18.0751 12.4141 17.5834 12.4141 16.3917V15.4167Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const Qe=({value:e=null,onGetValue:n,readOnly:o=!1,dateFormat:s="dd/MM/yyyy",name:a,placeholder:t="Select date",minDate:l,maxDate:r,showYearDropdown:d})=>{const c=e?new Date(e):null,[u,g]=b.useState(c);b.useEffect(()=>{const h=e?new Date(e):null;(h&&u&&h.getTime()!==u.getTime()||!h&&u||h&&!u)&&g(h)},[e]),b.useEffect(()=>{n&&n(a,u)},[u,n,a]);const p=h=>{g(h)};return i.jsx("div",{className:"builder_date__picker",children:i.jsx(Ln,{showIcon:!0,icon:i.jsx(zn,{className:"react-datepicker__calendar-icon"}),showPopperArrow:!1,dateFormat:s,disabled:o,selected:u,onChange:p,className:"field-control",portalId:"root-portal",placeholderText:t,minDate:l,maxDate:r,showYearDropdown:d,scrollableYearDropdown:!0,yearDropdownItemNumber:40})})};function Hn({element:e,validationData:n}){const{register:o=()=>({}),setValue:s,watch:a}=n||{};let t;return a&&(t=a()[e.id]),b.useEffect(()=>{o(e.id)},[e.id]),i.jsx(Qe,{name:e.id,value:t,onGetValue:s,readOnly:n==null?void 0:n.isReadOnly,dateFormat:(e==null?void 0:e.dateFormat)||"dd/MM/yyyy",minDate:e==null?void 0:e.minDate,maxDate:e==null?void 0:e.maxDate,showYearDropdown:e==null?void 0:e.allowYearPicker})}function Xe({element:e,validationData:n}){var s;const{register:o=()=>({})}=n||{};return i.jsx("div",{children:i.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"",type:(e==null?void 0:e.inputType)||"text",className:V("field-control",e==null?void 0:e.customClass),...o(e==null?void 0:e.id),disabled:n==null?void 0:n.isReadOnly,inputMode:(e==null?void 0:e.inputMode)||void 0,"aria-invalid":!!((s=n==null?void 0:n.errors)!=null&&s[e==null?void 0:e.id]),pattern:(e==null?void 0:e.pattern)||void 0})})}function Fn(e,n){const o=e.icons,s=e.aliases||Object.create(null),a=Object.create(null);function t(l){if(o[l])return a[l]=[];if(!(l in a)){a[l]=null;const r=s[l]&&s[l].parent,d=r&&t(r);d&&(a[l]=[r].concat(d))}return a[l]}return Object.keys(o).concat(Object.keys(s)).forEach(t),a}const Ii=Object.freeze({left:0,top:0,width:16,height:16}),ze=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),ei=Object.freeze({...Ii,...ze}),ii=Object.freeze({...ei,body:"",hidden:!1});function Vn(e,n){const o={};!e.hFlip!=!n.hFlip&&(o.hFlip=!0),!e.vFlip!=!n.vFlip&&(o.vFlip=!0);const s=((e.rotate||0)+(n.rotate||0))%4;return s&&(o.rotate=s),o}function Di(e,n){const o=Vn(e,n);for(const s in ii)s in ze?s in e&&!(s in o)&&(o[s]=ze[s]):s in n?o[s]=n[s]:s in e&&(o[s]=e[s]);return o}function Un(e,n,o){const s=e.icons,a=e.aliases||Object.create(null);let t={};function l(r){t=Di(s[r]||a[r],t)}return l(n),o.forEach(l),Di(e,t)}function Ki(e,n){const o=[];if(typeof e!="object"||typeof e.icons!="object")return o;e.not_found instanceof Array&&e.not_found.forEach(a=>{n(a,null),o.push(a)});const s=Fn(e);for(const a in s){const t=s[a];t&&(n(a,Un(e,a,t)),o.push(a))}return o}const Wn={provider:"",aliases:{},not_found:{},...Ii};function ni(e,n){for(const o in n)if(o in e&&typeof e[o]!=typeof n[o])return!1;return!0}function Gi(e){if(typeof e!="object"||e===null)return null;const n=e;if(typeof n.prefix!="string"||!e.icons||typeof e.icons!="object"||!ni(e,Wn))return null;const o=n.icons;for(const a in o){const t=o[a];if(!a||typeof t.body!="string"||!ni(t,ii))return null}const s=n.aliases||Object.create(null);for(const a in s){const t=s[a],l=t.parent;if(!a||typeof l!="string"||!o[l]&&!s[l]||!ni(t,ii))return null}return n}const Ri=Object.create(null);function Jn(e,n){return{provider:e,prefix:n,icons:Object.create(null),missing:new Set}}function Ce(e,n){const o=Ri[e]||(Ri[e]=Object.create(null));return o[n]||(o[n]=Jn(e,n))}function zi(e,n){return Gi(n)?Ki(n,(o,s)=>{s?e.icons[o]=s:e.missing.add(o)}):[]}function qn(e,n,o){try{if(typeof o.body=="string")return e.icons[n]={...o},!0}catch(s){}return!1}const Hi=/^[a-z0-9]+(-[a-z0-9]+)*$/,He=(e,n,o,s="")=>{const a=e.split(":");if(e.slice(0,1)==="@"){if(a.length<2||a.length>3)return null;s=a.shift().slice(1)}if(a.length>3||!a.length)return null;if(a.length>1){const r=a.pop(),d=a.pop(),c={provider:a.length>0?a[0]:s,prefix:d,name:r};return n&&!Fe(c)?null:c}const t=a[0],l=t.split("-");if(l.length>1){const r={provider:s,prefix:l.shift(),name:l.join("-")};return n&&!Fe(r)?null:r}if(o&&s===""){const r={provider:s,prefix:"",name:t};return n&&!Fe(r,o)?null:r}return null},Fe=(e,n)=>e?!!((n&&e.prefix===""||e.prefix)&&e.name):!1;let Pe=!1;function Fi(e){return typeof e=="boolean"&&(Pe=e),Pe}function Vi(e){const n=typeof e=="string"?He(e,!0,Pe):e;if(n){const o=Ce(n.provider,n.prefix),s=n.name;return o.icons[s]||(o.missing.has(s)?null:void 0)}}function Yn(e,n){const o=He(e,!0,Pe);if(!o)return!1;const s=Ce(o.provider,o.prefix);return n?qn(s,o.name,n):(s.missing.add(o.name),!0)}function Zn(e,n){if(typeof e!="object")return!1;if(typeof n!="string"&&(n=e.provider||""),Pe&&!n&&!e.prefix){let a=!1;return Gi(e)&&(e.prefix="",Ki(e,(t,l)=>{Yn(t,l)&&(a=!0)})),a}const o=e.prefix;if(!Fe({prefix:o,name:"a"}))return!1;const s=Ce(n,o);return!!zi(s,e)}const Ui=Object.freeze({width:null,height:null}),Wi=Object.freeze({...Ui,...ze}),$n=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Qn=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Ji(e,n,o){if(n===1)return e;if(o=o||100,typeof e=="number")return Math.ceil(e*n*o)/o;if(typeof e!="string")return e;const s=e.split($n);if(s===null||!s.length)return e;const a=[];let t=s.shift(),l=Qn.test(t);for(;;){if(l){const r=parseFloat(t);isNaN(r)?a.push(t):a.push(Math.ceil(r*n*o)/o)}else a.push(t);if(t=s.shift(),t===void 0)return a.join("");l=!l}}function Xn(e,n="defs"){let o="";const s=e.indexOf("<"+n);for(;s>=0;){const a=e.indexOf(">",s),t=e.indexOf("</"+n);if(a===-1||t===-1)break;const l=e.indexOf(">",t);if(l===-1)break;o+=e.slice(a+1,t).trim(),e=e.slice(0,s).trim()+e.slice(l+1)}return{defs:o,content:e}}function eo(e,n){return e?"<defs>"+e+"</defs>"+n:n}function io(e,n,o){const s=Xn(e);return eo(s.defs,n+s.content+o)}const no=e=>e==="unset"||e==="undefined"||e==="none";function oo(e,n){const o={...ei,...e},s={...Wi,...n},a={left:o.left,top:o.top,width:o.width,height:o.height};let t=o.body;[o,s].forEach(f=>{const m=[],x=f.hFlip,w=f.vFlip;let k=f.rotate;x?w?k+=2:(m.push("translate("+(a.width+a.left).toString()+" "+(0-a.top).toString()+")"),m.push("scale(-1 1)"),a.top=a.left=0):w&&(m.push("translate("+(0-a.left).toString()+" "+(a.height+a.top).toString()+")"),m.push("scale(1 -1)"),a.top=a.left=0);let S;switch(k<0&&(k-=Math.floor(k/4)*4),k=k%4,k){case 1:S=a.height/2+a.top,m.unshift("rotate(90 "+S.toString()+" "+S.toString()+")");break;case 2:m.unshift("rotate(180 "+(a.width/2+a.left).toString()+" "+(a.height/2+a.top).toString()+")");break;case 3:S=a.width/2+a.left,m.unshift("rotate(-90 "+S.toString()+" "+S.toString()+")");break}k%2===1&&(a.left!==a.top&&(S=a.left,a.left=a.top,a.top=S),a.width!==a.height&&(S=a.width,a.width=a.height,a.height=S)),m.length&&(t=io(t,'<g transform="'+m.join(" ")+'">',"</g>"))});const l=s.width,r=s.height,d=a.width,c=a.height;let u,g;l===null?(g=r===null?"1em":r==="auto"?c:r,u=Ji(g,d/c)):(u=l==="auto"?d:l,g=r===null?Ji(u,c/d):r==="auto"?c:r);const p={},h=(f,m)=>{no(m)||(p[f]=m.toString())};h("width",u),h("height",g);const y=[a.left,a.top,d,c];return p.viewBox=y.join(" "),{attributes:p,viewBox:y,body:t}}const ao=/\sid="(\S+)"/g,so="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let to=0;function lo(e,n=so){const o=[];let s;for(;s=ao.exec(e);)o.push(s[1]);if(!o.length)return e;const a="suffix"+(Math.random()*16777216|Date.now()).toString(16);return o.forEach(t=>{const l=typeof n=="function"?n(t):n+(to++).toString(),r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+r+')([")]|\\.[a-z])',"g"),"$1"+l+a+"$3")}),e=e.replace(new RegExp(a,"g"),""),e}const oi=Object.create(null);function ro(e,n){oi[e]=n}function ai(e){return oi[e]||oi[""]}function si(e){let n;if(typeof e.resources=="string")n=[e.resources];else if(n=e.resources,!(n instanceof Array)||!n.length)return null;return{resources:n,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const ti=Object.create(null),Oe=["https://api.simplesvg.com","https://api.unisvg.com"],Ve=[];for(;Oe.length>0;)Oe.length===1||Math.random()>.5?Ve.push(Oe.shift()):Ve.push(Oe.pop());ti[""]=si({resources:["https://api.iconify.design"].concat(Ve)});function uo(e,n){const o=si(n);return o===null?!1:(ti[e]=o,!0)}function li(e){return ti[e]}let qi=(()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch(n){}})();function co(e,n){const o=li(e);if(!o)return 0;let s;if(!o.maxURL)s=0;else{let a=0;o.resources.forEach(l=>{a=Math.max(a,l.length)});const t=n+".json?icons=";s=o.maxURL-a-o.path.length-t.length}return s}function mo(e){return e===404}const bo=(e,n,o)=>{const s=[],a=co(e,n),t="icons";let l={type:t,provider:e,prefix:n,icons:[]},r=0;return o.forEach((d,c)=>{r+=d.length+1,r>=a&&c>0&&(s.push(l),l={type:t,provider:e,prefix:n,icons:[]},r=d.length),l.icons.push(d)}),s.push(l),s};function vo(e){if(typeof e=="string"){const n=li(e);if(n)return n.path}return"/"}const po={prepare:bo,send:(e,n,o)=>{if(!qi){o("abort",424);return}let s=vo(n.provider);switch(n.type){case"icons":{const t=n.prefix,r=n.icons.join(","),d=new URLSearchParams({icons:r});s+=t+".json?"+d.toString();break}case"custom":{const t=n.uri;s+=t.slice(0,1)==="/"?t.slice(1):t;break}default:o("abort",400);return}let a=503;qi(e+s).then(t=>{const l=t.status;if(l!==200){setTimeout(()=>{o(mo(l)?"abort":"next",l)});return}return a=501,t.json()}).then(t=>{if(typeof t!="object"||t===null){setTimeout(()=>{t===404?o("abort",t):o("next",a)});return}setTimeout(()=>{o("success",t)})}).catch(()=>{o("next",a)})}};function Yi(e,n){e.forEach(o=>{const s=o.loaderCallbacks;s&&(o.loaderCallbacks=s.filter(a=>a.id!==n))})}function go(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const n=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!n.length)return;let o=!1;const s=e.provider,a=e.prefix;n.forEach(t=>{const l=t.icons,r=l.pending.length;l.pending=l.pending.filter(d=>{if(d.prefix!==a)return!0;const c=d.name;if(e.icons[c])l.loaded.push({provider:s,prefix:a,name:c});else if(e.missing.has(c))l.missing.push({provider:s,prefix:a,name:c});else return o=!0,!0;return!1}),l.pending.length!==r&&(o||Yi([e],t.id),t.callback(l.loaded.slice(0),l.missing.slice(0),l.pending.slice(0),t.abort))})}))}let ho=0;function fo(e,n,o){const s=ho++,a=Yi.bind(null,o,s);if(!n.pending.length)return a;const t={id:s,icons:n,callback:e,abort:a};return o.forEach(l=>{(l.loaderCallbacks||(l.loaderCallbacks=[])).push(t)}),a}function xo(e){const n={loaded:[],missing:[],pending:[]},o=Object.create(null);e.sort((a,t)=>a.provider!==t.provider?a.provider.localeCompare(t.provider):a.prefix!==t.prefix?a.prefix.localeCompare(t.prefix):a.name.localeCompare(t.name));let s={provider:"",prefix:"",name:""};return e.forEach(a=>{if(s.name===a.name&&s.prefix===a.prefix&&s.provider===a.provider)return;s=a;const t=a.provider,l=a.prefix,r=a.name,d=o[t]||(o[t]=Object.create(null)),c=d[l]||(d[l]=Ce(t,l));let u;r in c.icons?u=n.loaded:l===""||c.missing.has(r)?u=n.missing:u=n.pending;const g={provider:t,prefix:l,name:r};u.push(g)}),n}function yo(e,n=!0,o=!1){const s=[];return e.forEach(a=>{const t=typeof a=="string"?He(a,n,o):a;t&&s.push(t)}),s}const ko={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function wo(e,n,o,s){const a=e.resources.length,t=e.random?Math.floor(Math.random()*a):e.index;let l;if(e.random){let _=e.resources.slice(0);for(l=[];_.length>1;){const j=Math.floor(Math.random()*_.length);l.push(_[j]),_=_.slice(0,j).concat(_.slice(j+1))}l=l.concat(_)}else l=e.resources.slice(t).concat(e.resources.slice(0,t));const r=Date.now();let d="pending",c=0,u,g=null,p=[],h=[];typeof s=="function"&&h.push(s);function y(){g&&(clearTimeout(g),g=null)}function f(){d==="pending"&&(d="aborted"),y(),p.forEach(_=>{_.status==="pending"&&(_.status="aborted")}),p=[]}function m(_,j){j&&(h=[]),typeof _=="function"&&h.push(_)}function x(){return{startTime:r,payload:n,status:d,queriesSent:c,queriesPending:p.length,subscribe:m,abort:f}}function w(){d="failed",h.forEach(_=>{_(void 0,u)})}function k(){p.forEach(_=>{_.status==="pending"&&(_.status="aborted")}),p=[]}function S(_,j,L){const Q=j!=="success";switch(p=p.filter(W=>W!==_),d){case"pending":break;case"failed":if(Q||!e.dataAfterTimeout)return;break;default:return}if(j==="abort"){u=L,w();return}if(Q){u=L,p.length||(l.length?A():w());return}if(y(),k(),!e.random){const W=e.resources.indexOf(_.resource);W!==-1&&W!==e.index&&(e.index=W)}d="completed",h.forEach(W=>{W(L)})}function A(){if(d!=="pending")return;y();const _=l.shift();if(_===void 0){if(p.length){g=setTimeout(()=>{y(),d==="pending"&&(k(),w())},e.timeout);return}w();return}const j={status:"pending",resource:_,callback:(L,Q)=>{S(j,L,Q)}};p.push(j),c++,g=setTimeout(A,e.rotate),o(_,n,j.callback)}return setTimeout(A),x}function Zi(e){const n={...ko,...e};let o=[];function s(){o=o.filter(r=>r().status==="pending")}function a(r,d,c){const u=wo(n,r,d,(g,p)=>{s(),c&&c(g,p)});return o.push(u),u}function t(r){return o.find(d=>r(d))||null}return{query:a,find:t,setIndex:r=>{n.index=r},getIndex:()=>n.index,cleanup:s}}function $i(){}const di=Object.create(null);function _o(e){if(!di[e]){const n=li(e);if(!n)return;const o=Zi(n),s={config:n,redundancy:o};di[e]=s}return di[e]}function Ao(e,n,o){let s,a;if(typeof e=="string"){const t=ai(e);if(!t)return o(void 0,424),$i;a=t.send;const l=_o(e);l&&(s=l.redundancy)}else{const t=si(e);if(t){s=Zi(t);const l=e.resources?e.resources[0]:"",r=ai(l);r&&(a=r.send)}}return!s||!a?(o(void 0,424),$i):s.query(n,a,o)().abort}function Qi(){}function So(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,go(e)}))}function No(e){const n=[],o=[];return e.forEach(s=>{(s.match(Hi)?n:o).push(s)}),{valid:n,invalid:o}}function Ie(e,n,o){function s(){const a=e.pendingIcons;n.forEach(t=>{a&&a.delete(t),e.icons[t]||e.missing.add(t)})}if(o&&typeof o=="object")try{if(!zi(e,o).length){s();return}}catch(a){console.error(a)}s(),So(e)}function Xi(e,n){e instanceof Promise?e.then(o=>{n(o)}).catch(()=>{n(null)}):n(e)}function jo(e,n){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(n).sort():e.iconsToLoad=n,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:o,prefix:s}=e,a=e.iconsToLoad;if(delete e.iconsToLoad,!a||!a.length)return;const t=e.loadIcon;if(e.loadIcons&&(a.length>1||!t)){Xi(e.loadIcons(a,s,o),u=>{Ie(e,a,u)});return}if(t){a.forEach(u=>{const g=t(u,s,o);Xi(g,p=>{const h=p?{prefix:s,icons:{[u]:p}}:null;Ie(e,[u],h)})});return}const{valid:l,invalid:r}=No(a);if(r.length&&Ie(e,r,null),!l.length)return;const d=s.match(Hi)?ai(o):null;if(!d){Ie(e,l,null);return}d.prepare(o,s,l).forEach(u=>{Ao(o,u,g=>{Ie(e,u.icons,g)})})}))}const Co=(e,n)=>{const o=yo(e,!0,Fi()),s=xo(o);if(!s.pending.length){let d=!0;return n&&setTimeout(()=>{d&&n(s.loaded,s.missing,s.pending,Qi)}),()=>{d=!1}}const a=Object.create(null),t=[];let l,r;return s.pending.forEach(d=>{const{provider:c,prefix:u}=d;if(u===r&&c===l)return;l=c,r=u,t.push(Ce(c,u));const g=a[c]||(a[c]=Object.create(null));g[u]||(g[u]=[])}),s.pending.forEach(d=>{const{provider:c,prefix:u,name:g}=d,p=Ce(c,u),h=p.pendingIcons||(p.pendingIcons=new Set);h.has(g)||(h.add(g),a[c][u].push(g))}),t.forEach(d=>{const c=a[d.provider][d.prefix];c.length&&jo(d,c)}),n?fo(n,s,t):Qi};function Mo(e,n){const o={...e};for(const s in n){const a=n[s],t=typeof a;s in Ui?(a===null||a&&(t==="string"||t==="number"))&&(o[s]=a):t===typeof o[s]&&(o[s]=s==="rotate"?a%4:a)}return o}const To=/[\s,]+/;function Eo(e,n){n.split(To).forEach(o=>{switch(o.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function Bo(e,n=0){const o=e.replace(/^-?[0-9.]*/,"");function s(a){for(;a<0;)a+=4;return a%4}if(o===""){const a=parseInt(e);return isNaN(a)?0:s(a)}else if(o!==e){let a=0;switch(o){case"%":a=25;break;case"deg":a=90}if(a){let t=parseFloat(e.slice(0,e.length-o.length));return isNaN(t)?0:(t=t/a,t%1===0?s(t):0)}}return n}function Lo(e,n){let o=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const s in n)o+=" "+s+'="'+n[s]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+o+">"+e+"</svg>"}function Po(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Oo(e){return"data:image/svg+xml,"+Po(e)}function Io(e){return'url("'+Oo(e)+'")'}let De;function Do(){try{De=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch(e){De=null}}function Ko(e){return De===void 0&&Do(),De?De.createHTML(e):e}const en={...Wi,inline:!1},Go={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},Ro={display:"inline-block"},ri={backgroundColor:"currentColor"},nn={backgroundColor:"transparent"},on={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},an={WebkitMask:ri,mask:ri,background:nn};for(const e in an){const n=an[e];for(const o in on)n[e+o]=on[o]}const zo={...en,inline:!0};function sn(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const Ho=(e,n,o)=>{const s=n.inline?zo:en,a=Mo(s,n),t=n.mode||"svg",l={},r=n.style||{},d={...t==="svg"?Go:{}};if(o){const m=He(o,!1,!0);if(m){const x=["iconify"],w=["provider","prefix"];for(const k of w)m[k]&&x.push("iconify--"+m[k]);d.className=x.join(" ")}}for(let m in n){const x=n[m];if(x!==void 0)switch(m){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":d.ref=x;break;case"className":d[m]=(d[m]?d[m]+" ":"")+x;break;case"inline":case"hFlip":case"vFlip":a[m]=x===!0||x==="true"||x===1;break;case"flip":typeof x=="string"&&Eo(a,x);break;case"color":l.color=x;break;case"rotate":typeof x=="string"?a[m]=Bo(x):typeof x=="number"&&(a[m]=x);break;case"ariaHidden":case"aria-hidden":x!==!0&&x!=="true"&&delete d["aria-hidden"];break;default:s[m]===void 0&&(d[m]=x)}}const c=oo(e,a),u=c.attributes;if(a.inline&&(l.verticalAlign="-0.125em"),t==="svg"){d.style={...l,...r},Object.assign(d,u);let m=0,x=n.id;return typeof x=="string"&&(x=x.replace(/-/g,"_")),d.dangerouslySetInnerHTML={__html:Ko(lo(c.body,x?()=>x+"ID"+m++:"iconifyReact"))},b.createElement("svg",d)}const{body:g,width:p,height:h}=e,y=t==="mask"||(t==="bg"?!1:g.indexOf("currentColor")!==-1),f=Lo(g,{...u,width:p+"",height:h+""});return d.style={...l,"--svg":Io(f),width:sn(u.width),height:sn(u.height),...Ro,...y?ri:nn,...r},b.createElement("span",d)};if(Fi(!0),ro("",po),typeof document!="undefined"&&typeof window!="undefined"){const e=window;if(e.IconifyPreload!==void 0){const n=e.IconifyPreload,o="Invalid IconifyPreload syntax.";typeof n=="object"&&n!==null&&(n instanceof Array?n:[n]).forEach(s=>{try{(typeof s!="object"||s===null||s instanceof Array||typeof s.icons!="object"||typeof s.prefix!="string"||!Zn(s))&&console.error(o)}catch(a){console.error(o)}})}if(e.IconifyProviders!==void 0){const n=e.IconifyProviders;if(typeof n=="object"&&n!==null)for(let o in n){const s="IconifyProviders["+o+"] is invalid.";try{const a=n[o];if(typeof a!="object"||!a||a.resources===void 0)continue;uo(o,a)||console.error(s)}catch(a){console.error(s)}}}}function tn(e){const[n,o]=b.useState(!!e.ssr),[s,a]=b.useState({});function t(h){if(h){const y=e.icon;if(typeof y=="object")return{name:"",data:y};const f=Vi(y);if(f)return{name:y,data:f}}return{name:""}}const[l,r]=b.useState(t(!!e.ssr));function d(){const h=s.callback;h&&(h(),a({}))}function c(h){if(JSON.stringify(l)!==JSON.stringify(h))return d(),r(h),!0}function u(){var h;const y=e.icon;if(typeof y=="object"){c({name:"",data:y});return}const f=Vi(y);if(c({name:y,data:f}))if(f===void 0){const m=Co([y],u);a({callback:m})}else f&&((h=e.onLoad)===null||h===void 0||h.call(e,y))}b.useEffect(()=>(o(!0),d),[]),b.useEffect(()=>{n&&u()},[e.icon,n]);const{name:g,data:p}=l;return p?Ho({...ei,...p},e,g):e.children?e.children:e.fallback?e.fallback:b.createElement("span",{})}const ln=b.forwardRef((e,n)=>tn({...e,_ref:n}));b.forwardRef((e,n)=>tn({inline:!0,...e,_ref:n}));function F({icon:e,iconClass:n}){return i.jsx(i.Fragment,{children:i.jsx(ln,{icon:e,className:n})})}function ui({element:e,validationData:n,placeholder:o}){var u;const[s,a]=b.useState([]),{register:t=()=>({}),setValue:l,isReadOnly:r,watch:d}=n||{},c=b.useMemo(()=>s==null?void 0:s.map(g=>g.label).join(", "),[s]);return b.useEffect(()=>{t(e.id)},[e.id,t]),b.useEffect(()=>{if(d){const g=d(p=>{a(p[e.id])});return()=>{var p;return(p=g.unsubscribe)==null?void 0:p.call(g)}}},[d,e.id]),i.jsx("div",{className:"custom-select",children:i.jsx(K.Listbox,{value:s,onChange:g=>{a(g),l==null||l(e.id,g)},multiple:!0,disabled:r,by:"value",children:i.jsxs("div",{className:"custom-select__wrapper",children:[i.jsxs(K.Listbox.Button,{className:"custom-select__control field-control",disabled:r,children:[i.jsx("span",{className:"custom-select__value",children:s.length>0?c:i.jsx("span",{className:"custom-select__placeholder",children:o!=null?o:" Select options"})}),i.jsx("span",{className:"custom-select__icon",children:i.jsx(F,{icon:"lucide:chevron-down"})})]}),i.jsx(K.Transition,{as:b.Fragment,leave:"custom-select__transition",children:i.jsx(K.Listbox.Options,{anchor:"bottom start",className:"custom-select__options",children:(u=e==null?void 0:e.options)==null?void 0:u.map((g,p)=>i.jsx(K.Listbox.Option,{value:g,className:({active:h})=>`custom-select__option ${h?"custom-select__option--active":""}`,children:({selected:h})=>i.jsxs("div",{className:"custom-select__option-row",children:[i.jsx("span",{className:`custom-select__option-label ${h?"custom-select__option--selected":""}`,children:g.label}),h&&i.jsx("span",{className:"custom-select__check",children:"✓"})]})},p))})})]})})})}const Fo=["jpg","jpeg","png","gif","bmp","webp","svg","image"],Vo=(e="")=>{var o;const n=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return Fo.includes(n)||e.startsWith("data:image/")?"image":n==="pdf"||e.startsWith("data:application/pdf")?"pdf":["doc","docx"].includes(n)?"word":["xls","xlsx","csv"].includes(n)?"excel":["ppt","pptx"].includes(n)?"powerpoint":"other"},Uo={pdf:"vscode-icons:file-type-pdf2",word:"vscode-icons:file-type-word",excel:"vscode-icons:file-type-excel",powerpoint:"vscode-icons:file-type-powerpoint2"};function dn({fileUrl:e,fileName:n,removeFile:o}){const[s,a]=b.useState(!1),[t,l]=b.useState("unknown"),[r,d]=b.useState(null);b.useEffect(()=>{e&&l(Vo(e))},[e]),b.useEffect(()=>{if(t==="pdf"&&(e!=null&&e.startsWith("data:")))try{const h=atob(e.split(",")[1]),y=new ArrayBuffer(h.length),f=new Uint8Array(y);for(let w=0;w<h.length;w++)f[w]=h.charCodeAt(w);const m=new Blob([y],{type:"application/pdf"}),x=URL.createObjectURL(m);return d(x),()=>URL.revokeObjectURL(x)}catch(h){console.error("Error creating blob URL:",h)}else d(null)},[e,t]);const c=()=>{t==="image"||t==="pdf"?a(!0):window.open(r||e,"_blank")},u=()=>a(!1),g=n||(e==null?void 0:e.split("/").pop())||"Unknown file";function p(h,y="download"){if(!h)return;if(h.startsWith("data:")){const m=document.createElement("a");m.href=h,m.download=y,document.body.appendChild(m),m.click(),document.body.removeChild(m);return}const f=document.createElement("a");f.href=h,f.setAttribute("download",y),document.body.appendChild(f),f.click(),document.body.removeChild(f)}return i.jsxs("div",{className:"mt-2 field-control !py-1 !bg-gray-50 !flex justify-between gap-x-8 items-center",children:[i.jsxs("div",{onClick:c,className:"!flex items-center rounded cursor-pointer gap-x-3",title:`Click to preview ${g}`,children:[t==="image"&&i.jsx("div",{className:"flex items-center justify-center ",children:i.jsx(F,{iconClass:"text-4xl",icon:"fluent-color:image-48"})}),t!=="image"&&i.jsx(F,{icon:Uo[t],iconClass:"text-4xl"}),i.jsx("span",{className:"text-sm font-semibold text-center text-gray-700 truncate max-w-[300px]",children:g})]}),i.jsxs("div",{className:"flex gap-x-1 items-center",children:[i.jsx("button",{type:"button",className:"p-2",onClick:()=>p(r||e,n),title:`Download ${g}`,children:i.jsx(F,{icon:"streamline-flex:download-tray-solid"})}),o&&i.jsx("button",{type:"button",className:"p-2 text-lg text-red-500",onClick:o,children:i.jsx(F,{icon:"lets-icons:trash-duotone"})})]}),s&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onClick:u,children:i.jsxs("div",{className:"relative bg-white p-8 rounded-lg w-full max-w-[90vw] max-h-[90vh] overflow-auto",onClick:h=>h.stopPropagation(),children:[i.jsx("button",{onClick:u,className:"absolute text-2xl font-bold text-gray-700 top-2 right-2","aria-label":"Close preview",children:"×"}),t==="image"?i.jsx("img",{src:e,alt:g,className:"max-w-full max-h-[80vh] mx-auto object-contain"}):t==="pdf"?i.jsx("iframe",{src:r||e,title:g,className:"w-full h-[80vh] rounded border"}):null]})})]})}const ue=e=>{const n=typeof window!="undefined"?localStorage.getItem(e):"";try{return JSON.parse(n)}catch(o){return n}},rn=(e,n)=>{const o=typeof n!="string"?JSON.stringify(n):n;return localStorage.setItem(e,o)},Wo=5*1024*1024;function Jo({onFileLoaded:e,disabled:n=!1,handleDeleteFile:o,multiple:s=!1,list:a=null,accept:t=[]}){const{uploadUrl:l}=b.useContext(le),r=b.useRef(null),[d,c]=b.useState(a),[u,g]=b.useState(!1);b.useEffect(()=>{c(a)},[a]);const p=b.useMemo(()=>t==null?void 0:t.map(S=>S.value).join(", "),[t]),h=b.useMemo(()=>t==null?void 0:t.map(S=>S.label).join(", "),[t]),y=b.useCallback(async S=>{var _;const A=ue("token");try{const{data:j}=await je.post(l,S,{headers:{Authorization:`Bearer ${A}`}});return(_=j==null?void 0:j.data)==null?void 0:_.url}catch(j){throw console.error("File upload error:",j),new Error("Failed to upload file to server")}},[l]),f=b.useCallback(S=>new Promise((A,_)=>{const j=new FileReader;j.onloadend=async()=>{try{const L=j.result.replace(/^data:.*;base64,/,""),Q=l?await y({base64:L,ext:`.${S.name.split(".").pop()}`,fileName:S.name}):j.result;A({base64:Q,type:S.type,name:S.name})}catch(L){_(L)}},j.onerror=()=>_(new Error("File read failed")),j.readAsDataURL(S)}),[l,y]),m=b.useCallback(S=>{var _;const A=p?(_=p.split(","))==null?void 0:_.map(j=>j.trim()):[];for(const j of S){if(j.size>Wo)return me.toast.error(`File "${j.name}" exceeds 5MB limit (${(j.size/1024/1024).toFixed(2)}MB)`),!1;if(A.length&&!A.some(L=>j.type===L||j.name.toLowerCase().endsWith(L.replace("*",""))))return me.toast.error(`File "${j.name}" is not an allowed type. Allowed: ${h||"any"}`),!1}return!0},[p,h]),x=b.useCallback(async S=>{const A=Array.from(S.target.files||[]);if(!(!A.length||u)){if(!m(A)){r.current&&(r.current.value="");return}try{g(!0);const _=await Promise.all(A==null?void 0:A.map(f));c(j=>{const L=s&&j?[...j,..._]:_;return e(L),L}),me.toast.success(`Successfully uploaded ${A.length} file(s)`)}catch(_){console.error("Upload error:",_),me.toast.error("Failed to upload file(s). Please try again.")}finally{g(!1),r.current&&(r.current.value="")}}},[u,m,f,e,s]),w=b.useCallback(S=>{u||(r.current&&(r.current.value=""),c(A=>{const _=S===void 0?null:(A==null?void 0:A.filter((j,L)=>L!==S))||null;return e(_),_}),o==null||o())},[o,e,u]),k=d&&d.length>0;return i.jsxs("div",{className:"flex flex-col items-start gap-2",children:[!n&&i.jsxs("div",{className:"!flex field-control !py-0 !px-0 relative",children:[i.jsx("input",{ref:r,type:"file",onChange:x,disabled:n||u,multiple:s,accept:p||"",className:`w-full text-sm text-gray-500 file:mr-4 flex-1 file:px-4 !py-1 !pl-1\r
|
|
31
|
+
<%s key={someKey} {...props} />`,Si,Ne,Gs,Ne),En[Ne+Si]=!0}}return v===s?Ps(ae):Ls(ae),ae}}function Os(v,N,C){return Bn(v,N,C,!0)}function Is(v,N,C){return Bn(v,N,C,!1)}var Ds=Is,Ks=Os;Le.Fragment=s,Le.jsx=Ds,Le.jsxs=Ks}()),Le}var Bi;function Rn(){return Bi||(Bi=1,process.env.NODE_ENV==="production"?Re.exports=Kn():Re.exports=Gn()),Re.exports}var i=Rn();const le=b.createContext(void 0),Li={title:"",description:"",id:be.v4(),questionData:[],disabled:!1},Pi=({children:e})=>{const[n,o]=b.useState({}),[s,a]=b.useState({}),[t,l]=b.useState([Li]),[r,d]=b.useState(!1),[c,u]=b.useState(null),[g,p]=b.useState([0]),[h,y]=b.useState(""),f=b.useCallback(()=>{},[]),m=b.useCallback(()=>{const D=be.v4();l(M=>[...M,{...Li,id:D}]),u(D),p([t.length])},[t]),x=b.useCallback(D=>{l(M=>M.filter(T=>T.id!==D)),u(null)},[]),w=b.useCallback((D,M)=>{const T=t.find(I=>I.id===M),B=T==null?void 0:T.questionData.find(I=>I.id===D);B&&l(I=>I==null?void 0:I.map(Y=>Y.id===M?{...Y,questionData:Y.questionData.filter(J=>B.type==="grid"?J.gridId!==B.id&&J.id!==B.id:J.id!==D)}:Y))},[t,l]),k=b.useCallback((D,M)=>{const T=t.find(J=>J.id===M);if(!T)return;const B=T.questionData.findIndex(J=>J.id===D);if(B===-1)return;const I=T.questionData[B],Y=(J,oe={})=>({...JSON.parse(JSON.stringify(J)),id:be.v4(),...oe});l(J=>J==null?void 0:J.map(oe=>{var se;if(oe.id!==M)return oe;const O=[...oe.questionData];if(I.type==="grid"){const ve=(se=O==null?void 0:O.map((Z,de)=>({e:Z,i:de})).filter(({e:Z})=>Z.id===I.id||Z.gridId===I.id))==null?void 0:se.map(({i:Z})=>Z),pe=ve.length?Math.max(...ve)+1:B+1,fe=be.v4(),xe=Y(I,{});xe.id=fe;const R=O.filter(Z=>Z.gridId===I.id),z=R==null?void 0:R.map(Z=>Y(Z,{gridId:fe})),te=[...O.slice(0,pe),xe,...z,...O.slice(pe)];return{...oe,questionData:te}}else{const ve=Y(I,I.gridId?{gridId:I.gridId}:{}),pe=[...O.slice(0,B+1),ve,...O.slice(B+1)];return{...oe,questionData:pe}}}))},[t,l]),S=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>B.id===M?{...B,questionData:D}:B))},[]),A=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>B.id===M?{...B,questionData:[...B.questionData,D]}:B))},[]),_=b.useCallback((D,M,T)=>{l(B=>B==null?void 0:B.map(I=>I.id===M?{...I,questionData:[...I.questionData.slice(0,T),D,...I.questionData.slice(T)]}:I))},[]),j=b.useCallback((D,M,T)=>{l(B=>B==null?void 0:B.map(I=>{var Y;return I.id===T?{...I,questionData:(Y=I.questionData)==null?void 0:Y.map(J=>{var oe;return J.type==="grid"&&J.gridData?{...J,gridData:(oe=J.gridData)==null?void 0:oe.map((O,se)=>se===D?{...O,...M}:O).concat(D>=J.gridData.length?{...M}:[])}:J})}:I}))},[]),L=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>{var I;return B.id===M?{...B,questionData:(I=B.questionData)==null?void 0:I.map(Y=>Y.id===D.id?{...Y,...D}:Y)}:B}))},[]),Q=b.useCallback((D,M)=>{l(T=>T==null?void 0:T.map(B=>B.id===M?{...B,...D}:B))},[]),W=b.useMemo(()=>({formData:t,setFormData:l,handleDragStop:f,removeElement:w,elementData:s,setElementData:a,updateElementPosition:S,addElement:A,addElementInPosition:_,updateElement:L,addSection:m,removeSection:x,updateSection:Q,isDragging:r,setIsDragging:d,selectedSection:c,setSelectedSection:u,activeSections:g,setActiveSections:p,updateGridElement:j,answerData:n,setAnswerData:o,uploadUrl:h,setUploadUrl:y,duplicateElement:k}),[t,f,w,s,S,A,_,L,m,x,Q,r,c,g,j,n,h,k]);return i.jsx(le.Provider,{value:W,children:e})};function Oi(e){var n,o,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(n=0;n<a;n++)e[n]&&(o=Oi(e[n]))&&(s&&(s+=" "),s+=o)}else for(o in e)e[o]&&(s&&(s+=" "),s+=o);return s}function V(){for(var e,n,o=0,s="",a=arguments.length;o<a;o++)(e=arguments[o])&&(n=Oi(e))&&(s&&(s+=" "),s+=n);return s}function zn({type:e="calendar",className:n}){return i.jsx(i.Fragment,{children:e==="calendar"?i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[i.jsx("path",{d:"M6.66406 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M13.3359 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M2.91406 7.57495H17.0807",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M17.5 7.08341V14.1667C17.5 16.6667 16.25 18.3334 13.3333 18.3334H6.66667C3.75 18.3334 2.5 16.6667 2.5 14.1667V7.08341C2.5 4.58341 3.75 2.91675 6.66667 2.91675H13.3333C16.25 2.91675 17.5 4.58341 17.5 7.08341Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M13.0762 11.4167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M13.0762 13.9167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M9.99803 11.4167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M9.99803 13.9167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M6.91209 11.4167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M6.91209 13.9167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[i.jsx("path",{d:"M10 6.66663V10.8333",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M10.0026 18.3333C5.9776 18.3333 2.71094 15.0667 2.71094 11.0417C2.71094 7.01667 5.9776 3.75 10.0026 3.75C14.0276 3.75 17.2943 7.01667 17.2943 11.0417",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M7.5 1.66663H12.5",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M12.4141 15.4167V14.4501C12.4141 13.2584 13.2641 12.7667 14.2974 13.3667L15.1307 13.8501L15.9641 14.3334C16.9974 14.9334 16.9974 15.9084 15.9641 16.5084L15.1307 16.9917L14.2974 17.4751C13.2641 18.0751 12.4141 17.5834 12.4141 16.3917V15.4167Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const Qe=({value:e=null,onGetValue:n,readOnly:o=!1,dateFormat:s="dd/MM/yyyy",name:a,placeholder:t="Select date",minDate:l,maxDate:r,showYearDropdown:d})=>{const c=e?new Date(e):null,[u,g]=b.useState(c);b.useEffect(()=>{const h=e?new Date(e):null;(h&&u&&h.getTime()!==u.getTime()||!h&&u||h&&!u)&&g(h)},[e]),b.useEffect(()=>{n&&n(a,u)},[u,n,a]);const p=h=>{g(h)};return i.jsx("div",{className:"builder_date__picker",children:i.jsx(Ln,{showIcon:!0,icon:i.jsx(zn,{className:"react-datepicker__calendar-icon"}),showPopperArrow:!1,dateFormat:s,disabled:o,selected:u,onChange:p,className:"field-control",portalId:"root-portal",placeholderText:t,minDate:l,maxDate:r,showYearDropdown:d,scrollableYearDropdown:!0,yearDropdownItemNumber:40})})};function Hn({element:e,validationData:n}){const{register:o=()=>({}),setValue:s,watch:a}=n||{};let t;return a&&(t=a()[e.id]),b.useEffect(()=>{o(e.id)},[e.id]),i.jsx(Qe,{name:e.id,value:t,onGetValue:s,readOnly:n==null?void 0:n.isReadOnly,dateFormat:(e==null?void 0:e.dateFormat)||"dd/MM/yyyy",minDate:e==null?void 0:e.minDate,maxDate:e==null?void 0:e.maxDate,showYearDropdown:e==null?void 0:e.allowYearPicker})}function Xe({element:e,validationData:n}){var s;const{register:o=()=>({})}=n||{};return i.jsx("div",{children:i.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"",type:(e==null?void 0:e.inputType)||"text",className:V("field-control",e==null?void 0:e.customClass),...o(e==null?void 0:e.id),disabled:n==null?void 0:n.isReadOnly,inputMode:(e==null?void 0:e.inputMode)||void 0,"aria-invalid":!!((s=n==null?void 0:n.errors)!=null&&s[e==null?void 0:e.id]),pattern:(e==null?void 0:e.pattern)||void 0})})}function Fn(e,n){const o=e.icons,s=e.aliases||Object.create(null),a=Object.create(null);function t(l){if(o[l])return a[l]=[];if(!(l in a)){a[l]=null;const r=s[l]&&s[l].parent,d=r&&t(r);d&&(a[l]=[r].concat(d))}return a[l]}return Object.keys(o).concat(Object.keys(s)).forEach(t),a}const Ii=Object.freeze({left:0,top:0,width:16,height:16}),ze=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),ei=Object.freeze({...Ii,...ze}),ii=Object.freeze({...ei,body:"",hidden:!1});function Vn(e,n){const o={};!e.hFlip!=!n.hFlip&&(o.hFlip=!0),!e.vFlip!=!n.vFlip&&(o.vFlip=!0);const s=((e.rotate||0)+(n.rotate||0))%4;return s&&(o.rotate=s),o}function Di(e,n){const o=Vn(e,n);for(const s in ii)s in ze?s in e&&!(s in o)&&(o[s]=ze[s]):s in n?o[s]=n[s]:s in e&&(o[s]=e[s]);return o}function Un(e,n,o){const s=e.icons,a=e.aliases||Object.create(null);let t={};function l(r){t=Di(s[r]||a[r],t)}return l(n),o.forEach(l),Di(e,t)}function Ki(e,n){const o=[];if(typeof e!="object"||typeof e.icons!="object")return o;e.not_found instanceof Array&&e.not_found.forEach(a=>{n(a,null),o.push(a)});const s=Fn(e);for(const a in s){const t=s[a];t&&(n(a,Un(e,a,t)),o.push(a))}return o}const Wn={provider:"",aliases:{},not_found:{},...Ii};function ni(e,n){for(const o in n)if(o in e&&typeof e[o]!=typeof n[o])return!1;return!0}function Gi(e){if(typeof e!="object"||e===null)return null;const n=e;if(typeof n.prefix!="string"||!e.icons||typeof e.icons!="object"||!ni(e,Wn))return null;const o=n.icons;for(const a in o){const t=o[a];if(!a||typeof t.body!="string"||!ni(t,ii))return null}const s=n.aliases||Object.create(null);for(const a in s){const t=s[a],l=t.parent;if(!a||typeof l!="string"||!o[l]&&!s[l]||!ni(t,ii))return null}return n}const Ri=Object.create(null);function Jn(e,n){return{provider:e,prefix:n,icons:Object.create(null),missing:new Set}}function Ce(e,n){const o=Ri[e]||(Ri[e]=Object.create(null));return o[n]||(o[n]=Jn(e,n))}function zi(e,n){return Gi(n)?Ki(n,(o,s)=>{s?e.icons[o]=s:e.missing.add(o)}):[]}function qn(e,n,o){try{if(typeof o.body=="string")return e.icons[n]={...o},!0}catch(s){}return!1}const Hi=/^[a-z0-9]+(-[a-z0-9]+)*$/,He=(e,n,o,s="")=>{const a=e.split(":");if(e.slice(0,1)==="@"){if(a.length<2||a.length>3)return null;s=a.shift().slice(1)}if(a.length>3||!a.length)return null;if(a.length>1){const r=a.pop(),d=a.pop(),c={provider:a.length>0?a[0]:s,prefix:d,name:r};return n&&!Fe(c)?null:c}const t=a[0],l=t.split("-");if(l.length>1){const r={provider:s,prefix:l.shift(),name:l.join("-")};return n&&!Fe(r)?null:r}if(o&&s===""){const r={provider:s,prefix:"",name:t};return n&&!Fe(r,o)?null:r}return null},Fe=(e,n)=>e?!!((n&&e.prefix===""||e.prefix)&&e.name):!1;let Pe=!1;function Fi(e){return typeof e=="boolean"&&(Pe=e),Pe}function Vi(e){const n=typeof e=="string"?He(e,!0,Pe):e;if(n){const o=Ce(n.provider,n.prefix),s=n.name;return o.icons[s]||(o.missing.has(s)?null:void 0)}}function Yn(e,n){const o=He(e,!0,Pe);if(!o)return!1;const s=Ce(o.provider,o.prefix);return n?qn(s,o.name,n):(s.missing.add(o.name),!0)}function Zn(e,n){if(typeof e!="object")return!1;if(typeof n!="string"&&(n=e.provider||""),Pe&&!n&&!e.prefix){let a=!1;return Gi(e)&&(e.prefix="",Ki(e,(t,l)=>{Yn(t,l)&&(a=!0)})),a}const o=e.prefix;if(!Fe({prefix:o,name:"a"}))return!1;const s=Ce(n,o);return!!zi(s,e)}const Ui=Object.freeze({width:null,height:null}),Wi=Object.freeze({...Ui,...ze}),$n=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Qn=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Ji(e,n,o){if(n===1)return e;if(o=o||100,typeof e=="number")return Math.ceil(e*n*o)/o;if(typeof e!="string")return e;const s=e.split($n);if(s===null||!s.length)return e;const a=[];let t=s.shift(),l=Qn.test(t);for(;;){if(l){const r=parseFloat(t);isNaN(r)?a.push(t):a.push(Math.ceil(r*n*o)/o)}else a.push(t);if(t=s.shift(),t===void 0)return a.join("");l=!l}}function Xn(e,n="defs"){let o="";const s=e.indexOf("<"+n);for(;s>=0;){const a=e.indexOf(">",s),t=e.indexOf("</"+n);if(a===-1||t===-1)break;const l=e.indexOf(">",t);if(l===-1)break;o+=e.slice(a+1,t).trim(),e=e.slice(0,s).trim()+e.slice(l+1)}return{defs:o,content:e}}function eo(e,n){return e?"<defs>"+e+"</defs>"+n:n}function io(e,n,o){const s=Xn(e);return eo(s.defs,n+s.content+o)}const no=e=>e==="unset"||e==="undefined"||e==="none";function oo(e,n){const o={...ei,...e},s={...Wi,...n},a={left:o.left,top:o.top,width:o.width,height:o.height};let t=o.body;[o,s].forEach(f=>{const m=[],x=f.hFlip,w=f.vFlip;let k=f.rotate;x?w?k+=2:(m.push("translate("+(a.width+a.left).toString()+" "+(0-a.top).toString()+")"),m.push("scale(-1 1)"),a.top=a.left=0):w&&(m.push("translate("+(0-a.left).toString()+" "+(a.height+a.top).toString()+")"),m.push("scale(1 -1)"),a.top=a.left=0);let S;switch(k<0&&(k-=Math.floor(k/4)*4),k=k%4,k){case 1:S=a.height/2+a.top,m.unshift("rotate(90 "+S.toString()+" "+S.toString()+")");break;case 2:m.unshift("rotate(180 "+(a.width/2+a.left).toString()+" "+(a.height/2+a.top).toString()+")");break;case 3:S=a.width/2+a.left,m.unshift("rotate(-90 "+S.toString()+" "+S.toString()+")");break}k%2===1&&(a.left!==a.top&&(S=a.left,a.left=a.top,a.top=S),a.width!==a.height&&(S=a.width,a.width=a.height,a.height=S)),m.length&&(t=io(t,'<g transform="'+m.join(" ")+'">',"</g>"))});const l=s.width,r=s.height,d=a.width,c=a.height;let u,g;l===null?(g=r===null?"1em":r==="auto"?c:r,u=Ji(g,d/c)):(u=l==="auto"?d:l,g=r===null?Ji(u,c/d):r==="auto"?c:r);const p={},h=(f,m)=>{no(m)||(p[f]=m.toString())};h("width",u),h("height",g);const y=[a.left,a.top,d,c];return p.viewBox=y.join(" "),{attributes:p,viewBox:y,body:t}}const ao=/\sid="(\S+)"/g,so="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let to=0;function lo(e,n=so){const o=[];let s;for(;s=ao.exec(e);)o.push(s[1]);if(!o.length)return e;const a="suffix"+(Math.random()*16777216|Date.now()).toString(16);return o.forEach(t=>{const l=typeof n=="function"?n(t):n+(to++).toString(),r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+r+')([")]|\\.[a-z])',"g"),"$1"+l+a+"$3")}),e=e.replace(new RegExp(a,"g"),""),e}const oi=Object.create(null);function ro(e,n){oi[e]=n}function ai(e){return oi[e]||oi[""]}function si(e){let n;if(typeof e.resources=="string")n=[e.resources];else if(n=e.resources,!(n instanceof Array)||!n.length)return null;return{resources:n,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const ti=Object.create(null),Oe=["https://api.simplesvg.com","https://api.unisvg.com"],Ve=[];for(;Oe.length>0;)Oe.length===1||Math.random()>.5?Ve.push(Oe.shift()):Ve.push(Oe.pop());ti[""]=si({resources:["https://api.iconify.design"].concat(Ve)});function uo(e,n){const o=si(n);return o===null?!1:(ti[e]=o,!0)}function li(e){return ti[e]}let qi=(()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch(n){}})();function co(e,n){const o=li(e);if(!o)return 0;let s;if(!o.maxURL)s=0;else{let a=0;o.resources.forEach(l=>{a=Math.max(a,l.length)});const t=n+".json?icons=";s=o.maxURL-a-o.path.length-t.length}return s}function mo(e){return e===404}const bo=(e,n,o)=>{const s=[],a=co(e,n),t="icons";let l={type:t,provider:e,prefix:n,icons:[]},r=0;return o.forEach((d,c)=>{r+=d.length+1,r>=a&&c>0&&(s.push(l),l={type:t,provider:e,prefix:n,icons:[]},r=d.length),l.icons.push(d)}),s.push(l),s};function vo(e){if(typeof e=="string"){const n=li(e);if(n)return n.path}return"/"}const po={prepare:bo,send:(e,n,o)=>{if(!qi){o("abort",424);return}let s=vo(n.provider);switch(n.type){case"icons":{const t=n.prefix,r=n.icons.join(","),d=new URLSearchParams({icons:r});s+=t+".json?"+d.toString();break}case"custom":{const t=n.uri;s+=t.slice(0,1)==="/"?t.slice(1):t;break}default:o("abort",400);return}let a=503;qi(e+s).then(t=>{const l=t.status;if(l!==200){setTimeout(()=>{o(mo(l)?"abort":"next",l)});return}return a=501,t.json()}).then(t=>{if(typeof t!="object"||t===null){setTimeout(()=>{t===404?o("abort",t):o("next",a)});return}setTimeout(()=>{o("success",t)})}).catch(()=>{o("next",a)})}};function Yi(e,n){e.forEach(o=>{const s=o.loaderCallbacks;s&&(o.loaderCallbacks=s.filter(a=>a.id!==n))})}function go(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const n=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!n.length)return;let o=!1;const s=e.provider,a=e.prefix;n.forEach(t=>{const l=t.icons,r=l.pending.length;l.pending=l.pending.filter(d=>{if(d.prefix!==a)return!0;const c=d.name;if(e.icons[c])l.loaded.push({provider:s,prefix:a,name:c});else if(e.missing.has(c))l.missing.push({provider:s,prefix:a,name:c});else return o=!0,!0;return!1}),l.pending.length!==r&&(o||Yi([e],t.id),t.callback(l.loaded.slice(0),l.missing.slice(0),l.pending.slice(0),t.abort))})}))}let ho=0;function fo(e,n,o){const s=ho++,a=Yi.bind(null,o,s);if(!n.pending.length)return a;const t={id:s,icons:n,callback:e,abort:a};return o.forEach(l=>{(l.loaderCallbacks||(l.loaderCallbacks=[])).push(t)}),a}function xo(e){const n={loaded:[],missing:[],pending:[]},o=Object.create(null);e.sort((a,t)=>a.provider!==t.provider?a.provider.localeCompare(t.provider):a.prefix!==t.prefix?a.prefix.localeCompare(t.prefix):a.name.localeCompare(t.name));let s={provider:"",prefix:"",name:""};return e.forEach(a=>{if(s.name===a.name&&s.prefix===a.prefix&&s.provider===a.provider)return;s=a;const t=a.provider,l=a.prefix,r=a.name,d=o[t]||(o[t]=Object.create(null)),c=d[l]||(d[l]=Ce(t,l));let u;r in c.icons?u=n.loaded:l===""||c.missing.has(r)?u=n.missing:u=n.pending;const g={provider:t,prefix:l,name:r};u.push(g)}),n}function yo(e,n=!0,o=!1){const s=[];return e.forEach(a=>{const t=typeof a=="string"?He(a,n,o):a;t&&s.push(t)}),s}const ko={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function wo(e,n,o,s){const a=e.resources.length,t=e.random?Math.floor(Math.random()*a):e.index;let l;if(e.random){let _=e.resources.slice(0);for(l=[];_.length>1;){const j=Math.floor(Math.random()*_.length);l.push(_[j]),_=_.slice(0,j).concat(_.slice(j+1))}l=l.concat(_)}else l=e.resources.slice(t).concat(e.resources.slice(0,t));const r=Date.now();let d="pending",c=0,u,g=null,p=[],h=[];typeof s=="function"&&h.push(s);function y(){g&&(clearTimeout(g),g=null)}function f(){d==="pending"&&(d="aborted"),y(),p.forEach(_=>{_.status==="pending"&&(_.status="aborted")}),p=[]}function m(_,j){j&&(h=[]),typeof _=="function"&&h.push(_)}function x(){return{startTime:r,payload:n,status:d,queriesSent:c,queriesPending:p.length,subscribe:m,abort:f}}function w(){d="failed",h.forEach(_=>{_(void 0,u)})}function k(){p.forEach(_=>{_.status==="pending"&&(_.status="aborted")}),p=[]}function S(_,j,L){const Q=j!=="success";switch(p=p.filter(W=>W!==_),d){case"pending":break;case"failed":if(Q||!e.dataAfterTimeout)return;break;default:return}if(j==="abort"){u=L,w();return}if(Q){u=L,p.length||(l.length?A():w());return}if(y(),k(),!e.random){const W=e.resources.indexOf(_.resource);W!==-1&&W!==e.index&&(e.index=W)}d="completed",h.forEach(W=>{W(L)})}function A(){if(d!=="pending")return;y();const _=l.shift();if(_===void 0){if(p.length){g=setTimeout(()=>{y(),d==="pending"&&(k(),w())},e.timeout);return}w();return}const j={status:"pending",resource:_,callback:(L,Q)=>{S(j,L,Q)}};p.push(j),c++,g=setTimeout(A,e.rotate),o(_,n,j.callback)}return setTimeout(A),x}function Zi(e){const n={...ko,...e};let o=[];function s(){o=o.filter(r=>r().status==="pending")}function a(r,d,c){const u=wo(n,r,d,(g,p)=>{s(),c&&c(g,p)});return o.push(u),u}function t(r){return o.find(d=>r(d))||null}return{query:a,find:t,setIndex:r=>{n.index=r},getIndex:()=>n.index,cleanup:s}}function $i(){}const di=Object.create(null);function _o(e){if(!di[e]){const n=li(e);if(!n)return;const o=Zi(n),s={config:n,redundancy:o};di[e]=s}return di[e]}function Ao(e,n,o){let s,a;if(typeof e=="string"){const t=ai(e);if(!t)return o(void 0,424),$i;a=t.send;const l=_o(e);l&&(s=l.redundancy)}else{const t=si(e);if(t){s=Zi(t);const l=e.resources?e.resources[0]:"",r=ai(l);r&&(a=r.send)}}return!s||!a?(o(void 0,424),$i):s.query(n,a,o)().abort}function Qi(){}function So(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,go(e)}))}function No(e){const n=[],o=[];return e.forEach(s=>{(s.match(Hi)?n:o).push(s)}),{valid:n,invalid:o}}function Ie(e,n,o){function s(){const a=e.pendingIcons;n.forEach(t=>{a&&a.delete(t),e.icons[t]||e.missing.add(t)})}if(o&&typeof o=="object")try{if(!zi(e,o).length){s();return}}catch(a){console.error(a)}s(),So(e)}function Xi(e,n){e instanceof Promise?e.then(o=>{n(o)}).catch(()=>{n(null)}):n(e)}function jo(e,n){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(n).sort():e.iconsToLoad=n,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:o,prefix:s}=e,a=e.iconsToLoad;if(delete e.iconsToLoad,!a||!a.length)return;const t=e.loadIcon;if(e.loadIcons&&(a.length>1||!t)){Xi(e.loadIcons(a,s,o),u=>{Ie(e,a,u)});return}if(t){a.forEach(u=>{const g=t(u,s,o);Xi(g,p=>{const h=p?{prefix:s,icons:{[u]:p}}:null;Ie(e,[u],h)})});return}const{valid:l,invalid:r}=No(a);if(r.length&&Ie(e,r,null),!l.length)return;const d=s.match(Hi)?ai(o):null;if(!d){Ie(e,l,null);return}d.prepare(o,s,l).forEach(u=>{Ao(o,u,g=>{Ie(e,u.icons,g)})})}))}const Co=(e,n)=>{const o=yo(e,!0,Fi()),s=xo(o);if(!s.pending.length){let d=!0;return n&&setTimeout(()=>{d&&n(s.loaded,s.missing,s.pending,Qi)}),()=>{d=!1}}const a=Object.create(null),t=[];let l,r;return s.pending.forEach(d=>{const{provider:c,prefix:u}=d;if(u===r&&c===l)return;l=c,r=u,t.push(Ce(c,u));const g=a[c]||(a[c]=Object.create(null));g[u]||(g[u]=[])}),s.pending.forEach(d=>{const{provider:c,prefix:u,name:g}=d,p=Ce(c,u),h=p.pendingIcons||(p.pendingIcons=new Set);h.has(g)||(h.add(g),a[c][u].push(g))}),t.forEach(d=>{const c=a[d.provider][d.prefix];c.length&&jo(d,c)}),n?fo(n,s,t):Qi};function Mo(e,n){const o={...e};for(const s in n){const a=n[s],t=typeof a;s in Ui?(a===null||a&&(t==="string"||t==="number"))&&(o[s]=a):t===typeof o[s]&&(o[s]=s==="rotate"?a%4:a)}return o}const To=/[\s,]+/;function Eo(e,n){n.split(To).forEach(o=>{switch(o.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function Bo(e,n=0){const o=e.replace(/^-?[0-9.]*/,"");function s(a){for(;a<0;)a+=4;return a%4}if(o===""){const a=parseInt(e);return isNaN(a)?0:s(a)}else if(o!==e){let a=0;switch(o){case"%":a=25;break;case"deg":a=90}if(a){let t=parseFloat(e.slice(0,e.length-o.length));return isNaN(t)?0:(t=t/a,t%1===0?s(t):0)}}return n}function Lo(e,n){let o=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const s in n)o+=" "+s+'="'+n[s]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+o+">"+e+"</svg>"}function Po(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Oo(e){return"data:image/svg+xml,"+Po(e)}function Io(e){return'url("'+Oo(e)+'")'}let De;function Do(){try{De=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch(e){De=null}}function Ko(e){return De===void 0&&Do(),De?De.createHTML(e):e}const en={...Wi,inline:!1},Go={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},Ro={display:"inline-block"},ri={backgroundColor:"currentColor"},nn={backgroundColor:"transparent"},on={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},an={WebkitMask:ri,mask:ri,background:nn};for(const e in an){const n=an[e];for(const o in on)n[e+o]=on[o]}const zo={...en,inline:!0};function sn(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const Ho=(e,n,o)=>{const s=n.inline?zo:en,a=Mo(s,n),t=n.mode||"svg",l={},r=n.style||{},d={...t==="svg"?Go:{}};if(o){const m=He(o,!1,!0);if(m){const x=["iconify"],w=["provider","prefix"];for(const k of w)m[k]&&x.push("iconify--"+m[k]);d.className=x.join(" ")}}for(let m in n){const x=n[m];if(x!==void 0)switch(m){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":d.ref=x;break;case"className":d[m]=(d[m]?d[m]+" ":"")+x;break;case"inline":case"hFlip":case"vFlip":a[m]=x===!0||x==="true"||x===1;break;case"flip":typeof x=="string"&&Eo(a,x);break;case"color":l.color=x;break;case"rotate":typeof x=="string"?a[m]=Bo(x):typeof x=="number"&&(a[m]=x);break;case"ariaHidden":case"aria-hidden":x!==!0&&x!=="true"&&delete d["aria-hidden"];break;default:s[m]===void 0&&(d[m]=x)}}const c=oo(e,a),u=c.attributes;if(a.inline&&(l.verticalAlign="-0.125em"),t==="svg"){d.style={...l,...r},Object.assign(d,u);let m=0,x=n.id;return typeof x=="string"&&(x=x.replace(/-/g,"_")),d.dangerouslySetInnerHTML={__html:Ko(lo(c.body,x?()=>x+"ID"+m++:"iconifyReact"))},b.createElement("svg",d)}const{body:g,width:p,height:h}=e,y=t==="mask"||(t==="bg"?!1:g.indexOf("currentColor")!==-1),f=Lo(g,{...u,width:p+"",height:h+""});return d.style={...l,"--svg":Io(f),width:sn(u.width),height:sn(u.height),...Ro,...y?ri:nn,...r},b.createElement("span",d)};if(Fi(!0),ro("",po),typeof document!="undefined"&&typeof window!="undefined"){const e=window;if(e.IconifyPreload!==void 0){const n=e.IconifyPreload,o="Invalid IconifyPreload syntax.";typeof n=="object"&&n!==null&&(n instanceof Array?n:[n]).forEach(s=>{try{(typeof s!="object"||s===null||s instanceof Array||typeof s.icons!="object"||typeof s.prefix!="string"||!Zn(s))&&console.error(o)}catch(a){console.error(o)}})}if(e.IconifyProviders!==void 0){const n=e.IconifyProviders;if(typeof n=="object"&&n!==null)for(let o in n){const s="IconifyProviders["+o+"] is invalid.";try{const a=n[o];if(typeof a!="object"||!a||a.resources===void 0)continue;uo(o,a)||console.error(s)}catch(a){console.error(s)}}}}function tn(e){const[n,o]=b.useState(!!e.ssr),[s,a]=b.useState({});function t(h){if(h){const y=e.icon;if(typeof y=="object")return{name:"",data:y};const f=Vi(y);if(f)return{name:y,data:f}}return{name:""}}const[l,r]=b.useState(t(!!e.ssr));function d(){const h=s.callback;h&&(h(),a({}))}function c(h){if(JSON.stringify(l)!==JSON.stringify(h))return d(),r(h),!0}function u(){var h;const y=e.icon;if(typeof y=="object"){c({name:"",data:y});return}const f=Vi(y);if(c({name:y,data:f}))if(f===void 0){const m=Co([y],u);a({callback:m})}else f&&((h=e.onLoad)===null||h===void 0||h.call(e,y))}b.useEffect(()=>(o(!0),d),[]),b.useEffect(()=>{n&&u()},[e.icon,n]);const{name:g,data:p}=l;return p?Ho({...ei,...p},e,g):e.children?e.children:e.fallback?e.fallback:b.createElement("span",{})}const ln=b.forwardRef((e,n)=>tn({...e,_ref:n}));b.forwardRef((e,n)=>tn({inline:!0,...e,_ref:n}));function F({icon:e,iconClass:n}){return i.jsx(i.Fragment,{children:i.jsx(ln,{icon:e,className:n})})}function ui({element:e,validationData:n,placeholder:o}){var u;const[s,a]=b.useState([]),{register:t=()=>({}),setValue:l,isReadOnly:r,watch:d}=n||{},c=b.useMemo(()=>s==null?void 0:s.map(g=>g.label).join(", "),[s]);return b.useEffect(()=>{t(e.id)},[e.id,t]),b.useEffect(()=>{if(d){const g=d(p=>{a(p[e.id])});return()=>{var p;return(p=g.unsubscribe)==null?void 0:p.call(g)}}},[d,e.id]),i.jsx("div",{className:"custom-select",children:i.jsx(K.Listbox,{value:s||[],onChange:g=>{a(g),l==null||l(e.id,g)},multiple:!0,disabled:r,by:"value",children:i.jsxs("div",{className:"custom-select__wrapper",children:[i.jsxs(K.Listbox.Button,{className:"custom-select__control field-control",disabled:r,children:[i.jsx("span",{className:"custom-select__value",children:(s==null?void 0:s.length)>0?c:i.jsx("span",{className:"custom-select__placeholder",children:o!=null?o:" Select options"})}),i.jsx("span",{className:"custom-select__icon",children:i.jsx(F,{icon:"lucide:chevron-down"})})]}),i.jsx(K.Transition,{as:b.Fragment,leave:"custom-select__transition",children:i.jsx(K.Listbox.Options,{anchor:"bottom start",className:"custom-select__options",children:(u=e==null?void 0:e.options)==null?void 0:u.map((g,p)=>i.jsx(K.Listbox.Option,{value:g,className:({active:h})=>`custom-select__option ${h?"custom-select__option--active":""}`,children:({selected:h})=>i.jsxs("div",{className:"custom-select__option-row",children:[i.jsx("span",{className:`custom-select__option-label ${h?"custom-select__option--selected":""}`,children:g.label}),h&&i.jsx("span",{className:"custom-select__check",children:"✓"})]})},p))})})]})})})}const Fo=["jpg","jpeg","png","gif","bmp","webp","svg","image"],Vo=(e="")=>{var o;const n=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return Fo.includes(n)||e.startsWith("data:image/")?"image":n==="pdf"||e.startsWith("data:application/pdf")?"pdf":["doc","docx"].includes(n)?"word":["xls","xlsx","csv"].includes(n)?"excel":["ppt","pptx"].includes(n)?"powerpoint":"other"},Uo={pdf:"vscode-icons:file-type-pdf2",word:"vscode-icons:file-type-word",excel:"vscode-icons:file-type-excel",powerpoint:"vscode-icons:file-type-powerpoint2"};function dn({fileUrl:e,fileName:n,removeFile:o}){const[s,a]=b.useState(!1),[t,l]=b.useState("unknown"),[r,d]=b.useState(null);b.useEffect(()=>{e&&l(Vo(e))},[e]),b.useEffect(()=>{if(t==="pdf"&&(e!=null&&e.startsWith("data:")))try{const h=atob(e.split(",")[1]),y=new ArrayBuffer(h.length),f=new Uint8Array(y);for(let w=0;w<h.length;w++)f[w]=h.charCodeAt(w);const m=new Blob([y],{type:"application/pdf"}),x=URL.createObjectURL(m);return d(x),()=>URL.revokeObjectURL(x)}catch(h){console.error("Error creating blob URL:",h)}else d(null)},[e,t]);const c=()=>{t==="image"||t==="pdf"?a(!0):window.open(r||e,"_blank")},u=()=>a(!1),g=n||(e==null?void 0:e.split("/").pop())||"Unknown file";function p(h,y="download"){if(!h)return;if(h.startsWith("data:")){const m=document.createElement("a");m.href=h,m.download=y,document.body.appendChild(m),m.click(),document.body.removeChild(m);return}const f=document.createElement("a");f.href=h,f.setAttribute("download",y),document.body.appendChild(f),f.click(),document.body.removeChild(f)}return i.jsxs("div",{className:"mt-2 field-control !py-1 !bg-gray-50 !flex justify-between gap-x-8 items-center",children:[i.jsxs("div",{onClick:c,className:"!flex items-center rounded cursor-pointer gap-x-3",title:`Click to preview ${g}`,children:[t==="image"&&i.jsx("div",{className:"flex items-center justify-center ",children:i.jsx(F,{iconClass:"text-4xl",icon:"fluent-color:image-48"})}),t!=="image"&&i.jsx(F,{icon:Uo[t],iconClass:"text-4xl"}),i.jsx("span",{className:"text-sm font-semibold text-center text-gray-700 truncate max-w-[300px]",children:g})]}),i.jsxs("div",{className:"flex gap-x-1 items-center",children:[i.jsx("button",{type:"button",className:"p-2",onClick:()=>p(r||e,n),title:`Download ${g}`,children:i.jsx(F,{icon:"streamline-flex:download-tray-solid"})}),o&&i.jsx("button",{type:"button",className:"p-2 text-lg text-red-500",onClick:o,children:i.jsx(F,{icon:"lets-icons:trash-duotone"})})]}),s&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onClick:u,children:i.jsxs("div",{className:"relative bg-white p-8 rounded-lg w-full max-w-[90vw] max-h-[90vh] overflow-auto",onClick:h=>h.stopPropagation(),children:[i.jsx("button",{onClick:u,className:"absolute text-2xl font-bold text-gray-700 top-2 right-2","aria-label":"Close preview",children:"×"}),t==="image"?i.jsx("img",{src:e,alt:g,className:"max-w-full max-h-[80vh] mx-auto object-contain"}):t==="pdf"?i.jsx("iframe",{src:r||e,title:g,className:"w-full h-[80vh] rounded border"}):null]})})]})}const ue=e=>{const n=typeof window!="undefined"?localStorage.getItem(e):"";try{return JSON.parse(n)}catch(o){return n}},rn=(e,n)=>{const o=typeof n!="string"?JSON.stringify(n):n;return localStorage.setItem(e,o)},Wo=5*1024*1024;function Jo({onFileLoaded:e,disabled:n=!1,handleDeleteFile:o,multiple:s=!1,list:a=null,accept:t=[]}){const{uploadUrl:l}=b.useContext(le),r=b.useRef(null),[d,c]=b.useState(a),[u,g]=b.useState(!1);b.useEffect(()=>{c(a)},[a]);const p=b.useMemo(()=>t==null?void 0:t.map(S=>S.value).join(", "),[t]),h=b.useMemo(()=>t==null?void 0:t.map(S=>S.label).join(", "),[t]),y=b.useCallback(async S=>{var _;const A=ue("token");try{const{data:j}=await je.post(l,S,{headers:{Authorization:`Bearer ${A}`}});return(_=j==null?void 0:j.data)==null?void 0:_.url}catch(j){throw console.error("File upload error:",j),new Error("Failed to upload file to server")}},[l]),f=b.useCallback(S=>new Promise((A,_)=>{const j=new FileReader;j.onloadend=async()=>{try{const L=j.result.replace(/^data:.*;base64,/,""),Q=l?await y({base64:L,ext:`.${S.name.split(".").pop()}`,fileName:S.name}):j.result;A({base64:Q,type:S.type,name:S.name})}catch(L){_(L)}},j.onerror=()=>_(new Error("File read failed")),j.readAsDataURL(S)}),[l,y]),m=b.useCallback(S=>{var _;const A=p?(_=p.split(","))==null?void 0:_.map(j=>j.trim()):[];for(const j of S){if(j.size>Wo)return me.toast.error(`File "${j.name}" exceeds 5MB limit (${(j.size/1024/1024).toFixed(2)}MB)`),!1;if(A.length&&!A.some(L=>j.type===L||j.name.toLowerCase().endsWith(L.replace("*",""))))return me.toast.error(`File "${j.name}" is not an allowed type. Allowed: ${h||"any"}`),!1}return!0},[p,h]),x=b.useCallback(async S=>{const A=Array.from(S.target.files||[]);if(!(!A.length||u)){if(!m(A)){r.current&&(r.current.value="");return}try{g(!0);const _=await Promise.all(A==null?void 0:A.map(f));c(j=>{const L=s&&j?[...j,..._]:_;return e(L),L}),me.toast.success(`Successfully uploaded ${A.length} file(s)`)}catch(_){console.error("Upload error:",_),me.toast.error("Failed to upload file(s). Please try again.")}finally{g(!1),r.current&&(r.current.value="")}}},[u,m,f,e,s]),w=b.useCallback(S=>{u||(r.current&&(r.current.value=""),c(A=>{const _=S===void 0?null:(A==null?void 0:A.filter((j,L)=>L!==S))||null;return e(_),_}),o==null||o())},[o,e,u]),k=d&&d.length>0;return i.jsxs("div",{className:"flex flex-col items-start gap-2",children:[!n&&i.jsxs("div",{className:"!flex field-control !py-0 !px-0 relative",children:[i.jsx("input",{ref:r,type:"file",onChange:x,disabled:n||u,multiple:s,accept:p||"",className:`w-full text-sm text-gray-500 file:mr-4 flex-1 file:px-4 !py-1 !pl-1\r
|
|
32
32
|
file:rounded-[6px] file:py-[6px] file:border-0\r
|
|
33
33
|
file:text-sm file:font-semibold\r
|
|
34
34
|
file:bg-blue-50 file:text-blue-700\r
|
|
35
|
-
hover:file:bg-blue-100 disabled:opacity-50 disabled:cursor-not-allowed`}),k&&i.jsx("button",{type:"button",className:"p-2 text-lg text-red-500 hover:text-red-600 transition-colors disabled:opacity-50",onClick:()=>w(),disabled:u,"aria-label":"Remove all files",children:i.jsx(F,{icon:"lets-icons:trash-duotone"})})]}),k&&i.jsxs("div",{className:"relative grid gap-y-1 flex-1 w-full",children:[u&&i.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-white/60 rounded",children:i.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-600 font-medium",children:[i.jsx("span",{className:"animate-spin h-4 w-4 border-2 border-blue-500 border-t-transparent rounded-full"}),"Uploading..."]})}),typeof d=="object"&&(d==null?void 0:d.map((S,A)=>i.jsx(dn,{fileUrl:S.base64,fileName:S.name,removeFile:()=>w(A)},`${S.name}-${A}`)))]})]})}function qo({element:e,validationData:n}){var u;const[o,s]=b.useState((u=e==null?void 0:e.value)!=null?u:null),{register:a=()=>({}),setValue:t,isReadOnly:l,watch:r}=n||{};b.useEffect(()=>{a(e.id)},[e.id,a]),b.useEffect(()=>{if(r){const g=r(p=>{s(p[e.id])});return()=>{var p;return(p=g.unsubscribe)==null?void 0:p.call(g)}}},[r,e.id]);const d=b.useCallback(g=>{t==null||t(e.id,g),s(g)},[e.id,t]),c=()=>{t==null||t(e.id,null),s(null)};return i.jsxs("div",{children:[!l&&i.jsx(Jo,{onFileLoaded:d,disabled:l,multiple:e==null?void 0:e.isMultiple,handleDeleteFile:c,list:o,accept:e==null?void 0:e.acceptedFiles}),o&&l&&i.jsx("div",{className:"relative grid gap-y-1 flex-1 w-full",children:typeof o=="object"&&(o==null?void 0:o.map((g,p)=>i.jsx("div",{children:i.jsx(dn,{fileUrl:g.base64,fileName:g.name})},p)))})]})}function Yo({element:e,validationData:n}){const{register:o=()=>({})}=n||{};return i.jsx("input",{placeholder:e.placeholder,type:e.inputType,className:V("field-control",e==null?void 0:e.customClass),...o(e.id),disabled:n==null?void 0:n.isReadOnly})}const G=({label:e,name:n,register:o,errors:s,className:a,type:t="text",placeholder:l="",isFloating:r,setValue:d,value:c,trigger:u,prefix:g,disabled:p,watch:h})=>{var f,m,x,w;const y=o?{...o(n)}:{};if(t==="amount")return i.jsxs("div",{className:"space-y-1.5 relative",children:[i.jsx("label",{className:`block text-sm font-medium text-[#344054] font-onest ${r?"z-[40] absolute block text-[#667085] bg-white py-[2px] px-1 -top-[12px] left-3 ":"relative"}`,children:e}),i.jsx(Ge,{onValueChange:k=>{d(n,k),o&&o(n),u&&u(n)},placeholder:l,className:`field-control ${s!=null&&s[n]?"border-red-300":"border-[#D0D5DD]"}`,decimalsLimit:2,value:c,prefix:g,disabled:p}),(s==null?void 0:s[n])&&i.jsx("p",{className:"mt-1 text-sm text-red-600",children:(f=s[n])==null?void 0:f.message})]});if(["checkbox","radio"].includes(t)){const k=h==null?void 0:h(n);let S=!1;return k&&(t==="checkbox"?S=k==null?void 0:k.includes(c):S=k==c),i.jsxs("div",{className:"space-y-1",children:[i.jsxs("label",{className:"flex items-center gap-3 cursor-pointer select-none",children:[i.jsx("input",{...y,type:t,value:c,disabled:p,className:"peer sr-only"}),i.jsx("div",{className:`
|
|
35
|
+
hover:file:bg-blue-100 disabled:opacity-50 disabled:cursor-not-allowed`}),k&&i.jsx("button",{type:"button",className:"p-2 text-lg text-red-500 hover:text-red-600 transition-colors disabled:opacity-50",onClick:()=>w(),disabled:u,"aria-label":"Remove all files",children:i.jsx(F,{icon:"lets-icons:trash-duotone"})})]}),k&&i.jsxs("div",{className:"relative grid gap-y-1 flex-1 w-full",children:[u&&i.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-white/60 rounded",children:i.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-600 font-medium",children:[i.jsx("span",{className:"animate-spin h-4 w-4 border-2 border-blue-500 border-t-transparent rounded-full"}),"Uploading..."]})}),typeof d=="object"&&(d==null?void 0:d.map((S,A)=>i.jsx(dn,{fileUrl:S.base64,fileName:S.name,removeFile:()=>w(A)},`${S.name}-${A}`)))]})]})}function qo({element:e,validationData:n}){var u;const[o,s]=b.useState((u=e==null?void 0:e.value)!=null?u:null),{register:a=()=>({}),setValue:t,isReadOnly:l,watch:r}=n||{};b.useEffect(()=>{a(e.id)},[e.id,a]),b.useEffect(()=>{if(r){const g=r(p=>{s(p[e.id])});return()=>{var p;return(p=g.unsubscribe)==null?void 0:p.call(g)}}},[r,e.id]);const d=b.useCallback(g=>{t==null||t(e.id,g),s(g)},[e.id,t]),c=()=>{t==null||t(e.id,null),s(null)};return i.jsxs("div",{children:[!l&&i.jsx(Jo,{onFileLoaded:d,disabled:l,multiple:e==null?void 0:e.isMultiple,handleDeleteFile:c,list:o,accept:e==null?void 0:e.acceptedFiles}),o&&l&&i.jsx("div",{className:"relative grid gap-y-1 flex-1 w-full",children:typeof o=="object"&&(o==null?void 0:o.map((g,p)=>i.jsx("div",{children:i.jsx(dn,{fileUrl:g.base64,fileName:g.name})},p)))})]})}function Yo({element:e,validationData:n}){const{register:o=()=>({})}=n||{};return i.jsx("input",{placeholder:e.placeholder,type:e.inputType,className:V("field-control",e==null?void 0:e.customClass),...o(e.id),disabled:n==null?void 0:n.isReadOnly})}const G=({label:e,name:n,register:o,errors:s,className:a,type:t="text",placeholder:l="",isFloating:r,setValue:d,value:c,trigger:u,prefix:g,disabled:p,watch:h})=>{var f,m,x,w;const y=o?{...o(n)}:{};if(t==="amount")return i.jsxs("div",{className:"space-y-1.5 relative",children:[i.jsx("label",{className:`block text-sm font-medium text-[#344054] font-onest ${r?"z-[40] absolute block text-[#667085] bg-white py-[2px] px-1 -top-[12px] left-3 ":"relative"}`,children:e}),i.jsx(Ge,{onValueChange:k=>{d(n,k),o&&o(n),u&&u(n)},placeholder:l,className:`field-control ${s!=null&&s[n]?"border-red-300":"border-[#D0D5DD]"}`,decimalsLimit:2,value:c,prefix:g,disabled:p}),(s==null?void 0:s[n])&&i.jsx("p",{className:"mt-1 text-sm text-red-600",children:(f=s[n])==null?void 0:f.message})]});if(["checkbox","radio"].includes(t)){const k=(h==null?void 0:h(n))||null;let S=!1;return k&&(k!=null&&k.length&&t==="checkbox"?S=k==null?void 0:k.includes(c):S=k==c),i.jsxs("div",{className:"space-y-1",children:[i.jsxs("label",{className:"flex items-center gap-3 cursor-pointer select-none",children:[i.jsx("input",{...y,type:t,value:c||"",disabled:p,className:"peer sr-only"}),i.jsx("div",{className:`
|
|
36
36
|
w-[18px] h-[18px] flex items-center justify-center
|
|
37
37
|
border rounded-md transition-all duration-200
|
|
38
38
|
${s!=null&&s[n]?"border-red-300":"border-[#D0D5DD]"}
|