easy-forms-core 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/easy-form.js CHANGED
@@ -1,8 +1,8 @@
1
- var Je=Object.defineProperty;var _t=(l,t,e)=>t in l?Je(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var Ot=(l,t)=>()=>(l&&(t=l(l=0)),t);var jt=(l,t)=>{for(var e in t)Je(l,e,{get:t[e],enumerable:!0})};var T=(l,t,e)=>_t(l,typeof t!="symbol"?t+"":t,e);var Ye={};jt(Ye,{Hooks:()=>_,Lexer:()=>M,Marked:()=>Pt,Parser:()=>z,Renderer:()=>K,TextRenderer:()=>ze,Tokenizer:()=>G,defaults:()=>R,getDefaults:()=>Te,lexer:()=>Yr,marked:()=>C,options:()=>Hr,parse:()=>Wr,parseInline:()=>jr,parser:()=>Ur,setOptions:()=>Br,use:()=>_r,walkTokens:()=>Or});function Te(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}function St(l){R=l}function S(l,t=""){let e=typeof l=="string"?l:l.source,a={replace:(r,s)=>{let i=typeof s=="string"?s:s.source;return i=i.replace(L.caret,"$1"),e=e.replace(r,i),a},getRegex:()=>new RegExp(e,t)};return a}function A(l,t){if(t){if(L.escapeTest.test(l))return l.replace(L.escapeReplace,xt)}else if(L.escapeTestNoEncode.test(l))return l.replace(L.escapeReplaceNoEncode,xt);return l}function kt(l){try{l=encodeURI(l).replace(L.percentDecode,"%")}catch{return null}return l}function wt(l,t){let e=l.replace(L.findPipe,(s,i,n)=>{let o=!1,d=i;for(;--d>=0&&n[d]==="\\";)o=!o;return o?"|":" |"}),a=e.split(L.splitPipe),r=0;if(a[0].trim()||a.shift(),a.length>0&&!a.at(-1)?.trim()&&a.pop(),t)if(a.length>t)a.splice(t);else for(;a.length<t;)a.push("");for(;r<a.length;r++)a[r]=a[r].trim().replace(L.slashPipe,"|");return a}function Z(l,t,e){let a=l.length;if(a===0)return"";let r=0;for(;r<a;){let s=l.charAt(a-r-1);if(s===t&&!e)r++;else if(s!==t&&e)r++;else break}return l.slice(0,a-r)}function Nr(l,t){if(l.indexOf(t[1])===-1)return-1;let e=0;for(let a=0;a<l.length;a++)if(l[a]==="\\")a++;else if(l[a]===t[0])e++;else if(l[a]===t[1]&&(e--,e<0))return a;return e>0?-2:-1}function Dr(l,t=0){let e=t,a="";for(let r of l)if(r===" "){let s=4-e%4;a+=" ".repeat(s),e+=s}else a+=r,e++;return a}function Et(l,t,e,a,r){let s=t.href,i=t.title||null,n=l[1].replace(r.other.outputLinkReplace,"$1");a.state.inLink=!0;let o={type:l[0].charAt(0)==="!"?"image":"link",raw:e,href:s,title:i,text:n,tokens:a.inlineTokens(n)};return a.state.inLink=!1,o}function Vr(l,t,e){let a=l.match(e.other.indentCodeCompensation);if(a===null)return t;let r=a[1];return t.split(`
1
+ var Xe=Object.defineProperty;var _t=(l,t,e)=>t in l?Xe(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var jt=(l,t)=>()=>(l&&(t=l(l=0)),t);var Wt=(l,t)=>{for(var e in t)Xe(l,e,{get:t[e],enumerable:!0})};var F=(l,t,e)=>_t(l,typeof t!="symbol"?t+"":t,e);var Ze={};Wt(Ze,{Hooks:()=>O,Lexer:()=>M,Marked:()=>Nt,Parser:()=>A,Renderer:()=>K,TextRenderer:()=>Ae,Tokenizer:()=>G,defaults:()=>R,getDefaults:()=>Fe,lexer:()=>Zr,marked:()=>C,options:()=>Br,parse:()=>Ur,parseInline:()=>Wr,parser:()=>Yr,setOptions:()=>Or,use:()=>_r,walkTokens:()=>jr});function Fe(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}function Ct(l){R=l}function S(l,t=""){let e=typeof l=="string"?l:l.source,a={replace:(r,s)=>{let i=typeof s=="string"?s:s.source;return i=i.replace(L.caret,"$1"),e=e.replace(r,i),a},getRegex:()=>new RegExp(e,t)};return a}function z(l,t){if(t){if(L.escapeTest.test(l))return l.replace(L.escapeReplace,kt)}else if(L.escapeTestNoEncode.test(l))return l.replace(L.escapeReplaceNoEncode,kt);return l}function wt(l){try{l=encodeURI(l).replace(L.percentDecode,"%")}catch{return null}return l}function Et(l,t){let e=l.replace(L.findPipe,(s,i,n)=>{let o=!1,d=i;for(;--d>=0&&n[d]==="\\";)o=!o;return o?"|":" |"}),a=e.split(L.splitPipe),r=0;if(a[0].trim()||a.shift(),a.length>0&&!a.at(-1)?.trim()&&a.pop(),t)if(a.length>t)a.splice(t);else for(;a.length<t;)a.push("");for(;r<a.length;r++)a[r]=a[r].trim().replace(L.slashPipe,"|");return a}function Z(l,t,e){let a=l.length;if(a===0)return"";let r=0;for(;r<a;){let s=l.charAt(a-r-1);if(s===t&&!e)r++;else if(s!==t&&e)r++;else break}return l.slice(0,a-r)}function Dr(l,t){if(l.indexOf(t[1])===-1)return-1;let e=0;for(let a=0;a<l.length;a++)if(l[a]==="\\")a++;else if(l[a]===t[0])e++;else if(l[a]===t[1]&&(e--,e<0))return a;return e>0?-2:-1}function Vr(l,t=0){let e=t,a="";for(let r of l)if(r===" "){let s=4-e%4;a+=" ".repeat(s),e+=s}else a+=r,e++;return a}function St(l,t,e,a,r){let s=t.href,i=t.title||null,n=l[1].replace(r.other.outputLinkReplace,"$1");a.state.inLink=!0;let o={type:l[0].charAt(0)==="!"?"image":"link",raw:e,href:s,title:i,text:n,tokens:a.inlineTokens(n)};return a.state.inLink=!1,o}function Hr(l,t,e){let a=l.match(e.other.indentCodeCompensation);if(a===null)return t;let r=a[1];return t.split(`
2
2
  `).map(s=>{let i=s.match(e.other.beginningSpace);if(i===null)return s;let[n]=i;return n.length>=r.length?s.slice(r.length):s}).join(`
3
- `)}function C(l,t){return N.parse(l,t)}var R,P,Jt,L,Xt,er,tr,Q,rr,He,Ct,Ft,ar,Be,sr,_e,ir,or,Le,Oe,nr,Tt,lr,je,yt,dr,cr,pr,mr,Lt,ur,Me,We,Mt,fr,zt,hr,gr,At,br,yr,vr,It,xr,kr,Rt,wr,Er,Sr,Cr,Fr,Tr,Lr,Mr,zr,Ar,Fe,Ir,$t,qt,Rr,vt,Ue,$r,Ne,qr,Se,Y,Pr,xt,G,M,K,ze,z,Ce,_,Pt,N,Hr,Br,_r,Or,jr,Wr,Ur,Yr,Ze=Ot(()=>{"use strict";R=Te();P={exec:()=>null};Jt=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),L={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:l=>new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}#`),htmlBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}>`)},Xt=/^(?:[ \t]*(?:\n|$))+/,er=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,tr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Q=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,rr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,He=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ct=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ft=S(Ct).replace(/bull/g,He).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),ar=S(Ct).replace(/bull/g,He).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Be=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,sr=/^[^\n]+/,_e=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ir=S(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",_e).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),or=S(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,He).getRegex(),Le="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Oe=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,nr=S("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Oe).replace("tag",Le).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Tt=S(Be).replace("hr",Q).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Le).getRegex(),lr=S(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Tt).getRegex(),je={blockquote:lr,code:er,def:ir,fences:tr,heading:rr,hr:Q,html:nr,lheading:Ft,list:or,newline:Xt,paragraph:Tt,table:P,text:sr},yt=S("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Q).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Le).getRegex(),dr={...je,lheading:ar,table:yt,paragraph:S(Be).replace("hr",Q).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",yt).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Le).getRegex()},cr={...je,html:S(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Oe).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:P,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:S(Be).replace("hr",Q).replace("heading",` *#{1,6} *[^
4
- ]`).replace("lheading",Ft).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},pr=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,mr=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Lt=/^( {2,}|\\)\n(?!\s*$)/,ur=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Me=/[\p{P}\p{S}]/u,We=/[\s\p{P}\p{S}]/u,Mt=/[^\s\p{P}\p{S}]/u,fr=S(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,We).getRegex(),zt=/(?!~)[\p{P}\p{S}]/u,hr=/(?!~)[\s\p{P}\p{S}]/u,gr=/(?:[^\s\p{P}\p{S}]|~)/u,At=/(?![*_])[\p{P}\p{S}]/u,br=/(?![*_])[\s\p{P}\p{S}]/u,yr=/(?:[^\s\p{P}\p{S}]|[*_])/u,vr=S(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Jt?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),It=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,xr=S(It,"u").replace(/punct/g,Me).getRegex(),kr=S(It,"u").replace(/punct/g,zt).getRegex(),Rt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",wr=S(Rt,"gu").replace(/notPunctSpace/g,Mt).replace(/punctSpace/g,We).replace(/punct/g,Me).getRegex(),Er=S(Rt,"gu").replace(/notPunctSpace/g,gr).replace(/punctSpace/g,hr).replace(/punct/g,zt).getRegex(),Sr=S("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Mt).replace(/punctSpace/g,We).replace(/punct/g,Me).getRegex(),Cr=S(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,At).getRegex(),Fr="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Tr=S(Fr,"gu").replace(/notPunctSpace/g,yr).replace(/punctSpace/g,br).replace(/punct/g,At).getRegex(),Lr=S(/\\(punct)/,"gu").replace(/punct/g,Me).getRegex(),Mr=S(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),zr=S(Oe).replace("(?:-->|$)","-->").getRegex(),Ar=S("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",zr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Fe=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Ir=S(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Fe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),$t=S(/^!?\[(label)\]\[(ref)\]/).replace("label",Fe).replace("ref",_e).getRegex(),qt=S(/^!?\[(ref)\](?:\[\])?/).replace("ref",_e).getRegex(),Rr=S("reflink|nolink(?!\\()","g").replace("reflink",$t).replace("nolink",qt).getRegex(),vt=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ue={_backpedal:P,anyPunctuation:Lr,autolink:Mr,blockSkip:vr,br:Lt,code:mr,del:P,delLDelim:P,delRDelim:P,emStrongLDelim:xr,emStrongRDelimAst:wr,emStrongRDelimUnd:Sr,escape:pr,link:Ir,nolink:qt,punctuation:fr,reflink:$t,reflinkSearch:Rr,tag:Ar,text:ur,url:P},$r={...Ue,link:S(/^!?\[(label)\]\((.*?)\)/).replace("label",Fe).getRegex(),reflink:S(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Fe).getRegex()},Ne={...Ue,emStrongRDelimAst:Er,emStrongLDelim:kr,delLDelim:Cr,delRDelim:Tr,url:S(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",vt).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:S(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",vt).getRegex()},qr={...Ne,br:S(Lt).replace("{2,}","*").getRegex(),text:S(Ne.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Se={normal:je,gfm:dr,pedantic:cr},Y={normal:Ue,gfm:Ne,breaks:qr,pedantic:$r},Pr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},xt=l=>Pr[l];G=class{constructor(l){T(this,"options");T(this,"rules");T(this,"lexer");this.options=l||R}space(l){let t=this.rules.block.newline.exec(l);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(l){let t=this.rules.block.code.exec(l);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Z(e,`
5
- `)}}}fences(l){let t=this.rules.block.fences.exec(l);if(t){let e=t[0],a=Vr(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:a}}}heading(l){let t=this.rules.block.heading.exec(l);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let a=Z(e,"#");(this.options.pedantic||!a||this.rules.other.endingSpaceChar.test(a))&&(e=a.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(l){let t=this.rules.block.hr.exec(l);if(t)return{type:"hr",raw:Z(t[0],`
3
+ `)}function C(l,t){return N.parse(l,t)}var R,P,Xt,L,er,tr,rr,Q,ar,Be,Tt,Ft,sr,Oe,ir,_e,or,nr,Le,je,lr,Lt,dr,We,vt,cr,pr,mr,ur,Mt,fr,Me,Ue,At,hr,zt,gr,br,It,yr,vr,xr,Rt,kr,wr,$t,Er,Sr,Cr,Tr,Fr,Lr,Mr,Ar,zr,Ir,Te,Rr,qt,Pt,$r,xt,Ye,qr,De,Pr,Se,Y,Nr,kt,G,M,K,Ae,A,Ce,O,Nt,N,Br,Or,_r,jr,Wr,Ur,Yr,Zr,Ge=jt(()=>{"use strict";R=Fe();P={exec:()=>null};Xt=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),L={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:l=>new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}#`),htmlBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}>`)},er=/^(?:[ \t]*(?:\n|$))+/,tr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,rr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Q=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ar=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Be=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Tt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ft=S(Tt).replace(/bull/g,Be).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),sr=S(Tt).replace(/bull/g,Be).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Oe=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ir=/^[^\n]+/,_e=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,or=S(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",_e).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),nr=S(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Be).getRegex(),Le="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",je=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,lr=S("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",je).replace("tag",Le).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Lt=S(Oe).replace("hr",Q).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Le).getRegex(),dr=S(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Lt).getRegex(),We={blockquote:dr,code:tr,def:or,fences:rr,heading:ar,hr:Q,html:lr,lheading:Ft,list:nr,newline:er,paragraph:Lt,table:P,text:ir},vt=S("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Q).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Le).getRegex(),cr={...We,lheading:sr,table:vt,paragraph:S(Oe).replace("hr",Q).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",vt).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Le).getRegex()},pr={...We,html:S(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",je).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:P,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:S(Oe).replace("hr",Q).replace("heading",` *#{1,6} *[^
4
+ ]`).replace("lheading",Ft).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},mr=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ur=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Mt=/^( {2,}|\\)\n(?!\s*$)/,fr=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Me=/[\p{P}\p{S}]/u,Ue=/[\s\p{P}\p{S}]/u,At=/[^\s\p{P}\p{S}]/u,hr=S(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ue).getRegex(),zt=/(?!~)[\p{P}\p{S}]/u,gr=/(?!~)[\s\p{P}\p{S}]/u,br=/(?:[^\s\p{P}\p{S}]|~)/u,It=/(?![*_])[\p{P}\p{S}]/u,yr=/(?![*_])[\s\p{P}\p{S}]/u,vr=/(?:[^\s\p{P}\p{S}]|[*_])/u,xr=S(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Xt?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Rt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,kr=S(Rt,"u").replace(/punct/g,Me).getRegex(),wr=S(Rt,"u").replace(/punct/g,zt).getRegex(),$t="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Er=S($t,"gu").replace(/notPunctSpace/g,At).replace(/punctSpace/g,Ue).replace(/punct/g,Me).getRegex(),Sr=S($t,"gu").replace(/notPunctSpace/g,br).replace(/punctSpace/g,gr).replace(/punct/g,zt).getRegex(),Cr=S("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,At).replace(/punctSpace/g,Ue).replace(/punct/g,Me).getRegex(),Tr=S(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,It).getRegex(),Fr="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Lr=S(Fr,"gu").replace(/notPunctSpace/g,vr).replace(/punctSpace/g,yr).replace(/punct/g,It).getRegex(),Mr=S(/\\(punct)/,"gu").replace(/punct/g,Me).getRegex(),Ar=S(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),zr=S(je).replace("(?:-->|$)","-->").getRegex(),Ir=S("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",zr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Te=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Rr=S(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Te).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),qt=S(/^!?\[(label)\]\[(ref)\]/).replace("label",Te).replace("ref",_e).getRegex(),Pt=S(/^!?\[(ref)\](?:\[\])?/).replace("ref",_e).getRegex(),$r=S("reflink|nolink(?!\\()","g").replace("reflink",qt).replace("nolink",Pt).getRegex(),xt=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ye={_backpedal:P,anyPunctuation:Mr,autolink:Ar,blockSkip:xr,br:Mt,code:ur,del:P,delLDelim:P,delRDelim:P,emStrongLDelim:kr,emStrongRDelimAst:Er,emStrongRDelimUnd:Cr,escape:mr,link:Rr,nolink:Pt,punctuation:hr,reflink:qt,reflinkSearch:$r,tag:Ir,text:fr,url:P},qr={...Ye,link:S(/^!?\[(label)\]\((.*?)\)/).replace("label",Te).getRegex(),reflink:S(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Te).getRegex()},De={...Ye,emStrongRDelimAst:Sr,emStrongLDelim:wr,delLDelim:Tr,delRDelim:Lr,url:S(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",xt).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:S(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",xt).getRegex()},Pr={...De,br:S(Mt).replace("{2,}","*").getRegex(),text:S(De.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Se={normal:We,gfm:cr,pedantic:pr},Y={normal:Ye,gfm:De,breaks:Pr,pedantic:qr},Nr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},kt=l=>Nr[l];G=class{constructor(l){F(this,"options");F(this,"rules");F(this,"lexer");this.options=l||R}space(l){let t=this.rules.block.newline.exec(l);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(l){let t=this.rules.block.code.exec(l);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Z(e,`
5
+ `)}}}fences(l){let t=this.rules.block.fences.exec(l);if(t){let e=t[0],a=Hr(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:a}}}heading(l){let t=this.rules.block.heading.exec(l);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let a=Z(e,"#");(this.options.pedantic||!a||this.rules.other.endingSpaceChar.test(a))&&(e=a.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(l){let t=this.rules.block.hr.exec(l);if(t)return{type:"hr",raw:Z(t[0],`
6
6
  `)}}blockquote(l){let t=this.rules.block.blockquote.exec(l);if(t){let e=Z(t[0],`
7
7
  `).split(`
8
8
  `),a="",r="",s=[];for(;e.length>0;){let i=!1,n=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))n.push(e[o]),i=!0;else if(!i)n.push(e[o]);else break;e=e.slice(o);let d=n.join(`
@@ -14,16 +14,16 @@ ${c}`:c;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
14
14
  `),g=this.blockquote(h);s[s.length-1]=g,a=a.substring(0,a.length-u.raw.length)+g.raw,r=r.substring(0,r.length-u.text.length)+g.text;break}else if(p?.type==="list"){let u=p,h=u.raw+`
15
15
  `+e.join(`
16
16
  `),g=this.list(h);s[s.length-1]=g,a=a.substring(0,a.length-p.raw.length)+g.raw,r=r.substring(0,r.length-u.raw.length)+g.raw,e=h.substring(s.at(-1).raw.length).split(`
17
- `);continue}}return{type:"blockquote",raw:a,tokens:s,text:r}}}list(l){let t=this.rules.block.list.exec(l);if(t){let e=t[1].trim(),a=e.length>1,r={type:"list",raw:"",ordered:a,start:a?+e.slice(0,-1):"",loose:!1,items:[]};e=a?`\\d{1,9}\\${e.slice(-1)}`:`\\${e}`,this.options.pedantic&&(e=a?e:"[*+-]");let s=this.rules.other.listItemRegex(e),i=!1;for(;l;){let o=!1,d="",c="";if(!(t=s.exec(l))||this.rules.block.hr.test(l))break;d=t[0],l=l.substring(d.length);let m=Dr(t[2].split(`
17
+ `);continue}}return{type:"blockquote",raw:a,tokens:s,text:r}}}list(l){let t=this.rules.block.list.exec(l);if(t){let e=t[1].trim(),a=e.length>1,r={type:"list",raw:"",ordered:a,start:a?+e.slice(0,-1):"",loose:!1,items:[]};e=a?`\\d{1,9}\\${e.slice(-1)}`:`\\${e}`,this.options.pedantic&&(e=a?e:"[*+-]");let s=this.rules.other.listItemRegex(e),i=!1;for(;l;){let o=!1,d="",c="";if(!(t=s.exec(l))||this.rules.block.hr.test(l))break;d=t[0],l=l.substring(d.length);let m=Vr(t[2].split(`
18
18
  `,1)[0],t[1].length),p=l.split(`
19
19
  `,1)[0],u=!m.trim(),h=0;if(this.options.pedantic?(h=2,c=m.trimStart()):u?h=t[1].length+1:(h=m.search(this.rules.other.nonSpaceChar),h=h>4?1:h,c=m.slice(h),h+=t[1].length),u&&this.rules.other.blankLine.test(p)&&(d+=p+`
20
20
  `,l=l.substring(p.length+1),o=!0),!o){let g=this.rules.other.nextBulletRegex(h),f=this.rules.other.hrRegex(h),y=this.rules.other.fencesBeginRegex(h),v=this.rules.other.headingBeginRegex(h),b=this.rules.other.htmlBeginRegex(h),w=this.rules.other.blockquoteBeginRegex(h);for(;l;){let E=l.split(`
21
21
  `,1)[0],k;if(p=E,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),k=p):k=p.replace(this.rules.other.tabCharGlobal," "),y.test(p)||v.test(p)||b.test(p)||w.test(p)||g.test(p)||f.test(p))break;if(k.search(this.rules.other.nonSpaceChar)>=h||!p.trim())c+=`
22
22
  `+k.slice(h);else{if(u||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(m)||v.test(m)||f.test(m))break;c+=`
23
23
  `+p}u=!p.trim(),d+=E+`
24
- `,l=l.substring(E.length+1),m=k.slice(h)}}r.loose||(i?r.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(i=!0)),r.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),r.raw+=d}let n=r.items.at(-1);if(n)n.raw=n.raw.trimEnd(),n.text=n.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let o of r.items){if(this.lexer.state.top=!1,o.tokens=this.lexer.blockTokens(o.text,[]),o.task){if(o.text=o.text.replace(this.rules.other.listReplaceTask,""),o.tokens[0]?.type==="text"||o.tokens[0]?.type==="paragraph"){o.tokens[0].raw=o.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),o.tokens[0].text=o.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let c=this.lexer.inlineQueue.length-1;c>=0;c--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[c].src)){this.lexer.inlineQueue[c].src=this.lexer.inlineQueue[c].src.replace(this.rules.other.listReplaceTask,"");break}}let d=this.rules.other.listTaskCheckbox.exec(o.raw);if(d){let c={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};o.checked=c.checked,r.loose?o.tokens[0]&&["paragraph","text"].includes(o.tokens[0].type)&&"tokens"in o.tokens[0]&&o.tokens[0].tokens?(o.tokens[0].raw=c.raw+o.tokens[0].raw,o.tokens[0].text=c.raw+o.tokens[0].text,o.tokens[0].tokens.unshift(c)):o.tokens.unshift({type:"paragraph",raw:c.raw,text:c.raw,tokens:[c]}):o.tokens.unshift(c)}}if(!r.loose){let d=o.tokens.filter(m=>m.type==="space"),c=d.length>0&&d.some(m=>this.rules.other.anyLine.test(m.raw));r.loose=c}}if(r.loose)for(let o of r.items){o.loose=!0;for(let d of o.tokens)d.type==="text"&&(d.type="paragraph")}return r}}html(l){let t=this.rules.block.html.exec(l);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(l){let t=this.rules.block.def.exec(l);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),a=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:a,title:r}}}table(l){let t=this.rules.block.table.exec(l);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let e=wt(t[1]),a=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
- `):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(e.length===a.length){for(let i of a)this.rules.other.tableAlignRight.test(i)?s.align.push("right"):this.rules.other.tableAlignCenter.test(i)?s.align.push("center"):this.rules.other.tableAlignLeft.test(i)?s.align.push("left"):s.align.push(null);for(let i=0;i<e.length;i++)s.header.push({text:e[i],tokens:this.lexer.inline(e[i]),header:!0,align:s.align[i]});for(let i of r)s.rows.push(wt(i,s.header.length).map((n,o)=>({text:n,tokens:this.lexer.inline(n),header:!1,align:s.align[o]})));return s}}lheading(l){let t=this.rules.block.lheading.exec(l);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(l){let t=this.rules.block.paragraph.exec(l);if(t){let e=t[1].charAt(t[1].length-1)===`
26
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(l){let t=this.rules.block.text.exec(l);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(l){let t=this.rules.inline.escape.exec(l);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(l){let t=this.rules.inline.tag.exec(l);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(l){let t=this.rules.inline.link.exec(l);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let s=Z(e.slice(0,-1),"\\");if((e.length-s.length)%2===0)return}else{let s=Nr(t[2],"()");if(s===-2)return;if(s>-1){let i=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,i).trim(),t[3]=""}}let a=t[2],r="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(a);s&&(a=s[1],r=s[3])}else r=t[3]?t[3].slice(1,-1):"";return a=a.trim(),this.rules.other.startAngleBracket.test(a)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?a=a.slice(1):a=a.slice(1,-1)),Et(t,{href:a&&a.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(l,t){let e;if((e=this.rules.inline.reflink.exec(l))||(e=this.rules.inline.nolink.exec(l))){let a=(e[2]||e[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[a.toLowerCase()];if(!r){let s=e[0].charAt(0);return{type:"text",raw:s,text:s}}return Et(e,r,e[0],this.lexer,this.rules)}}emStrong(l,t,e=""){let a=this.rules.inline.emStrongLDelim.exec(l);if(!(!a||a[3]&&e.match(this.rules.other.unicodeAlphaNumeric))&&(!(a[1]||a[2])||!e||this.rules.inline.punctuation.exec(e))){let r=[...a[0]].length-1,s,i,n=r,o=0,d=a[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*l.length+r);(a=d.exec(t))!=null;){if(s=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!s)continue;if(i=[...s].length,a[3]||a[4]){n+=i;continue}else if((a[5]||a[6])&&r%3&&!((r+i)%3)){o+=i;continue}if(n-=i,n>0)continue;i=Math.min(i,i+n+o);let c=[...a[0]][0].length,m=l.slice(0,r+a.index+c+i);if(Math.min(r,i)%2){let u=m.slice(1,-1);return{type:"em",raw:m,text:u,tokens:this.lexer.inlineTokens(u)}}let p=m.slice(2,-2);return{type:"strong",raw:m,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(l){let t=this.rules.inline.code.exec(l);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),a=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return a&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(l){let t=this.rules.inline.br.exec(l);if(t)return{type:"br",raw:t[0]}}del(l,t,e=""){let a=this.rules.inline.delLDelim.exec(l);if(a&&(!a[1]||!e||this.rules.inline.punctuation.exec(e))){let r=[...a[0]].length-1,s,i,n=r,o=this.rules.inline.delRDelim;for(o.lastIndex=0,t=t.slice(-1*l.length+r);(a=o.exec(t))!=null;){if(s=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!s||(i=[...s].length,i!==r))continue;if(a[3]||a[4]){n+=i;continue}if(n-=i,n>0)continue;i=Math.min(i,i+n);let d=[...a[0]][0].length,c=l.slice(0,r+a.index+d+i),m=c.slice(r,-r);return{type:"del",raw:c,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(l){let t=this.rules.inline.autolink.exec(l);if(t){let e,a;return t[2]==="@"?(e=t[1],a="mailto:"+e):(e=t[1],a=e),{type:"link",raw:t[0],text:e,href:a,tokens:[{type:"text",raw:e,text:e}]}}}url(l){let t;if(t=this.rules.inline.url.exec(l)){let e,a;if(t[2]==="@")e=t[0],a="mailto:"+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(r!==t[0]);e=t[0],t[1]==="www."?a="http://"+t[0]:a=t[0]}return{type:"link",raw:t[0],text:e,href:a,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(l){let t=this.rules.inline.text.exec(l);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},M=class De{constructor(t){T(this,"tokens");T(this,"options");T(this,"state");T(this,"inlineQueue");T(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||R,this.options.tokenizer=this.options.tokenizer||new G,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let e={other:L,block:Se.normal,inline:Y.normal};this.options.pedantic?(e.block=Se.pedantic,e.inline=Y.pedantic):this.options.gfm&&(e.block=Se.gfm,this.options.breaks?e.inline=Y.breaks:e.inline=Y.gfm),this.tokenizer.rules=e}static get rules(){return{block:Se,inline:Y}}static lex(t,e){return new De(e).lex(t)}static lexInline(t,e){return new De(e).inlineTokens(t)}lex(t){t=t.replace(L.carriageReturn,`
24
+ `,l=l.substring(E.length+1),m=k.slice(h)}}r.loose||(i?r.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(i=!0)),r.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),r.raw+=d}let n=r.items.at(-1);if(n)n.raw=n.raw.trimEnd(),n.text=n.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let o of r.items){if(this.lexer.state.top=!1,o.tokens=this.lexer.blockTokens(o.text,[]),o.task){if(o.text=o.text.replace(this.rules.other.listReplaceTask,""),o.tokens[0]?.type==="text"||o.tokens[0]?.type==="paragraph"){o.tokens[0].raw=o.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),o.tokens[0].text=o.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let c=this.lexer.inlineQueue.length-1;c>=0;c--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[c].src)){this.lexer.inlineQueue[c].src=this.lexer.inlineQueue[c].src.replace(this.rules.other.listReplaceTask,"");break}}let d=this.rules.other.listTaskCheckbox.exec(o.raw);if(d){let c={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};o.checked=c.checked,r.loose?o.tokens[0]&&["paragraph","text"].includes(o.tokens[0].type)&&"tokens"in o.tokens[0]&&o.tokens[0].tokens?(o.tokens[0].raw=c.raw+o.tokens[0].raw,o.tokens[0].text=c.raw+o.tokens[0].text,o.tokens[0].tokens.unshift(c)):o.tokens.unshift({type:"paragraph",raw:c.raw,text:c.raw,tokens:[c]}):o.tokens.unshift(c)}}if(!r.loose){let d=o.tokens.filter(m=>m.type==="space"),c=d.length>0&&d.some(m=>this.rules.other.anyLine.test(m.raw));r.loose=c}}if(r.loose)for(let o of r.items){o.loose=!0;for(let d of o.tokens)d.type==="text"&&(d.type="paragraph")}return r}}html(l){let t=this.rules.block.html.exec(l);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(l){let t=this.rules.block.def.exec(l);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),a=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:a,title:r}}}table(l){let t=this.rules.block.table.exec(l);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let e=Et(t[1]),a=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
+ `):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(e.length===a.length){for(let i of a)this.rules.other.tableAlignRight.test(i)?s.align.push("right"):this.rules.other.tableAlignCenter.test(i)?s.align.push("center"):this.rules.other.tableAlignLeft.test(i)?s.align.push("left"):s.align.push(null);for(let i=0;i<e.length;i++)s.header.push({text:e[i],tokens:this.lexer.inline(e[i]),header:!0,align:s.align[i]});for(let i of r)s.rows.push(Et(i,s.header.length).map((n,o)=>({text:n,tokens:this.lexer.inline(n),header:!1,align:s.align[o]})));return s}}lheading(l){let t=this.rules.block.lheading.exec(l);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(l){let t=this.rules.block.paragraph.exec(l);if(t){let e=t[1].charAt(t[1].length-1)===`
26
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(l){let t=this.rules.block.text.exec(l);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(l){let t=this.rules.inline.escape.exec(l);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(l){let t=this.rules.inline.tag.exec(l);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(l){let t=this.rules.inline.link.exec(l);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let s=Z(e.slice(0,-1),"\\");if((e.length-s.length)%2===0)return}else{let s=Dr(t[2],"()");if(s===-2)return;if(s>-1){let i=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,i).trim(),t[3]=""}}let a=t[2],r="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(a);s&&(a=s[1],r=s[3])}else r=t[3]?t[3].slice(1,-1):"";return a=a.trim(),this.rules.other.startAngleBracket.test(a)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?a=a.slice(1):a=a.slice(1,-1)),St(t,{href:a&&a.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(l,t){let e;if((e=this.rules.inline.reflink.exec(l))||(e=this.rules.inline.nolink.exec(l))){let a=(e[2]||e[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[a.toLowerCase()];if(!r){let s=e[0].charAt(0);return{type:"text",raw:s,text:s}}return St(e,r,e[0],this.lexer,this.rules)}}emStrong(l,t,e=""){let a=this.rules.inline.emStrongLDelim.exec(l);if(!(!a||a[3]&&e.match(this.rules.other.unicodeAlphaNumeric))&&(!(a[1]||a[2])||!e||this.rules.inline.punctuation.exec(e))){let r=[...a[0]].length-1,s,i,n=r,o=0,d=a[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*l.length+r);(a=d.exec(t))!=null;){if(s=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!s)continue;if(i=[...s].length,a[3]||a[4]){n+=i;continue}else if((a[5]||a[6])&&r%3&&!((r+i)%3)){o+=i;continue}if(n-=i,n>0)continue;i=Math.min(i,i+n+o);let c=[...a[0]][0].length,m=l.slice(0,r+a.index+c+i);if(Math.min(r,i)%2){let u=m.slice(1,-1);return{type:"em",raw:m,text:u,tokens:this.lexer.inlineTokens(u)}}let p=m.slice(2,-2);return{type:"strong",raw:m,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(l){let t=this.rules.inline.code.exec(l);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),a=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return a&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(l){let t=this.rules.inline.br.exec(l);if(t)return{type:"br",raw:t[0]}}del(l,t,e=""){let a=this.rules.inline.delLDelim.exec(l);if(a&&(!a[1]||!e||this.rules.inline.punctuation.exec(e))){let r=[...a[0]].length-1,s,i,n=r,o=this.rules.inline.delRDelim;for(o.lastIndex=0,t=t.slice(-1*l.length+r);(a=o.exec(t))!=null;){if(s=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!s||(i=[...s].length,i!==r))continue;if(a[3]||a[4]){n+=i;continue}if(n-=i,n>0)continue;i=Math.min(i,i+n);let d=[...a[0]][0].length,c=l.slice(0,r+a.index+d+i),m=c.slice(r,-r);return{type:"del",raw:c,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(l){let t=this.rules.inline.autolink.exec(l);if(t){let e,a;return t[2]==="@"?(e=t[1],a="mailto:"+e):(e=t[1],a=e),{type:"link",raw:t[0],text:e,href:a,tokens:[{type:"text",raw:e,text:e}]}}}url(l){let t;if(t=this.rules.inline.url.exec(l)){let e,a;if(t[2]==="@")e=t[0],a="mailto:"+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(r!==t[0]);e=t[0],t[1]==="www."?a="http://"+t[0]:a=t[0]}return{type:"link",raw:t[0],text:e,href:a,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(l){let t=this.rules.inline.text.exec(l);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},M=class Ve{constructor(t){F(this,"tokens");F(this,"options");F(this,"state");F(this,"inlineQueue");F(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||R,this.options.tokenizer=this.options.tokenizer||new G,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let e={other:L,block:Se.normal,inline:Y.normal};this.options.pedantic?(e.block=Se.pedantic,e.inline=Y.pedantic):this.options.gfm&&(e.block=Se.gfm,this.options.breaks?e.inline=Y.breaks:e.inline=Y.gfm),this.tokenizer.rules=e}static get rules(){return{block:Se,inline:Y}}static lex(t,e){return new Ve(e).lex(t)}static lexInline(t,e){return new Ve(e).inlineTokens(t)}lex(t){t=t.replace(L.carriageReturn,`
27
27
  `),this.blockTokens(t,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let a=this.inlineQueue[e];this.inlineTokens(a.src,a.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],a=!1){for(this.options.pedantic&&(t=t.replace(L.tabCharGlobal," ").replace(L.spaceLine,""));t;){let r;if(this.options.extensions?.block?.some(i=>(r=i.call({lexer:this},t,e))?(t=t.substring(r.raw.length),e.push(r),!0):!1))continue;if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length);let i=e.at(-1);r.raw.length===1&&i!==void 0?i.raw+=`
28
28
  `:e.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length);let i=e.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(`
29
29
  `)?"":`
@@ -37,9 +37,9 @@ ${c}`:c;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
37
37
  `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):e.push(r),a=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length);let i=e.at(-1);i?.type==="text"?(i.raw+=(i.raw.endsWith(`
38
38
  `)?"":`
39
39
  `)+r.raw,i.text+=`
40
- `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):e.push(r);continue}if(t){let i="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){let a=t,r=null;if(this.tokens.links){let o=Object.keys(this.tokens.links);if(o.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)o.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,r.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)s=r[2]?r[2].length:0,a=a.slice(0,r.index+s)+"["+"a".repeat(r[0].length-s-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);a=this.options.hooks?.emStrongMask?.call({lexer:this},a)??a;let i=!1,n="";for(;t;){i||(n=""),i=!1;let o;if(this.options.extensions?.inline?.some(c=>(o=c.call({lexer:this},t,e))?(t=t.substring(o.raw.length),e.push(o),!0):!1))continue;if(o=this.tokenizer.escape(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.tag(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.link(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(o.raw.length);let c=e.at(-1);o.type==="text"&&c?.type==="text"?(c.raw+=o.raw,c.text+=o.text):e.push(o);continue}if(o=this.tokenizer.emStrong(t,a,n)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.codespan(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.br(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.del(t,a,n)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.autolink(t)){t=t.substring(o.raw.length),e.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(t))){t=t.substring(o.raw.length),e.push(o);continue}let d=t;if(this.options.extensions?.startInline){let c=1/0,m=t.slice(1),p;this.options.extensions.startInline.forEach(u=>{p=u.call({lexer:this},m),typeof p=="number"&&p>=0&&(c=Math.min(c,p))}),c<1/0&&c>=0&&(d=t.substring(0,c+1))}if(o=this.tokenizer.inlineText(d)){t=t.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(n=o.raw.slice(-1)),i=!0;let c=e.at(-1);c?.type==="text"?(c.raw+=o.raw,c.text+=o.text):e.push(o);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return e}},K=class{constructor(l){T(this,"options");T(this,"parser");this.options=l||R}space(l){return""}code({text:l,lang:t,escaped:e}){let a=(t||"").match(L.notSpaceStart)?.[0],r=l.replace(L.endingNewline,"")+`
41
- `;return a?'<pre><code class="language-'+A(a)+'">'+(e?r:A(r,!0))+`</code></pre>
42
- `:"<pre><code>"+(e?r:A(r,!0))+`</code></pre>
40
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):e.push(r);continue}if(t){let i="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){let a=t,r=null;if(this.tokens.links){let o=Object.keys(this.tokens.links);if(o.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)o.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,r.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)s=r[2]?r[2].length:0,a=a.slice(0,r.index+s)+"["+"a".repeat(r[0].length-s-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);a=this.options.hooks?.emStrongMask?.call({lexer:this},a)??a;let i=!1,n="";for(;t;){i||(n=""),i=!1;let o;if(this.options.extensions?.inline?.some(c=>(o=c.call({lexer:this},t,e))?(t=t.substring(o.raw.length),e.push(o),!0):!1))continue;if(o=this.tokenizer.escape(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.tag(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.link(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(o.raw.length);let c=e.at(-1);o.type==="text"&&c?.type==="text"?(c.raw+=o.raw,c.text+=o.text):e.push(o);continue}if(o=this.tokenizer.emStrong(t,a,n)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.codespan(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.br(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.del(t,a,n)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.autolink(t)){t=t.substring(o.raw.length),e.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(t))){t=t.substring(o.raw.length),e.push(o);continue}let d=t;if(this.options.extensions?.startInline){let c=1/0,m=t.slice(1),p;this.options.extensions.startInline.forEach(u=>{p=u.call({lexer:this},m),typeof p=="number"&&p>=0&&(c=Math.min(c,p))}),c<1/0&&c>=0&&(d=t.substring(0,c+1))}if(o=this.tokenizer.inlineText(d)){t=t.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(n=o.raw.slice(-1)),i=!0;let c=e.at(-1);c?.type==="text"?(c.raw+=o.raw,c.text+=o.text):e.push(o);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return e}},K=class{constructor(l){F(this,"options");F(this,"parser");this.options=l||R}space(l){return""}code({text:l,lang:t,escaped:e}){let a=(t||"").match(L.notSpaceStart)?.[0],r=l.replace(L.endingNewline,"")+`
41
+ `;return a?'<pre><code class="language-'+z(a)+'">'+(e?r:z(r,!0))+`</code></pre>
42
+ `:"<pre><code>"+(e?r:z(r,!0))+`</code></pre>
43
43
  `}blockquote({tokens:l}){return`<blockquote>
44
44
  ${this.parser.parse(l)}</blockquote>
45
45
  `}html({text:l}){return l}def(l){return""}heading({tokens:l,depth:t}){return`<h${t}>${this.parser.parseInline(l)}</h${t}>
@@ -55,12 +55,12 @@ ${this.parser.parse(l)}</blockquote>
55
55
  `}tablerow({text:l}){return`<tr>
56
56
  ${l}</tr>
57
57
  `}tablecell(l){let t=this.parser.parseInline(l.tokens),e=l.header?"th":"td";return(l.align?`<${e} align="${l.align}">`:`<${e}>`)+t+`</${e}>
58
- `}strong({tokens:l}){return`<strong>${this.parser.parseInline(l)}</strong>`}em({tokens:l}){return`<em>${this.parser.parseInline(l)}</em>`}codespan({text:l}){return`<code>${A(l,!0)}</code>`}br(l){return"<br>"}del({tokens:l}){return`<del>${this.parser.parseInline(l)}</del>`}link({href:l,title:t,tokens:e}){let a=this.parser.parseInline(e),r=kt(l);if(r===null)return a;l=r;let s='<a href="'+l+'"';return t&&(s+=' title="'+A(t)+'"'),s+=">"+a+"</a>",s}image({href:l,title:t,text:e,tokens:a}){a&&(e=this.parser.parseInline(a,this.parser.textRenderer));let r=kt(l);if(r===null)return A(e);l=r;let s=`<img src="${l}" alt="${A(e)}"`;return t&&(s+=` title="${A(t)}"`),s+=">",s}text(l){return"tokens"in l&&l.tokens?this.parser.parseInline(l.tokens):"escaped"in l&&l.escaped?l.text:A(l.text)}},ze=class{strong({text:l}){return l}em({text:l}){return l}codespan({text:l}){return l}del({text:l}){return l}html({text:l}){return l}text({text:l}){return l}link({text:l}){return""+l}image({text:l}){return""+l}br(){return""}checkbox({raw:l}){return l}},z=class Ve{constructor(t){T(this,"options");T(this,"renderer");T(this,"textRenderer");this.options=t||R,this.options.renderer=this.options.renderer||new K,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ze}static parse(t,e){return new Ve(e).parse(t)}static parseInline(t,e){return new Ve(e).parseInline(t)}parse(t){let e="";for(let a=0;a<t.length;a++){let r=t[a];if(this.options.extensions?.renderers?.[r.type]){let i=r,n=this.options.extensions.renderers[i.type].call({parser:this},i);if(n!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){e+=n||"";continue}}let s=r;switch(s.type){case"space":{e+=this.renderer.space(s);break}case"hr":{e+=this.renderer.hr(s);break}case"heading":{e+=this.renderer.heading(s);break}case"code":{e+=this.renderer.code(s);break}case"table":{e+=this.renderer.table(s);break}case"blockquote":{e+=this.renderer.blockquote(s);break}case"list":{e+=this.renderer.list(s);break}case"checkbox":{e+=this.renderer.checkbox(s);break}case"html":{e+=this.renderer.html(s);break}case"def":{e+=this.renderer.def(s);break}case"paragraph":{e+=this.renderer.paragraph(s);break}case"text":{e+=this.renderer.text(s);break}default:{let i='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return e}parseInline(t,e=this.renderer){let a="";for(let r=0;r<t.length;r++){let s=t[r];if(this.options.extensions?.renderers?.[s.type]){let n=this.options.extensions.renderers[s.type].call({parser:this},s);if(n!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){a+=n||"";continue}}let i=s;switch(i.type){case"escape":{a+=e.text(i);break}case"html":{a+=e.html(i);break}case"link":{a+=e.link(i);break}case"image":{a+=e.image(i);break}case"checkbox":{a+=e.checkbox(i);break}case"strong":{a+=e.strong(i);break}case"em":{a+=e.em(i);break}case"codespan":{a+=e.codespan(i);break}case"br":{a+=e.br(i);break}case"del":{a+=e.del(i);break}case"text":{a+=e.text(i);break}default:{let n='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(n),"";throw new Error(n)}}}return a}},_=(Ce=class{constructor(l){T(this,"options");T(this,"block");this.options=l||R}preprocess(l){return l}postprocess(l){return l}processAllTokens(l){return l}emStrongMask(l){return l}provideLexer(){return this.block?M.lex:M.lexInline}provideParser(){return this.block?z.parse:z.parseInline}},T(Ce,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),T(Ce,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Ce),Pt=class{constructor(...l){T(this,"defaults",Te());T(this,"options",this.setOptions);T(this,"parse",this.parseMarkdown(!0));T(this,"parseInline",this.parseMarkdown(!1));T(this,"Parser",z);T(this,"Renderer",K);T(this,"TextRenderer",ze);T(this,"Lexer",M);T(this,"Tokenizer",G);T(this,"Hooks",_);this.use(...l)}walkTokens(l,t){let e=[];for(let a of l)switch(e=e.concat(t.call(this,a)),a.type){case"table":{let r=a;for(let s of r.header)e=e.concat(this.walkTokens(s.tokens,t));for(let s of r.rows)for(let i of s)e=e.concat(this.walkTokens(i.tokens,t));break}case"list":{let r=a;e=e.concat(this.walkTokens(r.items,t));break}default:{let r=a;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(s=>{let i=r[s].flat(1/0);e=e.concat(this.walkTokens(i,t))}):r.tokens&&(e=e.concat(this.walkTokens(r.tokens,t)))}}return e}use(...l){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return l.forEach(e=>{let a={...e};if(a.async=this.defaults.async||a.async||!1,e.extensions&&(e.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let s=t.renderers[r.name];s?t.renderers[r.name]=function(...i){let n=r.renderer.apply(this,i);return n===!1&&(n=s.apply(this,i)),n}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[r.level];s?s.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),a.extensions=t),e.renderer){let r=this.defaults.renderer||new K(this.defaults);for(let s in e.renderer){if(!(s in r))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let i=s,n=e.renderer[i],o=r[i];r[i]=(...d)=>{let c=n.apply(r,d);return c===!1&&(c=o.apply(r,d)),c||""}}a.renderer=r}if(e.tokenizer){let r=this.defaults.tokenizer||new G(this.defaults);for(let s in e.tokenizer){if(!(s in r))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let i=s,n=e.tokenizer[i],o=r[i];r[i]=(...d)=>{let c=n.apply(r,d);return c===!1&&(c=o.apply(r,d)),c}}a.tokenizer=r}if(e.hooks){let r=this.defaults.hooks||new _;for(let s in e.hooks){if(!(s in r))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let i=s,n=e.hooks[i],o=r[i];_.passThroughHooks.has(s)?r[i]=d=>{if(this.defaults.async&&_.passThroughHooksRespectAsync.has(s))return(async()=>{let m=await n.call(r,d);return o.call(r,m)})();let c=n.call(r,d);return o.call(r,c)}:r[i]=(...d)=>{if(this.defaults.async)return(async()=>{let m=await n.apply(r,d);return m===!1&&(m=await o.apply(r,d)),m})();let c=n.apply(r,d);return c===!1&&(c=o.apply(r,d)),c}}a.hooks=r}if(e.walkTokens){let r=this.defaults.walkTokens,s=e.walkTokens;a.walkTokens=function(i){let n=[];return n.push(s.call(this,i)),r&&(n=n.concat(r.call(this,i))),n}}this.defaults={...this.defaults,...a}}),this}setOptions(l){return this.defaults={...this.defaults,...l},this}lexer(l,t){return M.lex(l,t??this.defaults)}parser(l,t){return z.parse(l,t??this.defaults)}parseMarkdown(l){return(t,e)=>{let a={...e},r={...this.defaults,...a},s=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&a.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=l),r.async)return(async()=>{let i=r.hooks?await r.hooks.preprocess(t):t,n=await(r.hooks?await r.hooks.provideLexer():l?M.lex:M.lexInline)(i,r),o=r.hooks?await r.hooks.processAllTokens(n):n;r.walkTokens&&await Promise.all(this.walkTokens(o,r.walkTokens));let d=await(r.hooks?await r.hooks.provideParser():l?z.parse:z.parseInline)(o,r);return r.hooks?await r.hooks.postprocess(d):d})().catch(s);try{r.hooks&&(t=r.hooks.preprocess(t));let i=(r.hooks?r.hooks.provideLexer():l?M.lex:M.lexInline)(t,r);r.hooks&&(i=r.hooks.processAllTokens(i)),r.walkTokens&&this.walkTokens(i,r.walkTokens);let n=(r.hooks?r.hooks.provideParser():l?z.parse:z.parseInline)(i,r);return r.hooks&&(n=r.hooks.postprocess(n)),n}catch(i){return s(i)}}}onError(l,t){return e=>{if(e.message+=`
59
- Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error occurred:</p><pre>"+A(e.message+"",!0)+"</pre>";return t?Promise.resolve(a):a}if(t)return Promise.reject(e);throw e}}},N=new Pt;C.options=C.setOptions=function(l){return N.setOptions(l),C.defaults=N.defaults,St(C.defaults),C};C.getDefaults=Te;C.defaults=R;C.use=function(...l){return N.use(...l),C.defaults=N.defaults,St(C.defaults),C};C.walkTokens=function(l,t){return N.walkTokens(l,t)};C.parseInline=N.parseInline;C.Parser=z;C.parser=z.parse;C.Renderer=K;C.TextRenderer=ze;C.Lexer=M;C.lexer=M.lex;C.Tokenizer=G;C.Hooks=_;C.parse=C;Hr=C.options,Br=C.setOptions,_r=C.use,Or=C.walkTokens,jr=C.parseInline,Wr=C,Ur=z.parse,Yr=M.lex});var J=class{parse(t){if(!t)throw new Error("Schema es requerido");if(!t.fields&&!t.steps)throw new Error("Schema debe tener fields o steps");if(t.steps){for(let r of t.steps)if(!r.fields||r.fields.length===0)throw new Error("Cada step debe tener al menos un field")}let e=t.fields?this.normalizeFields(t.fields):[],a=t.steps?t.steps.map(r=>({...r,fields:this.normalizeFields(r.fields)})):void 0;return{fields:e,steps:a,isWizard:!!(t.steps&&t.steps.length>0)}}normalizeFields(t){return t.map((e,a)=>{if(!e.type)throw new Error(`Field en \xEDndice ${a} debe tener un type`);if(!e.name)throw new Error(`Field en \xEDndice ${a} debe tener un name`);return this.validateFieldType(e,a),this.applyDefaults(e)})}validateFieldType(t,e){if(!["text","email","number","password","textarea","select","checkbox","radio","switch","date","file","file-drop","map","rating","slider","colorpicker","array","group","row","custom","quantity","accordion-select","image-grid-select","otp","markdown"].includes(t.type))throw new Error(`Field en \xEDndice ${e} tiene un type inv\xE1lido: ${t.type}`);switch(t.type){case"select":case"radio":case"accordion-select":case"image-grid-select":if(!("options"in t)||!t.options||t.options.length===0)throw new Error(`Field "${t.name}" de tipo ${t.type} debe tener options`);break;case"array":if(!("itemSchema"in t)||!t.itemSchema)throw new Error(`Field "${t.name}" de tipo array debe tener itemSchema`);if("minItems"in t){let r=t.minItems;if(r<0)throw new Error(`Field "${t.name}" de tipo array: minItems debe ser >= 0`);if("maxItems"in t){let s=t.maxItems;if(r>s)throw new Error(`Field "${t.name}" de tipo array: minItems (${r}) no puede ser mayor que maxItems (${s})`)}}break;case"group":if(!("fields"in t)||!t.fields||t.fields.length===0)throw new Error(`Field "${t.name}" de tipo group debe tener fields`);break;case"row":if(!("fields"in t)||!t.fields||t.fields.length===0)throw new Error(`Field "${t.name}" de tipo row debe tener fields`);break;case"colorpicker":if("defaultValue"in t&&t.defaultValue!=null&&!/^#[0-9A-Fa-f]{6}$/.test(String(t.defaultValue)))throw new Error(`Field "${t.name}" de tipo colorpicker debe tener defaultValue en formato hex (#RRGGBB)`);break}"leadingIcon"in t&&t.leadingIcon&&this.validateSlotContent(t.leadingIcon,t.name,"leadingIcon"),"trailingIcon"in t&&t.trailingIcon&&this.validateSlotContent(t.trailingIcon,t.name,"trailingIcon")}validateSlotContent(t,e,a){if(!t.type||!["image","html"].includes(t.type))throw new Error(`Field "${e}" ${a} debe tener type 'image' o 'html'`);if(t.type==="image"&&(!t.src||typeof t.src!="string"))throw new Error(`Field "${e}" ${a} con type 'image' debe tener src`);if(t.type==="html"&&(!t.html||typeof t.html!="string"))throw new Error(`Field "${e}" ${a} con type 'html' debe tener html`)}applyDefaults(t){let e={disabled:!1,hidden:!1};switch(t.type){case"checkbox":case"switch":"checked"in t||(e.checked=!1);break;case"select":case"accordion-select":case"image-grid-select":"multiple"in t||(e.multiple=!1),t.type==="image-grid-select"&&("columns"in t||(e.columns=3),"imageSize"in t||(e.imageSize="medium"));break;case"file":"multiple"in t||(e.multiple=!1);break;case"quantity":"min"in t||(e.min=0),"step"in t||(e.step=1);break;case"otp":"length"in t||(e.length=6),"numeric"in t||(e.numeric=!0);break;case"slider":"min"in t||(e.min=0),"max"in t||(e.max=100),"step"in t||(e.step=1);break;case"rating":"max"in t||(e.max=5);break;case"colorpicker":(!("defaultValue"in t)||t.defaultValue==null)&&(e.defaultValue="#000000");break}return{...e,...t}}getAllFields(t){let e=this.parse(t),a=[],r=s=>{for(let i of s)a.push(i),i.type==="group"&&"fields"in i&&r(i.fields),i.type==="row"&&"fields"in i&&r(i.fields),i.type==="array"&&"itemSchema"in i&&i.itemSchema.fields&&r(i.itemSchema.fields)};if(e.fields&&r(e.fields),e.steps)for(let s of e.steps)r(s.fields);return a}};function Wt(l){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(l);if(!t){let e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i.exec(l);return e?[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)].join(", "):"0, 123, 255"}return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)].join(", ")}var Ut={primary:"#007bff",secondary:"#6c757d",error:"#dc3545",success:"#28a745",text:"#212529",labelColor:"#212529",border:"#ddd",background:"#ffffff",groupBackground:"var(--easy-form-group-background)",groupTitle:"#212529",groupBorder:"#ddd"};function O(l){return{...Ut,...l}}function Xe(l){return`
58
+ `}strong({tokens:l}){return`<strong>${this.parser.parseInline(l)}</strong>`}em({tokens:l}){return`<em>${this.parser.parseInline(l)}</em>`}codespan({text:l}){return`<code>${z(l,!0)}</code>`}br(l){return"<br>"}del({tokens:l}){return`<del>${this.parser.parseInline(l)}</del>`}link({href:l,title:t,tokens:e}){let a=this.parser.parseInline(e),r=wt(l);if(r===null)return a;l=r;let s='<a href="'+l+'"';return t&&(s+=' title="'+z(t)+'"'),s+=">"+a+"</a>",s}image({href:l,title:t,text:e,tokens:a}){a&&(e=this.parser.parseInline(a,this.parser.textRenderer));let r=wt(l);if(r===null)return z(e);l=r;let s=`<img src="${l}" alt="${z(e)}"`;return t&&(s+=` title="${z(t)}"`),s+=">",s}text(l){return"tokens"in l&&l.tokens?this.parser.parseInline(l.tokens):"escaped"in l&&l.escaped?l.text:z(l.text)}},Ae=class{strong({text:l}){return l}em({text:l}){return l}codespan({text:l}){return l}del({text:l}){return l}html({text:l}){return l}text({text:l}){return l}link({text:l}){return""+l}image({text:l}){return""+l}br(){return""}checkbox({raw:l}){return l}},A=class He{constructor(t){F(this,"options");F(this,"renderer");F(this,"textRenderer");this.options=t||R,this.options.renderer=this.options.renderer||new K,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ae}static parse(t,e){return new He(e).parse(t)}static parseInline(t,e){return new He(e).parseInline(t)}parse(t){let e="";for(let a=0;a<t.length;a++){let r=t[a];if(this.options.extensions?.renderers?.[r.type]){let i=r,n=this.options.extensions.renderers[i.type].call({parser:this},i);if(n!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){e+=n||"";continue}}let s=r;switch(s.type){case"space":{e+=this.renderer.space(s);break}case"hr":{e+=this.renderer.hr(s);break}case"heading":{e+=this.renderer.heading(s);break}case"code":{e+=this.renderer.code(s);break}case"table":{e+=this.renderer.table(s);break}case"blockquote":{e+=this.renderer.blockquote(s);break}case"list":{e+=this.renderer.list(s);break}case"checkbox":{e+=this.renderer.checkbox(s);break}case"html":{e+=this.renderer.html(s);break}case"def":{e+=this.renderer.def(s);break}case"paragraph":{e+=this.renderer.paragraph(s);break}case"text":{e+=this.renderer.text(s);break}default:{let i='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return e}parseInline(t,e=this.renderer){let a="";for(let r=0;r<t.length;r++){let s=t[r];if(this.options.extensions?.renderers?.[s.type]){let n=this.options.extensions.renderers[s.type].call({parser:this},s);if(n!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){a+=n||"";continue}}let i=s;switch(i.type){case"escape":{a+=e.text(i);break}case"html":{a+=e.html(i);break}case"link":{a+=e.link(i);break}case"image":{a+=e.image(i);break}case"checkbox":{a+=e.checkbox(i);break}case"strong":{a+=e.strong(i);break}case"em":{a+=e.em(i);break}case"codespan":{a+=e.codespan(i);break}case"br":{a+=e.br(i);break}case"del":{a+=e.del(i);break}case"text":{a+=e.text(i);break}default:{let n='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(n),"";throw new Error(n)}}}return a}},O=(Ce=class{constructor(l){F(this,"options");F(this,"block");this.options=l||R}preprocess(l){return l}postprocess(l){return l}processAllTokens(l){return l}emStrongMask(l){return l}provideLexer(){return this.block?M.lex:M.lexInline}provideParser(){return this.block?A.parse:A.parseInline}},F(Ce,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),F(Ce,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Ce),Nt=class{constructor(...l){F(this,"defaults",Fe());F(this,"options",this.setOptions);F(this,"parse",this.parseMarkdown(!0));F(this,"parseInline",this.parseMarkdown(!1));F(this,"Parser",A);F(this,"Renderer",K);F(this,"TextRenderer",Ae);F(this,"Lexer",M);F(this,"Tokenizer",G);F(this,"Hooks",O);this.use(...l)}walkTokens(l,t){let e=[];for(let a of l)switch(e=e.concat(t.call(this,a)),a.type){case"table":{let r=a;for(let s of r.header)e=e.concat(this.walkTokens(s.tokens,t));for(let s of r.rows)for(let i of s)e=e.concat(this.walkTokens(i.tokens,t));break}case"list":{let r=a;e=e.concat(this.walkTokens(r.items,t));break}default:{let r=a;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(s=>{let i=r[s].flat(1/0);e=e.concat(this.walkTokens(i,t))}):r.tokens&&(e=e.concat(this.walkTokens(r.tokens,t)))}}return e}use(...l){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return l.forEach(e=>{let a={...e};if(a.async=this.defaults.async||a.async||!1,e.extensions&&(e.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let s=t.renderers[r.name];s?t.renderers[r.name]=function(...i){let n=r.renderer.apply(this,i);return n===!1&&(n=s.apply(this,i)),n}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[r.level];s?s.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),a.extensions=t),e.renderer){let r=this.defaults.renderer||new K(this.defaults);for(let s in e.renderer){if(!(s in r))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let i=s,n=e.renderer[i],o=r[i];r[i]=(...d)=>{let c=n.apply(r,d);return c===!1&&(c=o.apply(r,d)),c||""}}a.renderer=r}if(e.tokenizer){let r=this.defaults.tokenizer||new G(this.defaults);for(let s in e.tokenizer){if(!(s in r))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let i=s,n=e.tokenizer[i],o=r[i];r[i]=(...d)=>{let c=n.apply(r,d);return c===!1&&(c=o.apply(r,d)),c}}a.tokenizer=r}if(e.hooks){let r=this.defaults.hooks||new O;for(let s in e.hooks){if(!(s in r))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let i=s,n=e.hooks[i],o=r[i];O.passThroughHooks.has(s)?r[i]=d=>{if(this.defaults.async&&O.passThroughHooksRespectAsync.has(s))return(async()=>{let m=await n.call(r,d);return o.call(r,m)})();let c=n.call(r,d);return o.call(r,c)}:r[i]=(...d)=>{if(this.defaults.async)return(async()=>{let m=await n.apply(r,d);return m===!1&&(m=await o.apply(r,d)),m})();let c=n.apply(r,d);return c===!1&&(c=o.apply(r,d)),c}}a.hooks=r}if(e.walkTokens){let r=this.defaults.walkTokens,s=e.walkTokens;a.walkTokens=function(i){let n=[];return n.push(s.call(this,i)),r&&(n=n.concat(r.call(this,i))),n}}this.defaults={...this.defaults,...a}}),this}setOptions(l){return this.defaults={...this.defaults,...l},this}lexer(l,t){return M.lex(l,t??this.defaults)}parser(l,t){return A.parse(l,t??this.defaults)}parseMarkdown(l){return(t,e)=>{let a={...e},r={...this.defaults,...a},s=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&a.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=l),r.async)return(async()=>{let i=r.hooks?await r.hooks.preprocess(t):t,n=await(r.hooks?await r.hooks.provideLexer():l?M.lex:M.lexInline)(i,r),o=r.hooks?await r.hooks.processAllTokens(n):n;r.walkTokens&&await Promise.all(this.walkTokens(o,r.walkTokens));let d=await(r.hooks?await r.hooks.provideParser():l?A.parse:A.parseInline)(o,r);return r.hooks?await r.hooks.postprocess(d):d})().catch(s);try{r.hooks&&(t=r.hooks.preprocess(t));let i=(r.hooks?r.hooks.provideLexer():l?M.lex:M.lexInline)(t,r);r.hooks&&(i=r.hooks.processAllTokens(i)),r.walkTokens&&this.walkTokens(i,r.walkTokens);let n=(r.hooks?r.hooks.provideParser():l?A.parse:A.parseInline)(i,r);return r.hooks&&(n=r.hooks.postprocess(n)),n}catch(i){return s(i)}}}onError(l,t){return e=>{if(e.message+=`
59
+ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error occurred:</p><pre>"+z(e.message+"",!0)+"</pre>";return t?Promise.resolve(a):a}if(t)return Promise.reject(e);throw e}}},N=new Nt;C.options=C.setOptions=function(l){return N.setOptions(l),C.defaults=N.defaults,Ct(C.defaults),C};C.getDefaults=Fe;C.defaults=R;C.use=function(...l){return N.use(...l),C.defaults=N.defaults,Ct(C.defaults),C};C.walkTokens=function(l,t){return N.walkTokens(l,t)};C.parseInline=N.parseInline;C.Parser=A;C.parser=A.parse;C.Renderer=K;C.TextRenderer=Ae;C.Lexer=M;C.lexer=M.lex;C.Tokenizer=G;C.Hooks=O;C.parse=C;Br=C.options,Or=C.setOptions,_r=C.use,jr=C.walkTokens,Wr=C.parseInline,Ur=C,Yr=A.parse,Zr=M.lex});var J=class{parse(t){if(!t)throw new Error("Schema es requerido");if(!t.fields&&!t.steps)throw new Error("Schema debe tener fields o steps");if(t.steps){for(let r of t.steps)if(!r.fields||r.fields.length===0)throw new Error("Cada step debe tener al menos un field")}let e=t.fields?this.normalizeFields(t.fields):[],a=t.steps?t.steps.map(r=>({...r,fields:this.normalizeFields(r.fields)})):void 0;return{fields:e,steps:a,isWizard:!!(t.steps&&t.steps.length>0)}}normalizeFields(t){return t.map((e,a)=>{if(!e.type)throw new Error(`Field en \xEDndice ${a} debe tener un type`);if(!e.name)throw new Error(`Field en \xEDndice ${a} debe tener un name`);return this.validateFieldType(e,a),this.applyDefaults(e)})}validateFieldType(t,e){if(!["text","email","number","password","textarea","select","checkbox","radio","switch","date","file","file-drop","map","rating","slider","colorpicker","array","group","row","custom","quantity","accordion-select","image-grid-select","otp","markdown","autocomplete-tags"].includes(t.type))throw new Error(`Field en \xEDndice ${e} tiene un type inv\xE1lido: ${t.type}`);switch(t.type){case"select":case"radio":case"accordion-select":case"image-grid-select":case"autocomplete-tags":if(!("options"in t)||!t.options||t.options.length===0)throw new Error(`Field "${t.name}" de tipo ${t.type} debe tener options`);break;case"array":if(!("itemSchema"in t)||!t.itemSchema)throw new Error(`Field "${t.name}" de tipo array debe tener itemSchema`);if("minItems"in t){let r=t.minItems;if(r<0)throw new Error(`Field "${t.name}" de tipo array: minItems debe ser >= 0`);if("maxItems"in t){let s=t.maxItems;if(r>s)throw new Error(`Field "${t.name}" de tipo array: minItems (${r}) no puede ser mayor que maxItems (${s})`)}}break;case"group":if(!("fields"in t)||!t.fields||t.fields.length===0)throw new Error(`Field "${t.name}" de tipo group debe tener fields`);break;case"row":if(!("fields"in t)||!t.fields||t.fields.length===0)throw new Error(`Field "${t.name}" de tipo row debe tener fields`);break;case"colorpicker":if("defaultValue"in t&&t.defaultValue!=null&&!/^#[0-9A-Fa-f]{6}$/.test(String(t.defaultValue)))throw new Error(`Field "${t.name}" de tipo colorpicker debe tener defaultValue en formato hex (#RRGGBB)`);break}"leadingIcon"in t&&t.leadingIcon&&this.validateSlotContent(t.leadingIcon,t.name,"leadingIcon"),"trailingIcon"in t&&t.trailingIcon&&this.validateSlotContent(t.trailingIcon,t.name,"trailingIcon")}validateSlotContent(t,e,a){if(!t.type||!["image","html"].includes(t.type))throw new Error(`Field "${e}" ${a} debe tener type 'image' o 'html'`);if(t.type==="image"&&(!t.src||typeof t.src!="string"))throw new Error(`Field "${e}" ${a} con type 'image' debe tener src`);if(t.type==="html"&&(!t.html||typeof t.html!="string"))throw new Error(`Field "${e}" ${a} con type 'html' debe tener html`)}applyDefaults(t){let e={disabled:!1,hidden:!1};switch(t.type){case"checkbox":case"switch":"checked"in t||(e.checked=!1);break;case"select":case"accordion-select":case"image-grid-select":"multiple"in t||(e.multiple=!1),t.type==="image-grid-select"&&("columns"in t||(e.columns=3),"imageSize"in t||(e.imageSize="medium"));break;case"file":"multiple"in t||(e.multiple=!1);break;case"quantity":"min"in t||(e.min=0),"step"in t||(e.step=1);break;case"otp":"length"in t||(e.length=6),"numeric"in t||(e.numeric=!0);break;case"slider":"min"in t||(e.min=0),"max"in t||(e.max=100),"step"in t||(e.step=1);break;case"rating":"max"in t||(e.max=5);break;case"colorpicker":(!("defaultValue"in t)||t.defaultValue==null)&&(e.defaultValue="#000000");break}return{...e,...t}}getAllFields(t){let e=this.parse(t),a=[],r=s=>{for(let i of s)a.push(i),i.type==="group"&&"fields"in i&&r(i.fields),i.type==="row"&&"fields"in i&&r(i.fields),i.type==="array"&&"itemSchema"in i&&i.itemSchema.fields&&r(i.itemSchema.fields)};if(e.fields&&r(e.fields),e.steps)for(let s of e.steps)r(s.fields);return a}};function Ut(l){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(l);if(!t){let e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i.exec(l);return e?[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)].join(", "):"0, 123, 255"}return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)].join(", ")}var Yt={primary:"#007bff",secondary:"#6c757d",error:"#dc3545",success:"#28a745",text:"#212529",labelColor:"#212529",border:"#ddd",background:"#ffffff",groupBackground:"var(--easy-form-group-background)",groupTitle:"#212529",groupBorder:"#ddd"};function _(l){return{...Yt,...l}}function et(l){return`
60
60
  :host {
61
61
  display: block;
62
62
  --easy-form-primary: ${l.primary};
63
- --easy-form-primary-rgb: ${Wt(l.primary)};
63
+ --easy-form-primary-rgb: ${Ut(l.primary)};
64
64
  --easy-form-secondary: ${l.secondary};
65
65
  --easy-form-error: ${l.error};
66
66
  --easy-form-success: ${l.success};
@@ -1386,10 +1386,126 @@ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error
1386
1386
  opacity: 0.7;
1387
1387
  }
1388
1388
  }
1389
+ .easy-form-autocomplete-tags-container {
1390
+ position: relative;
1391
+ width: 100%;
1392
+ }
1393
+ .easy-form-autocomplete-tags {
1394
+ display: flex;
1395
+ flex-wrap: wrap;
1396
+ gap: 0.375rem;
1397
+ margin-bottom: 0.5rem;
1398
+ min-height: 2rem;
1399
+ }
1400
+ .easy-form-tag {
1401
+ display: inline-flex;
1402
+ align-items: center;
1403
+ gap: 0.375rem;
1404
+ padding: 0.25rem 0.5rem;
1405
+ background: var(--easy-form-primary);
1406
+ color: var(--easy-form-on-primary);
1407
+ border-radius: 4px;
1408
+ font-size: 0.875rem;
1409
+ line-height: 1;
1410
+ animation: easy-form-tag-enter 0.15s ease-out;
1411
+ }
1412
+ @keyframes easy-form-tag-enter {
1413
+ from {
1414
+ opacity: 0;
1415
+ transform: scale(0.8);
1416
+ }
1417
+ to {
1418
+ opacity: 1;
1419
+ transform: scale(1);
1420
+ }
1421
+ }
1422
+ .easy-form-tag-label {
1423
+ max-width: 150px;
1424
+ overflow: hidden;
1425
+ text-overflow: ellipsis;
1426
+ white-space: nowrap;
1427
+ }
1428
+ .easy-form-tag-remove {
1429
+ display: inline-flex;
1430
+ align-items: center;
1431
+ justify-content: center;
1432
+ width: 1rem;
1433
+ height: 1rem;
1434
+ padding: 0;
1435
+ background: transparent;
1436
+ border: none;
1437
+ color: var(--easy-form-on-primary);
1438
+ font-size: 1rem;
1439
+ line-height: 1;
1440
+ cursor: pointer;
1441
+ opacity: 0.7;
1442
+ transition: opacity 0.15s, transform 0.15s;
1443
+ border-radius: 50%;
1444
+ }
1445
+ .easy-form-tag-remove:hover {
1446
+ opacity: 1;
1447
+ transform: scale(1.1);
1448
+ background: rgba(255, 255, 255, 0.2);
1449
+ }
1450
+ .easy-form-tag-remove:focus {
1451
+ outline: 2px solid var(--easy-form-on-primary);
1452
+ outline-offset: 1px;
1453
+ }
1454
+ .easy-form-autocomplete-tags-input {
1455
+ width: 100%;
1456
+ padding: 0.5rem 0.75rem;
1457
+ font-size: 1rem;
1458
+ color: var(--easy-form-text);
1459
+ background: var(--easy-form-background);
1460
+ border: 1px solid var(--easy-form-border);
1461
+ border-radius: 4px;
1462
+ outline: none;
1463
+ }
1464
+ .easy-form-autocomplete-tags-input:focus {
1465
+ border-color: var(--easy-form-primary);
1466
+ box-shadow: 0 0 0 3px rgba(var(--easy-form-primary-rgb), 0.1);
1467
+ }
1468
+ .easy-form-autocomplete-tags-input::placeholder {
1469
+ color: color-mix(in srgb, var(--easy-form-text) 55%, transparent);
1470
+ }
1471
+ .easy-form-autocomplete-tags-input:disabled {
1472
+ cursor: not-allowed;
1473
+ opacity: 0.6;
1474
+ }
1475
+ .easy-form-autocomplete-tags-dropdown {
1476
+ position: absolute;
1477
+ top: 100%;
1478
+ left: 0;
1479
+ right: 0;
1480
+ max-height: 200px;
1481
+ overflow-y: auto;
1482
+ margin: 0.25rem 0 0 0;
1483
+ padding: 0.25rem 0;
1484
+ background: var(--easy-form-background);
1485
+ border: 1px solid var(--easy-form-border);
1486
+ border-radius: 4px;
1487
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
1488
+ list-style: none;
1489
+ z-index: 100;
1490
+ }
1491
+ .easy-form-autocomplete-tags-option {
1492
+ padding: 0.5rem 1rem;
1493
+ cursor: pointer;
1494
+ color: var(--easy-form-text);
1495
+ font-size: 0.875rem;
1496
+ transition: background-color 0.15s;
1497
+ }
1498
+ .easy-form-autocomplete-tags-option:hover {
1499
+ background: var(--easy-form-hover-overlay);
1500
+ }
1501
+ .easy-form-autocomplete-tags-option:focus {
1502
+ outline: none;
1503
+ background: rgba(var(--easy-form-primary-rgb), 0.1);
1504
+ }
1389
1505
  form {
1390
1506
  position: relative;
1391
1507
  }
1392
- `}function Re(l){return`
1508
+ `}function $e(l){return`
1393
1509
  .easy-form-label {
1394
1510
  color: var(--easy-form-label-color);
1395
1511
  }
@@ -1422,7 +1538,7 @@ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error
1422
1538
  border-bottom: 1px solid var(--easy-form-group-border);
1423
1539
  border-radius: 0;
1424
1540
  }
1425
- `}function et(l){return`
1541
+ `}function tt(l){return`
1426
1542
  .easy-form-label {
1427
1543
  color: var(--easy-form-label-color);
1428
1544
  }
@@ -1457,7 +1573,7 @@ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error
1457
1573
  border-radius: 4px;
1458
1574
  background: var(--easy-form-group-background);
1459
1575
  }
1460
- `}function tt(l){return`
1576
+ `}function rt(l){return`
1461
1577
  .easy-form-label {
1462
1578
  font-size: 0.875rem;
1463
1579
  font-weight: 500;
@@ -1542,7 +1658,7 @@ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error
1542
1658
  background: transparent;
1543
1659
  border: none;
1544
1660
  }
1545
- `}function rt(l){return`
1661
+ `}function at(l){return`
1546
1662
  .easy-form-label {
1547
1663
  color: var(--easy-form-label-color);
1548
1664
  }
@@ -1594,7 +1710,7 @@ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error
1594
1710
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
1595
1711
  background: var(--easy-form-group-background);
1596
1712
  }
1597
- `}function at(l){return`
1713
+ `}function st(l){return`
1598
1714
  .easy-form-field {
1599
1715
  border-bottom: 1px solid var(--easy-form-border);
1600
1716
  padding-bottom: 1rem;
@@ -1706,7 +1822,7 @@ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error
1706
1822
  border: none;
1707
1823
  padding: 0;
1708
1824
  }
1709
- `}function st(l){return`
1825
+ `}function it(l){return`
1710
1826
  .easy-form-label {
1711
1827
  color: var(--easy-form-label-color);
1712
1828
  font-size: 0.875rem;
@@ -1839,7 +1955,7 @@ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error
1839
1955
  transform: translateY(-2px);
1840
1956
  background: linear-gradient(135deg, color-mix(in srgb, var(--easy-form-primary) 75%, black) 0%, var(--easy-form-primary) 100%);
1841
1957
  }
1842
- `}function it(l){return`
1958
+ `}function ot(l){return`
1843
1959
  .easy-form-label {
1844
1960
  color: var(--easy-form-label-color);
1845
1961
  font-size: 0.875rem;
@@ -1935,7 +2051,7 @@ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error
1935
2051
  border-color: var(--easy-form-group-border);
1936
2052
  box-shadow: 0 2px 8px rgba(var(--easy-form-primary-rgb), 0.15);
1937
2053
  }
1938
- `}function ot(l){return`
2054
+ `}function nt(l){return`
1939
2055
  .easy-form-label {
1940
2056
  color: var(--easy-form-label-color);
1941
2057
  font-size: 0.875rem;
@@ -2012,7 +2128,7 @@ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error
2012
2128
  background: var(--easy-form-group-background);
2013
2129
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
2014
2130
  }
2015
- `}function nt(l){return`
2131
+ `}function lt(l){return`
2016
2132
  .easy-form-label {
2017
2133
  color: var(--easy-form-label-color);
2018
2134
  font-size: 0.875rem;
@@ -2168,7 +2284,7 @@ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error
2168
2284
  .easy-form-wizard-next:hover {
2169
2285
  background: rgba(var(--easy-form-primary-rgb), 0.35);
2170
2286
  }
2171
- `}function lt(l){return`
2287
+ `}function dt(l){return`
2172
2288
  .easy-form-label {
2173
2289
  color: var(--easy-form-label-color);
2174
2290
  font-size: 0.875rem;
@@ -2253,7 +2369,7 @@ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error
2253
2369
  background: var(--easy-form-group-background);
2254
2370
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.1);
2255
2371
  }
2256
- `}function dt(l){return`
2372
+ `}function ct(l){return`
2257
2373
  .easy-form-label {
2258
2374
  color: var(--easy-form-label-color);
2259
2375
  font-size: 0.75rem;
@@ -2454,7 +2570,7 @@ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error
2454
2570
  border: none;
2455
2571
  padding: 0;
2456
2572
  }
2457
- `}function ct(l){return`
2573
+ `}function pt(l){return`
2458
2574
  .easy-form-label {
2459
2575
  color: var(--easy-form-label-color);
2460
2576
  font-size: 0.875rem;
@@ -2651,7 +2767,7 @@ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error
2651
2767
  background-position: right 1rem center;
2652
2768
  padding-right: 2.5rem;
2653
2769
  }
2654
- `}function X(l,t){let e=Xe(t),a=Yt(l,t);return e+a}function Yt(l,t){switch(l){case"plano":return Re(t);case"tradicional":return et(t);case"material":return tt(t);case"rounded-shadow":return rt(t);case"lines":return at(t);case"shadcn":return st(t);case"chakra":return it(t);case"mantine":return ot(t);case"glass":return nt(t);case"bordered":return lt(t);case"minimal":return dt(t);case"efc":return ct(t);default:return Re(t)}}var pt={phone:{pattern:"(999) 999-9999",placeholder:"_"},"phone-us":{pattern:"(999) 999-9999",placeholder:"_"},"phone-international":{pattern:"+99 999 999 9999",placeholder:"_"},date:{pattern:"99/99/9999",placeholder:"_"},"date-us":{pattern:"99/99/9999",placeholder:"_"},"date-eu":{pattern:"99-99-9999",placeholder:"_"},"credit-card":{pattern:"9999 9999 9999 9999",placeholder:"_"},ssn:{pattern:"999-99-9999",placeholder:"_"},"zip-code":{pattern:"99999",placeholder:"_"},currency:{pattern:"$999,999.99",placeholder:"_",transform:l=>{let t=l.replace(/[^\d.]/g,"");return(parseFloat(t)||0).toFixed(2)}},percentage:{pattern:"999%",placeholder:"_",transform:l=>l.replace(/[^\d]/g,"")},time:{pattern:"99:99",placeholder:"_"},datetime:{pattern:"99/99/9999 99:99",placeholder:"_"}};function $e(l){return pt[l]}var ee="El valor contiene caracteres o patrones no permitidos",Zt=[/\b(union|select|insert|update|delete|drop|exec|execute|declare)\s+(all\s+)?(select|from|into|table)/i,/\b(or|and)\s+['"]?\d+['"]?\s*=\s*['"]?\d+/i,/;\s*(drop|delete|truncate|alter)\s+/i,/--\s*$/,/\/\*[\s\S]*\*\//,/'\s*or\s+'1'\s*=\s*'1/i,/"\s*or\s+"1"\s*=\s*"1/i,/\bexec\s*\(/i,/\bxp_\w+/i,/<script\b[\s\S]*?>[\s\S]*?<\/script>/i,/<script\b/i,/javascript\s*:/i,/vbscript\s*:/i,/on\w+\s*=\s*["'][^"']*["']/i,/on\w+\s*=\s*[^\s>]+/i,/<iframe\b/i,/<object\b/i,/<embed\b/i,/\beval\s*\(/i,/document\.(cookie|write|location)/i,/window\.(location|open|eval)/i,/[;&|]\s*(ls|cat|rm|wget|curl|nc|bash|sh|python|perl)\s/i,/\$\s*\([^)]+\)/,/`[^`]+`/,/\|\s*\w+/,/\$\s*where\b/i,/\$\s*gt\b|\$\s*ne\b|\$\s*regex\b/i,/\{\{[^}]*\}\}/,/\$\{[^}]*\}/];function mt(l){if(typeof l!="string"||l.length===0||l.trim().length===0)return!1;for(let e of Zt)if(e.test(l))return!0;return!1}function j(l){return l==null?!0:typeof l=="string"?!mt(l):Array.isArray(l)?l.every(t=>j(t)):typeof l=="object"?Object.values(l).every(t=>j(t)):!0}var W=class{constructor(t){this.attempts=0;this.lockedUntil=null;this.unlockCheckInterval=null;this.maxAttempts=Math.max(1,t.maxAttempts),this.blockDurationMs=(t.blockDurationMinutes??5)*60*1e3,this.storageKey=t.storageKey,this.onLocked=t.onLocked,this.onUnlocked=t.onUnlocked,this.storageKey&&typeof sessionStorage<"u"&&this.loadFromStorage()}loadFromStorage(){if(!(!this.storageKey||typeof sessionStorage>"u"))try{let t=sessionStorage.getItem(this.storageKey);if(t){let e=JSON.parse(t);this.attempts=e.attempts??0,this.lockedUntil=e.lockedUntil??null,this.checkExpiration()}}catch{}}saveToStorage(){if(!(!this.storageKey||typeof sessionStorage>"u"))try{let t={attempts:this.attempts,lockedUntil:this.lockedUntil??void 0};sessionStorage.setItem(this.storageKey,JSON.stringify(t))}catch{}}checkExpiration(){return this.lockedUntil===null?!1:Date.now()>=this.lockedUntil?(this.reset(),this.onUnlocked?.(),!0):!1}startUnlockCheck(){this.unlockCheckInterval||(this.unlockCheckInterval=setInterval(()=>{this.checkExpiration()&&this.stopUnlockCheck()},1e3))}stopUnlockCheck(){this.unlockCheckInterval&&(clearInterval(this.unlockCheckInterval),this.unlockCheckInterval=null)}incrementAttempts(){this.attempts++,this.attempts>=this.maxAttempts?(this.lockedUntil=Date.now()+this.blockDurationMs,this.saveToStorage(),this.onLocked?.(this.blockDurationMs),this.startUnlockCheck()):this.saveToStorage()}isLocked(){return this.checkExpiration()?!1:this.lockedUntil!==null&&Date.now()<this.lockedUntil}getRemainingBlockTimeMs(){return this.checkExpiration()||this.lockedUntil===null?0:Math.max(0,this.lockedUntil-Date.now())}reset(){this.attempts=0,this.lockedUntil=null,this.stopUnlockCheck(),this.saveToStorage()}getAttempts(){return this.attempts}};function D(l){return l==null?"":typeof l=="boolean"?l?"true":"false":typeof l=="object"?JSON.stringify(l):String(l)}function q(l){if(!l)return null;try{return JSON.parse(l)}catch{return l}}function I(l,t){return t.split(".").reduce((e,a)=>e?.[a],l)}function V(l,t,e){let a=t.split("."),r=a.pop(),s=a.reduce((i,n)=>((!i[n]||typeof i[n]!="object")&&(i[n]={}),i[n]),l);s[r]=e}function ut(l){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(l)}var H=class{evaluateCondition(t,e){let a=this.getFieldValue(t.field,e);return this.compareValues(a,t.operator,t.value)}evaluateConditions(t,e,a="and"){let r=Array.isArray(t)?t:[t];return r.length===0?!0:a==="and"?r.every(s=>this.evaluateCondition(s,e)):r.some(s=>this.evaluateCondition(s,e))}evaluateDependencies(t,e){let a=!0,r=!0,s=!1;if(t.show&&(a=this.evaluateConditions(t.show,e)),t.hide){let i=this.evaluateConditions(t.hide,e);a=a&&!i}if(t.enable&&(r=this.evaluateConditions(t.enable,e)),t.disable){let i=this.evaluateConditions(t.disable,e);r=r&&!i}if(t.required&&(s=this.evaluateConditions(t.required,e)),t.optional){let i=this.evaluateConditions(t.optional,e);s=s&&!i}return{visible:a,enabled:r,required:s}}getFieldValue(t,e){if(t in e)return e[t];let a=t.split("."),r=e;for(let s of a){if(r==null)return null;r=r[s]}return r}compareValues(t,e,a){switch(e){case"equals":return this.deepEqual(t,a);case"notEquals":return!this.deepEqual(t,a);case"contains":return Array.isArray(t)?t.includes(a):typeof t=="string"?t.includes(String(a)):!1;case"notContains":return!this.compareValues(t,"contains",a);case"greaterThan":return this.toNumber(t)>this.toNumber(a);case"lessThan":return this.toNumber(t)<this.toNumber(a);case"greaterThanOrEqual":return this.toNumber(t)>=this.toNumber(a);case"lessThanOrEqual":return this.toNumber(t)<=this.toNumber(a);case"in":return Array.isArray(a)?a.includes(t):!1;case"notIn":return!this.compareValues(t,"in",a);case"isEmpty":return t==null||t===""||Array.isArray(t)&&t.length===0;case"isNotEmpty":return!this.compareValues(t,"isEmpty",a);case"regex":try{return(typeof a=="string"?new RegExp(a):a).test(String(t||""))}catch{return!1}default:return!1}}deepEqual(t,e){if(t===e)return!0;if(t===null||e===null||t===void 0||e===void 0)return t===e;if(typeof t!=typeof e)return!1;if(Array.isArray(t)&&Array.isArray(e))return t.length!==e.length?!1:t.every((a,r)=>this.deepEqual(a,e[r]));if(typeof t=="object"){let a=Object.keys(t),r=Object.keys(e);return a.length!==r.length?!1:a.every(s=>this.deepEqual(t[s],e[s]))}return!1}toNumber(t){if(typeof t=="number")return t;if(typeof t=="string"){let e=parseFloat(t);return isNaN(e)?0:e}return 0}};var te=class{constructor(){this.conditionEngine=new H}async validateField(t,e){return this.validateFieldWithValidations(t,e,t.validations||[])}async validateFieldWithValidations(t,e,a){let r=[];if(!a||a.length===0)return r;for(let s of a){let i=await this.validateValue(s,e);i.isValid||r.push(i.message||this.getDefaultMessage(s))}return r}async validateValue(t,e){switch(t.type){case"required":return this.validateRequired(e);case"email":return this.validateEmail(e);case"minLength":return this.validateMinLength(e,t.value);case"maxLength":return this.validateMaxLength(e,t.value);case"min":return this.validateMin(e,t.value);case"max":return this.validateMax(e,t.value);case"pattern":return this.validatePattern(e,t.value);case"custom":return await this.validateCustom(e,t);case"noInjection":return this.validateNoInjection(e,t);default:return{isValid:!0}}}validateRequired(t){let e=t!=null&&t!==""&&!(Array.isArray(t)&&t.length===0);return{isValid:e,message:e?void 0:"Este campo es requerido"}}validateEmail(t){if(!t)return{isValid:!0};let e=typeof t=="string"&&ut(t);return{isValid:e,message:e?void 0:"Debe ser un email v\xE1lido"}}validateMinLength(t,e){if(!t)return{isValid:!0};let r=String(t).length>=e;return{isValid:r,message:r?void 0:`Debe tener al menos ${e} caracteres`}}validateMaxLength(t,e){if(!t)return{isValid:!0};let r=String(t).length<=e;return{isValid:r,message:r?void 0:`Debe tener m\xE1ximo ${e} caracteres`}}validateMin(t,e){if(t==null||t==="")return{isValid:!0};let a=Number(t),r=!isNaN(a)&&a>=e;return{isValid:r,message:r?void 0:`Debe ser mayor o igual a ${e}`}}validateMax(t,e){if(t==null||t==="")return{isValid:!0};let a=Number(t),r=!isNaN(a)&&a<=e;return{isValid:r,message:r?void 0:`Debe ser menor o igual a ${e}`}}validatePattern(t,e){if(!t)return{isValid:!0};let a;if(e instanceof RegExp)a=e;else if(typeof e=="string")try{a=new RegExp(e)}catch{return console.warn("Invalid regex pattern:",e),{isValid:!0}}else return console.warn("Pattern validation expects string or RegExp, got:",typeof e,e),{isValid:!0};let r=a.test(String(t));return{isValid:r,message:r?void 0:"El formato no es v\xE1lido"}}validateNoInjection(t,e){if(t==null||t==="")return{isValid:!0};let a=j(t);return{isValid:a,message:a?void 0:e.message||ee}}async validateCustom(t,e){try{let a=await e.validator(t);return{isValid:!!a,message:a?void 0:e.message||"Validaci\xF3n fallida"}}catch{return{isValid:!1,message:e.message||"Error en la validaci\xF3n"}}}getDefaultMessage(t){switch(t.type){case"required":return"Este campo es requerido";case"email":return"Debe ser un email v\xE1lido";case"minLength":return`Debe tener al menos ${t.value} caracteres`;case"maxLength":return`Debe tener m\xE1ximo ${t.value} caracteres`;case"min":return`Debe ser mayor o igual a ${t.value}`;case"max":return`Debe ser menor o igual a ${t.value}`;case"pattern":return"El formato no es v\xE1lido";case"custom":return"Validaci\xF3n fallida";case"noInjection":return ee;default:return"Campo inv\xE1lido"}}shouldValidateField(t,e){if(t.hidden||t.disabled)return!1;if(t.dependencies){let a=this.conditionEngine.evaluateDependencies(t.dependencies,e);if(!a.visible||!a.enabled)return!1}return!0}async validateForm(t,e){let a={};for(let r of t)if(this.shouldValidateField(r,e))if(r.type==="array"&&"itemSchema"in r){let n=r.itemSchema?.fields||[],o=e[r.name];if(Array.isArray(o))for(let c=0;c<o.length;c++){let m=o[c];for(let p of n){let u=`${r.name}.${c}.${p.name}`,h=m?.[p.name];if(!this.shouldValidateField(p,e))continue;let g=await this.validateField(p,h);g.length>0&&(a[u]=g)}}let d=await this.validateArrayField(r,o);d.length>0&&(a[r.name]=d)}else{let s=e[r.name],i=await this.validateField(r,s);i.length>0&&(a[r.name]=i)}return a}async validateArrayField(t,e){let a=[],r=t;return r.minItems!==void 0&&(Array.isArray(e)&&e.length>=r.minItems||a.push(`Debe tener al menos ${r.minItems} elementos`)),r.maxItems!==void 0&&(Array.isArray(e)&&e.length<=r.maxItems||a.push(`Debe tener m\xE1ximo ${r.maxItems} elementos`)),a}};var re=class{constructor(){this.wizardState=null;this.schema=null;this.dependencyCache=new Map;this.fieldDependencies=new Map;this.parser=new J,this.validator=new te,this.conditionEngine=new H,this.state=this.createInitialState()}createInitialState(){return{values:{},errors:{},touched:{},isValid:!0,isSubmitting:!1}}initializeSchema(t,e){this.schema=this.parser.parse(t),this.initializeValues(e),this.initializeWizard(),this.buildDependencyMap()}extractAllFields(t){let e=[];for(let a of t)e.push(a),a.type==="group"&&"fields"in a&&e.push(...this.extractAllFields(a.fields)),a.type==="row"&&"fields"in a&&e.push(...this.extractAllFields(a.fields));return e}getArrayItemOnlyFieldNames(t){let e=new Set(t.map(r=>r.name)),a=new Set;for(let r of t)if(r.type==="array"&&"itemSchema"in r&&r.itemSchema?.fields)for(let s of r.itemSchema.fields)e.has(s.name)||a.add(s.name);return a}extractAllFieldsWithArrays(t,e="",a="root"){let r=[];for(let s of t){let i=e?`${e}.${s.name}`:s.name,n=e||"";r.push({field:s,fullPath:i,containerType:a,containerPath:n}),s.type==="group"&&"fields"in s&&r.push(...this.extractAllFieldsWithArrays(s.fields,i,"group")),s.type==="row"&&"fields"in s&&r.push(...this.extractAllFieldsWithArrays(s.fields,i,"row")),s.type==="array"&&"itemSchema"in s&&s.itemSchema?.fields&&r.push(...this.extractAllFieldsWithArrays(s.itemSchema.fields,s.name,"array"))}return r}buildDependencyMap(){if(this.fieldDependencies.clear(),this.dependencyCache.clear(),!this.schema)return;let t=this.schema.isWizard?this.schema.steps.flatMap(a=>a.fields):this.schema.fields||[],e=this.extractAllFieldsWithArrays(t);for(let{field:a,fullPath:r,containerType:s,containerPath:i}of e){if(!a.dependencies)continue;let n=this.extractObservedFields(a.dependencies);for(let o of n)this.fieldDependencies.has(o)||this.fieldDependencies.set(o,new Set),this.fieldDependencies.get(o).add(a.name),r!==a.name&&this.fieldDependencies.get(o).add(r),s==="array"&&i&&(this.fieldDependencies.has(i)||this.fieldDependencies.set(i,new Set),this.fieldDependencies.get(i).add(r))}}extractObservedFields(t){let e=new Set,a=s=>{s&&s.field&&e.add(s.field)},r=s=>{Array.isArray(s)?s.forEach(a):s&&a(s)};return t.show&&r(t.show),t.hide&&r(t.hide),t.enable&&r(t.enable),t.disable&&r(t.disable),t.required&&r(t.required),t.optional&&r(t.optional),e}initializeValues(t){if(!this.schema)return;let e=this.schema.isWizard?this.schema.steps.flatMap(n=>n.fields):this.schema.fields||[],a=this.extractAllFields(e),r={...this.state.values},s={};if(t)for(let n in t){let o=t[n];o!=null&&V(s,n,o)}for(let n of a){let o=I(s,n.name);if(o!=null)continue;let d=I(r,n.name);d!=null?V(s,n.name,d):this.initializeFieldValue(n,s)}let i=this.getArrayItemOnlyFieldNames(e);for(let n in r)i.has(n)||n in s||(s[n]=r[n]);for(let n of e)if(n.type==="array"&&"minItems"in n&&"itemSchema"in n){let o=n,d=o.minItems??0;if(d>=1&&o.itemSchema?.fields?.length){let c=I(s,n.name);if(Array.isArray(c)&&c.length<d){let m=[...c];for(let p=c.length;p<d;p++){let u={};for(let h of o.itemSchema.fields)this.initializeFieldValue(h,u);m.push(u)}V(s,n.name,m)}}}for(let n of i)n in s&&delete s[n];this.state.values=s}initializeFieldValue(t,e){if(t.defaultValue!==void 0)e[t.name]=t.defaultValue;else switch(t.type){case"checkbox":case"switch":e[t.name]=t.checked||!1;break;case"select":"multiple"in t&&t.multiple?e[t.name]=[]:e[t.name]=null;break;case"array":{let a=t,r=a.minItems??0,s=a.itemSchema?.fields;if(r>=1&&s?.length){let i=[];for(let n=0;n<r;n++){let o={};for(let d of s)this.initializeFieldValue(d,o);i.push(o)}e[t.name]=i}else e[t.name]=[];break}case"group":if(e[t.name]={},"fields"in t)for(let a of t.fields)this.initializeFieldValue(a,e[t.name]);break;case"colorpicker":e[t.name]=t.defaultValue??"#000000";break;default:e[t.name]=null}}initializeWizard(){if(!this.schema||!this.schema.isWizard){this.wizardState=null;return}this.wizardState={currentStep:0,totalSteps:this.schema.steps.length,completedSteps:[]}}getState(){return{...this.state}}getWizardState(){return this.wizardState?{...this.wizardState}:null}getValue(t){return I(this.state.values,t)}createDefaultArrayItem(t){let a=t.itemSchema?.fields;if(!a?.length)return{};let r={};for(let s of a)this.initializeFieldValue(s,r);return r}async setValue(t,e){V(this.state.values,t,e),this.state.touched[t]=!0,this.invalidateDependencyCache(t),this.state.touched[t]&&this.schema&&await this.validateField(t);let a=this.fieldDependencies.get(t);if(a)for(let r of a)await this.validateField(r);this.updateValidity()}invalidateDependencyCache(t){let e=this.fieldDependencies.get(t);if(e)for(let s of e){this.dependencyCache.delete(s);let i=this.addArrayIndexToPath(t,s);i&&this.dependencyCache.delete(i)}let a=t.replace(/\[\d+\]/g,"");if(a!==t){if(e=this.fieldDependencies.get(a),e)for(let i of e){this.dependencyCache.delete(i);let n=t.match(/\[(\d+)\]/);if(n){let o=i.includes("[")?i:`${i.split(".").slice(0,-1).join(".")}[${n[1]}].${i.split(".").pop()}`;this.dependencyCache.delete(o)}}let s=a.split(".").pop();if(s&&s!==a&&(e=this.fieldDependencies.get(s),e))for(let i of e){this.dependencyCache.delete(i);let n=t.match(/\[(\d+)\]/);if(n){let d=`${t.split(".")[0].replace(/\[\d+\]/,"")}[${n[1]}].${i}`;this.dependencyCache.delete(d)}}}let r=t.split(".");for(let s=1;s<r.length;s++){if(r[s].includes("["))continue;let i=r.slice(s).join(".");if(e=this.fieldDependencies.get(i),e)for(let n of e)this.dependencyCache.delete(n),this.dependencyCache.delete(`${r[0]}.${i}`)}this.dependencyCache.delete(t)}addArrayIndexToPath(t,e){let a=t.match(/\[(\d+)\]/);if(!a)return null;let r=a[1],s=t.split(".")[0];if(e.startsWith(s)){let i=e.split(".");if(i.length>1)return`${i[0]}[${r}].${i.slice(1).join(".")}`}return null}setValueWithoutValidation(t,e){V(this.state.values,t,e),this.invalidateDependencyCache(t)}async validateField(t){if(!this.schema)return;let e=this.schema.isWizard?this.schema.steps.flatMap(o=>o.fields):this.schema.fields||[],r=this.extractAllFields(e).find(o=>o.name===t);if(!r)return;if(!this.getFieldVisibility(t)){delete this.state.errors[t];return}let s=this.getValue(t),i=this.getActiveValidations(r),n=await this.validator.validateFieldWithValidations(r,s,i);n.length>0?this.state.errors[t]=n:delete this.state.errors[t]}getActiveValidations(t){let e=[...t.validations||[]],a=["text","email","password","textarea"],r=t.skipInjectionValidation??t.props?.skipInjectionValidation;a.includes(t.type)&&!r&&!e.some(n=>n.type==="noInjection")&&(e=[{type:"noInjection"},...e]);let s=this.getFieldRequired(t.name),i=e.some(n=>n.type==="required");if(s&&!i?e=[{type:"required"},...e]:!s&&i&&(e=e.filter(n=>n.type!=="required")),t.conditionalValidations)for(let n of t.conditionalValidations)this.conditionEngine.evaluateConditions(n.condition,this.state.values)&&(e=[...e,...n.validations]);return e}async validateForm(){if(!this.schema)return{};let t=this.schema.isWizard?this.schema.steps.flatMap(r=>r.fields):this.schema.fields||[],e=this.extractAllFields(t),a=await this.validator.validateForm(e,this.state.values);return this.state.errors=a,this.updateValidity(),a}updateValidity(){this.state.isValid=Object.keys(this.state.errors).length===0}setTouched(t){this.state.touched[t]=!0}getErrors(t){return this.state.errors[t]||[]}getAllErrors(){return{...this.state.errors}}reset(){this.state=this.createInitialState(),this.schema&&(this.initializeValues(),this.initializeWizard())}nextStep(){return this.wizardState&&this.wizardState.currentStep<this.wizardState.totalSteps-1?(this.wizardState.currentStep++,!0):!1}previousStep(){return this.wizardState&&this.wizardState.currentStep>0?(this.wizardState.currentStep--,!0):!1}goToStep(t){return this.wizardState&&t>=0&&t<this.wizardState.totalSteps?(this.wizardState.currentStep=t,!0):!1}completeStep(t){this.wizardState&&(this.wizardState.completedSteps.includes(t)||this.wizardState.completedSteps.push(t))}setSubmitting(t){this.state.isSubmitting=t}getCurrentStepFields(){return!this.schema||!this.schema.isWizard||!this.wizardState?this.schema?.fields||[]:this.schema.steps[this.wizardState.currentStep].fields}getFieldVisibility(t){let e=this.dependencyCache.get(t);if(e!==void 0)return e.visible;if(!this.schema)return!0;let a=this.schema.isWizard?this.schema.steps.flatMap(p=>p.fields):this.schema.fields||[],r=this.extractAllFieldsWithArrays(a),s=r.find(p=>p.fullPath===t||p.field.name===t);if(!s){let p=t.replace(/\[\d+\]/g,"");s=r.find(u=>u.field.name===p||u.fullPath===p)}if(!s){let p=t.split(".").pop();s=r.find(u=>u.field.name===p)}if(!s||!s.field.dependencies)return!s?.field.hidden;let{field:i,containerType:n,containerPath:o}=s,d=s.field.dependencies,c={...this.state.values};if(n==="array"&&o){let p,u=g=>{if(g)return Array.isArray(g)?g[0]?.field:g.field};if(p=u(d.show)||u(d.hide)||u(d.enable)||u(d.disable)||u(d.required)||u(d.optional),p&&p){let g=t.match(/\[(\d+)\]/),f=g?parseInt(g[1],10):null,y=null;if(f!==null){let v=I(this.state.values,o);if(Array.isArray(v)&&v[f]&&(y=v[f][p]),y==null){let b=`${o}[${f}]`,w=this.state.values[b];w&&typeof w=="object"&&(y=w[p])}}else{let v=I(this.state.values,o);if(Array.isArray(v)){for(let b of v)if(b&&b[p]!==void 0){y=b[p];break}}}if(y!=null){let v={...this.state.values};v[p]=y;let b=this.conditionEngine.evaluateDependencies(d,v);return this.dependencyCache.set(t,b),b.visible&&!i.hidden}}let h={visible:!0,enabled:!0,required:!1};return this.dependencyCache.set(t,h),h.visible&&!i.hidden}else if(o){let p=I(this.state.values,o);if(p&&typeof p=="object"){let u=(g,f="")=>{let y={},v=Object.entries(g);for(let[b,w]of v){let E=f?`${f}.${b}`:b;w&&typeof w=="object"&&!Array.isArray(w)&&w!==null&&Object.assign(y,u(w,E))}for(let[b,w]of v){let E=f?`${f}.${b}`:b;w&&typeof w=="object"&&!Array.isArray(w)&&w!==null||E in y||(y[E]=w)}return y},h=u(p);c={...this.state.values,...h}}}let m=this.conditionEngine.evaluateDependencies(d,c);return this.dependencyCache.set(t,m),m.visible&&!i.hidden}getFieldEnabled(t){let e=this.dependencyCache.get(t);if(e!==void 0)return e.enabled;if(!this.schema)return!0;let a=this.schema.isWizard?this.schema.steps.flatMap(n=>n.fields):this.schema.fields||[],s=this.extractAllFields(a).find(n=>n.name===t);if(!s)return!0;if(s.disabled)return!1;if(!s.dependencies)return!0;let i=this.conditionEngine.evaluateDependencies(s.dependencies,this.state.values);return this.dependencyCache.set(t,i),i.enabled}getFieldRequired(t){let e=this.dependencyCache.get(t);if(e!==void 0)return e.required;if(!this.schema)return!1;let a=this.schema.isWizard?this.schema.steps.flatMap(o=>o.fields):this.schema.fields||[],s=this.extractAllFields(a).find(o=>o.name===t);if(!s)return!1;let i=s.validations?.some(o=>o.type==="required")||!1;if(!s.dependencies)return i;let n=this.conditionEngine.evaluateDependencies(s.dependencies,this.state.values);return this.dependencyCache.set(t,n),n.required||i}getDependentFields(t){return Array.from(this.fieldDependencies.get(t)||[])}};var x=class{constructor(t,e,a,r,s){this.field=t,this.value=e,this.error=a,this.onChange=r,this.onBlur=s}createInputWithSlots(t){let e=this.field.leadingIcon,a=this.field.trailingIcon;if(!e&&!a)return t;let r=document.createElement("div");if(r.className="easy-form-input-wrapper",e&&this.isSlotContentValid(e)){let i=this.renderSlotContent(e);i.className="easy-form-input-slot easy-form-input-slot-leading",r.appendChild(i)}let s=document.createElement("div");if(s.className="easy-form-input-core",s.appendChild(t),r.appendChild(s),a&&this.isSlotContentValid(a)){let i=this.renderSlotContent(a);i.className="easy-form-input-slot easy-form-input-slot-trailing",r.appendChild(i)}return r}isSlotContentValid(t){return t.type?t.type==="image"?!!t.src:t.type==="html"?!!t.html:!1:!1}renderSlotContent(t){let e=document.createElement("span");if(e.className="easy-form-input-slot-content",t.type==="image"&&t.src){let a=document.createElement("img");a.src=t.src,a.alt=t.alt??"",a.setAttribute("aria-hidden","true"),e.appendChild(a)}else t.type==="html"&&t.html&&(e.innerHTML=t.html);return e}createFieldContainer(t){let e=document.createElement("div"),r=Array.from(t.classList).filter(d=>d.startsWith("easy-form-")&&d!=="easy-form-field"&&(d.includes("-container")||d.includes("-wrapper"))),s=this.field.labelPosition??"up",i=this.createInputWithSlots(t);if(r.length>0?e.className=`easy-form-field easy-form-label-${s} ${r.join(" ")}`:e.className=`easy-form-field easy-form-label-${s}`,s==="none"&&this.field.label){let d=i.querySelector("input, textarea, select")||i;d instanceof HTMLElement&&d.setAttribute("aria-label",this.field.label)}let o=(()=>{if(!this.field.label||s==="none")return null;let d=document.createElement("label");if(d.className="easy-form-label",d.setAttribute("for",this.getFieldId()),d.textContent=this.field.label,this.field.validations?.some(c=>c.type==="required")){let c=document.createElement("span");c.className="easy-form-required",c.textContent=" *",d.appendChild(c)}return d})();if(s==="up")o&&e.appendChild(o),e.appendChild(i);else if(s==="down")e.appendChild(i),o&&e.appendChild(o);else if(s==="left"){let d=document.createElement("div");d.className="easy-form-field-inner easy-form-field-inner-horizontal",o&&d.appendChild(o),d.appendChild(i),e.appendChild(d)}else if(s==="right"){let d=document.createElement("div");d.className="easy-form-field-inner easy-form-field-inner-horizontal",d.appendChild(i),o&&d.appendChild(o),e.appendChild(d)}else e.appendChild(i);if(this.field.description){let d=document.createElement("p");d.className="easy-form-description",d.textContent=this.field.description,e.appendChild(d)}if(this.error){let d=document.createElement("p");d.className="easy-form-error",d.textContent=this.error,e.appendChild(d)}return e}getFieldId(){return`easy-form-${this.field.name}`}applyCommonProps(t){if(t.id=this.getFieldId(),t.setAttribute("name",this.field.name),this.field.disabled&&(t.setAttribute("disabled","true"),t.classList.add("easy-form-input-disabled")),this.field.hidden&&(t.style.display="none",t.classList.add("easy-form-field-hidden")),this.error&&t.classList.add("easy-form-input-error"),this.field.props)for(let[e,a]of Object.entries(this.field.props))(e.startsWith("data-")||e.startsWith("aria-"))&&t.setAttribute(e,String(a))}};function ft(l){let t=[];for(let e=0;e<l.length;e++){let a=l[e];switch(a){case"9":t.push({type:"digit",char:"9",editable:!0});break;case"a":case"A":t.push({type:"letter",char:a,editable:!0});break;case"*":t.push({type:"any",char:"*",editable:!0});break;default:t.push({type:"literal",char:a,editable:!1});break}}return t}function U(l,t){let e="",a=0;for(let r of t){if(!r.editable){e+=r.char;continue}if(a>=l.length)break;let s=l[a];if(!(r.type==="digit"&&!/\d/.test(s))){{if(r.type==="letter"&&!/[a-zA-Z]/.test(s))continue;if(r.type!=="any"){if(r.type!=="any"&&r.type!=="digit"&&r.type!=="letter")continue}}e+=s,a++}}return e}function qe(l,t){if(!l)return"";let e="",a=0;for(let r=0;r<l.length&&a<t.length;r++){let s=l[r],i=t[a];if(i.editable)i.type==="digit"&&/\d/.test(s)||i.type==="letter"&&/[a-zA-Z]/.test(s)||i.type==="any"?(e+=s,a++):(a++,r--);else if(s===i.char)a++;else if(a<t.length-1){let n=t[a+1];n&&n.editable&&(n.type==="digit"&&/\d/.test(s)||n.type==="letter"&&/[a-zA-Z]/.test(s)||n.type==="any")?(e+=s,a+=2):a++}else break}return e}function ae(l,t,e="forward"){if(e==="forward"){for(let a=l+1;a<t.length;a++)if(t[a].editable)return a;return t.length}else{for(let a=l-1;a>=0;a--)if(t[a].editable)return a;return 0}}function ht(l,t="_"){return l.map(e=>e.editable?t:e.char).join("")}function gt(l,t,e,a){let r=0;for(let i=0;i<Math.min(e,l.length);i++){let n=i;n<a.length&&a[n].editable&&r++}let s=0;for(let i=0;i<t.length&&i<a.length;i++)if(a[i].editable&&(s++,s>r))return i+1;return ae(Math.min(e,t.length-1),a,"forward")}var B=class{constructor(){this.tokenCache=new Map}getCustomMask(t){return t.custom?t.custom:t.type?$e(t.type):null}getTokens(t){let e=this.getCustomMask(t);if(!e)return null;let a=e.pattern;if(this.tokenCache.has(a))return this.tokenCache.get(a);let r=ft(e.pattern);return this.tokenCache.set(a,r),r}applyMask(t,e){let a=this.getTokens(e);if(!a)return t;let r=this.getCustomMask(e),s=a.filter(d=>d.editable),i=new Set(s.map(d=>d.type)),n="";for(let d of t)(i.has("any")||i.has("digit")&&/\d/.test(d)||i.has("letter")&&/[a-zA-Z]/.test(d))&&(n+=d);let o=U(n,a);return r.transform&&(o=r.transform(o),o=U(o,a)),o}removeMask(t,e){let a=this.getTokens(e);return a?qe(t,a):t}getMaskPlaceholder(t){let e=this.getTokens(t);if(!e)return"";let a=this.getCustomMask(t);return ht(e,a.placeholder||"_")}canInsertChar(t,e,a){let r=this.getTokens(a);if(!r||e>=r.length)return!1;let s=r[e];if(!s.editable)return!1;switch(s.type){case"digit":return/\d/.test(t);case"letter":return/[a-zA-Z]/.test(t);case"any":return!0;default:return!1}}processInput(t,e,a,r){let s=this.getTokens(a);if(!s)return{value:t,cursorPosition:t.length};let i=qe(t,s),n=U(i,s),o=this.getCustomMask(a);o.transform&&(n=o.transform(n),n=U(n,s));let d=gt(e,n,r,s);return{value:n,cursorPosition:Math.min(d,n.length)}}processKeyInput(t,e,a,r,s=!1){let i=this.getTokens(r);if(!i)return{value:e,cursorPosition:a};if(s){if(a===0)return{value:e,cursorPosition:0};let n=ae(a-1,i,"backward"),o=e.substring(0,n),d=e.substring(a),c=o+d,m=this.removeMask(c,r),p=this.applyMask(m,r),u=Math.max(0,n-1),h=ae(u,i,"forward");return{value:p,cursorPosition:h}}if(t.length===1&&this.canInsertChar(t,a,r)){let n=e.substring(0,a),o=e.substring(a),d=n+t+o;return this.processInput(d,e,r,a)}return{value:e,cursorPosition:a}}};var se=class extends x{constructor(e,a,r,s,i){super(e,a,r,s,i);this.maskEngine=null;this.previousValue="";e.mask&&(this.maskEngine=new B)}render(){let e=document.createElement("input");e.type=this.field.type==="email"?"email":this.field.type==="password"?"password":"text";let a=this.value??"";if(this.maskEngine&&this.field.mask&&(a&&(a=this.maskEngine.applyMask(String(a),this.field.mask)),this.previousValue=a),e.value=a,this.applyCommonProps(e),this.field.placeholder)e.placeholder=this.field.placeholder;else if(this.maskEngine&&this.field.mask){let r=this.maskEngine.getMaskPlaceholder(this.field.mask);r&&(e.placeholder=r)}return this.maskEngine&&this.field.mask?(e.addEventListener("input",r=>{let s=r.target,i=s.selectionStart||0,n=s.value,o=this.maskEngine.processInput(n,this.previousValue,this.field.mask,i);s.value=o.value,this.previousValue=o.value,setTimeout(()=>{s.setSelectionRange(o.cursorPosition,o.cursorPosition)},0);let d=this.field.mask.keepFormat?o.value:this.maskEngine.removeMask(o.value,this.field.mask);this.onChange(d)}),e.addEventListener("keydown",r=>{let s=r.target,i=s.selectionStart||0;if(r.key==="Backspace"||r.key==="Delete"){r.preventDefault();let n=r.key==="Backspace",o=this.maskEngine.processKeyInput("",s.value,i,this.field.mask,n);s.value=o.value,this.previousValue=o.value,setTimeout(()=>{s.setSelectionRange(o.cursorPosition,o.cursorPosition)},0);let d=this.field.mask.keepFormat?o.value:this.maskEngine.removeMask(o.value,this.field.mask);this.onChange(d)}}),e.addEventListener("paste",r=>{r.preventDefault();let s=(r.clipboardData||window.clipboardData).getData("text");if(s){let i=r.target,n=i.selectionStart||0,o=i.value.substring(0,n),d=i.value.substring(n),c=o+s+d,m=this.maskEngine.processInput(c,this.previousValue,this.field.mask,n);i.value=m.value,this.previousValue=m.value,setTimeout(()=>{i.setSelectionRange(m.cursorPosition,m.cursorPosition)},0);let p=this.field.mask.keepFormat?m.value:this.maskEngine.removeMask(m.value,this.field.mask);this.onChange(p)}})):e.addEventListener("input",r=>{let s=r.target;this.onChange(s.value)}),e.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(e)}};var ie=class extends x{constructor(e,a,r,s,i){super(e,a,r,s,i);this.maskEngine=null;this.previousValue="";e.mask&&(this.maskEngine=new B)}render(){let e=document.createElement("input");if(this.maskEngine&&this.field.mask){e.type="text";let r=this.value??"";r!==null&&r!==""&&(this.field.mask.type==="currency"?r=this.maskEngine.applyMask(String(r),this.field.mask):this.field.mask.type==="percentage"&&(r=this.maskEngine.applyMask(String(r),this.field.mask))),this.previousValue=r,e.value=r}else e.type="number",e.value=this.value??"";let a=this.field;if(!this.maskEngine&&e.type==="number"&&(a.min!==void 0&&(e.min=String(a.min)),a.max!==void 0&&(e.max=String(a.max)),a.step!==void 0&&(e.step=String(a.step))),this.applyCommonProps(e),this.field.placeholder)e.placeholder=this.field.placeholder;else if(this.maskEngine&&this.field.mask){let r=this.maskEngine.getMaskPlaceholder(this.field.mask);r&&(e.placeholder=r)}return this.maskEngine&&this.field.mask?(e.addEventListener("input",r=>{let s=r.target,i=s.selectionStart||0,n=s.value,o=this.maskEngine.processInput(n,this.previousValue,this.field.mask,i);s.value=o.value,this.previousValue=o.value,setTimeout(()=>{s.setSelectionRange(o.cursorPosition,o.cursorPosition)},0);let d=null;if(this.field.mask.type==="currency"){let c=this.maskEngine.removeMask(o.value,this.field.mask);d=c?parseFloat(c.replace(/[^\d.]/g,"")):null}else if(this.field.mask.type==="percentage"){let c=this.maskEngine.removeMask(o.value,this.field.mask);d=c?parseFloat(c):null}this.onChange(d)}),e.addEventListener("keydown",r=>{let s=r.target,i=s.selectionStart||0;if(r.key==="Backspace"||r.key==="Delete"){r.preventDefault();let n=r.key==="Backspace",o=this.maskEngine.processKeyInput("",s.value,i,this.field.mask,n);s.value=o.value,this.previousValue=o.value,setTimeout(()=>{s.setSelectionRange(o.cursorPosition,o.cursorPosition)},0);let d=null;if(this.field.mask.type==="currency"){let c=this.maskEngine.removeMask(o.value,this.field.mask);d=c?parseFloat(c.replace(/[^\d.]/g,"")):null}else if(this.field.mask.type==="percentage"){let c=this.maskEngine.removeMask(o.value,this.field.mask);d=c?parseFloat(c):null}this.onChange(d)}}),e.addEventListener("paste",r=>{r.preventDefault();let s=(r.clipboardData||window.clipboardData).getData("text");if(s){let i=r.target,n=i.selectionStart||0,o=i.value.substring(0,n),d=i.value.substring(n),c=o+s+d,m=this.maskEngine.processInput(c,this.previousValue,this.field.mask,n);i.value=m.value,this.previousValue=m.value,setTimeout(()=>{i.setSelectionRange(m.cursorPosition,m.cursorPosition)},0);let p=null;if(this.field.mask.type==="currency"){let u=this.maskEngine.removeMask(m.value,this.field.mask);p=u?parseFloat(u.replace(/[^\d.]/g,"")):null}else if(this.field.mask.type==="percentage"){let u=this.maskEngine.removeMask(m.value,this.field.mask);p=u?parseFloat(u):null}this.onChange(p)}})):e.addEventListener("input",r=>{let s=r.target,i=s.value===""?null:Number(s.value);this.onChange(i)}),e.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(e)}};var oe=class extends x{render(){let t=document.createElement("textarea");t.value=this.value??"",t.placeholder=this.field.placeholder||"";let e=this.field;return e.rows&&(t.rows=e.rows),e.cols&&(t.cols=e.cols),this.applyCommonProps(t),t.addEventListener("input",a=>{let r=a.target;this.onChange(r.value)}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var ne=class extends x{render(){let t=document.createElement("select"),e=this.field;if(e.multiple&&(t.multiple=!0),!e.multiple){let r=document.createElement("option");r.value="",r.textContent=e.placeholder||"Selecciona una opci\xF3n",r.setAttribute("data-placeholder",""),r.disabled=!0,t.appendChild(r)}for(let r of e.options){let s=document.createElement("option");typeof r=="string"?(s.value=r,s.textContent=r):(s.value=String(r.value),s.textContent=r.label),t.appendChild(s)}if(e.multiple&&Array.isArray(this.value))for(let r of t.options)r.selected=this.value.includes(r.value);else t.value=this.value??"";this.applyCommonProps(t);let a=()=>{!t.value?t.classList.add("easy-form-select-placeholder"):t.classList.remove("easy-form-select-placeholder")};return a(),t.addEventListener("change",r=>{let s=r.target;if(a(),e.multiple){let i=Array.from(s.selectedOptions).map(n=>n.value);this.onChange(i)}else this.onChange(s.value||null)}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var le=class extends x{render(){let t=document.createElement("input");t.type="checkbox",t.checked=!!this.value,this.applyCommonProps(t),t.addEventListener("change",r=>{let s=r.target;this.onChange(s.checked)}),t.addEventListener("blur",()=>{this.onBlur()});let e=document.createElement("div");e.className="easy-form-field";let a=document.createElement("label");if(a.className="easy-form-label-checkbox",a.setAttribute("for",this.getFieldId()),a.appendChild(t),this.field.label){let r=document.createTextNode(this.field.label);a.appendChild(r)}if(e.appendChild(a),this.field.description){let r=document.createElement("p");r.className="easy-form-description",r.textContent=this.field.description,e.appendChild(r)}if(this.error){let r=document.createElement("p");r.className="easy-form-error",r.textContent=this.error,e.appendChild(r)}return e}};var de=class extends x{render(){let t=document.createElement("div");if(t.className="easy-form-field",this.field.label){let r=document.createElement("label");if(r.className="easy-form-label",r.textContent=this.field.label,this.field.validations?.some(s=>s.type==="required")){let s=document.createElement("span");s.className="easy-form-required",s.textContent=" *",r.appendChild(s)}t.appendChild(r)}let e=document.createElement("div");e.className="easy-form-radio-group";let a=this.field;for(let r of a.options){let s=typeof r=="string"?r:r.value,i=typeof r=="string"?r:r.label,n=document.createElement("div");n.className="easy-form-radio-option";let o=document.createElement("input");o.type="radio",o.name=this.field.name,o.id=`${this.getFieldId()}-${s}`,o.value=String(s),o.checked=String(this.value)===String(s),this.field.disabled&&(o.disabled=!0);let d=document.createElement("label");d.setAttribute("for",o.id),d.textContent=i,d.className="easy-form-radio-label",o.addEventListener("change",()=>{this.onChange(s)}),o.addEventListener("blur",()=>{this.onBlur()}),n.appendChild(o),n.appendChild(d),e.appendChild(n)}if(t.appendChild(e),this.field.description){let r=document.createElement("p");r.className="easy-form-description",r.textContent=this.field.description,t.appendChild(r)}if(this.error){let r=document.createElement("p");r.className="easy-form-error",r.textContent=this.error,t.appendChild(r)}return t}};var ce=class extends x{render(){let t=document.createElement("input");t.type="checkbox",t.className="easy-form-switch",t.checked=!!this.value,this.applyCommonProps(t),t.addEventListener("change",r=>{let s=r.target;this.onChange(s.checked)}),t.addEventListener("blur",()=>{this.onBlur()});let e=document.createElement("div");e.className="easy-form-field";let a=document.createElement("label");if(a.className="easy-form-label-switch",a.setAttribute("for",this.getFieldId()),this.field.label){let r=document.createTextNode(this.field.label);a.appendChild(r)}if(a.appendChild(t),e.appendChild(a),this.field.description){let r=document.createElement("p");r.className="easy-form-description",r.textContent=this.field.description,e.appendChild(r)}if(this.error){let r=document.createElement("p");r.className="easy-form-error",r.textContent=this.error,e.appendChild(r)}return e}};var pe=class extends x{render(){let t=document.createElement("input");t.type="date";let e=this.field;if(e.min&&(t.min=e.min),e.max&&(t.max=e.max),this.value){let a=this.value instanceof Date?this.value.toISOString().split("T")[0]:String(this.value);t.value=a}return this.applyCommonProps(t),t.addEventListener("change",a=>{let r=a.target;this.onChange(r.value||null)}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var me=class extends x{render(){let t=document.createElement("input");t.type="file";let e=this.field;return e.accept&&(t.accept=e.accept),e.multiple&&(t.multiple=!0),this.applyCommonProps(t),t.addEventListener("change",a=>{let r=a.target;r.files&&(e.multiple?this.onChange(Array.from(r.files)):this.onChange(r.files[0]||null))}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var ue=class extends x{render(){let t=document.createElement("div");t.className="easy-form-quantity-container";let e=this.field,a=e.min??0,r=e.max??void 0,s=e.step??1,i=this.value??a,n=document.createElement("div");n.className="easy-form-quantity-wrapper";let o=document.createElement("button");o.type="button",o.className="easy-form-quantity-btn easy-form-quantity-decrement",o.textContent="\u2212",o.setAttribute("aria-label","Decrementar"),i<=a&&(o.disabled=!0,o.classList.add("disabled"));let d=document.createElement("input");d.type="number",d.value=String(i),d.min=String(a),r!==void 0&&(d.max=String(r)),d.step=String(s),d.className="easy-form-quantity-input",this.applyCommonProps(d);let c=document.createElement("button");c.type="button",c.className="easy-form-quantity-btn easy-form-quantity-increment",c.textContent="+",c.setAttribute("aria-label","Incrementar"),r!==void 0&&i>=r&&(c.disabled=!0,c.classList.add("disabled")),o.addEventListener("click",()=>{let p=Math.max(a,Number(d.value)-s);d.value=String(p),this.onChange(p),m()}),c.addEventListener("click",()=>{let p=r!==void 0?Math.min(r,Number(d.value)+s):Number(d.value)+s;d.value=String(p),this.onChange(p),m()}),d.addEventListener("input",p=>{let u=p.target,h=Number(u.value);isNaN(h)&&(h=a),h<a&&(h=a),r!==void 0&&h>r&&(h=r),u.value=String(h),this.onChange(h),m()}),d.addEventListener("blur",()=>{this.onBlur()});let m=()=>{let p=Number(d.value);o.disabled=p<=a,o.classList.toggle("disabled",p<=a),r!==void 0?(c.disabled=p>=r,c.classList.toggle("disabled",p>=r)):(c.disabled=!1,c.classList.remove("disabled"))};return n.appendChild(o),n.appendChild(d),n.appendChild(c),t.appendChild(n),this.createFieldContainer(t)}};var fe=class extends x{constructor(){super(...arguments);this.openAccordion=null}render(){let e=document.createElement("div");e.className="easy-form-accordion-select-container";let a=this.field,r=this.value??null;return a.options.forEach((s,i)=>{let n=typeof s=="string"?s:s.value,o=typeof s=="string"?s:s.label,d=typeof s=="object"&&"description"in s&&s.description?s.description:void 0,c=document.createElement("div");c.className="easy-form-accordion-item",c.setAttribute("data-value",String(n)),(r===n||Array.isArray(r)&&r.includes(n))&&(c.classList.add("selected"),a.multiple||(this.openAccordion=String(n)));let m=document.createElement("div");m.className="easy-form-accordion-header",m.setAttribute("role","button"),m.setAttribute("tabindex","0"),m.setAttribute("aria-expanded","false");let p=document.createElement("div");p.className="easy-form-accordion-header-content";let u=document.createElement("div");u.className="easy-form-accordion-indicator",a.multiple?(u.classList.add("checkbox"),Array.isArray(r)&&r.includes(n)&&u.classList.add("checked")):(u.classList.add("radio"),r===n&&u.classList.add("checked"));let h=document.createElement("span");h.className="easy-form-accordion-label",h.textContent=o;let g=document.createElement("span");g.className="easy-form-accordion-arrow",g.textContent="\u25BC",p.appendChild(u),p.appendChild(h),m.appendChild(p),m.appendChild(g);let f=document.createElement("div");if(f.className="easy-form-accordion-content",d){let b=document.createElement("p");b.className="easy-form-accordion-description",b.textContent=d,f.appendChild(b)}if(typeof s=="object"&&"content"in s&&s.content){let b=document.createElement("div");b.className="easy-form-accordion-custom-content",typeof s.content=="string"?b.innerHTML=s.content:s.content instanceof HTMLElement&&b.appendChild(s.content),f.appendChild(b)}c.appendChild(m),c.appendChild(f);let y=()=>{let b=c.classList.contains("open");a.multiple||e.querySelectorAll(".easy-form-accordion-item").forEach(w=>{if(w!==c){w.classList.remove("open");let E=w.querySelector(".easy-form-accordion-header"),k=w.querySelector(".easy-form-accordion-content"),F=w.querySelector(".easy-form-accordion-arrow");E&&E.setAttribute("aria-expanded","false"),k&&(k.style.maxHeight=null),F&&(F.style.transform="rotate(0deg)")}}),b?(c.classList.remove("open"),m.setAttribute("aria-expanded","false"),f.style.maxHeight=null,g.style.transform="rotate(0deg)",this.openAccordion=null):(c.classList.add("open"),m.setAttribute("aria-expanded","true"),f.style.maxHeight=f.scrollHeight+"px",g.style.transform="rotate(180deg)",this.openAccordion=String(n))},v=()=>{if(a.multiple){let b=Array.isArray(r)?[...r]:[],w=b.indexOf(n);w>-1?(b.splice(w,1),c.classList.remove("selected"),u.classList.remove("checked")):(b.push(n),c.classList.add("selected"),u.classList.add("checked")),this.onChange(b.length>0?b:null)}else e.querySelectorAll(".easy-form-accordion-item").forEach(b=>{b.classList.remove("selected");let w=b.querySelector(".easy-form-accordion-indicator");w&&w.classList.remove("checked")}),c.classList.add("selected"),u.classList.add("checked"),this.onChange(n)};m.addEventListener("click",b=>{b.stopPropagation(),v(),y()}),m.addEventListener("keydown",b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),v(),y())}),(r===n||Array.isArray(r)&&r.includes(n))&&(!a.multiple||a.autoExpand)&&setTimeout(()=>{c.classList.add("open"),m.setAttribute("aria-expanded","true"),f.style.maxHeight=f.scrollHeight+"px",g.style.transform="rotate(180deg)"},0),e.appendChild(c)}),this.createFieldContainer(e)}};var he=class extends x{render(){let t=document.createElement("div");t.className="easy-form-image-grid-container";let e=this.field,a=this.value??null,r=e.columns??3,s=e.imageSize??"medium";return t.style.gridTemplateColumns=`repeat(${r}, 1fr)`,t.style.gap=e.gap??"1rem",e.options.forEach(i=>{let n=typeof i=="string"?i:i.value,o=typeof i=="string"?i:i.label,d=typeof i=="object"&&"image"in i&&i.image?i.image:void 0,c=typeof i=="object"&&"description"in i&&i.description?i.description:void 0,m=document.createElement("div");m.className=`easy-form-image-grid-item easy-form-image-grid-${s}`,m.setAttribute("data-value",String(n)),m.setAttribute("role","button"),m.setAttribute("tabindex","0"),m.setAttribute("aria-label",o),(a===n||Array.isArray(a)&&a.includes(n))&&m.classList.add("selected");let p=document.createElement("div");if(p.className="easy-form-image-grid-image-container",d){let f=document.createElement("img");f.src=d,f.alt=o,f.className="easy-form-image-grid-image",p.appendChild(f)}else{let f=document.createElement("div");f.className="easy-form-image-grid-placeholder",f.textContent=o.charAt(0).toUpperCase(),p.appendChild(f)}let u=document.createElement("div");u.className="easy-form-image-grid-indicator",e.multiple?(u.classList.add("checkbox"),Array.isArray(a)&&a.includes(n)&&(u.classList.add("checked"),u.innerHTML="\u2713")):(u.classList.add("radio"),a===n&&(u.classList.add("checked"),u.innerHTML="\u25CF")),p.appendChild(u);let h=document.createElement("div");if(h.className="easy-form-image-grid-label",h.textContent=o,c){let f=document.createElement("div");f.className="easy-form-image-grid-description",f.textContent=c,m.appendChild(f)}m.appendChild(p),m.appendChild(h);let g=()=>{if(e.multiple){let f=Array.isArray(a)?[...a]:[],y=f.indexOf(n);y>-1?(f.splice(y,1),m.classList.remove("selected"),u.classList.remove("checked"),u.innerHTML=""):(f.push(n),m.classList.add("selected"),u.classList.add("checked"),u.innerHTML="\u2713"),this.onChange(f.length>0?f:null)}else t.querySelectorAll(".easy-form-image-grid-item").forEach(f=>{f.classList.remove("selected");let y=f.querySelector(".easy-form-image-grid-indicator");y&&(y.classList.remove("checked"),y.innerHTML="")}),m.classList.add("selected"),u.classList.add("checked"),u.innerHTML="\u25CF",this.onChange(n)};m.addEventListener("click",g),m.addEventListener("keydown",f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),g())}),m.addEventListener("blur",()=>{this.onBlur()}),t.appendChild(m)}),this.createFieldContainer(t)}};var ge=class extends x{constructor(){super(...arguments);this.inputs=[]}render(){let e=document.createElement("div");e.className="easy-form-otp-container";let r=this.field.length??6,s=this.value??"",i=String(s).padStart(r,"").slice(0,r);for(let n=0;n<r;n++){let o=document.createElement("input");o.type="text",o.inputMode="numeric",o.maxLength=1,o.className="easy-form-otp-input",o.setAttribute("aria-label",`C\xF3digo d\xEDgito ${n+1}`),i[n]&&(o.value=i[n]),this.applyCommonProps(o),o.id=`${this.getFieldId()}-${n}`;let d=n;o.addEventListener("input",c=>{let m=c.target,p=m.value.replace(/[^0-9]/g,"");m.value=p,p&&d<r-1&&this.inputs[d+1].focus(),this.updateOTPValue()}),o.addEventListener("keydown",c=>{let m=c.target;c.key==="Backspace"&&!m.value&&d>0&&(this.inputs[d-1].focus(),this.inputs[d-1].value="",this.updateOTPValue()),c.key==="ArrowLeft"&&d>0&&(c.preventDefault(),this.inputs[d-1].focus()),c.key==="ArrowRight"&&d<r-1&&(c.preventDefault(),this.inputs[d+1].focus())}),o.addEventListener("paste",c=>{c.preventDefault();let p=(c.clipboardData||window.clipboardData).getData("text").replace(/[^0-9]/g,"").slice(0,r);for(let h=0;h<p.length&&d+h<r;h++)this.inputs[d+h].value=p[h];let u=Math.min(d+p.length,r-1);this.inputs[u].focus(),this.updateOTPValue()}),o.addEventListener("focus",c=>{c.target.select()}),o.addEventListener("blur",()=>{this.onBlur()}),this.inputs.push(o),e.appendChild(o)}return this.createFieldContainer(e)}updateOTPValue(){let e=this.inputs.map(s=>s.value).join(""),a=this.field,r=e.length===this.inputs.length?e:null;a.numeric&&r?this.onChange(Number(r)):this.onChange(r)}};var Gt=6;function be(l){return l?'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>':'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>'}var ye=class extends x{constructor(){super(...arguments);this.inputs=[];this.visible=!1}get passwordField(){return this.field}render(){let e=this.passwordField,a=!!e.characterSeparated,r=a?typeof e.characterSeparated=="number"?e.characterSeparated:Gt:0;return a?this.createFieldContainer(this.renderSeparated(r)):this.createFieldContainer(this.renderSingle())}renderSingle(){let a=!!this.passwordField.showToggle,r=document.createElement("input");if(r.type="password",r.value=this.value??"",r.id=this.getFieldId(),this.applyCommonProps(r),this.field.placeholder&&(r.placeholder=this.field.placeholder),r.addEventListener("input",n=>{this.onChange(n.target.value)}),r.addEventListener("blur",()=>this.onBlur()),!a)return r;let s=document.createElement("div");s.className="easy-form-password-inner",r.classList.add("easy-form-password-input"),s.appendChild(r);let i=document.createElement("button");return i.type="button",i.className="easy-form-password-toggle",i.setAttribute("aria-label","Mostrar contrase\xF1a"),i.innerHTML=be(!1),i.addEventListener("click",()=>{this.visible=!this.visible,r.type=this.visible?"text":"password",i.setAttribute("aria-label",this.visible?"Ocultar contrase\xF1a":"Mostrar contrase\xF1a"),i.innerHTML=be(this.visible)}),s.appendChild(i),s}renderSeparated(e){let r=!!this.passwordField.showToggle,s=this.value??"",i=String(s).slice(0,e),n=document.createElement("div");n.className="easy-form-password-separated";for(let o=0;o<e;o++){let d=document.createElement("input");d.type="password",d.maxLength=1,d.className="easy-form-password-separated-input",d.setAttribute("aria-label",`Car\xE1cter ${o+1} de ${e}`),i[o]&&(d.value=i[o]),this.applyCommonProps(d),d.id=o===0?this.getFieldId():`${this.getFieldId()}-${o}`,o>0&&d.removeAttribute("name");let c=o;d.addEventListener("input",m=>{m.target.value&&c<e-1&&this.inputs[c+1].focus(),this.updateSeparatedValue()}),d.addEventListener("keydown",m=>{m.key==="Backspace"&&!m.target.value&&c>0&&(this.inputs[c-1].focus(),this.inputs[c-1].value="",this.updateSeparatedValue()),m.key==="ArrowLeft"&&c>0&&(m.preventDefault(),this.inputs[c-1].focus()),m.key==="ArrowRight"&&c<e-1&&(m.preventDefault(),this.inputs[c+1].focus())}),d.addEventListener("paste",m=>{m.preventDefault();let u=((m.clipboardData||window.clipboardData)?.getData("text")||"").slice(0,e-c).split("");for(let g=0;g<u.length&&c+g<e;g++)this.inputs[c+g].value=u[g];let h=Math.min(c+u.length,e-1);this.inputs[h].focus(),this.updateSeparatedValue()}),d.addEventListener("focus",m=>m.target.select()),d.addEventListener("blur",()=>this.onBlur()),this.inputs.push(d),n.appendChild(d)}if(r){let o=document.createElement("div");o.className="easy-form-password-separated-toggle";let d=document.createElement("button");d.type="button",d.className="easy-form-password-toggle",d.setAttribute("aria-label","Mostrar contrase\xF1a"),d.innerHTML=be(!1),d.addEventListener("click",()=>{this.visible=!this.visible;let c=this.visible?"text":"password";this.inputs.forEach(m=>{m.type=c}),d.setAttribute("aria-label",this.visible?"Ocultar contrase\xF1a":"Mostrar contrase\xF1a"),d.innerHTML=be(this.visible)}),o.appendChild(d),n.appendChild(o)}return n}updateSeparatedValue(){let e=this.inputs.map(a=>a.value).join("");this.onChange(e||null)}};var ve=class extends x{render(){let t=this.field,e=t.accept??"",a=t.multiple??!1,r=document.createElement("div");r.className="easy-form-file-drop",r.setAttribute("tabindex","0");let s=document.createElement("input");s.type="file",s.className="easy-form-file-drop-input",s.style.display="none",e&&(s.accept=e),a&&(s.multiple=!0);let i=document.createElement("span");i.className="easy-form-file-drop-label",i.textContent="Arrastra archivos aqu\xED o haz clic para seleccionar",r.appendChild(i),r.appendChild(s);let n=document.createElement("div");n.className="easy-form-file-drop-list";let o=c=>{let m=c?Array.isArray(c)?c.map(p=>p.name):[c.name]:[];if(n.innerHTML="",m.length===0){n.style.display="none";return}n.style.display="block",m.forEach(p=>{let u=document.createElement("div");u.className="easy-form-file-drop-item",u.textContent=p,n.appendChild(u)})};o(this.value);let d=c=>{if(!c||c.length===0)return;let m=a?Array.from(c):c[0];this.onChange(m),this.onBlur(),o(m)};return r.addEventListener("click",()=>{s.click()}),s.addEventListener("change",c=>{let m=c.target;d(m.files),m.value=""}),r.addEventListener("dragover",c=>{c.preventDefault(),c.stopPropagation(),r.classList.add("easy-form-file-drop-over")}),r.addEventListener("dragleave",c=>{c.preventDefault(),c.stopPropagation(),r.classList.remove("easy-form-file-drop-over")}),r.addEventListener("drop",c=>{c.preventDefault(),c.stopPropagation(),r.classList.remove("easy-form-file-drop-over"),d(c.dataTransfer?.files??null)}),r.appendChild(n),this.createFieldContainer(r)}};var Kt="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css",xe=class extends x{constructor(){super(...arguments);this.mapInstance=null;this.markerInstance=null}render(){let e=this.field,a=e.center??{lat:0,lng:0},r=e.zoom??13,s=this.value,i=typeof s=="object"&&s?.lat!=null?s.lat:a.lat,n=typeof s=="object"&&s?.lng!=null?s.lng:a.lng,o=document.createElement("div");o.className="easy-form-map";let d=document.createElement("div");d.className="easy-form-map-inputs";let c=document.createElement("input");c.type="number",c.step="any",c.placeholder="Latitud",c.value=String(i),c.className="easy-form-map-lat";let m=document.createElement("input");m.type="number",m.step="any",m.placeholder="Longitud",m.value=String(n),m.className="easy-form-map-lng";let p=()=>{let v=parseFloat(c.value),b=parseFloat(m.value);!isNaN(v)&&!isNaN(b)&&(this.onChange({lat:v,lng:b}),this.syncMarkerPosition(v,b)),this.onBlur()};c.addEventListener("change",p),m.addEventListener("change",p),d.appendChild(c),d.appendChild(m),o.appendChild(d);let u=document.createElement("div");u.className="easy-form-map-container",o.appendChild(u);let h="easy-form-leaflet-css",g=!1,f=document.createElement("link");return f.id=h,f.rel="stylesheet",f.href=Kt,f.onload=()=>{g=!0},o.insertBefore(f,o.firstChild),(async()=>{if(typeof window>"u")return;u.style.height="300px",u.style.width="100%",u.style.position="relative",u.style.overflow="hidden",u.style.display="block",await new Promise(k=>{let F=()=>{g&&u.offsetWidth>0&&u.offsetHeight>0?k(void 0):requestAnimationFrame(F)};F()}),await new Promise(k=>setTimeout(k,50));let v;try{v=await import("leaflet")}catch{u.innerHTML=`
2770
+ `}function X(l,t){let e=et(t),a=Zt(l,t);return e+a}function Zt(l,t){switch(l){case"plano":return $e(t);case"tradicional":return tt(t);case"material":return rt(t);case"rounded-shadow":return at(t);case"lines":return st(t);case"shadcn":return it(t);case"chakra":return ot(t);case"mantine":return nt(t);case"glass":return lt(t);case"bordered":return dt(t);case"minimal":return ct(t);case"efc":return pt(t);default:return $e(t)}}var mt={phone:{pattern:"(999) 999-9999",placeholder:"_"},"phone-us":{pattern:"(999) 999-9999",placeholder:"_"},"phone-international":{pattern:"+99 999 999 9999",placeholder:"_"},date:{pattern:"99/99/9999",placeholder:"_"},"date-us":{pattern:"99/99/9999",placeholder:"_"},"date-eu":{pattern:"99-99-9999",placeholder:"_"},"credit-card":{pattern:"9999 9999 9999 9999",placeholder:"_"},ssn:{pattern:"999-99-9999",placeholder:"_"},"zip-code":{pattern:"99999",placeholder:"_"},currency:{pattern:"$999,999.99",placeholder:"_",transform:l=>{let t=l.replace(/[^\d.]/g,"");return(parseFloat(t)||0).toFixed(2)}},percentage:{pattern:"999%",placeholder:"_",transform:l=>l.replace(/[^\d]/g,"")},time:{pattern:"99:99",placeholder:"_"},datetime:{pattern:"99/99/9999 99:99",placeholder:"_"}};function qe(l){return mt[l]}var ee="El valor contiene caracteres o patrones no permitidos",Gt=[/\b(union|select|insert|update|delete|drop|exec|execute|declare)\s+(all\s+)?(select|from|into|table)/i,/\b(or|and)\s+['"]?\d+['"]?\s*=\s*['"]?\d+/i,/;\s*(drop|delete|truncate|alter)\s+/i,/--\s*$/,/\/\*[\s\S]*\*\//,/'\s*or\s+'1'\s*=\s*'1/i,/"\s*or\s+"1"\s*=\s*"1/i,/\bexec\s*\(/i,/\bxp_\w+/i,/<script\b[\s\S]*?>[\s\S]*?<\/script>/i,/<script\b/i,/javascript\s*:/i,/vbscript\s*:/i,/on\w+\s*=\s*["'][^"']*["']/i,/on\w+\s*=\s*[^\s>]+/i,/<iframe\b/i,/<object\b/i,/<embed\b/i,/\beval\s*\(/i,/document\.(cookie|write|location)/i,/window\.(location|open|eval)/i,/[;&|]\s*(ls|cat|rm|wget|curl|nc|bash|sh|python|perl)\s/i,/\$\s*\([^)]+\)/,/`[^`]+`/,/\|\s*\w+/,/\$\s*where\b/i,/\$\s*gt\b|\$\s*ne\b|\$\s*regex\b/i,/\{\{[^}]*\}\}/,/\$\{[^}]*\}/];function ut(l){if(typeof l!="string"||l.length===0||l.trim().length===0)return!1;for(let e of Gt)if(e.test(l))return!0;return!1}function j(l){return l==null?!0:typeof l=="string"?!ut(l):Array.isArray(l)?l.every(t=>j(t)):typeof l=="object"?Object.values(l).every(t=>j(t)):!0}var W=class{constructor(t){this.attempts=0;this.lockedUntil=null;this.unlockCheckInterval=null;this.maxAttempts=Math.max(1,t.maxAttempts),this.blockDurationMs=(t.blockDurationMinutes??5)*60*1e3,this.storageKey=t.storageKey,this.onLocked=t.onLocked,this.onUnlocked=t.onUnlocked,this.storageKey&&typeof sessionStorage<"u"&&this.loadFromStorage()}loadFromStorage(){if(!(!this.storageKey||typeof sessionStorage>"u"))try{let t=sessionStorage.getItem(this.storageKey);if(t){let e=JSON.parse(t);this.attempts=e.attempts??0,this.lockedUntil=e.lockedUntil??null,this.checkExpiration()}}catch{}}saveToStorage(){if(!(!this.storageKey||typeof sessionStorage>"u"))try{let t={attempts:this.attempts,lockedUntil:this.lockedUntil??void 0};sessionStorage.setItem(this.storageKey,JSON.stringify(t))}catch{}}checkExpiration(){return this.lockedUntil===null?!1:Date.now()>=this.lockedUntil?(this.reset(),this.onUnlocked?.(),!0):!1}startUnlockCheck(){this.unlockCheckInterval||(this.unlockCheckInterval=setInterval(()=>{this.checkExpiration()&&this.stopUnlockCheck()},1e3))}stopUnlockCheck(){this.unlockCheckInterval&&(clearInterval(this.unlockCheckInterval),this.unlockCheckInterval=null)}incrementAttempts(){this.attempts++,this.attempts>=this.maxAttempts?(this.lockedUntil=Date.now()+this.blockDurationMs,this.saveToStorage(),this.onLocked?.(this.blockDurationMs),this.startUnlockCheck()):this.saveToStorage()}isLocked(){return this.checkExpiration()?!1:this.lockedUntil!==null&&Date.now()<this.lockedUntil}getRemainingBlockTimeMs(){return this.checkExpiration()||this.lockedUntil===null?0:Math.max(0,this.lockedUntil-Date.now())}reset(){this.attempts=0,this.lockedUntil=null,this.stopUnlockCheck(),this.saveToStorage()}getAttempts(){return this.attempts}};function D(l){return l==null?"":typeof l=="boolean"?l?"true":"false":typeof l=="object"?JSON.stringify(l):String(l)}function q(l){if(!l)return null;try{return JSON.parse(l)}catch{return l}}function I(l,t){return t.split(".").reduce((e,a)=>e?.[a],l)}function V(l,t,e){let a=t.split("."),r=a.pop(),s=a.reduce((i,n)=>((!i[n]||typeof i[n]!="object")&&(i[n]={}),i[n]),l);s[r]=e}function ft(l){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(l)}var H=class{evaluateCondition(t,e){let a=this.getFieldValue(t.field,e);return this.compareValues(a,t.operator,t.value)}evaluateConditions(t,e,a="and"){let r=Array.isArray(t)?t:[t];return r.length===0?!0:a==="and"?r.every(s=>this.evaluateCondition(s,e)):r.some(s=>this.evaluateCondition(s,e))}evaluateDependencies(t,e){let a=!0,r=!0,s=!1;if(t.show&&(a=this.evaluateConditions(t.show,e)),t.hide){let i=this.evaluateConditions(t.hide,e);a=a&&!i}if(t.enable&&(r=this.evaluateConditions(t.enable,e)),t.disable){let i=this.evaluateConditions(t.disable,e);r=r&&!i}if(t.required&&(s=this.evaluateConditions(t.required,e)),t.optional){let i=this.evaluateConditions(t.optional,e);s=s&&!i}return{visible:a,enabled:r,required:s}}getFieldValue(t,e){if(t in e)return e[t];let a=t.split("."),r=e;for(let s of a){if(r==null)return null;r=r[s]}return r}compareValues(t,e,a){switch(e){case"equals":return this.deepEqual(t,a);case"notEquals":return!this.deepEqual(t,a);case"contains":return Array.isArray(t)?t.includes(a):typeof t=="string"?t.includes(String(a)):!1;case"notContains":return!this.compareValues(t,"contains",a);case"greaterThan":return this.toNumber(t)>this.toNumber(a);case"lessThan":return this.toNumber(t)<this.toNumber(a);case"greaterThanOrEqual":return this.toNumber(t)>=this.toNumber(a);case"lessThanOrEqual":return this.toNumber(t)<=this.toNumber(a);case"in":return Array.isArray(a)?a.includes(t):!1;case"notIn":return!this.compareValues(t,"in",a);case"isEmpty":return t==null||t===""||Array.isArray(t)&&t.length===0;case"isNotEmpty":return!this.compareValues(t,"isEmpty",a);case"regex":try{return(typeof a=="string"?new RegExp(a):a).test(String(t||""))}catch{return!1}default:return!1}}deepEqual(t,e){if(t===e)return!0;if(t===null||e===null||t===void 0||e===void 0)return t===e;if(typeof t!=typeof e)return!1;if(Array.isArray(t)&&Array.isArray(e))return t.length!==e.length?!1:t.every((a,r)=>this.deepEqual(a,e[r]));if(typeof t=="object"){let a=Object.keys(t),r=Object.keys(e);return a.length!==r.length?!1:a.every(s=>this.deepEqual(t[s],e[s]))}return!1}toNumber(t){if(typeof t=="number")return t;if(typeof t=="string"){let e=parseFloat(t);return isNaN(e)?0:e}return 0}};var te=class{constructor(){this.conditionEngine=new H}async validateField(t,e){return this.validateFieldWithValidations(t,e,t.validations||[])}async validateFieldWithValidations(t,e,a){let r=[];if(!a||a.length===0)return r;for(let s of a){let i=await this.validateValue(s,e);i.isValid||r.push(i.message||this.getDefaultMessage(s))}return r}async validateValue(t,e){switch(t.type){case"required":return this.validateRequired(e);case"email":return this.validateEmail(e);case"minLength":return this.validateMinLength(e,t.value);case"maxLength":return this.validateMaxLength(e,t.value);case"min":return this.validateMin(e,t.value);case"max":return this.validateMax(e,t.value);case"pattern":return this.validatePattern(e,t.value);case"custom":return await this.validateCustom(e,t);case"noInjection":return this.validateNoInjection(e,t);default:return{isValid:!0}}}validateRequired(t){let e=t!=null&&t!==""&&!(Array.isArray(t)&&t.length===0);return{isValid:e,message:e?void 0:"Este campo es requerido"}}validateEmail(t){if(!t)return{isValid:!0};let e=typeof t=="string"&&ft(t);return{isValid:e,message:e?void 0:"Debe ser un email v\xE1lido"}}validateMinLength(t,e){if(!t)return{isValid:!0};let r=String(t).length>=e;return{isValid:r,message:r?void 0:`Debe tener al menos ${e} caracteres`}}validateMaxLength(t,e){if(!t)return{isValid:!0};let r=String(t).length<=e;return{isValid:r,message:r?void 0:`Debe tener m\xE1ximo ${e} caracteres`}}validateMin(t,e){if(t==null||t==="")return{isValid:!0};let a=Number(t),r=!isNaN(a)&&a>=e;return{isValid:r,message:r?void 0:`Debe ser mayor o igual a ${e}`}}validateMax(t,e){if(t==null||t==="")return{isValid:!0};let a=Number(t),r=!isNaN(a)&&a<=e;return{isValid:r,message:r?void 0:`Debe ser menor o igual a ${e}`}}validatePattern(t,e){if(!t)return{isValid:!0};let a;if(e instanceof RegExp)a=e;else if(typeof e=="string")try{a=new RegExp(e)}catch{return console.warn("Invalid regex pattern:",e),{isValid:!0}}else return console.warn("Pattern validation expects string or RegExp, got:",typeof e,e),{isValid:!0};let r=a.test(String(t));return{isValid:r,message:r?void 0:"El formato no es v\xE1lido"}}validateNoInjection(t,e){if(t==null||t==="")return{isValid:!0};let a=j(t);return{isValid:a,message:a?void 0:e.message||ee}}async validateCustom(t,e){try{let a=await e.validator(t);return{isValid:!!a,message:a?void 0:e.message||"Validaci\xF3n fallida"}}catch{return{isValid:!1,message:e.message||"Error en la validaci\xF3n"}}}getDefaultMessage(t){switch(t.type){case"required":return"Este campo es requerido";case"email":return"Debe ser un email v\xE1lido";case"minLength":return`Debe tener al menos ${t.value} caracteres`;case"maxLength":return`Debe tener m\xE1ximo ${t.value} caracteres`;case"min":return`Debe ser mayor o igual a ${t.value}`;case"max":return`Debe ser menor o igual a ${t.value}`;case"pattern":return"El formato no es v\xE1lido";case"custom":return"Validaci\xF3n fallida";case"noInjection":return ee;default:return"Campo inv\xE1lido"}}shouldValidateField(t,e){if(t.hidden||t.disabled)return!1;if(t.dependencies){let a=this.conditionEngine.evaluateDependencies(t.dependencies,e);if(!a.visible||!a.enabled)return!1}return!0}async validateForm(t,e){let a={};for(let r of t)if(this.shouldValidateField(r,e))if(r.type==="array"&&"itemSchema"in r){let n=r.itemSchema?.fields||[],o=e[r.name];if(Array.isArray(o))for(let c=0;c<o.length;c++){let m=o[c];for(let p of n){let u=`${r.name}.${c}.${p.name}`,h=m?.[p.name];if(!this.shouldValidateField(p,e))continue;let g=await this.validateField(p,h);g.length>0&&(a[u]=g)}}let d=await this.validateArrayField(r,o);d.length>0&&(a[r.name]=d)}else{let s=e[r.name],i=await this.validateField(r,s);i.length>0&&(a[r.name]=i)}return a}async validateArrayField(t,e){let a=[],r=t;return r.minItems!==void 0&&(Array.isArray(e)&&e.length>=r.minItems||a.push(`Debe tener al menos ${r.minItems} elementos`)),r.maxItems!==void 0&&(Array.isArray(e)&&e.length<=r.maxItems||a.push(`Debe tener m\xE1ximo ${r.maxItems} elementos`)),a}};var re=class{constructor(){this.wizardState=null;this.schema=null;this.dependencyCache=new Map;this.fieldDependencies=new Map;this.parser=new J,this.validator=new te,this.conditionEngine=new H,this.state=this.createInitialState()}createInitialState(){return{values:{},errors:{},touched:{},isValid:!0,isSubmitting:!1}}initializeSchema(t,e){this.schema=this.parser.parse(t),this.initializeValues(e),this.initializeWizard(),this.buildDependencyMap()}extractAllFields(t){let e=[];for(let a of t)e.push(a),a.type==="group"&&"fields"in a&&e.push(...this.extractAllFields(a.fields)),a.type==="row"&&"fields"in a&&e.push(...this.extractAllFields(a.fields));return e}getArrayItemOnlyFieldNames(t){let e=new Set(t.map(r=>r.name)),a=new Set;for(let r of t)if(r.type==="array"&&"itemSchema"in r&&r.itemSchema?.fields)for(let s of r.itemSchema.fields)e.has(s.name)||a.add(s.name);return a}extractAllFieldsWithArrays(t,e="",a="root"){let r=[];for(let s of t){let i=e?`${e}.${s.name}`:s.name,n=e||"";r.push({field:s,fullPath:i,containerType:a,containerPath:n}),s.type==="group"&&"fields"in s&&r.push(...this.extractAllFieldsWithArrays(s.fields,i,"group")),s.type==="row"&&"fields"in s&&r.push(...this.extractAllFieldsWithArrays(s.fields,i,"row")),s.type==="array"&&"itemSchema"in s&&s.itemSchema?.fields&&r.push(...this.extractAllFieldsWithArrays(s.itemSchema.fields,s.name,"array"))}return r}buildDependencyMap(){if(this.fieldDependencies.clear(),this.dependencyCache.clear(),!this.schema)return;let t=this.schema.isWizard?this.schema.steps.flatMap(a=>a.fields):this.schema.fields||[],e=this.extractAllFieldsWithArrays(t);for(let{field:a,fullPath:r,containerType:s,containerPath:i}of e){if(!a.dependencies)continue;let n=this.extractObservedFields(a.dependencies);for(let o of n)this.fieldDependencies.has(o)||this.fieldDependencies.set(o,new Set),this.fieldDependencies.get(o).add(a.name),r!==a.name&&this.fieldDependencies.get(o).add(r),s==="array"&&i&&(this.fieldDependencies.has(i)||this.fieldDependencies.set(i,new Set),this.fieldDependencies.get(i).add(r))}}extractObservedFields(t){let e=new Set,a=s=>{s&&s.field&&e.add(s.field)},r=s=>{Array.isArray(s)?s.forEach(a):s&&a(s)};return t.show&&r(t.show),t.hide&&r(t.hide),t.enable&&r(t.enable),t.disable&&r(t.disable),t.required&&r(t.required),t.optional&&r(t.optional),e}initializeValues(t){if(!this.schema)return;let e=this.schema.isWizard?this.schema.steps.flatMap(n=>n.fields):this.schema.fields||[],a=this.extractAllFields(e),r={...this.state.values},s={};if(t)for(let n in t){let o=t[n];o!=null&&V(s,n,o)}for(let n of a){let o=I(s,n.name);if(o!=null)continue;let d=I(r,n.name);d!=null?V(s,n.name,d):this.initializeFieldValue(n,s)}let i=this.getArrayItemOnlyFieldNames(e);for(let n in r)i.has(n)||n in s||(s[n]=r[n]);for(let n of e)if(n.type==="array"&&"minItems"in n&&"itemSchema"in n){let o=n,d=o.minItems??0;if(d>=1&&o.itemSchema?.fields?.length){let c=I(s,n.name);if(Array.isArray(c)&&c.length<d){let m=[...c];for(let p=c.length;p<d;p++){let u={};for(let h of o.itemSchema.fields)this.initializeFieldValue(h,u);m.push(u)}V(s,n.name,m)}}}for(let n of i)n in s&&delete s[n];this.state.values=s}initializeFieldValue(t,e){if(t.defaultValue!==void 0)e[t.name]=t.defaultValue;else switch(t.type){case"checkbox":case"switch":e[t.name]=t.checked||!1;break;case"select":"multiple"in t&&t.multiple?e[t.name]=[]:e[t.name]=null;break;case"array":{let a=t,r=a.minItems??0,s=a.itemSchema?.fields;if(r>=1&&s?.length){let i=[];for(let n=0;n<r;n++){let o={};for(let d of s)this.initializeFieldValue(d,o);i.push(o)}e[t.name]=i}else e[t.name]=[];break}case"group":if(e[t.name]={},"fields"in t)for(let a of t.fields)this.initializeFieldValue(a,e[t.name]);break;case"colorpicker":e[t.name]=t.defaultValue??"#000000";break;default:e[t.name]=null}}initializeWizard(){if(!this.schema||!this.schema.isWizard){this.wizardState=null;return}this.wizardState={currentStep:0,totalSteps:this.schema.steps.length,completedSteps:[]}}getState(){return{...this.state}}getWizardState(){return this.wizardState?{...this.wizardState}:null}getValue(t){return I(this.state.values,t)}createDefaultArrayItem(t){let a=t.itemSchema?.fields;if(!a?.length)return{};let r={};for(let s of a)this.initializeFieldValue(s,r);return r}async setValue(t,e){V(this.state.values,t,e),this.state.touched[t]=!0,this.invalidateDependencyCache(t),this.state.touched[t]&&this.schema&&await this.validateField(t);let a=this.fieldDependencies.get(t);if(a)for(let r of a)await this.validateField(r);this.updateValidity()}invalidateDependencyCache(t){let e=this.fieldDependencies.get(t);if(e)for(let s of e){this.dependencyCache.delete(s);let i=this.addArrayIndexToPath(t,s);i&&this.dependencyCache.delete(i)}let a=t.replace(/\[\d+\]/g,"");if(a!==t){if(e=this.fieldDependencies.get(a),e)for(let i of e){this.dependencyCache.delete(i);let n=t.match(/\[(\d+)\]/);if(n){let o=i.includes("[")?i:`${i.split(".").slice(0,-1).join(".")}[${n[1]}].${i.split(".").pop()}`;this.dependencyCache.delete(o)}}let s=a.split(".").pop();if(s&&s!==a&&(e=this.fieldDependencies.get(s),e))for(let i of e){this.dependencyCache.delete(i);let n=t.match(/\[(\d+)\]/);if(n){let d=`${t.split(".")[0].replace(/\[\d+\]/,"")}[${n[1]}].${i}`;this.dependencyCache.delete(d)}}}let r=t.split(".");for(let s=1;s<r.length;s++){if(r[s].includes("["))continue;let i=r.slice(s).join(".");if(e=this.fieldDependencies.get(i),e)for(let n of e)this.dependencyCache.delete(n),this.dependencyCache.delete(`${r[0]}.${i}`)}this.dependencyCache.delete(t)}addArrayIndexToPath(t,e){let a=t.match(/\[(\d+)\]/);if(!a)return null;let r=a[1],s=t.split(".")[0];if(e.startsWith(s)){let i=e.split(".");if(i.length>1)return`${i[0]}[${r}].${i.slice(1).join(".")}`}return null}setValueWithoutValidation(t,e){V(this.state.values,t,e),this.invalidateDependencyCache(t)}async validateField(t){if(!this.schema)return;let e=this.schema.isWizard?this.schema.steps.flatMap(o=>o.fields):this.schema.fields||[],r=this.extractAllFields(e).find(o=>o.name===t);if(!r)return;if(!this.getFieldVisibility(t)){delete this.state.errors[t];return}let s=this.getValue(t),i=this.getActiveValidations(r),n=await this.validator.validateFieldWithValidations(r,s,i);n.length>0?this.state.errors[t]=n:delete this.state.errors[t]}getActiveValidations(t){let e=[...t.validations||[]],a=["text","email","password","textarea"],r=t.skipInjectionValidation??t.props?.skipInjectionValidation;a.includes(t.type)&&!r&&!e.some(n=>n.type==="noInjection")&&(e=[{type:"noInjection"},...e]);let s=this.getFieldRequired(t.name),i=e.some(n=>n.type==="required");if(s&&!i?e=[{type:"required"},...e]:!s&&i&&(e=e.filter(n=>n.type!=="required")),t.conditionalValidations)for(let n of t.conditionalValidations)this.conditionEngine.evaluateConditions(n.condition,this.state.values)&&(e=[...e,...n.validations]);return e}async validateForm(){if(!this.schema)return{};let t=this.schema.isWizard?this.schema.steps.flatMap(r=>r.fields):this.schema.fields||[],e=this.extractAllFields(t),a=await this.validator.validateForm(e,this.state.values);return this.state.errors=a,this.updateValidity(),a}updateValidity(){this.state.isValid=Object.keys(this.state.errors).length===0}setTouched(t){this.state.touched[t]=!0}getErrors(t){return this.state.errors[t]||[]}getAllErrors(){return{...this.state.errors}}reset(){this.state=this.createInitialState(),this.schema&&(this.initializeValues(),this.initializeWizard())}nextStep(){return this.wizardState&&this.wizardState.currentStep<this.wizardState.totalSteps-1?(this.wizardState.currentStep++,!0):!1}previousStep(){return this.wizardState&&this.wizardState.currentStep>0?(this.wizardState.currentStep--,!0):!1}goToStep(t){return this.wizardState&&t>=0&&t<this.wizardState.totalSteps?(this.wizardState.currentStep=t,!0):!1}completeStep(t){this.wizardState&&(this.wizardState.completedSteps.includes(t)||this.wizardState.completedSteps.push(t))}setSubmitting(t){this.state.isSubmitting=t}getCurrentStepFields(){return!this.schema||!this.schema.isWizard||!this.wizardState?this.schema?.fields||[]:this.schema.steps[this.wizardState.currentStep].fields}getFieldVisibility(t){let e=this.dependencyCache.get(t);if(e!==void 0)return e.visible;if(!this.schema)return!0;let a=this.schema.isWizard?this.schema.steps.flatMap(p=>p.fields):this.schema.fields||[],r=this.extractAllFieldsWithArrays(a),s=r.find(p=>p.fullPath===t||p.field.name===t);if(!s){let p=t.replace(/\[\d+\]/g,"");s=r.find(u=>u.field.name===p||u.fullPath===p)}if(!s){let p=t.split(".").pop();s=r.find(u=>u.field.name===p)}if(!s||!s.field.dependencies)return!s?.field.hidden;let{field:i,containerType:n,containerPath:o}=s,d=s.field.dependencies,c={...this.state.values};if(n==="array"&&o){let p,u=g=>{if(g)return Array.isArray(g)?g[0]?.field:g.field};if(p=u(d.show)||u(d.hide)||u(d.enable)||u(d.disable)||u(d.required)||u(d.optional),p&&p){let g=t.match(/\[(\d+)\]/),f=g?parseInt(g[1],10):null,y=null;if(f!==null){let v=I(this.state.values,o);if(Array.isArray(v)&&v[f]&&(y=v[f][p]),y==null){let b=`${o}[${f}]`,w=this.state.values[b];w&&typeof w=="object"&&(y=w[p])}}else{let v=I(this.state.values,o);if(Array.isArray(v)){for(let b of v)if(b&&b[p]!==void 0){y=b[p];break}}}if(y!=null){let v={...this.state.values};v[p]=y;let b=this.conditionEngine.evaluateDependencies(d,v);return this.dependencyCache.set(t,b),b.visible&&!i.hidden}}let h={visible:!0,enabled:!0,required:!1};return this.dependencyCache.set(t,h),h.visible&&!i.hidden}else if(o){let p=I(this.state.values,o);if(p&&typeof p=="object"){let u=(g,f="")=>{let y={},v=Object.entries(g);for(let[b,w]of v){let E=f?`${f}.${b}`:b;w&&typeof w=="object"&&!Array.isArray(w)&&w!==null&&Object.assign(y,u(w,E))}for(let[b,w]of v){let E=f?`${f}.${b}`:b;w&&typeof w=="object"&&!Array.isArray(w)&&w!==null||E in y||(y[E]=w)}return y},h=u(p);c={...this.state.values,...h}}}let m=this.conditionEngine.evaluateDependencies(d,c);return this.dependencyCache.set(t,m),m.visible&&!i.hidden}getFieldEnabled(t){let e=this.dependencyCache.get(t);if(e!==void 0)return e.enabled;if(!this.schema)return!0;let a=this.schema.isWizard?this.schema.steps.flatMap(n=>n.fields):this.schema.fields||[],s=this.extractAllFields(a).find(n=>n.name===t);if(!s)return!0;if(s.disabled)return!1;if(!s.dependencies)return!0;let i=this.conditionEngine.evaluateDependencies(s.dependencies,this.state.values);return this.dependencyCache.set(t,i),i.enabled}getFieldRequired(t){let e=this.dependencyCache.get(t);if(e!==void 0)return e.required;if(!this.schema)return!1;let a=this.schema.isWizard?this.schema.steps.flatMap(o=>o.fields):this.schema.fields||[],s=this.extractAllFields(a).find(o=>o.name===t);if(!s)return!1;let i=s.validations?.some(o=>o.type==="required")||!1;if(!s.dependencies)return i;let n=this.conditionEngine.evaluateDependencies(s.dependencies,this.state.values);return this.dependencyCache.set(t,n),n.required||i}getDependentFields(t){return Array.from(this.fieldDependencies.get(t)||[])}};var x=class{constructor(t,e,a,r,s){this.field=t,this.value=e,this.error=a,this.onChange=r,this.onBlur=s}createInputWithSlots(t){let e=this.field.leadingIcon,a=this.field.trailingIcon;if(!e&&!a)return t;let r=document.createElement("div");if(r.className="easy-form-input-wrapper",e&&this.isSlotContentValid(e)){let i=this.renderSlotContent(e);i.className="easy-form-input-slot easy-form-input-slot-leading",r.appendChild(i)}let s=document.createElement("div");if(s.className="easy-form-input-core",s.appendChild(t),r.appendChild(s),a&&this.isSlotContentValid(a)){let i=this.renderSlotContent(a);i.className="easy-form-input-slot easy-form-input-slot-trailing",r.appendChild(i)}return r}isSlotContentValid(t){return t.type?t.type==="image"?!!t.src:t.type==="html"?!!t.html:!1:!1}renderSlotContent(t){let e=document.createElement("span");if(e.className="easy-form-input-slot-content",t.type==="image"&&t.src){let a=document.createElement("img");a.src=t.src,a.alt=t.alt??"",a.setAttribute("aria-hidden","true"),e.appendChild(a)}else t.type==="html"&&t.html&&(e.innerHTML=t.html);return e}createFieldContainer(t){let e=document.createElement("div"),r=Array.from(t.classList).filter(d=>d.startsWith("easy-form-")&&d!=="easy-form-field"&&(d.includes("-container")||d.includes("-wrapper"))),s=this.field.labelPosition??"up",i=this.createInputWithSlots(t);if(r.length>0?e.className=`easy-form-field easy-form-label-${s} ${r.join(" ")}`:e.className=`easy-form-field easy-form-label-${s}`,s==="none"&&this.field.label){let d=i.querySelector("input, textarea, select")||i;d instanceof HTMLElement&&d.setAttribute("aria-label",this.field.label)}let o=(()=>{if(!this.field.label||s==="none")return null;let d=document.createElement("label");if(d.className="easy-form-label",d.setAttribute("for",this.getFieldId()),d.textContent=this.field.label,this.field.validations?.some(c=>c.type==="required")){let c=document.createElement("span");c.className="easy-form-required",c.textContent=" *",d.appendChild(c)}return d})();if(s==="up")o&&e.appendChild(o),e.appendChild(i);else if(s==="down")e.appendChild(i),o&&e.appendChild(o);else if(s==="left"){let d=document.createElement("div");d.className="easy-form-field-inner easy-form-field-inner-horizontal",o&&d.appendChild(o),d.appendChild(i),e.appendChild(d)}else if(s==="right"){let d=document.createElement("div");d.className="easy-form-field-inner easy-form-field-inner-horizontal",d.appendChild(i),o&&d.appendChild(o),e.appendChild(d)}else e.appendChild(i);if(this.field.description){let d=document.createElement("p");d.className="easy-form-description",d.textContent=this.field.description,e.appendChild(d)}if(this.error){let d=document.createElement("p");d.className="easy-form-error",d.textContent=this.error,e.appendChild(d)}return e}getFieldId(){return`easy-form-${this.field.name}`}applyCommonProps(t){if(t.id=this.getFieldId(),t.setAttribute("name",this.field.name),this.field.disabled&&(t.setAttribute("disabled","true"),t.classList.add("easy-form-input-disabled")),this.field.hidden&&(t.style.display="none",t.classList.add("easy-form-field-hidden")),this.error&&t.classList.add("easy-form-input-error"),this.field.props)for(let[e,a]of Object.entries(this.field.props))(e.startsWith("data-")||e.startsWith("aria-"))&&t.setAttribute(e,String(a))}};function ht(l){let t=[];for(let e=0;e<l.length;e++){let a=l[e];switch(a){case"9":t.push({type:"digit",char:"9",editable:!0});break;case"a":case"A":t.push({type:"letter",char:a,editable:!0});break;case"*":t.push({type:"any",char:"*",editable:!0});break;default:t.push({type:"literal",char:a,editable:!1});break}}return t}function U(l,t){let e="",a=0;for(let r of t){if(!r.editable){e+=r.char;continue}if(a>=l.length)break;let s=l[a];if(!(r.type==="digit"&&!/\d/.test(s))){{if(r.type==="letter"&&!/[a-zA-Z]/.test(s))continue;if(r.type!=="any"){if(r.type!=="any"&&r.type!=="digit"&&r.type!=="letter")continue}}e+=s,a++}}return e}function Pe(l,t){if(!l)return"";let e="",a=0;for(let r=0;r<l.length&&a<t.length;r++){let s=l[r],i=t[a];if(i.editable)i.type==="digit"&&/\d/.test(s)||i.type==="letter"&&/[a-zA-Z]/.test(s)||i.type==="any"?(e+=s,a++):(a++,r--);else if(s===i.char)a++;else if(a<t.length-1){let n=t[a+1];n&&n.editable&&(n.type==="digit"&&/\d/.test(s)||n.type==="letter"&&/[a-zA-Z]/.test(s)||n.type==="any")?(e+=s,a+=2):a++}else break}return e}function ae(l,t,e="forward"){if(e==="forward"){for(let a=l+1;a<t.length;a++)if(t[a].editable)return a;return t.length}else{for(let a=l-1;a>=0;a--)if(t[a].editable)return a;return 0}}function gt(l,t="_"){return l.map(e=>e.editable?t:e.char).join("")}function bt(l,t,e,a){let r=0;for(let i=0;i<Math.min(e,l.length);i++){let n=i;n<a.length&&a[n].editable&&r++}let s=0;for(let i=0;i<t.length&&i<a.length;i++)if(a[i].editable&&(s++,s>r))return i+1;return ae(Math.min(e,t.length-1),a,"forward")}var B=class{constructor(){this.tokenCache=new Map}getCustomMask(t){return t.custom?t.custom:t.type?qe(t.type):null}getTokens(t){let e=this.getCustomMask(t);if(!e)return null;let a=e.pattern;if(this.tokenCache.has(a))return this.tokenCache.get(a);let r=ht(e.pattern);return this.tokenCache.set(a,r),r}applyMask(t,e){let a=this.getTokens(e);if(!a)return t;let r=this.getCustomMask(e),s=a.filter(d=>d.editable),i=new Set(s.map(d=>d.type)),n="";for(let d of t)(i.has("any")||i.has("digit")&&/\d/.test(d)||i.has("letter")&&/[a-zA-Z]/.test(d))&&(n+=d);let o=U(n,a);return r.transform&&(o=r.transform(o),o=U(o,a)),o}removeMask(t,e){let a=this.getTokens(e);return a?Pe(t,a):t}getMaskPlaceholder(t){let e=this.getTokens(t);if(!e)return"";let a=this.getCustomMask(t);return gt(e,a.placeholder||"_")}canInsertChar(t,e,a){let r=this.getTokens(a);if(!r||e>=r.length)return!1;let s=r[e];if(!s.editable)return!1;switch(s.type){case"digit":return/\d/.test(t);case"letter":return/[a-zA-Z]/.test(t);case"any":return!0;default:return!1}}processInput(t,e,a,r){let s=this.getTokens(a);if(!s)return{value:t,cursorPosition:t.length};let i=Pe(t,s),n=U(i,s),o=this.getCustomMask(a);o.transform&&(n=o.transform(n),n=U(n,s));let d=bt(e,n,r,s);return{value:n,cursorPosition:Math.min(d,n.length)}}processKeyInput(t,e,a,r,s=!1){let i=this.getTokens(r);if(!i)return{value:e,cursorPosition:a};if(s){if(a===0)return{value:e,cursorPosition:0};let n=ae(a-1,i,"backward"),o=e.substring(0,n),d=e.substring(a),c=o+d,m=this.removeMask(c,r),p=this.applyMask(m,r),u=Math.max(0,n-1),h=ae(u,i,"forward");return{value:p,cursorPosition:h}}if(t.length===1&&this.canInsertChar(t,a,r)){let n=e.substring(0,a),o=e.substring(a),d=n+t+o;return this.processInput(d,e,r,a)}return{value:e,cursorPosition:a}}};var se=class extends x{constructor(e,a,r,s,i){super(e,a,r,s,i);this.maskEngine=null;this.previousValue="";e.mask&&(this.maskEngine=new B)}render(){let e=document.createElement("input");e.type=this.field.type==="email"?"email":this.field.type==="password"?"password":"text";let a=this.value??"";if(this.maskEngine&&this.field.mask&&(a&&(a=this.maskEngine.applyMask(String(a),this.field.mask)),this.previousValue=a),e.value=a,this.applyCommonProps(e),this.field.placeholder)e.placeholder=this.field.placeholder;else if(this.maskEngine&&this.field.mask){let r=this.maskEngine.getMaskPlaceholder(this.field.mask);r&&(e.placeholder=r)}return this.maskEngine&&this.field.mask?(e.addEventListener("input",r=>{let s=r.target,i=s.selectionStart||0,n=s.value,o=this.maskEngine.processInput(n,this.previousValue,this.field.mask,i);s.value=o.value,this.previousValue=o.value,setTimeout(()=>{s.setSelectionRange(o.cursorPosition,o.cursorPosition)},0);let d=this.field.mask.keepFormat?o.value:this.maskEngine.removeMask(o.value,this.field.mask);this.onChange(d)}),e.addEventListener("keydown",r=>{let s=r.target,i=s.selectionStart||0;if(r.key==="Backspace"||r.key==="Delete"){r.preventDefault();let n=r.key==="Backspace",o=this.maskEngine.processKeyInput("",s.value,i,this.field.mask,n);s.value=o.value,this.previousValue=o.value,setTimeout(()=>{s.setSelectionRange(o.cursorPosition,o.cursorPosition)},0);let d=this.field.mask.keepFormat?o.value:this.maskEngine.removeMask(o.value,this.field.mask);this.onChange(d)}}),e.addEventListener("paste",r=>{r.preventDefault();let s=(r.clipboardData||window.clipboardData).getData("text");if(s){let i=r.target,n=i.selectionStart||0,o=i.value.substring(0,n),d=i.value.substring(n),c=o+s+d,m=this.maskEngine.processInput(c,this.previousValue,this.field.mask,n);i.value=m.value,this.previousValue=m.value,setTimeout(()=>{i.setSelectionRange(m.cursorPosition,m.cursorPosition)},0);let p=this.field.mask.keepFormat?m.value:this.maskEngine.removeMask(m.value,this.field.mask);this.onChange(p)}})):e.addEventListener("input",r=>{let s=r.target;this.onChange(s.value)}),e.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(e)}};var ie=class extends x{constructor(e,a,r,s,i){super(e,a,r,s,i);this.maskEngine=null;this.previousValue="";e.mask&&(this.maskEngine=new B)}render(){let e=document.createElement("input");if(this.maskEngine&&this.field.mask){e.type="text";let r=this.value??"";r!==null&&r!==""&&(this.field.mask.type==="currency"?r=this.maskEngine.applyMask(String(r),this.field.mask):this.field.mask.type==="percentage"&&(r=this.maskEngine.applyMask(String(r),this.field.mask))),this.previousValue=r,e.value=r}else e.type="number",e.value=this.value??"";let a=this.field;if(!this.maskEngine&&e.type==="number"&&(a.min!==void 0&&(e.min=String(a.min)),a.max!==void 0&&(e.max=String(a.max)),a.step!==void 0&&(e.step=String(a.step))),this.applyCommonProps(e),this.field.placeholder)e.placeholder=this.field.placeholder;else if(this.maskEngine&&this.field.mask){let r=this.maskEngine.getMaskPlaceholder(this.field.mask);r&&(e.placeholder=r)}return this.maskEngine&&this.field.mask?(e.addEventListener("input",r=>{let s=r.target,i=s.selectionStart||0,n=s.value,o=this.maskEngine.processInput(n,this.previousValue,this.field.mask,i);s.value=o.value,this.previousValue=o.value,setTimeout(()=>{s.setSelectionRange(o.cursorPosition,o.cursorPosition)},0);let d=null;if(this.field.mask.type==="currency"){let c=this.maskEngine.removeMask(o.value,this.field.mask);d=c?parseFloat(c.replace(/[^\d.]/g,"")):null}else if(this.field.mask.type==="percentage"){let c=this.maskEngine.removeMask(o.value,this.field.mask);d=c?parseFloat(c):null}this.onChange(d)}),e.addEventListener("keydown",r=>{let s=r.target,i=s.selectionStart||0;if(r.key==="Backspace"||r.key==="Delete"){r.preventDefault();let n=r.key==="Backspace",o=this.maskEngine.processKeyInput("",s.value,i,this.field.mask,n);s.value=o.value,this.previousValue=o.value,setTimeout(()=>{s.setSelectionRange(o.cursorPosition,o.cursorPosition)},0);let d=null;if(this.field.mask.type==="currency"){let c=this.maskEngine.removeMask(o.value,this.field.mask);d=c?parseFloat(c.replace(/[^\d.]/g,"")):null}else if(this.field.mask.type==="percentage"){let c=this.maskEngine.removeMask(o.value,this.field.mask);d=c?parseFloat(c):null}this.onChange(d)}}),e.addEventListener("paste",r=>{r.preventDefault();let s=(r.clipboardData||window.clipboardData).getData("text");if(s){let i=r.target,n=i.selectionStart||0,o=i.value.substring(0,n),d=i.value.substring(n),c=o+s+d,m=this.maskEngine.processInput(c,this.previousValue,this.field.mask,n);i.value=m.value,this.previousValue=m.value,setTimeout(()=>{i.setSelectionRange(m.cursorPosition,m.cursorPosition)},0);let p=null;if(this.field.mask.type==="currency"){let u=this.maskEngine.removeMask(m.value,this.field.mask);p=u?parseFloat(u.replace(/[^\d.]/g,"")):null}else if(this.field.mask.type==="percentage"){let u=this.maskEngine.removeMask(m.value,this.field.mask);p=u?parseFloat(u):null}this.onChange(p)}})):e.addEventListener("input",r=>{let s=r.target,i=s.value===""?null:Number(s.value);this.onChange(i)}),e.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(e)}};var oe=class extends x{render(){let t=document.createElement("textarea");t.value=this.value??"",t.placeholder=this.field.placeholder||"";let e=this.field;return e.rows&&(t.rows=e.rows),e.cols&&(t.cols=e.cols),this.applyCommonProps(t),t.addEventListener("input",a=>{let r=a.target;this.onChange(r.value)}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var ne=class extends x{render(){let t=document.createElement("select"),e=this.field;if(e.multiple&&(t.multiple=!0),!e.multiple){let r=document.createElement("option");r.value="",r.textContent=e.placeholder||"Selecciona una opci\xF3n",r.setAttribute("data-placeholder",""),r.disabled=!0,t.appendChild(r)}for(let r of e.options){let s=document.createElement("option");typeof r=="string"?(s.value=r,s.textContent=r):(s.value=String(r.value),s.textContent=r.label),t.appendChild(s)}if(e.multiple&&Array.isArray(this.value))for(let r of t.options)r.selected=this.value.includes(r.value);else t.value=this.value??"";this.applyCommonProps(t);let a=()=>{!t.value?t.classList.add("easy-form-select-placeholder"):t.classList.remove("easy-form-select-placeholder")};return a(),t.addEventListener("change",r=>{let s=r.target;if(a(),e.multiple){let i=Array.from(s.selectedOptions).map(n=>n.value);this.onChange(i)}else this.onChange(s.value||null)}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var le=class extends x{render(){let t=document.createElement("input");t.type="checkbox",t.checked=!!this.value,this.applyCommonProps(t),t.addEventListener("change",r=>{let s=r.target;this.onChange(s.checked)}),t.addEventListener("blur",()=>{this.onBlur()});let e=document.createElement("div");e.className="easy-form-field";let a=document.createElement("label");if(a.className="easy-form-label-checkbox",a.setAttribute("for",this.getFieldId()),a.appendChild(t),this.field.label){let r=document.createTextNode(this.field.label);a.appendChild(r)}if(e.appendChild(a),this.field.description){let r=document.createElement("p");r.className="easy-form-description",r.textContent=this.field.description,e.appendChild(r)}if(this.error){let r=document.createElement("p");r.className="easy-form-error",r.textContent=this.error,e.appendChild(r)}return e}};var de=class extends x{render(){let t=document.createElement("div");if(t.className="easy-form-field",this.field.label){let r=document.createElement("label");if(r.className="easy-form-label",r.textContent=this.field.label,this.field.validations?.some(s=>s.type==="required")){let s=document.createElement("span");s.className="easy-form-required",s.textContent=" *",r.appendChild(s)}t.appendChild(r)}let e=document.createElement("div");e.className="easy-form-radio-group";let a=this.field;for(let r of a.options){let s=typeof r=="string"?r:r.value,i=typeof r=="string"?r:r.label,n=document.createElement("div");n.className="easy-form-radio-option";let o=document.createElement("input");o.type="radio",o.name=this.field.name,o.id=`${this.getFieldId()}-${s}`,o.value=String(s),o.checked=String(this.value)===String(s),this.field.disabled&&(o.disabled=!0);let d=document.createElement("label");d.setAttribute("for",o.id),d.textContent=i,d.className="easy-form-radio-label",o.addEventListener("change",()=>{this.onChange(s)}),o.addEventListener("blur",()=>{this.onBlur()}),n.appendChild(o),n.appendChild(d),e.appendChild(n)}if(t.appendChild(e),this.field.description){let r=document.createElement("p");r.className="easy-form-description",r.textContent=this.field.description,t.appendChild(r)}if(this.error){let r=document.createElement("p");r.className="easy-form-error",r.textContent=this.error,t.appendChild(r)}return t}};var ce=class extends x{render(){let t=document.createElement("input");t.type="checkbox",t.className="easy-form-switch",t.checked=!!this.value,this.applyCommonProps(t),t.addEventListener("change",r=>{let s=r.target;this.onChange(s.checked)}),t.addEventListener("blur",()=>{this.onBlur()});let e=document.createElement("div");e.className="easy-form-field";let a=document.createElement("label");if(a.className="easy-form-label-switch",a.setAttribute("for",this.getFieldId()),this.field.label){let r=document.createTextNode(this.field.label);a.appendChild(r)}if(a.appendChild(t),e.appendChild(a),this.field.description){let r=document.createElement("p");r.className="easy-form-description",r.textContent=this.field.description,e.appendChild(r)}if(this.error){let r=document.createElement("p");r.className="easy-form-error",r.textContent=this.error,e.appendChild(r)}return e}};var pe=class extends x{render(){let t=document.createElement("input");t.type="date";let e=this.field;if(e.min&&(t.min=e.min),e.max&&(t.max=e.max),this.value){let a=this.value instanceof Date?this.value.toISOString().split("T")[0]:String(this.value);t.value=a}return this.applyCommonProps(t),t.addEventListener("change",a=>{let r=a.target;this.onChange(r.value||null)}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var me=class extends x{render(){let t=document.createElement("input");t.type="file";let e=this.field;return e.accept&&(t.accept=e.accept),e.multiple&&(t.multiple=!0),this.applyCommonProps(t),t.addEventListener("change",a=>{let r=a.target;r.files&&(e.multiple?this.onChange(Array.from(r.files)):this.onChange(r.files[0]||null))}),t.addEventListener("blur",()=>{this.onBlur()}),this.createFieldContainer(t)}};var ue=class extends x{render(){let t=document.createElement("div");t.className="easy-form-quantity-container";let e=this.field,a=e.min??0,r=e.max??void 0,s=e.step??1,i=this.value??a,n=document.createElement("div");n.className="easy-form-quantity-wrapper";let o=document.createElement("button");o.type="button",o.className="easy-form-quantity-btn easy-form-quantity-decrement",o.textContent="\u2212",o.setAttribute("aria-label","Decrementar"),i<=a&&(o.disabled=!0,o.classList.add("disabled"));let d=document.createElement("input");d.type="number",d.value=String(i),d.min=String(a),r!==void 0&&(d.max=String(r)),d.step=String(s),d.className="easy-form-quantity-input",this.applyCommonProps(d);let c=document.createElement("button");c.type="button",c.className="easy-form-quantity-btn easy-form-quantity-increment",c.textContent="+",c.setAttribute("aria-label","Incrementar"),r!==void 0&&i>=r&&(c.disabled=!0,c.classList.add("disabled")),o.addEventListener("click",()=>{let p=Math.max(a,Number(d.value)-s);d.value=String(p),this.onChange(p),m()}),c.addEventListener("click",()=>{let p=r!==void 0?Math.min(r,Number(d.value)+s):Number(d.value)+s;d.value=String(p),this.onChange(p),m()}),d.addEventListener("input",p=>{let u=p.target,h=Number(u.value);isNaN(h)&&(h=a),h<a&&(h=a),r!==void 0&&h>r&&(h=r),u.value=String(h),this.onChange(h),m()}),d.addEventListener("blur",()=>{this.onBlur()});let m=()=>{let p=Number(d.value);o.disabled=p<=a,o.classList.toggle("disabled",p<=a),r!==void 0?(c.disabled=p>=r,c.classList.toggle("disabled",p>=r)):(c.disabled=!1,c.classList.remove("disabled"))};return n.appendChild(o),n.appendChild(d),n.appendChild(c),t.appendChild(n),this.createFieldContainer(t)}};var fe=class extends x{constructor(){super(...arguments);this.openAccordion=null}render(){let e=document.createElement("div");e.className="easy-form-accordion-select-container";let a=this.field,r=this.value??null;return a.options.forEach((s,i)=>{let n=typeof s=="string"?s:s.value,o=typeof s=="string"?s:s.label,d=typeof s=="object"&&"description"in s&&s.description?s.description:void 0,c=document.createElement("div");c.className="easy-form-accordion-item",c.setAttribute("data-value",String(n)),(r===n||Array.isArray(r)&&r.includes(n))&&(c.classList.add("selected"),a.multiple||(this.openAccordion=String(n)));let m=document.createElement("div");m.className="easy-form-accordion-header",m.setAttribute("role","button"),m.setAttribute("tabindex","0"),m.setAttribute("aria-expanded","false");let p=document.createElement("div");p.className="easy-form-accordion-header-content";let u=document.createElement("div");u.className="easy-form-accordion-indicator",a.multiple?(u.classList.add("checkbox"),Array.isArray(r)&&r.includes(n)&&u.classList.add("checked")):(u.classList.add("radio"),r===n&&u.classList.add("checked"));let h=document.createElement("span");h.className="easy-form-accordion-label",h.textContent=o;let g=document.createElement("span");g.className="easy-form-accordion-arrow",g.textContent="\u25BC",p.appendChild(u),p.appendChild(h),m.appendChild(p),m.appendChild(g);let f=document.createElement("div");if(f.className="easy-form-accordion-content",d){let b=document.createElement("p");b.className="easy-form-accordion-description",b.textContent=d,f.appendChild(b)}if(typeof s=="object"&&"content"in s&&s.content){let b=document.createElement("div");b.className="easy-form-accordion-custom-content",typeof s.content=="string"?b.innerHTML=s.content:s.content instanceof HTMLElement&&b.appendChild(s.content),f.appendChild(b)}c.appendChild(m),c.appendChild(f);let y=()=>{let b=c.classList.contains("open");a.multiple||e.querySelectorAll(".easy-form-accordion-item").forEach(w=>{if(w!==c){w.classList.remove("open");let E=w.querySelector(".easy-form-accordion-header"),k=w.querySelector(".easy-form-accordion-content"),T=w.querySelector(".easy-form-accordion-arrow");E&&E.setAttribute("aria-expanded","false"),k&&(k.style.maxHeight=null),T&&(T.style.transform="rotate(0deg)")}}),b?(c.classList.remove("open"),m.setAttribute("aria-expanded","false"),f.style.maxHeight=null,g.style.transform="rotate(0deg)",this.openAccordion=null):(c.classList.add("open"),m.setAttribute("aria-expanded","true"),f.style.maxHeight=f.scrollHeight+"px",g.style.transform="rotate(180deg)",this.openAccordion=String(n))},v=()=>{if(a.multiple){let b=Array.isArray(r)?[...r]:[],w=b.indexOf(n);w>-1?(b.splice(w,1),c.classList.remove("selected"),u.classList.remove("checked")):(b.push(n),c.classList.add("selected"),u.classList.add("checked")),this.onChange(b.length>0?b:null)}else e.querySelectorAll(".easy-form-accordion-item").forEach(b=>{b.classList.remove("selected");let w=b.querySelector(".easy-form-accordion-indicator");w&&w.classList.remove("checked")}),c.classList.add("selected"),u.classList.add("checked"),this.onChange(n)};m.addEventListener("click",b=>{b.stopPropagation(),v(),y()}),m.addEventListener("keydown",b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),v(),y())}),(r===n||Array.isArray(r)&&r.includes(n))&&(!a.multiple||a.autoExpand)&&setTimeout(()=>{c.classList.add("open"),m.setAttribute("aria-expanded","true"),f.style.maxHeight=f.scrollHeight+"px",g.style.transform="rotate(180deg)"},0),e.appendChild(c)}),this.createFieldContainer(e)}};var he=class extends x{render(){let t=document.createElement("div");t.className="easy-form-image-grid-container";let e=this.field,a=this.value??null,r=e.columns??3,s=e.imageSize??"medium";return t.style.gridTemplateColumns=`repeat(${r}, 1fr)`,t.style.gap=e.gap??"1rem",e.options.forEach(i=>{let n=typeof i=="string"?i:i.value,o=typeof i=="string"?i:i.label,d=typeof i=="object"&&"image"in i&&i.image?i.image:void 0,c=typeof i=="object"&&"description"in i&&i.description?i.description:void 0,m=document.createElement("div");m.className=`easy-form-image-grid-item easy-form-image-grid-${s}`,m.setAttribute("data-value",String(n)),m.setAttribute("role","button"),m.setAttribute("tabindex","0"),m.setAttribute("aria-label",o),(a===n||Array.isArray(a)&&a.includes(n))&&m.classList.add("selected");let p=document.createElement("div");if(p.className="easy-form-image-grid-image-container",d){let f=document.createElement("img");f.src=d,f.alt=o,f.className="easy-form-image-grid-image",p.appendChild(f)}else{let f=document.createElement("div");f.className="easy-form-image-grid-placeholder",f.textContent=o.charAt(0).toUpperCase(),p.appendChild(f)}let u=document.createElement("div");u.className="easy-form-image-grid-indicator",e.multiple?(u.classList.add("checkbox"),Array.isArray(a)&&a.includes(n)&&(u.classList.add("checked"),u.innerHTML="\u2713")):(u.classList.add("radio"),a===n&&(u.classList.add("checked"),u.innerHTML="\u25CF")),p.appendChild(u);let h=document.createElement("div");if(h.className="easy-form-image-grid-label",h.textContent=o,c){let f=document.createElement("div");f.className="easy-form-image-grid-description",f.textContent=c,m.appendChild(f)}m.appendChild(p),m.appendChild(h);let g=()=>{if(e.multiple){let f=Array.isArray(a)?[...a]:[],y=f.indexOf(n);y>-1?(f.splice(y,1),m.classList.remove("selected"),u.classList.remove("checked"),u.innerHTML=""):(f.push(n),m.classList.add("selected"),u.classList.add("checked"),u.innerHTML="\u2713"),this.onChange(f.length>0?f:null)}else t.querySelectorAll(".easy-form-image-grid-item").forEach(f=>{f.classList.remove("selected");let y=f.querySelector(".easy-form-image-grid-indicator");y&&(y.classList.remove("checked"),y.innerHTML="")}),m.classList.add("selected"),u.classList.add("checked"),u.innerHTML="\u25CF",this.onChange(n)};m.addEventListener("click",g),m.addEventListener("keydown",f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),g())}),m.addEventListener("blur",()=>{this.onBlur()}),t.appendChild(m)}),this.createFieldContainer(t)}};var ge=class extends x{constructor(){super(...arguments);this.inputs=[]}render(){let e=document.createElement("div");e.className="easy-form-otp-container";let r=this.field.length??6,s=this.value??"",i=String(s).padStart(r,"").slice(0,r);for(let n=0;n<r;n++){let o=document.createElement("input");o.type="text",o.inputMode="numeric",o.maxLength=1,o.className="easy-form-otp-input",o.setAttribute("aria-label",`C\xF3digo d\xEDgito ${n+1}`),i[n]&&(o.value=i[n]),this.applyCommonProps(o),o.id=`${this.getFieldId()}-${n}`;let d=n;o.addEventListener("input",c=>{let m=c.target,p=m.value.replace(/[^0-9]/g,"");m.value=p,p&&d<r-1&&this.inputs[d+1].focus(),this.updateOTPValue()}),o.addEventListener("keydown",c=>{let m=c.target;c.key==="Backspace"&&!m.value&&d>0&&(this.inputs[d-1].focus(),this.inputs[d-1].value="",this.updateOTPValue()),c.key==="ArrowLeft"&&d>0&&(c.preventDefault(),this.inputs[d-1].focus()),c.key==="ArrowRight"&&d<r-1&&(c.preventDefault(),this.inputs[d+1].focus())}),o.addEventListener("paste",c=>{c.preventDefault();let p=(c.clipboardData||window.clipboardData).getData("text").replace(/[^0-9]/g,"").slice(0,r);for(let h=0;h<p.length&&d+h<r;h++)this.inputs[d+h].value=p[h];let u=Math.min(d+p.length,r-1);this.inputs[u].focus(),this.updateOTPValue()}),o.addEventListener("focus",c=>{c.target.select()}),o.addEventListener("blur",()=>{this.onBlur()}),this.inputs.push(o),e.appendChild(o)}return this.createFieldContainer(e)}updateOTPValue(){let e=this.inputs.map(s=>s.value).join(""),a=this.field,r=e.length===this.inputs.length?e:null;a.numeric&&r?this.onChange(Number(r)):this.onChange(r)}};var Kt=6;function be(l){return l?'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>':'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>'}var ye=class extends x{constructor(){super(...arguments);this.inputs=[];this.visible=!1}get passwordField(){return this.field}render(){let e=this.passwordField,a=!!e.characterSeparated,r=a?typeof e.characterSeparated=="number"?e.characterSeparated:Kt:0;return a?this.createFieldContainer(this.renderSeparated(r)):this.createFieldContainer(this.renderSingle())}renderSingle(){let a=!!this.passwordField.showToggle,r=document.createElement("input");if(r.type="password",r.value=this.value??"",r.id=this.getFieldId(),this.applyCommonProps(r),this.field.placeholder&&(r.placeholder=this.field.placeholder),r.addEventListener("input",n=>{this.onChange(n.target.value)}),r.addEventListener("blur",()=>this.onBlur()),!a)return r;let s=document.createElement("div");s.className="easy-form-password-inner",r.classList.add("easy-form-password-input"),s.appendChild(r);let i=document.createElement("button");return i.type="button",i.className="easy-form-password-toggle",i.setAttribute("aria-label","Mostrar contrase\xF1a"),i.innerHTML=be(!1),i.addEventListener("click",()=>{this.visible=!this.visible,r.type=this.visible?"text":"password",i.setAttribute("aria-label",this.visible?"Ocultar contrase\xF1a":"Mostrar contrase\xF1a"),i.innerHTML=be(this.visible)}),s.appendChild(i),s}renderSeparated(e){let r=!!this.passwordField.showToggle,s=this.value??"",i=String(s).slice(0,e),n=document.createElement("div");n.className="easy-form-password-separated";for(let o=0;o<e;o++){let d=document.createElement("input");d.type="password",d.maxLength=1,d.className="easy-form-password-separated-input",d.setAttribute("aria-label",`Car\xE1cter ${o+1} de ${e}`),i[o]&&(d.value=i[o]),this.applyCommonProps(d),d.id=o===0?this.getFieldId():`${this.getFieldId()}-${o}`,o>0&&d.removeAttribute("name");let c=o;d.addEventListener("input",m=>{m.target.value&&c<e-1&&this.inputs[c+1].focus(),this.updateSeparatedValue()}),d.addEventListener("keydown",m=>{m.key==="Backspace"&&!m.target.value&&c>0&&(this.inputs[c-1].focus(),this.inputs[c-1].value="",this.updateSeparatedValue()),m.key==="ArrowLeft"&&c>0&&(m.preventDefault(),this.inputs[c-1].focus()),m.key==="ArrowRight"&&c<e-1&&(m.preventDefault(),this.inputs[c+1].focus())}),d.addEventListener("paste",m=>{m.preventDefault();let u=((m.clipboardData||window.clipboardData)?.getData("text")||"").slice(0,e-c).split("");for(let g=0;g<u.length&&c+g<e;g++)this.inputs[c+g].value=u[g];let h=Math.min(c+u.length,e-1);this.inputs[h].focus(),this.updateSeparatedValue()}),d.addEventListener("focus",m=>m.target.select()),d.addEventListener("blur",()=>this.onBlur()),this.inputs.push(d),n.appendChild(d)}if(r){let o=document.createElement("div");o.className="easy-form-password-separated-toggle";let d=document.createElement("button");d.type="button",d.className="easy-form-password-toggle",d.setAttribute("aria-label","Mostrar contrase\xF1a"),d.innerHTML=be(!1),d.addEventListener("click",()=>{this.visible=!this.visible;let c=this.visible?"text":"password";this.inputs.forEach(m=>{m.type=c}),d.setAttribute("aria-label",this.visible?"Ocultar contrase\xF1a":"Mostrar contrase\xF1a"),d.innerHTML=be(this.visible)}),o.appendChild(d),n.appendChild(o)}return n}updateSeparatedValue(){let e=this.inputs.map(a=>a.value).join("");this.onChange(e||null)}};var ve=class extends x{render(){let t=this.field,e=t.accept??"",a=t.multiple??!1,r=document.createElement("div");r.className="easy-form-file-drop",r.setAttribute("tabindex","0");let s=document.createElement("input");s.type="file",s.className="easy-form-file-drop-input",s.style.display="none",e&&(s.accept=e),a&&(s.multiple=!0);let i=document.createElement("span");i.className="easy-form-file-drop-label",i.textContent="Arrastra archivos aqu\xED o haz clic para seleccionar",r.appendChild(i),r.appendChild(s);let n=document.createElement("div");n.className="easy-form-file-drop-list";let o=c=>{let m=c?Array.isArray(c)?c.map(p=>p.name):[c.name]:[];if(n.innerHTML="",m.length===0){n.style.display="none";return}n.style.display="block",m.forEach(p=>{let u=document.createElement("div");u.className="easy-form-file-drop-item",u.textContent=p,n.appendChild(u)})};o(this.value);let d=c=>{if(!c||c.length===0)return;let m=a?Array.from(c):c[0];this.onChange(m),this.onBlur(),o(m)};return r.addEventListener("click",()=>{s.click()}),s.addEventListener("change",c=>{let m=c.target;d(m.files),m.value=""}),r.addEventListener("dragover",c=>{c.preventDefault(),c.stopPropagation(),r.classList.add("easy-form-file-drop-over")}),r.addEventListener("dragleave",c=>{c.preventDefault(),c.stopPropagation(),r.classList.remove("easy-form-file-drop-over")}),r.addEventListener("drop",c=>{c.preventDefault(),c.stopPropagation(),r.classList.remove("easy-form-file-drop-over"),d(c.dataTransfer?.files??null)}),r.appendChild(n),this.createFieldContainer(r)}};var Qt="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css",xe=class extends x{constructor(){super(...arguments);this.mapInstance=null;this.markerInstance=null}render(){let e=this.field,a=e.center??{lat:0,lng:0},r=e.zoom??13,s=this.value,i=typeof s=="object"&&s?.lat!=null?s.lat:a.lat,n=typeof s=="object"&&s?.lng!=null?s.lng:a.lng,o=document.createElement("div");o.className="easy-form-map";let d=document.createElement("div");d.className="easy-form-map-inputs";let c=document.createElement("input");c.type="number",c.step="any",c.placeholder="Latitud",c.value=String(i),c.className="easy-form-map-lat";let m=document.createElement("input");m.type="number",m.step="any",m.placeholder="Longitud",m.value=String(n),m.className="easy-form-map-lng";let p=()=>{let v=parseFloat(c.value),b=parseFloat(m.value);!isNaN(v)&&!isNaN(b)&&(this.onChange({lat:v,lng:b}),this.syncMarkerPosition(v,b)),this.onBlur()};c.addEventListener("change",p),m.addEventListener("change",p),d.appendChild(c),d.appendChild(m),o.appendChild(d);let u=document.createElement("div");u.className="easy-form-map-container",o.appendChild(u);let h="easy-form-leaflet-css",g=!1,f=document.createElement("link");return f.id=h,f.rel="stylesheet",f.href=Qt,f.onload=()=>{g=!0},o.insertBefore(f,o.firstChild),(async()=>{if(typeof window>"u")return;u.style.height="300px",u.style.width="100%",u.style.position="relative",u.style.overflow="hidden",u.style.display="block",await new Promise(k=>{let T=()=>{g&&u.offsetWidth>0&&u.offsetHeight>0?k(void 0):requestAnimationFrame(T)};T()}),await new Promise(k=>setTimeout(k,50));let v;try{v=await import("leaflet")}catch{u.innerHTML=`
2655
2771
  <div style="padding:2rem;text-align:center;color:#666;font-size:0.875rem;background:#f9f9f9;border-radius:4px;">
2656
2772
  <strong>Campo map requiere Leaflet</strong><br><br>
2657
2773
  Instala e importa Leaflet para usar el mapa interactivo:<br>
@@ -2659,12 +2775,12 @@ Please report this to https://github.com/markedjs/marked.`,l){let a="<p>An error
2659
2775
  En tu app: <code>import 'leaflet'</code> y <code>import 'leaflet/dist/leaflet.css'</code><br>
2660
2776
  <a href="https://easyforms.dev/docs/tipos-campos#map" target="_blank" rel="noopener" style="color:var(--easy-form-primary,#007bff);">Ver documentaci\xF3n</a>
2661
2777
  </div>
2662
- `;return}delete v.Icon.Default.prototype._getIconUrl,v.Icon.Default.mergeOptions({iconRetinaUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png",iconUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png",shadowUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-shadow.png"}),this.mapInstance=v.map(u,{preferCanvas:!1,zoomControl:!0}).setView([i,n],r);let b=v.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',maxZoom:19}).addTo(this.mapInstance);this.mapInstance.invalidateSize(),b.on("load",()=>{this.mapInstance&&this.mapInstance.invalidateSize()});let w=()=>{this.mapInstance&&this.mapInstance.invalidateSize()};setTimeout(w,100),setTimeout(w,300),setTimeout(w,500),new IntersectionObserver(k=>{k.forEach(F=>{F.isIntersecting&&this.mapInstance&&setTimeout(()=>{this.mapInstance?.invalidateSize()},100)})}).observe(u),this.markerInstance=v.marker([i,n],{draggable:!0}).addTo(this.mapInstance).on("dragend",()=>{let k=this.markerInstance.getLatLng();c.value=String(Number(k.lat.toFixed(6))),m.value=String(Number(k.lng.toFixed(6))),this.onChange({lat:k.lat,lng:k.lng}),this.onBlur()}),this.mapInstance.on("click",k=>{let{lat:F,lng:$}=k.latlng;this.markerInstance.setLatLng([F,$]),c.value=String(Number(F.toFixed(6))),m.value=String(Number($.toFixed(6))),this.onChange({lat:F,lng:$}),this.onBlur()})})(),this.createFieldContainer(o)}syncMarkerPosition(e,a){this.mapInstance&&this.markerInstance&&(this.markerInstance.setLatLng([e,a]),this.mapInstance.setView([e,a]),setTimeout(()=>{this.mapInstance?.invalidateSize()},50))}};var bt=l=>`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="${l?"currentColor":"none"}" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" role="img" aria-hidden="true"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>`,ke=class extends x{render(){let t=this.field,e=t.max??5,a=t.half??!1,r=this.value!=null?Number(this.value):0,s=document.createElement("div");s.className="easy-form-rating",s.setAttribute("role","slider"),s.setAttribute("aria-valuemin","0"),s.setAttribute("aria-valuemax",String(e)),s.setAttribute("aria-valuenow",String(r)),s.setAttribute("aria-label",this.field.label||"Rating"),s.setAttribute("tabindex","0");let i=document.createElement("div");i.className="easy-form-rating-stars";for(let n=1;n<=e;n++){let o=document.createElement("button");o.type="button";let d=r>=n||a&&r>=n-.5;o.className=d?"easy-form-rating-star easy-form-rating-star-filled":"easy-form-rating-star",o.innerHTML=bt(d),o.setAttribute("aria-label",`${n} de ${e}`),o.addEventListener("click",c=>{c.preventDefault();let m=c.target.closest("button")?.getBoundingClientRect(),p=n;if(a&&m){let u=m.left+m.width/2;p=c.clientX<u?n-.5:n}this.onChange(p),this.onBlur(),this.rerenderStars(s,e,p,a),s.setAttribute("aria-valuenow",String(p))}),i.appendChild(o)}return s.appendChild(i),s.addEventListener("keydown",n=>{let o=Number(s.getAttribute("aria-valuenow"))||0,d=o;n.key==="ArrowRight"||n.key==="ArrowUp"?(n.preventDefault(),d=Math.min(e,a?o+.5:o+1),this.onChange(d)):(n.key==="ArrowLeft"||n.key==="ArrowDown")&&(n.preventDefault(),d=Math.max(0,a?o-.5:o-1),this.onChange(d)),d!==o&&(this.rerenderStars(s,e,d,a),s.setAttribute("aria-valuenow",String(d)))}),this.createFieldContainer(s)}rerenderStars(t,e,a,r){t.querySelectorAll(".easy-form-rating-star").forEach((i,n)=>{let o=n+1,d=a>=o||r&&a>=o-.5;i.className=d?"easy-form-rating-star easy-form-rating-star-filled":"easy-form-rating-star",i.innerHTML=bt(d)})}};var we=class extends x{render(){let t=this.field,e=t.min??0,a=t.max??100,r=t.step??1,s=t.showValue??!1,i=document.createElement("input");i.type="range",i.min=String(e),i.max=String(a),i.step=String(r),i.value=this.value!=null?String(this.value):String(e),i.setAttribute("aria-valuemin",String(e)),i.setAttribute("aria-valuemax",String(a)),i.setAttribute("aria-valuenow",i.value),this.applyCommonProps(i),i.addEventListener("input",o=>{let d=o.target,c=r>=1?parseInt(d.value,10):parseFloat(d.value);this.onChange(isNaN(c)?e:c),n&&(n.textContent=d.value),i.setAttribute("aria-valuenow",d.value)}),i.addEventListener("change",()=>{this.onBlur()});let n=null;if(s){n=document.createElement("span"),n.className="easy-form-slider-value",n.textContent=i.value;let o=document.createElement("div");return o.className="easy-form-slider-wrapper",o.appendChild(i),o.appendChild(n),this.createFieldContainer(o)}return this.createFieldContainer(i)}};var Qt=/^#?([0-9A-Fa-f]{6})$/;function Pe(l){let t=l.match(Qt);return t?`#${t[1].toLowerCase()}`:/^[0-9A-Fa-f]{6}$/.test(l)?`#${l.toLowerCase()}`:"#000000"}var Ee=class extends x{render(){let e=this.field.defaultValue??"#000000",a=this.value!=null&&typeof this.value=="string"?Pe(this.value):e,r=document.createElement("div");r.className="easy-form-color-wrapper";let s=document.createElement("input");s.type="color",s.value=a,s.setAttribute("value",a),s.setAttribute("aria-label",this.field.label||"Color"),s.id=`${this.getFieldId()}-picker`,this.field.disabled&&s.setAttribute("disabled","true");let i=document.createElement("input");i.type="text",i.value=a,i.setAttribute("aria-label",`${this.field.label||"Color"} (hex)`),i.placeholder="#000000",i.className="easy-form-color-text",this.applyCommonProps(i);let n=()=>{let d=s.value||"#000000",c=Pe(d);i.value=c,this.onChange(c)},o=()=>{let d=i.value.trim(),c=d.startsWith("#")?d:`#${d}`;if(/^#[0-9A-Fa-f]{6}$/.test(c)){let m=Pe(c);s.value=m,this.onChange(m)}};return s.addEventListener("input",n),s.addEventListener("change",()=>{n(),this.onBlur()}),i.addEventListener("input",o),i.addEventListener("blur",()=>{o(),this.onBlur()}),r.appendChild(s),r.appendChild(i),this.createFieldContainer(r)}};var Ae=class extends x{constructor(){super(...arguments);this.textareaEl=null;this.previewEl=null;this.previewModeEl=null}render(){let e=this.field,a=e.mode??"split",r=e.toolbar??!0,s=e.height??"300px",i=document.createElement("div");return i.className=`easy-form-markdown easy-form-markdown-mode-${a}`,a==="tabs"?this.renderTabsMode(i,e,r,s):a==="preview"?this.renderPreviewMode(i,e,r,s):this.renderSplitMode(i,e,r,s),this.checkAndShowDependenciesMessage(),this.createFieldContainer(i)}renderSplitMode(e,a,r,s){if(r){let d=this.createToolbar();e.appendChild(d)}let i=document.createElement("div");i.className="easy-form-markdown-editor-wrapper easy-form-markdown-split";let n=document.createElement("textarea");n.className="easy-form-markdown-textarea",n.value=this.value||"",n.placeholder=a.placeholder||"Escribe en Markdown...",n.style.height=s,this.textareaEl=n,n.addEventListener("input",()=>{this.onChange(n.value),this.updatePreview()}),n.addEventListener("blur",()=>{this.onBlur()}),i.appendChild(n),e.appendChild(i);let o=document.createElement("div");o.className="easy-form-markdown-preview",o.style.height=s,this.previewEl=o,this.value?this.renderPreview(this.value,o):o.innerHTML='<div class="easy-form-markdown-preview-placeholder">Vista previa</div>',i.appendChild(o)}renderTabsMode(e,a,r,s){let i=document.createElement("div");i.className="easy-form-markdown-tabs";let n=document.createElement("div");n.className="easy-form-markdown-tabs-header";let o=document.createElement("button");o.type="button",o.className="easy-form-markdown-tab active",o.textContent="Editor",o.addEventListener("click",()=>this.switchTab("editor"));let d=document.createElement("button");d.type="button",d.className="easy-form-markdown-tab",d.textContent="Vista previa",d.addEventListener("click",()=>this.switchTab("preview")),n.appendChild(o),n.appendChild(d),i.appendChild(n);let c=document.createElement("div");if(c.className="easy-form-markdown-tabs-content",r){let u=this.createToolbar();c.appendChild(u)}let m=document.createElement("textarea");m.className="easy-form-markdown-textarea",m.value=this.value||"",m.placeholder=a.placeholder||"Escribe en Markdown...",m.style.height=s,this.textareaEl=m,m.addEventListener("input",()=>{this.onChange(m.value),d.classList.contains("active")&&this.renderPreview(m.value,this.previewEl)}),m.addEventListener("blur",()=>{this.onBlur()}),c.appendChild(m);let p=document.createElement("div");p.className="easy-form-markdown-preview",p.style.height=s,p.style.display="none",this.previewEl=p,this.value?this.renderPreview(this.value,p):p.innerHTML='<div class="easy-form-markdown-preview-placeholder">Vista previa</div>',c.appendChild(p),i.appendChild(c),e.appendChild(i),i._editorTab=o,i._previewTab=d,i._textarea=m,i._preview=p}renderPreviewMode(e,a,r,s){if(r){let d=this.createToolbar();e.appendChild(d)}let i=document.createElement("div");i.className="easy-form-markdown-preview-mode",i.style.height=s,this.previewModeEl=i;let n=document.createElement("div");n.className="easy-form-markdown-preview-mode-content",this.renderPreview(this.value||"",n);let o=document.createElement("textarea");o.className="easy-form-markdown-textarea-invisible",o.value=this.value||"",o.placeholder=a.placeholder||"Escribe...",o.setAttribute("aria-label","Editor de markdown"),o.addEventListener("input",()=>{this.onChange(o.value),this.renderPreview(o.value,n)}),o.addEventListener("blur",()=>{this.onBlur()}),i.appendChild(o),i.appendChild(n),e.appendChild(i)}switchTab(e){let a=this.textareaEl?.closest(".easy-form-markdown-tabs");if(!a)return;let r=a._editorTab,s=a._previewTab,i=a._textarea,n=a._preview;e==="editor"?(r.classList.add("active"),s.classList.remove("active"),i.style.display="block",n.style.display="none"):(r.classList.remove("active"),s.classList.add("active"),i.style.display="none",n.style.display="block",i.value&&this.renderPreview(i.value,n))}createToolbar(){let e=document.createElement("div");return e.className="easy-form-markdown-toolbar",[{icon:"<strong>B</strong>",title:"Negrita",prefix:"**",suffix:"**",placeholder:"texto en negrita"},{icon:"<em>I</em>",title:"Cursiva",prefix:"_",suffix:"_",placeholder:"texto en cursiva"},{icon:"H1",title:"Encabezado 1",prefix:"# ",suffix:"",placeholder:"t\xEDtulo"},{icon:"H2",title:"Encabezado 2",prefix:"## ",suffix:"",placeholder:"t\xEDtulo"},{icon:"\u{1F517}",title:"Enlace",prefix:"[",suffix:"](url)",placeholder:"texto del enlace"},{icon:"<code>&lt;/&gt;</code>",title:"C\xF3digo",prefix:"`",suffix:"`",placeholder:"c\xF3digo"},{icon:"\u{1F4F7}",title:"Imagen",prefix:"![",suffix:"](url)",placeholder:"texto alternativo"},{icon:"\u2022",title:"Lista",prefix:"- ",suffix:"",placeholder:"elemento"},{icon:"1.",title:"Lista numerada",prefix:"1. ",suffix:"",placeholder:"elemento"},{icon:'"',title:"Cita",prefix:"> ",suffix:"",placeholder:"cita"}].forEach(r=>{let s=document.createElement("button");s.type="button",s.className="easy-form-markdown-toolbar-btn",s.title=r.title,s.innerHTML=r.icon,s.addEventListener("click",()=>this.insertMarkdown(r.prefix,r.suffix,r.placeholder)),e.appendChild(s)}),e}insertMarkdown(e,a,r){let s=this.textareaEl;if(!s){if(this.previewModeEl){let p=this.previewModeEl.querySelector(".easy-form-markdown-textarea-invisible");p&&this.insertMarkdownToPreviewMode(p,e,a,r)}return}let i=s.selectionStart,n=s.selectionEnd,o=s.value,d=o.substring(i,n)||(r??""),c=o.substring(0,i)+e+d+a+o.substring(n);s.value=c;let m=i+e.length+d.length;s.setSelectionRange(m,m),s.focus(),this.onChange(c),this.updatePreview()}insertMarkdownToPreviewMode(e,a,r,s){let i=e.selectionStart,n=e.selectionEnd,o=e.value,d=o.substring(i,n)||(s??""),c=o.substring(0,i)+a+d+r+o.substring(n);e.value=c;let m=i+a.length+d.length;if(e.setSelectionRange(m,m),e.focus(),this.onChange(c),this.previewModeEl){let p=this.previewModeEl.querySelector(".easy-form-markdown-preview-mode-content");p&&this.renderPreview(c,p)}}updatePreview(){if(!this.previewEl)return;let e=this.textareaEl?.value||"";if(!e){this.previewEl.innerHTML='<div class="easy-form-markdown-preview-placeholder">Vista previa</div>';return}this.renderPreview(e,this.previewEl)}async renderPreview(e,a){if(!e||!e.trim()){a.innerHTML='<div class="easy-form-markdown-preview-placeholder">Vista previa</div>';return}a.innerHTML='<div class="easy-form-markdown-preview-loading">Cargando...</div>';try{let r=await Promise.resolve().then(()=>(Ze(),Ye)),i=await(r.default||r).parse(e);a.innerHTML=i}catch{a.innerHTML=`
2778
+ `;return}delete v.Icon.Default.prototype._getIconUrl,v.Icon.Default.mergeOptions({iconRetinaUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png",iconUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png",shadowUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-shadow.png"}),this.mapInstance=v.map(u,{preferCanvas:!1,zoomControl:!0}).setView([i,n],r);let b=v.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',maxZoom:19}).addTo(this.mapInstance);this.mapInstance.invalidateSize(),b.on("load",()=>{this.mapInstance&&this.mapInstance.invalidateSize()});let w=()=>{this.mapInstance&&this.mapInstance.invalidateSize()};setTimeout(w,100),setTimeout(w,300),setTimeout(w,500),new IntersectionObserver(k=>{k.forEach(T=>{T.isIntersecting&&this.mapInstance&&setTimeout(()=>{this.mapInstance?.invalidateSize()},100)})}).observe(u),this.markerInstance=v.marker([i,n],{draggable:!0}).addTo(this.mapInstance).on("dragend",()=>{let k=this.markerInstance.getLatLng();c.value=String(Number(k.lat.toFixed(6))),m.value=String(Number(k.lng.toFixed(6))),this.onChange({lat:k.lat,lng:k.lng}),this.onBlur()}),this.mapInstance.on("click",k=>{let{lat:T,lng:$}=k.latlng;this.markerInstance.setLatLng([T,$]),c.value=String(Number(T.toFixed(6))),m.value=String(Number($.toFixed(6))),this.onChange({lat:T,lng:$}),this.onBlur()})})(),this.createFieldContainer(o)}syncMarkerPosition(e,a){this.mapInstance&&this.markerInstance&&(this.markerInstance.setLatLng([e,a]),this.mapInstance.setView([e,a]),setTimeout(()=>{this.mapInstance?.invalidateSize()},50))}};var yt=l=>`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="${l?"currentColor":"none"}" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" role="img" aria-hidden="true"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>`,ke=class extends x{render(){let t=this.field,e=t.max??5,a=t.half??!1,r=this.value!=null?Number(this.value):0,s=document.createElement("div");s.className="easy-form-rating",s.setAttribute("role","slider"),s.setAttribute("aria-valuemin","0"),s.setAttribute("aria-valuemax",String(e)),s.setAttribute("aria-valuenow",String(r)),s.setAttribute("aria-label",this.field.label||"Rating"),s.setAttribute("tabindex","0");let i=document.createElement("div");i.className="easy-form-rating-stars";for(let n=1;n<=e;n++){let o=document.createElement("button");o.type="button";let d=r>=n||a&&r>=n-.5;o.className=d?"easy-form-rating-star easy-form-rating-star-filled":"easy-form-rating-star",o.innerHTML=yt(d),o.setAttribute("aria-label",`${n} de ${e}`),o.addEventListener("click",c=>{c.preventDefault();let m=c.target.closest("button")?.getBoundingClientRect(),p=n;if(a&&m){let u=m.left+m.width/2;p=c.clientX<u?n-.5:n}this.onChange(p),this.onBlur(),this.rerenderStars(s,e,p,a),s.setAttribute("aria-valuenow",String(p))}),i.appendChild(o)}return s.appendChild(i),s.addEventListener("keydown",n=>{let o=Number(s.getAttribute("aria-valuenow"))||0,d=o;n.key==="ArrowRight"||n.key==="ArrowUp"?(n.preventDefault(),d=Math.min(e,a?o+.5:o+1),this.onChange(d)):(n.key==="ArrowLeft"||n.key==="ArrowDown")&&(n.preventDefault(),d=Math.max(0,a?o-.5:o-1),this.onChange(d)),d!==o&&(this.rerenderStars(s,e,d,a),s.setAttribute("aria-valuenow",String(d)))}),this.createFieldContainer(s)}rerenderStars(t,e,a,r){t.querySelectorAll(".easy-form-rating-star").forEach((i,n)=>{let o=n+1,d=a>=o||r&&a>=o-.5;i.className=d?"easy-form-rating-star easy-form-rating-star-filled":"easy-form-rating-star",i.innerHTML=yt(d)})}};var we=class extends x{render(){let t=this.field,e=t.min??0,a=t.max??100,r=t.step??1,s=t.showValue??!1,i=document.createElement("input");i.type="range",i.min=String(e),i.max=String(a),i.step=String(r),i.value=this.value!=null?String(this.value):String(e),i.setAttribute("aria-valuemin",String(e)),i.setAttribute("aria-valuemax",String(a)),i.setAttribute("aria-valuenow",i.value),this.applyCommonProps(i),i.addEventListener("input",o=>{let d=o.target,c=r>=1?parseInt(d.value,10):parseFloat(d.value);this.onChange(isNaN(c)?e:c),n&&(n.textContent=d.value),i.setAttribute("aria-valuenow",d.value)}),i.addEventListener("change",()=>{this.onBlur()});let n=null;if(s){n=document.createElement("span"),n.className="easy-form-slider-value",n.textContent=i.value;let o=document.createElement("div");return o.className="easy-form-slider-wrapper",o.appendChild(i),o.appendChild(n),this.createFieldContainer(o)}return this.createFieldContainer(i)}};var Jt=/^#?([0-9A-Fa-f]{6})$/;function Ne(l){let t=l.match(Jt);return t?`#${t[1].toLowerCase()}`:/^[0-9A-Fa-f]{6}$/.test(l)?`#${l.toLowerCase()}`:"#000000"}var Ee=class extends x{render(){let e=this.field.defaultValue??"#000000",a=this.value!=null&&typeof this.value=="string"?Ne(this.value):e,r=document.createElement("div");r.className="easy-form-color-wrapper";let s=document.createElement("input");s.type="color",s.value=a,s.setAttribute("value",a),s.setAttribute("aria-label",this.field.label||"Color"),s.id=`${this.getFieldId()}-picker`,this.field.disabled&&s.setAttribute("disabled","true");let i=document.createElement("input");i.type="text",i.value=a,i.setAttribute("aria-label",`${this.field.label||"Color"} (hex)`),i.placeholder="#000000",i.className="easy-form-color-text",this.applyCommonProps(i);let n=()=>{let d=s.value||"#000000",c=Ne(d);i.value=c,this.onChange(c)},o=()=>{let d=i.value.trim(),c=d.startsWith("#")?d:`#${d}`;if(/^#[0-9A-Fa-f]{6}$/.test(c)){let m=Ne(c);s.value=m,this.onChange(m)}};return s.addEventListener("input",n),s.addEventListener("change",()=>{n(),this.onBlur()}),i.addEventListener("input",o),i.addEventListener("blur",()=>{o(),this.onBlur()}),r.appendChild(s),r.appendChild(i),this.createFieldContainer(r)}};var ze=class extends x{constructor(){super(...arguments);this.textareaEl=null;this.previewEl=null;this.previewModeEl=null}render(){let e=this.field,a=e.mode??"split",r=e.toolbar??!0,s=e.height??"300px",i=document.createElement("div");return i.className=`easy-form-markdown easy-form-markdown-mode-${a}`,a==="tabs"?this.renderTabsMode(i,e,r,s):a==="preview"?this.renderPreviewMode(i,e,r,s):this.renderSplitMode(i,e,r,s),this.checkAndShowDependenciesMessage(),this.createFieldContainer(i)}renderSplitMode(e,a,r,s){if(r){let d=this.createToolbar();e.appendChild(d)}let i=document.createElement("div");i.className="easy-form-markdown-editor-wrapper easy-form-markdown-split";let n=document.createElement("textarea");n.className="easy-form-markdown-textarea",n.value=this.value||"",n.placeholder=a.placeholder||"Escribe en Markdown...",n.style.height=s,this.textareaEl=n,n.addEventListener("input",()=>{this.onChange(n.value),this.updatePreview()}),n.addEventListener("blur",()=>{this.onBlur()}),i.appendChild(n),e.appendChild(i);let o=document.createElement("div");o.className="easy-form-markdown-preview",o.style.height=s,this.previewEl=o,this.value?this.renderPreview(this.value,o):o.innerHTML='<div class="easy-form-markdown-preview-placeholder">Vista previa</div>',i.appendChild(o)}renderTabsMode(e,a,r,s){let i=document.createElement("div");i.className="easy-form-markdown-tabs";let n=document.createElement("div");n.className="easy-form-markdown-tabs-header";let o=document.createElement("button");o.type="button",o.className="easy-form-markdown-tab active",o.textContent="Editor",o.addEventListener("click",()=>this.switchTab("editor"));let d=document.createElement("button");d.type="button",d.className="easy-form-markdown-tab",d.textContent="Vista previa",d.addEventListener("click",()=>this.switchTab("preview")),n.appendChild(o),n.appendChild(d),i.appendChild(n);let c=document.createElement("div");if(c.className="easy-form-markdown-tabs-content",r){let u=this.createToolbar();c.appendChild(u)}let m=document.createElement("textarea");m.className="easy-form-markdown-textarea",m.value=this.value||"",m.placeholder=a.placeholder||"Escribe en Markdown...",m.style.height=s,this.textareaEl=m,m.addEventListener("input",()=>{this.onChange(m.value),d.classList.contains("active")&&this.renderPreview(m.value,this.previewEl)}),m.addEventListener("blur",()=>{this.onBlur()}),c.appendChild(m);let p=document.createElement("div");p.className="easy-form-markdown-preview",p.style.height=s,p.style.display="none",this.previewEl=p,this.value?this.renderPreview(this.value,p):p.innerHTML='<div class="easy-form-markdown-preview-placeholder">Vista previa</div>',c.appendChild(p),i.appendChild(c),e.appendChild(i),i._editorTab=o,i._previewTab=d,i._textarea=m,i._preview=p}renderPreviewMode(e,a,r,s){if(r){let d=this.createToolbar();e.appendChild(d)}let i=document.createElement("div");i.className="easy-form-markdown-preview-mode",i.style.height=s,this.previewModeEl=i;let n=document.createElement("div");n.className="easy-form-markdown-preview-mode-content",this.renderPreview(this.value||"",n);let o=document.createElement("textarea");o.className="easy-form-markdown-textarea-invisible",o.value=this.value||"",o.placeholder=a.placeholder||"Escribe...",o.setAttribute("aria-label","Editor de markdown"),o.addEventListener("input",()=>{this.onChange(o.value),this.renderPreview(o.value,n)}),o.addEventListener("blur",()=>{this.onBlur()}),i.appendChild(o),i.appendChild(n),e.appendChild(i)}switchTab(e){let a=this.textareaEl?.closest(".easy-form-markdown-tabs");if(!a)return;let r=a._editorTab,s=a._previewTab,i=a._textarea,n=a._preview;e==="editor"?(r.classList.add("active"),s.classList.remove("active"),i.style.display="block",n.style.display="none"):(r.classList.remove("active"),s.classList.add("active"),i.style.display="none",n.style.display="block",i.value&&this.renderPreview(i.value,n))}createToolbar(){let e=document.createElement("div");return e.className="easy-form-markdown-toolbar",[{icon:"<strong>B</strong>",title:"Negrita",prefix:"**",suffix:"**",placeholder:"texto en negrita"},{icon:"<em>I</em>",title:"Cursiva",prefix:"_",suffix:"_",placeholder:"texto en cursiva"},{icon:"H1",title:"Encabezado 1",prefix:"# ",suffix:"",placeholder:"t\xEDtulo"},{icon:"H2",title:"Encabezado 2",prefix:"## ",suffix:"",placeholder:"t\xEDtulo"},{icon:"\u{1F517}",title:"Enlace",prefix:"[",suffix:"](url)",placeholder:"texto del enlace"},{icon:"<code>&lt;/&gt;</code>",title:"C\xF3digo",prefix:"`",suffix:"`",placeholder:"c\xF3digo"},{icon:"\u{1F4F7}",title:"Imagen",prefix:"![",suffix:"](url)",placeholder:"texto alternativo"},{icon:"\u2022",title:"Lista",prefix:"- ",suffix:"",placeholder:"elemento"},{icon:"1.",title:"Lista numerada",prefix:"1. ",suffix:"",placeholder:"elemento"},{icon:'"',title:"Cita",prefix:"> ",suffix:"",placeholder:"cita"}].forEach(r=>{let s=document.createElement("button");s.type="button",s.className="easy-form-markdown-toolbar-btn",s.title=r.title,s.innerHTML=r.icon,s.addEventListener("click",()=>this.insertMarkdown(r.prefix,r.suffix,r.placeholder)),e.appendChild(s)}),e}insertMarkdown(e,a,r){let s=this.textareaEl;if(!s){if(this.previewModeEl){let p=this.previewModeEl.querySelector(".easy-form-markdown-textarea-invisible");p&&this.insertMarkdownToPreviewMode(p,e,a,r)}return}let i=s.selectionStart,n=s.selectionEnd,o=s.value,d=o.substring(i,n)||(r??""),c=o.substring(0,i)+e+d+a+o.substring(n);s.value=c;let m=i+e.length+d.length;s.setSelectionRange(m,m),s.focus(),this.onChange(c),this.updatePreview()}insertMarkdownToPreviewMode(e,a,r,s){let i=e.selectionStart,n=e.selectionEnd,o=e.value,d=o.substring(i,n)||(s??""),c=o.substring(0,i)+a+d+r+o.substring(n);e.value=c;let m=i+a.length+d.length;if(e.setSelectionRange(m,m),e.focus(),this.onChange(c),this.previewModeEl){let p=this.previewModeEl.querySelector(".easy-form-markdown-preview-mode-content");p&&this.renderPreview(c,p)}}updatePreview(){if(!this.previewEl)return;let e=this.textareaEl?.value||"";if(!e){this.previewEl.innerHTML='<div class="easy-form-markdown-preview-placeholder">Vista previa</div>';return}this.renderPreview(e,this.previewEl)}async renderPreview(e,a){if(!e||!e.trim()){a.innerHTML='<div class="easy-form-markdown-preview-placeholder">Vista previa</div>';return}a.innerHTML='<div class="easy-form-markdown-preview-loading">Cargando...</div>';try{let r=await Promise.resolve().then(()=>(Ge(),Ze)),i=await(r.default||r).parse(e);a.innerHTML=i}catch{a.innerHTML=`
2663
2779
  <div class="easy-form-markdown-error">
2664
2780
  <strong>Vista previa no disponible</strong><br><br>
2665
2781
  Instala <code>marked</code> para usar la vista previa:<br>
2666
2782
  <code>npm install marked</code><br><br>
2667
2783
  En tu app: <code>import 'marked'</code>
2668
2784
  </div>
2669
- `}}checkAndShowDependenciesMessage(){setTimeout(async()=>{try{await Promise.resolve().then(()=>(Ze(),Ye))}catch{let e=this.textareaEl?.closest(".easy-form-markdown")||this.previewModeEl?.closest(".easy-form-markdown");if(!e)return;let a=e.querySelector(".easy-form-markdown-preview-placeholder");a&&(a.innerHTML+='<br><small style="color:#888">Instala <code>marked</code> para renderizar</small>')}},100)}};function Nt(l,t,e,a,r){switch(l.type){case"text":case"email":return new se(l,t,e,a,r).render();case"password":return new ye(l,t,e,a,r).render();case"number":return new ie(l,t,e,a,r).render();case"textarea":return new oe(l,t,e,a,r).render();case"select":return new ne(l,t,e,a,r).render();case"checkbox":return new le(l,t,e,a,r).render();case"radio":return new de(l,t,e,a,r).render();case"switch":return new ce(l,t,e,a,r).render();case"date":return new pe(l,t,e,a,r).render();case"file":return new me(l,t,e,a,r).render();case"file-drop":return new ve(l,t,e,a,r).render();case"map":return new xe(l,t,e,a,r).render();case"rating":return new ke(l,t,e,a,r).render();case"slider":return new we(l,t,e,a,r).render();case"colorpicker":return new Ee(l,t,e,a,r).render();case"quantity":return new ue(l,t,e,a,r).render();case"accordion-select":return new fe(l,t,e,a,r).render();case"image-grid-select":return new he(l,t,e,a,r).render();case"otp":return new ge(l,t,e,a,r).render();case"markdown":return new Ae(l,t,e,a,r).render();default:let s=document.createElement("div");return s.textContent=`Tipo de campo no soportado: ${l.type}`,s}}var Dt=new Map;function Zr(l,t){Dt.set(l,t)}function Vt(l){for(let[t,e]of Object.entries(l))Zr(t,e)}function Ge(l){return Dt.get(l)}var Gr={fields:[{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"password",name:"password",label:"Password",placeholder:"Enter your password",validations:[{type:"required",message:"Password is required"},{type:"minLength",value:6,message:"Password must be at least 6 characters"}]},{type:"checkbox",name:"rememberMe",label:"Remember me",defaultValue:!1}]},Kr={fields:[{type:"text",name:"name",label:"Full Name",placeholder:"Enter your full name",validations:[{type:"required",message:"Name is required"},{type:"minLength",value:2,message:"Name must be at least 2 characters"}]},{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"password",name:"password",label:"Password",placeholder:"Create a password",validations:[{type:"required",message:"Password is required"},{type:"minLength",value:8,message:"Password must be at least 8 characters"}]},{type:"password",name:"confirmPassword",label:"Confirm Password",placeholder:"Confirm your password",validations:[{type:"required",message:"Please confirm your password"},{type:"custom",validator:l=>typeof l=="string"&&l.length>=8,message:"Password must be at least 8 characters"}]}]},Qr={fields:[{type:"otp",name:"code",label:"Verification Code",validations:[{type:"required",message:"Verification code is required"}]}]},Jr={fields:[{type:"text",name:"name",label:"Name",placeholder:"Enter your name",validations:[{type:"required",message:"Name is required"}]},{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"text",name:"subject",label:"Subject",placeholder:"Enter the subject",validations:[{type:"required",message:"Subject is required"}]},{type:"textarea",name:"message",label:"Message",placeholder:"Enter your message",rows:5,validations:[{type:"required",message:"Message is required"},{type:"minLength",value:10,message:"Message must be at least 10 characters"}]}]},Xr={fields:[{type:"email",name:"email",label:"Email",placeholder:"Enter your email address",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]}]},ea={fields:[{type:"password",name:"currentPassword",label:"Current Password",placeholder:"Enter your current password",validations:[{type:"required",message:"Current password is required"}]},{type:"password",name:"newPassword",label:"New Password",placeholder:"Enter your new password",validations:[{type:"required",message:"New password is required"},{type:"minLength",value:8,message:"Password must be at least 8 characters"}]},{type:"password",name:"confirmPassword",label:"Confirm New Password",placeholder:"Confirm your new password",validations:[{type:"required",message:"Please confirm your new password"},{type:"custom",validator:l=>typeof l=="string"&&l.length>=8,message:"Password must be at least 8 characters"}]}]},ta={fields:[{type:"text",name:"name",label:"Full Name",placeholder:"Enter your full name",validations:[{type:"required",message:"Name is required"}]},{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"text",name:"phone",label:"Phone",placeholder:"Enter your phone number",mask:{type:"phone"}},{type:"textarea",name:"bio",label:"Bio",placeholder:"Tell us about yourself",rows:4},{type:"file",name:"avatar",label:"Profile Picture",accept:"image/*"}]},ra={fields:[{type:"group",name:"billingAddress",label:"Billing Address",fields:[{type:"text",name:"street",label:"Street Address",placeholder:"Enter street address",validations:[{type:"required",message:"Street address is required"}]},{type:"row",name:"cityState",fields:[{type:"text",name:"city",label:"City",placeholder:"City",validations:[{type:"required",message:"City is required"}]},{type:"text",name:"state",label:"State",placeholder:"State",validations:[{type:"required",message:"State is required"}]}]},{type:"text",name:"zipCode",label:"ZIP Code",placeholder:"ZIP Code",validations:[{type:"required",message:"ZIP code is required"}]}]},{type:"select",name:"paymentMethod",label:"Payment Method",options:[{label:"Credit Card",value:"credit-card"},{label:"Debit Card",value:"debit-card"},{label:"PayPal",value:"paypal"},{label:"Bank Transfer",value:"bank-transfer"}],validations:[{type:"required",message:"Payment method is required"}]},{type:"select",name:"shipping",label:"Shipping Method",options:[{label:"Standard (5-7 days)",value:"standard"},{label:"Express (2-3 days)",value:"express"},{label:"Overnight",value:"overnight"}],validations:[{type:"required",message:"Shipping method is required"}]}]},aa={fields:[{type:"select",name:"rating",label:"Rating",options:[{label:"1 - Poor",value:1},{label:"2 - Fair",value:2},{label:"3 - Good",value:3},{label:"4 - Very Good",value:4},{label:"5 - Excellent",value:5}],validations:[{type:"required",message:"Rating is required"}]},{type:"textarea",name:"comment",label:"Comment",placeholder:"Share your feedback",rows:5,validations:[{type:"required",message:"Comment is required"}]},{type:"email",name:"email",label:"Email (optional)",placeholder:"Enter your email if you want a response"}]},sa={fields:[{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"checkbox",name:"weeklyNewsletter",label:"Weekly Newsletter",defaultValue:!0},{type:"checkbox",name:"productUpdates",label:"Product Updates",defaultValue:!1},{type:"checkbox",name:"promotions",label:"Promotions and Special Offers",defaultValue:!1}]},ia={fields:[{type:"date",name:"date",label:"Date",validations:[{type:"required",message:"Date is required"}]},{type:"text",name:"time",label:"Time",placeholder:"HH:MM",mask:{type:"time"},validations:[{type:"required",message:"Time is required"}]},{type:"number",name:"guests",label:"Number of Guests",placeholder:"Enter number of guests",min:1,max:20,validations:[{type:"required",message:"Number of guests is required"},{type:"min",value:1,message:"At least 1 guest is required"}]},{type:"textarea",name:"specialRequests",label:"Special Requests",placeholder:"Any special requests or dietary restrictions?",rows:4}]},oa={fields:[{type:"select",name:"rating",label:"Rating",options:[{label:"1 Star",value:1},{label:"2 Stars",value:2},{label:"3 Stars",value:3},{label:"4 Stars",value:4},{label:"5 Stars",value:5}],validations:[{type:"required",message:"Rating is required"}]},{type:"text",name:"title",label:"Review Title",placeholder:"Give your review a title",validations:[{type:"required",message:"Review title is required"},{type:"minLength",value:5,message:"Title must be at least 5 characters"}]},{type:"textarea",name:"comment",label:"Your Review",placeholder:"Share your experience",rows:6,validations:[{type:"required",message:"Review comment is required"},{type:"minLength",value:20,message:"Review must be at least 20 characters"}]}]},Ht={login:Gr,register:Kr,otp:Qr,contact:Jr,"password-reset":Xr,"password-change":ea,profile:ta,checkout:ra,feedback:aa,subscription:sa,booking:ia,review:oa};function Ke(l){return l in Ht?Ht[l]:null}function Bt(l,t){let e=Ke(l);if(!e)throw new Error(`Template "${l}" not found`);let a=e.fields||[],r=e.steps;if(r&&r.length>0){let s=r[r.length-1];return{...e,steps:[...r.slice(0,-1),{...s,fields:[...s.fields,...t]}]}}return{...e,fields:[...a,...t]}}var na=typeof HTMLElement<"u"?HTMLElement:class{},Qe=class extends na{constructor(){if(typeof HTMLElement>"u")throw new Error("EasyForm can only be used in a browser environment");super();this.customComponents={};this.isRendering=!1;this.attemptsLock=null;this.lockCountdownInterval=null;this.slotTemplates=null;this.skipPreserveValuesOnNextRender=!1;this.persistenceConfig=null;this.persistenceDebounceTimer=null;this.pendingRestoreValues=null;this.isRestoringValues=!1;this.completeTimeInterval=null;this.timeRemaining=0;this.timerStarted=!1;this.timerExpired=!1;this.dependencyRenderTimeout=null;this.stateManager=new re,this.shadow=this.attachShadow({mode:"open"})}static get observedAttributes(){return["schema","template","template-extend","theme","colors","initialData","loading","disabled","max-attempts","block-duration-minutes","attempts-storage-key","submit-button","label-position","show-completed-indicator","form-direction","complete-time"]}get schema(){let e=this.getAttribute("schema");return e?this.getAttribute("template")?(console.warn('EasyForm: Cannot use both "schema" and "template" attributes. "template" will be ignored.'),q(e)):q(e):null}set schema(e){e&&this.getAttribute("template")&&(console.warn('EasyForm: Setting "schema" will remove "template" attribute.'),this.removeAttribute("template"),this.removeAttribute("template-extend")),console.log("EasyForm: Setting schema via JS",e?.fields?.map(a=>({name:a.name,type:a.type,deps:!!a.dependencies}))),e?(this.setAttribute("schema",D(e)),this.handleSchemaChange()):this.removeAttribute("schema")}get template(){let e=this.getAttribute("template");return e?(this.getAttribute("schema")&&console.warn('EasyForm: Cannot use both "template" and "schema" attributes. "schema" will be ignored.'),e):null}set template(e){e&&this.getAttribute("schema")&&(console.warn('EasyForm: Setting "template" will remove "schema" attribute.'),this.removeAttribute("schema")),e?this.setAttribute("template",e):(this.removeAttribute("template"),this.removeAttribute("template-extend"))}get templateExtend(){let e=this.getAttribute("template-extend");return e?q(e):null}set templateExtend(e){e?this.setAttribute("template-extend",D(e)):this.removeAttribute("template-extend")}get maxAttempts(){let e=this.getAttribute("max-attempts");if(!e)return null;let a=parseInt(e,10);return isNaN(a)?null:a}set maxAttempts(e){e!=null&&e>=1?this.setAttribute("max-attempts",String(e)):this.removeAttribute("max-attempts")}get blockDurationMinutes(){let e=this.getAttribute("block-duration-minutes");if(!e)return null;let a=parseInt(e,10);return isNaN(a)?null:a}set blockDurationMinutes(e){e!=null&&e>=1?this.setAttribute("block-duration-minutes",String(e)):this.removeAttribute("block-duration-minutes")}get attemptsStorageKey(){return this.getAttribute("attempts-storage-key")}set attemptsStorageKey(e){e?this.setAttribute("attempts-storage-key",e):this.removeAttribute("attempts-storage-key")}get submitButton(){let e=this.getAttribute("submit-button");if(e)try{return q(e)}catch{return null}return null}set submitButton(e){e&&typeof e=="object"?this.setAttribute("submit-button",D(e)):this.removeAttribute("submit-button")}getSubmitButtonConfig(e){let a=this.submitButton,s={...e?.submitButton,...a};return{visible:s.visible??!0,text:s.text??"Enviar",width:s.width??"auto",align:s.align??"left"}}connectedCallback(){this.setupAttemptsLock(),this.setupStyles(),(this.hasAttribute("schema")||this.schema)&&this.render()}attributeChangedCallback(e,a,r){if(e==="schema"&&r!==a&&(this.getAttribute("template")&&(console.warn('EasyForm: "schema" and "template" cannot be used together. Removing "template".'),this.removeAttribute("template"),this.removeAttribute("template-extend")),this.handleSchemaChange()),e==="template"&&r!==a&&(this.getAttribute("schema")&&(console.warn('EasyForm: "template" and "schema" cannot be used together. Removing "schema".'),this.removeAttribute("schema")),this.handleSchemaChange()),e==="template-extend"&&r!==a&&this.handleSchemaChange(),e==="initialData"&&r!==a&&this.handleSchemaChange(),(e==="theme"||e==="colors")&&r!==a&&this.setupStyles(),e==="loading"&&r!==a){let s=this.shadow.querySelector("form");this.updateLoadingOverlay(s||void 0),s&&s.querySelectorAll("input, textarea, select, button").forEach(n=>{n instanceof HTMLElement&&"disabled"in n&&(n.disabled=this.loading)})}e==="disabled"&&r!==a&&this.render(),(e==="label-position"||e==="form-direction"||e==="show-completed-indicator")&&r!==a&&this.render(),(e==="max-attempts"||e==="block-duration-minutes"||e==="attempts-storage-key")&&r!==a&&(this.setupAttemptsLock(),this.updateLockOverlay()),e==="submit-button"&&r!==a&&this.render(),e==="complete-time"&&r!==a&&(this.resetTimer(),this.completeTime&&(this.timeRemaining=this.completeTime,this.render()))}setupAttemptsLock(){let e=this.maxAttempts;if(e==null||e<1){this.attemptsLock=null;return}this.attemptsLock=new W({maxAttempts:e,blockDurationMinutes:this.blockDurationMinutes??5,storageKey:this.attemptsStorageKey??void 0,onLocked:()=>{this.updateLockOverlay()},onUnlocked:()=>{this.stopLockCountdown(),this.updateLockOverlay(),this.render()}})}handleSchemaChange(){let e=null,a=this.template;if(a?e=this.getSchemaFromTemplate(a):e=this.schema,e){let r=this.initialData;this.stateManager.initializeSchema(e,r||void 0),this.initPersistence(e),this.render()}}getSchemaFromTemplate(e){let a=Ke(e);if(!a)return console.error(`EasyForm: Template "${e}" not found`),null;let r=this.templateExtend;return r&&r.length>0?Bt(e,r):a}async render(){if(!this.isRendering){this.isRendering=!0;try{let e=null,a=this.template;if(a?e=this.getSchemaFromTemplate(a):e=this.schema,!e){let E=this.shadow.querySelector("form");E&&E.parentNode===this.shadow&&E.remove();return}let r=this.skipPreserveValuesOnNextRender,s=r?{}:this.preserveCurrentValues();this.skipPreserveValuesOnNextRender=!1;let i=this.stateManager.getWizardState();if(s&&Object.keys(s).length>0)for(let[E,k]of Object.entries(s))this.stateManager.setValueWithoutValidation(E,k);let n=this.initialData,o=i!==null,d=e.steps&&e.steps.length>0;if(!r&&(!i||!o||!d||i&&e.steps&&i.totalSteps!==e.steps.length)&&(this.stateManager.initializeSchema(e,n||void 0),o&&d&&i)){let E=this.stateManager.getWizardState();if(E&&i.totalSteps===E.totalSteps){i.currentStep>=0&&i.currentStep<E.totalSteps&&this.stateManager.goToStep(i.currentStep);for(let k of i.completedSteps)k>=0&&k<E.totalSteps&&this.stateManager.completeStep(k)}}let m=this.stateManager.getWizardState(),p=document.createElement("form");p.addEventListener("submit",E=>this.handleSubmit(E)),(this.disabled||this.loading)&&p.classList.add("easy-form-disabled");let u=this.getAttribute("form-direction"),h=e.direction??(u==="vertical"||u==="horizontal"?u:"vertical");p.classList.add(`easy-form-direction-${h}`);let g=this.getAttribute("show-completed-indicator"),f=e.completedIndicator??(g!==null&&g!=="false"),y=typeof f=="object"&&f?.position?f.position:"top";if(m)this.renderWizard(p,e);else{this.renderFields(p,e.fields||[]);let E=this.getSubmitButtonConfig(e);if(E.visible){let k=document.createElement("div");k.className="easy-form-submit-wrapper",k.style.textAlign=E.align;let F=document.createElement("button");F.type="submit",F.textContent=E.text,F.className="easy-form-submit",F.style.width=E.width,(this.disabled||this.loading)&&(F.disabled=!0),k.appendChild(F),p.appendChild(k)}}let v=null;if(f){let{completed:E,total:k}=this.getCompletedRequiredProgress(e),F=document.createElement("div");F.className="easy-form-completed-indicator",F.setAttribute("role","progressbar"),F.setAttribute("aria-valuenow",String(E)),F.setAttribute("aria-valuemin","0"),F.setAttribute("aria-valuemax",String(k)),F.setAttribute("aria-label",`Campos obligatorios completados: ${E} de ${k}`);let $=document.createElement("div");$.className="easy-form-completed-track";let Ie=document.createElement("div");Ie.className="easy-form-completed-fill",Ie.style.width=k>0?`${E/k*100}%`:"0%",$.appendChild(Ie),F.appendChild($),v=document.createElement("div"),v.className="easy-form-wrapper",y==="top"?(v.appendChild(F),v.appendChild(p)):(v.appendChild(p),v.appendChild(F))}let b=this.shadow.querySelector("form");if(b&&b.parentNode===this.shadow&&b!==p)try{b.remove()}catch(E){console.warn("Error al eliminar formulario anterior:",E)}let w=this.shadow.querySelector(".easy-form-wrapper");w&&w.remove(),this.shadow.appendChild(v||p),this.completeTime&&!this.timerExpired&&(this.renderTimerDisplay(),this.setupTimerInputListener()),this.loading&&this.updateLoadingOverlay(p),this.updateLockOverlay(p)}finally{this.isRendering=!1,this.pendingRestoreValues&&this.applyPendingRestoreValues()}}}updateLockOverlay(e){let a=this.shadow.querySelector(".easy-form-lock-overlay");if(a&&a.remove(),this.stopLockCountdown(),!this.attemptsLock?.isLocked())return;let r=e||this.shadow.querySelector("form");if(!r)return;let s=document.createElement("div");s.className="easy-form-lock-overlay";let i=document.createElement("div");i.className="easy-form-lock-message",i.setAttribute("role","alert");let n=()=>{let o=this.attemptsLock.getRemainingBlockTimeMs();if(o<=0){this.stopLockCountdown();return}let d=Math.floor(o/6e4),c=Math.floor(o%6e4/1e3),m=d>0?`${d} min ${c} s`:`${c} segundos`;i.textContent=`Demasiados intentos. Intenta de nuevo en ${m}.`};n(),s.appendChild(i),r.appendChild(s),this.lockCountdownInterval=setInterval(n,1e3)}stopLockCountdown(){this.lockCountdownInterval&&(clearInterval(this.lockCountdownInterval),this.lockCountdownInterval=null)}updateLoadingOverlay(e){let a=this.shadow.querySelector(".easy-form-loading-overlay");if(a&&a.remove(),this.loading){let r=e||this.shadow.querySelector("form");if(r){let s=document.createElement("div");s.className="easy-form-loading-overlay";let i=document.createElement("div");i.className="easy-form-loading-spinner",s.appendChild(i),r.appendChild(s)}}}preserveCurrentValues(){let e=null,a=this.template;if(a?e=this.getSchemaFromTemplate(a):e=this.schema,!e)return{};let r=this.shadow.querySelector("form"),s={};if(!r)return s;let i=r.querySelectorAll("input, textarea, select");for(let n of i){let o=n.getAttribute("name");if(!o||!(this.findFieldInSchema(e,o)!==null))continue;let c;if(n instanceof HTMLInputElement)if(n.type==="checkbox")c=n.checked;else if(n.type==="radio")if(n.checked)c=n.value;else continue;else n.type==="number"?c=n.value===""?null:Number(n.value):c=n.value;else n instanceof HTMLTextAreaElement?c=n.value:n instanceof HTMLSelectElement&&(n.multiple?c=Array.from(n.selectedOptions).map(m=>m.value):c=n.value||null);c!==void 0&&(s[o]=c===""?null:c)}return s}initializeSlotTemplates(){if(this.slotTemplates!==null)return;let e=[];for(let a of Array.from(this.children))a instanceof HTMLElement&&e.push(a);if(e.length===0){this.slotTemplates=[];return}this.slotTemplates=e.map(a=>{let r=a.hasAttribute("row")?a.getAttribute("row"):null,s=r!=null&&r!==""?Number(r):NaN,i=Number.isFinite(s)?s:null;return{template:a.cloneNode(!0),row:i}})}getSlotClonesByRow(e){this.initializeSlotTemplates();let a=new Map;if(!this.slotTemplates||this.slotTemplates.length===0)return a;for(let{template:r,row:s}of this.slotTemplates){let i=typeof s=="number"?s:-1;Number.isFinite(i)||(i=-1),(i<0||i>=e)&&(i=-1);let n=r.cloneNode(!0),o=a.get(i)??[];o.push(n),a.set(i,o)}return a}applySlotDisabledState(e){if(!this.disabled&&!this.loading)return;e.classList.add("easy-form-slot-disabled"),e.querySelectorAll("input, textarea, select, button").forEach(r=>{"disabled"in r&&(r.disabled=!0)})}renderFields(e,a){if(a.length===0){let o=this.getSlotClonesByRow(0).get(-1);if(o&&o.length>0)for(let d of o)this.applySlotDisabledState(d),e.appendChild(d);return}let r=a.length,s=this.getSlotClonesByRow(r);for(let n=0;n<a.length;n++){let o=s.get(n);if(o&&o.length>0){for(let m of o)this.applySlotDisabledState(m),e.appendChild(m);s.delete(n)}let d=a[n],c=this.renderField(d);c&&e.appendChild(c)}let i=s.get(-1);if(i&&i.length>0)for(let n of i)this.applySlotDisabledState(n),e.appendChild(n)}renderField(e){let a=this.stateManager.getFieldVisibility(e.name),r=this.stateManager.getFieldEnabled(e.name);if(console.log(`Rendering field: ${e.name} (${e.type}), visible: ${a}, enabled: ${r}, hasDeps: ${!!e.dependencies}`),e.type==="group"){let f=this.renderGroup(e);return a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled"),f}if(e.type==="row"){let f=this.renderRow(e);return a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled"),f}if(e.type==="array"){let f=this.renderArray(e);return a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled"),f}if(e.type==="custom"){let f=this.renderCustom(e);return f&&(a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled")),f}let s=this.stateManager.getValue(e.name),i=this.stateManager.getErrors(e.name),n=i.length>0?i[0]:void 0,o=this.disabled||this.loading,d=this.getAttribute("label-position"),c=["up","down","left","right","none"],m=e.labelPosition??(d&&c.includes(d)?d:"up"),p={...e,disabled:o||!r||e.disabled,labelPosition:m},u=Ge(e.type);if(u){let f=u({field:p,value:s,error:n,onChange:y=>this.handleFieldChange(e.name,y),onBlur:()=>this.handleFieldBlur(e.name)});return f&&!a&&(f.style.display="none",f.classList.add("easy-form-field-hidden")),f}let h=Nt(p,s,n,f=>this.handleFieldChange(e.name,f),()=>this.handleFieldBlur(e.name)),g=h.querySelector(".easy-form-field")||h;return g instanceof HTMLElement&&g.setAttribute("data-field-name",e.name),a||(h.style.display="none",h.classList.add("easy-form-field-hidden")),h}renderGroup(e){let a=e,r=a.direction??"vertical",s=a.collapsible===!0,i=a.defaultOpen!==!1,n=document.createElement("div");if(n.className=`easy-form-group easy-form-direction-${r}`,e.name&&n.setAttribute("data-field-name",e.name),s){n.classList.add("easy-form-group-collapsible"),i||n.classList.add("easy-form-group-collapsed");let o=document.createElement("button");o.type="button",o.className="easy-form-group-header",o.setAttribute("aria-expanded",String(i));let d=`easy-form-group-${(e.name||"group").replace(/[^a-z0-9]/gi,"-")}-content`;o.setAttribute("aria-controls",d);let c=document.createElement("span");c.textContent=e.label||"Grupo";let m=document.createElement("span");m.className="easy-form-group-chevron",m.setAttribute("aria-hidden","true"),m.textContent="\u25BC",o.appendChild(c),o.appendChild(m),n.appendChild(o);let p=document.createElement("div");if(p.id=d,p.className="easy-form-group-content","fields"in e&&e.fields)for(let h of e.fields){let g=h.name.startsWith(e.name+".")?h.name:`${e.name}.${h.name}`,f={...h,name:g},y=this.renderField(f);y&&p.appendChild(y)}n.appendChild(p);let u=h=>{h?p.style.maxHeight=p.scrollHeight+"px":p.style.maxHeight="0"};i?requestAnimationFrame(()=>u(!0)):p.style.maxHeight="0",o.addEventListener("click",()=>{n.classList.contains("easy-form-group-collapsed")?(n.classList.remove("easy-form-group-collapsed"),o.setAttribute("aria-expanded","true"),u(!0)):(p.style.maxHeight=p.scrollHeight+"px",requestAnimationFrame(()=>{n.classList.add("easy-form-group-collapsed"),o.setAttribute("aria-expanded","false"),u(!1)}))})}else{if(e.label){let o=document.createElement("h3");o.className="easy-form-group-label",o.textContent=e.label,n.appendChild(o)}if("fields"in e&&e.fields)for(let o of e.fields){let d=o.name.startsWith(e.name+".")?o.name:`${e.name}.${o.name}`,c={...o,name:d},m=this.renderField(c);m&&n.appendChild(m)}}return n}renderRow(e){let a=document.createElement("div");a.className="easy-form-row";let r=e;if(a.style.display="flex",a.style.flexWrap="wrap",a.style.alignItems=r.align||"stretch",r.gap!==void 0){let s=typeof r.gap=="number"?`${r.gap}px`:r.gap;a.style.gap=s}else a.style.gap="1rem";if("fields"in e&&e.fields)for(let s of e.fields){let i=this.renderField(s);if(i){let n=document.createElement("div");n.style.flex="1",n.style.minWidth="0",n.appendChild(i),a.appendChild(n)}}return a}renderArray(e){let a=document.createElement("div");if(a.className="easy-form-array",a.setAttribute("data-field-name",e.name),e.label){let m=document.createElement("label");m.className="easy-form-label",m.textContent=e.label,a.appendChild(m)}let r=this.stateManager.getValue(e.name)||[],s=e,i=s.minItems??0,n=s.maxItems??1/0,o=document.createElement("div");o.className="easy-form-array-items";for(let m=0;m<r.length;m++){let p=document.createElement("div");if(p.className="easy-form-array-item",s.itemSchema?.fields)for(let g of s.itemSchema.fields){let f={...g,name:`${e.name}.${m}.${g.name}`},y=this.renderField(f);y&&p.appendChild(y)}let u=document.createElement("button");u.type="button",u.textContent="Eliminar",u.className="easy-form-array-remove";let h=r.length<=i;this.disabled||this.loading||h?u.disabled=!0:u.addEventListener("click",()=>{let g=[...r];g.splice(m,1),this.handleFieldChange(e.name,g)}),p.appendChild(u),o.appendChild(p)}a.appendChild(o);let d=document.createElement("button");d.type="button",d.textContent="Agregar",d.className="easy-form-array-add";let c=r.length>=n;return this.disabled||this.loading||c?d.disabled=!0:d.addEventListener("click",()=>{let m=this.stateManager.createDefaultArrayItem(e),p=[...r,m];this.handleFieldChange(e.name,p)}),a.appendChild(d),a}renderCustom(e){let a=Ge("custom");if(!a){let n=document.createElement("div");return n.textContent=`Componente custom no registrado para: ${e.name}`,n}let r=this.stateManager.getValue(e.name),s=this.stateManager.getErrors(e.name),i=s.length>0?s[0]:void 0;return a({field:e,value:r,error:i,onChange:n=>this.handleFieldChange(e.name,n),onBlur:()=>this.handleFieldBlur(e.name)})}getCompletedRequiredProgress(e){let a=c=>{let m=[];for(let p of c)if(p.type==="array"&&"itemSchema"in p&&p.itemSchema?.fields){let u=this.stateManager.getValue(p.name),h=Array.isArray(u)?u.length:0;for(let g=0;g<h;g++)for(let f of p.itemSchema.fields)m.push({...f,name:`${p.name}.${g}.${f.name}`})}else(p.type==="group"||p.type==="row")&&"fields"in p&&p.fields?m.push(...a(p.fields)):m.push(p);return m},r=e.steps?this.stateManager.getCurrentStepFields()||[]:e.fields||[],n=a(r).filter(c=>c.validations?.some(m=>m.type==="required")).filter(c=>this.stateManager.getFieldVisibility(c.name)),o=n.length;return{completed:n.filter(c=>{if(this.stateManager.getErrors(c.name).length>0)return!1;let p=this.stateManager.getValue(c.name);return!(p==null||typeof p=="string"&&p.trim()===""||Array.isArray(p)&&p.length===0&&c.type==="array")}).length,total:o}}renderWizard(e,a){let r=this.stateManager.getWizardState();if(!r)return;let s=document.createElement("div");s.className="easy-form-wizard";let i=document.createElement("div");i.className="easy-form-wizard-steps";let n=a?.stepStyle;if(n&&n!=="default"&&i.classList.add(`ef-stepper-${n}`),a?.steps)for(let p=0;p<a.steps.length;p++){let u=document.createElement("div");u.className="easy-form-wizard-step",p===r.currentStep&&u.classList.add("active"),r.completedSteps.includes(p)&&u.classList.add("completed"),u.textContent=a.steps[p].title,i.appendChild(u)}s.appendChild(i);let o=document.createElement("div");o.className="easy-form-wizard-fields";let d=this.stateManager.getCurrentStepFields();this.renderFields(o,d),s.appendChild(o);let c=document.createElement("div");if(c.className="easy-form-wizard-nav",r.currentStep>0){let p=document.createElement("button");p.type="button",p.textContent="Anterior",p.className="easy-form-wizard-prev",this.disabled||this.loading?p.disabled=!0:p.addEventListener("click",()=>{this.stateManager.getWizardState()&&this.stateManager.previousStep()&&(this.render(),this.emitStepChange())}),c.appendChild(p)}if(r.currentStep<r.totalSteps-1){let p=document.createElement("button");p.type="button",p.textContent="Siguiente",p.className="easy-form-wizard-next",this.disabled||this.loading?p.disabled=!0:p.addEventListener("click",async()=>{let u=this.stateManager.getWizardState();if(!u)return;let h=this.stateManager.getCurrentStepFields();for(let v of h)this.stateManager.getFieldVisibility(v.name)&&await this.stateManager.validateField(v.name);let g=this.stateManager.getAllErrors(),f={};for(let v of h)g[v.name]&&g[v.name].length>0&&(f[v.name]=g[v.name]);Object.keys(f).length>0?this.emitError(f):(this.stateManager.completeStep(u.currentStep),this.stateManager.nextStep()&&(this.render(),this.emitStepChange()))}),c.appendChild(p)}let m=this.getSubmitButtonConfig(a);if(r.currentStep===r.totalSteps-1&&m.visible){let p=document.createElement("button");p.type="button",p.textContent=m.text,p.className="easy-form-wizard-next",p.style.width=m.width,this.disabled||this.loading?p.disabled=!0:p.addEventListener("click",async()=>{let u=this.stateManager.getCurrentStepFields();for(let y of u)this.stateManager.getFieldVisibility(y.name)&&await this.stateManager.validateField(y.name);let h=this.stateManager.getAllErrors(),g={};for(let y of u)h[y.name]&&h[y.name].length>0&&(g[y.name]=h[y.name]);Object.keys(g).length>0?this.emitError(g):await this.handleSubmit(new Event("submit"))}),c.appendChild(p)}s.appendChild(c),e.appendChild(s)}async handleFieldChange(e,a){await this.stateManager.setValue(e,a),this.scheduleSave();let r=this.schema;if(r){let n=this.findFieldInSchema(r,e);n?.type==="array"&&(this.rerenderArrayField(n)||(this.skipPreserveValuesOnNextRender=!0,requestAnimationFrame(()=>this.render())))}let s=this.stateManager.getDependentFields(e);s.length>0&&(this.dependencyRenderTimeout&&clearTimeout(this.dependencyRenderTimeout),this.dependencyRenderTimeout=setTimeout(()=>{this.renderDependentFields(s),this.emitDependencyChange(e,s)},10));let i=new CustomEvent("change",{detail:{field:e,value:a,values:this.stateManager.getState().values},bubbles:!0,composed:!0});this.dispatchEvent(i)}rerenderArrayField(e){let a=this.shadow.querySelector(`[data-field-name="${e.name}"].easy-form-array`);if(!a?.parentNode)return!1;let r=this.renderArray(e);return a.parentNode.replaceChild(r,a),!0}renderDependentFields(e){let a=this.schema;if(!a)return;let r=this.getAllFieldsWithDependencies(a),s=r.length>0;console.log("renderDependentFields:",{fieldNames:e,hasAnyFieldsWithDeps:s,allFieldsWithDeps:r.map(o=>o.name)});let i=this.shadow.querySelector("form");if(!i)return;let n=new Set;for(let o of e)n.add(o);for(let o of e)this.stateManager.getDependentFields(o).forEach(c=>n.add(c));for(let o of n){let d=i.querySelector(`[data-field-name="${o}"]`);if(d||(d=i.querySelector(`.easy-form-field[name="${o}"]`)),d||(d=i.querySelector(`[data-field-name="${o}"], [data-group-name="${o}"]`)),d){let c=this.findFieldInSchema(a,o);if(!c)continue;let m=d.parentElement;if(m){let p=this.renderField(c);p&&m.replaceChild(p,d)}}}}getAllFieldsWithDependencies(e){let a=[],r=i=>{for(let n of i)n.dependencies&&a.push(n),n.type==="group"&&"fields"in n&&r(n.fields),n.type==="row"&&"fields"in n&&r(n.fields),n.type==="array"&&"itemSchema"in n&&n.itemSchema?.fields&&r(n.itemSchema.fields)},s=e.isWizard?e.steps.flatMap(i=>i.fields):e.fields||[];return r(s),a}emitDependencyChange(e,a){let r=new CustomEvent("dependencyChange",{detail:{changedField:e,affectedFields:a},bubbles:!0,composed:!0});this.dispatchEvent(r)}async handleFieldBlur(e){this.stateManager.setTouched(e),await this.stateManager.validateField(e),this.updateSingleField(e)}updateSingleField(e){let a=this.schema;if(!a||!this.findFieldInSchema(a,e))return;let s=this.stateManager.getErrors(e),i=s.length>0?s[0]:void 0,n=this.shadow.querySelector(`[name="${e}"]`)?.closest(".easy-form-field");if(!n)return;let o=n.querySelector(".easy-form-error");if(i){if(o)o.textContent=i;else{let c=document.createElement("p");c.className="easy-form-error",c.textContent=i,n.appendChild(c)}n.querySelector("input, textarea, select")?.classList.add("easy-form-input-error")}else o?.remove(),n.querySelector("input, textarea, select")?.classList.remove("easy-form-input-error")}findFieldInSchema(e,a){let r=e.fields||[],s=a.indexOf(".");if(s>0){let i=a.slice(0,s),n=a.slice(s+1),o=r.find(d=>d.name===i);if(!o)return null;if((o.type==="group"||o.type==="row")&&"fields"in o&&o.fields){let d=this.findFieldInSchema({fields:o.fields},n);return d?{...d,name:a}:null}return null}for(let i of r){if(i.name===a)return i;if(i.type==="group"&&"fields"in i){let n=this.findFieldInSchema({fields:i.fields},a);if(n)return n}if(i.type==="row"&&"fields"in i){let n=this.findFieldInSchema({fields:i.fields},a);if(n)return n}}return null}async handleSubmit(e){if(e.preventDefault(),this.attemptsLock?.isLocked())return;if(this.timerExpired){this.emitError({form:["El tiempo ha expirado. No puedes enviar el formulario."]});return}let a=await this.stateManager.validateForm(),r=this.stateManager.getState();if(Object.keys(a).length>0){for(let n of Object.keys(a))this.updateSingleField(n);this.emitError(a);return}let s={values:r.values,isValid:!0,errors:{}};this.completeTime&&this.timerStarted&&(s.timeRemaining=this.timeRemaining);let i=new CustomEvent("submit",{detail:s,bubbles:!0,composed:!0});this.dispatchEvent(i),this.clearPersistence()}emitError(e){let a=new CustomEvent("error",{detail:{errors:e},bubbles:!0,composed:!0});this.dispatchEvent(a)}emitStepChange(){let e=this.stateManager.getWizardState();if(!e)return;let a=new CustomEvent("stepChange",{detail:{currentStep:e.currentStep,previousStep:e.currentStep>0?e.currentStep-1:e.currentStep,totalSteps:e.totalSteps},bubbles:!0,composed:!0});this.dispatchEvent(a)}registerComponents(e){this.customComponents={...this.customComponents,...e},Vt(e)}reset(){this.stateManager.reset(),this.render()}incrementAttempts(){this.attemptsLock?.incrementAttempts(),this.attemptsLock?.isLocked()&&this.updateLockOverlay()}resetAttempts(){this.attemptsLock?.reset(),this.stopLockCountdown(),this.updateLockOverlay(),this.render()}isLocked(){return this.attemptsLock?.isLocked()??!1}getRemainingBlockTimeMs(){return this.attemptsLock?.getRemainingBlockTimeMs()??0}requestSubmit(){let e=this.shadow.querySelector("form");e&&typeof e.requestSubmit=="function"&&e.requestSubmit()}clear(){let e=this.schema,a=this.template,r=null;a?r=this.getSchemaFromTemplate(a):r=e,r&&(this.stateManager.initializeSchema(r,{}),this.render())}getValues(){return this.stateManager.getState().values}getValue(e){return this.stateManager.getValue(e)}async setValue(e,a){await this.stateManager.setValue(e,a),this.render()}async setValues(e){for(let[a,r]of Object.entries(e))await this.stateManager.setValue(a,r);this.render()}async validate(){let e=await this.stateManager.validateForm();if(Object.keys(e).length>0){for(let a of Object.keys(e))this.updateSingleField(a);this.emitError(e)}else this.shadow.querySelectorAll(".easy-form-error").forEach(s=>s.remove()),this.shadow.querySelectorAll(".easy-form-input-error").forEach(s=>s.classList.remove("easy-form-input-error"));return e}async validateField(e){return await this.stateManager.validateField(e),this.updateSingleField(e),this.stateManager.getErrors(e)}getErrors(){return this.stateManager.getAllErrors()}getFieldErrors(e){return this.stateManager.getErrors(e)}isValid(){return this.stateManager.getState().isValid}get theme(){let e=this.getAttribute("theme");return e&&["plano","tradicional","material","rounded-shadow","lines","shadcn","chakra","mantine","glass","bordered","minimal","efc"].includes(e)?e:"plano"}set theme(e){e?this.setAttribute("theme",e):this.removeAttribute("theme")}get colors(){let e=this.getAttribute("colors");return e?q(e):null}set colors(e){e?this.setAttribute("colors",D(e)):this.removeAttribute("colors")}get initialData(){let e=this.getAttribute("initialData");return e?q(e):null}set initialData(e){e?this.setAttribute("initialData",D(e)):this.removeAttribute("initialData")}get loading(){return this.hasAttribute("loading")}set loading(e){e?this.setAttribute("loading",""):this.removeAttribute("loading")}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get completeTime(){let e=this.getAttribute("complete-time");if(!e)return null;let a=parseInt(e,10);return isNaN(a)||a<=0?null:a}set completeTime(e){e!=null&&e>0?this.setAttribute("complete-time",String(e)):this.removeAttribute("complete-time")}setupStyles(){let e=this.shadow.querySelector("style");e&&e.remove();let a=this.theme,r=O(this.colors||void 0),s=X(a,r),i=document.createElement("style");i.textContent=s,this.shadow.firstChild?this.shadow.insertBefore(i,this.shadow.firstChild):this.shadow.appendChild(i)}initPersistence(e){if(!e.persistence||!e.persistence.enabled){this.persistenceConfig=null;return}this.persistenceConfig={enabled:!0,key:e.persistence.key,autoSave:e.persistence.autoSave??!0,debounce:e.persistence.debounce??500,onRestore:e.persistence.onRestore},this.restoreFromStorage()}restoreFromStorage(){if(!(!this.persistenceConfig||!this.persistenceConfig.enabled)&&this.persistenceConfig.key)try{let e=localStorage.getItem(this.persistenceConfig.key);if(e){let a=JSON.parse(e);a&&typeof a=="object"&&(this.pendingRestoreValues=a,this.persistenceConfig.onRestore&&this.persistenceConfig.onRestore(a))}}catch(e){console.warn("EasyForm: Error restoring from localStorage:",e)}}applyPendingRestoreValues(){if(!this.pendingRestoreValues||this.isRestoringValues)return;this.isRestoringValues=!0;let e={...this.pendingRestoreValues};this.pendingRestoreValues=null;for(let[a,r]of Object.entries(e))this.stateManager.setValueWithoutValidation(a,r);this.updateInputsWithValues(e),this.isRestoringValues=!1}updateInputsWithValues(e){for(let a of Object.keys(e)){let r=this.shadow.querySelector(`[name="${a}"]`);r&&(r.value=e[a]??"")}}saveToStorage(){if(!(!this.persistenceConfig||!this.persistenceConfig.enabled)&&this.persistenceConfig.key)try{let e=this.stateManager.getState().values;localStorage.setItem(this.persistenceConfig.key,JSON.stringify(e))}catch(e){console.warn("EasyForm: Error saving to localStorage:",e)}}scheduleSave(){!this.persistenceConfig||!this.persistenceConfig.enabled||this.persistenceConfig.autoSave&&(this.persistenceDebounceTimer&&clearTimeout(this.persistenceDebounceTimer),this.persistenceDebounceTimer=setTimeout(()=>{this.saveToStorage()},this.persistenceConfig.debounce))}clearPersistence(){if(!(!this.persistenceConfig||!this.persistenceConfig.key))try{localStorage.removeItem(this.persistenceConfig.key)}catch(e){console.warn("EasyForm: Error clearing localStorage:",e)}}resetTimer(){this.completeTimeInterval&&(clearInterval(this.completeTimeInterval),this.completeTimeInterval=null),this.timerStarted=!1,this.timerExpired=!1,this.completeTime&&(this.timeRemaining=this.completeTime)}startTimer(){this.timerStarted||this.timerExpired||!this.completeTime||(this.timerStarted=!0,this.timeRemaining=this.completeTime,this.updateTimerDisplay(),this.completeTimeInterval=setInterval(()=>{this.timeRemaining--,this.updateTimerDisplay(),this.timeRemaining<=0&&this.handleTimerExpired()},1e3))}updateTimerDisplay(){let e=this.shadow.querySelector(".easy-form-timer");if(!e)return;let a=Math.floor(this.timeRemaining/60),r=this.timeRemaining%60,s=`${a}:${r.toString().padStart(2,"0")}`;e.textContent=s,this.timeRemaining<=30&&e.classList.add("easy-form-timer-warning"),this.timeRemaining<=10&&e.classList.add("easy-form-timer-danger")}handleTimerExpired(){this.completeTimeInterval&&(clearInterval(this.completeTimeInterval),this.completeTimeInterval=null),this.timerExpired=!0;let e=new CustomEvent("timeout",{detail:{originalTime:this.completeTime||0,expiredAt:new Date},bubbles:!0,composed:!0});this.dispatchEvent(e),this.disableAllFields()}disableAllFields(){let e=this.shadow.querySelector("form");if(!e)return;e.querySelectorAll("input, textarea, select, button").forEach(s=>{(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement||s instanceof HTMLButtonElement&&s.type!=="submit")&&(s.disabled=!0)}),e.classList.add("easy-form-timer-expired");let r=this.shadow.querySelector(".easy-form-timer");r&&(r.classList.add("easy-form-timer-expired"),r.textContent="Tiempo agotado")}setupTimerInputListener(){if(!this.completeTime||this.timerStarted)return;let e=this.shadow.querySelector("form");if(!e)return;let a=()=>{!this.timerStarted&&!this.timerExpired&&this.startTimer()};e.addEventListener("input",a,{once:!0})}renderTimerDisplay(){let e=this.shadow.querySelector(".easy-form-timer");e&&e.remove();let a=this.shadow.querySelector("form");if(!a)return;let r=document.createElement("div");r.className="easy-form-timer";let s=this.completeTime||0,i=Math.floor(s/60),n=s%60;r.textContent=`${i}:${n.toString().padStart(2,"0")}`,a.insertBefore(r,a.firstChild)}};typeof window<"u"&&typeof customElements<"u"&&!customElements.get("easy-form")&&customElements.define("easy-form",Qe);export{Qe as EasyForm};
2785
+ `}}checkAndShowDependenciesMessage(){setTimeout(async()=>{try{await Promise.resolve().then(()=>(Ge(),Ze))}catch{let e=this.textareaEl?.closest(".easy-form-markdown")||this.previewModeEl?.closest(".easy-form-markdown");if(!e)return;let a=e.querySelector(".easy-form-markdown-preview-placeholder");a&&(a.innerHTML+='<br><small style="color:#888">Instala <code>marked</code> para renderizar</small>')}},100)}};var Ie=class extends x{constructor(){super(...arguments);this.selectedTags=[];this.inputElement=null;this.dropdownElement=null;this.tagsContainer=null}render(){let e=document.createElement("div");e.className="easy-form-autocomplete-tags-container";let a=this.field;return this.selectedTags=this.initializeSelectedTags(a),this.tagsContainer=document.createElement("div"),this.tagsContainer.className="easy-form-autocomplete-tags",this.renderTags(),e.appendChild(this.tagsContainer),this.inputElement=document.createElement("input"),this.inputElement.type="text",this.inputElement.className="easy-form-autocomplete-tags-input",this.inputElement.placeholder=a.placeholder||"Escribe para buscar...",this.inputElement.setAttribute("autocomplete","off"),a.disabled&&(this.inputElement.disabled=!0),e.appendChild(this.inputElement),this.dropdownElement=document.createElement("ul"),this.dropdownElement.className="easy-form-autocomplete-tags-dropdown",this.dropdownElement.style.display="none",e.appendChild(this.dropdownElement),this.setupEventListeners(a),this.applyCommonProps(e.querySelector("input")),this.createFieldContainer(e)}initializeSelectedTags(e){let a=this.value;if(!a||!Array.isArray(a)||a.length===0)return[];let r=[];for(let s of a){let i=e.options.find(n=>{let o=typeof n=="string"?n:n.value;return String(o)===String(s)});if(i){let n=typeof i=="string"?i:i.label,o=typeof i=="string"?i:String(i.value);r.push({label:n,value:o})}else r.push({label:String(s),value:String(s)})}return r}renderTags(){if(this.tagsContainer){this.tagsContainer.innerHTML="";for(let e=0;e<this.selectedTags.length;e++){let a=this.selectedTags[e],r=document.createElement("span");r.className="easy-form-tag",r.setAttribute("data-index",String(e));let s=document.createElement("span");s.className="easy-form-tag-label",s.textContent=a.label,r.appendChild(s);let i=document.createElement("button");i.className="easy-form-tag-remove",i.type="button",i.setAttribute("aria-label",`Eliminar ${a.label}`),i.innerHTML="&times;",i.addEventListener("click",n=>{n.stopPropagation(),this.removeTag(e)}),r.appendChild(i),this.tagsContainer.appendChild(r)}}}removeTag(e){this.selectedTags.splice(e,1),this.renderTags(),this.notifyChange()}setupEventListeners(e){if(!this.inputElement||!this.dropdownElement)return;let a=e.minChars??0;this.inputElement.addEventListener("input",()=>{let r=this.inputElement.value.toLowerCase();if(r.length<a){this.dropdownElement.style.display="none";return}let s=this.filterOptions(e.options,r);this.renderDropdown(s,e)}),this.inputElement.addEventListener("keydown",r=>{if(r.key==="Enter"){r.preventDefault();let s=this.inputElement.value.trim();s&&this.addTagFromInput(e,s)}else r.key==="Backspace"&&this.inputElement.value===""&&this.selectedTags.length>0&&this.removeTag(this.selectedTags.length-1)}),this.inputElement.addEventListener("focus",()=>{let r=this.inputElement.value.toLowerCase();if(r.length>=a){let s=this.filterOptions(e.options,r);this.renderDropdown(s,e)}}),this.inputElement.addEventListener("click",r=>{r.stopPropagation();let s=this.inputElement.value.toLowerCase();if(s.length>=a){let i=this.filterOptions(e.options,s);this.renderDropdown(i,e)}else if(s.length===0){let i=this.filterOptions(e.options,"");this.renderDropdown(i,e)}}),document.addEventListener("click",r=>{let s=r.target;!this.dropdownElement.contains(s)&&s!==this.inputElement&&!this.tagsContainer?.contains(s)&&(this.dropdownElement.style.display="none")}),this.inputElement.addEventListener("blur",()=>{setTimeout(()=>{this.dropdownElement.style.display="none",this.onBlur()},150)})}filterOptions(e,a){let r=[];for(let s of e){let i=typeof s=="string"?s:s.label,n=typeof s=="string"?s:String(s.value);i.toLowerCase().includes(a)&&(this.selectedTags.some(d=>d.value.toLowerCase()===n.toLowerCase())||r.push({label:i,value:n}))}return r}renderDropdown(e,a){if(!this.dropdownElement||!this.inputElement)return;if(this.dropdownElement.innerHTML="",e.length===0){this.dropdownElement.style.display="none";return}let r=a.maxTags??1/0;if(this.selectedTags.length>=r){this.dropdownElement.style.display="none";return}for(let s of e){let i=document.createElement("li");i.className="easy-form-autocomplete-tags-option",i.textContent=s.label,i.setAttribute("role","option"),i.addEventListener("click",()=>{this.addTag(s),this.inputElement.value="",this.dropdownElement.style.display="none"}),this.dropdownElement.appendChild(i)}this.dropdownElement.style.display="block"}addTag(e){let r=this.field.maxTags??1/0;this.selectedTags.length>=r||this.selectedTags.some(i=>i.value.toLowerCase()===e.value.toLowerCase())||(this.selectedTags.push(e),this.renderTags(),this.notifyChange())}addTagFromInput(e,a){let r=e.options.find(s=>(typeof s=="string"?s:s.label).toLowerCase()===a.toLowerCase());if(r){let s=typeof r=="string"?r:r.label,i=typeof r=="string"?r:String(r.value);this.addTag({label:s,value:i}),this.inputElement.value="",this.dropdownElement.style.display="none"}else{let s=this.filterOptions(e.options,a);if(s.length>0)this.addTag(s[0]),this.inputElement.value="",this.dropdownElement.style.display="none";else{let i=e.maxTags??1/0;this.selectedTags.length<i&&(this.addTag({label:a,value:a}),this.inputElement.value="",this.dropdownElement.style.display="none")}}}notifyChange(){let e=this.selectedTags.map(a=>a.value);this.onChange(e.length>0?e:null)}};function Dt(l,t,e,a,r){switch(l.type){case"text":case"email":return new se(l,t,e,a,r).render();case"password":return new ye(l,t,e,a,r).render();case"number":return new ie(l,t,e,a,r).render();case"textarea":return new oe(l,t,e,a,r).render();case"select":return new ne(l,t,e,a,r).render();case"checkbox":return new le(l,t,e,a,r).render();case"radio":return new de(l,t,e,a,r).render();case"switch":return new ce(l,t,e,a,r).render();case"date":return new pe(l,t,e,a,r).render();case"file":return new me(l,t,e,a,r).render();case"file-drop":return new ve(l,t,e,a,r).render();case"map":return new xe(l,t,e,a,r).render();case"rating":return new ke(l,t,e,a,r).render();case"slider":return new we(l,t,e,a,r).render();case"colorpicker":return new Ee(l,t,e,a,r).render();case"quantity":return new ue(l,t,e,a,r).render();case"accordion-select":return new fe(l,t,e,a,r).render();case"image-grid-select":return new he(l,t,e,a,r).render();case"otp":return new ge(l,t,e,a,r).render();case"markdown":return new ze(l,t,e,a,r).render();case"autocomplete-tags":return new Ie(l,t,e,a,r).render();default:let s=document.createElement("div");return s.textContent=`Tipo de campo no soportado: ${l.type}`,s}}var Vt=new Map;function Gr(l,t){Vt.set(l,t)}function Ht(l){for(let[t,e]of Object.entries(l))Gr(t,e)}function Ke(l){return Vt.get(l)}var Kr={fields:[{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"password",name:"password",label:"Password",placeholder:"Enter your password",validations:[{type:"required",message:"Password is required"},{type:"minLength",value:6,message:"Password must be at least 6 characters"}]},{type:"checkbox",name:"rememberMe",label:"Remember me",defaultValue:!1}]},Qr={fields:[{type:"text",name:"name",label:"Full Name",placeholder:"Enter your full name",validations:[{type:"required",message:"Name is required"},{type:"minLength",value:2,message:"Name must be at least 2 characters"}]},{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"password",name:"password",label:"Password",placeholder:"Create a password",validations:[{type:"required",message:"Password is required"},{type:"minLength",value:8,message:"Password must be at least 8 characters"}]},{type:"password",name:"confirmPassword",label:"Confirm Password",placeholder:"Confirm your password",validations:[{type:"required",message:"Please confirm your password"},{type:"custom",validator:l=>typeof l=="string"&&l.length>=8,message:"Password must be at least 8 characters"}]}]},Jr={fields:[{type:"otp",name:"code",label:"Verification Code",validations:[{type:"required",message:"Verification code is required"}]}]},Xr={fields:[{type:"text",name:"name",label:"Name",placeholder:"Enter your name",validations:[{type:"required",message:"Name is required"}]},{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"text",name:"subject",label:"Subject",placeholder:"Enter the subject",validations:[{type:"required",message:"Subject is required"}]},{type:"textarea",name:"message",label:"Message",placeholder:"Enter your message",rows:5,validations:[{type:"required",message:"Message is required"},{type:"minLength",value:10,message:"Message must be at least 10 characters"}]}]},ea={fields:[{type:"email",name:"email",label:"Email",placeholder:"Enter your email address",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]}]},ta={fields:[{type:"password",name:"currentPassword",label:"Current Password",placeholder:"Enter your current password",validations:[{type:"required",message:"Current password is required"}]},{type:"password",name:"newPassword",label:"New Password",placeholder:"Enter your new password",validations:[{type:"required",message:"New password is required"},{type:"minLength",value:8,message:"Password must be at least 8 characters"}]},{type:"password",name:"confirmPassword",label:"Confirm New Password",placeholder:"Confirm your new password",validations:[{type:"required",message:"Please confirm your new password"},{type:"custom",validator:l=>typeof l=="string"&&l.length>=8,message:"Password must be at least 8 characters"}]}]},ra={fields:[{type:"text",name:"name",label:"Full Name",placeholder:"Enter your full name",validations:[{type:"required",message:"Name is required"}]},{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"text",name:"phone",label:"Phone",placeholder:"Enter your phone number",mask:{type:"phone"}},{type:"textarea",name:"bio",label:"Bio",placeholder:"Tell us about yourself",rows:4},{type:"file",name:"avatar",label:"Profile Picture",accept:"image/*"}]},aa={fields:[{type:"group",name:"billingAddress",label:"Billing Address",fields:[{type:"text",name:"street",label:"Street Address",placeholder:"Enter street address",validations:[{type:"required",message:"Street address is required"}]},{type:"row",name:"cityState",fields:[{type:"text",name:"city",label:"City",placeholder:"City",validations:[{type:"required",message:"City is required"}]},{type:"text",name:"state",label:"State",placeholder:"State",validations:[{type:"required",message:"State is required"}]}]},{type:"text",name:"zipCode",label:"ZIP Code",placeholder:"ZIP Code",validations:[{type:"required",message:"ZIP code is required"}]}]},{type:"select",name:"paymentMethod",label:"Payment Method",options:[{label:"Credit Card",value:"credit-card"},{label:"Debit Card",value:"debit-card"},{label:"PayPal",value:"paypal"},{label:"Bank Transfer",value:"bank-transfer"}],validations:[{type:"required",message:"Payment method is required"}]},{type:"select",name:"shipping",label:"Shipping Method",options:[{label:"Standard (5-7 days)",value:"standard"},{label:"Express (2-3 days)",value:"express"},{label:"Overnight",value:"overnight"}],validations:[{type:"required",message:"Shipping method is required"}]}]},sa={fields:[{type:"select",name:"rating",label:"Rating",options:[{label:"1 - Poor",value:1},{label:"2 - Fair",value:2},{label:"3 - Good",value:3},{label:"4 - Very Good",value:4},{label:"5 - Excellent",value:5}],validations:[{type:"required",message:"Rating is required"}]},{type:"textarea",name:"comment",label:"Comment",placeholder:"Share your feedback",rows:5,validations:[{type:"required",message:"Comment is required"}]},{type:"email",name:"email",label:"Email (optional)",placeholder:"Enter your email if you want a response"}]},ia={fields:[{type:"email",name:"email",label:"Email",placeholder:"Enter your email",validations:[{type:"required",message:"Email is required"},{type:"email",message:"Please enter a valid email"}]},{type:"checkbox",name:"weeklyNewsletter",label:"Weekly Newsletter",defaultValue:!0},{type:"checkbox",name:"productUpdates",label:"Product Updates",defaultValue:!1},{type:"checkbox",name:"promotions",label:"Promotions and Special Offers",defaultValue:!1}]},oa={fields:[{type:"date",name:"date",label:"Date",validations:[{type:"required",message:"Date is required"}]},{type:"text",name:"time",label:"Time",placeholder:"HH:MM",mask:{type:"time"},validations:[{type:"required",message:"Time is required"}]},{type:"number",name:"guests",label:"Number of Guests",placeholder:"Enter number of guests",min:1,max:20,validations:[{type:"required",message:"Number of guests is required"},{type:"min",value:1,message:"At least 1 guest is required"}]},{type:"textarea",name:"specialRequests",label:"Special Requests",placeholder:"Any special requests or dietary restrictions?",rows:4}]},na={fields:[{type:"select",name:"rating",label:"Rating",options:[{label:"1 Star",value:1},{label:"2 Stars",value:2},{label:"3 Stars",value:3},{label:"4 Stars",value:4},{label:"5 Stars",value:5}],validations:[{type:"required",message:"Rating is required"}]},{type:"text",name:"title",label:"Review Title",placeholder:"Give your review a title",validations:[{type:"required",message:"Review title is required"},{type:"minLength",value:5,message:"Title must be at least 5 characters"}]},{type:"textarea",name:"comment",label:"Your Review",placeholder:"Share your experience",rows:6,validations:[{type:"required",message:"Review comment is required"},{type:"minLength",value:20,message:"Review must be at least 20 characters"}]}]},Bt={login:Kr,register:Qr,otp:Jr,contact:Xr,"password-reset":ea,"password-change":ta,profile:ra,checkout:aa,feedback:sa,subscription:ia,booking:oa,review:na};function Qe(l){return l in Bt?Bt[l]:null}function Ot(l,t){let e=Qe(l);if(!e)throw new Error(`Template "${l}" not found`);let a=e.fields||[],r=e.steps;if(r&&r.length>0){let s=r[r.length-1];return{...e,steps:[...r.slice(0,-1),{...s,fields:[...s.fields,...t]}]}}return{...e,fields:[...a,...t]}}var la=typeof HTMLElement<"u"?HTMLElement:class{},Je=class extends la{constructor(){if(typeof HTMLElement>"u")throw new Error("EasyForm can only be used in a browser environment");super();this.customComponents={};this.isRendering=!1;this.attemptsLock=null;this.lockCountdownInterval=null;this.slotTemplates=null;this.skipPreserveValuesOnNextRender=!1;this.persistenceConfig=null;this.persistenceDebounceTimer=null;this.pendingRestoreValues=null;this.isRestoringValues=!1;this.completeTimeInterval=null;this.timeRemaining=0;this.timerStarted=!1;this.timerExpired=!1;this.dependencyRenderTimeout=null;this.stateManager=new re,this.shadow=this.attachShadow({mode:"open"})}static get observedAttributes(){return["schema","template","template-extend","theme","colors","initialData","loading","disabled","max-attempts","block-duration-minutes","attempts-storage-key","submit-button","label-position","show-completed-indicator","form-direction","complete-time"]}get schema(){let e=this.getAttribute("schema");return e?this.getAttribute("template")?(console.warn('EasyForm: Cannot use both "schema" and "template" attributes. "template" will be ignored.'),q(e)):q(e):null}set schema(e){e&&this.getAttribute("template")&&(console.warn('EasyForm: Setting "schema" will remove "template" attribute.'),this.removeAttribute("template"),this.removeAttribute("template-extend")),console.log("EasyForm: Setting schema via JS",e?.fields?.map(a=>({name:a.name,type:a.type,deps:!!a.dependencies}))),e?(this.setAttribute("schema",D(e)),this.handleSchemaChange()):this.removeAttribute("schema")}get template(){let e=this.getAttribute("template");return e?(this.getAttribute("schema")&&console.warn('EasyForm: Cannot use both "template" and "schema" attributes. "schema" will be ignored.'),e):null}set template(e){e&&this.getAttribute("schema")&&(console.warn('EasyForm: Setting "template" will remove "schema" attribute.'),this.removeAttribute("schema")),e?this.setAttribute("template",e):(this.removeAttribute("template"),this.removeAttribute("template-extend"))}get templateExtend(){let e=this.getAttribute("template-extend");return e?q(e):null}set templateExtend(e){e?this.setAttribute("template-extend",D(e)):this.removeAttribute("template-extend")}get maxAttempts(){let e=this.getAttribute("max-attempts");if(!e)return null;let a=parseInt(e,10);return isNaN(a)?null:a}set maxAttempts(e){e!=null&&e>=1?this.setAttribute("max-attempts",String(e)):this.removeAttribute("max-attempts")}get blockDurationMinutes(){let e=this.getAttribute("block-duration-minutes");if(!e)return null;let a=parseInt(e,10);return isNaN(a)?null:a}set blockDurationMinutes(e){e!=null&&e>=1?this.setAttribute("block-duration-minutes",String(e)):this.removeAttribute("block-duration-minutes")}get attemptsStorageKey(){return this.getAttribute("attempts-storage-key")}set attemptsStorageKey(e){e?this.setAttribute("attempts-storage-key",e):this.removeAttribute("attempts-storage-key")}get submitButton(){let e=this.getAttribute("submit-button");if(e)try{return q(e)}catch{return null}return null}set submitButton(e){e&&typeof e=="object"?this.setAttribute("submit-button",D(e)):this.removeAttribute("submit-button")}getSubmitButtonConfig(e){let a=this.submitButton,s={...e?.submitButton,...a};return{visible:s.visible??!0,text:s.text??"Enviar",width:s.width??"auto",align:s.align??"left"}}connectedCallback(){this.setupAttemptsLock(),this.setupStyles(),(this.hasAttribute("schema")||this.schema)&&this.render()}attributeChangedCallback(e,a,r){if(e==="schema"&&r!==a&&(this.getAttribute("template")&&(console.warn('EasyForm: "schema" and "template" cannot be used together. Removing "template".'),this.removeAttribute("template"),this.removeAttribute("template-extend")),this.handleSchemaChange()),e==="template"&&r!==a&&(this.getAttribute("schema")&&(console.warn('EasyForm: "template" and "schema" cannot be used together. Removing "schema".'),this.removeAttribute("schema")),this.handleSchemaChange()),e==="template-extend"&&r!==a&&this.handleSchemaChange(),e==="initialData"&&r!==a&&this.handleSchemaChange(),(e==="theme"||e==="colors")&&r!==a&&this.setupStyles(),e==="loading"&&r!==a){let s=this.shadow.querySelector("form");this.updateLoadingOverlay(s||void 0),s&&s.querySelectorAll("input, textarea, select, button").forEach(n=>{n instanceof HTMLElement&&"disabled"in n&&(n.disabled=this.loading)})}e==="disabled"&&r!==a&&this.render(),(e==="label-position"||e==="form-direction"||e==="show-completed-indicator")&&r!==a&&this.render(),(e==="max-attempts"||e==="block-duration-minutes"||e==="attempts-storage-key")&&r!==a&&(this.setupAttemptsLock(),this.updateLockOverlay()),e==="submit-button"&&r!==a&&this.render(),e==="complete-time"&&r!==a&&(this.resetTimer(),this.completeTime&&(this.timeRemaining=this.completeTime,this.render()))}setupAttemptsLock(){let e=this.maxAttempts;if(e==null||e<1){this.attemptsLock=null;return}this.attemptsLock=new W({maxAttempts:e,blockDurationMinutes:this.blockDurationMinutes??5,storageKey:this.attemptsStorageKey??void 0,onLocked:()=>{this.updateLockOverlay()},onUnlocked:()=>{this.stopLockCountdown(),this.updateLockOverlay(),this.render()}})}handleSchemaChange(){let e=null,a=this.template;if(a?e=this.getSchemaFromTemplate(a):e=this.schema,e){let r=this.initialData;this.stateManager.initializeSchema(e,r||void 0),this.initPersistence(e),this.render()}}getSchemaFromTemplate(e){let a=Qe(e);if(!a)return console.error(`EasyForm: Template "${e}" not found`),null;let r=this.templateExtend;return r&&r.length>0?Ot(e,r):a}async render(){if(!this.isRendering){this.isRendering=!0;try{let e=null,a=this.template;if(a?e=this.getSchemaFromTemplate(a):e=this.schema,!e){let E=this.shadow.querySelector("form");E&&E.parentNode===this.shadow&&E.remove();return}let r=this.skipPreserveValuesOnNextRender,s=r?{}:this.preserveCurrentValues();this.skipPreserveValuesOnNextRender=!1;let i=this.stateManager.getWizardState();if(s&&Object.keys(s).length>0)for(let[E,k]of Object.entries(s))this.stateManager.setValueWithoutValidation(E,k);let n=this.initialData,o=i!==null,d=e.steps&&e.steps.length>0;if(!r&&(!i||!o||!d||i&&e.steps&&i.totalSteps!==e.steps.length)&&(this.stateManager.initializeSchema(e,n||void 0),o&&d&&i)){let E=this.stateManager.getWizardState();if(E&&i.totalSteps===E.totalSteps){i.currentStep>=0&&i.currentStep<E.totalSteps&&this.stateManager.goToStep(i.currentStep);for(let k of i.completedSteps)k>=0&&k<E.totalSteps&&this.stateManager.completeStep(k)}}let m=this.stateManager.getWizardState(),p=document.createElement("form");p.addEventListener("submit",E=>this.handleSubmit(E)),(this.disabled||this.loading)&&p.classList.add("easy-form-disabled");let u=this.getAttribute("form-direction"),h=e.direction??(u==="vertical"||u==="horizontal"?u:"vertical");p.classList.add(`easy-form-direction-${h}`);let g=this.getAttribute("show-completed-indicator"),f=e.completedIndicator??(g!==null&&g!=="false"),y=typeof f=="object"&&f?.position?f.position:"top";if(m)this.renderWizard(p,e);else{this.renderFields(p,e.fields||[]);let E=this.getSubmitButtonConfig(e);if(E.visible){let k=document.createElement("div");k.className="easy-form-submit-wrapper",k.style.textAlign=E.align;let T=document.createElement("button");T.type="submit",T.textContent=E.text,T.className="easy-form-submit",T.style.width=E.width,(this.disabled||this.loading)&&(T.disabled=!0),k.appendChild(T),p.appendChild(k)}}let v=null;if(f){let{completed:E,total:k}=this.getCompletedRequiredProgress(e),T=document.createElement("div");T.className="easy-form-completed-indicator",T.setAttribute("role","progressbar"),T.setAttribute("aria-valuenow",String(E)),T.setAttribute("aria-valuemin","0"),T.setAttribute("aria-valuemax",String(k)),T.setAttribute("aria-label",`Campos obligatorios completados: ${E} de ${k}`);let $=document.createElement("div");$.className="easy-form-completed-track";let Re=document.createElement("div");Re.className="easy-form-completed-fill",Re.style.width=k>0?`${E/k*100}%`:"0%",$.appendChild(Re),T.appendChild($),v=document.createElement("div"),v.className="easy-form-wrapper",y==="top"?(v.appendChild(T),v.appendChild(p)):(v.appendChild(p),v.appendChild(T))}let b=this.shadow.querySelector("form");if(b&&b.parentNode===this.shadow&&b!==p)try{b.remove()}catch(E){console.warn("Error al eliminar formulario anterior:",E)}let w=this.shadow.querySelector(".easy-form-wrapper");w&&w.remove(),this.shadow.appendChild(v||p),this.completeTime&&!this.timerExpired&&(this.renderTimerDisplay(),this.setupTimerInputListener()),this.loading&&this.updateLoadingOverlay(p),this.updateLockOverlay(p)}finally{this.isRendering=!1,this.pendingRestoreValues&&this.applyPendingRestoreValues()}}}updateLockOverlay(e){let a=this.shadow.querySelector(".easy-form-lock-overlay");if(a&&a.remove(),this.stopLockCountdown(),!this.attemptsLock?.isLocked())return;let r=e||this.shadow.querySelector("form");if(!r)return;let s=document.createElement("div");s.className="easy-form-lock-overlay";let i=document.createElement("div");i.className="easy-form-lock-message",i.setAttribute("role","alert");let n=()=>{let o=this.attemptsLock.getRemainingBlockTimeMs();if(o<=0){this.stopLockCountdown();return}let d=Math.floor(o/6e4),c=Math.floor(o%6e4/1e3),m=d>0?`${d} min ${c} s`:`${c} segundos`;i.textContent=`Demasiados intentos. Intenta de nuevo en ${m}.`};n(),s.appendChild(i),r.appendChild(s),this.lockCountdownInterval=setInterval(n,1e3)}stopLockCountdown(){this.lockCountdownInterval&&(clearInterval(this.lockCountdownInterval),this.lockCountdownInterval=null)}updateLoadingOverlay(e){let a=this.shadow.querySelector(".easy-form-loading-overlay");if(a&&a.remove(),this.loading){let r=e||this.shadow.querySelector("form");if(r){let s=document.createElement("div");s.className="easy-form-loading-overlay";let i=document.createElement("div");i.className="easy-form-loading-spinner",s.appendChild(i),r.appendChild(s)}}}preserveCurrentValues(){let e=null,a=this.template;if(a?e=this.getSchemaFromTemplate(a):e=this.schema,!e)return{};let r=this.shadow.querySelector("form"),s={};if(!r)return s;let i=r.querySelectorAll("input, textarea, select");for(let n of i){let o=n.getAttribute("name");if(!o||!(this.findFieldInSchema(e,o)!==null))continue;let c;if(n instanceof HTMLInputElement)if(n.type==="checkbox")c=n.checked;else if(n.type==="radio")if(n.checked)c=n.value;else continue;else n.type==="number"?c=n.value===""?null:Number(n.value):c=n.value;else n instanceof HTMLTextAreaElement?c=n.value:n instanceof HTMLSelectElement&&(n.multiple?c=Array.from(n.selectedOptions).map(m=>m.value):c=n.value||null);c!==void 0&&(s[o]=c===""?null:c)}return s}initializeSlotTemplates(){if(this.slotTemplates!==null)return;let e=[];for(let a of Array.from(this.children))a instanceof HTMLElement&&e.push(a);if(e.length===0){this.slotTemplates=[];return}this.slotTemplates=e.map(a=>{let r=a.hasAttribute("row")?a.getAttribute("row"):null,s=r!=null&&r!==""?Number(r):NaN,i=Number.isFinite(s)?s:null;return{template:a.cloneNode(!0),row:i}})}getSlotClonesByRow(e){this.initializeSlotTemplates();let a=new Map;if(!this.slotTemplates||this.slotTemplates.length===0)return a;for(let{template:r,row:s}of this.slotTemplates){let i=typeof s=="number"?s:-1;Number.isFinite(i)||(i=-1),(i<0||i>=e)&&(i=-1);let n=r.cloneNode(!0),o=a.get(i)??[];o.push(n),a.set(i,o)}return a}applySlotDisabledState(e){if(!this.disabled&&!this.loading)return;e.classList.add("easy-form-slot-disabled"),e.querySelectorAll("input, textarea, select, button").forEach(r=>{"disabled"in r&&(r.disabled=!0)})}renderFields(e,a){if(a.length===0){let o=this.getSlotClonesByRow(0).get(-1);if(o&&o.length>0)for(let d of o)this.applySlotDisabledState(d),e.appendChild(d);return}let r=a.length,s=this.getSlotClonesByRow(r);for(let n=0;n<a.length;n++){let o=s.get(n);if(o&&o.length>0){for(let m of o)this.applySlotDisabledState(m),e.appendChild(m);s.delete(n)}let d=a[n],c=this.renderField(d);c&&e.appendChild(c)}let i=s.get(-1);if(i&&i.length>0)for(let n of i)this.applySlotDisabledState(n),e.appendChild(n)}renderField(e){let a=this.stateManager.getFieldVisibility(e.name),r=this.stateManager.getFieldEnabled(e.name);if(console.log(`Rendering field: ${e.name} (${e.type}), visible: ${a}, enabled: ${r}, hasDeps: ${!!e.dependencies}`),e.type==="group"){let f=this.renderGroup(e);return a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled"),f}if(e.type==="row"){let f=this.renderRow(e);return a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled"),f}if(e.type==="array"){let f=this.renderArray(e);return a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled"),f}if(e.type==="custom"){let f=this.renderCustom(e);return f&&(a||(f.style.display="none",f.classList.add("easy-form-field-hidden")),r||f.classList.add("easy-form-field-disabled")),f}let s=this.stateManager.getValue(e.name),i=this.stateManager.getErrors(e.name),n=i.length>0?i[0]:void 0,o=this.disabled||this.loading,d=this.getAttribute("label-position"),c=["up","down","left","right","none"],m=e.labelPosition??(d&&c.includes(d)?d:"up"),p={...e,disabled:o||!r||e.disabled,labelPosition:m},u=Ke(e.type);if(u){let f=u({field:p,value:s,error:n,onChange:y=>this.handleFieldChange(e.name,y),onBlur:()=>this.handleFieldBlur(e.name)});return f&&!a&&(f.style.display="none",f.classList.add("easy-form-field-hidden")),f}let h=Dt(p,s,n,f=>this.handleFieldChange(e.name,f),()=>this.handleFieldBlur(e.name)),g=h.querySelector(".easy-form-field")||h;return g instanceof HTMLElement&&g.setAttribute("data-field-name",e.name),a||(h.style.display="none",h.classList.add("easy-form-field-hidden")),h}renderGroup(e){let a=e,r=a.direction??"vertical",s=a.collapsible===!0,i=a.defaultOpen!==!1,n=document.createElement("div");if(n.className=`easy-form-group easy-form-direction-${r}`,e.name&&n.setAttribute("data-field-name",e.name),s){n.classList.add("easy-form-group-collapsible"),i||n.classList.add("easy-form-group-collapsed");let o=document.createElement("button");o.type="button",o.className="easy-form-group-header",o.setAttribute("aria-expanded",String(i));let d=`easy-form-group-${(e.name||"group").replace(/[^a-z0-9]/gi,"-")}-content`;o.setAttribute("aria-controls",d);let c=document.createElement("span");c.textContent=e.label||"Grupo";let m=document.createElement("span");m.className="easy-form-group-chevron",m.setAttribute("aria-hidden","true"),m.textContent="\u25BC",o.appendChild(c),o.appendChild(m),n.appendChild(o);let p=document.createElement("div");if(p.id=d,p.className="easy-form-group-content","fields"in e&&e.fields)for(let h of e.fields){let g=h.name.startsWith(e.name+".")?h.name:`${e.name}.${h.name}`,f={...h,name:g},y=this.renderField(f);y&&p.appendChild(y)}n.appendChild(p);let u=h=>{h?p.style.maxHeight=p.scrollHeight+"px":p.style.maxHeight="0"};i?requestAnimationFrame(()=>u(!0)):p.style.maxHeight="0",o.addEventListener("click",()=>{n.classList.contains("easy-form-group-collapsed")?(n.classList.remove("easy-form-group-collapsed"),o.setAttribute("aria-expanded","true"),u(!0)):(p.style.maxHeight=p.scrollHeight+"px",requestAnimationFrame(()=>{n.classList.add("easy-form-group-collapsed"),o.setAttribute("aria-expanded","false"),u(!1)}))})}else{if(e.label){let o=document.createElement("h3");o.className="easy-form-group-label",o.textContent=e.label,n.appendChild(o)}if("fields"in e&&e.fields)for(let o of e.fields){let d=o.name.startsWith(e.name+".")?o.name:`${e.name}.${o.name}`,c={...o,name:d},m=this.renderField(c);m&&n.appendChild(m)}}return n}renderRow(e){let a=document.createElement("div");a.className="easy-form-row";let r=e;if(a.style.display="flex",a.style.flexWrap="wrap",a.style.alignItems=r.align||"stretch",r.gap!==void 0){let s=typeof r.gap=="number"?`${r.gap}px`:r.gap;a.style.gap=s}else a.style.gap="1rem";if("fields"in e&&e.fields)for(let s of e.fields){let i=this.renderField(s);if(i){let n=document.createElement("div");n.style.flex="1",n.style.minWidth="0",n.appendChild(i),a.appendChild(n)}}return a}renderArray(e){let a=document.createElement("div");if(a.className="easy-form-array",a.setAttribute("data-field-name",e.name),e.label){let m=document.createElement("label");m.className="easy-form-label",m.textContent=e.label,a.appendChild(m)}let r=this.stateManager.getValue(e.name)||[],s=e,i=s.minItems??0,n=s.maxItems??1/0,o=document.createElement("div");o.className="easy-form-array-items";for(let m=0;m<r.length;m++){let p=document.createElement("div");if(p.className="easy-form-array-item",s.itemSchema?.fields)for(let g of s.itemSchema.fields){let f={...g,name:`${e.name}.${m}.${g.name}`},y=this.renderField(f);y&&p.appendChild(y)}let u=document.createElement("button");u.type="button",u.textContent="Eliminar",u.className="easy-form-array-remove";let h=r.length<=i;this.disabled||this.loading||h?u.disabled=!0:u.addEventListener("click",()=>{let g=[...r];g.splice(m,1),this.handleFieldChange(e.name,g)}),p.appendChild(u),o.appendChild(p)}a.appendChild(o);let d=document.createElement("button");d.type="button",d.textContent="Agregar",d.className="easy-form-array-add";let c=r.length>=n;return this.disabled||this.loading||c?d.disabled=!0:d.addEventListener("click",()=>{let m=this.stateManager.createDefaultArrayItem(e),p=[...r,m];this.handleFieldChange(e.name,p)}),a.appendChild(d),a}renderCustom(e){let a=Ke("custom");if(!a){let n=document.createElement("div");return n.textContent=`Componente custom no registrado para: ${e.name}`,n}let r=this.stateManager.getValue(e.name),s=this.stateManager.getErrors(e.name),i=s.length>0?s[0]:void 0;return a({field:e,value:r,error:i,onChange:n=>this.handleFieldChange(e.name,n),onBlur:()=>this.handleFieldBlur(e.name)})}getCompletedRequiredProgress(e){let a=c=>{let m=[];for(let p of c)if(p.type==="array"&&"itemSchema"in p&&p.itemSchema?.fields){let u=this.stateManager.getValue(p.name),h=Array.isArray(u)?u.length:0;for(let g=0;g<h;g++)for(let f of p.itemSchema.fields)m.push({...f,name:`${p.name}.${g}.${f.name}`})}else(p.type==="group"||p.type==="row")&&"fields"in p&&p.fields?m.push(...a(p.fields)):m.push(p);return m},r=e.steps?this.stateManager.getCurrentStepFields()||[]:e.fields||[],n=a(r).filter(c=>c.validations?.some(m=>m.type==="required")).filter(c=>this.stateManager.getFieldVisibility(c.name)),o=n.length;return{completed:n.filter(c=>{if(this.stateManager.getErrors(c.name).length>0)return!1;let p=this.stateManager.getValue(c.name);return!(p==null||typeof p=="string"&&p.trim()===""||Array.isArray(p)&&p.length===0&&c.type==="array")}).length,total:o}}renderWizard(e,a){let r=this.stateManager.getWizardState();if(!r)return;let s=document.createElement("div");s.className="easy-form-wizard";let i=document.createElement("div");i.className="easy-form-wizard-steps";let n=a?.stepStyle;if(n&&n!=="default"&&i.classList.add(`ef-stepper-${n}`),a?.steps)for(let p=0;p<a.steps.length;p++){let u=document.createElement("div");u.className="easy-form-wizard-step",p===r.currentStep&&u.classList.add("active"),r.completedSteps.includes(p)&&u.classList.add("completed"),u.textContent=a.steps[p].title,i.appendChild(u)}s.appendChild(i);let o=document.createElement("div");o.className="easy-form-wizard-fields";let d=this.stateManager.getCurrentStepFields();this.renderFields(o,d),s.appendChild(o);let c=document.createElement("div");if(c.className="easy-form-wizard-nav",r.currentStep>0){let p=document.createElement("button");p.type="button",p.textContent="Anterior",p.className="easy-form-wizard-prev",this.disabled||this.loading?p.disabled=!0:p.addEventListener("click",()=>{this.stateManager.getWizardState()&&this.stateManager.previousStep()&&(this.render(),this.emitStepChange())}),c.appendChild(p)}if(r.currentStep<r.totalSteps-1){let p=document.createElement("button");p.type="button",p.textContent="Siguiente",p.className="easy-form-wizard-next",this.disabled||this.loading?p.disabled=!0:p.addEventListener("click",async()=>{let u=this.stateManager.getWizardState();if(!u)return;let h=this.stateManager.getCurrentStepFields();for(let v of h)this.stateManager.getFieldVisibility(v.name)&&await this.stateManager.validateField(v.name);let g=this.stateManager.getAllErrors(),f={};for(let v of h)g[v.name]&&g[v.name].length>0&&(f[v.name]=g[v.name]);Object.keys(f).length>0?this.emitError(f):(this.stateManager.completeStep(u.currentStep),this.stateManager.nextStep()&&(this.render(),this.emitStepChange()))}),c.appendChild(p)}let m=this.getSubmitButtonConfig(a);if(r.currentStep===r.totalSteps-1&&m.visible){let p=document.createElement("button");p.type="button",p.textContent=m.text,p.className="easy-form-wizard-next",p.style.width=m.width,this.disabled||this.loading?p.disabled=!0:p.addEventListener("click",async()=>{let u=this.stateManager.getCurrentStepFields();for(let y of u)this.stateManager.getFieldVisibility(y.name)&&await this.stateManager.validateField(y.name);let h=this.stateManager.getAllErrors(),g={};for(let y of u)h[y.name]&&h[y.name].length>0&&(g[y.name]=h[y.name]);Object.keys(g).length>0?this.emitError(g):await this.handleSubmit(new Event("submit"))}),c.appendChild(p)}s.appendChild(c),e.appendChild(s)}async handleFieldChange(e,a){await this.stateManager.setValue(e,a),this.scheduleSave();let r=this.schema;if(r){let n=this.findFieldInSchema(r,e);n?.type==="array"&&(this.rerenderArrayField(n)||(this.skipPreserveValuesOnNextRender=!0,requestAnimationFrame(()=>this.render())))}let s=this.stateManager.getDependentFields(e);s.length>0&&(this.dependencyRenderTimeout&&clearTimeout(this.dependencyRenderTimeout),this.dependencyRenderTimeout=setTimeout(()=>{this.renderDependentFields(s),this.emitDependencyChange(e,s)},10));let i=new CustomEvent("change",{detail:{field:e,value:a,values:this.stateManager.getState().values},bubbles:!0,composed:!0});this.dispatchEvent(i)}rerenderArrayField(e){let a=this.shadow.querySelector(`[data-field-name="${e.name}"].easy-form-array`);if(!a?.parentNode)return!1;let r=this.renderArray(e);return a.parentNode.replaceChild(r,a),!0}renderDependentFields(e){let a=this.schema;if(!a)return;let r=this.getAllFieldsWithDependencies(a),s=r.length>0;console.log("renderDependentFields:",{fieldNames:e,hasAnyFieldsWithDeps:s,allFieldsWithDeps:r.map(o=>o.name)});let i=this.shadow.querySelector("form");if(!i)return;let n=new Set;for(let o of e)n.add(o);for(let o of e)this.stateManager.getDependentFields(o).forEach(c=>n.add(c));for(let o of n){let d=i.querySelector(`[data-field-name="${o}"]`);if(d||(d=i.querySelector(`.easy-form-field[name="${o}"]`)),d||(d=i.querySelector(`[data-field-name="${o}"], [data-group-name="${o}"]`)),d){let c=this.findFieldInSchema(a,o);if(!c)continue;let m=d.parentElement;if(m){let p=this.renderField(c);p&&m.replaceChild(p,d)}}}}getAllFieldsWithDependencies(e){let a=[],r=i=>{for(let n of i)n.dependencies&&a.push(n),n.type==="group"&&"fields"in n&&r(n.fields),n.type==="row"&&"fields"in n&&r(n.fields),n.type==="array"&&"itemSchema"in n&&n.itemSchema?.fields&&r(n.itemSchema.fields)},s=e.isWizard?e.steps.flatMap(i=>i.fields):e.fields||[];return r(s),a}emitDependencyChange(e,a){let r=new CustomEvent("dependencyChange",{detail:{changedField:e,affectedFields:a},bubbles:!0,composed:!0});this.dispatchEvent(r)}async handleFieldBlur(e){this.stateManager.setTouched(e),await this.stateManager.validateField(e),this.updateSingleField(e)}updateSingleField(e){let a=this.schema;if(!a||!this.findFieldInSchema(a,e))return;let s=this.stateManager.getErrors(e),i=s.length>0?s[0]:void 0,n=this.shadow.querySelector(`[name="${e}"]`)?.closest(".easy-form-field");if(!n)return;let o=n.querySelector(".easy-form-error");if(i){if(o)o.textContent=i;else{let c=document.createElement("p");c.className="easy-form-error",c.textContent=i,n.appendChild(c)}n.querySelector("input, textarea, select")?.classList.add("easy-form-input-error")}else o?.remove(),n.querySelector("input, textarea, select")?.classList.remove("easy-form-input-error")}findFieldInSchema(e,a){let r=e.fields||[],s=a.indexOf(".");if(s>0){let i=a.slice(0,s),n=a.slice(s+1),o=r.find(d=>d.name===i);if(!o)return null;if((o.type==="group"||o.type==="row")&&"fields"in o&&o.fields){let d=this.findFieldInSchema({fields:o.fields},n);return d?{...d,name:a}:null}return null}for(let i of r){if(i.name===a)return i;if(i.type==="group"&&"fields"in i){let n=this.findFieldInSchema({fields:i.fields},a);if(n)return n}if(i.type==="row"&&"fields"in i){let n=this.findFieldInSchema({fields:i.fields},a);if(n)return n}}return null}async handleSubmit(e){if(e.preventDefault(),this.attemptsLock?.isLocked())return;if(this.timerExpired){this.emitError({form:["El tiempo ha expirado. No puedes enviar el formulario."]});return}let a=await this.stateManager.validateForm(),r=this.stateManager.getState();if(Object.keys(a).length>0){for(let n of Object.keys(a))this.updateSingleField(n);this.emitError(a);return}let s={values:r.values,isValid:!0,errors:{}};this.completeTime&&this.timerStarted&&(s.timeRemaining=this.timeRemaining);let i=new CustomEvent("submit",{detail:s,bubbles:!0,composed:!0});this.dispatchEvent(i),this.clearPersistence()}emitError(e){let a=new CustomEvent("error",{detail:{errors:e},bubbles:!0,composed:!0});this.dispatchEvent(a)}emitStepChange(){let e=this.stateManager.getWizardState();if(!e)return;let a=new CustomEvent("stepChange",{detail:{currentStep:e.currentStep,previousStep:e.currentStep>0?e.currentStep-1:e.currentStep,totalSteps:e.totalSteps},bubbles:!0,composed:!0});this.dispatchEvent(a)}registerComponents(e){this.customComponents={...this.customComponents,...e},Ht(e)}reset(){this.stateManager.reset(),this.render()}incrementAttempts(){this.attemptsLock?.incrementAttempts(),this.attemptsLock?.isLocked()&&this.updateLockOverlay()}resetAttempts(){this.attemptsLock?.reset(),this.stopLockCountdown(),this.updateLockOverlay(),this.render()}isLocked(){return this.attemptsLock?.isLocked()??!1}getRemainingBlockTimeMs(){return this.attemptsLock?.getRemainingBlockTimeMs()??0}requestSubmit(){let e=this.shadow.querySelector("form");e&&typeof e.requestSubmit=="function"&&e.requestSubmit()}clear(){let e=this.schema,a=this.template,r=null;a?r=this.getSchemaFromTemplate(a):r=e,r&&(this.stateManager.initializeSchema(r,{}),this.render())}getValues(){return this.stateManager.getState().values}getValue(e){return this.stateManager.getValue(e)}async setValue(e,a){await this.stateManager.setValue(e,a),this.render()}async setValues(e){for(let[a,r]of Object.entries(e))await this.stateManager.setValue(a,r);this.render()}async validate(){let e=await this.stateManager.validateForm();if(Object.keys(e).length>0){for(let a of Object.keys(e))this.updateSingleField(a);this.emitError(e)}else this.shadow.querySelectorAll(".easy-form-error").forEach(s=>s.remove()),this.shadow.querySelectorAll(".easy-form-input-error").forEach(s=>s.classList.remove("easy-form-input-error"));return e}async validateField(e){return await this.stateManager.validateField(e),this.updateSingleField(e),this.stateManager.getErrors(e)}getErrors(){return this.stateManager.getAllErrors()}getFieldErrors(e){return this.stateManager.getErrors(e)}isValid(){return this.stateManager.getState().isValid}get theme(){let e=this.getAttribute("theme");return e&&["plano","tradicional","material","rounded-shadow","lines","shadcn","chakra","mantine","glass","bordered","minimal","efc"].includes(e)?e:"plano"}set theme(e){e?this.setAttribute("theme",e):this.removeAttribute("theme")}get colors(){let e=this.getAttribute("colors");return e?q(e):null}set colors(e){e?this.setAttribute("colors",D(e)):this.removeAttribute("colors")}get initialData(){let e=this.getAttribute("initialData");return e?q(e):null}set initialData(e){e?this.setAttribute("initialData",D(e)):this.removeAttribute("initialData")}get loading(){return this.hasAttribute("loading")}set loading(e){e?this.setAttribute("loading",""):this.removeAttribute("loading")}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get completeTime(){let e=this.getAttribute("complete-time");if(!e)return null;let a=parseInt(e,10);return isNaN(a)||a<=0?null:a}set completeTime(e){e!=null&&e>0?this.setAttribute("complete-time",String(e)):this.removeAttribute("complete-time")}setupStyles(){let e=this.shadow.querySelector("style");e&&e.remove();let a=this.theme,r=_(this.colors||void 0),s=X(a,r),i=document.createElement("style");i.textContent=s,this.shadow.firstChild?this.shadow.insertBefore(i,this.shadow.firstChild):this.shadow.appendChild(i)}initPersistence(e){if(!e.persistence||!e.persistence.enabled){this.persistenceConfig=null;return}this.persistenceConfig={enabled:!0,key:e.persistence.key,autoSave:e.persistence.autoSave??!0,debounce:e.persistence.debounce??500,onRestore:e.persistence.onRestore},this.restoreFromStorage()}restoreFromStorage(){if(!(!this.persistenceConfig||!this.persistenceConfig.enabled)&&this.persistenceConfig.key)try{let e=localStorage.getItem(this.persistenceConfig.key);if(e){let a=JSON.parse(e);a&&typeof a=="object"&&(this.pendingRestoreValues=a,this.persistenceConfig.onRestore&&this.persistenceConfig.onRestore(a))}}catch(e){console.warn("EasyForm: Error restoring from localStorage:",e)}}applyPendingRestoreValues(){if(!this.pendingRestoreValues||this.isRestoringValues)return;this.isRestoringValues=!0;let e={...this.pendingRestoreValues};this.pendingRestoreValues=null;for(let[a,r]of Object.entries(e))this.stateManager.setValueWithoutValidation(a,r);this.updateInputsWithValues(e),this.isRestoringValues=!1}updateInputsWithValues(e){for(let a of Object.keys(e)){let r=this.shadow.querySelector(`[name="${a}"]`);r&&(r.value=e[a]??"")}}saveToStorage(){if(!(!this.persistenceConfig||!this.persistenceConfig.enabled)&&this.persistenceConfig.key)try{let e=this.stateManager.getState().values;localStorage.setItem(this.persistenceConfig.key,JSON.stringify(e))}catch(e){console.warn("EasyForm: Error saving to localStorage:",e)}}scheduleSave(){!this.persistenceConfig||!this.persistenceConfig.enabled||this.persistenceConfig.autoSave&&(this.persistenceDebounceTimer&&clearTimeout(this.persistenceDebounceTimer),this.persistenceDebounceTimer=setTimeout(()=>{this.saveToStorage()},this.persistenceConfig.debounce))}clearPersistence(){if(!(!this.persistenceConfig||!this.persistenceConfig.key))try{localStorage.removeItem(this.persistenceConfig.key)}catch(e){console.warn("EasyForm: Error clearing localStorage:",e)}}resetTimer(){this.completeTimeInterval&&(clearInterval(this.completeTimeInterval),this.completeTimeInterval=null),this.timerStarted=!1,this.timerExpired=!1,this.completeTime&&(this.timeRemaining=this.completeTime)}startTimer(){this.timerStarted||this.timerExpired||!this.completeTime||(this.timerStarted=!0,this.timeRemaining=this.completeTime,this.updateTimerDisplay(),this.completeTimeInterval=setInterval(()=>{this.timeRemaining--,this.updateTimerDisplay(),this.timeRemaining<=0&&this.handleTimerExpired()},1e3))}updateTimerDisplay(){let e=this.shadow.querySelector(".easy-form-timer");if(!e)return;let a=Math.floor(this.timeRemaining/60),r=this.timeRemaining%60,s=`${a}:${r.toString().padStart(2,"0")}`;e.textContent=s,this.timeRemaining<=30&&e.classList.add("easy-form-timer-warning"),this.timeRemaining<=10&&e.classList.add("easy-form-timer-danger")}handleTimerExpired(){this.completeTimeInterval&&(clearInterval(this.completeTimeInterval),this.completeTimeInterval=null),this.timerExpired=!0;let e=new CustomEvent("timeout",{detail:{originalTime:this.completeTime||0,expiredAt:new Date},bubbles:!0,composed:!0});this.dispatchEvent(e),this.disableAllFields()}disableAllFields(){let e=this.shadow.querySelector("form");if(!e)return;e.querySelectorAll("input, textarea, select, button").forEach(s=>{(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement||s instanceof HTMLButtonElement&&s.type!=="submit")&&(s.disabled=!0)}),e.classList.add("easy-form-timer-expired");let r=this.shadow.querySelector(".easy-form-timer");r&&(r.classList.add("easy-form-timer-expired"),r.textContent="Tiempo agotado")}setupTimerInputListener(){if(!this.completeTime||this.timerStarted)return;let e=this.shadow.querySelector("form");if(!e)return;let a=()=>{!this.timerStarted&&!this.timerExpired&&this.startTimer()};e.addEventListener("input",a,{once:!0})}renderTimerDisplay(){let e=this.shadow.querySelector(".easy-form-timer");e&&e.remove();let a=this.shadow.querySelector("form");if(!a)return;let r=document.createElement("div");r.className="easy-form-timer";let s=this.completeTime||0,i=Math.floor(s/60),n=s%60;r.textContent=`${i}:${n.toString().padStart(2,"0")}`,a.insertBefore(r,a.firstChild)}};typeof window<"u"&&typeof customElements<"u"&&!customElements.get("easy-form")&&customElements.define("easy-form",Je);export{Je as EasyForm};
2670
2786
  //# sourceMappingURL=easy-form.js.map