UNPKG

react-drag-form-builder-dilshad

Version:

A powerful React form builder with drag-and-drop functionality and rich field types

1,392 lines 838 kB
import * as Ne from "react"; import ue, { useState as de, useRef as Se, useEffect as ke, createRef as cm, useContext as kd, useLayoutEffect as um, useCallback as Me, forwardRef as Id, useImperativeHandle as dm, useMemo as hm } from "react"; import pm, { flushSync as _d } from "react-dom"; var tr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function Rd(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } var Ms = { exports: {} }, Ln = {}; /** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var fc; function fm() { if (fc) return Ln; fc = 1; var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment"); function r(n, s, i) { var o = null; if (i !== void 0 && (o = "" + i), s.key !== void 0 && (o = "" + s.key), "key" in s) { i = {}; for (var l in s) l !== "key" && (i[l] = s[l]); } else i = s; return s = i.ref, { $$typeof: e, type: n, key: o, ref: s !== void 0 ? s : null, props: i }; } return Ln.Fragment = t, Ln.jsx = r, Ln.jsxs = r, Ln; } var kn = {}; /** * @license React * react-jsx-runtime.development.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var mc; function mm() { return mc || (mc = 1, process.env.NODE_ENV !== "production" && function() { function e(S) { if (S == null) return null; if (typeof S == "function") return S.$$typeof === W ? null : S.displayName || S.name || null; if (typeof S == "string") return S; switch (S) { case b: return "Fragment"; case N: return "Profiler"; case x: return "StrictMode"; case L: return "Suspense"; case B: return "SuspenseList"; case ie: return "Activity"; } if (typeof S == "object") switch (typeof S.tag == "number" && console.error( "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue." ), S.$$typeof) { case g: return "Portal"; case D: return (S.displayName || "Context") + ".Provider"; case w: return (S._context.displayName || "Context") + ".Consumer"; case T: var z = S.render; return S = S.displayName, S || (S = z.displayName || z.name || "", S = S !== "" ? "ForwardRef(" + S + ")" : "ForwardRef"), S; case I: return z = S.displayName || null, z !== null ? z : e(S.type) || "Memo"; case H: z = S._payload, S = S._init; try { return e(S(z)); } catch { } } return null; } function t(S) { return "" + S; } function r(S) { try { t(S); var z = !1; } catch { z = !0; } if (z) { z = console; var G = z.error, Y = typeof Symbol == "function" && Symbol.toStringTag && S[Symbol.toStringTag] || S.constructor.name || "Object"; return G.call( z, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", Y ), t(S); } } function n(S) { if (S === b) return "<>"; if (typeof S == "object" && S !== null && S.$$typeof === H) return "<...>"; try { var z = e(S); return z ? "<" + z + ">" : "<...>"; } catch { return "<...>"; } } function s() { var S = v.A; return S === null ? null : S.getOwner(); } function i() { return Error("react-stack-top-frame"); } function o(S) { if (O.call(S, "key")) { var z = Object.getOwnPropertyDescriptor(S, "key").get; if (z && z.isReactWarning) return !1; } return S.key !== void 0; } function l(S, z) { function G() { k || (k = !0, console.error( "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", z )); } G.isReactWarning = !0, Object.defineProperty(S, "key", { get: G, configurable: !0 }); } function c() { var S = e(this.type); return C[S] || (C[S] = !0, console.error( "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release." )), S = this.props.ref, S !== void 0 ? S : null; } function u(S, z, G, Y, oe, J, me, be) { return G = J.ref, S = { $$typeof: m, type: S, key: z, props: J, _owner: oe }, (G !== void 0 ? G : null) !== null ? Object.defineProperty(S, "ref", { enumerable: !1, get: c }) : Object.defineProperty(S, "ref", { enumerable: !1, value: null }), S._store = {}, Object.defineProperty(S._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: 0 }), Object.defineProperty(S, "_debugInfo", { configurable: !1, enumerable: !1, writable: !0, value: null }), Object.defineProperty(S, "_debugStack", { configurable: !1, enumerable: !1, writable: !0, value: me }), Object.defineProperty(S, "_debugTask", { configurable: !1, enumerable: !1, writable: !0, value: be }), Object.freeze && (Object.freeze(S.props), Object.freeze(S)), S; } function p(S, z, G, Y, oe, J, me, be) { var re = z.children; if (re !== void 0) if (Y) if (j(re)) { for (Y = 0; Y < re.length; Y++) h(re[Y]); Object.freeze && Object.freeze(re); } else console.error( "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead." ); else h(re); if (O.call(z, "key")) { re = e(S); var P = Object.keys(z).filter(function(Z) { return Z !== "key"; }); Y = 0 < P.length ? "{key: someKey, " + P.join(": ..., ") + ": ...}" : "{key: someKey}", q[re + Y] || (P = 0 < P.length ? "{" + P.join(": ..., ") + ": ...}" : "{}", console.error( `A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`, Y, re, P, re ), q[re + Y] = !0); } if (re = null, G !== void 0 && (r(G), re = "" + G), o(z) && (r(z.key), re = "" + z.key), "key" in z) { G = {}; for (var _ in z) _ !== "key" && (G[_] = z[_]); } else G = z; return re && l( G, typeof S == "function" ? S.displayName || S.name || "Unknown" : S ), u( S, re, J, oe, s(), G, me, be ); } function h(S) { typeof S == "object" && S !== null && S.$$typeof === m && S._store && (S._store.validated = 1); } var d = ue, m = Symbol.for("react.transitional.element"), g = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), x = Symbol.for("react.strict_mode"), N = Symbol.for("react.profiler"), w = Symbol.for("react.consumer"), D = Symbol.for("react.context"), T = Symbol.for("react.forward_ref"), L = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), I = Symbol.for("react.memo"), H = Symbol.for("react.lazy"), ie = Symbol.for("react.activity"), W = Symbol.for("react.client.reference"), v = d.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, O = Object.prototype.hasOwnProperty, j = Array.isArray, V = console.createTask ? console.createTask : function() { return null; }; d = { "react-stack-bottom-frame": function(S) { return S(); } }; var k, C = {}, R = d["react-stack-bottom-frame"].bind( d, i )(), M = V(n(i)), q = {}; kn.Fragment = b, kn.jsx = function(S, z, G, Y, oe) { var J = 1e4 > v.recentlyCreatedOwnerStacks++; return p( S, z, G, !1, Y, oe, J ? Error("react-stack-top-frame") : R, J ? V(n(S)) : M ); }, kn.jsxs = function(S, z, G, Y, oe) { var J = 1e4 > v.recentlyCreatedOwnerStacks++; return p( S, z, G, !0, Y, oe, J ? Error("react-stack-top-frame") : R, J ? V(n(S)) : M ); }; }()), kn; } var gc; function gm() { return gc || (gc = 1, process.env.NODE_ENV === "production" ? Ms.exports = fm() : Ms.exports = mm()), Ms.exports; } var a = gm(); const bc = (e, t) => { let r = e.label, n = e.placeholder || (e.label ? `Enter ${e.label}` : ""); if (e.id === "dynamic-single-line") { const i = e.label, o = t.filter( (l) => l.type === "dynamic-single-line" && (l.label === i || l.label.startsWith(i + " ")) ); o.length > 0 && (r = `${i} ${o.length + 1}`, n = `Enter ${i} ${o.length + 1}`); } return { id: `${e.id}_${Date.now()}`, type: e.id, label: r, originalIcon: e.icon, color: e.color, values: {}, showLabel: !0, instruction: "", hoverText: "", placeholder: n, inputType: "text", visibility: !0, required: !1, subFields: bm(e.id), options: vm(e.id), minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1, selectedIcon: null, iconColor: e.color, allowedFileTypes: xm(e.id), maxFileSize: ym(e.id), multipleFiles: !1 }; }, bm = (e) => { switch (e) { case "name": return { firstName: { show: !0, label: "First Name", placeholder: "Enter first name", required: !1, order: 0 }, lastName: { show: !0, label: "Last Name", placeholder: "Enter last name", required: !1, order: 1 } }; case "address": return { street: { show: !0, label: "Street Address", placeholder: "Enter street address", required: !1, order: 0 }, city: { show: !0, label: "City", placeholder: "City", required: !1, order: 1 }, zip: { show: !0, label: "ZIP Code", placeholder: "ZIP", required: !1, order: 2 } }; case "table": return { columns: [ { id: 1, label: "Column 1" }, { id: 2, label: "Column 2" } ], rows: [ { id: 1, values: ["", ""] }, { id: 2, values: ["", ""] } ] }; default: return {}; } }, xm = (e) => { switch (e) { case "file-upload": return ["pdf", "doc", "docx", "txt", "rtf"]; case "image-upload": return ["jpg", "jpeg", "png", "gif", "webp"]; case "audio-video-upload": return ["mp3", "mp4", "wav", "avi", "mov"]; default: return []; } }, ym = (e) => { switch (e) { case "file-upload": return 10; // 10MB case "image-upload": return 10; // 10MB case "audio-video-upload": return 50; // 50MB default: return 10; } }, vm = (e) => { switch (e) { case "dropdown": case "radio": case "checkbox": return [ { id: 1, label: "Option 1", value: "option1" }, { id: 2, label: "Option 2", value: "option2" }, { id: 3, label: "Option 3", value: "option3" } ]; case "multiple-choice": return [ { id: 1, label: "Choice A", value: "choiceA" }, { id: 2, label: "Choice B", value: "choiceB" }, { id: 3, label: "Choice C", value: "choiceC" }, { id: 4, label: "Choice D", value: "choiceD" } ]; case "image-choices": return [ { id: 1, label: "Option 1", value: "option1", image: "" }, { id: 2, label: "Option 2", value: "option2", image: "" }, { id: 3, label: "Option 3", value: "option3", image: "" }, { id: 4, label: "Option 4", value: "option4", image: "" } ]; case "matrix-choice": return { rows: [ { id: 1, label: "Row 1" }, { id: 2, label: "Row 2" }, { id: 3, label: "Row 3" } ], columns: [ { id: 1, label: "Column 1" }, { id: 2, label: "Column 2" }, { id: 3, label: "Column 3" } ] }; default: return []; } }, Nm = () => ({ name: "Conference Registration Form", type: "registration", description: "Complete registration form for the upcoming conference with accommodation and travel details.", structure: [ // Guest Category Section { id: `radio_${Date.now()}_1`, type: "radio", label: "Are you accompanying a registered conference delegate?", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-green-600 font-bold text-lg", children: "?" }), color: "text-green-600", values: {}, showLabel: !0, instruction: "Please select one option", hoverText: "Choose if you are accompanying a delegate", placeholder: "", inputType: "text", visibility: !0, subFields: {}, options: [ { id: 1, label: "Yes", value: "yes" }, { id: 2, label: "No", value: "no" } ], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `radio_${Date.now()}_2`, type: "radio", label: "Are you an industry professional attending independently?", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-blue-600 font-bold text-lg", children: "🏢" }), color: "text-blue-600", values: {}, showLabel: !0, instruction: "", hoverText: "", placeholder: "", inputType: "text", visibility: !0, subFields: {}, options: [ { id: 1, label: "Yes", value: "yes" }, { id: 2, label: "No", value: "no" } ], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, // Personal Information { id: `dropdown_${Date.now()}_3`, type: "dropdown", label: "Title", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-purple-600 font-bold text-lg", children: "👤" }), color: "text-purple-600", values: {}, showLabel: !0, instruction: "", hoverText: "", placeholder: "Select your title", inputType: "text", visibility: !0, subFields: {}, options: [ { id: 1, label: "Prof.", value: "prof" }, { id: 2, label: "Dr.", value: "dr" }, { id: 3, label: "Er.", value: "er" }, { id: 4, label: "Mr.", value: "mr" }, { id: 5, label: "Mrs.", value: "mrs" }, { id: 6, label: "Miss", value: "miss" } ], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `name_${Date.now()}_4`, type: "name", label: "Full Name", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-blue-500 font-bold text-lg", children: "👤" }), color: "text-blue-500", values: {}, showLabel: !0, instruction: "Enter your first and last name as per official documents", hoverText: "This will appear on your certificate", placeholder: "", inputType: "text", visibility: !0, subFields: { firstName: { show: !0, label: "First Name", placeholder: "Enter first name", required: !0, order: 0 }, lastName: { show: !0, label: "Last Name", placeholder: "Enter last name", required: !0, order: 1 } }, options: [], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `radio_${Date.now()}_5`, type: "radio", label: "Gender", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-pink-600 font-bold text-lg", children: "⚧" }), color: "text-pink-600", values: {}, showLabel: !0, instruction: "", hoverText: "", placeholder: "", inputType: "text", visibility: !0, subFields: {}, options: [ { id: 1, label: "Male", value: "male" }, { id: 2, label: "Female", value: "female" }, { id: 3, label: "Transgender", value: "transgender" } ], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `phone_${Date.now()}_6`, type: "phone", label: "Contact Number (for correspondence)", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-purple-500 font-bold text-lg", children: "📞" }), color: "text-purple-500", values: {}, showLabel: !0, instruction: "Primary contact number for all correspondence", hoverText: "We'll use this for important updates", placeholder: "+91 98765 43210", inputType: "tel", visibility: !0, subFields: {}, options: [], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `email_${Date.now()}_7`, type: "email", label: "Email Address (for all correspondence)", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-red-500 font-bold text-lg", children: "📧" }), color: "text-red-500", values: {}, showLabel: !0, instruction: "All conference updates will be sent to this email", hoverText: "Please ensure this email is active", placeholder: "your.email@example.com", inputType: "email", visibility: !0, subFields: {}, options: [], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `phone_${Date.now()}_8`, type: "phone", label: "WhatsApp Number (for conference updates)", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-green-500 font-bold text-lg", children: "💬" }), color: "text-green-500", values: {}, showLabel: !0, instruction: "For quick conference updates and notifications", hoverText: "WhatsApp number for instant updates", placeholder: "+91 98765 43210", inputType: "tel", visibility: !0, subFields: {}, options: [], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `single-line_${Date.now()}_9`, type: "single-line", label: "Organization / Institute", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-indigo-600 font-bold text-lg", children: "🏛️" }), color: "text-indigo-600", values: {}, showLabel: !0, instruction: "Enter your current organization or institute name", hoverText: "This will appear on your certificate", placeholder: "University/Company Name", inputType: "text", visibility: !0, subFields: {}, options: [], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `single-line_${Date.now()}_10`, type: "single-line", label: "Current Designation / Position", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-orange-600 font-bold text-lg", children: "💼" }), color: "text-orange-600", values: {}, showLabel: !0, instruction: "", hoverText: "", placeholder: "Professor/Manager/Student etc.", inputType: "text", visibility: !0, subFields: {}, options: [], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, // Accommodation Requirements { id: `radio_${Date.now()}_11`, type: "radio", label: "Do you require accommodation?", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-blue-700 font-bold text-lg", children: "🏨" }), color: "text-blue-700", values: {}, showLabel: !0, instruction: "", hoverText: "", placeholder: "", inputType: "text", visibility: !0, subFields: {}, options: [ { id: 1, label: "Yes", value: "yes" }, { id: 2, label: "No", value: "no" } ], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `checkbox_${Date.now()}_12`, type: "checkbox", label: "Dates required (please tick all that apply)", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-green-700 font-bold text-lg", children: "📅" }), color: "text-green-700", values: {}, showLabel: !0, instruction: "Select all dates you need accommodation", hoverText: "", placeholder: "", inputType: "text", visibility: !0, subFields: {}, options: [ { id: 1, label: "20.11.2025", value: "2025-11-20" }, { id: 2, label: "21.11.2025", value: "2025-11-21" }, { id: 3, label: "22.11.2025", value: "2025-11-22" }, { id: 4, label: "23.11.2025", value: "2025-11-23" } ], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `date_${Date.now()}_13`, type: "date", label: "Expected Date of Arrival", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-orange-600 font-bold text-lg", children: "📅" }), color: "text-orange-600", values: {}, showLabel: !0, instruction: "", hoverText: "", placeholder: "", inputType: "text", visibility: !0, subFields: {}, options: [], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `radio_${Date.now()}_14`, type: "radio", label: "Mode of Travel", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-blue-600 font-bold text-lg", children: "✈️" }), color: "text-blue-600", values: {}, showLabel: !0, instruction: "", hoverText: "", placeholder: "", inputType: "text", visibility: !0, subFields: {}, options: [ { id: 1, label: "Air", value: "air" }, { id: 2, label: "Train", value: "train" }, { id: 3, label: "Bus", value: "bus" } ], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `time_${Date.now()}_15`, type: "time", label: "Time of Arrival", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-blue-700 font-bold text-lg", children: "🕐" }), color: "text-blue-700", values: {}, showLabel: !0, instruction: "", hoverText: "", placeholder: "", inputType: "text", visibility: !0, subFields: {}, options: [], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `single-line_${Date.now()}_16`, type: "single-line", label: "Train/Flight Number & PNR", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-purple-700 font-bold text-lg", children: "🎫" }), color: "text-purple-700", values: {}, showLabel: !0, instruction: "Enter your travel details for pickup arrangements", hoverText: "", placeholder: "AI 123 / 12345ABC", inputType: "text", visibility: !0, subFields: {}, options: [], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `radio_${Date.now()}_17`, type: "radio", label: "Dietary Preference", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-green-600 font-bold text-lg", children: "🍽️" }), color: "text-green-600", values: {}, showLabel: !0, instruction: "", hoverText: "", placeholder: "", inputType: "text", visibility: !0, subFields: {}, options: [ { id: 1, label: "Vegetarian", value: "vegetarian" }, { id: 2, label: "Non-Vegetarian", value: "non-vegetarian" } ], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, // Conference T-shirt { id: `radio_${Date.now()}_18`, type: "radio", label: "Would you like to purchase a conference T-shirt?", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-pink-600 font-bold text-lg", children: "👕" }), color: "text-pink-600", values: {}, showLabel: !0, instruction: "Additional payment of ₹600/- applies", hoverText: "Payment details will be notified via email", placeholder: "", inputType: "text", visibility: !0, subFields: {}, options: [ { id: 1, label: "Yes", value: "yes" }, { id: 2, label: "No", value: "no" } ], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `dropdown_${Date.now()}_19`, type: "dropdown", label: "T-shirt Size", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-indigo-600 font-bold text-lg", children: "📏" }), color: "text-indigo-600", values: {}, showLabel: !0, instruction: "Select your preferred size", hoverText: "", placeholder: "Select size", inputType: "text", visibility: !0, subFields: {}, options: [ { id: 1, label: "S", value: "s" }, { id: 2, label: "M", value: "m" }, { id: 3, label: "L", value: "l" }, { id: 4, label: "XL", value: "xl" }, { id: 5, label: "XXL", value: "xxl" }, { id: 6, label: "XXXL", value: "xxxl" } ], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, // Conference Trip { id: `radio_${Date.now()}_20`, type: "radio", label: "Are you planning to join the conference trip?", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-green-700 font-bold text-lg", children: "🚌" }), color: "text-green-700", values: {}, showLabel: !0, instruction: "Trip includes visits to Wayanad Wildlife Sanctuary, Pookode Lake, Banasura Sagar Dam, and Karapuzha Ecotourism Centre. Limited to 100 participants (first come, first served). Additional fee: ₹1,200/-", hoverText: "", placeholder: "", inputType: "text", visibility: !0, subFields: {}, options: [ { id: 1, label: "Yes (charges apply)", value: "yes" }, { id: 2, label: "No", value: "no" } ], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, // Accompanying Person { id: `radio_${Date.now()}_21`, type: "radio", label: "Do you have an accompanying person?", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-purple-600 font-bold text-lg", children: "👥" }), color: "text-purple-600", values: {}, showLabel: !0, instruction: "", hoverText: "", placeholder: "", inputType: "text", visibility: !0, subFields: {}, options: [ { id: 1, label: "Yes", value: "yes" }, { id: 2, label: "No", value: "no" } ], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `single-line_${Date.now()}_22`, type: "single-line", label: "Name of Accompanying Person", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-blue-600 font-bold text-lg", children: "👤" }), color: "text-blue-600", values: {}, showLabel: !0, instruction: "Provide full name and relationship to you", hoverText: "", placeholder: "Full Name", inputType: "text", visibility: !0, subFields: {}, options: [], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, { id: `single-line_${Date.now()}_23`, type: "single-line", label: "Unique ID Number", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-orange-600 font-bold text-lg", children: "🆔" }), color: "text-orange-600", values: {}, showLabel: !0, instruction: "Enter the unique ID number for the accompanying person", hoverText: "", placeholder: "ID Number", inputType: "text", visibility: !0, subFields: {}, options: [], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 }, // Confirmation { id: `checkbox_${Date.now()}_24`, type: "checkbox", label: "Confirmation", originalIcon: () => /* @__PURE__ */ a.jsx("span", { className: "text-green-600 font-bold text-lg", children: "✅" }), color: "text-green-600", values: {}, showLabel: !0, instruction: "Please confirm the following before submitting", hoverText: "", placeholder: "", inputType: "text", visibility: !0, subFields: {}, options: [ { id: 1, label: "I confirm that the details entered above are correct to the best of my knowledge", value: "details_correct" }, { id: 2, label: "I have verified that my name and institution are correctly entered and understand that no changes can be made once certificates are printed", value: "name_verified" } ], minRating: 1, maxRating: 5, minValue: 0, maxValue: 100, step: 1 } ], rules: [] }), wm = (e) => { const { isEditMode: t, formId: r, formName: n, onFormNameChange: s, onSave: i } = e, [o, l] = de([]), [c, u] = de({}), [p, h] = de({ isOpen: !1, field: null }), [d, m] = de(!1), [g, b] = de({}), [x, N] = de(null), [w, D] = de(!1), [T, L] = de(!1), [B, I] = de([]), [H, ie] = de(!1), [W, v] = de(!1), O = Se(null); return ke(() => { x && O.current && setTimeout(() => { const X = document.querySelector( `[data-field-id="${x}"]` ); X && (X.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), X.style.transform = "scale(1.02)", X.style.transition = "transform 0.3s ease-out", setTimeout(() => { X.style.transform = "scale(1)"; }, 300)), N(null); }, 100); }, [x, o]), ke(() => { n !== void 0 && n !== c.formName && u((X) => ({ ...X, formName: n })); }, [n]), { formFields: o, formDetails: c, settingsDrawer: p, isPreviewMode: d, previewData: g, showFormDetailsModal: w, showRulesModal: T, formRules: B, isTestMode: H, isSaving: W, formContainerRef: O, handlers: { handleFieldSelect: (X) => { const ge = bc(X, o); l([...o, ge]), N(ge.id); }, handleFieldAdd: (X, ge) => { const fe = bc(X, o), it = [...o]; it.splice(ge, 0, fe), l(it), N(fe.id); }, handleFieldRemove: (X) => { l(o.filter((fe) => fe.id !== X)); const ge = { ...c }; delete ge[X], u(ge); }, handleFieldUpdate: (X, ge) => { l( o.map( (fe) => fe.id === X ? { ...fe, ...ge } : fe ) ); }, handleFieldDuplicate: (X) => { const ge = { ...X, id: `field_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, label: `${X.label} (Copy)` }; l([...o, ge]), N(ge.id); }, handleFieldOpenSettings: (X) => { h({ isOpen: !0, field: X }); }, handleFieldSettingsUpdate: (X, ge) => { l( o.map( (fe) => fe.id === X ? { ...fe, ...ge } : fe ) ), h({ isOpen: !1, field: null }); }, handleFieldReorder: (X, ge) => { const fe = [...o], [it] = fe.splice(X, 1); fe.splice(ge, 0, it), l(fe); }, handleCloseSettingsDrawer: () => { h({ isOpen: !1, field: null }); }, handleSaveForm: () => { if (W) return; if (o.length === 0) { alert("Please add some fields to your form before saving."); return; } v(!0); const X = { name: c.formName || n, type: c.formType, description: c.formDescription, structure: o, formsRules: B }; console.log("Form Data to Save:", X), i && i(X), v(!1), alert("Form saved successfully!"); }, handleFormDetailsSubmit: (X) => { if (W) return; v(!0); const ge = { ...X, structure: o, formsRules: B }; console.log("Form Data with Details:", ge), i && i(ge), v(!1), D(!1), m(!0), b({}); }, handleExitPreview: () => { ie(!1), m(!1), b({}); }, handlePreviewFieldUpdate: (X, ge) => { b((fe) => ({ ...fe, [X]: ge })); }, handleSubmitPreview: (X) => { const ge = X || (() => { const fe = {}; return Object.entries(g).forEach(([it, Ie]) => { const [Bt, hr] = it.split("."), Mt = Bt.split("_")[0]; hr ? (fe[Mt] || (fe[Mt] = {}), fe[Mt][hr] = Ie) : fe[Mt] = Ie; }), fe; })(); console.log("Form Submission Data (with labels):", ge), console.log( "Data source:", X ? "FormPreview formatted" : "Fallback transformation" ), console.log("Form Structure:", o), alert("Form submitted successfully! Check console for data."); }, handleClearAll: () => { l([]), u({}), I([]); }, handleOpenRules: () => { L(!0); }, handleSaveRules: (X) => { I(X), L(!1); }, shouldShowField: (X) => { if (!B || B.length === 0) return !0; const ge = B.filter((fe) => fe.fieldId === X); return ge.length === 0 ? !0 : ge.every((fe) => { const it = o.find((Bt) => Bt.id === fe.targetFieldId); if (!it) return !0; const Ie = g[it.id]; if (!Ie) return fe.condition === "is_empty"; switch (fe.condition) { case "equals": return Ie === fe.value; case "not_equals": return Ie !== fe.value; case "contains": return Ie.includes(fe.value); case "not_contains": return !Ie.includes(fe.value); case "is_empty": return !Ie || Ie.trim() === ""; case "is_not_empty": return Ie && Ie.trim() !== ""; default: return !0; } }); }, handlePreviewForm: () => { m(!0), b({}); }, handleTestRules: () => { ie(!0), m(!0), b({}); }, handleExitTest: () => { ie(!1), m(!1), b({}); }, handleLoadDemo: () => { const X = Nm(); l(X.structure), u({ formName: X.name, formType: X.type, formDescription: X.description }), I(X.rules || []), i && i({ name: X.name, type: X.type, description: X.description, structure: X.structure, formsRules: X.rules || [] }); }, loadForm: (X) => { if (X.structure && X.structure.length > 0 && l(X.structure), (X.name || X.type || X.description) && u({ formName: X.name, formType: X.type, formDescription: X.description }), X.FormsRules || X.formsRules) { let ge = []; try { ge = JSON.parse(X.FormsRules || X.formsRules || "[]"); } catch { ge = []; } I(Array.isArray(ge) ? ge : []); } else I([]); }, setShowFormDetailsModal: D, setShowRulesModal: L } }; }; var Pd = { color: void 0, size: void 0, className: void 0, style: void 0, attr: void 0 }, xc = ue.createContext && /* @__PURE__ */ ue.createContext(Pd), Em = ["attr", "size", "title"]; function jm(e, t) { if (e == null) return {}; var r = Sm(e, t), n, s; if (Object.getOwnPropertySymbols) { var i = Object.getOwnPropertySymbols(e); for (s = 0; s < i.length; s++) n = i[s], !(t.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(e, n) && (r[n] = e[n]); } return r; } function Sm(e, t) { if (e == null) return {}; var r = {}; for (var n in e) if (Object.prototype.hasOwnProperty.call(e, n)) { if (t.indexOf(n) >= 0) continue; r[n] = e[n]; } return r; } function ai() { return ai = Object.assign ? Object.assign.bind() : function(e) { for (var t = 1; t < arguments.length; t++) { var r = arguments[t]; for (var n in r) Object.prototype.hasOwnProperty.call(r, n) && (e[n] = r[n]); } return e; }, ai.apply(this, arguments); } function yc(e, t) { var r = Object.keys(e); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); t && (n = n.filter(function(s) { return Object.getOwnPropertyDescriptor(e, s).enumerable; })), r.push.apply(r, n); } return r; } function li(e) { for (var t = 1; t < arguments.length; t++) { var r = arguments[t] != null ? arguments[t] : {}; t % 2 ? yc(Object(r), !0).forEach(function(n) { Cm(e, n, r[n]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : yc(Object(r)).forEach(function(n) { Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n)); }); } return e; } function Cm(e, t, r) { return t = Am(t), t in e ? Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = r, e; } function Am(e) { var t = Tm(e, "string"); return typeof t == "symbol" ? t : t + ""; } function Tm(e, t) { if (typeof e != "object" || !e) return e; var r = e[Symbol.toPrimitive]; if (r !== void 0) { var n = r.call(e, t); if (typeof n != "object") return n; throw new TypeError("@@toPrimitive must return a primitive value."); } return (t === "string" ? String : Number)(e); } function Fd(e) { return e && e.map((t, r) => /* @__PURE__ */ ue.createElement(t.tag, li({ key: r }, t.attr), Fd(t.child))); } function Q(e) { return (t) => /* @__PURE__ */ ue.createElement(Om, ai({ attr: li({}, e.attr) }, t), Fd(e.child)); } function Om(e) { var t = (r) => { var { attr: n, size: s, title: i } = e, o = jm(e, Em), l = s || r.size || "1em", c; return r.className && (c = r.className), e.className && (c = (c ? c + " " : "") + e.className), /* @__PURE__ */ ue.createElement("svg", ai({ stroke: "currentColor", fill: "currentColor", strokeWidth: "0" }, r.attr, n, o, { className: c, style: li(li({ color: e.color || r.color }, r.style), e.style), height: l, width: l, xmlns: "http://www.w3.org/2000/svg" }), i && /* @__PURE__ */ ue.createElement("title", null, i), e.children); }; return xc !== void 0 ? /* @__PURE__ */ ue.createElement(xc.Consumer, null, (r) => t(r)) : t(Pd); } function nn(e) { return Q({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M256 112v288m144-144H112" }, child: [] }] })(e); } function qd(e) { return Q({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M407.72 224c-3.4 0-14.79.1-18 .3l-64.9 1.7a1.83 1.83 0 0 1-1.69-.9L193.55 67.56a9 9 0 0 0-6.66-3.56H160l73 161a2.35 2.35 0 0 1-2.26 3.35l-121.69 1.8a8.06 8.06 0 0 1-6.6-3.1l-37-45c-3-3.9-8.62-6-13.51-6H33.08c-1.29 0-1.1 1.21-.75 2.43l19.84 71.42a16.3 16.3 0 0 1 0 11.9L32.31 333c-.59 1.95-.52 3 1.77 3H52c8.14 0 9.25-1.06 13.41-6.3l37.7-45.7a8.19 8.19 0 0 1 6.6-3.1l120.68 2.7a2.7 2.7 0 0 1 2.43 3.74L160 448h26.64a9 9 0 0 0 6.65-3.55L323.14 287c.39-.6 2-.9 2.69-.9l63.9 1.7c3.3.2 14.59.3 18 .3C452 288.1 480 275.93 480 256s-27.88-32-72.28-32z" }, child: [] }] })(e); } function Dm(e) { return Q({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "48", d: "M244 400 100 256l144-144M120 256h292" }, child: [] }] })(e); } function Bd(e) { return Q({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M467 176a29.94 29.94 0 0 0-25.32 12.5 2 2 0 0 1-3.64-1.14v-36.65c0-20.75-16.34-38.21-37.08-38.7A38 38 0 0 0 362 150v82a2 2 0 0 1-2 2H152a2 2 0 0 1-2-2v-81.29c0-20.75-16.34-38.21-37.08-38.7A38 38 0 0 0 74 150v37.38a2 2 0 0 1-3.64 1.14A29.94 29.94 0 0 0 45 176c-16.3.51-29 14.31-29 30.62v98.72c0 16.31 12.74 30.11 29 30.62a29.94 29.94 0 0 0 25.32-12.5 2 2 0 0 1 3.68 1.16v36.67C74 382 90.34 399.5 111.08 400A38 38 0 0 0 150 362v-82a2 2 0 0 1 2-2h208a2 2 0 0 1 2 2v81.29c0 20.75 16.34 38.21 37.08 38.7A38 38 0 0 0 438 362v-37.38a2 2 0 0 1 3.64-1.14A29.94 29.94 0 0 0 467 336c16.3-.51 29-14.31 29-30.62v-98.74c0-16.31-12.74-30.11-29-30.64z" }, child: [] }] })(e); } function Md(e) { return Q({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M256 160c16-63.16 76.43-95.41 208-96a15.94 15.94 0 0 1 16 16v288a16 16 0 0 1-16 16c-128 0-177.45 25.81-208 64-30.37-38-80-64-208-64-9.88 0-16-8.05-16-17.93V80a15.94 15.94 0 0 1 16-16c131.57.59 192 32.84 208 96zm0 0v288" }, child: [] }] })(e); } function $d(e) { return Q({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "rect", attr: { width: "448", height: "320", x: "32", y: "128", fill: "none", strokeLinejoin: "round", strokeWidth: "32", rx: "48", ry: "48" }, child: [] }, { tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M144 128V96a32 32 0 0 1 32-32h160a32 32 0 0 1 32 32v32m112 112H32m288 0v24a8 8 0 0 1-8 8H200a8 8 0 0 1-8-8v-24" }, child: [] }] })(e); } function Vd(e) { return Q({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "rect", attr: { width: "352", height: "192", x: "80", y: "112", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", rx: "32", ry: "32" }, child: [] }, { tag: "rect", attr: { width: "352", height: "128", x: "80", y: "304", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", rx: "32", ry: "32" }, child: [] }, { tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M400 112H112a32.09 32.09 0 0 1-32-32h0a32.09 32.09 0 0 1 32-32h288a32.09 32.09 0 0 1 32 32h0a32.09 32.09 0 0 1-32 32zM144 432v22a10 10 0 0 1-10 10h-28a10 10 0 0 1-10-10v-22zm272 0v22a10 10 0 0 1-10 10h-28a10 10 0 0 1-10-10v-22z" }, child: [] }, { tag: "circle", attr: { cx: "368", cy: "368", r: "16", fill: "none", strokeLinejoin: "round", strokeWidth: "32" }, child: [] }, { tag: "circle", attr: { cx: "144", cy: "368", r: "16", fill: "none", strokeLinejoin: "round", strokeWidth: "32" }, child: [] }, { tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M256 112v192M80 80v288M432 80v288" }, child: [] }] })(e); } function Ud(e) { return Q({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M176 416v64M80 32h192a32 32 0 0 1 32 32v412a4 4 0 0 1-4 4H48h0V64a32 32 0 0 1 32-32zm240 160h112a32 32 0 0 1 32 32v256h0-160 0V208a16 16 0 0 1 16-16z" }, child: [] }, { tag: "path", attr: { d: "M98.08 431.87a16 16 0 1 1 13.79-13.79 16 16 0 0 1-13.79 13.79zm0-80a16 16 0 1 1 13.79-13.79 16 16 0 0 1-13.79 13.79zm0-80a16 16 0 1 1 13.79-13.79 16 16 0 0 1-13.79 13.79zm0-80a16 16 0 1 1 13.79-13.79 16 16 0 0 1-13.79 13.79zm0-80a16 16 0 1 1 13.79-13.79 16 16 0 0 1-13.79 13.79zm80 240a16 16 0 1 1 13.79-13.79 16 16 0 0 1-13.79 13.79zm0-80a16 16 0 1 1 13.79-13.79 16 16 0 0 1-13.79 13.79zm0-80a16 16 0 1 1 13.79-13.79 16 16 0 0 1-13.79 13.79zm0-80a16 16 0 1 1 13.79-13.79 16 16 0 0 1-13.79 13.79zm80 320a16 16 0 1 1 13.79-13.79 16 16 0 0 1-13.79 13.79zm0-80a16 16 0 1 1 13.79-13.79 16 16 0 0 1-13.79 13.79zm0-80a16 16 0 1 1 13.79-13.79 16 16 0 0 1-13.79 13.79z" }, child: [] }, { tag: "ellipse", attr: { cx: "256", cy: "176", rx: "15.95", ry: "16.03", transform: "rotate(-45 255.99 175.996)" }, child: [] }, { tag: "path", attr: { d: "M258.08 111.87a16 16 0 1 1 13.79-13.79 16 16 0 0 1-13.79 13.79zM400 400a16 16 0 1 0 16 16 16 16 0 0 0-16-16zm0-80a16 16 0 1 0 16 16 16 16 0 0 0-16-16zm0-80a16 16 0 1 0 16 16 16 16 0 0 0-16-16zm-64 160a16 16 0 1 0 16 16 16 16 0 0 0-16-16zm0-80a16 16 0 1 0 16 16 16 16 0 0 0-16-16zm0-80a16 16 0 1 0 16 16 16 16 0 0 0-16-16z" }, child: [] }] })(e); } function Lm(e) { return Q({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "rect", attr: { width: "416", height: "384", x: "48", y: "80", fill: "none", strokeLinejoin: "round", strokeWidth: "32", rx: "48" }, child: [] }, { tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M128 48v32m256-32v32m80 80H48" }, child: [] }] })(e); } function el(e) { return Q({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "rect", attr: { width: "416", height: "384", x: "48", y: "80", fill: "none", strokeLinejoin: "round", strokeWidth: "32", rx: "48" }, child: [] }, { tag: "circle", attr: { cx: "296", cy: "232", r: "24" }, child: [] }, { tag: "circle", attr: { cx: "376", cy: "232", r: "24" }, child: [] }, { tag: "circle", attr: { cx: "296", cy: "312", r: "24" }, child: [] }, { tag: "circle", attr: { cx: "376", cy: "312", r: "24" }, child: [] }, { tag: "circle", attr: { cx: "136", cy: "312", r: "24" }, child: [] }, { tag: "circle", attr: { cx: "216", cy: "312", r: "24" }, child: [] }, { tag: "circle", attr: { cx: "136", cy: "392", r: "24" }, child: [] }, { tag: "circle", attr: { cx: "216", cy: "392", r: "24" }, child: [] }, { tag: "circle", attr: { cx: "296", cy: "392", r: "24" }, child: [] }, { tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M128 48v32m256-32v32" }, child: [] }, { tag: "path", attr: { fill: "none", strokeLinejoin: "round", strokeWidth: "32", d: "M464 160H48" }, child: [] }] })(e); } function tl(e) { return Q({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeMiterlimit: "10", strokeWidth: "32", d: "M451 374c-15.88-16-54.34-39.35-73-48.76-24.3-12.24-26.3-13.24-45.4.95-12.74 9.47-21.21 17.93-36.12 14.75s-47.31-21.11-75.68-49.39-47.34-61.62-50.53-76.48 5.41-23.23 14.79-36c13.22-18 12.22-21 .92-45.3-8.81-18.9-32.84-57-48.9-72.8C119.9 44 119.9 47 108.83 51.6A160.15 160.15 0 0 0 83 65.37C67 76 58.12 84.83 51.91 98.1s-9 44.38 23.07 102.64 54.57 88.05 101.14 134.49S258.5 406.64 310.85 436c64.76 36.27 89.6 29.2 102.91 23s22.18-15 32.83-31a159.09 159.09 0 0 0 13.8-25.8C465 391.17 468 391.17 451 374z" }, child: [] }] })(e); } function zd(e) { return Q({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "m350.54 148.68-26.62-42.06C318.31 100.08 310.62 96 302 96h-92c-8.62 0-16.31 4.08-21.92 10.62l-26.62 42.06C155.85 155.23 148.62 160 140 160H80a32 32 0 0 0-32 32v192a32 32 0 0 0 32 32h352a32 32 0 0 0 32-32V192a32 32 0 0 0-32-32h-59c-8.65 0-16.85-4.77-22.46-11.32z" }, child: [] }, { tag: "circle", attr: { cx: "256", cy: "272", r: "80", fill: "none", strokeMiterlimit: "10", strokeWidth: "32" }, child: [] }, { tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M124 158v-22h-24v22" }, child: [] }] })(e); } function Wd(e) { return Q({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "m80 224 37.78-88.15C123.93 121.5 139.6 112 157.11 112h197.78c17.51 0 33.18 9.5 39.33 23.85L432 224m-352 0h352v144H80zm32 144v32H80v-32m352 0v32h-32v-32" }, child: [] }, { tag: "circle", attr: { cx: "144", cy: "288", r: "16", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32" }, child: [] }, { tag: "circle", attr: { cx: "368", cy: "288", r: "16", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32" }, child: [] }] })(e); } funct