import{a as k,g as D,i as E,aH as H,u as I,k as L,r as M,H as C,j as t,_ as b,h as m,e7 as P,I as c,e8 as F,f as y,bG as $}from"./main-634.js";import{D as G,B as K}from"./bf-400-72.js";import{F as _}from"./bf-767-388.js";import{t as R}from"./bf-676-386.js";import{A as Z}from"./bf-710-385.js";import{E as T}from"./bf-178-233.js";import{S as U}from"./bf-982-242.js";import{S as V}from"./bf-26-460.js";import"./bf-25-81.js";import"./bf-438-114.js";import"./bf-638-271.js";import"./bf-247-269.js";import"./bf-692-111.js";import"./bf-486-243.js";import"./bf-497-246.js";import"./bf-723-244.js";import"./bf-299-245.js";import"./bf-534-247.js";import"./bf-962-248.js";import"./bf-343-249.js";import"./bf-791-250.js";import"./bf-641-107.js";import"./bf-570-251.js";import"./bf-838-80.js";import"./bf-297-103.js";import"./bf-284-252.js";import"./bf-17-106.js";import"./bf-671-253.js";import"./bf-334-254.js";import"./bf-423-273.js";import"./bf-457-387.js";import"./bf-577-275.js";import"./bf-288-389.js";import"./bf-939-390.js";var g=[{lbl:"Only Characters",val:"^[a-zA-Z]+$",msg:"Only characters allowed"},{lbl:"Only Digits",val:"^[0-9]+(^[.])?$",msg:"Only digits allowed"},{lbl:"Name",val:"^[a-zA-Z .]+$",msg:"Name cannot contain any number or special characters"},{lbl:"Username",val:"^[a-z0-9_.]+$",msg:"Username cannot contain any space or special characters"},{lbl:"Character Limit",val:"^.{0,100}$",msg:"Maximum 100 characters allowed"},{lbl:"Word Limit",val:"^(?:$_bf_$b$_bf_$w+$_bf_$b[$_bf_$s$_bf_$r$_bf_$n]*){1,30}$",msg:"Maximum 30 words allowed"},{lbl:"Only Gmail",val:"^[a-z0-9]($_bf_$.?[a-z0-9]){0,}@(gmail)$_bf_$.com$",msg:"Only Gmail is allowed"}];function Ae(){const{css:l}=k(),{fieldKey:s}=D(),[f,v]=E(H),N=I(L),x=M.useRef();if(!s)return null;const e=C(f[s]),h=e.adminLbl||"",j=e.valid.regexr||"",S=e.valid.flags||"",i=N.err||{},z=r=>{var p;if(!c)return;const{value:a}=r.target;if(a==="")delete e.valid.regexr;else{const o=F(a);e.valid.regexr=o,e.err||(e.err={}),e.err.regexr||(e.err.regexr={});const d=g.find(u=>u.val===o);e.err.regexr.dflt=d?`<p style="margin:0">${d.msg}</p>`:((p=i[e.typ])==null?void 0:p.regexr)||(i==null?void 0:i.regexr)||'<p style="margin:0">Pattern not matched</p>',e.err.regexr.show=!0,e.typ==="password"&&delete e.valid.validations}const n=y(f,o=>{o[s]=e});v(n),$({event:`Regex Pattern updated: ${e.lbl||h||s}`,type:"set_regexr",state:{fields:n,fldKey:s}})},w=r=>{var n,p,o;if((p=(n=x==null?void 0:x.current)==null?void 0:n._tippy)==null||p.hide(),!c)return;if(r==="")delete e.valid.regexr;else{const d=F(r);e.valid.regexr=d,e.err||(e.err={}),e.err.regexr||(e.err.regexr={});const u=g.find(O=>O.val===d);e.err.regexr.dflt=u?`<p style="margin:0">${u.msg}</p>`:((o=i[e.typ])==null?void 0:o.regexr)||(i==null?void 0:i.regexr)||'<p style="margin:0">Pattern not matched</p>',e.err.regexr.show=!0,e.typ==="password"&&delete e.valid.validations}const a=y(f,d=>{d[s]=e});v(a),$({event:`Regex Pattern updated: ${e.lbl||h||s}`,type:"set_regexr",state:{fields:a,fldKey:s}})},B=r=>{if(!c)return;r.target.value===""?delete e.valid.flags:e.valid.flags=r.target.value;const a=y(f,n=>{n[s]=e});v(a),$({event:`Regex Pattern Flag updated: ${e.lbl||h||s}`,type:"set_flags",state:{fields:a,fldKey:s}})};return t.jsx(U,{id:"ptrn-stng",title:b("RegEx Pattern"),className:l(_.fieldSection),isPro:!0,tip:R.pattern,proProperty:"regexPattern",children:t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:l(m.mr2,m.mt3,m.pl1),children:[t.jsxs("div",{className:l(m.flxcb,m.ml1),children:[t.jsxs("h4",{className:l(m.m0,_.title),children:[b("Expression"),":"]}),t.jsxs(G,{instance:x,children:[t.jsx("button",{"data-testid":"ptrn-stng-exprsn-btn","data-close":!0,type:"button",className:l(A.dotBtn),unselectable:"on",draggable:"false",style:{cursor:"pointer"},title:b("Fields"),children:t.jsx(K,{size:19})}),t.jsx("div",{children:t.jsx("ul",{role:"menu",children:g==null?void 0:g.map((r,a)=>t.jsxs("li",{"data-testid":`ptrn-stng-expn-itm-${a}`,role:"menuitem",className:`${l(A.button)} btnHover`,onKeyDown:()=>w(r.val),onClick:()=>w(r.val),children:[t.jsx("span",{children:r.lbl}),t.jsx("br",{}),t.jsx("small",{children:P(r.val)})]},a))})})]})]}),t.jsx(Z,{id:"ptrn-stng-expn",ariaLabel:"Pattern for input field",placeholder:"e.g. ([A-Z])\\w+",list:"patterns",disabled:!c,value:P(j),changeAction:z})]}),t.jsx("div",{className:l({mr:5},m.pl1),children:t.jsx(V,{id:"ptrn-stng-flg",inpType:"text",title:b("Flags:"),value:S,action:B,placeholder:"e.g. g",cls:l(_.input),disabled:!c})}),j&&t.jsx(T,{id:"ptrn-stng-expn",type:"regexr",title:"Error Message",tipTitle:R.patternsErrMsg})]})})}const A={dotBtn:{b:0,brs:5,mr:15,curp:1},button:{dy:"block",w:"100%",ta:"left",b:0,bd:"none",p:3,curp:1,"&:hover":{bd:"var(--white-0-95)",cr:"var(--black-0)",brs:8},fs:11}};export{Ae as default};
