Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@felte/element

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@felte/element - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

16

dist/felte-field.js

@@ -223,2 +223,5 @@ /**

}
function booleanCoverter(value) {
return value === '' || (!!value && value !== 'false');
}
class FelteField extends HTMLElement {

@@ -236,3 +239,5 @@ constructor() {

var _a;
const element = this.children.item(0);
const element = this.target
? this.querySelector(this.target)
: this.firstElementChild;
if (!element || element === this._element)

@@ -255,2 +260,3 @@ return;

'value',
'target',
];

@@ -265,3 +271,3 @@ }

touchonchange: {
converter: (value) => value === '' || (!!value && value !== 'false'),
converter: booleanCoverter,
name: 'touchOnChange',

@@ -286,5 +292,9 @@ },

composed: {
converter: (value) => value === '' || (!!value && value !== 'false'),
converter: booleanCoverter,
name: 'composed',
},
target: {
converter: String,
name: 'target',
},
};

@@ -291,0 +301,0 @@ }

2

dist/felte-field.min.js

@@ -1,2 +0,2 @@

function e(e){var t;return"INPUT"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function t(e){var t;return"SELECT"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function n(n){return e(n)||function(e){var t;return"TEXTAREA"===(null===(t=e)||void 0===t?void 0:t.nodeName)}(n)||t(n)}function i(i,r){var o;if(!n(i))return;const l=r;if(e(i)){if("checkbox"===i.type){const e=l;return void 0===e||"boolean"==typeof e?void(i.checked=!!e):void(Array.isArray(e)&&(e.includes(i.value)?i.checked=!0:i.checked=!1))}if("radio"===i.type){const e=l;return void(i.value===e?i.checked=!0:i.checked=!1)}if("file"===i.type)return i.files=null,void(i.value="")}else if(t(i)){if(i.multiple){if(Array.isArray(l)){i.value=String(null!==(o=l[0])&&void 0!==o?o:"");for(const e of i.options)l.includes(e.value)?e.selected=!0:e.selected=!1}}else{i.value=String(null!=l?l:"");for(const e of i.options)e.value===l?e.selected=!0:e.selected=!1}return}i.value=String(null!=l?l:"")}const r={attributes:!0,attributeFilter:["data-felte-validation-message","aria-invalid"]};function o(e,t){var o,l;let a,u,s,d,v,c;function h(e,t){if(!v)return;i(v,t);const n=new Event(e,{bubbles:!0,composed:!0});v.dispatchEvent(n)}function f(e){e.forEach((()=>{const e=v.getAttribute("aria-invalid");e?d.setAttribute("aria-invalid",e):d.removeAttribute("aria-invalid");const t=v.getAttribute("data-felte-validation-message");t?d.setAttribute("data-felte-validation-message",t):d.removeAttribute("data-felte-validation-message")}))}function m(e){c&&(i(v,u),c(e))}function p(e){h(s?"change":"input",e)}return"string"==typeof e?(a=e,u=null==t?void 0:t.defaultValue,s=null!==(o=null==t?void 0:t.touchOnChange)&&void 0!==o&&o,c=null==t?void 0:t.onFormReset):(a=e.name,u=e.defaultValue,s=null!==(l=e.touchOnChange)&&void 0!==l&&l,c=null==e?void 0:e.onFormReset),{field:function(e){let t,o;if(d=e,n(e))return v=e,v.name=a,{};{let l=!1,s=!1;return setTimeout((()=>{if(s)return;const c=d.parentNode;if(!c||c.nodeType!==Node.ELEMENT_NODE)return;const h=c.querySelector(`[name="${a}"]`);if(h&&n(h))v=h;else{const t=document.createElement("input");t.type="hidden",t.name=a,c.insertBefore(t,e.nextSibling),v=t,l=!0}i(v,u),t=new MutationObserver(f),t.observe(v,r),o=v.closest("form"),null==o||o.addEventListener("reset",m)})),{destroy(){var e;l&&(null===(e=v.parentNode)||void 0===e||e.removeChild(v)),s=!0,null==t||t.disconnect(),null==o||o.removeEventListener("reset",m)}}}},onInput:p,onChange:p,onBlur:function(){h("focusout")}}}class l extends HTMLElement{constructor(){var e;super(...arguments),this.touchOnChange=!1,this.valueProp="value",this.inputEvent="input",this.blurEvent="focusout",this.composed=!1,this._onBlur=(e="blur",function(){throw new TypeError(`Can't call "${e}" on HTMLFelteFieldElement. The element is not ready yet.`)}),this._ready=!1,this._updateField=()=>{var e;const t=this.children.item(0);t&&t!==this._element&&(this._element=t,null===(e=this._destroy)||void 0===e||e.call(this),this._destroy=void 0,this._createField())}}static get observedAttributes(){return["name","touchonchange","valueprop","inputevent","blurevent","composed","value"]}static get attributeMap(){return{name:{converter:String,name:"name"},touchonchange:{converter:e=>""===e||!!e&&"false"!==e,name:"touchOnChange"},valueprop:{converter:String,name:"valueProp"},inputevent:{converter:String,name:"inputEvent"},blurevent:{converter:String,name:"blurEvent"},value:{converter:String,name:"value"},composed:{converter:e=>""===e||!!e&&"false"!==e,name:"composed"}}}attributeChangedCallback(e,t,n){if(t===n)return;const{converter:i,name:r}=l.attributeMap[e];this[r]=i(n)}set value(e){var t;null===(t=this._onInput)||void 0===t||t.call(this,e),this._value=e}get value(){return this._value}blur(){this._onBlur()}get ready(){return this._ready}_createField(){var e;const{name:t,inputEvent:n,blurEvent:i,touchOnChange:r,value:l,composed:a}=this;if(!t)throw new Error('<felte-field> must have a "name" attribute');const u=this._element;if(!u)return;u[this.valueProp]=l;const{field:s,onInput:d,onBlur:v}=o(t,{touchOnChange:r,defaultValue:l,onFormReset:()=>{this.value=l,u[this.valueProp]=l}});this._onInput=d,this._onBlur=v;const{destroy:c}=s(u),h=e=>{const t=a?e.composedPath()[0]:e.target;this.value=t[this.valueProp]},f=()=>{v()};u.addEventListener(n,h),u.addEventListener(i,f),this._destroy=()=>{null==c||c(),u.removeEventListener(n,h),u.removeEventListener(n,f)},this._ready=!0,null===(e=this.onfeltefieldready)||void 0===e||e.call(this),this.dispatchEvent(new Event("feltefieldready"))}connectedCallback(){setTimeout((()=>{this._updateField(),this._observer=new MutationObserver(this._updateField),this._observer.observe(this,{childList:!0})}))}disconnectedCallback(){var e,t;null===(e=this._destroy)||void 0===e||e.call(this),null===(t=this._observer)||void 0===t||t.disconnect()}}customElements.get("felte-field")||(customElements.define("felte-field",l),window.HTMLFelteFieldElement=l);export{l as FelteField};
function e(e){var t;return"INPUT"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function t(e){var t;return"SELECT"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function n(n){return e(n)||function(e){var t;return"TEXTAREA"===(null===(t=e)||void 0===t?void 0:t.nodeName)}(n)||t(n)}function i(i,r){var o;if(!n(i))return;const l=r;if(e(i)){if("checkbox"===i.type){const e=l;return void 0===e||"boolean"==typeof e?void(i.checked=!!e):void(Array.isArray(e)&&(e.includes(i.value)?i.checked=!0:i.checked=!1))}if("radio"===i.type){const e=l;return void(i.value===e?i.checked=!0:i.checked=!1)}if("file"===i.type)return i.files=null,void(i.value="")}else if(t(i)){if(i.multiple){if(Array.isArray(l)){i.value=String(null!==(o=l[0])&&void 0!==o?o:"");for(const e of i.options)l.includes(e.value)?e.selected=!0:e.selected=!1}}else{i.value=String(null!=l?l:"");for(const e of i.options)e.value===l?e.selected=!0:e.selected=!1}return}i.value=String(null!=l?l:"")}const r={attributes:!0,attributeFilter:["data-felte-validation-message","aria-invalid"]};function o(e,t){var o,l;let a,u,s,d,c,v;function h(e,t){if(!c)return;i(c,t);const n=new Event(e,{bubbles:!0,composed:!0});c.dispatchEvent(n)}function f(e){e.forEach((()=>{const e=c.getAttribute("aria-invalid");e?d.setAttribute("aria-invalid",e):d.removeAttribute("aria-invalid");const t=c.getAttribute("data-felte-validation-message");t?d.setAttribute("data-felte-validation-message",t):d.removeAttribute("data-felte-validation-message")}))}function m(e){v&&(i(c,u),v(e))}function p(e){h(s?"change":"input",e)}return"string"==typeof e?(a=e,u=null==t?void 0:t.defaultValue,s=null!==(o=null==t?void 0:t.touchOnChange)&&void 0!==o&&o,v=null==t?void 0:t.onFormReset):(a=e.name,u=e.defaultValue,s=null!==(l=e.touchOnChange)&&void 0!==l&&l,v=null==e?void 0:e.onFormReset),{field:function(e){let t,o;if(d=e,n(e))return c=e,c.name=a,{};{let l=!1,s=!1;return setTimeout((()=>{if(s)return;const v=d.parentNode;if(!v||v.nodeType!==Node.ELEMENT_NODE)return;const h=v.querySelector(`[name="${a}"]`);if(h&&n(h))c=h;else{const t=document.createElement("input");t.type="hidden",t.name=a,v.insertBefore(t,e.nextSibling),c=t,l=!0}i(c,u),t=new MutationObserver(f),t.observe(c,r),o=c.closest("form"),null==o||o.addEventListener("reset",m)})),{destroy(){var e;l&&(null===(e=c.parentNode)||void 0===e||e.removeChild(c)),s=!0,null==t||t.disconnect(),null==o||o.removeEventListener("reset",m)}}}},onInput:p,onChange:p,onBlur:function(){h("focusout")}}}function l(e){return""===e||!!e&&"false"!==e}class a extends HTMLElement{constructor(){var e;super(...arguments),this.touchOnChange=!1,this.valueProp="value",this.inputEvent="input",this.blurEvent="focusout",this.composed=!1,this._onBlur=(e="blur",function(){throw new TypeError(`Can't call "${e}" on HTMLFelteFieldElement. The element is not ready yet.`)}),this._ready=!1,this._updateField=()=>{var e;const t=this.target?this.querySelector(this.target):this.firstElementChild;t&&t!==this._element&&(this._element=t,null===(e=this._destroy)||void 0===e||e.call(this),this._destroy=void 0,this._createField())}}static get observedAttributes(){return["name","touchonchange","valueprop","inputevent","blurevent","composed","value","target"]}static get attributeMap(){return{name:{converter:String,name:"name"},touchonchange:{converter:l,name:"touchOnChange"},valueprop:{converter:String,name:"valueProp"},inputevent:{converter:String,name:"inputEvent"},blurevent:{converter:String,name:"blurEvent"},value:{converter:String,name:"value"},composed:{converter:l,name:"composed"},target:{converter:String,name:"target"}}}attributeChangedCallback(e,t,n){if(t===n)return;const{converter:i,name:r}=a.attributeMap[e];this[r]=i(n)}set value(e){var t;null===(t=this._onInput)||void 0===t||t.call(this,e),this._value=e}get value(){return this._value}blur(){this._onBlur()}get ready(){return this._ready}_createField(){var e;const{name:t,inputEvent:n,blurEvent:i,touchOnChange:r,value:l,composed:a}=this;if(!t)throw new Error('<felte-field> must have a "name" attribute');const u=this._element;if(!u)return;u[this.valueProp]=l;const{field:s,onInput:d,onBlur:c}=o(t,{touchOnChange:r,defaultValue:l,onFormReset:()=>{this.value=l,u[this.valueProp]=l}});this._onInput=d,this._onBlur=c;const{destroy:v}=s(u),h=e=>{const t=a?e.composedPath()[0]:e.target;this.value=t[this.valueProp]},f=()=>{c()};u.addEventListener(n,h),u.addEventListener(i,f),this._destroy=()=>{null==v||v(),u.removeEventListener(n,h),u.removeEventListener(n,f)},this._ready=!0,null===(e=this.onfeltefieldready)||void 0===e||e.call(this),this.dispatchEvent(new Event("feltefieldready"))}connectedCallback(){setTimeout((()=>{this._updateField(),this._observer=new MutationObserver(this._updateField),this._observer.observe(this,{childList:!0})}))}disconnectedCallback(){var e,t;null===(e=this._destroy)||void 0===e||e.call(this),null===(t=this._observer)||void 0===t||t.disconnect()}}customElements.get("felte-field")||(customElements.define("felte-field",a),window.HTMLFelteFieldElement=a);export{a as FelteField};
//# sourceMappingURL=felte-field.min.js.map

@@ -1,2 +0,2 @@

function e(e){let t;return function(e,...t){const r=e.subscribe(...t);return r.unsubscribe?()=>r.unsubscribe():r}(e,(e=>t=e))(),t}class t extends Error{constructor(e,t){super(e),this.name="FelteSubmitError",this.response=t}}function r(e){var t;return"INPUT"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function n(e){var t;return"SELECT"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function i(e){var t;return"FIELDSET"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function s(e){return r(e)||function(e){var t;return"TEXTAREA"===(null===(t=e)||void 0===t?void 0:t.nodeName)}(e)||n(e)}function a(e){return e.nodeType===Node.ELEMENT_NODE}function o(e,t,r){const n=r=>String.prototype.split.call(t,r).filter(Boolean).reduce(((e,t)=>null!=e?e[t]:e),e),i=n(/[,[\]]+?/)||n(/[,[\].]+?/);return void 0===i||i===e?r:i}function u(e){return"[object Object]"===Object.prototype.toString.call(e)}function l(e){return Object.keys(e||{}).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:u(e[r])?l(e[r]):Array.isArray(e[r])?[...e[r]]:e[r]})),{})}function d(e,t,r){e&&(e=l(e)),u(e)||(e={});const n=Array.isArray(t)?t:t.match(/[^.[\]]+/g)||[],i=n[n.length-1];if(!i)return e;let s=e;for(let e=0;e<n.length-1;e++){const t=n[e];if(!s[t]||!u(s[t])&&!Array.isArray(s[t])){const r=n[e+1];isNaN(Number(r))?s[t]={}:s[t]=[]}s=s[t]}return s[i]=r(s[i]),e}function c(e,t,r){return d(e,t,(()=>r))}function f(e,t){return null!=t?t:s(e)?e.name:""}function v(e){if(s(e))return[e];if(0===e.childElementCount)return[];const t=new Set;for(const r of e.children){if(s(r)&&t.add(r),i(r))for(const e of r.elements)s(e)&&t.add(e);r.childElementCount>0&&v(r).forEach((e=>t.add(e)))}return Array.from(t)}function h(e){for(const t of e.elements)(s(t)||i(t))&&e.hasAttribute("data-felte-keep-on-remove")&&!t.hasAttribute("data-felte-keep-on-remove")&&(t.dataset.felteKeepOnRemove=e.dataset.felteKeepOnRemove)}function m(e){return e.type.match(/^(number|range)$/)?e.value?+e.value:void 0:e.value}function y(e){var t;let a={},u={};for(const l of e.elements){if(i(l)&&h(l),!s(l)||!l.name)continue;const v=f(l);if(r(l)){if("checkbox"===l.type){if(void 0===o(a,v)){if(1===Array.from(e.querySelectorAll(`[name="${l.name}"]`)).filter((e=>!!s(e)&&v===f(e))).length){a=c(a,v,l.checked),u=c(u,v,!1);continue}a=c(a,v,l.checked?[l.value]:[]),u=c(u,v,!1);continue}Array.isArray(o(a,v))&&l.checked&&(a=d(a,v,(e=>[...e,l.value])));continue}if("radio"===l.type){if(o(a,v))continue;a=c(a,v,l.checked?l.value:void 0),u=c(u,v,!1);continue}if("file"===l.type){a=c(a,v,l.multiple?Array.from(l.files||[]):null===(t=l.files)||void 0===t?void 0:t[0]),u=c(u,v,!1);continue}}else if(n(l)){if(l.multiple){const e=Array.from(l.options).filter((e=>e.selected)).map((e=>e.value));a=c(a,v,e)}else a=c(a,v,l.value);u=c(u,v,!1);continue}const y=m(l);a=c(a,v,y),u=c(u,v,!1)}return{defaultData:a,defaultTouched:u}}function p(e,t){var i;if(!s(e))return;const a=t;if(r(e)){if("checkbox"===e.type){const t=a;return void 0===t||"boolean"==typeof t?void(e.checked=!!t):void(Array.isArray(t)&&(t.includes(e.value)?e.checked=!0:e.checked=!1))}if("radio"===e.type){const t=a;return void(e.value===t?e.checked=!0:e.checked=!1)}if("file"===e.type)return e.files=null,void(e.value="")}else if(n(e)){if(e.multiple){if(Array.isArray(a)){e.value=String(null!==(i=a[0])&&void 0!==i?i:"");for(const t of e.options)a.includes(t.value)?t.selected=!0:t.selected=!1}}else{e.value=String(null!=a?a:"");for(const t of e.options)t.value===a?t.selected=!0:t.selected=!1}return}e.value=String(null!=a?a:"")}function b(e,t){for(const r of e.elements){if(i(r)&&h(r),!s(r)||!r.name)continue;p(r,o(t,f(r)))}}
function e(e){let t;return function(e,...t){const r=e.subscribe(...t);return r.unsubscribe?()=>r.unsubscribe():r}(e,(e=>t=e))(),t}class t extends Error{constructor(e,t){super(e),this.name="FelteSubmitError",this.response=t}}function r(e){var t;return"INPUT"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function n(e){var t;return"SELECT"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function i(e){var t;return"FIELDSET"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function s(e){return r(e)||function(e){var t;return"TEXTAREA"===(null===(t=e)||void 0===t?void 0:t.nodeName)}(e)||n(e)}function a(e){return e.nodeType===Node.ELEMENT_NODE}function o(e,t,r){const n=r=>String.prototype.split.call(t,r).filter(Boolean).reduce(((e,t)=>null!=e?e[t]:e),e),i=n(/[,[\]]+?/)||n(/[,[\].]+?/);return void 0===i||i===e?r:i}function u(e){return"[object Object]"===Object.prototype.toString.call(e)}function l(e){return Object.keys(e||{}).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:u(e[r])?l(e[r]):Array.isArray(e[r])?[...e[r]]:e[r]})),{})}function c(e,t,r){e&&(e=l(e)),u(e)||(e={});const n=Array.isArray(t)?t:t.match(/[^.[\]]+/g)||[],i=n[n.length-1];if(!i)return e;let s=e;for(let e=0;e<n.length-1;e++){const t=n[e];if(!s[t]||!u(s[t])&&!Array.isArray(s[t])){const r=n[e+1];isNaN(Number(r))?s[t]={}:s[t]=[]}s=s[t]}return s[i]=r(s[i]),e}function d(e,t,r){return c(e,t,(()=>r))}function f(e,t){return null!=t?t:s(e)?e.name:""}function v(e){if(s(e))return[e];if(0===e.childElementCount)return[];const t=new Set;for(const r of e.children){if(s(r)&&t.add(r),i(r))for(const e of r.elements)s(e)&&t.add(e);r.childElementCount>0&&v(r).forEach((e=>t.add(e)))}return Array.from(t)}function h(e){for(const t of e.elements)(s(t)||i(t))&&e.hasAttribute("data-felte-keep-on-remove")&&!t.hasAttribute("data-felte-keep-on-remove")&&(t.dataset.felteKeepOnRemove=e.dataset.felteKeepOnRemove)}function m(e){return e.type.match(/^(number|range)$/)?e.value?+e.value:void 0:e.value}function y(e){var t;let a={},u={};for(const l of e.elements){if(i(l)&&h(l),!s(l)||!l.name)continue;const v=f(l);if(r(l)){if("checkbox"===l.type){if(void 0===o(a,v)){if(1===Array.from(e.querySelectorAll(`[name="${l.name}"]`)).filter((e=>!!s(e)&&v===f(e))).length){a=d(a,v,l.checked),u=d(u,v,!1);continue}a=d(a,v,l.checked?[l.value]:[]),u=d(u,v,!1);continue}Array.isArray(o(a,v))&&l.checked&&(a=c(a,v,(e=>[...e,l.value])));continue}if("radio"===l.type){if(o(a,v))continue;a=d(a,v,l.checked?l.value:void 0),u=d(u,v,!1);continue}if("file"===l.type){a=d(a,v,l.multiple?Array.from(l.files||[]):null===(t=l.files)||void 0===t?void 0:t[0]),u=d(u,v,!1);continue}}else if(n(l)){if(l.multiple){const e=Array.from(l.options).filter((e=>e.selected)).map((e=>e.value));a=d(a,v,e)}else a=d(a,v,l.value);u=d(u,v,!1);continue}const y=m(l);a=d(a,v,y),u=d(u,v,!1)}return{defaultData:a,defaultTouched:u}}function p(e,t){var i;if(!s(e))return;const a=t;if(r(e)){if("checkbox"===e.type){const t=a;return void 0===t||"boolean"==typeof t?void(e.checked=!!t):void(Array.isArray(t)&&(t.includes(e.value)?e.checked=!0:e.checked=!1))}if("radio"===e.type){const t=a;return void(e.value===t?e.checked=!0:e.checked=!1)}if("file"===e.type)return e.files=null,void(e.value="")}else if(n(e)){if(e.multiple){if(Array.isArray(a)){e.value=String(null!==(i=a[0])&&void 0!==i?i:"");for(const t of e.options)a.includes(t.value)?t.selected=!0:t.selected=!1}}else{e.value=String(null!=a?a:"");for(const t of e.options)t.value===a?t.selected=!0:t.selected=!1}return}e.value=String(null!=a?a:"")}function b(e,t){for(const r of e.elements){if(i(r)&&h(r),!s(r)||!r.name)continue;p(r,o(t,f(r)))}}
/*! *****************************************************************************

@@ -29,3 +29,3 @@ Copyright (c) Microsoft Corporation.

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function F(e){return function(t){if(u(t)){return function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(V(t,e),["key"])}return e}}function V(e,t){return A(e,(e=>u(e)?V(e,t):Array.isArray(e)?e.map(F(t)):t))}function _(e,t){if(!e||Object(e)!==e)return;void 0!==e&&(e=l(e));const r=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g)||[],n=1===r.length?e:o(e,r.slice(0,-1).join("."));return Array.isArray(n)?n.splice(Number(r[r.length-1]),1):null==n||delete n[r[r.length-1]],e}function j(e,t,r,n){return d(e,t,(e=>void 0===e||Array.isArray(e)?(e||(e=[]),void 0===n?e.push(r):e.splice(n,0,r),e):e))}function k(e){return"function"==typeof e}function T(e){return(t,r)=>{if("string"==typeof t){const n=t;e((e=>{const t=k(r)?r(o(e,n)):r;return c(e,n,t)}))}else e((e=>k(t)?t(e):t))}}function D({stores:t,config:r,validateErrors:n,validateWarnings:i}){var s;let a,f=S(null!==(s=r.initialValues)&&void 0!==s?s:{});const{data:v,touched:h,errors:m,warnings:y,isDirty:p,isSubmitting:g,interacted:A}=t,O=T(v.update),F=T(h.update),k=T(m.update),D=T(y.update);function I(e){O((t=>{const r=e(t);return a&&b(a,r),r}))}const x=(e,t,r)=>{T(I)(e,t),"string"==typeof e&&r&&F(e,!0)};function L(e){m.update(e),y.update(e),h.update(e),v.update((t=>{const r=e(t);return setTimeout((()=>a&&b(a,r))),r}))}const N=T(g.update),P=T(p.update),C=T(A.update);return{public:{setData:O,setFields:x,setTouched:F,setErrors:k,setWarnings:D,setIsSubmitting:N,setIsDirty:P,setInteracted:C,validate:async function(){const t=e(v);h.set(E(t,!0)),A.set(null);const r=await n(t);return await i(t),r},reset:function(){x(l(f)),F((e=>V(e,!1))),A.set(null),p.set(!1)},unsetField:function(e){L((t=>_(t,e)))},resetField:function(e){const t=o(f,e),r=!!u(t)&&E(t,!1),n=u(r)?V(r,[]):[];v.update((r=>{const n=c(r,e,t);return a&&b(a,n),n})),h.update((t=>c(t,e,r))),m.update((t=>c(t,e,n))),y.update((t=>c(t,e,n)))},addField:function(e,t,r){const n=!!u(t)&&E(t,!1),i=u(n)?V(n,[]):[];t=u(t)?Object.assign(Object.assign({},t),{key:w()}):t,m.update((t=>j(t,e,i,r))),y.update((t=>j(t,e,i,r))),h.update((t=>j(t,e,n,r))),v.update((n=>{const i=j(n,e,t,r);return setTimeout((()=>a&&b(a,i))),i}))},swapFields:function(e,t,r){L((n=>function(e,t,r,n){return d(e,t,(e=>e&&Array.isArray(e)?([e[r],e[n]]=[e[n],e[r]],e):e))}(n,e,t,r)))},moveField:function(e,t,r){L((n=>function(e,t,r,n){return d(e,t,(e=>e&&Array.isArray(e)?(e.splice(n,0,e.splice(r,1)[0]),e):e))}(n,e,t,r)))},setInitialValues:e=>{f=S(e)}},private:{_setFormNode(e){a=e},_getFormNode:()=>a,_getInitialValues:()=>f}}}function I(){class e extends CustomEvent{constructor(e){super("feltesuccess",{detail:e})}}class t extends CustomEvent{constructor(e){super("felteerror",{detail:e,cancelable:!0})}setErrors(e){this.preventDefault(),this.errors=e}}class r extends Event{constructor(){super("feltesubmit",{cancelable:!0})}handleSubmit(e){this.onSubmit=e}handleError(e){this.onError=e}handleSuccess(e){this.onSuccess=e}}return{createErrorEvent:e=>new t(e),createSubmitEvent:()=>new r,createSuccessEvent:t=>new e(t)}}function x(...e){const t=e.pop(),r=l(e.shift());if(0===e.length)return r;for(const n of e){if(!n)continue;let e=t(r,n);if(void 0!==e)return e;const i=Array.from(new Set(Object.keys(r).concat(Object.keys(n))));for(const s of i)if(e=t(r[s],n[s]),void 0!==e)r[s]=e;else if(u(n[s])&&u(r[s]))r[s]=x(r[s],n[s],t);else if(Array.isArray(n[s]))r[s]=n[s].map(((e,n)=>{if(!u(e))return e;return x(Array.isArray(r[s])?r[s][n]:r[s],e,t)}));else if(u(n[s])){const e=V(l(n[s]),void 0);r[s]=x(e,n[s],t)}else void 0!==n[s]&&(r[s]=n[s])}return r}function L(...e){return x(...e,(()=>{}))}function N(e,t){return function(e,t){return Object.keys(e).some((r=>t(e[r])))}(e,(e=>u(e)?N(e,t):Array.isArray(e)?0===e.length||e.every((e=>"string"==typeof e))?t(e):e.some((e=>u(e)?N(e,t):t(e))):t(e)))}function P(e){let t=e;for(;t&&"FORM"!==t.nodeName;){if(t.hasAttribute("data-felte-ignore"))return!0;t=t.parentElement}return!1}function C(e,t){let r;return(...n)=>{clearTimeout(r),r=setTimeout((()=>{e.apply(this,n)}),t)}}function M(e,t){if(!u(e)||!u(t)){if(Array.isArray(t)){if(t.some(u))return;const r=Array.isArray(e)?e:[];return t.map(((e,t)=>{var n;return null!==(n=r[t])&&void 0!==n?n:e}))}return void 0!==e?e:void 0}}function W(...e){return x(...e,M)}function H({helpers:i,stores:d,config:h,extender:p,validateErrors:b,validateWarnings:A,_setFormNode:w,_getFormNode:S,_getInitialValues:F,_setCurrentExtenders:j,_getCurrentExtenders:k}){const{setFields:T,setTouched:D,reset:x,setInitialValues:M}=i,{addValidator:H,addTransformer:R,validate:U,setIsDirty:q,setIsSubmitting:$}=i,B=g(i,["addValidator","addTransformer","validate","setIsDirty","setIsSubmitting"]),{data:K,errors:z,warnings:X,touched:G,isSubmitting:J,isDirty:Q,interacted:Y}=d;function Z(r){return async function(n){var i,a,o,u,l,d,c;const f=S(),{createErrorEvent:v,createSubmitEvent:m,createSuccessEvent:y}=I(),p=m();null==f||f.dispatchEvent(p);const g=null!==(a=null!==(i=p.onError)&&void 0!==i?i:null==r?void 0:r.onError)&&void 0!==a?a:h.onError,w=null!==(u=null!==(o=p.onSuccess)&&void 0!==o?o:null==r?void 0:r.onSuccess)&&void 0!==u?u:h.onSuccess,F=null!==(c=null!==(d=null!==(l=p.onSubmit)&&void 0!==l?l:null==r?void 0:r.onSubmit)&&void 0!==d?d:h.onSubmit)&&void 0!==c?c:function(e){if(e)return async function(){let r=new FormData(e);const n=new URL(e.action),i="get"===e.method.toLowerCase()?"get":n.searchParams.get("_method")||e.method;let s,a=e.enctype;e.querySelector('input[type="file"]')&&(a="multipart/form-data"),"get"!==i&&"application/x-www-form-urlencoded"!==a||(r=new URLSearchParams(r)),"get"===i?(r.forEach(((e,t)=>{n.searchParams.append(t,e)})),s={method:i}):s={method:i,body:r,headers:{"Content-Type":a}};const o=await window.fetch(n.toString(),s);if(o.ok)return o;throw new t("An error occurred while submitting the form",o)}}(f);if(!F)return;if(null==n||n.preventDefault(),p.defaultPrevented)return;J.set(!0),Y.set(null);const _=O(e(K)),j=await b(_,null==r?void 0:r.validate),T=await A(_,null==r?void 0:r.warn);if(T&&X.set(L(V(_,[]),T)),G.set(E(_,!0)),j){G.set(E(j,!0));if(N(j,(e=>Array.isArray(e)?e.length>=1:!!e)))return await new Promise((e=>setTimeout(e))),k().forEach((e=>{var t;return null===(t=e.onSubmitError)||void 0===t?void 0:t.call(e,{data:_,errors:j})})),void J.set(!1)}const D=Object.assign(Object.assign({},B),{form:f,controls:f&&Array.from(f.elements).filter(s),config:Object.assign(Object.assign({},h),r)});try{const e=await F(_,D);null==f||f.dispatchEvent(y(Object.assign({response:e},D))),await(null==w?void 0:w(e,D))}catch(t){const r=v(Object.assign({error:t},D));if(null==f||f.dispatchEvent(r),!g&&!r.defaultPrevented)throw t;if(!g&&!r.errors)return;const n=r.errors||await(null==g?void 0:g(t,D));n&&(G.set(E(n,!0)),z.set(n),await new Promise((e=>setTimeout(e))),k().forEach((t=>{var r;return null===(r=t.onSubmitError)||void 0===r?void 0:r.call(t,{data:_,errors:e(z)})})))}finally{J.set(!1)}}}const ee=Z();return{form:function(t){function i(e){return function(r){return r({form:t,stage:e,controls:Array.from(t.elements).filter(s),data:K,errors:z,warnings:X,touched:G,config:h,addValidator:H,addTransformer:R,setFields:T,validate:U,reset:x})}}t.requestSubmit||(t.requestSubmit=ee),j(p.map(i("MOUNT"))),t.noValidate=!!h.validate;const{defaultData:d,defaultTouched:b}=y(t);function g(e){const t=e.target;if(!t||!s(t)||n(t)||P(t))return;if(["checkbox","radio","file"].includes(t.type))return;if(!t.name)return;Q.set(!0);const r=m(t);Y.set(t.name),K.update((e=>c(e,f(t),r)))}function A(e){const i=e.target;if(i&&s(i)&&!P(i)&&i.name)if(D(f(i),!0),Y.set(i.name),(n(i)||["checkbox","radio","file","hidden"].includes(i.type))&&Q.set(!0),"hidden"===i.type&&K.update((e=>c(e,f(i),i.value))),n(i))!function(e){if(e.multiple){const t=Array.from(e.options).filter((e=>e.selected)).map((e=>e.value));K.update((r=>c(r,f(e),t)))}else K.update((t=>c(t,f(e),e.value)))}(i);else{if(!r(i))return;"checkbox"===i.type?function(e){const n=f(e),i=Array.from(t.querySelectorAll(`[name="${e.name}"]`)).filter((e=>!!s(e)&&n===f(e)));if(0!==i.length)1===i.length?K.update((t=>c(t,f(e),e.checked))):K.update((t=>c(t,f(e),i.filter(r).filter((e=>e.checked)).map((e=>e.value)))))}(i):"radio"===i.type?function(e){const n=t.querySelectorAll(`[name="${e.name}"]`),i=Array.from(n).find((e=>r(e)&&e.checked));K.update((t=>c(t,f(e),null==i?void 0:i.value)))}(i):"file"===i.type&&function(e){var t;const r=Array.from(null!==(t=e.files)&&void 0!==t?t:[]);K.update((t=>c(t,f(e),e.multiple?r:r[0])))}(i)}}function E(e){const t=e.target;t&&s(t)&&!P(t)&&t.name&&(D(f(t),!0),Y.set(t.name))}function S(e){e.preventDefault(),x()}w(t),M(L(l(d),F())),T(F()),G.set(b);const O=C((()=>{k().forEach((e=>{var t;return null===(t=e.destroy)||void 0===t?void 0:t.call(e)})),j(p.map(i("UPDATE")));const{defaultData:e,defaultTouched:r}=y(t);K.update((t=>W(t,e))),G.update((e=>W(e,r)))}),0);let V=[];const I=C((()=>{k().forEach((e=>{var t;return null===(t=e.destroy)||void 0===t?void 0:t.call(e)})),j(p.map(i("UPDATE"))),function(t){let r=e(K),n=e(G),i=e(z),s=e(X);for(const a of t.reverse()){if(a.hasAttribute("data-felte-keep-on-remove")&&"false"!==a.dataset.felteKeepOnRemove)continue;const t=/.*(\[[0-9]+\]|\.[0-9]+)\.[^.]+$/;let l=f(a);const d=e(G);if(t.test(l)){const e=l.split(".").slice(0,-1).join("."),t=o(d,e);u(t)&&Object.keys(t).length<=1&&(l=e)}r=_(r,l),n=_(n,l),i=_(i,l),s=_(s,l)}K.set(r),G.set(n),z.set(i),X.set(s)}(V),V=[]}),0),N=new MutationObserver((function(e){for(const t of e)if("childList"===t.type){if(t.addedNodes.length>0){if(!Array.from(t.addedNodes).some((e=>{if(!a(e))return!1;if(s(e))return!0;return v(e).length>0})))continue;O()}if(t.removedNodes.length>0)for(const e of t.removedNodes){if(!a(e))continue;const t=v(e);0!==t.length&&(V.push(...t),I())}}}));N.observe(t,{childList:!0,subtree:!0}),t.addEventListener("input",g),t.addEventListener("change",A),t.addEventListener("focusout",E),t.addEventListener("submit",ee),t.addEventListener("reset",S);const q=z.subscribe((e=>{for(const r of t.elements){if(!s(r)||!r.name)continue;const t=o(e,f(r)),n=Array.isArray(t)?t.join("\n"):"string"==typeof t?t:void 0;n!==r.dataset.felteValidationMessage&&(n?(r.dataset.felteValidationMessage=n,r.setAttribute("aria-invalid","true")):(delete r.dataset.felteValidationMessage,r.removeAttribute("aria-invalid")))}}));return{destroy(){N.disconnect(),t.removeEventListener("input",g),t.removeEventListener("change",A),t.removeEventListener("focusout",E),t.removeEventListener("submit",ee),t.removeEventListener("reset",S),q(),k().forEach((e=>{var t;return null===(t=e.destroy)||void 0===t?void 0:t.call(e)}))}}},createSubmitHandler:Z,handleSubmit:ee}}function R(e,t){return t?Array.isArray(t)?t.reduce(((e,t)=>t(e)),e):t(e):e}function U(e,t){if(!u(e)&&!u(t)){if(null===e||""===e)return t;if(null===t||""===t)return e;if(!t)return e;if(e&&t){if(Array.isArray(e)){if(!Array.isArray(t))return[...e,t];const r=[],n=Math.max(t.length,e.length);for(let i=0;i<n;i++){let n=e[i],s=t[i];u(n)||u(s)?r.push(q([null!=n?n:{},null!=s?s:{}])):(Array.isArray(n)||(n=[n]),Array.isArray(s)||(s=[s]),r.push(...n,...s))}return r.filter(Boolean)}return Array.isArray(t)||(t=[t]),[e,...t].reduce(((e,t)=>e.concat(t)),[]).filter(Boolean)}}}function q(e){return x(...e,U)}function $(e,t){if(u(e))return!t||u(t)&&0===Object.keys(t).length?V(e,null):void 0;if(Array.isArray(e)){if(e.some(u))return;const r=Array.isArray(t)?t:[];return e.map(((e,t)=>{const n=r[t];return Array.isArray(n)&&0===n.length?null:e&&n||null}))}return Array.isArray(t)&&0===t.length?null:Array.isArray(t)?e?t:null:e&&t?[t]:null}function B(e,t){if(u(e))return!t||u(t)&&0===Object.keys(t).length?V(e,null):void 0;if(Array.isArray(e)){if(e.some(u))return;const r=Array.isArray(t)?t:[];return e.map(((e,t)=>{const n=r[t];return Array.isArray(n)&&0===n.length?null:n||null}))}return Array.isArray(t)&&0===t.length?null:Array.isArray(t)?t:t?[t]:null}function K([e,t]){return x(t,e,$)}function z([e,t]){return x(t,e,B)}function X(e,t){var r,n,i,s,a,o,u,d,c;const f=function(e){return function(t,r,n){const i=Array.isArray(t)?t:[t],s=new Array(i.length),a=e(n),o=a.set,u=a.subscribe;let l;return a.subscribe=function(e){const t=u(e);return()=>{t()}},[a,function(){l=i.map(((e,t)=>e.subscribe((e=>{s[t]=e,o(r(s))}))))},function(){null==l||l.forEach((e=>e()))}]}}(e),v=t.initialValues=t.initialValues?S(R(l(t.initialValues),t.transform)):{},h=E(O(v),!1),m=e(h),y=e(0),[p,b,g]=f([m,y],(([e,t])=>N(e,(e=>!!e))&&t>=1),!1);function A(e){let t;return async function(r,n,i,s=!1){if(!i||!r)return;let a=n&&Object.keys(n).length>0?n:V(r,[]);const o=function(e){const t={aborted:!1,priority:e};return{signal:t,abort(){t.aborted=!0}}}(s);if((null==t?void 0:t.signal.priority)&&!s||(null==t||t.abort(),t=o),t.signal.priority&&!s)return;y.update((e=>e+1));const u=(l=r,(d=i)?(Array.isArray(d)?d:[d]).map((e=>e(l))):[]);var l,d;return u.forEach((async t=>{const r=await t;o.signal.aborted||(a=q([a,r]),e.set(a))})),await Promise.all(u),t=void 0,y.update((e=>e-1)),a}}delete p.set,delete p.update;let w=V(h,[]);const F=e(v),_=V(h,[]),j=e(_),k=e(l(_)),[T,D,I]=f([j,k],q,l(_)),x=V(h,[]),L=e(x),P=e(l(x)),[M,W,H]=f([L,P],q,l(x)),[U,$,B]=f([T,m],K,l(_)),[X,G,J]=f([M,m],z,l(x));let Q=!1;const[Y,Z,ee]=f(T,(([e])=>{var r;return Q?!N(e,(e=>Array.isArray(e)?e.length>=1:!!e)):(Q=!0,!t.validate&&!(null===(r=t.debounced)||void 0===r?void 0:r.validate))}),!t.validate&&!(null===(r=t.debounced)||void 0===r?void 0:r.validate));delete Y.set,delete Y.update;const te=e(!1),re=e(!1),ne=e(null),ie=A(j),se=A(L),ae=A(k),oe=A(P),ue=C(ae,null!==(a=null!==(i=null===(n=t.debounced)||void 0===n?void 0:n.validateTimeout)&&void 0!==i?i:null===(s=t.debounced)||void 0===s?void 0:s.timeout)&&void 0!==a?a:300),le=C(oe,null!==(c=null!==(u=null===(o=t.debounced)||void 0===o?void 0:o.warnTimeout)&&void 0!==u?u:null===(d=t.debounced)||void 0===d?void 0:d.timeout)&&void 0!==c?c:300);let de=_,ce=x;function fe(){const e=F.subscribe((e=>{var r,n;const i=O(e);ie(i,w,t.validate),se(i,w,t.warn),ue(i,w,null===(r=t.debounced)||void 0===r?void 0:r.validate),le(i,w,null===(n=t.debounced)||void 0===n?void 0:n.warn)})),r=m.subscribe((e=>{w=V(e,[])})),n=T.subscribe((e=>{de=e})),i=M.subscribe((e=>{ce=e}));return D(),Z(),W(),$(),G(),b(),function(){e(),B(),I(),H(),J(),ee(),g(),r(),n(),i()}}function ve(e){j.set(e(de)),k.set({})}function he(e){L.set(e(ce)),P.set({})}return U.set=function(e){ve((()=>e))},U.update=ve,X.set=function(e){he((()=>e))},X.update=he,{data:F,errors:U,warnings:X,touched:m,isValid:Y,isSubmitting:te,isDirty:re,isValidating:p,interacted:ne,validateErrors:async function(e,r){var n;const i=O(e),s=ie(i,w,null!=r?r:t.validate,!0);if(r)return s;const a=ae(i,w,null===(n=t.debounced)||void 0===n?void 0:n.validate,!0);return q(await Promise.all([s,a]))},validateWarnings:async function(e,r){var n;const i=O(e),s=se(i,w,null!=r?r:t.warn,!0);if(r)return s;const a=oe(i,w,null===(n=t.debounced)||void 0===n?void 0:n.warn,!0);return q(await Promise.all([s,a]))},cleanup:t.preventStoreStart?()=>{}:fe(),start:fe}}function G(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((e,r)=>G(e,t[r])));if(u(e)&&u(t)){const r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every((r=>G(e[r],t[r])))}return!1}const J=[],Q=()=>{};function Y(e,t=Q){let r;const n=new Set;function i(t){if(s=t,((i=e)!=i?s==s:i!==s||i&&"object"==typeof i||"function"==typeof i)&&(e=t,r)){const t=!J.length;for(const t of n)t[1](),J.push(t,e);if(t){for(let e=0;e<J.length;e+=2)J[e][0](J[e+1]);J.length=0}}var i,s}return{set:i,update:function(t){i(t(e))},subscribe:function(s,a=Q){const o=[s,a];return n.add(o),1===n.size&&(r=t(i)||Q),s(e),()=>{n.delete(o),r&&0===n.size&&(r(),r=null)}}}}function Z(e){return function(){throw new TypeError(`Can't call "${e}" on HTMLFelteFormElement. The element is not ready yet.`)}}const ee=["data","errors","touched","warnings","isSubmitting","isDirty","isValid","isValidating","interacted"];class te extends HTMLElement{constructor(){super(...arguments),this.id="",this._configuration={},this._storeValues={data:void 0,errors:void 0,touched:void 0,warnings:void 0,isSubmitting:!1,isDirty:!1,isValid:void 0,isValidating:!1,interacted:null},this.setData=Z("setData"),this.setFields=Z("setFields"),this.setInitialValues=Z("setInitialValues"),this.addField=Z("addField"),this.unsetField=Z("unsetField"),this.swapFields=Z("swapFields"),this.moveField=Z("moveField"),this.resetField=Z("resetField"),this.reset=Z("reset"),this.submit=Z("submit"),this.createSubmitHandler=Z("createSubmitHandler"),this.setErrors=Z("setErrors"),this.setTouched=Z("setTouched"),this.setWarnings=Z("setWarnings"),this.setIsSubmitting=Z("setIsSubmitting"),this.setIsDirty=Z("setIsDirty"),this.setInteracted=Z("setInteracted"),this._ready=!1,this.validate=Z("validate"),this._formElement=null,this._updateForm=()=>{var e;const t=this.querySelector("form");t&&t!==this._formElement&&(this.dispatchEvent(new Event("felteconnect",{bubbles:!0,composed:!0})),this._formElement=t,null===(e=this._destroy)||void 0===e||e.call(this),this._destroy=void 0,this._createForm())}}set configuration(e){this._configuration=e,this._destroy&&(this._destroy(),this._destroy=void 0,this._ready=!1,this._createForm())}get configuration(){return this._configuration}get data(){return this._storeValues.data}get errors(){return this._storeValues.errors}get touched(){return this._storeValues.touched}get warnings(){return this._storeValues.warnings}get isSubmitting(){return this._storeValues.isSubmitting}get isDirty(){return this._storeValues.isDirty}get isValid(){return this._storeValues.isValid}get isValidating(){return this._storeValues.isValidating}get interacted(){return this._storeValues.interacted}get ready(){return this._ready}_createForm(){var e;const t=this._formElement;if(!t)return;const r=this.configuration;this.elements=t.elements;const{form:n,cleanup:i,...s}=function(e,t){var r,n;function i(t,{debounced:r,level:n}={debounced:!1,level:"error"}){var i;const s="error"===n?"validate":"warn";null!==(i=e.debounced)&&void 0!==i||(e.debounced={});const a=r?e.debounced:e;a[s]?a[s]=[...a[s],t]:a[s]=[t]}function s(t){e.transform?e.transform=[...e.transform,t]:e.transform=[t]}null!==(r=e.extend)&&void 0!==r||(e.extend=[]),null!==(n=e.debounced)&&void 0!==n||(e.debounced={}),e.validate&&!Array.isArray(e.validate)&&(e.validate=[e.validate]),e.debounced.validate&&!Array.isArray(e.debounced.validate)&&(e.debounced.validate=[e.debounced.validate]),e.transform&&!Array.isArray(e.transform)&&(e.transform=[e.transform]),e.warn&&!Array.isArray(e.warn)&&(e.warn=[e.warn]),e.debounced.warn&&!Array.isArray(e.debounced.warn)&&(e.debounced.warn=[e.debounced.warn]);const a=Array.isArray(e.extend)?e.extend:[e.extend];let o=[];const{isSubmitting:u,isValidating:l,data:d,errors:c,warnings:f,touched:v,isValid:h,isDirty:m,cleanup:y,start:p,validateErrors:b,validateWarnings:g,interacted:A}=X(t.storeFactory,e),E=d.update,w=d.set;d.update=t=>E((r=>S(R(t(r),e.transform)))),d.set=t=>w(S(R(t,e.transform)));const O=D({extender:a,config:e,addValidator:i,addTransformer:s,validateErrors:b,validateWarnings:g,stores:{data:d,errors:c,warnings:f,touched:v,isValid:h,isValidating:l,isSubmitting:u,isDirty:m,interacted:A}});o=a.map((t=>t({stage:"SETUP",errors:c,warnings:f,touched:v,data:d,config:e,addValidator:i,addTransformer:s,setFields:O.public.setFields,reset:O.public.reset,validate:O.public.validate})));const F=Object.assign({config:e,stores:{data:d,touched:v,errors:c,warnings:f,isSubmitting:u,isValidating:l,isValid:h,isDirty:m,interacted:A},helpers:Object.assign(Object.assign({},O.public),{addTransformer:s,addValidator:i}),extender:a,validateErrors:b,validateWarnings:g,_getCurrentExtenders:()=>o,_setCurrentExtenders:e=>{o=e}},O.private),{form:V,createSubmitHandler:_,handleSubmit:j}=H(F);return Object.assign({data:d,errors:c,warnings:f,touched:v,isValid:h,isSubmitting:u,isValidating:l,isDirty:m,interacted:A,form:V,handleSubmit:j,createSubmitHandler:_,cleanup:y,startStores:p},O.public)}(r,{storeFactory:Y});this.setData=s.setData,this.setFields=s.setFields,this.setErrors=s.setErrors,this.setTouched=s.setTouched,this.setWarnings=s.setWarnings,this.setIsSubmitting=s.setIsSubmitting,this.setIsDirty=s.setIsDirty,this.setInteracted=s.setInteracted,this.setInitialValues=s.setInitialValues,this.validate=s.validate,this.addField=s.addField,this.unsetField=s.unsetField,this.swapFields=s.swapFields,this.moveField=s.moveField,this.resetField=s.resetField,this.reset=s.reset,this.submit=s.handleSubmit,this.createSubmitHandler=s.createSubmitHandler;const a=ee.map((e=>s[e].subscribe((t=>{if(G(t,this._storeValues[e]))return;this._storeValues[e]=t;const r=this[`on${n=e,n.charAt(0).toUpperCase()+n.slice(1)}Change`];var n;"function"==typeof r&&r(t),this.dispatchEvent(new Event(`${e.toLowerCase()}change`))})))),{destroy:o}=n(t),{createSubmitEvent:u,createErrorEvent:l,createSuccessEvent:d}=I(),c=e=>{const t=e,r=u();this.dispatchEvent(r),r.defaultPrevented&&t.preventDefault(),t.onSubmit=r.onSubmit,t.onSuccess=r.onSuccess,t.onError=r.onError},f=e=>{const t=d(e.detail);this.dispatchEvent(t)},v=e=>{const t=e,r=l(t.detail);this.dispatchEvent(r),t.errors=r.errors,r.defaultPrevented&&t.preventDefault()};t.addEventListener("feltesubmit",c),t.addEventListener("feltesuccess",f),t.addEventListener("felteerror",v),this._destroy=()=>{o(),i(),t.removeEventListener("feltesubmit",c),t.removeEventListener("feltesuccess",f),t.removeEventListener("felteerror",v),a.forEach((e=>e()))},this._ready=!0,null===(e=this.onFelteReady)||void 0===e||e.call(this),this.dispatchEvent(new Event("felteready",{bubbles:!0,composed:!0}))}connectedCallback(){setTimeout((()=>{this._updateForm(),this._observer=new MutationObserver(this._updateForm),this._observer.observe(this,{childList:!0})}))}disconnectedCallback(){var e,t;null===(e=this._destroy)||void 0===e||e.call(this),null===(t=this._observer)||void 0===t||t.disconnect()}static get observedAttributes(){return["id"]}attributeChangedCallback(e,t,r){if(t!==r)switch(e){case"id":this.id=r}}}customElements.get("felte-form")||(customElements.define("felte-form",te),window.HTMLFelteFormElement=te);export{te as FelteForm,t as FelteSubmitError};
***************************************************************************** */function F(e){return function(t){if(u(t)){return function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(V(t,e),["key"])}return e}}function V(e,t){return A(e,(e=>u(e)?V(e,t):Array.isArray(e)?e.map(F(t)):t))}function _(e,t){if(!e||Object(e)!==e)return;void 0!==e&&(e=l(e));const r=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g)||[],n=1===r.length?e:o(e,r.slice(0,-1).join("."));return Array.isArray(n)?n.splice(Number(r[r.length-1]),1):null==n||delete n[r[r.length-1]],e}function j(e,t,r,n){return c(e,t,(e=>void 0===e||Array.isArray(e)?(e||(e=[]),void 0===n?e.push(r):e.splice(n,0,r),e):e))}function k(e){return"function"==typeof e}function T(e){return(t,r)=>{if("string"==typeof t){const n=t;e((e=>{const t=k(r)?r(o(e,n)):r;return d(e,n,t)}))}else e((e=>k(t)?t(e):t))}}function D({stores:t,config:r,validateErrors:n,validateWarnings:i}){var s;let a,f=S(null!==(s=r.initialValues)&&void 0!==s?s:{});const{data:v,touched:h,errors:m,warnings:y,isDirty:p,isSubmitting:g,interacted:A}=t,O=T(v.update),F=T(h.update),k=T(m.update),D=T(y.update);function I(e){O((t=>{const r=e(t);return a&&b(a,r),r}))}const x=(e,t,r)=>{T(I)(e,t),"string"==typeof e&&r&&F(e,!0)};function L(e){m.update(e),y.update(e),h.update(e),v.update((t=>{const r=e(t);return setTimeout((()=>a&&b(a,r))),r}))}const N=T(g.update),P=T(p.update),C=T(A.update);return{public:{setData:O,setFields:x,setTouched:F,setErrors:k,setWarnings:D,setIsSubmitting:N,setIsDirty:P,setInteracted:C,validate:async function(){const t=e(v);h.set(E(t,!0)),A.set(null);const r=await n(t);return await i(t),r},reset:function(){x(l(f)),F((e=>V(e,!1))),A.set(null),p.set(!1)},unsetField:function(e){L((t=>_(t,e)))},resetField:function(e){const t=o(f,e),r=!!u(t)&&E(t,!1),n=u(r)?V(r,[]):[];v.update((r=>{const n=d(r,e,t);return a&&b(a,n),n})),h.update((t=>d(t,e,r))),m.update((t=>d(t,e,n))),y.update((t=>d(t,e,n)))},addField:function(e,t,r){const n=!!u(t)&&E(t,!1),i=u(n)?V(n,[]):[];t=u(t)?Object.assign(Object.assign({},t),{key:w()}):t,m.update((t=>j(t,e,i,r))),y.update((t=>j(t,e,i,r))),h.update((t=>j(t,e,n,r))),v.update((n=>{const i=j(n,e,t,r);return setTimeout((()=>a&&b(a,i))),i}))},swapFields:function(e,t,r){L((n=>function(e,t,r,n){return c(e,t,(e=>e&&Array.isArray(e)?([e[r],e[n]]=[e[n],e[r]],e):e))}(n,e,t,r)))},moveField:function(e,t,r){L((n=>function(e,t,r,n){return c(e,t,(e=>e&&Array.isArray(e)?(e.splice(n,0,e.splice(r,1)[0]),e):e))}(n,e,t,r)))},setInitialValues:e=>{f=S(e)}},private:{_setFormNode(e){a=e},_getFormNode:()=>a,_getInitialValues:()=>f}}}function I(){class e extends CustomEvent{constructor(e){super("feltesuccess",{detail:e})}}class t extends CustomEvent{constructor(e){super("felteerror",{detail:e,cancelable:!0})}setErrors(e){this.preventDefault(),this.errors=e}}class r extends Event{constructor(){super("feltesubmit",{cancelable:!0})}handleSubmit(e){this.onSubmit=e}handleError(e){this.onError=e}handleSuccess(e){this.onSuccess=e}}return{createErrorEvent:e=>new t(e),createSubmitEvent:()=>new r,createSuccessEvent:t=>new e(t)}}function x(...e){const t=e.pop(),r=l(e.shift());if(0===e.length)return r;for(const n of e){if(!n)continue;let e=t(r,n);if(void 0!==e)return e;const i=Array.from(new Set(Object.keys(r).concat(Object.keys(n))));for(const s of i)if(e=t(r[s],n[s]),void 0!==e)r[s]=e;else if(u(n[s])&&u(r[s]))r[s]=x(r[s],n[s],t);else if(Array.isArray(n[s]))r[s]=n[s].map(((e,n)=>{if(!u(e))return e;return x(Array.isArray(r[s])?r[s][n]:r[s],e,t)}));else if(u(n[s])){const e=V(l(n[s]),void 0);r[s]=x(e,n[s],t)}else void 0!==n[s]&&(r[s]=n[s])}return r}function L(...e){return x(...e,(()=>{}))}function N(e,t){return function(e,t){return Object.keys(e).some((r=>t(e[r])))}(e,(e=>u(e)?N(e,t):Array.isArray(e)?0===e.length||e.every((e=>"string"==typeof e))?t(e):e.some((e=>u(e)?N(e,t):t(e))):t(e)))}function P(e){let t=e;for(;t&&"FORM"!==t.nodeName;){if(t.hasAttribute("data-felte-ignore"))return!0;t=t.parentElement}return!1}function C(e,t){let r;return(...n)=>{clearTimeout(r),r=setTimeout((()=>{e.apply(this,n)}),t)}}function M(e,t){if(!u(e)||!u(t)){if(Array.isArray(t)){if(t.some(u))return;const r=Array.isArray(e)?e:[];return t.map(((e,t)=>{var n;return null!==(n=r[t])&&void 0!==n?n:e}))}return void 0!==e?e:void 0}}function W(...e){return x(...e,M)}function H({helpers:i,stores:c,config:h,extender:p,validateErrors:b,validateWarnings:A,_setFormNode:w,_getFormNode:S,_getInitialValues:F,_setCurrentExtenders:j,_getCurrentExtenders:k}){const{setFields:T,setTouched:D,reset:x,setInitialValues:M}=i,{addValidator:H,addTransformer:R,validate:U,setIsDirty:q,setIsSubmitting:$}=i,B=g(i,["addValidator","addTransformer","validate","setIsDirty","setIsSubmitting"]),{data:K,errors:z,warnings:X,touched:G,isSubmitting:J,isDirty:Q,interacted:Y}=c;function Z(r){return async function(n){var i,a,o,u,l,c,d;const f=S(),{createErrorEvent:v,createSubmitEvent:m,createSuccessEvent:y}=I(),p=m();null==f||f.dispatchEvent(p);const g=null!==(a=null!==(i=p.onError)&&void 0!==i?i:null==r?void 0:r.onError)&&void 0!==a?a:h.onError,w=null!==(u=null!==(o=p.onSuccess)&&void 0!==o?o:null==r?void 0:r.onSuccess)&&void 0!==u?u:h.onSuccess,F=null!==(d=null!==(c=null!==(l=p.onSubmit)&&void 0!==l?l:null==r?void 0:r.onSubmit)&&void 0!==c?c:h.onSubmit)&&void 0!==d?d:function(e){if(e)return async function(){let r=new FormData(e);const n=new URL(e.action),i="get"===e.method.toLowerCase()?"get":n.searchParams.get("_method")||e.method;let s,a=e.enctype;e.querySelector('input[type="file"]')&&(a="multipart/form-data"),"get"!==i&&"application/x-www-form-urlencoded"!==a||(r=new URLSearchParams(r)),"get"===i?(r.forEach(((e,t)=>{n.searchParams.append(t,e)})),s={method:i}):s={method:i,body:r,headers:{"Content-Type":a}};const o=await window.fetch(n.toString(),s);if(o.ok)return o;throw new t("An error occurred while submitting the form",o)}}(f);if(!F)return;if(null==n||n.preventDefault(),p.defaultPrevented)return;J.set(!0),Y.set(null);const _=O(e(K)),j=await b(_,null==r?void 0:r.validate),T=await A(_,null==r?void 0:r.warn);if(T&&X.set(L(V(_,[]),T)),G.set(E(_,!0)),j){G.set(E(j,!0));if(N(j,(e=>Array.isArray(e)?e.length>=1:!!e)))return await new Promise((e=>setTimeout(e))),k().forEach((e=>{var t;return null===(t=e.onSubmitError)||void 0===t?void 0:t.call(e,{data:_,errors:j})})),void J.set(!1)}const D=Object.assign(Object.assign({},B),{form:f,controls:f&&Array.from(f.elements).filter(s),config:Object.assign(Object.assign({},h),r)});try{const e=await F(_,D);null==f||f.dispatchEvent(y(Object.assign({response:e},D))),await(null==w?void 0:w(e,D))}catch(t){const r=v(Object.assign({error:t},D));if(null==f||f.dispatchEvent(r),!g&&!r.defaultPrevented)throw t;if(!g&&!r.errors)return;const n=r.errors||await(null==g?void 0:g(t,D));n&&(G.set(E(n,!0)),z.set(n),await new Promise((e=>setTimeout(e))),k().forEach((t=>{var r;return null===(r=t.onSubmitError)||void 0===r?void 0:r.call(t,{data:_,errors:e(z)})})))}finally{J.set(!1)}}}const ee=Z();return{form:function(t){function i(e){return function(r){return r({form:t,stage:e,controls:Array.from(t.elements).filter(s),data:K,errors:z,warnings:X,touched:G,config:h,addValidator:H,addTransformer:R,setFields:T,validate:U,reset:x})}}t.requestSubmit||(t.requestSubmit=ee),j(p.map(i("MOUNT"))),t.noValidate=!!h.validate;const{defaultData:c,defaultTouched:b}=y(t);function g(e){const t=e.target;if(!t||!s(t)||n(t)||P(t))return;if(["checkbox","radio","file"].includes(t.type))return;if(!t.name)return;Q.set(!0);const r=m(t);Y.set(t.name),K.update((e=>d(e,f(t),r)))}function A(e){const i=e.target;if(i&&s(i)&&!P(i)&&i.name)if(D(f(i),!0),Y.set(i.name),(n(i)||["checkbox","radio","file","hidden"].includes(i.type))&&Q.set(!0),"hidden"===i.type&&K.update((e=>d(e,f(i),i.value))),n(i))!function(e){if(e.multiple){const t=Array.from(e.options).filter((e=>e.selected)).map((e=>e.value));K.update((r=>d(r,f(e),t)))}else K.update((t=>d(t,f(e),e.value)))}(i);else{if(!r(i))return;"checkbox"===i.type?function(e){const n=f(e),i=Array.from(t.querySelectorAll(`[name="${e.name}"]`)).filter((e=>!!s(e)&&n===f(e)));if(0!==i.length)1===i.length?K.update((t=>d(t,f(e),e.checked))):K.update((t=>d(t,f(e),i.filter(r).filter((e=>e.checked)).map((e=>e.value)))))}(i):"radio"===i.type?function(e){const n=t.querySelectorAll(`[name="${e.name}"]`),i=Array.from(n).find((e=>r(e)&&e.checked));K.update((t=>d(t,f(e),null==i?void 0:i.value)))}(i):"file"===i.type&&function(e){var t;const r=Array.from(null!==(t=e.files)&&void 0!==t?t:[]);K.update((t=>d(t,f(e),e.multiple?r:r[0])))}(i)}}function E(e){const t=e.target;t&&s(t)&&!P(t)&&t.name&&(D(f(t),!0),Y.set(t.name))}function S(e){e.preventDefault(),x()}w(t),M(L(l(c),F())),T(F()),G.set(b);const O=C((()=>{k().forEach((e=>{var t;return null===(t=e.destroy)||void 0===t?void 0:t.call(e)})),j(p.map(i("UPDATE")));const{defaultData:e,defaultTouched:r}=y(t);K.update((t=>W(t,e))),G.update((e=>W(e,r)))}),0);let V=[];const I=C((()=>{k().forEach((e=>{var t;return null===(t=e.destroy)||void 0===t?void 0:t.call(e)})),j(p.map(i("UPDATE"))),function(t){let r=e(K),n=e(G),i=e(z),s=e(X);for(const a of t.reverse()){if(a.hasAttribute("data-felte-keep-on-remove")&&"false"!==a.dataset.felteKeepOnRemove)continue;const t=/.*(\[[0-9]+\]|\.[0-9]+)\.[^.]+$/;let l=f(a);const c=e(G);if(t.test(l)){const e=l.split(".").slice(0,-1).join("."),t=o(c,e);u(t)&&Object.keys(t).length<=1&&(l=e)}r=_(r,l),n=_(n,l),i=_(i,l),s=_(s,l)}K.set(r),G.set(n),z.set(i),X.set(s)}(V),V=[]}),0),N=new MutationObserver((function(e){for(const t of e)if("childList"===t.type){if(t.addedNodes.length>0){if(!Array.from(t.addedNodes).some((e=>{if(!a(e))return!1;if(s(e))return!0;return v(e).length>0})))continue;O()}if(t.removedNodes.length>0)for(const e of t.removedNodes){if(!a(e))continue;const t=v(e);0!==t.length&&(V.push(...t),I())}}}));N.observe(t,{childList:!0,subtree:!0}),t.addEventListener("input",g),t.addEventListener("change",A),t.addEventListener("focusout",E),t.addEventListener("submit",ee),t.addEventListener("reset",S);const q=z.subscribe((e=>{for(const r of t.elements){if(!s(r)||!r.name)continue;const t=o(e,f(r)),n=Array.isArray(t)?t.join("\n"):"string"==typeof t?t:void 0;n!==r.dataset.felteValidationMessage&&(n?(r.dataset.felteValidationMessage=n,r.setAttribute("aria-invalid","true")):(delete r.dataset.felteValidationMessage,r.removeAttribute("aria-invalid")))}}));return{destroy(){N.disconnect(),t.removeEventListener("input",g),t.removeEventListener("change",A),t.removeEventListener("focusout",E),t.removeEventListener("submit",ee),t.removeEventListener("reset",S),q(),k().forEach((e=>{var t;return null===(t=e.destroy)||void 0===t?void 0:t.call(e)}))}}},createSubmitHandler:Z,handleSubmit:ee}}function R(e,t){return t?Array.isArray(t)?t.reduce(((e,t)=>t(e)),e):t(e):e}function U(e,t){if(!u(e)&&!u(t)){if(null===e||""===e)return t;if(null===t||""===t)return e;if(!t)return e;if(e&&t){if(Array.isArray(e)){if(!Array.isArray(t))return[...e,t];const r=[],n=Math.max(t.length,e.length);for(let i=0;i<n;i++){let n=e[i],s=t[i];u(n)||u(s)?r.push(q([null!=n?n:{},null!=s?s:{}])):(Array.isArray(n)||(n=[n]),Array.isArray(s)||(s=[s]),r.push(...n,...s))}return r.filter(Boolean)}return Array.isArray(t)||(t=[t]),[e,...t].reduce(((e,t)=>e.concat(t)),[]).filter(Boolean)}}}function q(e){return x(...e,U)}function $(e,t){if(u(e))return!t||u(t)&&0===Object.keys(t).length?V(e,null):void 0;if(Array.isArray(e)){if(e.some(u))return;const r=Array.isArray(t)?t:[];return e.map(((e,t)=>{const n=r[t];return Array.isArray(n)&&0===n.length?null:e&&n||null}))}return Array.isArray(t)&&0===t.length?null:Array.isArray(t)?e?t:null:e&&t?[t]:null}function B(e,t){if(u(e))return!t||u(t)&&0===Object.keys(t).length?V(e,null):void 0;if(Array.isArray(e)){if(e.some(u))return;const r=Array.isArray(t)?t:[];return e.map(((e,t)=>{const n=r[t];return Array.isArray(n)&&0===n.length?null:n||null}))}return Array.isArray(t)&&0===t.length?null:Array.isArray(t)?t:t?[t]:null}function K([e,t]){return x(t,e,$)}function z([e,t]){return x(t,e,B)}function X(e,t){var r,n,i,s,a,o,u,c,d;const f=function(e){return function(t,r,n){const i=Array.isArray(t)?t:[t],s=new Array(i.length),a=e(n),o=a.set,u=a.subscribe;let l;return a.subscribe=function(e){const t=u(e);return()=>{t()}},[a,function(){l=i.map(((e,t)=>e.subscribe((e=>{s[t]=e,o(r(s))}))))},function(){null==l||l.forEach((e=>e()))}]}}(e),v=t.initialValues=t.initialValues?S(R(l(t.initialValues),t.transform)):{},h=E(O(v),!1),m=e(h),y=e(0),[p,b,g]=f([m,y],(([e,t])=>N(e,(e=>!!e))&&t>=1),!1);function A(e){let t;return async function(r,n,i,s=!1){if(!i||!r)return;let a=n&&Object.keys(n).length>0?n:V(r,[]);const o=function(e){const t={aborted:!1,priority:e};return{signal:t,abort(){t.aborted=!0}}}(s);if((null==t?void 0:t.signal.priority)&&!s||(null==t||t.abort(),t=o),t.signal.priority&&!s)return;y.update((e=>e+1));const u=(l=r,(c=i)?(Array.isArray(c)?c:[c]).map((e=>e(l))):[]);var l,c;return u.forEach((async t=>{const r=await t;o.signal.aborted||(a=q([a,r]),e.set(a))})),await Promise.all(u),t=void 0,y.update((e=>e-1)),a}}delete p.set,delete p.update;let w=V(h,[]);const F=e(v),_=V(h,[]),j=e(_),k=e(l(_)),[T,D,I]=f([j,k],q,l(_)),x=V(h,[]),L=e(x),P=e(l(x)),[M,W,H]=f([L,P],q,l(x)),[U,$,B]=f([T,m],K,l(_)),[X,G,J]=f([M,m],z,l(x));let Q=!1;const[Y,Z,ee]=f(T,(([e])=>{var r;return Q?!N(e,(e=>Array.isArray(e)?e.length>=1:!!e)):(Q=!0,!t.validate&&!(null===(r=t.debounced)||void 0===r?void 0:r.validate))}),!t.validate&&!(null===(r=t.debounced)||void 0===r?void 0:r.validate));delete Y.set,delete Y.update;const te=e(!1),re=e(!1),ne=e(null),ie=A(j),se=A(L),ae=A(k),oe=A(P),ue=C(ae,null!==(a=null!==(i=null===(n=t.debounced)||void 0===n?void 0:n.validateTimeout)&&void 0!==i?i:null===(s=t.debounced)||void 0===s?void 0:s.timeout)&&void 0!==a?a:300),le=C(oe,null!==(d=null!==(u=null===(o=t.debounced)||void 0===o?void 0:o.warnTimeout)&&void 0!==u?u:null===(c=t.debounced)||void 0===c?void 0:c.timeout)&&void 0!==d?d:300);let ce=_,de=x;function fe(){const e=F.subscribe((e=>{var r,n;const i=O(e);ie(i,w,t.validate),se(i,w,t.warn),ue(i,w,null===(r=t.debounced)||void 0===r?void 0:r.validate),le(i,w,null===(n=t.debounced)||void 0===n?void 0:n.warn)})),r=m.subscribe((e=>{w=V(e,[])})),n=T.subscribe((e=>{ce=e})),i=M.subscribe((e=>{de=e}));return D(),Z(),W(),$(),G(),b(),function(){e(),B(),I(),H(),J(),ee(),g(),r(),n(),i()}}function ve(e){j.set(e(ce)),k.set({})}function he(e){L.set(e(de)),P.set({})}return U.set=function(e){ve((()=>e))},U.update=ve,X.set=function(e){he((()=>e))},X.update=he,{data:F,errors:U,warnings:X,touched:m,isValid:Y,isSubmitting:te,isDirty:re,isValidating:p,interacted:ne,validateErrors:async function(e,r){var n;const i=O(e),s=ie(i,w,null!=r?r:t.validate,!0);if(r)return s;const a=ae(i,w,null===(n=t.debounced)||void 0===n?void 0:n.validate,!0);return q(await Promise.all([s,a]))},validateWarnings:async function(e,r){var n;const i=O(e),s=se(i,w,null!=r?r:t.warn,!0);if(r)return s;const a=oe(i,w,null===(n=t.debounced)||void 0===n?void 0:n.warn,!0);return q(await Promise.all([s,a]))},cleanup:t.preventStoreStart?()=>{}:fe(),start:fe}}function G(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((e,r)=>G(e,t[r])));if(u(e)&&u(t)){const r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every((r=>G(e[r],t[r])))}return!1}const J=[],Q=()=>{};function Y(e,t=Q){let r;const n=new Set;function i(t){if(s=t,((i=e)!=i?s==s:i!==s||i&&"object"==typeof i||"function"==typeof i)&&(e=t,r)){const t=!J.length;for(const t of n)t[1](),J.push(t,e);if(t){for(let e=0;e<J.length;e+=2)J[e][0](J[e+1]);J.length=0}}var i,s}return{set:i,update:function(t){i(t(e))},subscribe:function(s,a=Q){const o=[s,a];return n.add(o),1===n.size&&(r=t(i)||Q),s(e),()=>{n.delete(o),r&&0===n.size&&(r(),r=null)}}}}function Z(e){return function(){throw new TypeError(`Can't call "${e}" on HTMLFelteFormElement. The element is not ready yet.`)}}const ee=["data","errors","touched","warnings","isSubmitting","isDirty","isValid","isValidating","interacted"];class te extends HTMLElement{constructor(){super(...arguments),this._configuration={},this._storeValues={data:void 0,errors:void 0,touched:void 0,warnings:void 0,isSubmitting:!1,isDirty:!1,isValid:void 0,isValidating:!1,interacted:null},this.setData=Z("setData"),this.setFields=Z("setFields"),this.setInitialValues=Z("setInitialValues"),this.addField=Z("addField"),this.unsetField=Z("unsetField"),this.swapFields=Z("swapFields"),this.moveField=Z("moveField"),this.resetField=Z("resetField"),this.reset=Z("reset"),this.submit=Z("submit"),this.createSubmitHandler=Z("createSubmitHandler"),this.setErrors=Z("setErrors"),this.setTouched=Z("setTouched"),this.setWarnings=Z("setWarnings"),this.setIsSubmitting=Z("setIsSubmitting"),this.setIsDirty=Z("setIsDirty"),this.setInteracted=Z("setInteracted"),this._ready=!1,this.validate=Z("validate"),this._formElement=null,this._updateForm=()=>{var e;const t=this.querySelector("form");t&&t!==this._formElement&&(this.dispatchEvent(new Event("felteconnect",{bubbles:!0,composed:!0})),this._formElement=t,null===(e=this._destroy)||void 0===e||e.call(this),this._destroy=void 0,this._createForm())}}set configuration(e){this._configuration=e,this._destroy&&(this._destroy(),this._destroy=void 0,this._ready=!1,this._createForm())}get configuration(){return this._configuration}get data(){return this._storeValues.data}get errors(){return this._storeValues.errors}get touched(){return this._storeValues.touched}get warnings(){return this._storeValues.warnings}get isSubmitting(){return this._storeValues.isSubmitting}get isDirty(){return this._storeValues.isDirty}get isValid(){return this._storeValues.isValid}get isValidating(){return this._storeValues.isValidating}get interacted(){return this._storeValues.interacted}get ready(){return this._ready}_createForm(){var e;const t=this._formElement;if(!t)return;const r=this.configuration;this.elements=t.elements;const{form:n,cleanup:i,...s}=function(e,t){var r,n;function i(t,{debounced:r,level:n}={debounced:!1,level:"error"}){var i;const s="error"===n?"validate":"warn";null!==(i=e.debounced)&&void 0!==i||(e.debounced={});const a=r?e.debounced:e;a[s]?a[s]=[...a[s],t]:a[s]=[t]}function s(t){e.transform?e.transform=[...e.transform,t]:e.transform=[t]}null!==(r=e.extend)&&void 0!==r||(e.extend=[]),null!==(n=e.debounced)&&void 0!==n||(e.debounced={}),e.validate&&!Array.isArray(e.validate)&&(e.validate=[e.validate]),e.debounced.validate&&!Array.isArray(e.debounced.validate)&&(e.debounced.validate=[e.debounced.validate]),e.transform&&!Array.isArray(e.transform)&&(e.transform=[e.transform]),e.warn&&!Array.isArray(e.warn)&&(e.warn=[e.warn]),e.debounced.warn&&!Array.isArray(e.debounced.warn)&&(e.debounced.warn=[e.debounced.warn]);const a=Array.isArray(e.extend)?e.extend:[e.extend];let o=[];const{isSubmitting:u,isValidating:l,data:c,errors:d,warnings:f,touched:v,isValid:h,isDirty:m,cleanup:y,start:p,validateErrors:b,validateWarnings:g,interacted:A}=X(t.storeFactory,e),E=c.update,w=c.set;c.update=t=>E((r=>S(R(t(r),e.transform)))),c.set=t=>w(S(R(t,e.transform)));const O=D({extender:a,config:e,addValidator:i,addTransformer:s,validateErrors:b,validateWarnings:g,stores:{data:c,errors:d,warnings:f,touched:v,isValid:h,isValidating:l,isSubmitting:u,isDirty:m,interacted:A}});o=a.map((t=>t({stage:"SETUP",errors:d,warnings:f,touched:v,data:c,config:e,addValidator:i,addTransformer:s,setFields:O.public.setFields,reset:O.public.reset,validate:O.public.validate})));const F=Object.assign({config:e,stores:{data:c,touched:v,errors:d,warnings:f,isSubmitting:u,isValidating:l,isValid:h,isDirty:m,interacted:A},helpers:Object.assign(Object.assign({},O.public),{addTransformer:s,addValidator:i}),extender:a,validateErrors:b,validateWarnings:g,_getCurrentExtenders:()=>o,_setCurrentExtenders:e=>{o=e}},O.private),{form:V,createSubmitHandler:_,handleSubmit:j}=H(F);return Object.assign({data:c,errors:d,warnings:f,touched:v,isValid:h,isSubmitting:u,isValidating:l,isDirty:m,interacted:A,form:V,handleSubmit:j,createSubmitHandler:_,cleanup:y,startStores:p},O.public)}(r,{storeFactory:Y});this.setData=s.setData,this.setFields=s.setFields,this.setErrors=s.setErrors,this.setTouched=s.setTouched,this.setWarnings=s.setWarnings,this.setIsSubmitting=s.setIsSubmitting,this.setIsDirty=s.setIsDirty,this.setInteracted=s.setInteracted,this.setInitialValues=s.setInitialValues,this.validate=s.validate,this.addField=s.addField,this.unsetField=s.unsetField,this.swapFields=s.swapFields,this.moveField=s.moveField,this.resetField=s.resetField,this.reset=s.reset,this.submit=s.handleSubmit,this.createSubmitHandler=s.createSubmitHandler;const a=ee.map((e=>s[e].subscribe((t=>{if(G(t,this._storeValues[e]))return;this._storeValues[e]=t;const r=this[`on${n=e,n.charAt(0).toUpperCase()+n.slice(1)}Change`];var n;"function"==typeof r&&r(t),this.dispatchEvent(new Event(`${e.toLowerCase()}change`))})))),{destroy:o}=n(t),{createSubmitEvent:u,createErrorEvent:l,createSuccessEvent:c}=I(),d=e=>{const t=e,r=u();this.dispatchEvent(r),r.defaultPrevented&&t.preventDefault(),t.onSubmit=r.onSubmit,t.onSuccess=r.onSuccess,t.onError=r.onError},f=e=>{const t=c(e.detail);this.dispatchEvent(t)},v=e=>{const t=e,r=l(t.detail);this.dispatchEvent(r),t.errors=r.errors,r.defaultPrevented&&t.preventDefault()};t.addEventListener("feltesubmit",d),t.addEventListener("feltesuccess",f),t.addEventListener("felteerror",v),this._destroy=()=>{o(),i(),t.removeEventListener("feltesubmit",d),t.removeEventListener("feltesuccess",f),t.removeEventListener("felteerror",v),a.forEach((e=>e()))},this._ready=!0,null===(e=this.onFelteReady)||void 0===e||e.call(this),this.dispatchEvent(new Event("felteready",{bubbles:!0,composed:!0}))}connectedCallback(){setTimeout((()=>{this._updateForm(),this._observer=new MutationObserver(this._updateForm),this._observer.observe(this,{childList:!0})}))}disconnectedCallback(){var e,t;null===(e=this._destroy)||void 0===e||e.call(this),null===(t=this._observer)||void 0===t||t.disconnect()}static get observedAttributes(){return["id"]}attributeChangedCallback(e,t,r){if(t!==r)switch(e){case"id":this.id=r}}}customElements.get("felte-form")||(customElements.define("felte-form",te),window.HTMLFelteFormElement=te);export{te as FelteForm,t as FelteSubmitError};
//# sourceMappingURL=felte-form.min.js.map

