PageSourceSearch

https://blackparakeetztoo.com/wp-content/plugins/user-registration…/js/frontend/user-registration.js?ver=5.2.8

js blackparakeetztoo.com collected 2026-10-08 08:10:24 UTC 91,444 bytes, 3,461 lines download raw bytes

1/* global  user_registration_params, ur_frontend_params_with_form_id */
2(function ($) {
3	var user_registration_form_init = function () {
4		var ursL10n = user_registration_params.ursL10n;
5
6		var user_registration_frontend_utils = {
7			/**
8			 * Function to show success message.
9			 *
10			 * @since 4.2.1
11			 */
12			show_success_message: function (message) {
13				$(
14					".user-registration-membership-notice__container .user-registration-membership-notice__red"
15				)
16					.removeClass("user-registration-membership-notice__red")
17					.addClass("user-registration-membership-notice__blue");
18				$(".user-registration-membership-notice__message").text(
19					message
20				);
21				$(".user-registration-membership-notice__container").css(
22					"display",
23					"block"
24				);
25				//attach near my account title.
26				if (
27					$(document).find(".user-registration-MyAccount").length ===
28					1
29				) {
30					$(
31						".user-registration-membership-notice__container .ur-toaster"
32					);
33				}
34				// this.toggleNotice();
35				this.ur_remove_cookie("urm_toast_content");
36				this.ur_remove_cookie("urm_toast_success_message");
37			},
38			show_error_message: function (message) {
39				$(".user-registration-membership-notice__container")
40					.removeClass("user-registration-membership-notice__blue")
41					.addClass("user-registration-membership-notice__red");
42				$(".user-registration-membership-notice__message").text(
43					message
44				);
45				$(".user-registration-membership-notice__container").css(
46					"display",
47					"block"
48				);
49
50				//attach near my account title.
51				if (
52					$(document).find(".user-registration-MyAccount").length ===
53					1
54				) {
55					$(
56						".user-registration-membership-notice__container .ur-toaster "
57					);
58				}
59				// this.toggleNotice();
60				this.ur_remove_cookie("urm_toast_content");
61				this.ur_remove_cookie("urm_toast_success_message");
62			},
63
64			/**
65			 * Removes the notice after some time.
66			 *
67			 * @since 4.2.1
68			 */
69			toggleNotice: function () {
70				var noticeContainer = $(
71					".user-registration-membership-notice__container"
72				);
73				setTimeout(function () {
74					noticeContainer.fadeOut(4000);
75				}, 4000);
76			},
77
78			/**
79			 * Retrieves the cookie values set.
80			 *
81			 * @since 4.2.1
82			 */
83			ur_get_cookie: function (cookie_key) {
84				var matches = document.cookie.match(
85					new RegExp(
86						"(?:^|; )" +
87							cookie_key.replace(
88								/([\.$?*|{}\(\)\[\]\\\/\+^])/g,
89								"\\$1"
90							) +
91							"=([^;]*)"
92					)
93				);
94				return matches ? decodeURIComponent(matches[1]) : undefined;
95			},
96
97			/**
98			 * Deletes the cookie values.
99			 *
100			 * @since 4.2.1
101			 */
102			ur_remove_cookie: function (cookie_key) {
103				document.cookie = cookie_key + "=; Max-Age=-99999999; path=/" + (window.location.protocol === 'https:' ? '; Secure' : '') + "; SameSite=Strict";
104			}
105		};
106
107		$.fn.ur_form_submission = function () {
108			// traverse all nodes
109			return this.each(function () {
110				// express a single node as a jQuery object
111				var $this = $(this);
112				var available_field = [];
113				var required_fields =
114					user_registration_params.form_required_fields;
115				var form = {
116					init: function () {},
117					get_form_data: function (form_id) {
118						if (
119							form_id ===
120								$this.closest(".ur-frontend-form").attr("id") ||
121							$(".ur-frontend-form")
122								.find("form.edit-profile")
123								.hasClass("user-registration-EditProfileForm")
124						) {
125							var this_instance = this;
126							var form_data = [];
127							var frontend_field = form.separate_form_handler("");
128							var repeater_field_data = {};
129
130							$this
131								.closest("form")
132								.find(".ur-repeater-row")
133								.each(function () {
134									var fieldName = $(this)
135										.closest(".ur-repeater-row")
136										.data("repeater-field-name");
137									var rowName =
138										"row_" +
139										$(this)
140											.closest(".ur-repeater-row")
141											.data("repeater-row");
142
143									if (
144										$(this).closest(
145											".user-registration-EditProfileForm"
146										).length > 0
147									) {
148										fieldName =
149											"user_registration_" + fieldName;
150									}
151
152									if (!repeater_field_data[fieldName]) {
153										repeater_field_data[fieldName] = {
154											field_name: fieldName,
155											field_type: "repeater",
156											value: {},
157											label: $(this)
158												.closest(".ur-repeater-row")
159												.find(".ur-repeater-label")
160												.find(".ur-label")
161												.text(),
162											extra_params: {
163												field_key: "repeater",
164												label: $(this)
165													.closest(".ur-repeater-row")
166													.find(".ur-repeater-label")
167													.find(".ur-label")
168													.text()
169											}
170										};
171									}
172
173									if (
174										!repeater_field_data[fieldName][
175											"value"
176										][rowName]
177									) {
178										repeater_field_data[fieldName]["value"][
179											rowName
180										] = [];
181									}
182								});
183
184							var multi_value_field = new Array();
185							$.each(frontend_field, function () {
186								var field_name = $(this).attr("name");
187								var field_type = $(this).attr("type");
188								var single_field = form.separate_form_handler(
189									'[name="' + field_name + '"]'
190								);
191
192								var selection_fields_array = ["radio"];
193								var fieldName = $(this)
194									.closest(".ur-repeater-row")
195									.data("repeater-field-name");
196
197								if (
198									$(this).closest(
199										".user-registration-EditProfileForm"
200									).length > 0
201								) {
202									fieldName =
203										"user_registration_" + fieldName;
204								}
205
206								var rowName =
207									"row_" +
208									$(this)
209										.closest(".ur-repeater-row")
210										.data("repeater-row");
211
212								if (
213									(single_field.length < 2 ||
214										single_field.closest(".ur-repeater-row")
215											.length > 0) &&
216									$.inArray(
217										field_type,
218										selection_fields_array
219									) < 0
220								) {
221									var single_data =
222										this_instance.get_fieldwise_data(
223											$(this)
224										);
225
226									var invite_code =
227										document.querySelector("#invite_code");
228
229									if (
230										"invite_code" === single_data.field_name
231									) {
232										if (
233											"none" !== invite_code.style.display
234										) {
235											form_data.push(single_data);
236										}
237									} else {
238										if (
239											$(this).closest(".ur-repeater-row")
240												.length > 0
241										) {
242											if (
243												$(this)
244													.closest(".form-row")
245													.find(
246														"*[name='" +
247															$(this).attr(
248																"name"
249															) +
250															"']"
251													).length < 2 ||
252												"range" ===
253													$(this).attr("type") ||
254												$(this).hasClass(
255													"ur-smart-phone-field"
256												)
257											) {
258												repeater_field_data[fieldName][
259													"value"
260												][rowName].push(single_data);
261											} else {
262												if (
263													multi_value_field.indexOf(
264														single_data.field_name +
265															"[]"
266													) === -1
267												) {
268													multi_value_field.push(
269														single_data.field_name +
270															"[]"
271													);
272												}
273											}
274										} else {
275											form_data.push(single_data);
276										}
277									}
278								} else {
279									if (
280										$.inArray(
281											field_name,
282											multi_value_field
283										) < 0
284									) {
285										multi_value_field.push(field_name);
286									}
287								}
288							});
289
290							for (
291								var multi_start = 0;
292								multi_start < multi_value_field.length;
293								multi_start++
294							) {
295								var field = form.separate_form_handler(
296									'[name="' +
297										multi_value_field[multi_start] +
298										'"]'
299								);
300								var node_type = field
301									.get(0)
302									.tagName.toLowerCase();
303
304								var field_type =
305									"undefined" !== field.eq(0).attr("type")
306										? field.eq(0).attr("type")
307										: "null";
308
309								var field_value = new Array();
310
311								var repeater_field_value = {};
312								$.each(field, function () {
313									var this_field = $(this);
314
315									var this_field_value = "";
316
317									switch (
318										this_field.get(0).tagName.toLowerCase()
319									) {
320										case "input":
321											switch (field_type) {
322												case "checkbox":
323												case "radio":
324													this_field_value =
325														this_field.prop(
326															"checked"
327														)
328															? this_field.val()
329															: "";
330													break;
331												default:
332													this_field_value =
333														this_field.val();
334											}
335											break;
336										case "select":
337											this_field_value = this_field.val();
338											break;
339										case "textarea":
340											this_field_value = this_field.val();
341											break;
342										default:
343									}
344
345									if (this_field_value !== "") {
346										if (
347											this_field.closest(
348												".ur-repeater-row"
349											).length > 0
350										) {
351											if (
352												this_field.closest(
353													".field-radio"
354												).length > 0
355											) {
356												repeater_field_value[
357													this_field.attr("data-id")
358												] = this_field_value;
359											} else {
360												if (
361													"undefined" ===
362													typeof repeater_field_value[
363														this_field.attr(
364															"data-id"
365														)
366													]
367												) {
368													repeater_field_value[
369														this_field.attr(
370															"data-id"
371														)
372													] = new Array();
373												}
374												repeater_field_value[
375													this_field.attr("data-id")
376												].push(this_field_value);
377											}
378										} else {
379											field_value.push(this_field_value);
380										}
381									}
382								});
383
384								if (field_type == "checkbox") {
385									if (
386										"" !==
387										user_registration_params.is_payment_compatible
388									) {
389										if (
390											field.eq(0).attr("data-field") ==
391											"multiple_choice"
392										) {
393											$(document).trigger(
394												"user_registration_frontend_multiple_choice_data_filter",
395												[field_value, field]
396											);
397											field_value = field
398												.closest(
399													".field-multiple_choice"
400												)
401												.data("payment-value");
402
403											var field_value_json =
404												JSON.stringify(field_value);
405										} else {
406											var field_value_json =
407												JSON.stringify(field_value);
408										}
409									} else {
410										if (
411											field.eq(0).attr("data-field") ==
412											"multiple_choice"
413										) {
414											var multi_choice = field_value;
415											var field_value_json = 0;
416											for (
417												var i = 0;
418												i < multi_choice.length;
419												i++
420											) {
421												field_value_json +=
422													multi_choice[i] << 0;
423											}
424										} else {
425											var field_value_json =
426												JSON.stringify(field_value);
427										}
428									}
429								} else if (field_type == "radio") {
430									if (
431										"" !==
432										user_registration_params.is_payment_compatible
433									) {
434										if (
435											field.eq(0).attr("data-field") ==
436											"subscription_plan"
437										) {
438											$(document).trigger(
439												"user_registration_frontend_subscription_plan_data_filter",
440												[field_value, field]
441											);
442											selectedSubscriptionPlan = field
443												.closest(
444													".field-subscription_plan"
445												)
446												.find(
447													'input[name="subscription_plan[]"]:checked'
448												);
449
450											if (
451												selectedSubscriptionPlan.length >
452												0
453											) {
454												// Get the data attribute value
455												var dataValue =
456													selectedSubscriptionPlan.data(
457														"value"
458													);
459												var field_value_json =
460													JSON.stringify(
461														dataValue +
462															":" +
463															selectedSubscriptionPlan.val()
464													);
465											}
466										} else {
467											var field_value_json =
468												field_value[0];
469										}
470									} else {
471										var field_value_json = field_value[0];
472									}
473								} else {
474									var field_value_json = field.val();
475								}
476
477								var single_form_field_name =
478									multi_value_field[multi_start];
479								single_form_field_name =
480									single_form_field_name.replace("[]", "");
481
482								if (
483									single_form_field_name === "urm_membership"
484								) {
485									single_form_field_name = field
486										.eq(0)
487										.attr("data-name");
488								}
489								var field_data = {
490									value: field_value_json,
491									field_type: field_type,
492									label: field.eq(0).attr("data-label"),
493									field_name: single_form_field_name
494								};
495
496								if (
497									Object.keys(repeater_field_value).length > 0
498								) {
499									var field_detail = new Array();
500
501									$.each(
502										repeater_field_value,
503										function (key, value) {
504											key =
505												$("[name='" + key + "']")
506													.length < 1 &&
507												key.indexOf("[]") === -1
508													? key + "[]"
509													: key;
510											var row_id = $(
511												'[name="' + key + '"]'
512											)
513												.closest(".ur-repeater-row")
514												.data("repeater-row");
515											var repeater_value = Object.assign(
516												{},
517												field_data
518											);
519
520											repeater_value.value =
521												"string" === typeof value
522													? value
523													: JSON.stringify(value);
524
525											repeater_value.field_name =
526												single_form_field_name.slice(
527													0,
528													-2
529												);
530
531											var current_repeater_field_name =
532												"undefined" ===
533												typeof repeater_field_data[
534													$("[name='" + key + "']")
535														.closest(
536															".ur-repeater-row"
537														)
538														.data(
539															"repeater-field-name"
540														)
541												]
542													? "user_registration_" +
543														$(
544															"[name='" +
545																key +
546																"']"
547														)
548															.closest(
549																".ur-repeater-row"
550															)
551															.data(
552																"repeater-field-name"
553															)
554													: $("[name='" + key + "']")
555															.closest(
556																".ur-repeater-row"
557															)
558															.data(
559																"repeater-field-name"
560															);
561											repeater_field_data[
562												current_repeater_field_name
563											]["value"]["row_" + row_id].push(
564												repeater_value
565											);
566										}
567									);
568								} else {
569									form_data.push(field_data);
570								}
571							}
572
573							Object.keys(repeater_field_data).forEach(
574								function (field_key) {
575									if (
576										$("input[name='" + field_key + "'")
577											.length > 0
578									) {
579										$("input[name='" + field_key + "'").val(
580											JSON.stringify(
581												repeater_field_data[field_key]
582											)
583										);
584									}
585								}
586							);
587
588							if (Object.keys(repeater_field_data).length > 0) {
589								$.merge(
590									form_data,
591									Object.values(repeater_field_data)
592								);
593							}
594							$(document).trigger(
595								"user_registration_frontend_form_data_filter",
596								[form_data]
597							);
598							return form_data;
599						}
600					},
601					get_fieldwise_data: function (field) {
602						var formwise_data = {};
603
604						var node_type = field.get(0).tagName.toLowerCase();
605						var field_name =
606							"undefined" !== field.attr("name")
607								? field.attr("name")
608								: "null";
609
610						var phone_id = [];
611						if (
612							field.attr("name") !== undefined &&
613							field.attr("name") !== ""
614						) {
615							formwise_data.field_name = field.attr("name");
616							formwise_data.field_name =
617								formwise_data.field_name.replace("[]", "");
618
619							if (
620								$(field).closest(".ur-repeater-row").length > 0
621							) {
622								if (
623									$(field).closest(".field-multi_select2")
624										.length > 0
625								) {
626									formwise_data.field_name =
627										formwise_data.field_name.slice(0, -2);
628								}
629
630								if (
631									$(field).closest(".field-file").length > 0
632								) {
633									formwise_data.field_name = $(field)
634										.closest(".field-file")
635										.attr("data-ref-id");
636								}
637							}
638						} else {
639							formwise_data.field_name = "";
640						}
641
642						$(".field-phone, .field-billing_phone").each(
643							function () {
644								var phone_field_id = $(this)
645									.find(".form-row")
646									.attr("id");
647								// Check if smart phone field is enabled.
648								if (
649									$(this)
650										.find(".form-row")
651										.find("#" + phone_field_id)
652										.hasClass("ur-smart-phone-field")
653								) {
654									phone_id.push(
655										$(this).find(".form-row").attr("id")
656									);
657								}
658							}
659						);
660						var field_type =
661							"undefined" !== field.attr("type")
662								? field.attr("type")
663								: "null";
664
665						var textarea_type = field
666							.get(0)
667							.className.split(" ")[0];
668
669						formwise_data.value = "";
670
671						switch (node_type) {
672							case "input":
673								var checked_value = new Array();
674								switch (field_type) {
675									case "checkbox":
676										if (
677											!field.closest(
678												".field-privacy_policy"
679											).length > 0
680										) {
681											if (field.prop("checked")) {
682												checked_value.push(field.val());
683												formwise_data.value =
684													JSON.stringify(
685														checked_value
686													);
687												if (
688													"separate_shipping" ===
689													field.attr("data-id")
690												) {
691													formwise_data.value =
692														field.val();
693												}
694											} else {
695												formwise_data.value = "";
696											}
697										} else {
698											formwise_data.value = field.prop(
699												"checked"
700											)
701												? field.val()
702												: "";
703
704											privacy_field_name = field
705												.closest(
706													".field-privacy_policy"
707												)
708												.data("ref-id");
709
710											if (
711												"undefined" !==
712												typeof privacy_field_name
713											) {
714												formwise_data.field_name =
715													privacy_field_name;
716											}
717										}
718										break;
719									case "radio":
720										formwise_data.value = field.prop(
721											"checked"
722										)
723											? field.val()
724											: "";
725										formwise_data.field_name = field
726											.closest(".field-privacy_policy")
727											.data("ref-id");
728										break;
729									default:
730										formwise_data.value = field.val();
731								}
732
733								if (ur_includes(phone_id, field_name)) {
734									formwise_data.value = field
735										.siblings('input[type="hidden"]')
736										.val();
737								}
738								break;
739							case "select":
740								formwise_data.value = field.val();
741								break;
742							case "textarea":
743								switch (textarea_type) {
744									case "wysiwyg":
745										tinyMCE.triggerSave();
746										formwise_data.value = field.val();
747										break;
748									default:
749										formwise_data.value = field.val();
750								}
751								break;
752							default:
753						}
754
755						$(document).trigger(
756							"user_registration_frontend_form_data_render",
757							[field, formwise_data]
758						);
759						formwise_data.field_type =
760							"undefined" !== field.eq(0).attr("type")
761								? field.eq(0).attr("type")
762								: "null";
763						if (field.attr("data-label") !== undefined) {
764							formwise_data.label = field.attr("data-label");
765						} else if (
766							field.prev().length &&
767							field.prev().get(0).tagName.toLowerCase() ===
768								"label"
769						) {
770							formwise_data.label = field.prev().text();
771						} else {
772							formwise_data.label = formwise_data.field_type;
773						}
774
775						if (
776							$.inArray(
777								formwise_data.field_name,
778								required_fields.join(",").trim()
779							) >= 0
780						) {
781							available_field.push(formwise_data.field_name);
782						}
783
784						return formwise_data;
785					},
786					show_message: function (
787						message,
788						type,
789						$submit_node,
790						position
791					) {
792						$submit_node
793							.closest(".user-registration")
794							.find(".ur-message")
795							.remove();
796
797						// Check if the form is edit-profile form.
798						if (
799							$(".ur-frontend-form")
800								.find("form.edit-profile")
801								.hasClass("user-registration-EditProfileForm")
802						) {
803							var wrapper = $(
804								'<div class="user-registration-' + type + '"/>'
805							);
806							wrapper.append(message);
807
808							if ($("#user-registration").hasClass("vertical")) {
809								wrapper.insertBefore(".ur-frontend-form");
810							} else {
811								wrapper.insertBefore(
812									".user-registration-MyAccount-navigation"
813								);
814							}
815						} else {
816							var wrapper = $(
817								'<div class="ur-message user-registration-' +
818									type +
819									'" id="ur-submit-message-node"/>'
820							);
821							if (type === "error") {
822								var svgIcon =
823									'<svg xmlns="http://www.w3.org/2000/svg" width="35" height="35" viewB
823ox="0 0 35 35" fill="none">' +
824									'    <g clip-path="url(#clip0_8269_857)">' +
825									'        <path d="M10.4979 24.6391C14.4408 28.5063 20.7721 28.445 24.6394 24.5022C28.5066 20.5593 28.4453 14.2279 24.5025 10.3607C20.5596 6.49343 14.2283 6.55472 10.361 10.4976C6.49374 14.4404 6.55503 20.7718 10.4979 24.6391Z" stroke="#F25656" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>' +
826									'        <path d="M20.3008 14.6445L14.699 20.3559" stroke="#F25656" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>' +
827									'        <path d="M14.6445 14.6992L20.3559 20.301" stroke="#F25656" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>' +
828									"    </g>" +
829									"    <defs>" +
830									'        <clipPath id="clip0_8269_857">' +
831									'            <rect width="24" height="24" fill="white" transform="translate(17.3359 0.530273) rotate(44.4454)"></rect>' +
832									"        </clipPath>" +
833									"    </defs>" +
834									"</svg>";
835
836								wrapper.append(svgIcon);
837							}
838							wrapper.append(message);
839							// Check the position set by the admin and append message accordingly.
840							if ("1" === position) {
841								$submit_node.append(wrapper);
842							} else if ("2" === position) {
843								if (type == "message") {
844									$submit_node
845										.closest(".entry-content")
846										.prepend(wrapper);
847									$submit_node
848										.closest(".ur-frontend-form")
849										.hide();
850								} else {
851									$submit_node.append(wrapper);
852								}
853							} else {
854								$submit_node
855									.closest(".ur-frontend-form")
856									.prepend(wrapper);
857							}
858						}
859					},
860					/**
861					 * Handles registration form submit and edit-profile form submit instances separately.
862					 *
863					 * @since  1.8.5
864					 *
865					 * @param element Element to search for in the template.
866					 */
867					separate_form_handler: function (element) {
868						var field = "";
869
870						// Check if the form is edit-profile form.
871						if (
872							$(".ur-frontend-form")
873								.find("form.edit-profile")
874								.hasClass("user-registration-EditProfileForm")
875						) {
876							field = $this
877								.find(".user-registration-profile-fields")
878								.find(".ur-edit-profile-field" + element);
879						} else {
880							field = $this
881								.closest(".ur-frontend-form")
882								.find(".ur-form-grid")
883								.find(".ur-frontend-field" + element);
884						}
885
886						return field;
887					},
888					missing_attachment_handler: function name(file_upload) {
889						var file_upload_field_array = [];
890
891						//Check if file upload field exists.
892						if (1 <= file_upload.length) {
893							file_upload.each(function () {
894								var file_upload_id = $(this).attr("id");
895
896								if (
897									$.inArray(
898										file_upload_id,
899										file_upload_field_array
900									) === -1
901								) {
902									file_upload_field_array.push(
903										file_upload_id
904									);
905								}
906							});
907
908							for (
909								var i = 0;
910								i < file_upload_field_array.length;
911								i++
912							) {
913								var file_upload_val = $(
914									"#" + file_upload_field_array[i]
915								)
916									.val()
917									.split(",");
918
919								for (
920									var j = file_upload_val.length;
921									j >= 0;
922									j--
923								) {
924									if (!$.isNumeric(file_upload_val[j])) {
925										file_upload_val.splice(j, 1);
926									}
927								}
928								$("#" + file_upload_field_array[i]).val(
929									file_upload_val
930								);
931							}
932						}
933					}
934				};
935
936				var events = {
937					init: function () {
938						this.form_submit_event();
939						if (
940							user_registration_params.ajax_submission_on_edit_profile
941						) {
942							this.edit_profile_event();
943						}
944					},
945					/**
946					 * Handles registration ajax form submission event.
947					 *
948					 */
949					form_submit_event: function () {
950						$(".ur-frontend-form").each(function () {
951							var $registration_form = $(this);
952
953							$registration_form
954								.find("form.register")
955								.off("submit")
956								.on("submit", function (event) {
957									event.preventDefault();
958
959									// Prevent the form submission if submit button is hidden or disabled.
960									if (
961										$registration_form
962											.find(
963												"form.register button.ur-submit-button"
964											)
965											.is(":hidden") ||
966										$registration_form
967											.find(
968												"form.register button.ur-submit-button"
969											)
970											.is(":disabled")
971									) {
972										return false;
973									}
974									var $this = $(this);
975
976									// Validator messages.
977									$.extend($.validator.messages, {
978										required:
979											user_registration_params.message_required_fields,
980										url: user_registration_params.message_url_fields,
981										email: user_registration_params.message_email_fields,
982										number: user_registration_params.message_number_fields,
983										confirmpassword:
984											user_registration_params.message_confirm_password_fields
985									});
986
987									if (
988										$this.find(
989											".user-registration-password-strength"
990										).length > 0
991									) {
992										var current_strength = $this
993											.find(
994												".user-registration-password-strength"
995											)
996											.attr("data-current-strength");
997										var min_strength = $this
998											.find(
999												".user-registration-password-strength"
1000											)
1001											.attr("data-min-strength");
1002
1003										if (
1004											parseInt(current_strength, 0) <
1005											parseInt(min_strength, 0)
1006										) {
1007											if (
1008												$this
1009													.find("#user_pass")
1010													.val() != ""
1011											) {
1012												$this
1013													.find("#user_pass-error")
1014													.remove();
1015
1016												var error_msg_dom =
1017													'<label id="user_pass-error" class="user-registration-error" for="user_pass">' +
1018													ursL10n.password_strength_error +
1019													".</label>";
1020												$this
1021													.find(
1022														".user-registration-password-hint"
1023													)
1024													.after(error_msg_dom);
1025												$this
1026													.find("#user_pass")
1027													.attr("aria-invalid", true);
1028												$this
1029													.find("#user_pass")
1030													.trigger("focus");
1031											}
1032
1033											return false;
1034										}
1035									}
1036
1037									var $el = $this.find(
1038										".ur-smart-phone-field"
1039									);
1040
1041									if ("true" === $el.attr("aria-invalid")) {
1042										var wrapper = $el.closest("p.form-row");
1043										wrapper
1044											.find(
1045												"#" + $el.data("id") + "-error"
1046											)
1047											.remove();
1048										var phone_error_msg_dom =
1049											'<label id="' +
1050											$el.data("id") +
1051											"-error" +
1052											'" class="user-registration-error" for="' +
1053											$el.data("id") +
1054											'">' +
1055											user_registration_params.message_validate_phone_number +
1056											"</label>";
1057										wrapper.append(phone_error_msg_dom);
1058										wrapper
1059											.find("#" + $el.data("id"))
1060											.attr("aria-invalid", true);
1061										return true;
1062									}
1063
1064									// Remove word added by form filler in file upload field during submission
1065									var file_upload =
1066										$this.find(".urfu-file-input");
1067
1068									form.missing_attachment_handler(
1069										file_upload
1070									);
1071
1072									var exist_detail = $this
1073										.find(".uraf-profile-picture-upload")
1074										.find(
1075											".user-registration-error"
1076										).length;
1077
1078									if (1 === exist_detail) {
1079										var profile = $this
1080											.find(
1081												".uraf-profile-picture-upload"
1082											)
1083											.find(
1084												".uraf-profile-picture-input"
1085											);
1086										var wrapper = $this.find(
1087											".uraf-profile-picture-upload"
1088										);
1089										wrapper
1090											.find(
1091												"#" +
1092													profile.attr("name") +
1093													"-error"
1094											)
1095											.remove();
1096										wrapper
1097											.find(
1098												".uraf-profile-picture-file-error"
1099											)
1100											.remove();
1101										var error_message =
1102											'<label id="' +
1103											profile.attr("name") +
1104											"-error" +
1105											'" class="user-registration-error" for="' +
1106											profile.attr("name") +
1107											'">' +
1108											user_registration_params.message_required_fields +
1109											"</label>";
1110										wrapper
1111											.find(
1112												"button.wp_uraf_profile_picture_upload"
1113											)
1114											.after(error_message);
1115									}
1116									//place it before user_registration_frontend_validate_before_form_submit trigger gets used by other addons so that regular val
1116idation is shown before addon validations
1117									if (!$this.valid()) {
1118										return;
1119									}
1120									$(document).trigger(
1121										"user_registration_frontend_validate_before_form_submit",
1122										[$this]
1123									);
1124									if (
1125										$(
1126											"#stripe-errors.user-registration-error:visible"
1127										).length
1128									) {
1129										return;
1130									}
1131									if (
1132										0 <
1133										$this.find(".dz-error-message").length
1134									) {
1135										return;
1136									}
1137									if (
1138										$this
1139											.find(
1140												"#user_registration_stripe_gateway"
1141											)
1142											.find(".user-registration-error")
1143											.length > 0 &&
1144										$this
1145											.find(
1146												"#user_registration_stripe_gateway"
1147											)
1148											.find(".user-registration-error")
1149											.is(":visible")
1150									) {
1151										return;
1152									}
1153
1154									$this
1155										.find(".ur-submit-button")
1156										.prop("disabled", true);
1157									var form_data;
1158									var form_id = 0;
1159									var captchaResponse = "";
1160									var registration_language = "";
1161									if (
1162										"hCaptcha" ===
1163										user_registration_params.recaptcha_type
1164									) {
1165										captchaResponse = $this
1166											.find('[name="h-captcha-response"]')
1167											.val();
1168									} else if (
1169										"cloudflare" ===
1170										user_registration_params.recaptcha_type
1171									) {
1172										captchaResponse = $this
1173											.find(
1174												'[name="cf-turnstile-response"]'
1175											)
1176											.val();
1177									} else {
1178										captchaResponse = $this
1179											.find(
1180												'[name="g-recaptcha-response"]'
1181											)
1182											.val();
1183									}
1184									try {
1185										form_data = JSON.stringify(
1186											form.get_form_data(
1187												$this
1188													.closest(
1189														".ur-frontend-form"
1190													)
1191													.attr("id")
1192											)
1193										);
1194									} catch (ex) {
1195										form_data = "";
1196									}
1197
1198									if (
1199										$(this)
1200											.closest("form")
1201											.find(
1202												'input[name="ur-user-form-id"]'
1203											).length === 1
1204									) {
1205										form_id = $(this)
1206											.closest("form")
1207											.find(
1208												'input[name="ur-user-form-id"]'
1209											)
1210											.val();
1211									}
1212									if (
1213										$(this)
1214											.closest("form")
1215											.find(
1216												'input[name="ur-registration-language"]'
1217											).length === 1
1218									) {
1219										registration_language = $(this)
1220											.closest("form")
1221											.find(
1222												'input[name="ur-registration-language"]'
1223											)
1224											.val();
1225									}
1226
1227									// Append tax details if available
1228									var taxDetails =
1229										$(document).find("#ur-tax-details");
1230
1231									if (taxDetails.length > 0) {
1232										form_data.tax_rate =
1233											taxDetails.data("tax-rate");
1234										form_data.tax_calculation_method =
1235											taxDetails.data(
1236												"tax-calculation-method"
1237											);
1238									}
1239
1240									var data = {
1241										action: "user_registration_user_form_submit",
1242										form_data: form_data,
1243										captchaResponse: captchaResponse,
1244										form_id: form_id,
1245										registration_language:
1246											registration_language
1247									};
1248
1249									var $error_message = {};
1250									$(document).trigger(
1251										"user_registration_frontend_before_form_submit",
1252										[data, $this, $error_message]
1253									);
1254
1255									if (
1256										"undefined" !==
1257											typeof $error_message.message &&
1258										"" !== $error_message.message
1259									) {
1260										form.show_message(
1261											"<p>" +
1262												$error_message.message +
1263												"</p>",
1264											"error",
1265											$this,
1266											"1"
1267										);
1268										$this
1269											.find(".ur-submit-button")
1270											.prop("disabled", false);
1271										return;
1272									}
1273
1274									if (
1275										$this
1276											.find(
1277												'.field-authorize_net_gateway[data-field-id="authorizenet_gateway"]'
1278											)
1279											.find(".ur-authorize-net-errors")
1280											.length > 0
1281									) {
1282										return;
1283									}
1284
1285									$this
1286										.find(".ur-submit-button")
1287										.find("span")
1288										.addClass("ur-front-spinner");
1289
1290									if (
1291										$registration_form
1292											.find(
1293												"form.register button.ur-submit-button"
1294											)
1295											.hasClass(
1296												"urm-update-membership-button"
1297											)
1298									) {
1299										$(document).trigger(
1300											"user_registration_membership_update_before_form_submit",
1301											[data, $this, $error_message]
1302										);
1303									} else {
1304										var hit_third_party_api =
1305											events.wait_third_party_api($this);
1306										if (hit_third_party_api) {
1307											var thirdPartyHandlerPromise =
1308												new Promise(function (
1309													resolve,
1310													reject
1311												) {
1312													$(document).trigger(
1313														"user_registration_third_party_api_before_form_submit",
1314														[
1315															data,
1316															$this,
1317															$error_message,
1318															resolve,
1319															reject
1320														]
1321													);
1322												}).then(function (val) {
1323													events.ajax_form_submit(
1324														val
1325													);
1326												});
1327										} else {
1328											events.ajax_form_submit(data);
1329										}
1330									}
1331								});
1332						});
1333					},
1334					/**
1335					 * Wait Form submission for third party api hit response.
1336					 *
1337					 */
1338					wait_third_party_api: function ($form) {
1339						var flag = false;
1340						if (
1341							$form.find(
1342								"#user_registration_authorize_net_gateway[data-gateway='authorize_net']:visible"
1343							).length > 0
1344						) {
1345							flag = true;
1346						}
1347						return flag;
1348					},
1349					/**
1350					 * Handles AJAX error responses for form submission.
1351					 *
1352					 * @param {Object} xhr - The XMLHttpRequest object
1353					 * @param {string} status - The status of the request
1354					 * @param {string} error - The error message
1355					 * @param {Object} $form - The jQuery form object
1356					 * @param {Object} posted_data - The data that was posted
1357					 */
1358					handle_ajax_error: function (
1359						xhr,
1360						status,
1361						error,
1362						$form,
1363						posted_data
1364					) {
1365						// Re-enable submit button
1366						$form.find(".ur-submit-button").prop("disabled", false);
1367
1368						if (
1369							$form.find(".field-membership").length > 0 ||
1370							$form.find(".field-stripe_gateway").length > 0 ||
1371							$form.find(".field-authorize_net_gateway").length >
1372								0
1373						) {
1374							$form
1375								.find(".ur-submit-button")
1376								.find("span")
1377								.removeClass("ur-front-spinner");
1378							// Show fallback message
1379							form.show_message(
1380								user_registration_params.ajax_form_submit_error,
1381								"error",
1382								$form,
1383								"1"
1384							);
1385						} else {
1386							// Add all necessary hidden fields for fallback submission
1387							if (
1388								$form.find('input[name="ur_fallback_submit"]')
1389									.length === 0
1390							) {
1391								$form.append(
1392									'<input type="hidden" name="ur_fallback_submit" value="1" />'
1393								);
1394							}
1395
1396							// Add action field
1397							if (
1398								$form.find('input[name="action"]').length === 0
1399							) {
1400								$form.append(
1401									'<input type="hidden" name="action" value="user_registration_user_form_submit" />'
1402								);
1403							}
1404
1405							// Add form data
1406							if (
1407								$form.find('input[name="form_data"]').length ===
1408								0
1409							) {
1410								$form.append(
1411									'<input type="hidden" name="form_data" value="' +
1412										encodeURIComponent(
1413											posted_data.form_data
1414										) +
1415										'" />'
1416								);
1417							}
1418
1419							// Add captcha response
1420							if (
1421								posted_data.captchaResponse &&
1422								$form.find('input[name="captchaResponse"]')
1423									.length === 0
1424							) {
1425								$form.append(
1426									'<input type="hidden" name="captchaResponse" value="' +
1427										posted_data.captchaResponse +
1428										'" />'
1429								);
1430							}
1431
1432							// Add form ID
1433							if (
1434								posted_data.form_id &&
1435								$form.find('input[name="form_id"]').length === 0
1436							) {
1437								$form.append(
1438									'<input type="hidden" name="form_id" value="' +
1439										posted_data.form_id +
1440										'" />'
1441								);
1442							}
1443
1444							// Add registration language
1445							if (
1446								posted_data.registration_language &&
1447								$form.find(
1448									'input[name="registration_language"]'
1449								).length === 0
1450							) {
1451								$form.append(
1452									'<input type="hidden" name="registration_language" value="' +
1453										posted_data.registration_language +
1454										'" />'
1455								);
1456							}
1457
1458							// Submit the form traditionally
1459							$form[0].submit();
1460						}
1461					},
1462					/**
1463					 * Ajax form submission event.
1464					 *
1465					 */
1466					ajax_form_submit: function (posted_data) {
1467						var $form = $this;
1468
1469						$.ajax({
1470							url: user_registration_params.ajax_url,
1471							data: posted_data,
1472							type: "POST",
1473							async: true,
1474							error: function (xhr, status, error) {
1475								events.handle_ajax_error(
1476									xhr,
1477									status,
1478									error,
1479									$form,
1480									posted_data
1481								);
1482							},
1483							complete: function (ajax_response) {
1484								$(document.body).trigger(
1485									"user_registration_after_form_submit_completion"
1486								);
1487								var ajaxFlag = [];
1488								ajaxFlag["status"] = true;
1489
1490								var response_text = JSON.parse(
1491									ajax_response.responseText
1492								);
1493								if (
1494									response_text &&
1495									response_text.success &&
1496									posted_data &&
1497									posted_data.ur_authorize_net
1498								) {
1499									var response_data = response_text.data;
1500									var authorize_net_data = {
1501										ur_authorize_net:
1502											posted_data.ur_authorize_net
1503									};
1504									response_data = $.extend(
1505										{},
1506										response_data,
1507										authorize_net_data
1508									);
1509									response_text.data = response_data;
1510								}
1511								ajax_response.responseText =
1512									JSON.stringify(response_text);
1513
1514								$(document).trigger(
1515									"user_registration_frontend_before_ajax_complete_success_message",
1516									[ajax_response, ajaxFlag, $this]
1517								);
1518								if (ajaxFlag["status"]) {
1519									$this
1520										.find(".ur-submit-button")
1521										.find("span")
1522										.removeClass("ur-front-spinner");
1523
1524									var redirect_url = $this
1525										.find('input[name="ur-redirect-url"]')
1526										.val();
1527									var message = $('<ul class=""/>');
1528									var type = "error";
1529									var individual_field_message = false;
1530
1531									try {
1532										var response = JSON.parse(
1533											ajax_response.responseText
1534										);
1535
1536										var timeout =
1537											response &&
1538											response.data &&
1539											response.data.redirect_timeout !==
1540												undefined &&
1541											response.data.redirect_timeout !==
1542												null &&
1543											response.data.redirect_timeout !==
1544												""
1545												? response.data.redirect_timeout
1546												: 2000;
1547
1548										if (
1549											typeof response.success !==
1550												"undefined" &&
1551											response.success === true &&
1552											typeof response.data
1553												.paypal_redirect !== "undefined"
1554										) {
1555											window.setTimeout(function () {
1556												window.location =
1557													response.data.paypal_redirect;
1558											}, timeout);
1559										}
1560
1561										if (
1562											typeof response.success !==
1563												"undefined" &&
1564											response.success === true &&
1565											typeof response.data
1566												.mollie_redirect !== "undefined"
1567										) {
1568											window.setTimeout(function () {
1569												window.location =
1570													response.data.mollie_redirect;
1571											}, timeout);
1572										}
1573
1574										if (
1575											typeof response.success !==
1576												"undefined" &&
1577											response.success === true
1578										) {
1579											type = "message";
1580										}
1581
1582										if (type === "message") {
1583											// Membership/subscription registration: do not show "User successfully registered."; membership module shows "New member has been successfully created." only.
1584											if (
1585												response.data &&
1586												response.data
1587													.registration_type ===
1588													"membership"
1589											) {
1590												type = "membership_handled";
1591											}
1592										}
1593										if (type === "message") {
1594											$this
1595												.find(
1596													".user-registration-password-hint"
1597												)
1598												.remove();
1599											$this
1600												.find(
1601													".user-registration-password-strength"
1602												)
1603												.remove();
1604
1605											if (
1606												response.data
1607													.form_login_option ==
1608												"admin_approval"
1609											) {
1610												message.append(
1611													"<li>" +
1612														ursL10n.user_under_approval +
1613														"</li>"
1614												);
1615											} else if (
1616												response.data
1617													.form_login_option ==
1618													"email_confirmation" ||
1619												response.data
1620													.form_login_option ==
1621													"admin_approval_after_email_confirmation"
1622											) {
1623												message.append(
1624													"<li>" +
1625														ursL10n.user_email_pending +
1626														"</li>"
1627												);
1628											} else if (
1629												response.data
1630													.form_login_option ==
1631													"payment" &&
1632												typeof response.data.message !==
1633													"undefined"
1634											) {
1635												message.append(
1636													"<li>" +
1637														response.data.message +
1638														"</li>"
1639												);
1640											} else {
1641												message.append(
1642													"<li>" +
1643														(typeof response.data
1644															.message ===
1645															"undefined")
1646														? ursL10n.user_successfully_saved
1647														: response.data
1648																.message +
1649																"</li>"
1650												);
1651											}
1652
1653											if (
1654												"undefined" !==
1655												typeof response.data
1656													.auto_password_generation_success_message
1657											) {
1658												message.append(
1659													"<li>" +
1660														response.data
1661															.auto_password_generation_success_message +
1662														"</li>"
1663												);
1664											}
1665											$(".ur-input-count").text("0");
1666											if (
1667												!user_registration_params.ur_hold_data_before_redirection
1668											) {
1669												$this[0].reset();
1670											}
1671											if (
1672												$this.find("#profile_pic_url")
1673													.length
1674											) {
1675												$("#profile_pic_url").val("");
1676											}
1677
1678											jQuery("#billing_country").trigger(
1679												"change"
1680											);
1681											jQuery("#shipping_country").trigger(
1682												"change"
1683											);
1684
1685											if (
1686												"undefined" !==
1687												typeof response.data
1688													.role_based_redirect_url
1689											) {
1690												redirect_url =
1691													response.data
1692														.role_based_redirect_url;
1693											}
1694											if (
1695												typeof response.data
1696													.form_login_option !==
1697													"undefined" &&
1698												response.data
1699													.form_login_option ===
1700													"sms_verification"
1701											) {
1702												window.setTimeout(function () {
1703													if (
1704														typeof response.data
1705															.redirect_url !==
1706															"undefined" &&
1707														response.data
1708															.redirect_url
1709													) {
1710														window.location =
1711															response.data.redirect_url;
1712													}
1713												}, timeout);
1714											}
1715
1716											if (
1717												"undefined" !==
1718													typeof redirect_url &&
1719												redirect_url !== ""
1720											) {
1721												$(document).trigger(
1722													"user_registration_frontend_before_redirect_url",
1723													[redirect_url]
1724												);
1725
1726												window.setTimeout(function () {
1727													window.location =
1728														redirect_url;
1729												}, timeout);
1730											} else {
1731												if (
1732													typeof response.data
1733														.auto_login !==
1734														"undefined" &&
1735													response.data.auto_login
1736												) {
1737													$(document).trigger(
1738														"user_registration_frontend_before_auto_login"
1739													);
1740													window.setTimeout(
1741														function () {
1742															if (
1743																typeof response
1744																	.data
1745																	.redirect_url !==
1746																	"undefined" &&
1747																response.data
1748																	.redirect_url
1749															) {
1750																window.location =
1751																	response.data.redirect_url;
1752															} else {
1753																location.reload();
1754															}
1755														},
1756														timeout
1757													);
1758												}
1759											}
1760										} else if (type === "error") {
1761											if (
1762												typeof response.data.message ===
1763												"object"
1764											) {
1765												$.each(
1766													response.data.message,
1767													function (
1768														index,
1769														message_value
1770													) {
1771														if (
1772															message_value.hasOwnProperty(
1773																"individual"
1774															)
1775														) {
1776															var $field_id = [];
1777															$.each(
1778																$this
1779																	.find(
1780																		".ur-field-item"
1781																	)
1782																	.find(
1783																		".ur-frontend-field"
1784																	),
1785																function (
1786																	index
1787																) {
1788																	var $this =
1789																		$(this);
1790
1791																	if (
1792																		$this.hasClass(
1793																			"input-captcha-icon-radio"
1794																		)
1795																	) {
1796																		var data_id =
1797																			$this.attr(
1798																				"data-id"
1799																			);
1800
1801																		if (
1802																			!$field_id.includes(
1803																				data_id
1804																			)
1805																		) {
1806																			$field_id.push(
1807																				data_id
1808																			);
1809																		}
1810																	} else {
1811																		var $id =
1812																			$this.attr(
1813																				"id"
1814																			);
1815																		$field_id.push(
1816																			$id
1817																		);
1818																	}
1819																}
1820															);
1821
1822															var field_name = "";
1823
1824															$.each(
1825																message_value,
1826																function (
1827																	index,
1828																	value
1829																) {
1830																	var repeater_field_name =
1831																		"";
1832																	var repeater_row_id =
1833																		"";
1834
1835																	if (
1836																		message_value.hasOwnProperty(
1837																			"repeater_field_name"
1838																		)
1839																	) {
1840																		repeater_field_name =
1841																			message_value.repeater_field_name;
1842																		repeater_row_id =
1843																			message_value.row_id.replace(
1844																				"row_",
1845																				""
1846																			);
1847																		index =
1848																			index +
1849																			"_" +
1850																			repeater_row_id;
1851																	}
1852
1853																	if (
1854																		$field_id.includes(
1855																			index
1856																		)
1857																	) {
1858																		field_name =
1859																			index;
1860
1861																		var error_message =
1862																			'<label id="' +
1863																			index +
1864																			"-error" +
1865																			'" class="user-registration-error" for="' +
1866																			index +
1867																			'">' +
1868																			value +
1869																			"</label>";
1870
1871																		var wrapper =
1872																			"";
1873
1874																		if (
1875																			$this.find(
1876																				".ur-repeater-row[data-repeater-field-name='" +
1877																					repeater_field_name +
1878																					"'][data-repeater-row='" +
1879																					repeater_row_id +
1880																					"'] "
1881																			)
1882																				.length >
1883																			0
1884																		) {
1885																			wrapper =
1886																				$this
1887																					.find(
1888																						".ur-repeater-row[data-repeater-field-name='" +
1889																							repeater_field_name +
1890																							"'][data-repeater-row='" +
1891																							repeater_row_id +
1892																							"'] "
1893																					)
1894																					.find(
1895																						".ur-field-item"
1896																					)
1897																					.find(
1898																						"input[id='" +
1899																							index +
1900																							"'], textarea[id='" +
1901																							index +
1902																							"']"
1903																					);
1904																		} else {
1905																			wrapper =
1906																				$this
1907																					.find(
1908																						".ur-form-row"
1909																					)
1910																					.find(
1911																						".ur-field-item"
1912																					)
1913																					.find(
1914																						"input[id='" +
1915																							index +
1916																							"'], textarea[id='" +
1917																							index +
1918																							"']"
1919																					);
1920																		}
1921
1922																		wrapper
1923																			.closest(
1924																				".ur-field-item"
1925																			)
1926																			.find(
1927																				".user-registration-error"
1928																			)
1929																			.remove();
1930																		wrapper
1931																			.closest(
1932																				".form-row"
1933																			)
1934																			.append(
1935																				error_message
1936																			);
1937																		individual_field_message = true;
1938																	}
1939																}
1940															);
1941															$(document).trigger(
1942																"ur_handle_field_error_messages",
1943																[
1944																	$this,
1945																	field_name
1946																]
1947															);
1948														} else {
1949															message.append(
1950																"<li>" +
1951																	message_value +
1952																	"</li>"
1953															);
1954														}
1955													}
1956												);
1957											} else {
1958												message.append(
1959													"<li>" +
1960														response.data.message +
1961														"</li>"
1962												);
1963											}
1964										}
1965									} catch (e) {
1966										message.append(
1967											$("<li></li>").text(e.message)
1968										);
1969									}
1970
1971									var success_message_position = JSON.parse(
1972										ajax_response.responseText
1973									).data.success_message_positon;
1974
1975									if (!individual_field_message) {
1976										form.show_message(
1977											message,
1978											type,
1979											$this,
1980											success_message_position
1981										);
1982									} else {
1983										var $field_id = [];
1984
1985										$.each(
1986											$this
1987												.find(".ur-field-item")
1988												.find(".ur-frontend-field"),
1989											function (index) {
1990												var $this = $(this);
1991
1992												var $id = $this.attr("id");
1993												$field_id.push($id);
1994											}
1995										);
1996										var field_name = "";
1997
1998										$.each(
1999											response.data.message,
2000											function (index, value) {
2001												if ($field_id.includes(index)) {
2002													field_name = index;
2003													var error_message =
2004														'<label id="' +
2005														index +
2006														"-error" +
2007														'" class="user-registration-error" for="' +
2008														index +
2009														'">' +
2010														value +
2011														"</label>";
2012
2013													var wrapper = $this
2014														.find(".ur-field-item")
2015														.find(
2016															"input[id='" +
2017																index +
2018																"'], textarea[id='" +
2019																index +
2020																"']"
2021														);
2022
2023													wrapper
2024														.closest(
2025															".ur-field-item"
2026														)
2027														.find(
2028															".user-registration-error"
2029														)
2030														.remove();
2031													wrapper
2032														.closest(".form-row")
2033														.append(error_message);
2034												}
2035											}
2036										);
2037										$(document).trigger(
2038											"ur_handle_field_error_messages",
2039											[$this, field_name]
2040										);
2041									}
2042
2043									// Check the position set by the admin and scroll to the message postion accordingly.
2044									if ("1" === success_message_position) {
2045										// Scroll to the bottom on ajax submission complete.
2046										$(window).scrollTop(
2047											$this
2048												.find(".ur-button-container")
2049												.offset().top
2050										);
2051									} else {
2052										// Scroll to the top on ajax submission complete.
2053										$(window).scrollTop(
2054											$this
2055												.closest(".ur-frontend-form")
2056												.offset().top
2057										);
2058									}
2059
2060									$(document).trigger(
2061										"user_registration_frontend_after_ajax_complete",
2062										[
2063											ajax_response.responseText,
2064											type,
2065											$this
2066										]
2067									);
2068									$this
2069										.find(".ur-submit-button")
2070										.prop("disabled", false);
2071								}
2072
2073								$(".coupon-message").css({
2074									display: "none"
2075								});
2076							}
2077						});
2078					},
2079					/**
2080					 * Handles edit-profile ajax form submission event.
2081					 *
2082					 * @since  1.8.5
2083					 */
2084					edit_profile_event: function () {
2085						if (
2086							!user_registration_params.ajax_submission_on_edit_profile
2087						) {
2088							return;
2089						}
2090						$("form.user-registration-EditProfileForm")
2091							.off("submit")
2092							.on("submit", function (event) {
2093								event.preventDefault();
2094								event.stopImmediatePropagation();
2095								var $this = $(this);
2096
2097								// Validator messages.
2098								$.extend($.validator.messages, {
2099									required:
2100										user_registration_params.message_required_fields,
2101									url: user_registration_params.message_url_fields,
2102									email: user_registration_params.message_email_fields,
2103									number: user_registration_params.message_number_fields
2104								});
2105
2106								var $el = $this.find(".ur-smart-phone-field");
2107
2108								if ("true" === $el.attr("aria-invalid")) {
2109									var wrapper = $el.closest("p.form-row");
2110									wrapper
2111										.find("#" + $el.data("id") + "-error")
2112										.remove();
2113									var phone_error_msg_dom =
2114										'<label id="' +
2115										$el.data("id") +
2116										"-error" +
2117										'" class="user-registration-error" for="' +
2118										$el.data("id") +
2119										'">' +
2120										user_registration_params.message_validate_phone_number +
2121										"</label>";
2122									wrapper.append(phone_error_msg_dom);
2123									wrapper
2124										.find("#" + $el.data("id"))
2125										.attr("aria-invalid", true);
2126									return true;
2127								}
2128
2129								var exist_detail = $this
2130									.find(".uraf-profile-picture-upload")
2131									.find(".user-registration-error").length;
2132
2133								if (1 === exist_detail) {
2134									var profile = $this
2135										.find(".uraf-profile-picture-upload")
2136										.find(".uraf-profile-picture-input");
2137									var wrapper = $this.find(
2138										".uraf-profile-picture-upload"
2139									);
2140									wrapper
2141										.find(
2142											"#" +
2143												profile.attr("name") +
2144												"-error"
2145										)
2146										.remove();
2147									wrapper
2148										.find(
2149											".uraf-profile-picture-file-error"
2150										)
2151										.remove();
2152									var error_message =
2153										'<label id="' +
2154										profile.attr("name") +
2155										"-error" +
2156										'" class="user-registration-error" for="' +
2157										profile.attr("name") +
2158										'">' +
2159										user_registration_params.message_required_fields +
2160										"</label>";
2161									wrapper
2162										.find(
2163											"button.wp_uraf_profile_picture_upload"
2164										)
2165										.after(error_message);
2166								}
2167
2168								if (!$this.valid()) {
2169									return false;
2170								}
2171
2172								var profile_picture_error = $this
2173									.find(
2174										".user-registration-profile-picture-error"
2175									)
2176									.find(".user-registration-error").length;
2177								if (1 === profile_picture_error) {
2178									return false;
2179								}
2180
2181								event.preventDefault();
2182								$this
2183									.find(".user-registration-submit-Button")
2184									.prop("disabled", true);
2185
2186								// Remove word added by form filler in file upload field during submission
2187								var file_upload =
2188									$this.find(".urfu-file-input");
2189
2190								form.missing_attachment_handler(file_upload);
2191
2192								var form_data;
2193								var form_nonce = "0";
2194
2195								try {
2196									form_data = form.get_form_data();
2197
2198									// Handle profile picture
2199									var profile_picture_url =
2200										$("#profile_pic_url").val();
2201
2202									form_data.push({
2203										value: profile_picture_url,
2204										field_name:
2205											"user_registration_profile_pic_url"
2206									});
2207
2208									form_data = JSON.stringify(form_data);
2209								} catch (ex) {
2210									form_data = "";
2211								}
2212
2213								var data = {
2214									action: "user_registration_update_profile_details",
2215									security:
2216										user_registration_params.user_registration_profile_details_save,
2217									form_data: form_data
2218								};
2219
2220								$(document).trigger(
2221									"user_registration_frontend_before_edit_profile_submit",
2222									[data, $this]
2223								);
2224
2225								$this
2226									.find(".user-registration-submit-Button")
2227									.find("span")
2228									.addClass("ur-front-spinner");
2229
2230								$.ajax({
2231									type: "POST",
2232									url: user_registration_params.ajax_url,
2233									dataType: "JSON",
2234									data: data,
2235									complete: function (ajax_response) {
2236										$(document).trigger(
2237											"user_registration_process_before_edit_profile_submit_completion"
2238										);
2239										$this
2240											.find("span.ur-front-spinner")
2241											.removeClass("ur-front-spinner");
2242										$this
2243											.closest(".user-registration")
2244											.find(".user-registration-error")
2245											.remove();
2246										$this
2247											.closest(".user-registration")
2248											.find(".user-registration-message")
2249											.remove();
2250
2251										var message = $('<ul class=""/>');
2252										var type = "error";
2253
2254										try {
2255											var response = JSON.parse(
2256												ajax_response.responseText
2257											);
2258
2259											if (
2260												typeof response.success !==
2261													"undefined" &&
2262												response.success === true
2263											) {
2264												type = "message";
2265												if (
2266													typeof response.data
2267														.profile_pic_id !==
2268													"undefined"
2269												) {
2270													$this
2271														.find(
2272															".ur_removed_profile_pic"
2273														)
2274														.val("");
2275
2276													if (
2277														$this.find(
2278															".uraf-profile-picture-remove"
2279														).length > 0
2280													) {
2281														$this
2282															.find(
2283																".uraf-profile-picture-remove"
2284															)
2285															.data(
2286																"attachment-id",
2287																response.data
2288																	.profile_pic_id
2289															);
2290													}
2291													if (
2292														$this.find(
2293															".profile-pic-remove"
2294														).length > 0
2295													) {
2296														$this
2297															.find(
2298																".profile-pic-remove"
2299															)
2300															.data(
2301																"attachment-id",
2302																response.data
2303																	.profile_pic_id
2304															);
2305													}
2306												}
2307											}
2308
2309											var individual_field_message = false;
2310											if (
2311												typeof response.data.message ===
2312												"object"
2313											) {
2314												$.each(
2315													response.data.message,
2316													function (
2317														index,
2318														message_value
2319													) {
2320														if (
2321															message_value.hasOwnProperty(
2322																"individual"
2323															)
2324														) {
2325															var $field_id = [];
2326															$.each(
2327																$this
2328																	.find(
2329																		".ur-form-row"
2330																	)
2331																	.find(
2332																		".ur-field-item"
2333																	)
2334																	.find(
2335																		".ur-edit-profile-field"
2336																	),
2337																function (
2338																	index
2339																) {
2340																	var $this =
2341																		$(this);
2342																	var $id =
2343																		$this.attr(
2344																			"id"
2345																		);
2346																	$field_id.push(
2347																		$id
2348																	);
2349																}
2350															);
2351
2352															$.each(
2353																message_value,
2354																function (
2355																	index,
2356																	value
2357																) {
2358																	var repeater_field_name =
2359																		"";
2360																	var repeater_row_id =
2361																		"";
2362
2363																	if (
2364																		message_value.hasOwnProperty(
2365																			"repeater_field_name"
2366																		)
2367																	) {
2368																		repeater_field_name =
2369																			message_value.repeater_field_name;
2370																		repeater_row_id =
2371																			message_value.row_id.replace(
2372																				"row_",
2373																				""
2374																			);
2375																		index =
2376																			"user_registration_" +
2377																			index +
2378																			"_" +
2379																			repeater_row_id;
2380																	} else {
2381																		index =
2382																			index.indexOf(
2383																				"user_registration_"
2384																			) ===
2385																			-1
2386																				? "user_registration_" +
2387																					index
2388																				: index;
2389																	}
2390
2391																	if (
2392																		$field_id.includes(
2393																			index
2394																		)
2395																	) {
2396																		var error_message =
2397																			'<label id="' +
2398																			index +
2399																			"-error" +
2400																			'" class="user-registration-error" for="' +
2401																			index +
2402																			'">' +
2403																			value +
2404																			"</label>";
2405																		var wrapper =
2406																			$this.find(
2407																				".ur-form-row"
2408																			);
2409
2410																		if (
2411																			wrapper.hasClass(
2412																				"ur-repeater-row"
2413																			)
2414																		) {
2415																			wrapper =
2416																				wrapper
2417																					.find(
2418																						".ur-repeater-row[data-repeater-field-name='" +
2419																							repeater_field_name +
2420																							"'][data-repeater-row='" +
2421																							repeater_row_id +
2422																							"'] "
2423																					)
2424																					.find(
2425																						".ur-field-item"
2426																					)
2427																					.find(
2428																						"input[id='" +
2429																							index +
2430																							"'], textarea[id='" +
2431																							index +
2432																							"']"
2433																					);
2434																		} else {
2435																			wrapper =
2436																				wrapper
2437																					.find(
2438																						".ur-field-item"
2439																					)
2440																					.find(
2441																						"input[id='" +
2442																							index +
2443																							"'], textarea[id='" +
2444																							index +
2445																							"']"
2446																					);
2447																		}
2448
2449																		wrapper
2450																			.closest(
2451																				".form-row"
2452																			)
2453																			.append(
2454																				error_message
2455																			);
2456																		individual_field_message = true;
2457																	}
2458																}
2459															);
2460														} else {
2461															message.append(
2462																"<li>" +
2463																	message_value +
2464																	"</li>"
2465															);
2466														}
2467													}
2468												);
2469											} else {
2470												message.append(
2471													"<li>" +
2472														response.data.message +
2473														"</li>"
2474												);
2475												if (
2476													undefined !==
2477													response.data
2478														.userEmailPendingMessage
2479												) {
2480													$(
2481														".user-registration-info.user-email-change-update-notice"
2482													).remove();
2483													form.show_message(
2484														$(
2485															'<ul class=""/>'
2486														).append(
2487															"<li>" +
2488																response.data
2489																	.userEmailUpdateMessage +
2490																"</li>"
2491														),
2492														"info user-email-change-update-notice",
2493														$this,
2494														"0"
2495													);
2496
2497													if (
2498														$(
2499															"input#user_registration_user_email"
2500														).next(
2501															"div.email-updated"
2502														).length
2503													) {
2504														$(
2505															"input#user_registration_user_email"
2506														)
2507															.next(
2508																"div.email-updated"
2509															)
2510															.remove();
2511													}
2512													$(
2513														response.data
2514															.userEmailPendingMessage
2515													).insertAfter(
2516														$(
2517															"input#user_registration_user_email"
2518														)
2519													);
2520													$(
2521														"input#user_registration_user_email"
2522													).val(
2523														response.data
2524															.oldUserEmail
2525													);
2526												}
2527											}
2528										} catch (e) {
2529											message.append(
2530												$("<li></li>").text(e.message)
2531											);
2532										}
2533
2534										if (!individual_field_message) {
2535											form.show_message(
2536												message,
2537												type,
2538												$this,
2539												"0"
2540											);
2541										}
2542										// Add trigger to handle functionalities that may be needed after edit-profile ajax submission submissions.
2543										$(document).trigger(
2544											"user_registration_edit_profile_after_ajax_complete",
2545											[ajax_response, $this]
2546										);
2547										$this
2548											.find(
2549												".user-registration-submit-Button"
2550											)
2551											.prop("disabled", false);
2552
2553										// Scroll yo the top on ajax submission complete.
2554										$(window).scrollTop(
2555											$(".user-registration").position()
2556										);
2557									}
2558								}).fail(function () {
2559									form.show_message(
2560										"<p>" +
2561											user_registration_params.ajax_form_submit_error +
2562											"</p>",
2563										"error",
2564										$this,
2565										"1"
2566									);
2567									$this
2568										.find(
2569											".user-registration-submit-Button"
2570										)
2571										.prop("disabled", false);
2572									return;
2573								});
2574							});
2575					}
2576				};
2577				form.init();
2578
2579				if ($(".user-registration-EditProfileForm ").length > 0) {
2580					form.get_form_data(
2581						$(".user-registration-EditProfileForm ").data("form-id")
2582					);
2583				}
2584
2585				events.init();
2586			});
2587		};
2588
2589		$(function () {
2590			// Initialize the flatpickr when the document is ready to be manipulated.
2591			$(document).ready(function () {
2592				// Handle user registration form submit event.
2593				$(".ur-submit-button").on("click", function () {
2594					$(this).closest("form.register").ur_form_submission();
2595				});
2596
2597				if (
2598					user_registration_frontend_utils.ur_get_cookie(
2599						"urm_toast_content"
2600					) &&
2601					$(".user-registration-page .notice-container").length === 0
2602				) {
2603					$(document)
2604						.find(".user-registration-page")
2605						.prepend(
2606							'<div class="user-registration-membership-notice__container">' +
2607								'<div class="ur-toaster user-registration-membership-notice__red">' +
2608									'<span class="user-registration-membership-notice__message"></span>' +
2609									'<span class="user-registration-membership__close_notice">&times;</span>' +
2610								"</div>" +
2611							"</div>"
2612						);
2613				}
2614
2615				var urm_toast_success_message =
2616					user_registration_frontend_utils.ur_get_cookie(
2617						"urm_toast_success_message"
2618					);
2619
2620				// Displays the toast message.
2621				user_registration_frontend_utils.show_success_message(
2622					urm_toast_success_message
2623				);
2624
2625				$(".user-registration-membership__close_notice").on(
2626					"click",
2627					function () {
2628						$(
2629							".user-registration-membership-notice__container"
2630						).hide();
2631					}
2632				);
2633
2634				// Handle edit-profile form submit event.
2635				$(
2636					"input[name='save_account_details'], button[name='save_account_details']"
2637				)
2638					.off("click")
2639					.on("click", function (event) {
2640						event.preventDefault();
2641						// Check if the form is edit-profile form and check if ajax submission on edit profile is enabled.
2642						if (
2643							$(".ur-frontend-form")
2644								.find("form.edit-profile")
2645								.hasClass("user-registration-EditProfileForm")
2646						) {
2647							$(
2648								"form.user-registration-EditProfileForm"
2649							).ur_form_submission();
2650						}
2651						if (
2652							user_registration_params.ajax_submission_on_edit_profile
2653						) {
2654							$(this).submit();
2655						} else {
2656							$(this).closest("form")[0].submit();
2657						}
2658					});
2659				if ($(".ur-flatpickr-field").length) {
2660					// create an array to store the flatpickr instances.
2661					var flatpickrInstances = [];
2662					$(".ur-flatpickr-field").each(function () {
2663						var field = $(this);
2664						// check if flatpickr has already been initialized for the field.
2665						var instance = flatpickrInstances.find(function (i) {
2666							return i.element == field[0];
2667						});
2668
2669						if (instance) {
2670							// flatpickr has already been initialized for the field, so open the instance.
2671							instance.open();
2672						} else {
2673							var field_id = field.attr("data-id");
2674							var formated_date = field
2675								.closest(".ur-field-item")
2676								.find("#formated_date")
2677								.val();
2678
2679							if (0 < $(".ur-frontend-form").length) {
2680								var date_selector = $(
2681									".ur-frontend-form #" + field_id
2682								)
2683									.attr("type", "text")
2684									.val(formated_date);
2685							} else {
2686								var date_selector = $(
2687									".woocommerce-MyAccount-content #" +
2688										field_id
2689								)
2690									.attr("type", "text")
2691									.val(formated_date);
2692							}
2693
2694							field.attr(
2695								"data-date-format",
2696								date_selector.data("date-format")
2697							);
2698
2699							if (date_selector.data("mode")) {
2700								field.attr("data-mode", "range");
2701							}
2702							field.attr(
2703								"data-locale",
2704								date_selector.data("locale")
2705							);
2706							field.attr(
2707								"data-min-date",
2708								date_selector.data("min-date")
2709							);
2710							field.attr(
2711								"data-max-date",
2712								date_selector.data("max-date")
2713							);
2714							field.attr("data-default-date", formated_date);
2715
2716							// flatpickr has not been initialized for the field, so create a new instance.
2717							instance = field.flatpickr({
2718								disableMobile: true,
2719								onChange: function (
2720									selectedDates,
2721									dateString,
2722									instance
2723								) {
2724									$("#" + field_id).val(dateString);
2725								}
2726							});
2727
2728							flatpickrInstances.push(instance);
2729						}
2730					});
2731				}
2732			});
2733
2734			// Handel WYSIWYG field client side validation.
2735			$(document).on("tinymce-editor-init", function (event, editor) {
2736				var $editorContainer = $(editor.getContainer());
2737				var containerId = $editorContainer.attr("id");
2738
2739				var hiddenEditor = $("#" + containerId)
2740					.closest(".form-row")
2741					.find("[data-label = 'WYSIWYG']");
2742
2743				editor.on("keyup", function (e) {
2744					hiddenEditor.val(tinyMCE.activeEditor.getContent());
2745				});
2746			});
2747
2748			$(".ur-frontend-form").each(function () {
2749				var $registration_form = $(this).find("form.register");
2750
2751				$registration_form.on(
2752					"focusout",
2753					"#user_pass, #password_1",
2754					function () {
2755						$this = $(this);
2756						var this_name = $(this).attr("name");
2757						var this_data_id = $(this).data("id");
2758						var enable_strength_password = $this
2759							.closest("form")
2760							.attr("data-enable-strength-password");
2761
2762						if (enable_strength_password) {
2763							var wrapper = $this.closest("form");
2764							var minimum_password_strength = wrapper.attr(
2765								"data-minimum-password-strength"
2766							);
2767							var disallowedListArray = [];
2768							if (
2769								wp.passwordStrength &&
2770								"function" ===
2771									typeof wp.passwordStrength
2772										.userInputDisallowedList
2773							) {
2774								disallowedListArray =
2775									wp.passwordStrength.userInputDisallowedList();
2776							} else if (
2777								wp.passwordStrength &&
2778								"function" ===
2779									typeof wp.passwordStrength
2780										.userInputBlacklist
2781							) {
2782								disallowedListArray =
2783									wp.passwordStrength.userInputBlacklist();
2784							}
2785
2786							disallowedListArray.push(
2787								wrapper
2788									.find('input[data-id="user_email"]')
2789									.val()
2790							); // Add email address in disallowedList.
2791							disallowedListArray.push(
2792								wrapper
2793									.find('input[data-id="user_login"]')
2794									.val()
2795							); // Add username in disallowedList.
2796
2797							var strength = wp.passwordStrength?.meter(
2798								$this.val(),
2799								disallowedListArray
2800							);
2801
2802							if (minimum_password_strength === "4") {
2803								strength = customPasswordChecks($this.val());
2804							}
2805
2806							if (strength < minimum_password_strength) {
2807								if ($this.val() !== "") {
2808									wrapper
2809										.find("#" + this_data_id + "-error")
2810										.remove();
2811									var error_msg_dom =
2812										'<label id="' +
2813										this_data_id +
2814										'-error" class="user-registration-error" for="' +
2815										this_name +
2816										'">' +
2817										ursL10n.password_strength_error +
2818										".</label>";
2819									wrapper
2820										.find(
2821											".user-registration-password-hint"
2822										)
2823										.after(error_msg_dom);
2824								}
2825							}
2826						}
2827					}
2828				);
2829			});
2830		});
2831		/**
2832		 * Set the value of count in already exist details of field textarea.
2833		 */
2834		$(function () {
2835			$("textarea").each(function () {
2836				/**
2837				 * show the character and word count in textarea field.
2838				 */
2839				$(this).on("input", user_registration_count);
2840				var input_count;
2841				var selected_area_field = $(this).closest(".ur-field-item");
2842				if (selected_area_field.find(".ur-input-count").length > 0) {
2843					var selected_area_text = $(this).val().trim();
2844					if (
2845						selected_area_field
2846							.find(".ur-input-count")
2847							.data("count-type") === "characters"
2848					) {
2849						input_count = selected_area_text.length;
2850					} else {
2851						input_count =
2852							selected_area_text === ""
2853								? 0
2854								: selected_area_text.split(/\s+/).length;
2855					}
2856				}
2857				selected_area_field.find(".ur-input-count").text(input_count);
2858			});
2859		});
2860		/**
2861		 * Append a country option and Remove it on click, if the country is not allowed.
2862		 */
2863		$(function () {
2864			if (
2865				$(
2866					".user-registration-EditProfileForm.edit-profile .field-country"
2867				).length > 0
2868			) {
2869				$(".field-country").each(function () {
2870					var option_value = $(this)
2871						.find(".ur-data-holder")
2872						.data("option-value");
2873					var option_html = $(this)
2874						.find(".ur-data-holder")
2875						.data("option-html");
2876					var $select = $(this).find("select");
2877
2878					if (option_value && option_html) {
2879						if (
2880							$select.find('option[value="' + option_value + '"]')
2881								.length === 0
2882						) {
2883							$select.append(
2884								"<option class='ur-remove' selected='selected' value='" +
2885									option_value +
2886									"'>" +
2887									option_html +
2888									"</option>"
2889							);
2890						}
2891						$(this).on("click", function () {
2892							$(this).find(".ur-remove").remove();
2893						});
2894					}
2895				});
2896			}
2897		});
2898
2899		$(document).on("urm_show_action_message", function (e, data) {
2900			if (data.type == "error") {
2901				user_registration_frontend_utils.show_error_message(
2902					data.message
2903				);
2904			} else {
2905				user_registration_frontend_utils.show_success_message(
2906					data.message
2907				);
2908			}
2909		});
2910	};
2911	function user_registration_count() {
2912		$("textarea").each(function () {
2913			var input_count;
2914			var selected_area_field = $(this).closest(".ur-field-item");
2915			if (selected_area_field.find(".ur-input-count").length > 0) {
2916				var selected_area_text = $(this).val().trim();
2917				if (
2918					selected_area_field
2919						.find(".ur-input-count")
2920						.data("count-type") === "characters"
2921				) {
2922					input_count = selected_area_text.length;
2923				} else {
2924					input_count =
2925						selected_area_text === ""
2926							? 0
2927							: selected_area_text.split(/\s+/).length;
2928				}
2929			}
2930			selected_area_field.find(".ur-input-count").text(input_count);
2931		});
2932	}
2933
2934	/**
2935	 * @since 2.0.0
2936	 *
2937	 * To check and uncheck all the option in checkbox.
2938	 */
2939	$(function () {
2940		$(".input-checkbox").each(function () {
2941			var checkAll = $(this).attr("data-id");
2942			if ("undefined" !== typeof checkAll) {
2943				if (
2944					$('input[name="' + checkAll + '[]"]:checked').length ==
2945					$('[data-id = "' + checkAll + '" ]').length
2946				) {
2947					$('[data-check = "' + checkAll + '" ]').prop(
2948						"checked",
2949						true
2950					);
2951				}
2952			}
2953		});
2954
2955		$('input[type="checkbox"]#checkall').on("click", function () {
2956			var checkAll = $(this).attr("data-check");
2957			if ("undefined" !== typeof checkAll) {
2958				$('[data-id = "' + checkAll + '[]" ]').prop(
2959					"checked",
2960					$(this).prop("checked")
2961				);
2962			}
2963		});
2964
2965		$(".input-checkbox").on("change", function () {
2966			var checkAll = $(this).attr("data-id");
2967
2968			if ("undefined" !== typeof checkAll) {
2969				checkAll = checkAll.replace("[]", "");
2970
2971				if ($(this).prop("checked") === false) {
2972					$('[data-check = "' + checkAll + '" ]').prop(
2973						"checked",
2974						false
2975					);
2976				}
2977
2978				if (
2979					$('input[name="' + checkAll + '[]"]:checked').length ==
2980					$('[data-id = "' + checkAll + '" ]').length
2981				) {
2982					$('[data-check = "' + checkAll + '" ]').prop(
2983						"checked",
2984						true
2985					);
2986				}
2987			}
2988		});
2989	});
2990	user_registration_form_init();
2991
2992	/**
2993	 * Reinitialize the form again after page is fully loaded,
2994	 * in order to support third party popup plugins.
2995	 *
2996	 * @since 1.9.0
2997	 */
2998	$(window).on("load", function () {
2999		user_registration_form_init();
3000	});
3001	$(window).on("user_registration_repeater_modified", function () {
3002		user_registration_form_init();
3003	});
3004
3005	/**
3006	 * Reinitializes the form again in the elementor popup.
3007	 *
3008	 * @since 4.2.1
3009	 */
3010	window.addEventListener("load", function () {
3011		window.addEventListener("elementor/popup/show", function () {
3012			var forms = document.querySelectorAll(
3013				".elementor-popup-modal form.register:not(.elementor)"
3014			);
3015			forms.forEach(function (form) {
3016				user_registration_form_init();
3017				form.classList.add("elementor"); // Add class to prevent reinitialization
3018			});
3019		});
3020	});
3021
3022	$(document).on(
3023		"click",
3024		"#login-registration--login,#login-registration--registration",
3025		function () {
3026			var action = $(this).data("action");
3027			if (action === "login" && !$(this).hasClass("active")) {
3028				$(this).addClass("active");
3029				$("#login-registration--registration").removeClass("active");
3030				$(".login-registration")
3031					.find(".ur-login-form")
3032					.removeClass("hidden");
3033				$(".login-registration")
3034					.find(".ur-registration-form")
3035					.addClass("hidden");
3036			}
3037			if (action === "registration" && !$(this).hasClass("active")) {
3038				$(this).addClass("active");
3039				$("#login-registration--login").removeClass("active");
3040				$(".login-registration")
3041					.find(".ur-login-form")
3042					.addClass("hidden");
3043				$(".login-registration")
3044					.find(".ur-registration-form")
3045					.removeClass("hidden");
3046			}
3047		}
3048	);
3049
3050	$(document).on("change", ".ur-field-address-country", function (e) {
3051		e.stopPropagation();
3052		e.preventDefault();
3053
3054		var $el = $(this);
3055		var fieldId = $el.data("id");
3056		var country = $el.val();
3057		var stateEnable = $el.data("state-enabled");
3058
3059		if (!stateEnable) {
3060			return;
3061		}
3062		var data = {
3063			action: "user_registration_update_state_field",
3064			security:
3065				user_registration_params.user_registration_update_state_field,
3066			country: country
3067		};
3068		var $stateWrapper = $el.siblings(
3069			".ur-field-address-state-outer-wrapper"
3070		);
3071
3072		$.ajax({
3073			type: "POST",
3074			url: user_registration_params.ajax_url,
3075			data: data,
3076			beforeSend: function () {
3077				$stateWrapper.empty();
3078				$stateWrapper.append('<span class="ur-front-spinner"></span>');
3079			},
3080			success: function (response) {
3081				var $stateElement;
3082
3083				if (response.success && response.data.has_state && '' !== response.data.state) {
3084					var $select = $('<select class="ur-field-address-state select ur-frontend-field"></select>');
3085					$select.attr('name', fieldId + '_state');
3086					$select.append($($.parseHTML(response.data.state, null, false)).filter('option'));
3087					$stateElement = $select;
3088				} else {
3089					var $input = $('<input type="text" class="ur-field-address-state input-text ur-frontend-field"/>');
3090					$input.attr('name', fieldId + '_state');
3091					$stateElement = $input;
3092				}
3093
3094				$( document ).find( '.ur-front-spinner' ).remove();
3095
3096				$stateWrapper.append($stateElement);
3097				$stateElement.trigger('change');
3098			}
3099		});
3100	});
3101
3102	/**
3103	 * Apply tax calculation
3104	 *
3105	 * @param $el
3106	 * @param country
3107	 * @param country_change
3108	 * @param $stateElement
3109	 *
3110	 * @since 5.0.0
3111	 */
3112	function apply_tax_calculation(
3113		$el,
3114		country,
3115		country_change,
3116		$stateElement
3117	) {
3118		var state = "";
3119		var regions = user_registration_params.regions_list.regions[country];
3120		var defaultRate = regions && regions.rate != null ? regions.rate : 0;
3121		var membershipData = {};
3122
3123		if ($(document).find("#urm-membership-list").length) {
3124			membershipData = getMembershipData();
3125		} else {
3126			membershipData.total = $('.ur-total-amount[type="hidden"]').val();
3127		}
3128
3129		if (country_change) {
3130			state = $stateElement.find("option:first").val();
3131		} else {
3132			state = $stateElement.val();
3133		}
3134
3135		/**
3136		 * Check if country exists in regions list
3137		 * then check for states
3138		 * else apply default rate
3139		 */
3140		if (
3141			user_registration_params.regions_list.regions.hasOwnProperty(
3142				country
3143			)
3144		) {
3145			if (regions.hasOwnProperty("states") && "" !== state) {
3146				var states = regions.states;
3147
3148				if (states.hasOwnProperty(state)) {
3149					let taxRate = states[state];
3150					calculate_total(membershipData, taxRate);
3151				} else {
3152					if (defaultRate !== undefined && defaultRate !== "") {
3153						calculate_total(membershipData, defaultRate);
3154					}
3155				}
3156			} else {
3157				calculate_total(membershipData, defaultRate);
3158			}
3159		} else {
3160			calculate_total(membershipData, defaultRate);
3161		}
3162		$("#ur-local-currency-switch-currency").trigger("change");
3163	}
3164
3165	/**
3166	 * Get membership data
3167	 *
3168	 * @returns {{}}
3169	 *
3170	 * @since 5.0.0
3171	 */
3172	function getMembershipData() {
3173		var user_data = {};
3174		var form_inputs = $("#ur-membership-registration").find(
3175			"input.ur_membership_input_class"
3176		);
3177
3178		form_inputs = convert_to_array(form_inputs);
3179
3180		form_inputs.forEach(function (item) {
3181			var $this = $(item);
3182
3183			if ($this.attr("name") !== undefined) {
3184				var name = $this.attr("name").toLowerCase().replace("urm_", "");
3185				user_data[name] = $this.val();
3186			}
3187		});
3188
3189		var membership_input = $('input[name="urm_membership"]:checked');
3190		user_data.membership = membership_input.val();
3191		user_data.payment_method = "free";
3192		user_data.total = membership_input.data("urm-pg-calculated-amount");
3193		if (membership_input.data("urm-pg-type") !== "free") {
3194			user_data.payment_method = $(
3195				'input[name="urm_payment_method"]:checked:visible'
3196			).val();
3197		}
3198		var date = new Date();
3199		user_data.start_date =
3200			date.getFullYear() +
3201			"-" +
3202			(date.getMonth() + 1) +
3203			"-" +
3204			date.getDate();
3205
3206		return user_data;
3207	}
3208
3209	/**
3210	 * Calculate total with tax
3211	 *
3212	 * @param membershipData
3213	 * @param taxRate
3214	 *
3215	 * @since 5.0.0
3216	 */
3217	function calculate_total(membershipData, taxRate) {
3218		var total_input = $("#ur-membership-total");
3219
3220		let membershipPrice = parseFloat(membershipData.total);
3221		let taxAmount = 0;
3222		if (user_registration_params.is_tax_calculation_activated) {
3223			taxAmount = (membershipPrice * taxRate) / 100;
3224		}
3225		let totalPrice = membershipPrice + taxAmount;
3226		let total = parseFloat(totalPrice).toFixed(2);
3227
3228		$(".urm-membership-tax-value")
3229			.find(".ur_membership_input_label")
3230			.text(taxRate + "% Tax");
3231		var subTotalInput = $("#ur-membership-subtotal");
3232		var taxInput = $("#ur-membership-tax");
3233
3234		if (total_input.length) {
3235			if ("left" === user_registration_params.currency_pos) {
3236				total_input.text(
3237					user_registration_params.currency_symbol + total
3238				);
3239				subTotalInput.text(
3240					user_registration_params.currency_symbol +
3241						membershipPrice.toFixed(2)
3242				);
3243				taxInput.text(
3244					user_registration_params.currency_symbol +
3245						taxAmount.toFixed(2)
3246				);
3247			} else {
3248				total_input.text(
3249					total + user_registration_params.currency_symbol
3250				);
3251				subTotalInput.text(
3252					membershipPrice.toFixed(2) +
3253						user_registration_params.currency_symbol
3254				);
3255				taxInput.text(
3256					taxAmount.toFixed(2) +
3257						user_registration_params.currency_symbol
3258				);
3259			}
3260		} else {
3261			total_input = $(".ur-total-amount[type='hidden']");
3262			total_input.val(total);
3263			$(document).find("span.ur-total-amount").text(total);
3264		}
3265
3266		$("#ur-tax-details").remove();
3267
3268		var taxDetailsInput =
3269			'<input type="hidden" ' +
3270			'id="ur-tax-details" ' +
3271			'name="ur_tax_details" ' +
3272			'data-tax-rate="' +
3273			taxRate +
3274			'" ' +
3275			'data-tax-calculation-method="' +
3276			user_registration_params.tax_calculation_method +
3277			'" ' +
3278			'data-total="' +
3279			total +
3280			'">';
3281
3282		total_input.after(taxDetailsInput);
3283	}
3284})(jQuery);
3285
3286function ur_includes(arr, item) {
3287	if (Array.isArray(arr)) {
3288		for (var i = 0; i < arr.length; i += 1) {
3289			if (arr[i] === item) {
3290				return true;
3291			}
3292		}
3293	}
3294	return false;
3295}
3296
3297/**
3298 *
3299 * @param password
3300 * @returns {number}
3301 */
3302function customPasswordChecks(password) {
3303	var custom_password_params =
3304			ur_frontend_params_with_form_id.custom_password_params,
3305		minLength =
3306			custom_password_params.minimum_pass_length !== undefined &&
3307			custom_password_params.minimum_pass_length >= 3
3308				? custom_password_params.minimum_pass_length
3309				: 3,
3310		maxRepeatChars =
3311			custom_password_params.max_rep_chars !== undefined
3312				? custom_password_params.max_rep_chars
3313				: 0,
3314		canRepeatChars =
3315			custom_password_params.no_rep_chars !== undefined
3316				? custom_password_params.no_rep_chars
3317				: 0,
3318		minUppercaseCount =
3319			custom_password_params.minimum_uppercase !== undefined
3320				? custom_password_params.minimum_uppercase
3321				: 0,
3322		minSpecialCharCount =
3323			custom_password_params.minimum_special_chars !== undefined
3324				? custom_password_params.minimum_special_chars
3325				: 0,
3326		minimumDigitsCount =
3327			custom_password_params.minimum_digits !== undefined
3328				? custom_password_params.minimum_digits
3329				: 0,
3330		specialChars = new Set([
3331			"!",
3332			"@",
3333			"#",
3334			"$",
3335			"%",
3336			"^",
3337			"&",
3338			"*",
3339			"(",
3340			")",
3341			"-",
3342			"_",
3343			"=",
3344			"+",
3345			"{",
3346			"}",
3347			"[",
3348			"]",
3349			"|",
3350			"\\",
3351			":",
3352			";",
3353			'"',
3354			"'",
3355			"<",
3356			">",
3357			",",
3358			".",
3359			"?",
3360			"/"
3361		]),
3362		lastChar = "",
3363		repeatCount = 0,
3364		uppercaseCount = 0,
3365		digitCount = 0,
3366		specialCharCount = 0;
3367
3368	if (password.length < minLength) {
3369		return 0;
3370	}
3371
3372	for (var i = 0; i < password.length; i++) {
3373		var letter = password[i];
3374		// Check if the character is uppercase
3375		if (/[A-Z]/.test(letter)) {
3376			uppercaseCount++;
3377		}
3378		letter = letter.toLowerCase();
3379		// Check if the character is a digit
3380		if (/\d/.test(letter)) {
3381			digitCount++;
3382		}
3383
3384		// Check if the character is a special character
3385		if (specialChars.has(letter)) {
3386			specialCharCount++;
3387		}
3388
3389		// Check for repeated characters
3390		if (canRepeatChars && letter === lastChar) {
3391			repeatCount++;
3392			if (repeatCount >= maxRepeatChars) {
3393				return 0;
3394			}
3395		} else {
3396			repeatCount = 0; // Reset count if the character changes
3397		}
3398		lastChar = letter;
3399	}
3400
3401	// Check if the password meets the required criteria
3402	if (minUppercaseCount > 0 && uppercaseCount < minUppercaseCount) {
3403		return 0;
3404	}
3405	if (minSpecialCharCount > 0 && specialCharCount < minSpecialCharCount) {
3406		return 0;
3407	}
3408	if (minimumDigitsCount > 0 && digitCount < minimumDigitsCount) {
3409		return 0;
3410	}
3411	return 4;
3412}
3413
3414//Shows the content restriction message if botiga theme is used.
3415jQuery(document).ready(function ($) {
3416	var urcrContentRestrictMsg = $(document).find(".urcr-restrict-msg");
3417	if (urcrContentRestrictMsg.length > 1) {
3418		urcrContentRestrictMsg.hide().first().show();
3419	}
3420});
3421
3422/**
3423 * Check if hello elementor theme is active or not to resolve flatpickr design issue.
3424 *
3425 */
3426jQuery(document).ready(function ($) {
3427	//Check the hello elementor theme is active or not through its stylesheet.
3428	var $isHelloElementorActive =
3429		$('link#hello-elementor-css[href*="themes/hello-elementor"]').length >
3430		0;
3431
3432	if (!$isHelloElementorActive) {
3433		return;
3434	}
3435
3436	$(document).on("focus", ".ur-flatpickr-field", function () {
3437		var $input = $(this);
3438
3439		setTimeout(function () {
3440			$(".flatpickr-calendar:visible .flatpickr-current-month").css(
3441				"display",
3442				"flex"
3443			);
3444		}, 50);
3445	});
3446});
3447jQuery(document).ready(function ($) {
3448	$(".ur-submit-button.ur-disabled-btn").on("click", function (e) {
3449		e.preventDefault();
3450	});
3451});
3452
3453/**
3454 * A function that converts an object to an array by taking its values, excluding the first two, and preserving the original order.
3455 *
3456 * @param {jQuery} $object - The jQuery object to be converted to an array.
3457 * @return {Array} The array with values from the object, excluding the first two, and in the original order.
3458 */
3459function convert_to_array($object) {
3460	return Object.values($object).reverse().slice(2).reverse();
3461}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.