diff --git a/package.json b/package.json index 8f240ea2..9a73a127 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nette-forms", - "version": "3.4.0", + "version": "3.4.1", "description": "Client side script for Nette Forms Component", "keywords": [ "nette", diff --git a/src/assets/netteForms.js b/src/assets/netteForms.js index dc7397e4..759580c3 100644 --- a/src/assets/netteForms.js +++ b/src/assets/netteForms.js @@ -617,7 +617,8 @@ }); } for (let id in rule.toggle ?? []) { - formToggles[id] ??= {elem: elem, state: rule.toggle[id] ? curSuccess : !curSuccess}; + formToggles[id] ??= {elem: elem}; + formToggles[id].state ||= rule.toggle[id] ? curSuccess : !curSuccess; } } } diff --git a/src/assets/netteForms.min.js b/src/assets/netteForms.min.js index 272db1f9..8d84f28f 100644 --- a/src/assets/netteForms.min.js +++ b/src/assets/netteForms.min.js @@ -4,4 +4,4 @@ * * This file is part of the Nette Framework (https://nette.org) * Copyright (c) 2004 David Grudl (https://davidgrudl.com) - */!function(e,t){if(e.JSON)if("function"==typeof define&&define.amd)define((()=>t(e)));else if("object"==typeof module&&"object"==typeof module.exports)module.exports=t(e);else{var n;let r=!(null!==(n=e.Nette)&&void 0!==n&&n.noInit);e.Nette=t(e),r&&e.Nette.initOnLoad()}}("undefined"!=typeof window?window:void 0,(e=>{const t={};let n={},r={},o=new e.WeakMap;function l(e,t){let n=e.elements.namedItem(t);return n instanceof RadioNodeList?n[0]:n}function a(e){let t=e.form.elements.namedItem(e.name);return t instanceof RadioNodeList?Array.from(t):[t]}return t.formErrors=[],t.version="3.3.0",t.onDocumentReady=function(e){"loading"!==document.readyState?e.call(this):document.addEventListener("DOMContentLoaded",e)},t.getValue=function(e){var n,r;return e instanceof HTMLInputElement?"radio"===e.type?(null===(n=a(e).find((e=>e.checked)))||void 0===n?void 0:n.value)??null:"file"===e.type?e.files:"checkbox"===e.type?e.name.endsWith("[]")?a(e).filter((e=>e.checked)).map((e=>e.value)):e.checked:e.value.trim():e instanceof HTMLSelectElement?e.multiple?Array.from(e.selectedOptions,(e=>e.value)):(null===(r=e.selectedOptions[0])||void 0===r?void 0:r.value)??null:e instanceof HTMLTextAreaElement?e.value:e instanceof RadioNodeList?t.getValue(e[0]):null},t.getEffectiveValue=function(e,r=!1){let o=t.getValue(e);if(o===e.getAttribute("data-nette-empty-value")&&(o=""),r&&void 0===n[e.name]){n[e.name]=!0;let r={value:o};t.validateControl(e,null,!0,r),o=r.value,delete n[e.name]}return o},t.validateControl=function(e,n,r=!1,o=null,a=null){n??=JSON.parse(e.getAttribute("data-nette-rules")??"[]"),o??={value:t.getEffectiveValue(e)},a??=!t.validateRule(e,":filled",null,o);for(let i of n){let n=i.op.match(/(~)?([^?]+)/),u=i.control?l(e.form,i.control):e;if(i.neg=n[1],i.op=n[2],i.condition=!!i.rules,!u)continue;if(a&&!i.condition&&":filled"!==i.op)continue;let f=t.validateRule(u,i.op,i.arg,e===u?o:void 0);if(null!==f)if(i.neg&&(f=!f),i.condition&&f){if(!t.validateControl(e,i.rules,r,o,":blank"!==i.op&&a))return!1}else if(!i.condition&&!f){if(t.isDisabled(u))continue;if(!r){let n=Array.isArray(i.arg)?i.arg:[i.arg],r=i.msg.replace(/%(value|\d+)/g,((r,o)=>t.getValue("value"===o?u:e.form.elements.namedItem(n[o].control))));t.addError(u,r)}return!1}}return!0},t.validateForm=function(e,n=!1){let r,o=e.form??e;if(t.formErrors=[],o["nette-submittedBy"]&&null!==o["nette-submittedBy"].getAttribute("formnovalidate")){let e=JSON.parse(o["nette-submittedBy"].getAttribute("data-nette-validation-scope")??"[]");if(!e.length)return t.showFormErrors(o,[]),!0;r=new RegExp("^("+e.join("-|")+"-)")}for(let e of o.elements)if(e.willValidate&&e.validity.badInput)return e.reportValidity(),!1;for(let e of Array.from(o.elements))if(e.getAttribute("data-nette-rules")&&(!r||e.name.replace(/]\[|\[|]|$/g,"-").match(r))&&!t.isDisabled(e)&&!t.validateControl(e,null,n)&&!t.formErrors.length)return!1;let l=!t.formErrors.length;return t.showFormErrors(o,t.formErrors),l},t.isDisabled=function(e){return"radio"===e.type?a(e).every((e=>e.disabled)):e.disabled},t.addError=function(e,n){t.formErrors.push({element:e,message:n})},t.showFormErrors=function(e,n){let r,o=[];for(let e of n)o.indexOf(e.message)<0&&(o.push(e.message),!r&&e.element.focus&&(r=e.element));o.length&&t.showModal(o.join("\n"),(()=>{r&&r.focus()}))},t.showModal=function(e,t){let n=document.createElement("dialog");if(!n.showModal)return alert(e),void t();let r=document.createElement("style");r.innerText=".netteFormsModal { text-align: center; margin: auto; border: 2px solid black; padding: 1rem } .netteFormsModal button { padding: .1em 2em }";let o=document.createElement("button");o.innerText="OK",o.onclick=()=>{n.remove(),t()},n.setAttribute("class","netteFormsModal"),n.innerText=e+"\n\n",n.append(r,o),document.body.append(n),n.showModal()},t.validateRule=function(e,n,r,o){if(e.validity.badInput)return":filled"===n;o??={value:t.getEffectiveValue(e,!0)};let a=":"===n.charAt(0)?n.substring(1):n;a=a.replace("::","_").replaceAll("\\","");let i=Array.isArray(r)?r:[r];return i=i.map((n=>{if(null!=n&&n.control){let r=l(e.form,n.control);return r===e?o.value:t.getEffectiveValue(r,!0)}return n})),t.validators[a]?t.validators[a](e,Array.isArray(r)?i:i[0],o.value,o):null},t.validators={filled:function(e,t,n){return""!==n&&!1!==n&&null!==n&&(!Array.isArray(n)||!!n.length)&&(!(n instanceof FileList)||n.length)},blank:function(e,n,r){return!t.validators.filled(e,n,r)},valid:function(e){return t.validateControl(e,null,!0)},equal:function(e,t,n){if(void 0===t)return null;let r=e=>"number"==typeof e||"string"==typeof e?""+e:!0===e?"1":"";n=Array.isArray(n)?n:[n],t=Array.isArray(t)?t:[t];e:for(let e of n){for(let n of t)if(r(e)===r(n))continue e;return!1}return n.length>0},notEqual:function(e,n,r){return void 0===n?null:!t.validators.equal(e,n,r)},minLength:function(e,t,n){return(n="number"==typeof n?n.toString():n).length>=t},maxLength:function(e,t,n){return(n="number"==typeof n?n.toString():n).length<=t},length:function(e,t,n){return n="number"==typeof n?n.toString():n,(null===(t=Array.isArray(t)?t:[t,t])[0]||n.length>=t[0])&&(null===t[1]||n.length<=t[1])},email:function(e,t,n){return/^("([ !#-[\]-~]|\\[ -~])+"|[-a-z0-9!#$%&'*+/=?^_`{|}~]+(\.[-a-z0-9!#$%&'*+/=?^_`{|}~]+)*)@([0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)+[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?$/i.test(n)},url:function(e,t,n,r){return/^[a-z\d+.-]+:/.test(n)||(n="https://"+n),!!/^https?:\/\/((([-_0-9a-z\u00C0-\u02FF\u0370-\u1EFF]+\.)*[0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)?[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[[0-9a-f:]{3,39}\])(:\d{1,5})?(\/\S*)?$/i.test(n)&&(r.value=n,!0)},regexp:function(e,t,n){let r="string"==typeof t&&t.match(/^\/(.*)\/([imu]*)$/);try{return r&&new RegExp(r[1],r[2].replace("u","")).test(n)}catch{}},pattern:function(e,t,n,r,o){if("string"!=typeof t)return null;try{let e;try{e=new RegExp("^(?:"+t+")$",o?"ui":"u")}catch{e=new RegExp("^(?:"+t+")$",o?"i":"")}return n instanceof FileList?Array.from(n).every((t=>e.test(t.name))):e.test(n)}catch{}},patternCaseInsensitive:function(e,n,r){return t.validators.pattern(e,n,r,null,!0)},numeric:function(e,t,n){return/^[0-9]+$/.test(n)},integer:function(e,t,n,r){return!!/^-?[0-9]+$/.test(n)&&(r.value=parseFloat(n),!0)},float:function(e,t,n,r){return n=n.replace(/ +/g,"").replace(/,/g,"."),!!/^-?[0-9]*\.?[0-9]+$/.test(n)&&(r.value=parseFloat(n),!0)},min:function(e,t,n){return Number.isFinite(t)&&(n=parseFloat(n)),n>=t},max:function(e,t,n){return Number.isFinite(t)&&(n=parseFloat(n)),n<=t},range:function(e,n,r){return Array.isArray(n)?"time"===e.type&&n[0]>n[1]?r>=n[0]||r<=n[1]:(null===n[0]||t.validators.min(e,n[0],r))&&(null===n[1]||t.validators.max(e,n[1],r)):null},submitted:function(e){return e.form["nette-submittedBy"]===e},fileSize:function(e,t,n){return Array.from(n).every((e=>e.size<=t))},mimeType:function(e,t,n){let r=[];return(t=Array.isArray(t)?t:[t]).forEach((e=>r.push("^"+e.replace(/([^\w])/g,"\\$1").replace("\\*",".*")+"$"))),r=new RegExp(r.join("|")),Array.from(n).every((e=>!e.type||r.test(e.type)))},image:function(e,n,r){return t.validators.mimeType(e,n??["image/gif","image/png","image/jpeg","image/webp"],r)},static:function(e,t){return t}},t.toggleForm=function(e,n=null){r={};for(let r of Array.from(e.elements))r.getAttribute("data-nette-rules")&&t.toggleControl(r,null,null,!n);for(let e in r)t.toggle(e,r[e].state,r[e].elem,n)},t.toggleControl=function(e,n,i,u,f=null,d=null){n??=JSON.parse(e.getAttribute("data-nette-rules")??"[]"),f??={value:t.getEffectiveValue(e)},d??=!t.validateRule(e,":filled",null,f);let s,c=!1;for(let m of n){let n=m.op.match(/(~)?([^?]+)/),g=m.control?l(e.form,m.control):e;if(m.neg=n[1],m.op=n[2],m.condition=!!m.rules,g&&(!d||m.condition||":filled"===m.op)){if(s=i,!1!==i){if(s=t.validateRule(g,m.op,m.arg,e===g?f:void 0),null===s)continue;m.neg&&(s=!s),m.condition||(i=s)}if(m.condition&&t.toggleControl(e,m.rules,s,u,f,":blank"!==m.op&&d)||m.toggle){c=!0,u&&a(g).filter((e=>!o.has(e))).forEach((n=>{n.addEventListener("change",(n=>t.toggleForm(e.form,n))),o.set(n,null)}));for(let t in m.toggle??[])r[t]??={elem:e,state:m.toggle[t]?s:!s}}}}return c},t.toggle=function(e,t,n,r){/^\w[\w.:-]*$/.test(e)&&(e="#"+e),Array.from(document.querySelectorAll(e)).forEach((e=>e.hidden=!t))},t.compactCheckboxes=function(e,t){let n={};for(let r of e.elements)r instanceof HTMLInputElement&&"checkbox"===r.type&&r.name.endsWith("[]")&&r.checked&&!r.disabled&&(t.delete(r.name),n[r.name]??=[],n[r.name].push(r.value));for(let e in n)t.set(e.substring(0,e.length-2),n[e].join(","))},t.initForm=function(e){"get"===e.method&&e.hasAttribute("data-nette-compact")&&e.addEventListener("formdata",(n=>t.compactCheckboxes(e,n.formData))),Array.from(e.elements).some((e=>e.getAttribute("data-nette-rules")))&&(t.toggleForm(e),e.noValidate||(e.noValidate=!0,e.addEventListener("submit",(n=>{t.validateForm(e)||(n.stopPropagation(),n.preventDefault())})),e.addEventListener("reset",(()=>{setTimeout((()=>t.toggleForm(e)))}))))},t.initOnLoad=function(){t.onDocumentReady((()=>{Array.from(document.forms).forEach((e=>t.initForm(e))),document.body.addEventListener("click",(e=>{let t=e.target;for(;t;){if(t.form&&t.type in{submit:1,image:1}){t.form["nette-submittedBy"]=t;break}t=t.parentNode}}))}))},t.webalize=function(e){e=e.toLowerCase();let n,r="";for(let o=0;ot(e)));else if("object"==typeof module&&"object"==typeof module.exports)module.exports=t(e);else{var n;let r=!(null!==(n=e.Nette)&&void 0!==n&&n.noInit);e.Nette=t(e),r&&e.Nette.initOnLoad()}}("undefined"!=typeof window?window:void 0,(e=>{const t={};let n={},r={},o=new e.WeakMap;function l(e,t){let n=e.elements.namedItem(t);return n instanceof RadioNodeList?n[0]:n}function a(e){let t=e.form.elements.namedItem(e.name);return t instanceof RadioNodeList?Array.from(t):[t]}return t.formErrors=[],t.version="3.3.0",t.onDocumentReady=function(e){"loading"!==document.readyState?e.call(this):document.addEventListener("DOMContentLoaded",e)},t.getValue=function(e){var n,r;return e instanceof HTMLInputElement?"radio"===e.type?(null===(n=a(e).find((e=>e.checked)))||void 0===n?void 0:n.value)??null:"file"===e.type?e.files:"checkbox"===e.type?e.name.endsWith("[]")?a(e).filter((e=>e.checked)).map((e=>e.value)):e.checked:e.value.trim():e instanceof HTMLSelectElement?e.multiple?Array.from(e.selectedOptions,(e=>e.value)):(null===(r=e.selectedOptions[0])||void 0===r?void 0:r.value)??null:e instanceof HTMLTextAreaElement?e.value:e instanceof RadioNodeList?t.getValue(e[0]):null},t.getEffectiveValue=function(e,r=!1){let o=t.getValue(e);if(o===e.getAttribute("data-nette-empty-value")&&(o=""),r&&void 0===n[e.name]){n[e.name]=!0;let r={value:o};t.validateControl(e,null,!0,r),o=r.value,delete n[e.name]}return o},t.validateControl=function(e,n,r=!1,o=null,a=null){n??=JSON.parse(e.getAttribute("data-nette-rules")??"[]"),o??={value:t.getEffectiveValue(e)},a??=!t.validateRule(e,":filled",null,o);for(let i of n){let n=i.op.match(/(~)?([^?]+)/),u=i.control?l(e.form,i.control):e;if(i.neg=n[1],i.op=n[2],i.condition=!!i.rules,!u)continue;if(a&&!i.condition&&":filled"!==i.op)continue;let f=t.validateRule(u,i.op,i.arg,e===u?o:void 0);if(null!==f)if(i.neg&&(f=!f),i.condition&&f){if(!t.validateControl(e,i.rules,r,o,":blank"!==i.op&&a))return!1}else if(!i.condition&&!f){if(t.isDisabled(u))continue;if(!r){let n=Array.isArray(i.arg)?i.arg:[i.arg],r=i.msg.replace(/%(value|\d+)/g,((r,o)=>t.getValue("value"===o?u:e.form.elements.namedItem(n[o].control))));t.addError(u,r)}return!1}}return!0},t.validateForm=function(e,n=!1){let r,o=e.form??e;if(t.formErrors=[],o["nette-submittedBy"]&&null!==o["nette-submittedBy"].getAttribute("formnovalidate")){let e=JSON.parse(o["nette-submittedBy"].getAttribute("data-nette-validation-scope")??"[]");if(!e.length)return t.showFormErrors(o,[]),!0;r=new RegExp("^("+e.join("-|")+"-)")}for(let e of o.elements)if(e.willValidate&&e.validity.badInput)return e.reportValidity(),!1;for(let e of Array.from(o.elements))if(e.getAttribute("data-nette-rules")&&(!r||e.name.replace(/]\[|\[|]|$/g,"-").match(r))&&!t.isDisabled(e)&&!t.validateControl(e,null,n)&&!t.formErrors.length)return!1;let l=!t.formErrors.length;return t.showFormErrors(o,t.formErrors),l},t.isDisabled=function(e){return"radio"===e.type?a(e).every((e=>e.disabled)):e.disabled},t.addError=function(e,n){t.formErrors.push({element:e,message:n})},t.showFormErrors=function(e,n){let r,o=[];for(let e of n)o.indexOf(e.message)<0&&(o.push(e.message),!r&&e.element.focus&&(r=e.element));o.length&&t.showModal(o.join("\n"),(()=>{r&&r.focus()}))},t.showModal=function(e,t){let n=document.createElement("dialog");if(!n.showModal)return alert(e),void t();let r=document.createElement("style");r.innerText=".netteFormsModal { text-align: center; margin: auto; border: 2px solid black; padding: 1rem } .netteFormsModal button { padding: .1em 2em }";let o=document.createElement("button");o.innerText="OK",o.onclick=()=>{n.remove(),t()},n.setAttribute("class","netteFormsModal"),n.innerText=e+"\n\n",n.append(r,o),document.body.append(n),n.showModal()},t.validateRule=function(e,n,r,o){if(e.validity.badInput)return":filled"===n;o??={value:t.getEffectiveValue(e,!0)};let a=":"===n.charAt(0)?n.substring(1):n;a=a.replace("::","_").replaceAll("\\","");let i=Array.isArray(r)?r:[r];return i=i.map((n=>{if(null!=n&&n.control){let r=l(e.form,n.control);return r===e?o.value:t.getEffectiveValue(r,!0)}return n})),t.validators[a]?t.validators[a](e,Array.isArray(r)?i:i[0],o.value,o):null},t.validators={filled:function(e,t,n){return""!==n&&!1!==n&&null!==n&&(!Array.isArray(n)||!!n.length)&&(!(n instanceof FileList)||n.length)},blank:function(e,n,r){return!t.validators.filled(e,n,r)},valid:function(e){return t.validateControl(e,null,!0)},equal:function(e,t,n){if(void 0===t)return null;let r=e=>"number"==typeof e||"string"==typeof e?""+e:!0===e?"1":"";n=Array.isArray(n)?n:[n],t=Array.isArray(t)?t:[t];e:for(let e of n){for(let n of t)if(r(e)===r(n))continue e;return!1}return n.length>0},notEqual:function(e,n,r){return void 0===n?null:!t.validators.equal(e,n,r)},minLength:function(e,t,n){return(n="number"==typeof n?n.toString():n).length>=t},maxLength:function(e,t,n){return(n="number"==typeof n?n.toString():n).length<=t},length:function(e,t,n){return n="number"==typeof n?n.toString():n,(null===(t=Array.isArray(t)?t:[t,t])[0]||n.length>=t[0])&&(null===t[1]||n.length<=t[1])},email:function(e,t,n){return/^("([ !#-[\]-~]|\\[ -~])+"|[-a-z0-9!#$%&'*+/=?^_`{|}~]+(\.[-a-z0-9!#$%&'*+/=?^_`{|}~]+)*)@([0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)+[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?$/i.test(n)},url:function(e,t,n,r){return/^[a-z\d+.-]+:/.test(n)||(n="https://"+n),!!/^https?:\/\/((([-_0-9a-z\u00C0-\u02FF\u0370-\u1EFF]+\.)*[0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)?[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[[0-9a-f:]{3,39}\])(:\d{1,5})?(\/\S*)?$/i.test(n)&&(r.value=n,!0)},regexp:function(e,t,n){let r="string"==typeof t&&t.match(/^\/(.*)\/([imu]*)$/);try{return r&&new RegExp(r[1],r[2].replace("u","")).test(n)}catch{}},pattern:function(e,t,n,r,o){if("string"!=typeof t)return null;try{let e;try{e=new RegExp("^(?:"+t+")$",o?"ui":"u")}catch{e=new RegExp("^(?:"+t+")$",o?"i":"")}return n instanceof FileList?Array.from(n).every((t=>e.test(t.name))):e.test(n)}catch{}},patternCaseInsensitive:function(e,n,r){return t.validators.pattern(e,n,r,null,!0)},numeric:function(e,t,n){return/^[0-9]+$/.test(n)},integer:function(e,t,n,r){return!!/^-?[0-9]+$/.test(n)&&(r.value=parseFloat(n),!0)},float:function(e,t,n,r){return n=n.replace(/ +/g,"").replace(/,/g,"."),!!/^-?[0-9]*\.?[0-9]+$/.test(n)&&(r.value=parseFloat(n),!0)},min:function(e,t,n){return Number.isFinite(t)&&(n=parseFloat(n)),n>=t},max:function(e,t,n){return Number.isFinite(t)&&(n=parseFloat(n)),n<=t},range:function(e,n,r){return Array.isArray(n)?"time"===e.type&&n[0]>n[1]?r>=n[0]||r<=n[1]:(null===n[0]||t.validators.min(e,n[0],r))&&(null===n[1]||t.validators.max(e,n[1],r)):null},submitted:function(e){return e.form["nette-submittedBy"]===e},fileSize:function(e,t,n){return Array.from(n).every((e=>e.size<=t))},mimeType:function(e,t,n){let r=[];return(t=Array.isArray(t)?t:[t]).forEach((e=>r.push("^"+e.replace(/([^\w])/g,"\\$1").replace("\\*",".*")+"$"))),r=new RegExp(r.join("|")),Array.from(n).every((e=>!e.type||r.test(e.type)))},image:function(e,n,r){return t.validators.mimeType(e,n??["image/gif","image/png","image/jpeg","image/webp"],r)},static:function(e,t){return t}},t.toggleForm=function(e,n=null){r={};for(let r of Array.from(e.elements))r.getAttribute("data-nette-rules")&&t.toggleControl(r,null,null,!n);for(let e in r)t.toggle(e,r[e].state,r[e].elem,n)},t.toggleControl=function(e,n,i,u,f=null,d=null){n??=JSON.parse(e.getAttribute("data-nette-rules")??"[]"),f??={value:t.getEffectiveValue(e)},d??=!t.validateRule(e,":filled",null,f);let s,c=!1;for(let m of n){let n=m.op.match(/(~)?([^?]+)/),g=m.control?l(e.form,m.control):e;if(m.neg=n[1],m.op=n[2],m.condition=!!m.rules,g&&(!d||m.condition||":filled"===m.op)){if(s=i,!1!==i){if(s=t.validateRule(g,m.op,m.arg,e===g?f:void 0),null===s)continue;m.neg&&(s=!s),m.condition||(i=s)}if(m.condition&&t.toggleControl(e,m.rules,s,u,f,":blank"!==m.op&&d)||m.toggle){c=!0,u&&a(g).filter((e=>!o.has(e))).forEach((n=>{n.addEventListener("change",(n=>t.toggleForm(e.form,n))),o.set(n,null)}));for(let t in m.toggle??[])r[t]??={elem:e},r[t].state||=m.toggle[t]?s:!s}}}return c},t.toggle=function(e,t,n,r){/^\w[\w.:-]*$/.test(e)&&(e="#"+e),Array.from(document.querySelectorAll(e)).forEach((e=>e.hidden=!t))},t.compactCheckboxes=function(e,t){let n={};for(let r of e.elements)r instanceof HTMLInputElement&&"checkbox"===r.type&&r.name.endsWith("[]")&&r.checked&&!r.disabled&&(t.delete(r.name),n[r.name]??=[],n[r.name].push(r.value));for(let e in n)t.set(e.substring(0,e.length-2),n[e].join(","))},t.initForm=function(e){"get"===e.method&&e.hasAttribute("data-nette-compact")&&e.addEventListener("formdata",(n=>t.compactCheckboxes(e,n.formData))),Array.from(e.elements).some((e=>e.getAttribute("data-nette-rules")))&&(t.toggleForm(e),e.noValidate||(e.noValidate=!0,e.addEventListener("submit",(n=>{t.validateForm(e)||(n.stopPropagation(),n.preventDefault())})),e.addEventListener("reset",(()=>{setTimeout((()=>t.toggleForm(e)))}))))},t.initOnLoad=function(){t.onDocumentReady((()=>{Array.from(document.forms).forEach((e=>t.initForm(e))),document.body.addEventListener("click",(e=>{let t=e.target;for(;t;){if(t.form&&t.type in{submit:1,image:1}){t.form["nette-submittedBy"]=t;break}t=t.parentNode}}))}))},t.webalize=function(e){e=e.toLowerCase();let n,r="";for(let o=0;o