@@ -30,3 +30,3 @@ function e(e){let t;return function(e,...t){const r=e.subscribe(...t);return r.unsubscribe?()=>r.unsubscribe():r}(e,(e=>t=e))(),t}class t extends Error{constructor(e,t){super(e),this.name="FelteSubmitError",this.response=t}}function r(e){var t;return"INPUT"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function n(e){var t;return"SELECT"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function i(e){var t;return"FIELDSET"===(null===(t=e)||void 0===t?void 0:t.nodeName)}function s(e){return r(e)||function(e){var t;return"TEXTAREA"===(null===(t=e)||void 0===t?void 0:t.nodeName)}(e)||n(e)}function o(e){return e.nodeType===Node.ELEMENT_NODE}function a(e,t,r){const n=r=>String.prototype.split.call(t,r).filter(Boolean).reduce(((e,t)=>null!=e?e[t]:e),e),i=n(/[,[\]]+?/)||n(/[,[\].]+?/);return void 0===i||i===e?r:i}function u(e){return"[object Object]"===Object.prototype.toString.call(e)}function l(e){return Object.keys(e||{}).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:u(e[r])?l(e[r]):Array.isArray(e[r])?[...e[r]]:e[r]})),{})}function d(e,t,r){e&&(e=l(e)),u(e)||(e={});const n=Array.isArray(t)?t:t.match(/[^.[\]]+/g)||[],i=n[n.length-1];if(!i)return e;let s=e;for(let e=0;e<n.length-1;e++){const t=n[e];if(!s[t]||!u(s[t])&&!Array.isArray(s[t])){const r=n[e+1];isNaN(Number(r))?s[t]={}:s[t]=[]}s=s[t]}return s[i]=r(s[i]),e}function c(e,t,r){return d(e,t,(()=>r))}function f(e,t){return null!=t?t:s(e)?e.name:""}function v(e){if(s(e))return[e];if(0===e.childElementCount)return[];const t=new Set;for(const r of e.children){if(s(r)&&t.add(r),i(r))for(const e of r.elements)s(e)&&t.add(e);r.childElementCount>0&&v(r).forEach((e=>t.add(e)))}return Array.from(t)}function h(e){for(const t of e.elements)(s(t)||i(t))&&e.hasAttribute("data-felte-keep-on-remove")&&!t.hasAttribute("data-felte-keep-on-remove")&&(t.dataset.felteKeepOnRemove=e.dataset.felteKeepOnRemove)}function m(e){return e.type.match(/^(number|range)$/)?e.value?+e.value:void 0:e.value}function y(e){var t;let o={},u={};for(const l of e.elements){if(i(l)&&h(l),!s(l)||!l.name)continue;const v=f(l);if(r(l)){if("checkbox"===l.type){if(void 0===a(o,v)){if(1===Array.from(e.querySelectorAll(`[name="${l.name}"]`)).filter((e=>!!s(e)&&v===f(e))).length){o=c(o,v,l.checked),u=c(u,v,!1);continue}o=c(o,v,l.checked?[l.value]:[]),u=c(u,v,!1);continue}Array.isArray(a(o,v))&&l.checked&&(o=d(o,v,(e=>[...e,l.value])));continue}if("radio"===l.type){if(a(o,v))continue;o=c(o,v,l.checked?l.value:void 0),u=c(u,v,!1);continue}if("file"===l.type){o=c(o,v,l.multiple?Array.from(l.files||[]):null===(t=l.files)||void 0===t?void 0:t[0]),u=c(u,v,!1);continue}}else if(n(l)){if(l.multiple){const e=Array.from(l.options).filter((e=>e.selected)).map((e=>e.value));o=c(o,v,e)}else o=c(o,v,l.value);u=c(u,v,!1);continue}const y=m(l);o=c(o,v,y),u=c(u,v,!1)}return{defaultData:o,defaultTouched:u}}function p(e,t){var i;if(!s(e))return;const o=t;if(r(e)){if("checkbox"===e.type){const t=o;return void 0===t||"boolean"==typeof t?void(e.checked=!!t):void(Array.isArray(t)&&(t.includes(e.value)?e.checked=!0:e.checked=!1))}if("radio"===e.type){const t=o;return void(e.value===t?e.checked=!0:e.checked=!1)}if("file"===e.type)return e.files=null,void(e.value="")}else if(n(e)){if(e.multiple){if(Array.isArray(o)){e.value=String(null!==(i=o[0])&&void 0!==i?i:"");for(const t of e.options)o.includes(t.value)?t.selected=!0:t.selected=!1}}else{e.value=String(null!=o?o:"");for(const t of e.options)t.value===o?t.selected=!0:t.selected=!1}return}e.value=String(null!=o?o:"")}function b(e,t){for(const r of e.elements){if(i(r)&&h(r),!s(r)||!r.name)continue;p(r,a(t,f(r)))}}const g={attributes:!0,attributeFilter:["data-felte-validation-message","aria-invalid"]};

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function O(e){return function(t){if(u(t)){return function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(V(t,e),["key"])}return e}}function V(e,t){return A(e,(e=>u(e)?V(e,t):Array.isArray(e)?e.map(O(t)):t))}function T(e,t){if(!e||Object(e)!==e)return;void 0!==e&&(e=l(e));const r=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g)||[],n=1===r.length?e:a(e,r.slice(0,-1).join("."));return Array.isArray(n)?n.splice(Number(r[r.length-1]),1):null==n||delete n[r[r.length-1]],e}function k(e,t,r,n){return d(e,t,(e=>void 0===e||Array.isArray(e)?(e||(e=[]),void 0===n?e.push(r):e.splice(n,0,r),e):e))}function j(e){return"function"==typeof e}function L(e){return(t,r)=>{if("string"==typeof t){const n=t;e((e=>{const t=j(r)?r(a(e,n)):r;return c(e,n,t)}))}else e((e=>j(t)?t(e):t))}}function D({stores:t,config:r,validateErrors:n,validateWarnings:i}){var s;let o,f=_(null!==(s=r.initialValues)&&void 0!==s?s:{});const{data:v,touched:h,errors:m,warnings:y,isDirty:p,isSubmitting:g,interacted:E}=t,A=L(v.update),F=L(h.update),O=L(m.update),j=L(y.update);function D(e){A((t=>{const r=e(t);return o&&b(o,r),r}))}const I=(e,t,r)=>{L(D)(e,t),"string"==typeof e&&r&&F(e,!0)};function C(e){m.update(e),y.update(e),h.update(e),v.update((t=>{const r=e(t);return setTimeout((()=>o&&b(o,r))),r}))}const x=L(g.update),P=L(p.update),N=L(E.update);return{public:{setData:A,setFields:I,setTouched:F,setErrors:O,setWarnings:j,setIsSubmitting:x,setIsDirty:P,setInteracted:N,validate:async function(){const t=e(v);h.set(w(t,!0)),E.set(null);const r=await n(t);return await i(t),r},reset:function(){I(l(f)),F((e=>V(e,!1))),E.set(null),p.set(!1)},unsetField:function(e){C((t=>T(t,e)))},resetField:function(e){const t=a(f,e),r=!!u(t)&&w(t,!1),n=u(r)?V(r,[]):[];v.update((r=>{const n=c(r,e,t);return o&&b(o,n),n})),h.update((t=>c(t,e,r))),m.update((t=>c(t,e,n))),y.update((t=>c(t,e,n)))},addField:function(e,t,r){const n=!!u(t)&&w(t,!1),i=u(n)?V(n,[]):[];t=u(t)?Object.assign(Object.assign({},t),{key:S()}):t,m.update((t=>k(t,e,i,r))),y.update((t=>k(t,e,i,r))),h.update((t=>k(t,e,n,r))),v.update((n=>{const i=k(n,e,t,r);return setTimeout((()=>o&&b(o,i))),i}))},swapFields:function(e,t,r){C((n=>function(e,t,r,n){return d(e,t,(e=>e&&Array.isArray(e)?([e[r],e[n]]=[e[n],e[r]],e):e))}(n,e,t,r)))},moveField:function(e,t,r){C((n=>function(e,t,r,n){return d(e,t,(e=>e&&Array.isArray(e)?(e.splice(n,0,e.splice(r,1)[0]),e):e))}(n,e,t,r)))},setInitialValues:e=>{f=_(e)}},private:{_setFormNode(e){o=e},_getFormNode:()=>o,_getInitialValues:()=>f}}}function I(){class e extends CustomEvent{constructor(e){super("feltesuccess",{detail:e})}}class t extends CustomEvent{constructor(e){super("felteerror",{detail:e,cancelable:!0})}setErrors(e){this.preventDefault(),this.errors=e}}class r extends Event{constructor(){super("feltesubmit",{cancelable:!0})}handleSubmit(e){this.onSubmit=e}handleError(e){this.onError=e}handleSuccess(e){this.onSuccess=e}}return{createErrorEvent:e=>new t(e),createSubmitEvent:()=>new r,createSuccessEvent:t=>new e(t)}}function C(...e){const t=e.pop(),r=l(e.shift());if(0===e.length)return r;for(const n of e){if(!n)continue;let e=t(r,n);if(void 0!==e)return e;const i=Array.from(new Set(Object.keys(r).concat(Object.keys(n))));for(const s of i)if(e=t(r[s],n[s]),void 0!==e)r[s]=e;else if(u(n[s])&&u(r[s]))r[s]=C(r[s],n[s],t);else if(Array.isArray(n[s]))r[s]=n[s].map(((e,n)=>{if(!u(e))return e;return C(Array.isArray(r[s])?r[s][n]:r[s],e,t)}));else if(u(n[s])){const e=V(l(n[s]),void 0);r[s]=C(e,n[s],t)}else void 0!==n[s]&&(r[s]=n[s])}return r}function x(...e){return C(...e,(()=>{}))}function P(e,t){return function(e,t){return Object.keys(e).some((r=>t(e[r])))}(e,(e=>u(e)?P(e,t):Array.isArray(e)?0===e.length||e.every((e=>"string"==typeof e))?t(e):e.some((e=>u(e)?P(e,t):t(e))):t(e)))}function N(e){let t=e;for(;t&&"FORM"!==t.nodeName;){if(t.hasAttribute("data-felte-ignore"))return!0;t=t.parentElement}return!1}function M(e,t){let r;return(...n)=>{clearTimeout(r),r=setTimeout((()=>{e.apply(this,n)}),t)}}function H(e,t){if(!u(e)||!u(t)){if(Array.isArray(t)){if(t.some(u))return;const r=Array.isArray(e)?e:[];return t.map(((e,t)=>{var n;return null!==(n=r[t])&&void 0!==n?n:e}))}return void 0!==e?e:void 0}}function R(...e){return C(...e,H)}function W({helpers:i,stores:d,config:h,extender:p,validateErrors:b,validateWarnings:g,_setFormNode:A,_getFormNode:S,_getInitialValues:_,_setCurrentExtenders:O,_getCurrentExtenders:k}){const{setFields:j,setTouched:L,reset:D,setInitialValues:C}=i,{addValidator:H,addTransformer:W,validate:B,setIsDirty:$,setIsSubmitting:q}=i,U=E(i,["addValidator","addTransformer","validate","setIsDirty","setIsSubmitting"]),{data:K,errors:z,warnings:X,touched:G,isSubmitting:J,isDirty:Q,interacted:Y}=d;function Z(r){return async function(n){var i,o,a,u,l,d,c;const f=S(),{createErrorEvent:v,createSubmitEvent:m,createSuccessEvent:y}=I(),p=m();null==f||f.dispatchEvent(p);const E=null!==(o=null!==(i=p.onError)&&void 0!==i?i:null==r?void 0:r.onError)&&void 0!==o?o:h.onError,A=null!==(u=null!==(a=p.onSuccess)&&void 0!==a?a:null==r?void 0:r.onSuccess)&&void 0!==u?u:h.onSuccess,_=null!==(c=null!==(d=null!==(l=p.onSubmit)&&void 0!==l?l:null==r?void 0:r.onSubmit)&&void 0!==d?d:h.onSubmit)&&void 0!==c?c:function(e){if(e)return async function(){let r=new FormData(e);const n=new URL(e.action),i="get"===e.method.toLowerCase()?"get":n.searchParams.get("_method")||e.method;let s,o=e.enctype;e.querySelector('input[type="file"]')&&(o="multipart/form-data"),"get"!==i&&"application/x-www-form-urlencoded"!==o||(r=new URLSearchParams(r)),"get"===i?(r.forEach(((e,t)=>{n.searchParams.append(t,e)})),s={method:i}):s={method:i,body:r,headers:{"Content-Type":o}};const a=await window.fetch(n.toString(),s);if(a.ok)return a;throw new t("An error occurred while submitting the form",a)}}(f);if(!_)return;if(null==n||n.preventDefault(),p.defaultPrevented)return;J.set(!0),Y.set(null);const O=F(e(K)),T=await b(O,null==r?void 0:r.validate),j=await g(O,null==r?void 0:r.warn);if(j&&X.set(x(V(O,[]),j)),G.set(w(O,!0)),T){G.set(w(T,!0));if(P(T,(e=>Array.isArray(e)?e.length>=1:!!e)))return await new Promise((e=>setTimeout(e))),k().forEach((e=>{var t;return null===(t=e.onSubmitError)||void 0===t?void 0:t.call(e,{data:O,errors:T})})),void J.set(!1)}const L=Object.assign(Object.assign({},U),{form:f,controls:f&&Array.from(f.elements).filter(s),config:Object.assign(Object.assign({},h),r)});try{const e=await _(O,L);null==f||f.dispatchEvent(y(Object.assign({response:e},L))),await(null==A?void 0:A(e,L))}catch(t){const r=v(Object.assign({error:t},L));if(null==f||f.dispatchEvent(r),!E&&!r.defaultPrevented)throw t;if(!E&&!r.errors)return;const n=r.errors||await(null==E?void 0:E(t,L));n&&(G.set(w(n,!0)),z.set(n),await new Promise((e=>setTimeout(e))),k().forEach((t=>{var r;return null===(r=t.onSubmitError)||void 0===r?void 0:r.call(t,{data:O,errors:e(z)})})))}finally{J.set(!1)}}}const ee=Z();return{form:function(t){function i(e){return function(r){return r({form:t,stage:e,controls:Array.from(t.elements).filter(s),data:K,errors:z,warnings:X,touched:G,config:h,addValidator:H,addTransformer:W,setFields:j,validate:B,reset:D})}}t.requestSubmit||(t.requestSubmit=ee),O(p.map(i("MOUNT"))),t.noValidate=!!h.validate;const{defaultData:d,defaultTouched:b}=y(t);function g(e){const t=e.target;if(!t||!s(t)||n(t)||N(t))return;if(["checkbox","radio","file"].includes(t.type))return;if(!t.name)return;Q.set(!0);const r=m(t);Y.set(t.name),K.update((e=>c(e,f(t),r)))}function E(e){const i=e.target;if(i&&s(i)&&!N(i)&&i.name)if(L(f(i),!0),Y.set(i.name),(n(i)||["checkbox","radio","file","hidden"].includes(i.type))&&Q.set(!0),"hidden"===i.type&&K.update((e=>c(e,f(i),i.value))),n(i))!function(e){if(e.multiple){const t=Array.from(e.options).filter((e=>e.selected)).map((e=>e.value));K.update((r=>c(r,f(e),t)))}else K.update((t=>c(t,f(e),e.value)))}(i);else{if(!r(i))return;"checkbox"===i.type?function(e){const n=f(e),i=Array.from(t.querySelectorAll(`[name="${e.name}"]`)).filter((e=>!!s(e)&&n===f(e)));if(0!==i.length)1===i.length?K.update((t=>c(t,f(e),e.checked))):K.update((t=>c(t,f(e),i.filter(r).filter((e=>e.checked)).map((e=>e.value)))))}(i):"radio"===i.type?function(e){const n=t.querySelectorAll(`[name="${e.name}"]`),i=Array.from(n).find((e=>r(e)&&e.checked));K.update((t=>c(t,f(e),null==i?void 0:i.value)))}(i):"file"===i.type&&function(e){var t;const r=Array.from(null!==(t=e.files)&&void 0!==t?t:[]);K.update((t=>c(t,f(e),e.multiple?r:r[0])))}(i)}}function w(e){const t=e.target;t&&s(t)&&!N(t)&&t.name&&(L(f(t),!0),Y.set(t.name))}function S(e){e.preventDefault(),D()}A(t),C(x(l(d),_())),j(_()),G.set(b);const F=M((()=>{k().forEach((e=>{var t;return null===(t=e.destroy)||void 0===t?void 0:t.call(e)})),O(p.map(i("UPDATE")));const{defaultData:e,defaultTouched:r}=y(t);K.update((t=>R(t,e))),G.update((e=>R(e,r)))}),0);let V=[];const I=M((()=>{k().forEach((e=>{var t;return null===(t=e.destroy)||void 0===t?void 0:t.call(e)})),O(p.map(i("UPDATE"))),function(t){let r=e(K),n=e(G),i=e(z),s=e(X);for(const o of t.reverse()){if(o.hasAttribute("data-felte-keep-on-remove")&&"false"!==o.dataset.felteKeepOnRemove)continue;const t=/.*(\[[0-9]+\]|\.[0-9]+)\.[^.]+$/;let l=f(o);const d=e(G);if(t.test(l)){const e=l.split(".").slice(0,-1).join("."),t=a(d,e);u(t)&&Object.keys(t).length<=1&&(l=e)}r=T(r,l),n=T(n,l),i=T(i,l),s=T(s,l)}K.set(r),G.set(n),z.set(i),X.set(s)}(V),V=[]}),0),P=new MutationObserver((function(e){for(const t of e)if("childList"===t.type){if(t.addedNodes.length>0){if(!Array.from(t.addedNodes).some((e=>{if(!o(e))return!1;if(s(e))return!0;return v(e).length>0})))continue;F()}if(t.removedNodes.length>0)for(const e of t.removedNodes){if(!o(e))continue;const t=v(e);0!==t.length&&(V.push(...t),I())}}}));P.observe(t,{childList:!0,subtree:!0}),t.addEventListener("input",g),t.addEventListener("change",E),t.addEventListener("focusout",w),t.addEventListener("submit",ee),t.addEventListener("reset",S);const $=z.subscribe((e=>{for(const r of t.elements){if(!s(r)||!r.name)continue;const t=a(e,f(r)),n=Array.isArray(t)?t.join("\n"):"string"==typeof t?t:void 0;n!==r.dataset.felteValidationMessage&&(n?(r.dataset.felteValidationMessage=n,r.setAttribute("aria-invalid","true")):(delete r.dataset.felteValidationMessage,r.removeAttribute("aria-invalid")))}}));return{destroy(){P.disconnect(),t.removeEventListener("input",g),t.removeEventListener("change",E),t.removeEventListener("focusout",w),t.removeEventListener("submit",ee),t.removeEventListener("reset",S),$(),k().forEach((e=>{var t;return null===(t=e.destroy)||void 0===t?void 0:t.call(e)}))}}},createSubmitHandler:Z,handleSubmit:ee}}function B(e,t){return t?Array.isArray(t)?t.reduce(((e,t)=>t(e)),e):t(e):e}function $(e,t){if(!u(e)&&!u(t)){if(null===e||""===e)return t;if(null===t||""===t)return e;if(!t)return e;if(e&&t){if(Array.isArray(e)){if(!Array.isArray(t))return[...e,t];const r=[],n=Math.max(t.length,e.length);for(let i=0;i<n;i++){let n=e[i],s=t[i];u(n)||u(s)?r.push(q([null!=n?n:{},null!=s?s:{}])):(Array.isArray(n)||(n=[n]),Array.isArray(s)||(s=[s]),r.push(...n,...s))}return r.filter(Boolean)}return Array.isArray(t)||(t=[t]),[e,...t].reduce(((e,t)=>e.concat(t)),[]).filter(Boolean)}}}function q(e){return C(...e,$)}function U(e,t){if(u(e))return!t||u(t)&&0===Object.keys(t).length?V(e,null):void 0;if(Array.isArray(e)){if(e.some(u))return;const r=Array.isArray(t)?t:[];return e.map(((e,t)=>{const n=r[t];return Array.isArray(n)&&0===n.length?null:e&&n||null}))}return Array.isArray(t)&&0===t.length?null:Array.isArray(t)?e?t:null:e&&t?[t]:null}function K(e,t){if(u(e))return!t||u(t)&&0===Object.keys(t).length?V(e,null):void 0;if(Array.isArray(e)){if(e.some(u))return;const r=Array.isArray(t)?t:[];return e.map(((e,t)=>{const n=r[t];return Array.isArray(n)&&0===n.length?null:n||null}))}return Array.isArray(t)&&0===t.length?null:Array.isArray(t)?t:t?[t]:null}function z([e,t]){return C(t,e,U)}function X([e,t]){return C(t,e,K)}function G(e,t){var r,n,i,s,o,a,u,d,c;const f=function(e){return function(t,r,n){const i=Array.isArray(t)?t:[t],s=new Array(i.length),o=e(n),a=o.set,u=o.subscribe;let l;return o.subscribe=function(e){const t=u(e);return()=>{t()}},[o,function(){l=i.map(((e,t)=>e.subscribe((e=>{s[t]=e,a(r(s))}))))},function(){null==l||l.forEach((e=>e()))}]}}(e),v=t.initialValues=t.initialValues?_(B(l(t.initialValues),t.transform)):{},h=w(F(v),!1),m=e(h),y=e(0),[p,b,g]=f([m,y],(([e,t])=>P(e,(e=>!!e))&&t>=1),!1);function E(e){let t;return async function(r,n,i,s=!1){if(!i||!r)return;let o=n&&Object.keys(n).length>0?n:V(r,[]);const a=function(e){const t={aborted:!1,priority:e};return{signal:t,abort(){t.aborted=!0}}}(s);if((null==t?void 0:t.signal.priority)&&!s||(null==t||t.abort(),t=a),t.signal.priority&&!s)return;y.update((e=>e+1));const u=(l=r,(d=i)?(Array.isArray(d)?d:[d]).map((e=>e(l))):[]);var l,d;return u.forEach((async t=>{const r=await t;a.signal.aborted||(o=q([o,r]),e.set(o))})),await Promise.all(u),t=void 0,y.update((e=>e-1)),o}}delete p.set,delete p.update;let A=V(h,[]);const S=e(v),O=V(h,[]),T=e(O),k=e(l(O)),[j,L,D]=f([T,k],q,l(O)),I=V(h,[]),C=e(I),x=e(l(I)),[N,H,R]=f([C,x],q,l(I)),[W,$,U]=f([j,m],z,l(O)),[K,G,J]=f([N,m],X,l(I));let Q=!1;const[Y,Z,ee]=f(j,(([e])=>{var r;return Q?!P(e,(e=>Array.isArray(e)?e.length>=1:!!e)):(Q=!0,!t.validate&&!(null===(r=t.debounced)||void 0===r?void 0:r.validate))}),!t.validate&&!(null===(r=t.debounced)||void 0===r?void 0:r.validate));delete Y.set,delete Y.update;const te=e(!1),re=e(!1),ne=e(null),ie=E(T),se=E(C),oe=E(k),ae=E(x),ue=M(oe,null!==(o=null!==(i=null===(n=t.debounced)||void 0===n?void 0:n.validateTimeout)&&void 0!==i?i:null===(s=t.debounced)||void 0===s?void 0:s.timeout)&&void 0!==o?o:300),le=M(ae,null!==(c=null!==(u=null===(a=t.debounced)||void 0===a?void 0:a.warnTimeout)&&void 0!==u?u:null===(d=t.debounced)||void 0===d?void 0:d.timeout)&&void 0!==c?c:300);let de=O,ce=I;function fe(){const e=S.subscribe((e=>{var r,n;const i=F(e);ie(i,A,t.validate),se(i,A,t.warn),ue(i,A,null===(r=t.debounced)||void 0===r?void 0:r.validate),le(i,A,null===(n=t.debounced)||void 0===n?void 0:n.warn)})),r=m.subscribe((e=>{A=V(e,[])})),n=j.subscribe((e=>{de=e})),i=N.subscribe((e=>{ce=e}));return L(),Z(),H(),$(),G(),b(),function(){e(),U(),D(),R(),J(),ee(),g(),r(),n(),i()}}function ve(e){T.set(e(de)),k.set({})}function he(e){C.set(e(ce)),x.set({})}return W.set=function(e){ve((()=>e))},W.update=ve,K.set=function(e){he((()=>e))},K.update=he,{data:S,errors:W,warnings:K,touched:m,isValid:Y,isSubmitting:te,isDirty:re,isValidating:p,interacted:ne,validateErrors:async function(e,r){var n;const i=F(e),s=ie(i,A,null!=r?r:t.validate,!0);if(r)return s;const o=oe(i,A,null===(n=t.debounced)||void 0===n?void 0:n.validate,!0);return q(await Promise.all([s,o]))},validateWarnings:async function(e,r){var n;const i=F(e),s=se(i,A,null!=r?r:t.warn,!0);if(r)return s;const o=ae(i,A,null===(n=t.debounced)||void 0===n?void 0:n.warn,!0);return q(await Promise.all([s,o]))},cleanup:t.preventStoreStart?()=>{}:fe(),start:fe}}function J(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((e,r)=>J(e,t[r])));if(u(e)&&u(t)){const r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every((r=>J(e[r],t[r])))}return!1}class Q extends HTMLElement{constructor(){var e;super(...arguments),this.touchOnChange=!1,this.valueProp="value",this.inputEvent="input",this.blurEvent="focusout",this.composed=!1,this._onBlur=(e="blur",function(){throw new TypeError(`Can't call "${e}" on HTMLFelteFieldElement. The element is not ready yet.`)}),this._ready=!1,this._updateField=()=>{var e;const t=this.children.item(0);t&&t!==this._element&&(this._element=t,null===(e=this._destroy)||void 0===e||e.call(this),this._destroy=void 0,this._createField())}}static get observedAttributes(){return["name","touchonchange","valueprop","inputevent","blurevent","composed","value"]}static get attributeMap(){return{name:{converter:String,name:"name"},touchonchange:{converter:e=>""===e||!!e&&"false"!==e,name:"touchOnChange"},valueprop:{converter:String,name:"valueProp"},inputevent:{converter:String,name:"inputEvent"},blurevent:{converter:String,name:"blurEvent"},value:{converter:String,name:"value"},composed:{converter:e=>""===e||!!e&&"false"!==e,name:"composed"}}}attributeChangedCallback(e,t,r){if(t===r)return;const{converter:n,name:i}=Q.attributeMap[e];this[i]=n(r)}set value(e){var t;null===(t=this._onInput)||void 0===t||t.call(this,e),this._value=e}get value(){return this._value}blur(){this._onBlur()}get ready(){return this._ready}_createField(){var e;const{name:t,inputEvent:r,blurEvent:n,touchOnChange:i,value:a,composed:u}=this;if(!t)throw new Error('<felte-field> must have a "name" attribute');const l=this._element;if(!l)return;l[this.valueProp]=a;const{field:d,onInput:c,onBlur:f}=function(e,t){var r,n;let i,a,u,l,d,c;function f(e,t){if(!d)return;p(d,t);const r=new Event(e,{bubbles:!0,composed:!0});d.dispatchEvent(r)}function v(e){e.forEach((()=>{const e=d.getAttribute("aria-invalid");e?l.setAttribute("aria-invalid",e):l.removeAttribute("aria-invalid");const t=d.getAttribute("data-felte-validation-message");t?l.setAttribute("data-felte-validation-message",t):l.removeAttribute("data-felte-validation-message")}))}function h(e){c&&(p(d,a),c(e))}function m(e){f(u?"change":"input",e)}return"string"==typeof e?(i=e,a=null==t?void 0:t.defaultValue,u=null!==(r=null==t?void 0:t.touchOnChange)&&void 0!==r&&r,c=null==t?void 0:t.onFormReset):(i=e.name,a=e.defaultValue,u=null!==(n=e.touchOnChange)&&void 0!==n&&n,c=null==e?void 0:e.onFormReset),{field:function(e){let t,r;if(l=e,s(e))return d=e,d.name=i,{};{let n=!1,u=!1;return setTimeout((()=>{if(u)return;const c=l.parentNode;if(!c||!o(c))return;const f=c.querySelector(`[name="${i}"]`);if(f&&s(f))d=f;else{const t=document.createElement("input");t.type="hidden",t.name=i,c.insertBefore(t,e.nextSibling),d=t,n=!0}p(d,a),t=new MutationObserver(v),t.observe(d,g),r=d.closest("form"),null==r||r.addEventListener("reset",h)})),{destroy(){var e;n&&(null===(e=d.parentNode)||void 0===e||e.removeChild(d)),u=!0,null==t||t.disconnect(),null==r||r.removeEventListener("reset",h)}}}},onInput:m,onChange:m,onBlur:function(){f("focusout")}}}(t,{touchOnChange:i,defaultValue:a,onFormReset:()=>{this.value=a,l[this.valueProp]=a}});this._onInput=c,this._onBlur=f;const{destroy:v}=d(l),h=e=>{const t=u?e.composedPath()[0]:e.target;this.value=t[this.valueProp]},m=()=>{f()};l.addEventListener(r,h),l.addEventListener(n,m),this._destroy=()=>{null==v||v(),l.removeEventListener(r,h),l.removeEventListener(r,m)},this._ready=!0,null===(e=this.onfeltefieldready)||void 0===e||e.call(this),this.dispatchEvent(new Event("feltefieldready"))}connectedCallback(){setTimeout((()=>{this._updateField(),this._observer=new MutationObserver(this._updateField),this._observer.observe(this,{childList:!0})}))}disconnectedCallback(){var e,t;null===(e=this._destroy)||void 0===e||e.call(this),null===(t=this._observer)||void 0===t||t.disconnect()}}customElements.get("felte-field")||(customElements.define("felte-field",Q),window.HTMLFelteFieldElement=Q);const Y=[],Z=()=>{};function ee(e,t=Z){let r;const n=new Set;function i(t){if(s=t,((i=e)!=i?s==s:i!==s||i&&"object"==typeof i||"function"==typeof i)&&(e=t,r)){const t=!Y.length;for(const t of n)t[1](),Y.push(t,e);if(t){for(let e=0;e<Y.length;e+=2)Y[e][0](Y[e+1]);Y.length=0}}var i,s}return{set:i,update:function(t){i(t(e))},subscribe:function(s,o=Z){const a=[s,o];return n.add(a),1===n.size&&(r=t(i)||Z),s(e),()=>{n.delete(a),r&&0===n.size&&(r(),r=null)}}}}function te(e){return function(){throw new TypeError(`Can't call "${e}" on HTMLFelteFormElement. The element is not ready yet.`)}}const re=["data","errors","touched","warnings","isSubmitting","isDirty","isValid","isValidating","interacted"];class ne extends HTMLElement{constructor(){super(...arguments),this.id="",this._configuration={},this._storeValues={data:void 0,errors:void 0,touched:void 0,warnings:void 0,isSubmitting:!1,isDirty:!1,isValid:void 0,isValidating:!1,interacted:null},this.setData=te("setData"),this.setFields=te("setFields"),this.setInitialValues=te("setInitialValues"),this.addField=te("addField"),this.unsetField=te("unsetField"),this.swapFields=te("swapFields"),this.moveField=te("moveField"),this.resetField=te("resetField"),this.reset=te("reset"),this.submit=te("submit"),this.createSubmitHandler=te("createSubmitHandler"),this.setErrors=te("setErrors"),this.setTouched=te("setTouched"),this.setWarnings=te("setWarnings"),this.setIsSubmitting=te("setIsSubmitting"),this.setIsDirty=te("setIsDirty"),this.setInteracted=te("setInteracted"),this._ready=!1,this.validate=te("validate"),this._formElement=null,this._updateForm=()=>{var e;const t=this.querySelector("form");t&&t!==this._formElement&&(this.dispatchEvent(new Event("felteconnect",{bubbles:!0,composed:!0})),this._formElement=t,null===(e=this._destroy)||void 0===e||e.call(this),this._destroy=void 0,this._createForm())}}set configuration(e){this._configuration=e,this._destroy&&(this._destroy(),this._destroy=void 0,this._ready=!1,this._createForm())}get configuration(){return this._configuration}get data(){return this._storeValues.data}get errors(){return this._storeValues.errors}get touched(){return this._storeValues.touched}get warnings(){return this._storeValues.warnings}get isSubmitting(){return this._storeValues.isSubmitting}get isDirty(){return this._storeValues.isDirty}get isValid(){return this._storeValues.isValid}get isValidating(){return this._storeValues.isValidating}get interacted(){return this._storeValues.interacted}get ready(){return this._ready}_createForm(){var e;const t=this._formElement;if(!t)return;const r=this.configuration;this.elements=t.elements;const{form:n,cleanup:i,...s}=function(e,t){var r,n;function i(t,{debounced:r,level:n}={debounced:!1,level:"error"}){var i;const s="error"===n?"validate":"warn";null!==(i=e.debounced)&&void 0!==i||(e.debounced={});const o=r?e.debounced:e;o[s]?o[s]=[...o[s],t]:o[s]=[t]}function s(t){e.transform?e.transform=[...e.transform,t]:e.transform=[t]}null!==(r=e.extend)&&void 0!==r||(e.extend=[]),null!==(n=e.debounced)&&void 0!==n||(e.debounced={}),e.validate&&!Array.isArray(e.validate)&&(e.validate=[e.validate]),e.debounced.validate&&!Array.isArray(e.debounced.validate)&&(e.debounced.validate=[e.debounced.validate]),e.transform&&!Array.isArray(e.transform)&&(e.transform=[e.transform]),e.warn&&!Array.isArray(e.warn)&&(e.warn=[e.warn]),e.debounced.warn&&!Array.isArray(e.debounced.warn)&&(e.debounced.warn=[e.debounced.warn]);const o=Array.isArray(e.extend)?e.extend:[e.extend];let a=[];const{isSubmitting:u,isValidating:l,data:d,errors:c,warnings:f,touched:v,isValid:h,isDirty:m,cleanup:y,start:p,validateErrors:b,validateWarnings:g,interacted:E}=G(t.storeFactory,e),A=d.update,w=d.set;d.update=t=>A((r=>_(B(t(r),e.transform)))),d.set=t=>w(_(B(t,e.transform)));const S=D({extender:o,config:e,addValidator:i,addTransformer:s,validateErrors:b,validateWarnings:g,stores:{data:d,errors:c,warnings:f,touched:v,isValid:h,isValidating:l,isSubmitting:u,isDirty:m,interacted:E}});a=o.map((t=>t({stage:"SETUP",errors:c,warnings:f,touched:v,data:d,config:e,addValidator:i,addTransformer:s,setFields:S.public.setFields,reset:S.public.reset,validate:S.public.validate})));const F=Object.assign({config:e,stores:{data:d,touched:v,errors:c,warnings:f,isSubmitting:u,isValidating:l,isValid:h,isDirty:m,interacted:E},helpers:Object.assign(Object.assign({},S.public),{addTransformer:s,addValidator:i}),extender:o,validateErrors:b,validateWarnings:g,_getCurrentExtenders:()=>a,_setCurrentExtenders:e=>{a=e}},S.private),{form:O,createSubmitHandler:V,handleSubmit:T}=W(F);return Object.assign({data:d,errors:c,warnings:f,touched:v,isValid:h,isSubmitting:u,isValidating:l,isDirty:m,interacted:E,form:O,handleSubmit:T,createSubmitHandler:V,cleanup:y,startStores:p},S.public)}(r,{storeFactory:ee});this.setData=s.setData,this.setFields=s.setFields,this.setErrors=s.setErrors,this.setTouched=s.setTouched,this.setWarnings=s.setWarnings,this.setIsSubmitting=s.setIsSubmitting,this.setIsDirty=s.setIsDirty,this.setInteracted=s.setInteracted,this.setInitialValues=s.setInitialValues,this.validate=s.validate,this.addField=s.addField,this.unsetField=s.unsetField,this.swapFields=s.swapFields,this.moveField=s.moveField,this.resetField=s.resetField,this.reset=s.reset,this.submit=s.handleSubmit,this.createSubmitHandler=s.createSubmitHandler;const o=re.map((e=>s[e].subscribe((t=>{if(J(t,this._storeValues[e]))return;this._storeValues[e]=t;const r=this[`on${n=e,n.charAt(0).toUpperCase()+n.slice(1)}Change`];var n;"function"==typeof r&&r(t),this.dispatchEvent(new Event(`${e.toLowerCase()}change`))})))),{destroy:a}=n(t),{createSubmitEvent:u,createErrorEvent:l,createSuccessEvent:d}=I(),c=e=>{const t=e,r=u();this.dispatchEvent(r),r.defaultPrevented&&t.preventDefault(),t.onSubmit=r.onSubmit,t.onSuccess=r.onSuccess,t.onError=r.onError},f=e=>{const t=d(e.detail);this.dispatchEvent(t)},v=e=>{const t=e,r=l(t.detail);this.dispatchEvent(r),t.errors=r.errors,r.defaultPrevented&&t.preventDefault()};t.addEventListener("feltesubmit",c),t.addEventListener("feltesuccess",f),t.addEventListener("felteerror",v),this._destroy=()=>{a(),i(),t.removeEventListener("feltesubmit",c),t.removeEventListener("feltesuccess",f),t.removeEventListener("felteerror",v),o.forEach((e=>e()))},this._ready=!0,null===(e=this.onFelteReady)||void 0===e||e.call(this),this.dispatchEvent(new Event("felteready",{bubbles:!0,composed:!0}))}connectedCallback(){setTimeout((()=>{this._updateForm(),this._observer=new MutationObserver(this._updateForm),this._observer.observe(this,{childList:!0})}))}disconnectedCallback(){var e,t;null===(e=this._destroy)||void 0===e||e.call(this),null===(t=this._observer)||void 0===t||t.disconnect()}static get observedAttributes(){return["id"]}attributeChangedCallback(e,t,r){if(t!==r)switch(e){case"id":this.id=r}}}function ie(e,t){return document.addEventListener("felteconnect",(function r(n){const i=n.composedPath()[0];i.id===e&&(i.configuration=t,document.removeEventListener("felteconnect",r))})),new Promise((t=>{document.addEventListener("felteready",(function r(n){const i=n.composedPath()[0];i.id===e&&(t(i),document.removeEventListener("felteready",r))}))}))}customElements.get("felte-form")||(customElements.define("felte-form",ne),window.HTMLFelteFormElement=ne);export{Q as FelteField,ne as FelteForm,t as FelteSubmitError,ie as prepareForm};
***************************************************************************** */function O(e){return function(t){if(u(t)){return function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(V(t,e),["key"])}return e}}function V(e,t){return A(e,(e=>u(e)?V(e,t):Array.isArray(e)?e.map(O(t)):t))}function T(e,t){if(!e||Object(e)!==e)return;void 0!==e&&(e=l(e));const r=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g)||[],n=1===r.length?e:a(e,r.slice(0,-1).join("."));return Array.isArray(n)?n.splice(Number(r[r.length-1]),1):null==n||delete n[r[r.length-1]],e}function k(e,t,r,n){return d(e,t,(e=>void 0===e||Array.isArray(e)?(e||(e=[]),void 0===n?e.push(r):e.splice(n,0,r),e):e))}function j(e){return"function"==typeof e}function L(e){return(t,r)=>{if("string"==typeof t){const n=t;e((e=>{const t=j(r)?r(a(e,n)):r;return c(e,n,t)}))}else e((e=>j(t)?t(e):t))}}function D({stores:t,config:r,validateErrors:n,validateWarnings:i}){var s;let o,f=_(null!==(s=r.initialValues)&&void 0!==s?s:{});const{data:v,touched:h,errors:m,warnings:y,isDirty:p,isSubmitting:g,interacted:E}=t,A=L(v.update),F=L(h.update),O=L(m.update),j=L(y.update);function D(e){A((t=>{const r=e(t);return o&&b(o,r),r}))}const I=(e,t,r)=>{L(D)(e,t),"string"==typeof e&&r&&F(e,!0)};function C(e){m.update(e),y.update(e),h.update(e),v.update((t=>{const r=e(t);return setTimeout((()=>o&&b(o,r))),r}))}const x=L(g.update),P=L(p.update),N=L(E.update);return{public:{setData:A,setFields:I,setTouched:F,setErrors:O,setWarnings:j,setIsSubmitting:x,setIsDirty:P,setInteracted:N,validate:async function(){const t=e(v);h.set(w(t,!0)),E.set(null);const r=await n(t);return await i(t),r},reset:function(){I(l(f)),F((e=>V(e,!1))),E.set(null),p.set(!1)},unsetField:function(e){C((t=>T(t,e)))},resetField:function(e){const t=a(f,e),r=!!u(t)&&w(t,!1),n=u(r)?V(r,[]):[];v.update((r=>{const n=c(r,e,t);return o&&b(o,n),n})),h.update((t=>c(t,e,r))),m.update((t=>c(t,e,n))),y.update((t=>c(t,e,n)))},addField:function(e,t,r){const n=!!u(t)&&w(t,!1),i=u(n)?V(n,[]):[];t=u(t)?Object.assign(Object.assign({},t),{key:S()}):t,m.update((t=>k(t,e,i,r))),y.update((t=>k(t,e,i,r))),h.update((t=>k(t,e,n,r))),v.update((n=>{const i=k(n,e,t,r);return setTimeout((()=>o&&b(o,i))),i}))},swapFields:function(e,t,r){C((n=>function(e,t,r,n){return d(e,t,(e=>e&&Array.isArray(e)?([e[r],e[n]]=[e[n],e[r]],e):e))}(n,e,t,r)))},moveField:function(e,t,r){C((n=>function(e,t,r,n){return d(e,t,(e=>e&&Array.isArray(e)?(e.splice(n,0,e.splice(r,1)[0]),e):e))}(n,e,t,r)))},setInitialValues:e=>{f=_(e)}},private:{_setFormNode(e){o=e},_getFormNode:()=>o,_getInitialValues:()=>f}}}function I(){class e extends CustomEvent{constructor(e){super("feltesuccess",{detail:e})}}class t extends CustomEvent{constructor(e){super("felteerror",{detail:e,cancelable:!0})}setErrors(e){this.preventDefault(),this.errors=e}}class r extends Event{constructor(){super("feltesubmit",{cancelable:!0})}handleSubmit(e){this.onSubmit=e}handleError(e){this.onError=e}handleSuccess(e){this.onSuccess=e}}return{createErrorEvent:e=>new t(e),createSubmitEvent:()=>new r,createSuccessEvent:t=>new e(t)}}function C(...e){const t=e.pop(),r=l(e.shift());if(0===e.length)return r;for(const n of e){if(!n)continue;let e=t(r,n);if(void 0!==e)return e;const i=Array.from(new Set(Object.keys(r).concat(Object.keys(n))));for(const s of i)if(e=t(r[s],n[s]),void 0!==e)r[s]=e;else if(u(n[s])&&u(r[s]))r[s]=C(r[s],n[s],t);else if(Array.isArray(n[s]))r[s]=n[s].map(((e,n)=>{if(!u(e))return e;return C(Array.isArray(r[s])?r[s][n]:r[s],e,t)}));else if(u(n[s])){const e=V(l(n[s]),void 0);r[s]=C(e,n[s],t)}else void 0!==n[s]&&(r[s]=n[s])}return r}function x(...e){return C(...e,(()=>{}))}function P(e,t){return function(e,t){return Object.keys(e).some((r=>t(e[r])))}(e,(e=>u(e)?P(e,t):Array.isArray(e)?0===e.length||e.every((e=>"string"==typeof e))?t(e):e.some((e=>u(e)?P(e,t):t(e))):t(e)))}function N(e){let t=e;for(;t&&"FORM"!==t.nodeName;){if(t.hasAttribute("data-felte-ignore"))return!0;t=t.parentElement}return!1}function M(e,t){let r;return(...n)=>{clearTimeout(r),r=setTimeout((()=>{e.apply(this,n)}),t)}}function H(e,t){if(!u(e)||!u(t)){if(Array.isArray(t)){if(t.some(u))return;const r=Array.isArray(e)?e:[];return t.map(((e,t)=>{var n;return null!==(n=r[t])&&void 0!==n?n:e}))}return void 0!==e?e:void 0}}function R(...e){return C(...e,H)}function W({helpers:i,stores:d,config:h,extender:p,validateErrors:b,validateWarnings:g,_setFormNode:A,_getFormNode:S,_getInitialValues:_,_setCurrentExtenders:O,_getCurrentExtenders:k}){const{setFields:j,setTouched:L,reset:D,setInitialValues:C}=i,{addValidator:H,addTransformer:W,validate:q,setIsDirty:B,setIsSubmitting:$}=i,U=E(i,["addValidator","addTransformer","validate","setIsDirty","setIsSubmitting"]),{data:K,errors:z,warnings:X,touched:G,isSubmitting:J,isDirty:Q,interacted:Y}=d;function Z(r){return async function(n){var i,o,a,u,l,d,c;const f=S(),{createErrorEvent:v,createSubmitEvent:m,createSuccessEvent:y}=I(),p=m();null==f||f.dispatchEvent(p);const E=null!==(o=null!==(i=p.onError)&&void 0!==i?i:null==r?void 0:r.onError)&&void 0!==o?o:h.onError,A=null!==(u=null!==(a=p.onSuccess)&&void 0!==a?a:null==r?void 0:r.onSuccess)&&void 0!==u?u:h.onSuccess,_=null!==(c=null!==(d=null!==(l=p.onSubmit)&&void 0!==l?l:null==r?void 0:r.onSubmit)&&void 0!==d?d:h.onSubmit)&&void 0!==c?c:function(e){if(e)return async function(){let r=new FormData(e);const n=new URL(e.action),i="get"===e.method.toLowerCase()?"get":n.searchParams.get("_method")||e.method;let s,o=e.enctype;e.querySelector('input[type="file"]')&&(o="multipart/form-data"),"get"!==i&&"application/x-www-form-urlencoded"!==o||(r=new URLSearchParams(r)),"get"===i?(r.forEach(((e,t)=>{n.searchParams.append(t,e)})),s={method:i}):s={method:i,body:r,headers:{"Content-Type":o}};const a=await window.fetch(n.toString(),s);if(a.ok)return a;throw new t("An error occurred while submitting the form",a)}}(f);if(!_)return;if(null==n||n.preventDefault(),p.defaultPrevented)return;J.set(!0),Y.set(null);const O=F(e(K)),T=await b(O,null==r?void 0:r.validate),j=await g(O,null==r?void 0:r.warn);if(j&&X.set(x(V(O,[]),j)),G.set(w(O,!0)),T){G.set(w(T,!0));if(P(T,(e=>Array.isArray(e)?e.length>=1:!!e)))return await new Promise((e=>setTimeout(e))),k().forEach((e=>{var t;return null===(t=e.onSubmitError)||void 0===t?void 0:t.call(e,{data:O,errors:T})})),void J.set(!1)}const L=Object.assign(Object.assign({},U),{form:f,controls:f&&Array.from(f.elements).filter(s),config:Object.assign(Object.assign({},h),r)});try{const e=await _(O,L);null==f||f.dispatchEvent(y(Object.assign({response:e},L))),await(null==A?void 0:A(e,L))}catch(t){const r=v(Object.assign({error:t},L));if(null==f||f.dispatchEvent(r),!E&&!r.defaultPrevented)throw t;if(!E&&!r.errors)return;const n=r.errors||await(null==E?void 0:E(t,L));n&&(G.set(w(n,!0)),z.set(n),await new Promise((e=>setTimeout(e))),k().forEach((t=>{var r;return null===(r=t.onSubmitError)||void 0===r?void 0:r.call(t,{data:O,errors:e(z)})})))}finally{J.set(!1)}}}const ee=Z();return{form:function(t){function i(e){return function(r){return r({form:t,stage:e,controls:Array.from(t.elements).filter(s),data:K,errors:z,warnings:X,touched:G,config:h,addValidator:H,addTransformer:W,setFields:j,validate:q,reset:D})}}t.requestSubmit||(t.requestSubmit=ee),O(p.map(i("MOUNT"))),t.noValidate=!!h.validate;const{defaultData:d,defaultTouched:b}=y(t);function g(e){const t=e.target;if(!t||!s(t)||n(t)||N(t))return;if(["checkbox","radio","file"].includes(t.type))return;if(!t.name)return;Q.set(!0);const r=m(t);Y.set(t.name),K.update((e=>c(e,f(t),r)))}function E(e){const i=e.target;if(i&&s(i)&&!N(i)&&i.name)if(L(f(i),!0),Y.set(i.name),(n(i)||["checkbox","radio","file","hidden"].includes(i.type))&&Q.set(!0),"hidden"===i.type&&K.update((e=>c(e,f(i),i.value))),n(i))!function(e){if(e.multiple){const t=Array.from(e.options).filter((e=>e.selected)).map((e=>e.value));K.update((r=>c(r,f(e),t)))}else K.update((t=>c(t,f(e),e.value)))}(i);else{if(!r(i))return;"checkbox"===i.type?function(e){const n=f(e),i=Array.from(t.querySelectorAll(`[name="${e.name}"]`)).filter((e=>!!s(e)&&n===f(e)));if(0!==i.length)1===i.length?K.update((t=>c(t,f(e),e.checked))):K.update((t=>c(t,f(e),i.filter(r).filter((e=>e.checked)).map((e=>e.value)))))}(i):"radio"===i.type?function(e){const n=t.querySelectorAll(`[name="${e.name}"]`),i=Array.from(n).find((e=>r(e)&&e.checked));K.update((t=>c(t,f(e),null==i?void 0:i.value)))}(i):"file"===i.type&&function(e){var t;const r=Array.from(null!==(t=e.files)&&void 0!==t?t:[]);K.update((t=>c(t,f(e),e.multiple?r:r[0])))}(i)}}function w(e){const t=e.target;t&&s(t)&&!N(t)&&t.name&&(L(f(t),!0),Y.set(t.name))}function S(e){e.preventDefault(),D()}A(t),C(x(l(d),_())),j(_()),G.set(b);const F=M((()=>{k().forEach((e=>{var t;return null===(t=e.destroy)||void 0===t?void 0:t.call(e)})),O(p.map(i("UPDATE")));const{defaultData:e,defaultTouched:r}=y(t);K.update((t=>R(t,e))),G.update((e=>R(e,r)))}),0);let V=[];const I=M((()=>{k().forEach((e=>{var t;return null===(t=e.destroy)||void 0===t?void 0:t.call(e)})),O(p.map(i("UPDATE"))),function(t){let r=e(K),n=e(G),i=e(z),s=e(X);for(const o of t.reverse()){if(o.hasAttribute("data-felte-keep-on-remove")&&"false"!==o.dataset.felteKeepOnRemove)continue;const t=/.*(\[[0-9]+\]|\.[0-9]+)\.[^.]+$/;let l=f(o);const d=e(G);if(t.test(l)){const e=l.split(".").slice(0,-1).join("."),t=a(d,e);u(t)&&Object.keys(t).length<=1&&(l=e)}r=T(r,l),n=T(n,l),i=T(i,l),s=T(s,l)}K.set(r),G.set(n),z.set(i),X.set(s)}(V),V=[]}),0),P=new MutationObserver((function(e){for(const t of e)if("childList"===t.type){if(t.addedNodes.length>0){if(!Array.from(t.addedNodes).some((e=>{if(!o(e))return!1;if(s(e))return!0;return v(e).length>0})))continue;F()}if(t.removedNodes.length>0)for(const e of t.removedNodes){if(!o(e))continue;const t=v(e);0!==t.length&&(V.push(...t),I())}}}));P.observe(t,{childList:!0,subtree:!0}),t.addEventListener("input",g),t.addEventListener("change",E),t.addEventListener("focusout",w),t.addEventListener("submit",ee),t.addEventListener("reset",S);const B=z.subscribe((e=>{for(const r of t.elements){if(!s(r)||!r.name)continue;const t=a(e,f(r)),n=Array.isArray(t)?t.join("\n"):"string"==typeof t?t:void 0;n!==r.dataset.felteValidationMessage&&(n?(r.dataset.felteValidationMessage=n,r.setAttribute("aria-invalid","true")):(delete r.dataset.felteValidationMessage,r.removeAttribute("aria-invalid")))}}));return{destroy(){P.disconnect(),t.removeEventListener("input",g),t.removeEventListener("change",E),t.removeEventListener("focusout",w),t.removeEventListener("submit",ee),t.removeEventListener("reset",S),B(),k().forEach((e=>{var t;return null===(t=e.destroy)||void 0===t?void 0:t.call(e)}))}}},createSubmitHandler:Z,handleSubmit:ee}}function q(e,t){return t?Array.isArray(t)?t.reduce(((e,t)=>t(e)),e):t(e):e}function B(e,t){if(!u(e)&&!u(t)){if(null===e||""===e)return t;if(null===t||""===t)return e;if(!t)return e;if(e&&t){if(Array.isArray(e)){if(!Array.isArray(t))return[...e,t];const r=[],n=Math.max(t.length,e.length);for(let i=0;i<n;i++){let n=e[i],s=t[i];u(n)||u(s)?r.push($([null!=n?n:{},null!=s?s:{}])):(Array.isArray(n)||(n=[n]),Array.isArray(s)||(s=[s]),r.push(...n,...s))}return r.filter(Boolean)}return Array.isArray(t)||(t=[t]),[e,...t].reduce(((e,t)=>e.concat(t)),[]).filter(Boolean)}}}function $(e){return C(...e,B)}function U(e,t){if(u(e))return!t||u(t)&&0===Object.keys(t).length?V(e,null):void 0;if(Array.isArray(e)){if(e.some(u))return;const r=Array.isArray(t)?t:[];return e.map(((e,t)=>{const n=r[t];return Array.isArray(n)&&0===n.length?null:e&&n||null}))}return Array.isArray(t)&&0===t.length?null:Array.isArray(t)?e?t:null:e&&t?[t]:null}function K(e,t){if(u(e))return!t||u(t)&&0===Object.keys(t).length?V(e,null):void 0;if(Array.isArray(e)){if(e.some(u))return;const r=Array.isArray(t)?t:[];return e.map(((e,t)=>{const n=r[t];return Array.isArray(n)&&0===n.length?null:n||null}))}return Array.isArray(t)&&0===t.length?null:Array.isArray(t)?t:t?[t]:null}function z([e,t]){return C(t,e,U)}function X([e,t]){return C(t,e,K)}function G(e,t){var r,n,i,s,o,a,u,d,c;const f=function(e){return function(t,r,n){const i=Array.isArray(t)?t:[t],s=new Array(i.length),o=e(n),a=o.set,u=o.subscribe;let l;return o.subscribe=function(e){const t=u(e);return()=>{t()}},[o,function(){l=i.map(((e,t)=>e.subscribe((e=>{s[t]=e,a(r(s))}))))},function(){null==l||l.forEach((e=>e()))}]}}(e),v=t.initialValues=t.initialValues?_(q(l(t.initialValues),t.transform)):{},h=w(F(v),!1),m=e(h),y=e(0),[p,b,g]=f([m,y],(([e,t])=>P(e,(e=>!!e))&&t>=1),!1);function E(e){let t;return async function(r,n,i,s=!1){if(!i||!r)return;let o=n&&Object.keys(n).length>0?n:V(r,[]);const a=function(e){const t={aborted:!1,priority:e};return{signal:t,abort(){t.aborted=!0}}}(s);if((null==t?void 0:t.signal.priority)&&!s||(null==t||t.abort(),t=a),t.signal.priority&&!s)return;y.update((e=>e+1));const u=(l=r,(d=i)?(Array.isArray(d)?d:[d]).map((e=>e(l))):[]);var l,d;return u.forEach((async t=>{const r=await t;a.signal.aborted||(o=$([o,r]),e.set(o))})),await Promise.all(u),t=void 0,y.update((e=>e-1)),o}}delete p.set,delete p.update;let A=V(h,[]);const S=e(v),O=V(h,[]),T=e(O),k=e(l(O)),[j,L,D]=f([T,k],$,l(O)),I=V(h,[]),C=e(I),x=e(l(I)),[N,H,R]=f([C,x],$,l(I)),[W,B,U]=f([j,m],z,l(O)),[K,G,J]=f([N,m],X,l(I));let Q=!1;const[Y,Z,ee]=f(j,(([e])=>{var r;return Q?!P(e,(e=>Array.isArray(e)?e.length>=1:!!e)):(Q=!0,!t.validate&&!(null===(r=t.debounced)||void 0===r?void 0:r.validate))}),!t.validate&&!(null===(r=t.debounced)||void 0===r?void 0:r.validate));delete Y.set,delete Y.update;const te=e(!1),re=e(!1),ne=e(null),ie=E(T),se=E(C),oe=E(k),ae=E(x),ue=M(oe,null!==(o=null!==(i=null===(n=t.debounced)||void 0===n?void 0:n.validateTimeout)&&void 0!==i?i:null===(s=t.debounced)||void 0===s?void 0:s.timeout)&&void 0!==o?o:300),le=M(ae,null!==(c=null!==(u=null===(a=t.debounced)||void 0===a?void 0:a.warnTimeout)&&void 0!==u?u:null===(d=t.debounced)||void 0===d?void 0:d.timeout)&&void 0!==c?c:300);let de=O,ce=I;function fe(){const e=S.subscribe((e=>{var r,n;const i=F(e);ie(i,A,t.validate),se(i,A,t.warn),ue(i,A,null===(r=t.debounced)||void 0===r?void 0:r.validate),le(i,A,null===(n=t.debounced)||void 0===n?void 0:n.warn)})),r=m.subscribe((e=>{A=V(e,[])})),n=j.subscribe((e=>{de=e})),i=N.subscribe((e=>{ce=e}));return L(),Z(),H(),B(),G(),b(),function(){e(),U(),D(),R(),J(),ee(),g(),r(),n(),i()}}function ve(e){T.set(e(de)),k.set({})}function he(e){C.set(e(ce)),x.set({})}return W.set=function(e){ve((()=>e))},W.update=ve,K.set=function(e){he((()=>e))},K.update=he,{data:S,errors:W,warnings:K,touched:m,isValid:Y,isSubmitting:te,isDirty:re,isValidating:p,interacted:ne,validateErrors:async function(e,r){var n;const i=F(e),s=ie(i,A,null!=r?r:t.validate,!0);if(r)return s;const o=oe(i,A,null===(n=t.debounced)||void 0===n?void 0:n.validate,!0);return $(await Promise.all([s,o]))},validateWarnings:async function(e,r){var n;const i=F(e),s=se(i,A,null!=r?r:t.warn,!0);if(r)return s;const o=ae(i,A,null===(n=t.debounced)||void 0===n?void 0:n.warn,!0);return $(await Promise.all([s,o]))},cleanup:t.preventStoreStart?()=>{}:fe(),start:fe}}function J(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((e,r)=>J(e,t[r])));if(u(e)&&u(t)){const r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every((r=>J(e[r],t[r])))}return!1}function Q(e){return""===e||!!e&&"false"!==e}class Y extends HTMLElement{constructor(){var e;super(...arguments),this.touchOnChange=!1,this.valueProp="value",this.inputEvent="input",this.blurEvent="focusout",this.composed=!1,this._onBlur=(e="blur",function(){throw new TypeError(`Can't call "${e}" on HTMLFelteFieldElement. The element is not ready yet.`)}),this._ready=!1,this._updateField=()=>{var e;const t=this.target?this.querySelector(this.target):this.firstElementChild;t&&t!==this._element&&(this._element=t,null===(e=this._destroy)||void 0===e||e.call(this),this._destroy=void 0,this._createField())}}static get observedAttributes(){return["name","touchonchange","valueprop","inputevent","blurevent","composed","value","target"]}static get attributeMap(){return{name:{converter:String,name:"name"},touchonchange:{converter:Q,name:"touchOnChange"},valueprop:{converter:String,name:"valueProp"},inputevent:{converter:String,name:"inputEvent"},blurevent:{converter:String,name:"blurEvent"},value:{converter:String,name:"value"},composed:{converter:Q,name:"composed"},target:{converter:String,name:"target"}}}attributeChangedCallback(e,t,r){if(t===r)return;const{converter:n,name:i}=Y.attributeMap[e];this[i]=n(r)}set value(e){var t;null===(t=this._onInput)||void 0===t||t.call(this,e),this._value=e}get value(){return this._value}blur(){this._onBlur()}get ready(){return this._ready}_createField(){var e;const{name:t,inputEvent:r,blurEvent:n,touchOnChange:i,value:a,composed:u}=this;if(!t)throw new Error('<felte-field> must have a "name" attribute');const l=this._element;if(!l)return;l[this.valueProp]=a;const{field:d,onInput:c,onBlur:f}=function(e,t){var r,n;let i,a,u,l,d,c;function f(e,t){if(!d)return;p(d,t);const r=new Event(e,{bubbles:!0,composed:!0});d.dispatchEvent(r)}function v(e){e.forEach((()=>{const e=d.getAttribute("aria-invalid");e?l.setAttribute("aria-invalid",e):l.removeAttribute("aria-invalid");const t=d.getAttribute("data-felte-validation-message");t?l.setAttribute("data-felte-validation-message",t):l.removeAttribute("data-felte-validation-message")}))}function h(e){c&&(p(d,a),c(e))}function m(e){f(u?"change":"input",e)}return"string"==typeof e?(i=e,a=null==t?void 0:t.defaultValue,u=null!==(r=null==t?void 0:t.touchOnChange)&&void 0!==r&&r,c=null==t?void 0:t.onFormReset):(i=e.name,a=e.defaultValue,u=null!==(n=e.touchOnChange)&&void 0!==n&&n,c=null==e?void 0:e.onFormReset),{field:function(e){let t,r;if(l=e,s(e))return d=e,d.name=i,{};{let n=!1,u=!1;return setTimeout((()=>{if(u)return;const c=l.parentNode;if(!c||!o(c))return;const f=c.querySelector(`[name="${i}"]`);if(f&&s(f))d=f;else{const t=document.createElement("input");t.type="hidden",t.name=i,c.insertBefore(t,e.nextSibling),d=t,n=!0}p(d,a),t=new MutationObserver(v),t.observe(d,g),r=d.closest("form"),null==r||r.addEventListener("reset",h)})),{destroy(){var e;n&&(null===(e=d.parentNode)||void 0===e||e.removeChild(d)),u=!0,null==t||t.disconnect(),null==r||r.removeEventListener("reset",h)}}}},onInput:m,onChange:m,onBlur:function(){f("focusout")}}}(t,{touchOnChange:i,defaultValue:a,onFormReset:()=>{this.value=a,l[this.valueProp]=a}});this._onInput=c,this._onBlur=f;const{destroy:v}=d(l),h=e=>{const t=u?e.composedPath()[0]:e.target;this.value=t[this.valueProp]},m=()=>{f()};l.addEventListener(r,h),l.addEventListener(n,m),this._destroy=()=>{null==v||v(),l.removeEventListener(r,h),l.removeEventListener(r,m)},this._ready=!0,null===(e=this.onfeltefieldready)||void 0===e||e.call(this),this.dispatchEvent(new Event("feltefieldready"))}connectedCallback(){setTimeout((()=>{this._updateField(),this._observer=new MutationObserver(this._updateField),this._observer.observe(this,{childList:!0})}))}disconnectedCallback(){var e,t;null===(e=this._destroy)||void 0===e||e.call(this),null===(t=this._observer)||void 0===t||t.disconnect()}}customElements.get("felte-field")||(customElements.define("felte-field",Y),window.HTMLFelteFieldElement=Y);const Z=[],ee=()=>{};function te(e,t=ee){let r;const n=new Set;function i(t){if(s=t,((i=e)!=i?s==s:i!==s||i&&"object"==typeof i||"function"==typeof i)&&(e=t,r)){const t=!Z.length;for(const t of n)t[1](),Z.push(t,e);if(t){for(let e=0;e<Z.length;e+=2)Z[e][0](Z[e+1]);Z.length=0}}var i,s}return{set:i,update:function(t){i(t(e))},subscribe:function(s,o=ee){const a=[s,o];return n.add(a),1===n.size&&(r=t(i)||ee),s(e),()=>{n.delete(a),r&&0===n.size&&(r(),r=null)}}}}function re(e){return function(){throw new TypeError(`Can't call "${e}" on HTMLFelteFormElement. The element is not ready yet.`)}}const ne=["data","errors","touched","warnings","isSubmitting","isDirty","isValid","isValidating","interacted"];class ie extends HTMLElement{constructor(){super(...arguments),this._configuration={},this._storeValues={data:void 0,errors:void 0,touched:void 0,warnings:void 0,isSubmitting:!1,isDirty:!1,isValid:void 0,isValidating:!1,interacted:null},this.setData=re("setData"),this.setFields=re("setFields"),this.setInitialValues=re("setInitialValues"),this.addField=re("addField"),this.unsetField=re("unsetField"),this.swapFields=re("swapFields"),this.moveField=re("moveField"),this.resetField=re("resetField"),this.reset=re("reset"),this.submit=re("submit"),this.createSubmitHandler=re("createSubmitHandler"),this.setErrors=re("setErrors"),this.setTouched=re("setTouched"),this.setWarnings=re("setWarnings"),this.setIsSubmitting=re("setIsSubmitting"),this.setIsDirty=re("setIsDirty"),this.setInteracted=re("setInteracted"),this._ready=!1,this.validate=re("validate"),this._formElement=null,this._updateForm=()=>{var e;const t=this.querySelector("form");t&&t!==this._formElement&&(this.dispatchEvent(new Event("felteconnect",{bubbles:!0,composed:!0})),this._formElement=t,null===(e=this._destroy)||void 0===e||e.call(this),this._destroy=void 0,this._createForm())}}set configuration(e){this._configuration=e,this._destroy&&(this._destroy(),this._destroy=void 0,this._ready=!1,this._createForm())}get configuration(){return this._configuration}get data(){return this._storeValues.data}get errors(){return this._storeValues.errors}get touched(){return this._storeValues.touched}get warnings(){return this._storeValues.warnings}get isSubmitting(){return this._storeValues.isSubmitting}get isDirty(){return this._storeValues.isDirty}get isValid(){return this._storeValues.isValid}get isValidating(){return this._storeValues.isValidating}get interacted(){return this._storeValues.interacted}get ready(){return this._ready}_createForm(){var e;const t=this._formElement;if(!t)return;const r=this.configuration;this.elements=t.elements;const{form:n,cleanup:i,...s}=function(e,t){var r,n;function i(t,{debounced:r,level:n}={debounced:!1,level:"error"}){var i;const s="error"===n?"validate":"warn";null!==(i=e.debounced)&&void 0!==i||(e.debounced={});const o=r?e.debounced:e;o[s]?o[s]=[...o[s],t]:o[s]=[t]}function s(t){e.transform?e.transform=[...e.transform,t]:e.transform=[t]}null!==(r=e.extend)&&void 0!==r||(e.extend=[]),null!==(n=e.debounced)&&void 0!==n||(e.debounced={}),e.validate&&!Array.isArray(e.validate)&&(e.validate=[e.validate]),e.debounced.validate&&!Array.isArray(e.debounced.validate)&&(e.debounced.validate=[e.debounced.validate]),e.transform&&!Array.isArray(e.transform)&&(e.transform=[e.transform]),e.warn&&!Array.isArray(e.warn)&&(e.warn=[e.warn]),e.debounced.warn&&!Array.isArray(e.debounced.warn)&&(e.debounced.warn=[e.debounced.warn]);const o=Array.isArray(e.extend)?e.extend:[e.extend];let a=[];const{isSubmitting:u,isValidating:l,data:d,errors:c,warnings:f,touched:v,isValid:h,isDirty:m,cleanup:y,start:p,validateErrors:b,validateWarnings:g,interacted:E}=G(t.storeFactory,e),A=d.update,w=d.set;d.update=t=>A((r=>_(q(t(r),e.transform)))),d.set=t=>w(_(q(t,e.transform)));const S=D({extender:o,config:e,addValidator:i,addTransformer:s,validateErrors:b,validateWarnings:g,stores:{data:d,errors:c,warnings:f,touched:v,isValid:h,isValidating:l,isSubmitting:u,isDirty:m,interacted:E}});a=o.map((t=>t({stage:"SETUP",errors:c,warnings:f,touched:v,data:d,config:e,addValidator:i,addTransformer:s,setFields:S.public.setFields,reset:S.public.reset,validate:S.public.validate})));const F=Object.assign({config:e,stores:{data:d,touched:v,errors:c,warnings:f,isSubmitting:u,isValidating:l,isValid:h,isDirty:m,interacted:E},helpers:Object.assign(Object.assign({},S.public),{addTransformer:s,addValidator:i}),extender:o,validateErrors:b,validateWarnings:g,_getCurrentExtenders:()=>a,_setCurrentExtenders:e=>{a=e}},S.private),{form:O,createSubmitHandler:V,handleSubmit:T}=W(F);return Object.assign({data:d,errors:c,warnings:f,touched:v,isValid:h,isSubmitting:u,isValidating:l,isDirty:m,interacted:E,form:O,handleSubmit:T,createSubmitHandler:V,cleanup:y,startStores:p},S.public)}(r,{storeFactory:te});this.setData=s.setData,this.setFields=s.setFields,this.setErrors=s.setErrors,this.setTouched=s.setTouched,this.setWarnings=s.setWarnings,this.setIsSubmitting=s.setIsSubmitting,this.setIsDirty=s.setIsDirty,this.setInteracted=s.setInteracted,this.setInitialValues=s.setInitialValues,this.validate=s.validate,this.addField=s.addField,this.unsetField=s.unsetField,this.swapFields=s.swapFields,this.moveField=s.moveField,this.resetField=s.resetField,this.reset=s.reset,this.submit=s.handleSubmit,this.createSubmitHandler=s.createSubmitHandler;const o=ne.map((e=>s[e].subscribe((t=>{if(J(t,this._storeValues[e]))return;this._storeValues[e]=t;const r=this[`on${n=e,n.charAt(0).toUpperCase()+n.slice(1)}Change`];var n;"function"==typeof r&&r(t),this.dispatchEvent(new Event(`${e.toLowerCase()}change`))})))),{destroy:a}=n(t),{createSubmitEvent:u,createErrorEvent:l,createSuccessEvent:d}=I(),c=e=>{const t=e,r=u();this.dispatchEvent(r),r.defaultPrevented&&t.preventDefault(),t.onSubmit=r.onSubmit,t.onSuccess=r.onSuccess,t.onError=r.onError},f=e=>{const t=d(e.detail);this.dispatchEvent(t)},v=e=>{const t=e,r=l(t.detail);this.dispatchEvent(r),t.errors=r.errors,r.defaultPrevented&&t.preventDefault()};t.addEventListener("feltesubmit",c),t.addEventListener("feltesuccess",f),t.addEventListener("felteerror",v),this._destroy=()=>{a(),i(),t.removeEventListener("feltesubmit",c),t.removeEventListener("feltesuccess",f),t.removeEventListener("felteerror",v),o.forEach((e=>e()))},this._ready=!0,null===(e=this.onFelteReady)||void 0===e||e.call(this),this.dispatchEvent(new Event("felteready",{bubbles:!0,composed:!0}))}connectedCallback(){setTimeout((()=>{this._updateForm(),this._observer=new MutationObserver(this._updateForm),this._observer.observe(this,{childList:!0})}))}disconnectedCallback(){var e,t;null===(e=this._destroy)||void 0===e||e.call(this),null===(t=this._observer)||void 0===t||t.disconnect()}static get observedAttributes(){return["id"]}attributeChangedCallback(e,t,r){if(t!==r)switch(e){case"id":this.id=r}}}function se(e,t){return document.addEventListener("felteconnect",(function r(n){const i=n.composedPath()[0];i.id===e&&(i.configuration=t,document.removeEventListener("felteconnect",r))})),new Promise((t=>{document.addEventListener("felteready",(function r(n){const i=n.composedPath()[0];i.id===e&&(t(i),document.removeEventListener("felteready",r))}))}))}customElements.get("felte-form")||(customElements.define("felte-form",ie),window.HTMLFelteFormElement=ie);export{Y as FelteField,ie as FelteForm,t as FelteSubmitError,se as prepareForm};
//# sourceMappingURL=index.min.js.map

@@ -16,2 +16,3 @@ import { FieldValue } from '@felte/core';

composed: boolean;
target?: string;
private _value?;

@@ -18,0 +19,0 @@ set value(newValue: Value);

@@ -16,2 +16,3 @@ import { FieldValue } from '@felte/core';

composed: boolean;
target?: string;
private _value?;

@@ -18,0 +19,0 @@ set value(newValue: Value);

@@ -16,2 +16,3 @@ import { FieldValue, Obj, FormConfig, Keyed, Errors, Touched, Helpers, Form, Paths, FieldsSetter, ObjectSetter } from "@felte/core";

composed: boolean;
target?: string;
private _value?;

@@ -18,0 +19,0 @@ set value(newValue: Value);

@@ -16,2 +16,3 @@ import { FieldValue, Obj, FormConfig, Keyed, Errors, Touched, Helpers, Form, Paths, FieldsSetter, ObjectSetter } from "@felte/core";

composed: boolean;
target?: string;
private _value?;

@@ -18,0 +19,0 @@ set value(newValue: Value);

{
"name": "@felte/element",
"version": "0.3.1",
"version": "0.3.2",
"description": "An extensible form library that can be used as a custom element",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc