@realtek/core-theme 0.0.169 → 0.0.170

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.
@@ -6,5 +6,5 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
6
6
  `).replace(/<[^>]+>/g,` `),t=t.replace(/&nbsp;/gi,` `).replace(/&amp;/gi,`&`).replace(/&lt;/gi,`<`).replace(/&gt;/gi,`>`).replace(/&#39;|&apos;/gi,`'`).replace(/&quot;/gi,`"`),t.replace(/[ \t\f\v]+/g,` `).replace(/\n{2,}/g,`
7
7
  `).trim()}function Yv(e){return e.replace(/•/g,`
8
8
  `).split(/\n+/).map(e=>e.trim().replace(/^[-–—•]\s*/,``).trim()).filter(Boolean)}function Xv(e){return Yv(e.replace(/(?:^|\s)[-–—]\s+/g,`
9
- `))}function Zv(e){let t=e.match(/^([A-Za-z][A-Za-z&/ ]{1,28}?)\s*:\s*(\S.+)$/);if(!t)return null;let n=t[1].trim(),r=t[2].trim();return n.split(/\s+/).length>3||r.length>60?null:{fieldKey:n.toLowerCase().replace(/\s+/g,`-`),fieldLabel:Kv(n),value:r}}function Qv(e){let t=e.toLowerCase().replace(/[\s:.\-–—]+$/,``).trim();return Hv.has(t)?Uv.test(t)?`education`:Wv.test(t)?`keySkills`:`overview`:null}function $v(e){let t=[],n={overview:[],keySkills:[],education:[]},r=`overview`;return e.forEach(e=>{let i=Qv(e);if(i){r=i;return}if(r===`overview`){let n=Zv(e);if(n){t.push(n);return}}n[r].push(e)}),{meta:t,overview:qv(n.overview),keySkills:qv(n.keySkills),education:qv(n.education)}}function ey(e){let t=[...Vv].sort((e,t)=>t.length-e.length),n=RegExp(`\\b(${t.map(Gv).join(`|`)})\\b\\s*:?`,`gi`),r=[...e.matchAll(n)];if(!r.length)return{meta:[],overview:qv(Xv(e)),keySkills:[],education:[]};let i={overview:[],keySkills:[],education:[]},a=e.slice(0,r[0].index).trim();return a&&i.overview.push(...Xv(a)),r.forEach((t,n)=>{let a=t[1].trim().toLowerCase(),o=t.index+t[0].length,s=n+1<r.length?r[n+1].index:e.length,c=Xv(e.slice(o,s).trim());c.length&&i[Uv.test(a)?`education`:Wv.test(a)?`keySkills`:`overview`].push(...c)}),{meta:[],overview:qv(i.overview),keySkills:qv(i.keySkills),education:qv(i.education)}}function ty(e){let t=Jv(e);if(!t)return{meta:[],overview:[],keySkills:[],education:[]};let n=Yv(t);return n.length>=4?$v(n):ey(t)}function ny({items:e}){return(0,o.jsx)(`ul`,{className:`jdv-ats-bullets`,children:e.map((e,t)=>(0,o.jsx)(`li`,{className:`jdv-ats-bullet-item`,children:e},t))})}function ry({raw:e=``,meta:t=[]}){let[n,i]=(0,r.useState)(!1),a=(0,r.useMemo)(()=>ty(e),[e]),s=t.length?t:a.meta,c=[];if(a.overview.length&&c.push({key:`overview`,title:`Overview`,items:a.overview}),a.keySkills.length&&c.push({key:`keySkills`,title:`Key Skills`,items:a.keySkills,card:!0,icon:`🛠️`}),a.education.length&&c.push({key:`education`,title:`Education`,items:a.education,card:!0,icon:`🎓`}),!s.length&&!c.length)return(0,o.jsx)(zv,{type:`secondary`,children:`No description available.`});let l=n?c:c.slice(0,Bv),u=c.length-Bv;return(0,o.jsxs)(`div`,{className:`jdv-ats-desc`,children:[s.length>0&&(0,o.jsx)(`div`,{className:`jdv-ats-meta-grid`,children:s.map(({fieldKey:e,fieldLabel:t,value:n})=>(0,o.jsxs)(`div`,{className:`jdv-ats-meta-row`,children:[(0,o.jsx)(`span`,{className:`jdv-ats-meta-key`,children:t}),(0,o.jsx)(`span`,{className:`jdv-ats-meta-val`,children:n})]},e??t))}),(0,o.jsx)(`div`,{className:`jdv-ats-sections`,children:l.map(e=>e.card?(0,o.jsxs)(`div`,{className:`education-block`,children:[(0,o.jsxs)(`div`,{className:`education-header`,children:[(0,o.jsx)(`span`,{children:e.icon}),(0,o.jsx)(`span`,{children:e.title})]}),(0,o.jsx)(`ul`,{className:`education-list`,children:e.items.map((e,t)=>(0,o.jsx)(`li`,{className:`education-list-item`,children:e},t))})]},e.key):(0,o.jsxs)(`div`,{className:`jdv-ats-section`,children:[(0,o.jsx)(`div`,{className:`jdv-ats-section-hd`,children:(0,o.jsx)(`span`,{children:e.title})}),(0,o.jsx)(ny,{items:e.items})]},e.key))}),u>0&&(0,o.jsx)(`span`,{className:`jdv-desc-toggle`,onClick:()=>i(e=>!e),children:n?`Show less`:`Show more (${u} more section${u>1?`s`:``})`})]})}var{Text:iy}=i.Typography;function ay(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function oy(e){return e?e.name?e.name:e.fullName?e.fullName:e.firstName||e.lastName?[e.firstName,e.lastName].filter(Boolean).join(` `):e.candidateName??e.clientName??e.jobTitle??``:``}function sy(e){return e?e.email??e.emailId??e.emailAddress??``:``}function cy(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function ly(e){return e==null||e===``?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.join(`, `):typeof e==`object`?e.label??e.name??Object.values(e).join(` `):String(e)}var uy=[`jobDescription`,`description`,`rawDescription`,`jobDescriptionText`];function dy(e){return String(e??``).toLowerCase()===`job`}function fy(e){let t=uy.includes(e.field),n=/description/i.test(e.label??``);return t||n}function py({steps:e,current:t,onStepClick:n}){return(0,o.jsx)(`div`,{className:`preview-stepper`,children:e.map((i,s)=>{let c=s<t,l=s===t,u=s===e.length-1;return(0,o.jsxs)(r.Fragment,{children:[(0,o.jsxs)(`button`,{type:`button`,className:`preview-stepper__item${l?` preview-stepper__item--active`:``}`,onClick:()=>n(s),"aria-label":`Go to step ${s+1}: ${i.title}`,"aria-current":l?`step`:void 0,children:[(0,o.jsx)(`div`,{className:[`preview-stepper__circle`,c?`preview-stepper__circle--done`:``,l?`preview-stepper__circle--active`:``].filter(Boolean).join(` `),children:c?(0,o.jsx)(a.CheckOutlined,{}):s+1}),(0,o.jsx)(`span`,{className:`preview-stepper__label${l?` preview-stepper__label--active`:``}`,children:i.title})]}),!u&&(0,o.jsx)(`div`,{className:`preview-stepper__line${c?` preview-stepper__line--done`:``}`})]},i.title??s)})})}function my({record:e}){let t=oy(e),n=sy(e),r=cy(e);return!t&&!n?null:(0,o.jsxs)(`div`,{className:`preview-profile-card`,children:[(0,o.jsxs)(`div`,{className:`preview-profile-card__info`,children:[(0,o.jsx)(i.Avatar,{className:`preview-profile-card__avatar`,children:ay(t)}),(0,o.jsxs)(`div`,{className:`preview-profile-card__text`,children:[t&&(0,o.jsx)(`span`,{className:`preview-profile-card__name`,children:t}),n&&(0,o.jsx)(`span`,{className:`preview-profile-card__email`,children:n})]})]}),r&&(0,o.jsx)(i.Tag,{className:`preview-profile-card__status`,children:r})]})}function hy({fields:e,moduleName:t}){return e?.length?(0,o.jsx)(`div`,{className:`preview-field-grid`,children:e.map(e=>{let n=e.value,r=Array.isArray(n)&&n.length>0,i=dy(t)&&fy(e)&&typeof n==`string`&&n.trim();return r?n.map((t,r)=>(0,o.jsxs)(`div`,{className:`preview-field-card`,children:[(0,o.jsxs)(`span`,{className:`preview-field-card__label`,children:[e.label,n.length>1?` (${r+1})`:``]}),(0,o.jsx)(`span`,{className:`preview-field-card__value`,children:ly(t)})]},`${e.field??e.label}-${r}`)):i?(0,o.jsxs)(`div`,{className:`preview-field-card preview-field-card--description`,children:[(0,o.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,o.jsx)(`div`,{className:`preview-field-card__description`,children:(0,o.jsx)(ry,{raw:n})})]},e.field??e.label):(0,o.jsxs)(`div`,{className:`preview-field-card`,children:[(0,o.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,o.jsx)(`span`,{className:`preview-field-card__value`,children:ly(n)})]},e.field??e.label)})}):null}function gy(){let t=(0,s.useNavigate)(),{moduleName:n=``,record:c=null}=(0,s.useLocation)().state??{},l=c?.id??c?._id,[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(!!(n&&l)),[m,h]=(0,r.useState)(null),[g,_]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(!n||!l)return;let t=!1;return e.Sn({module:n,id:l}).then(e=>{t||(d(Array.isArray(e)?e:[]),p(!1))}).catch(e=>{t||(h(e.message||`Failed to load preview`),p(!1))}),()=>{t=!0}},[n,l]);function v(){t(-1)}let y=u.length,b=y>1,x=u[g],S=y>4?`min(${y*105+80}px, min(95vw, 1200px))`:`min(680px, calc(100vw - 32px))`,C=u.map((e,t)=>({title:e.label??e.name??`Step ${t+1}`})),w=(0,o.jsxs)(`div`,{className:`preview-modal-header`,children:[(0,o.jsx)(`span`,{className:`preview-modal-module`,children:n.toUpperCase()}),(0,o.jsx)(`span`,{className:`preview-modal-title`,children:x?.label??(n?`Preview - ${n}`:`Preview`)})]}),T=(0,o.jsxs)(`div`,{className:`wizard-footer`,children:[b&&(0,o.jsxs)(iy,{className:`preview-footer-step-count`,children:[`Step `,g+1,` of `,y]}),(0,o.jsxs)(`div`,{className:`wizard-footer-nav`,children:[(0,o.jsx)(i.Button,{onClick:v,children:`Close`}),b&&g>0&&(0,o.jsx)(i.Button,{onClick:()=>_(e=>e-1),children:`Back`}),b&&(g<y-1?(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.RightOutlined,{}),iconPosition:`end`,onClick:()=>_(e=>e+1),children:`Next`}):(0,o.jsx)(i.Button,{type:`primary`,onClick:v,children:`Done`}))]})]});function E(){return!n||!l?(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`Preview id is missing.`}):f?(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:(0,o.jsx)(i.Spin,{size:`small`})}):m?(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status job-preview-error`,children:m}):u.length?u.map((e,t)=>(0,o.jsx)(`div`,{style:{display:t===g?`block`:`none`},children:e.fields?.length>0?(0,o.jsx)(hy,{fields:e.fields,moduleName:n}):(0,o.jsx)(iy,{type:`secondary`,children:`No fields in this group.`})},e.name??e.id??t)):(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`No form groups found.`})}return(0,o.jsxs)(i.Modal,{centered:!0,className:`wizard-modal preview-modal`,footer:T,open:!0,title:w,width:S,onCancel:v,maskClosable:!1,children:[b&&(0,o.jsx)(`div`,{className:`wizard-steps-container`,children:(0,o.jsx)(py,{steps:C,current:g,onStepClick:_})}),(0,o.jsxs)(`div`,{className:`wizard-body`,children:[c&&(0,o.jsx)(my,{record:c}),E()]})]})}var{Text:_y}=i.Typography,{TextArea:vy}=i.Input,yy=[{key:`basic`,title:`Basic Info`,description:`General details`,fields:[{name:`firstName`,label:`First Name`,type:`input`,required:!0,placeholder:`Enter first name`,span:12},{name:`lastName`,label:`Last Name`,type:`input`,required:!0,placeholder:`Enter last name`,span:12},{name:`email`,label:`Email Address`,type:`input`,required:!0,placeholder:`Enter email address`,rules:[{type:`email`,message:`Please enter a valid email`}]},{name:`phone`,label:`Phone`,type:`input`,placeholder:`Enter phone number`}]},{key:`details`,title:`Details`,description:`Additional info`,fields:[{name:`role`,label:`Role`,type:`select`,required:!0,placeholder:`Select a role`,span:12,options:[{label:`Developer`,value:`developer`},{label:`Designer`,value:`designer`},{label:`Manager`,value:`manager`},{label:`Analyst`,value:`analyst`}]},{name:`department`,label:`Department`,type:`select`,placeholder:`Select department`,span:12,options:[{label:`Engineering`,value:`engineering`},{label:`Product`,value:`product`},{label:`Operations`,value:`operations`},{label:`Finance`,value:`finance`}]},{name:`notes`,label:`Notes`,type:`textarea`,placeholder:`Any additional notes...`}]},{key:`confirm`,title:`Confirm`,description:`Review & submit`,isReview:!0}];function by(e){switch(e.type){case`select`:return(0,o.jsx)(i.Select,{placeholder:e.placeholder,options:e.options,style:{width:`100%`}});case`textarea`:return(0,o.jsx)(vy,{rows:3,placeholder:e.placeholder});case`number`:return(0,o.jsx)(i.InputNumber,{placeholder:e.placeholder,style:{width:`100%`}});default:return(0,o.jsx)(i.Input,{type:e.inputType||`text`,placeholder:e.placeholder})}}function xy({steps:e,form:t}){let n=t.getFieldsValue(),r=e.filter(e=>!e.isReview);return r.some(e=>(e.fields||[]).some(e=>n[e.name]!==void 0&&n[e.name]!==``))?(0,o.jsxs)(`div`,{className:`wizard-review-content`,children:[r.map(e=>(0,o.jsxs)(`div`,{className:`wizard-review-section`,children:[(0,o.jsx)(_y,{className:`wizard-review-section-title`,children:e.title}),(0,o.jsx)(`div`,{className:`wizard-review-grid`,children:(e.fields||[]).map(e=>{let t=n[e.name],r=t===void 0||t===``||t===null?`—`:String(t);return(0,o.jsxs)(`div`,{className:`wizard-review-row`,children:[(0,o.jsx)(`span`,{className:`wizard-review-label`,children:e.label}),(0,o.jsx)(`span`,{className:`wizard-review-separator`,children:`:`}),(0,o.jsx)(`span`,{className:`wizard-review-value`,children:r})]},e.name)})})]},e.key)),(0,o.jsxs)(`div`,{className:`wizard-review-confirm-note`,children:[(0,o.jsx)(a.CheckCircleOutlined,{className:`wizard-review-confirm-icon`}),(0,o.jsx)(_y,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,o.jsx)(`div`,{className:`wizard-review-empty`,children:(0,o.jsx)(_y,{type:`secondary`,children:`No data entered yet.`})})}function Sy(){let[e]=i.Form.useForm(),t=(0,s.useNavigate)(),{title:n=`Wizard`,moduleName:a=``,steps:c=yy,onSubmit:l}=(0,s.useLocation)().state??{},[u,d]=(0,r.useState)(0),f=c[u],p=u===c.length-1,m=u===0;function h(){t(-1)}function g(){let t=(f.fields||[]).map(e=>e.name);e.validateFields(t.length>0?t:void 0).then(()=>{d(e=>e+1)})}function _(){d(e=>e-1)}function v(){let n=e.getFieldsValue();typeof l==`function`&&l(n),t(-1)}let y=c.map((e,t)=>({title:e.title,description:e.description,status:t<u?`finish`:t===u?`process`:`wait`}));return(0,o.jsxs)(i.Modal,{open:!0,title:a?`${n} — ${a}`:n,footer:(0,o.jsxs)(`div`,{className:`wizard-footer`,children:[(0,o.jsx)(i.Button,{onClick:h,children:`Cancel`}),(0,o.jsxs)(`div`,{className:`wizard-footer-nav`,children:[!m&&(0,o.jsx)(i.Button,{onClick:_,children:`Back`}),p?(0,o.jsx)(i.Button,{type:`primary`,onClick:v,children:`Submit`}):(0,o.jsx)(i.Button,{type:`primary`,onClick:g,children:`Next`})]})]}),onCancel:h,width:`min(680px, calc(100vw - 32px))`,centered:!0,className:`wizard-modal`,children:[(0,o.jsx)(`div`,{className:`wizard-steps-container`,children:(0,o.jsx)(i.Steps,{current:u,items:y,size:`small`,className:`wizard-steps`})}),(0,o.jsx)(`div`,{className:`wizard-body`,children:(0,o.jsxs)(i.Form,{form:e,layout:`vertical`,children:[c.filter(e=>!e.isReview).map((e,t)=>(0,o.jsx)(`div`,{style:{display:t===u?`block`:`none`},children:(0,o.jsx)(i.Row,{gutter:16,children:(e.fields||[]).map(e=>(0,o.jsx)(i.Col,{span:e.span||24,children:(0,o.jsx)(i.Form.Item,{name:e.name,label:e.label,rules:[...e.required?[{required:!0,message:`${e.label} is required`}]:[],...e.rules||[]],children:by(e)})},e.name))})},e.key)),f.isReview&&(0,o.jsx)(xy,{steps:c,form:e})]})})]})}function Cy({titleText:e,titleIcon:t}){let n=t===`delete`;return(0,o.jsxs)(`span`,{className:`dynamic-popup__header`,children:[(0,o.jsx)(`span`,{className:`dynamic-popup__header-icon-box${n?` dynamic-popup__header-icon-box--danger`:``}`,children:n?(0,o.jsx)(a.DeleteOutlined,{}):(0,o.jsx)(a.AppstoreOutlined,{})}),(0,o.jsx)(`span`,{className:`dynamic-popup__header-label`,children:e})]})}function wy({note:t,description:n,showSelectedCount:r,count:i,itemLabel:a,bodyText:s,deleteError:c}){return(0,o.jsxs)(o.Fragment,{children:[t&&(0,o.jsx)(e.An,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:t}),n&&(0,o.jsx)(e.An,{variant:`body`,className:`dynamic-popup__description`,children:n}),r&&i>0&&(0,o.jsxs)(e.An,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,o.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),s&&(0,o.jsx)(e.An,{variant:`body`,children:s}),c&&(0,o.jsx)(e.An,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:c})]})}function Ty({footerNote:t}){return t?(0,o.jsx)(e.An,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:t}):null}var{TextArea:Ey}=i.Input,Dy=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],Oy=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function ky(e=[]){return e.map(e=>{if(!e||typeof e!=`object`)return e;let t=[e.value,e.user_id,e.userId,e.USER_ID,e.legacyUserId,e.id,e._id].find(e=>e!=null&&String(e).trim()!==``),n=t==null?``:String(t).trim();return{...e,value:n}}).filter(e=>typeof e!=`object`||!e||String(e.value??``).trim()!==``)}function Ay({field:e,value:t,onChange:n}){return(0,o.jsx)(i.Input,{value:t,onChange:n,placeholder:e.placeholder,maxLength:e.maxLength,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function jy({field:e,value:t,onChange:n}){return(0,o.jsx)(Ey,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function My({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{value:n,onChange:r,options:ky(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function Ny({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{mode:`multiple`,value:n,onChange:r,options:ky(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function Py({field:e,options:t,onSearch:n,value:r,onChange:s}){return(0,o.jsx)(i.Select,{showSearch:!0,filterOption:!1,notFoundContent:null,value:r,onChange:s,options:ky(t),placeholder:e.placeholder,onSearch:n,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function Fy({field:e,mentionOpts:t,onMentionSearch:n,value:r,onChange:a}){return(0,o.jsx)(i.Mentions,{value:r,onChange:a,rows:e.rows??5,placeholder:e.placeholder,prefix:`@`,options:t,onSearch:n,className:`dynamic-popup__mention-textarea`})}function Iy({value:e={},onChange:t}){let n=e.period??`Hourly`,r=e.isRange??!1;function a(n){t?.({...e,...n})}return(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(i.Space.Compact,{style:{width:`100%`},children:[r?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.InputNumber,{controls:!1,placeholder:`From`,value:e.minAmount,onChange:e=>a({minAmount:e}),style:{flex:1}}),(0,o.jsx)(i.InputNumber,{controls:!1,placeholder:`To`,value:e.maxAmount,onChange:e=>a({maxAmount:e}),style:{flex:1}})]}):(0,o.jsx)(i.InputNumber,{controls:!1,placeholder:`0`,value:e.amount,onChange:e=>a({amount:e}),style:{flex:2}}),(0,o.jsx)(i.Select,{value:e.currency??void 0,options:Dy,onChange:e=>a({currency:e}),style:{width:80}}),(0,o.jsx)(i.Select,{value:n,options:Oy,onChange:e=>a({period:e}),style:{width:110}})]}),(0,o.jsxs)(i.Space,{size:`small`,style:{marginTop:8},children:[(0,o.jsx)(i.Switch,{checked:r,onChange:e=>a({isRange:e})}),(0,o.jsx)(`span`,{children:`Range`})]})]})}function Ly({field:e,value:t,onChange:n}){return(0,o.jsx)(i.DatePicker,{value:t,onChange:n,placeholder:e.placeholder??`Select date`,style:{width:`100%`},format:`YYYY-MM-DD`})}function Ry({field:e,checked:t,onChange:n}){return(0,o.jsx)(i.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function zy({field:e,value:t,onChange:n}){return(0,o.jsx)(i.InputNumber,{value:t,onChange:n,min:e.min,max:e.max,placeholder:e.placeholder,style:{width:`100%`}})}function By({options:e,value:t,onChange:n}){return(0,o.jsx)(i.Radio.Group,{value:t,onChange:n,options:e})}var Vy={input:Ay,text:Ay,textarea:jy,select:My,"multi-select":Ny,"search-select":Py,"mention-textarea":Fy,"candidate-rate":Iy,"priority-checkbox":Ry,"date-picker":Ly,number:zy,radio:By};function Hy(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}function Uy(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function Wy(e){if(!e)return``;let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=Math.round((n(new Date)-n(t))/864e5);return r<=0?`Today`:r===1?`Yesterday`:`${r} days ago`}function Gy(e){let t=Array.isArray(e?.submissionHistory)?e.submissionHistory:[],n=[e?.lastSubmittedAt,e?.submittedAt,e?.updatedAt,...t.map(e=>e?.submittedAt||e?.updatedAt)].filter(Boolean);return n.length?n.reduce((e,t)=>new Date(t)>new Date(e)?t:e):null}function Ky(e,t){if(typeof e==`string`)return{label:e,value:e};if(e?.label!==void 0&&e?.value!==void 0&&!t?.labelTemplate&&!t?.valueKey)return e;let{labelKey:n,valueKey:r,labelTemplate:i}=t??{},a=i?.includes(`{lastdate}`)?{...e,lastdate:Wy(Gy(e))}:e,o=(i?Uy(i,a):null)||(n?e?.[n]:null)||e?.name||e?.fullName||e?.candidateName||e?.title||e?.displayName||e?.text||e?.applicantReferenceId||e?.applicantRefrenceId||String(Object.values(e||{})[0]??``),s=(r?e?.[r]:null)??e?.id??e?._id??e?.applicantReferenceId??e?.applicantRefrenceId??String(Object.values(e||{})[0]??``);return{label:String(o),value:String(s),_raw:e}}function qy(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>Ky(t,e))}function Jy(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var Yy=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function Xy({form:t,fields:n,initialValues:r,dynamicOptions:a,popupContext:s,extraData:c,removedIds:l,setRemovedIds:u,showAlreadyAssigned:d,onValuesChange:f,getSearchHandler:p,getMentionSearchHandler:m,mentionOptions:h}){let g=d&&c;return!n.length&&!g?null:(0,o.jsxs)(o.Fragment,{children:[g&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`dynamic-popup__already-assigned`,children:[(0,o.jsx)(e.An,{variant:`caption`,color:`secondary`,children:`Already Assigned People`}),(0,o.jsx)(`div`,{style:{marginTop:6,display:`flex`,flexWrap:`wrap`,gap:6},children:(c?.recruitersData??[]).filter(e=>{let t=String(e?.user_id??e?.id??e?.userId??``);return t&&!l.includes(t)}).map(e=>{let t=String(e?.user_id??e?.id??e?.userId??``),n=e?.name??e?.user_name??e?.userName??e?.email??t;return(0,o.jsx)(i.Tag,{closable:!0,onClose:()=>{t&&u(e=>Array.from(new Set([...e,t])))},children:n},t||n)})})]}),(0,o.jsx)(i.Divider,{style:{margin:`12px 0`}})]}),n.length>0&&(0,o.jsx)(i.Form,{form:t,layout:`vertical`,initialValues:r,onValuesChange:(e,t)=>f(t),children:Zy(n).map(t=>Qy(t,t=>{let n=a[t.name]??qy(t,s),r=p(t),c=m(t),l=h[t.name]??[],u=Hy(t.type),d=Vy[t.type],f=[];return t.required&&f.push({required:!0,message:`${t.label||`This field`} is required`}),typeof t.validator==`function`&&f.push({validator:(e,n)=>{let r=t.validator(n,s);return r?Promise.reject(Error(r)):Promise.resolve()}}),Yy.has(t.type)&&f.push(e.K({label:t.label,field:t.name,type:t.type})),(0,o.jsx)(i.Form.Item,{name:t.name,label:t.label,rules:f,...u,children:d?(0,o.jsx)(d,{field:t,options:n,onSearch:r,mentionOpts:l,onMentionSearch:c}):null},t.name)}))})]})}function Zy(e){let t=[];for(let n of e){let e=t[t.length-1];n.inlineRow&&e?.inlineRow===n.inlineRow?e.fields.push(n):t.push({inlineRow:n.inlineRow,fields:[n]})}return t.map(e=>e.fields)}function Qy(e,t){return e.length===1?t(e[0]):(0,o.jsx)(`div`,{style:{display:`flex`,gap:8,alignItems:`flex-start`},children:e.map((e,n)=>(0,o.jsx)(`div`,{style:{flex:n===0?2:1,minWidth:0},children:t(e)},e.name))},`row-${e.map(e=>e.name).join(`-`)}`)}function $y({open:e,config:t,api:n,fields:i,popupContext:a,formValues:o}){let[s,c]=(0,r.useState)({}),[l,u]=(0,r.useState)(null);return(0,r.useEffect)(()=>{e||(c({}),u(null))},[e]),(0,r.useEffect)(()=>{if(!e||!t||!n.getOptions)return;let r=new AbortController;return i.forEach(e=>{!e.fetchOptionsKey||e.fetchOptionsParamKey||Promise.resolve(n.getOptions(e,void 0,a)).then(t=>{r.signal.aborted||c(n=>({...n,[e.name]:t}))}).catch(t=>{r.signal.aborted||console.error(`[DynamicPopup] Failed to load options for field "${e.name}":`,t)})}),()=>r.abort()},[e,n,t,i,a]),(0,r.useEffect)(()=>{if(!e||!t||!n.getOptions)return;let r=i.filter(e=>e.fetchOptionsKey&&e.fetchOptionsParamKey);if(!r.length)return;let s=new AbortController;return r.forEach(e=>{let t=o[e.fetchOptionsParamKey]??a[e.fetchOptionsParamKey],r={[e.fetchOptionsParamKey]:t};Promise.resolve(n.getOptions(e,r,a)).then(t=>{s.signal.aborted||c(n=>({...n,[e.name]:t}))}).catch(t=>{s.signal.aborted||console.error(`[DynamicPopup] Failed to load param-dependent options for "${e.name}":`,t)})}),()=>s.abort()},[e,n,t,i,o,a]),(0,r.useEffect)(()=>{if(!e||!t||!n.loadExtraData)return;let r=new AbortController;return Promise.resolve(n.loadExtraData(a)).then(e=>{r.signal.aborted||u(e)}).catch(e=>{r.signal.aborted||(console.error(`[DynamicPopup] Failed to load extra data:`,e),u(null))}),()=>r.abort()},[e,n,t,a]),{dynamicOptions:s,setDynamicOptions:c,extraData:l}}var eb=500,tb=3;function nb({api:e,popupContext:t,setDynamicOptions:n}){let[i,a]=(0,r.useState)({}),o=(0,r.useRef)({}),s=(0,r.useRef)({}),c=(0,r.useRef)({});function l(r){if(!r.searchFetchKey&&!r.searchFetcher)return;let i=e.searchOptions??e.searchFetcher;if(typeof i==`function`)return e=>{if(clearTimeout(o.current[r.name]),e.length<tb){n(e=>({...e,[r.name]:[]}));return}o.current[r.name]=setTimeout(()=>{s.current[r.name]?.abort();let a=new AbortController;s.current[r.name]=a,Promise.resolve(i(r,e,t)).then(e=>{if(a.signal.aborted)return;let t=Array.isArray(e)?e:e?.items??e?.list??[];n(e=>({...e,[r.name]:t.map(e=>Ky(e,r))}))}).catch(e=>{a.signal.aborted||console.error(`[DynamicPopup] Search failed for field "${r.name}":`,e)})},eb)}}function u(n){let r=e.getMentionOptions??e.mentionFetcher;if(typeof r==`function`)return e=>{c.current[n.name]?.abort();let i=new AbortController;c.current[n.name]=i,Promise.resolve(r(n,e,t)).then(e=>{if(i.signal.aborted)return;let t=Array.isArray(e)?e:e?.items??e?.list??[];a(e=>({...e,[n.name]:t.map(e=>({value:e.user_name??e.userName??e.username??String(e),label:e.user_name??e.userName??e.username??String(e)}))}))}).catch(e=>{i.signal.aborted||console.error(`[DynamicPopup] Mention search failed for field "${n.name}":`,e)})}}return{mentionOptions:i,getSearchHandler:l,getMentionSearchHandler:u}}function rb({form:e,config:t,api:n,popupContext:a,resolvedIds:o,dynamicOptions:s,extraData:c,removedIds:l,fields:u,onClose:d,onSubmit:f}){let[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(null);async function _(e){let t={resolvedIds:o,dynamicOptions:s,extraData:c,removedIds:l};if(typeof n.submit==`function`)return n.submit(e,a,t);if(typeof f==`function`)return f(e,a,t)}function v(){if(t){if(!u.length){if(t.mode===`delete`&&typeof n.deleteItems==`function`){m(!0),g(null),Promise.resolve(n.deleteItems(o,a)).then(()=>d({success:!0})).catch(e=>{let t=e?.message||`Delete failed. Please try again.`;g(t),m(!1),i.message.error(t)});return}if(typeof n.onOk==`function`){m(!0),Promise.resolve(n.onOk(a)).then(()=>d({success:!0})).catch(e=>{let t=e?.message||`Failed. Please try again.`;i.message.error(t),m(!1)});return}if(typeof n.submit==`function`){m(!0),Promise.resolve(_({})).then(e=>{e?.navigated||(i.message.success(t.successMessage||`Saved successfully`),d({success:!0}))}).catch(e=>{i.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>m(!1));return}d();return}e.validateFields().then(async e=>{m(!0);try{if((await _(e))?.navigated)return;i.message.success(t.successMessage||`Saved successfully`),d({success:!0})}catch(e){i.message.error(e?.message||`Failed. Please try again.`)}finally{m(!1)}}).catch(()=>{})}}function y(){m(!1),g(null)}return{handleOk:v,confirming:p,deleteError:h,resetSubmitState:y}}function ib({open:e=!0,config:t,context:n={},onClose:a,onSubmit:s,api:l={}}){let[u]=i.Form.useForm(),[d,f]=(0,r.useState)({}),[p,m]=(0,r.useState)([]),h=i.Form.useWatch([],u,{preserve:!0})??{},g=(0,r.useMemo)(()=>Jy(n),[n]),{selectedIds:_=[],selectedRecords:v=[],moduleName:y=``}=g,b=(0,r.useMemo)(()=>_.map((e,t)=>{let n=v[t];return n?.id??n?._id??e}),[_,v]),x=(0,r.useMemo)(()=>t?typeof t.getFields==`function`?t.getFields(g):t.fields??[]:[],[t,g]),S=(0,r.useMemo)(()=>{let e={};return x.forEach(t=>{let n=g[t.initialValueKey];!t.initialValueKey||n===void 0||(e[t.name]=t.type===`date-picker`?(0,c.default)(n):n)}),e},[x,g]),{dynamicOptions:C,setDynamicOptions:w,extraData:T}=$y({open:e,config:t,api:l,fields:x,popupContext:g,formValues:d}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=nb({api:l,popupContext:g,setDynamicOptions:w});function k(e){typeof a==`function`&&a(e)}let{handleOk:A,confirming:j,deleteError:M,resetSubmitState:N}=rb({form:u,config:t,api:l,popupContext:g,resolvedIds:b,dynamicOptions:C,extraData:T,removedIds:p,fields:x,onClose:k,onSubmit:s});(0,r.useEffect)(()=>{e&&(u.resetFields(),f(S??{}),m(g.removedIds??[]),N())},[e,S]);let P=!!t?.autoSubmitWhenNoFields&&x.length===0;(0,r.useEffect)(()=>{!e||!P||A()},[e,P]);let F=_.length,I=String(y).replace(/s$/i,``),L=F===1?I:y,R=v[0]??{},z=t?.getTitleText?t.getTitleText(F,L,R,g):t?.title,B=F===1?R.jobTitle??R.title??R.name??R.fullName??R.candidateName??null:null,V=t?.getBodyText?t.getBodyText(F,I,L,B,g):t?.bodyText??null,H=typeof t?.getNote==`function`?t.getNote(g):t?.note,U=x.filter(e=>e.required).every(e=>{let t=h[e.name];return!(t==null||t===``||Array.isArray(t)&&t.length===0||typeof t==`object`&&!Array.isArray(t)&&Object.keys(t).length===0)}),W=t?.disabledUntilFilled&&!U;if(!t||!e||P)return null;let G=t.component;return G?(0,o.jsx)(i.Modal,{open:e,title:t.title||t.getTitleText?(0,o.jsx)(Cy,{titleText:z,titleIcon:t.titleIcon}):null,footer:null,width:t.width??760,centered:!0,maskClosable:!1,onCancel:()=>k(),className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:(0,o.jsx)(G,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:k})}):(0,o.jsxs)(i.Modal,{open:e,title:(0,o.jsx)(Cy,{titleText:z,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:A,onCancel:()=>k(),okButtonProps:{danger:t.okButtonDanger,disabled:W,loading:j},cancelButtonProps:{disabled:j},closable:!j,maskClosable:!1,width:t.width??480,centered:!0,className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:[(0,o.jsx)(wy,{note:H,description:t.description,showSelectedCount:t.showSelectedCount,count:F,itemLabel:L,bodyText:V,deleteError:M}),(0,o.jsx)(Ty,{footerNote:t.footerNote}),(0,o.jsx)(Xy,{form:u,fields:x,initialValues:S,dynamicOptions:C,popupContext:g,extraData:T,removedIds:p,setRemovedIds:m,showAlreadyAssigned:t.showAlreadyAssigned,onValuesChange:f,getSearchHandler:D,getMentionSearchHandler:O,mentionOptions:E})]})}var ab={mode:`delete`,getTitleText:(e,t)=>`Delete ${e>0?`${e} `:``}${t}`,titleIcon:`delete`,okText:`Delete`,okButtonDanger:!0,width:420,getBodyText:(e,t,n,r)=>r?`Are you sure you want to delete the ${r} ${t}?`:e>1?`Are you sure you want to delete ${e} selected ${n}?`:`Are you sure you want to delete this ${t}?`,footerNote:`This action cannot be undone.`,fields:[]},ob={deleteItems:async(e,t)=>{await F(t.moduleName,e)}},sb={title:`Quick Submit`,okText:`Submit`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getNote:e=>e.moduleName===`candidate`?`Note: Select a job to submit this candidate`:`Note: Select a candidate to submit for this job`,getFields:e=>e.jobId?[]:e.moduleName===`candidate`?[{name:`jobId`,label:`Job list`,type:`search-select`,required:!0,placeholder:`Search Job ID/Job name (minimum 3 characters)`,searchFetchKey:`quickSubmitJobList`}]:[{name:`candidate`,label:`Candidate`,type:`search-select`,required:!0,placeholder:`Search candidate name (minimum 3 character)`,optionsKey:`candidateOptions`,searchFetchKey:`quickSubmitCandidates`,labelTemplate:`{applicantRefrenceId} - {firstName} {lastName} - ({lastdate})`,valueKey:`applicantId`}]},cb={searchOptions:async(e,t,n)=>{if(e.searchFetchKey===`quickSubmitJobList`){let e=n.selectedRecords?.[0]??{},r=await Gt({searchQuery:t,candidateId:e.id??e._id??n.selectedIds?.[0]});return(Array.isArray(r?.data)?r.data:[]).map(e=>({label:[e.jobReferenceId,e.jobTitle].filter(Boolean).join(` - `)||String(e._id??``),value:e._id??``}))}if(e.searchFetchKey===`quickSubmitCandidates`){let e=n.selectedRecords?.[0]??{},r=n.jobId??e.jobId??e.id??e._id??n.selectedIds?.[0];return ga({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t})}return[]},submit:async(e,t,n)=>{let{navigate:r,selectedRecords:i=[],selectedIds:a=[],moduleName:o,isFromSubmission:s=!1}=t,c=i[0]??{},l,u;t.jobId?(l=t.jobId,u=c.id??c._id??a[0]??``):o===`candidate`?(l=e.jobId??``,u=c.id??c._id??a[0]??``):(l=c.jobId??c.id??c._id??a[0]??``,u=e.candidate??``);let d=n?.dynamicOptions?.candidate?.find(e=>e?._raw?.applicantId===u),f=s||!!d?._raw?.isFromSubmission,p=t.submissionId??d?._raw?.submissionId??c.submissionId??``,m=new URLSearchParams;if(u&&m.set(`candidateId`,u),m.set(`isFromSubmission`,String(!!f)),f)p&&m.set(`submissionId`,p);else if(l&&u){let{exists:e,submissionId:t}=await Y({jobId:l,applicantId:u});if(e)throw Error(`This candidate is already submitted for this job${t?` (submission ${t})`:``}.`)}return r(`/submission-create/${l}?${m.toString()}`),{navigated:!0}}},lb={title:`Add Notes & Share`,okText:`Save & Share`,width:480,fields:[{name:`notes`,type:`mention-textarea`,required:!0,rows:5,placeholder:`Add your notes on the job. Use '@' to mention someone.`,mentionFetchKey:`mentionUsers`}]},ub=e=>e?.data??e;async function db({relatedId:e,notes:n,title:r,notesFor:i}){return ub(await Dt(t.v,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var fb={getMentionOptions:async(e,t)=>L(t),submit:async(e,t)=>{let n=Array.isArray(t.selectedIds)?t.selectedIds[0]:t.selectedIds;if(!n)throw Error(`Please select a record before adding a note.`);await db({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},pb={name:`jobId`,label:`Job Title / ID`,type:`search-select`,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle}`},mb={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`goodfited`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},hb={title:`Tag to Job`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[mb]:[pb,mb]},gb={searchOptions:async(e,t)=>e.searchFetchKey===`tagToJobJobList`?I(t):[],submit:async(e,t)=>{await V({jobId:e.jobId??t.jobId,candidateIds:t.selectedIds,hiringStage:e.hiringStage??t.hiringStage})}},_b={title:`Change Status`,okText:`Apply`,width:420,showSelectedCount:!0,fields:[{name:`status`,label:`New Status`,type:`select`,required:!0,placeholder:`Select a status`,optionsKey:`statusOptions`,initialValueKey:`currentStatus`,defaultOptions:[{label:`Active`,value:`active`},{label:`Inactive`,value:`inactive`},{label:`Pending`,value:`pending`},{label:`Closed`,value:`closed`}]}]},vb={submit:async(e,t)=>{await P(t.moduleName,t.selectedIds,e.status)}},yb={getTitleText:e=>`Remove ${e>1?`${e} Candidates`:`Candidate`} from Shortlist`,titleIcon:`delete`,okText:`Remove`,okButtonDanger:!0,width:420,getBodyText:e=>e>1?`Are you sure you want to remove ${e} selected candidates from the shortlist?`:`Are you sure you want to remove this candidate from the shortlist?`,footerNote:`The candidate will be moved back to the pipeline.`,fields:[]},bb={onOk:async e=>{await se({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},xb={title:`Add to Groups`,description:`Select a group to add the selected candidate(s) to`,okText:`Add to Group`,width:480,disabledUntilFilled:!0,fields:[{name:`groupId`,label:`Group`,type:`select`,required:!0,placeholder:`Select a group`,fetchOptionsKey:`candidateGroups`}]},Sb={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?H():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await U({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},Cb={title:`Self Assign`,okText:`Yes`,cancelText:`No`,width:420,bodyText:`Are you sure you want to assign this job?`,fields:[]},wb={onOk:async e=>{await W({jobIds:e.selectedIds})}},Tb={getTitleText:(e,t,n)=>{let r=n?.jobTitle||n?.title||``;return r?`Assign - ${r}`:`Assign`},okText:`Assign`,width:520,disabledUntilFilled:!0,showAlreadyAssigned:!0,fields:[{name:`assignToUserId`,label:`Assign to`,type:`select`,required:!0,placeholder:`Select a user`,fetchOptionsKey:`assignToUsers`},{name:`candidateRate`,label:`Candidate Rate`,type:`candidate-rate`},{name:`priority`,label:`Priority`,type:`priority-checkbox`,checkboxLabel:`Mark as High`}]},Eb={getOptions:async e=>e.fetchOptionsKey===`assignToUsers`?ee():[],loadExtraData:async e=>te(e.selectedIds[0]),submit:async(e,t,{removedIds:n,extraData:r})=>{await q({jobIds:t.selectedIds,userId:e.assignToUserId,rate:e.candidateRate,priority:e.priority,removedIds:n,existingRecruiters:r?.recruitersData})}},Db={title:`Add Sticky Notes`,getTitleText:(e,t,n,r)=>r.editingNoteId?`Edit Sticky Notes`:`Add Sticky Notes`,okText:`Save`,width:480,fields:[{name:`heading`,label:`Heading`,type:`input`,required:!0,placeholder:`Enter heading`,initialValueKey:`editingHeading`},{name:`targetDate`,label:`Target Date`,type:`date-picker`,required:!1,initialValueKey:`editingTargetDate`},{name:`comments`,label:`Comments`,type:`mention-textarea`,required:!0,rows:5,placeholder:`Enter your note here... Use '@' to mention someone.`,mentionFetchKey:`mentionUsers`,initialValueKey:`editingComments`}]},Ob={getMentionOptions:async(e,t)=>L(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await z(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await R({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},kb={title:`Move to Onboarding`,bodyText:`Are you sure you want to move this candidate to onboarding?`,okText:`Yes`,cancelText:`No`,width:420,successMessage:`Moved to onboarding successfully`,fields:[{name:`sendOnboardingEmail`,type:`priority-checkbox`,checkboxLabel:`Send Onboarding Email`}]},Ab={submit:async(e,t)=>{await J({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function jb(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var Mb={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function Nb(e,t,n){let r=jb(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function Pb(e){let t=e.selectedRecords?.[0]??{},n=Nb(t,`candidateRate`,`candidateAcceptedRate`)??Nb(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=Nb(t,`candidateRate`,`candidateAcceptedCurrency`)??Nb(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:Nb(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??Nb(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??Mb[String(r??``).toUpperCase()]??(r||`$`),unit:Nb(t,`candidateRate`,`candidateAcceptedPayUnit`)??Nb(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var Fb={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=Pb(i);return`Candidate Rate: ${a?`${a.symbol}${a.amount}${a.unit?`/${a.unit}`:``}`:`-`}`},fields:[{name:`candidateProposedRate`,label:`Proposed Rate`,type:`number`,required:!0,placeholder:`Amount`,min:0,inlineRow:`proposedRate`,validator:(e,t)=>{if(e==null||e===``)return;let n=Pb(t);if(n&&Number(e)<=Number(n.amount))return`Proposed rate must be greater than Candidate Rate`}},{name:`candidateProposedRateCurrency`,label:`Currency`,type:`select`,required:!0,inlineRow:`proposedRate`,defaultOptions:[{label:`$ USD`,value:`$`},{label:`₹ INR`,value:`₹`},{label:`€ EUR`,value:`€`}]},{name:`candidateProposedRateUnit`,label:`Unit`,type:`select`,required:!0,inlineRow:`proposedRate`,defaultOptions:[{label:`Year`,value:`yr`},{label:`Month`,value:`mo`},{label:`Week`,value:`wk`},{label:`Hour`,value:`hr`},{label:`Daily`,value:`day`}]},{name:`submitVia`,label:`Submit Via`,type:`radio`,required:!0,defaultOptions:[{label:`Mail`,value:`Mail`},{label:`VMS`,value:`VMS`}]}]},Ib={submit:async(e,t)=>{let n=t.selectedIds[0];if(await ie(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await ae(n)}catch{i.message.warning(`Approved. VMS notification could not be sent — use Send Mail to notify the client.`)}else i.message.info(`Approved — use Send Mail to notify the client.`)}};function Lb(e,t={}){return{client:t.clientName??e.clientName,role:t.jobTitle??e.jobTitle??e.designation,reqId:t.reqId??e.jobClientRefrenceId??e.mspReqId??e.submissionId,name:t.candidateName||[e.firstName,e.lastName].filter(Boolean).join(` `)||e.candidateFullName,location:t.jobLocation??e.city??e.currentLocation??e.jobLocation,vendor:t.employerName??e.supplierName??e.submitSource,submittedBy:t.submittedBy??e.signatureEmail??e.recruiterName,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function Rb({selectedIds:e,selectedRecords:t,onClose:n}){let a=t?.[0]??{},s=e?.[0]??_f(a),[c,l]=(0,r.useState)(null),[u,d]=(0,r.useState)(!0);(0,r.useEffect)(()=>{let e=!1;return d(!0),Bf(s,a).then(t=>{e||l(t)}).catch(t=>{e||(i.message.error(t?.message??`Unable to load finance details`),l({record:{submission:a},lookups:{},display:{}}))}).finally(()=>{e||d(!1)}),()=>{e=!0}},[s]);let f=(0,r.useMemo)(()=>({submissionApprove:async({computed:e})=>{await ie(s,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currency,candidateProposedRateUnit:`hr`,submitVia:`Mail`}),i.message.success(`Submission approved`),n?.({success:!0})},submissionReject:async({reason:e})=>{await oe({submissionId:s,rejectReasonId:2,rejectReason:`Rate not approved`,rejectReasonComments:e}),i.message.success(`Submission rejected`),n?.({success:!0})}}),[s,n]);return u||!c?(0,o.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,o.jsx)(i.Spin,{size:`large`})}):(0,o.jsx)(Pf,{type:tf,record:c.record,lookups:c.lookups,identity:Lb(a,c.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:f,onClose:()=>n?.(),variant:`popup`})}Rb.propTypes={selectedIds:l.default.array,selectedRecords:l.default.array,onClose:l.default.func};var zb={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:Rb},Bb={submit:async()=>{}},Vb=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],Hb={title:`Reject`,okText:`Reject`,okButtonDanger:!0,width:480,successMessage:`Submission rejected successfully`,fields:[{name:`rejectReason`,label:`Rejection Reasons`,type:`select`,required:!0,placeholder:`Select rejection reasons`,defaultOptions:Vb.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},Ub={submit:async(e,t)=>{let n=Vb.find(t=>String(t.id)===String(e.rejectReason));await oe({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},Wb={delete:ab,"quick-submit":sb,"add-notes":lb,"tag-to-job":hb,"change-status":_b,"remove-from-shortlist":yb,"add-to-groups":xb,"self-assign":Cb,"others-assign":Tb,"sticky-notes":Db,"move-to-onboarding":kb,"approve-rate":Fb,"manager-approve":zb,reject:Hb},Gb={delete:ob,"quick-submit":cb,"add-notes":fb,"tag-to-job":gb,"change-status":vb,"remove-from-shortlist":bb,"add-to-groups":Sb,"self-assign":wb,"others-assign":Eb,"sticky-notes":Ob,"move-to-onboarding":Ab,"approve-rate":Ib,"manager-approve":Bb,reject:Ub};function Kb(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function qb(e,...t){for(let n of t){let t=String(n).split(`.`).reduce((e,t)=>e?.[t],e);if(t!=null&&t!==``)return t}return``}function Jb(e){let t=qb(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[qb(e,`firstName`,`first_name`),qb(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function Yb(e){return String(qb(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function Xb(e){return String(qb(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function Zb({open:n=!0,context:a={},onClose:s}){let[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(``),[m,h]=(0,r.useState)(!0),[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)(``),b=String(a.selectedIds?.[0]??a.selectedRecords?.[0]?._id??a.selectedRecords?.[0]?.id??a.batchId??``);(0,r.useEffect)(()=>{if(!n)return;let t=!1;return e.wn(`onboarding`,200,0).then(e=>{t||l(Kb(e))}).catch(e=>{t||y(e.message||`Unable to load onboarding candidates`)}).finally(()=>{t||h(!1)}),()=>{t=!0}},[n]);let x=(0,r.useMemo)(()=>{let e=f.trim().toLowerCase();return e?c.filter(t=>[Jb(t),qb(t,`email`,`candidateEmail`,`candidate_email`),qb(t,`status`,`onboardingStatus`,`onboarding_status`)].some(t=>String(t).toLowerCase().includes(e))):c},[c,f]);async function S(){if(!b){y(`Select a batch before adding candidates`);return}let n=c.filter(e=>u.includes(Xb(e)));if(n.length){_(!0),y(``);try{let{userId:r}=t.a();await Promise.all(n.map(t=>e.lt(`batchCandidates`,{schemaVersion:1,batchId:b,candidateId:Yb(t),workforceEngagementId:Xb(t),source:`ONBOARDING`,assignmentStatus:`ASSIGNED`,assignedAt:new Date().toISOString(),assignedBy:r??0,isDeleted:!1}))),i.message.success(`${n.length} candidate${n.length===1?``:`s`} added to the batch`),s?.({refresh:!0})}catch(e){y(e.message||`Unable to add candidates to the batch`)}finally{_(!1)}}}return(0,o.jsxs)(i.Modal,{open:n,title:`Add Candidate to Batch`,okText:`Add`,onOk:S,onCancel:()=>s?.(),okButtonProps:{disabled:u.length===0||!b,loading:g},cancelButtonProps:{disabled:g},closable:!g,maskClosable:!1,width:760,centered:!0,children:[v&&(0,o.jsx)(i.Alert,{type:`error`,showIcon:!0,message:v,style:{marginBottom:12}}),(0,o.jsx)(i.Input.Search,{allowClear:!0,placeholder:`Search onboarding candidates`,value:f,onChange:e=>p(e.target.value),style:{marginBottom:12}}),(0,o.jsx)(i.Table,{rowKey:e=>Xb(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>Jb(t)},{title:`Email`,key:`email`,render:(e,t)=>qb(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>qb(t,`status`,`onboardingStatus`,`onboarding_status`)||`—`}],dataSource:x,loading:m,size:`small`,pagination:{pageSize:10,showSizeChanger:!1},rowSelection:{selectedRowKeys:u,onChange:d,getCheckboxProps:e=>({disabled:!Yb(e)||!Xb(e)})},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var Qb={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function $b(e){if(!e)return null;let t=[...e.groups??[]].sort((e,t)=>Number(e.order??0)-Number(t.order??0)).flatMap(e=>[...e.fields??[]].filter(e=>e.show!==0&&e.show!==!1).sort((e,t)=>Number(e.order??0)-Number(t.order??0)).map(e=>({...e,name:e.name??e.field,label:e.label??e.field,type:Qb[String(e.type??`text`).toLowerCase()]??e.type??`input`,required:e.required??e.req===1,options:(e.options??[]).map(e=>({label:e.label??e.name??e.value,value:e.value??e.id??e.label}))})));return{title:e.label,fields:t}}function ex({apiMap:n={},extraConfigs:i={}}){let a=(0,r.useMemo)(()=>({...Gb,...n}),[n]),c=(0,r.useMemo)(()=>({...Wb,...i}),[i]),{popupKey:l}=(0,s.useParams)(),u=(0,s.useNavigate)(),{state:d={}}=(0,s.useLocation)(),[f,p]=(0,r.useState)({key:``,config:null});(0,r.useEffect)(()=>{let t=!1;if(!l||!d.moduleName)return;let n=`${d.moduleName}:${l}`;return e.jt(d.moduleName,`popup`,l).then(e=>{t||p({key:n,config:$b(e[0])})}).catch(()=>{t||p({key:n,config:null})}),()=>{t=!0}},[l,d.moduleName]);let m=(0,r.useMemo)(()=>{let e=c[l],t=`${d.moduleName}:${l}`,n=f.key===t?f.config:null;return n?{...e,...n}:e},[f,c,l,d.moduleName]),h=(0,r.useMemo)(()=>({selectedIds:d.selectedIds??[],selectedRecords:d.selectedRecords??[],moduleName:d.moduleName??``,navigate:u,...d.popupContext??{}}),[u,d.selectedIds,d.selectedRecords,d.moduleName,d.popupContext]),g=(0,r.useMemo)(()=>{let e=d.popupAction;return e?.apiPath?{submit:(n,r)=>{let i=String(e.apiMethod||`POST`).toUpperCase();return t.i(t.v,e.apiPath.startsWith(`/`)?e.apiPath:`/${e.apiPath}`,{method:i,body:[`GET`,`DELETE`].includes(i)?void 0:JSON.stringify({...n,selectedIds:r.selectedIds,selectedRecords:r.selectedRecords,moduleName:r.moduleName})})}}:{}},[d.popupAction]);return l===`add-batch-candidate`?(0,o.jsx)(Zb,{open:!0,context:h,onClose:()=>u(-1)}):(0,o.jsx)(ib,{open:!0,config:m,context:h,onClose:handlePopupClose,api:{...a[l]??{},...g}})}var tx={title:`Vendor Share`,maxVendorSelect:1e3,defaultTab:`myVendor`,defaultPageSize:10,vendorTabs:[{key:`myVendor`,label:`My Vendors`},{key:`allVendor`,label:`All Vendors`}],vendorColumns:[{title:`Vendor Name`,dataIndex:`vendorName`,key:`vendorName`},{title:`Email`,dataIndex:`vendorEmail`,key:`vendorEmail`},{title:`Location`,dataIndex:`vendorLocation`,key:`vendorLocation`},{title:`Updated On`,dataIndex:`updatedOn`,key:`updatedOn`}]},nx={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>vt({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>yt(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>bt({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},rx=tx.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function ix(){let e=(0,s.useNavigate)(),t=(0,s.useLocation)(),{selectedIds:n=[],selectedRecords:c=[],recipients:l=[],subject:u=``,onSend:d,moduleName:f=``,popupAction:p={}}=t.state??{},m=n[0]??c[0]?._id??c[0]?.id,[h,g]=(0,r.useState)({to:l.join(`, `),cc:``,bcc:``,subject:u,contents:``,showCc:!1,showBcc:!1}),[_,v]=(0,r.useState)(!m),[y,b]=(0,r.useState)(tx.defaultTab),[x,S]=(0,r.useState)(``),[C,w]=(0,r.useState)([]),[T,E]=(0,r.useState)(0),[D,O]=(0,r.useState)(0),[k,A]=(0,r.useState)(0),[j,M]=(0,r.useState)(1),[N,P]=(0,r.useState)(tx.defaultPageSize),[F,I]=(0,r.useState)(!1),[L,R]=(0,r.useState)([]);(0,r.useEffect)(()=>{if(!m)return;let e=!1;I(!0);let t=x?100:N,n=x?0:(j-1)*N;return nx.getVendorList({jobId:m,limit:t,offset:n,type:y}).then(t=>{if(e)return;let n=t?.data?.vendorList??t?.data??[],r=t?.data?.myVendorCount??0,i=t?.data?.allVendorCount??0;w(Array.isArray(n)?n:[]),E(r),O(i),A(y===`myVendor`?r:i)}).catch(()=>{e||(w([]),A(0))}).finally(()=>{e||I(!1)}),()=>{e=!0}},[m,y,j,N,x]),(0,r.useEffect)(()=>{m&&nx.getMailDetails(m).then(e=>g(t=>({...t,subject:e.subject||t.subject,contents:e.contents||t.contents,to:e.toMail?.length?Array.isArray(e.toMail)?e.toMail.join(`, `):String(e.toMail):t.to,cc:e.ccMail?.length?Array.isArray(e.ccMail)?e.ccMail.join(`, `):String(e.ccMail):t.cc}))).catch(()=>{}).finally(()=>v(!0))},[m]);let z=(0,r.useMemo)(()=>L.map(e=>C.find(t=>t.vendorId===e)?.vendorEmail??``).filter(Boolean),[L,C]),B=(0,r.useMemo)(()=>({...h,bcc:[...new Set([...jv(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function V(e){let t=new Set(z);g({...e,bcc:jv(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let H=(jv(B.to).length||jv(B.bcc).length)&&Mv(B.to)&&Mv(B.cc)&&Mv(B.bcc)&&B.subject.trim(),U=e=>e===`myVendor`?T:D;function W(){e(-1)}function G(){H&&nx.submit({jobId:m,toMail:jv(B.to),ccMail:jv(B.cc),bccMail:jv(B.bcc),subject:B.subject,contents:B.contents}).then(t=>{t?.status===!0?(i.message.success(t?.data||`Mail sent successfully.`),typeof d==`function`&&d({...B,message:B.contents,selectedIds:n}),e(-1)):i.message.error(t?.message||t?.data||`Failed to send mail. Please try again.`)}).catch(e=>{i.message.error(e?.message||`Failed to send mail. Please try again.`)})}let ee=(0,r.useMemo)(()=>{if(!x)return C;let e=x.toLowerCase();return C.filter(t=>(t.vendorName??``).toLowerCase().includes(e)||(t.vendorEmail??``).toLowerCase().includes(e)||(t.vendorLocation??``).toLowerCase().includes(e))},[C,x]);return(0,o.jsx)(i.Drawer,{open:!0,placement:`right`,onClose:W,closable:!1,rootClassName:`vendor-share`,width:`95%`,footer:(0,o.jsxs)(`div`,{className:`vendor-share__footer`,children:[(0,o.jsx)(i.Button,{onClick:W,children:`Cancel`}),(0,o.jsx)(i.Button,{type:`primary`,disabled:!H,onClick:G,children:`Send`})]}),children:(0,o.jsxs)(`div`,{className:`vendor-share__body`,children:[(0,o.jsxs)(`div`,{className:`vendor-share__left`,children:[(0,o.jsxs)(`div`,{className:`vendor-share__vendor-header`,children:[(0,o.jsxs)(`div`,{className:`vendor-share__vendor-header-row`,children:[(0,o.jsx)(i.Button,{type:`text`,icon:(0,o.jsx)(a.CloseOutlined,{}),onClick:W,size:`small`,style:{marginRight:8}}),(0,o.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,o.jsx)(a.TeamOutlined,{})}),(0,o.jsx)(`span`,{className:`dynamic-popup__header-label`,children:`Vendor List`}),(0,o.jsxs)(`div`,{className:`vendor-share__vendor-search`,children:[(0,o.jsx)(a.SearchOutlined,{className:`vendor-share__search-icon`}),(0,o.jsx)(i.Input,{variant:`borderless`,placeholder:`Search vendor`,value:x,onChange:e=>{S(e.target.value),M(1)},className:`vendor-share__search-input`})]})]}),(0,o.jsx)(`div`,{className:`vendor-share__vendor-tabs`,children:tx.vendorTabs.map(e=>(0,o.jsxs)(`span`,{className:`vendor-share__vendor-tab${y===e.key?` vendor-share__vendor-tab--active`:``}`,onClick:()=>{b(e.key),M(1),R([])},children:[e.label,` (`,U(e.key),`)`]},e.key))})]}),(0,o.jsx)(`div`,{className:`vendor-share__vendor-table-wrapper`,children:(0,o.jsx)(i.Table,{rowKey:e=>e.vendorId,columns:rx,dataSource:ee,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>tx.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,o.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,o.jsx)(ge,{current:j,pageSize:N,total:k,onChange:e=>M(e),onPageSizeChange:e=>P(e)})})]}),(0,o.jsx)(`div`,{className:`vendor-share__right`,children:(0,o.jsx)(Lv,{value:B,onChange:V,moduleName:f,defaultTemplateId:p.defaultTemplateId??t.state?.defaultTemplateId??``,ready:_,contextRecords:c,title:`Share`,hint:`Select vendors or add email addresses`,bccHint:`Vendor emails are added automatically`,afterBcc:L.length>0?(0,o.jsxs)(`div`,{className:`vendor-share__selected-count`,children:[L.length,` / `,tx.maxVendorSelect,` Vendors selected`]}):null})})]})})}var ax={EMAIL:/^[a-zA-Z0-9._%+-]+@[a-zA-Z][a-zA-Z-]*\.[a-zA-Z]{2,}$/,PHONE:/^[0-9]{10}$/,PASSWORD:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/,ALPHABETS:/^[A-Za-z ]+$/,ALPHANUMERIC:/^(?!\s)[A-Za-z0-9 ]+$/,NUMBER:/^[0-9]+$/,URL:/^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+(com|org|net|in|co|io|gov|edu)(\/[^\s]*)?$/i,CANDIDATE_ID:/^[A-Za-z0-9-]+$/,REMARKS:/^[A-Za-z0-9\s.,'"\-()!?/@#$%&]*$/,DESIGNATION:/^[a-zA-Z0-9\s,.\-&()]{2,100}$/,DOB:/^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/\d{4}$/,COMPANY_NAME:/^[A-Za-z0-9\s&.,'()-]+$/,FIRST_NAME:/^[A-Z][a-zA-Z]*$/,FULL_NAME:/^[A-Z][a-zA-Z]*(?: [A-Z][a-zA-Z]*)*$/,NO_SPACES:/^\S+$/,STARTS_WITH_CAPITAL:/^[A-Z].*$/},ox={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},sx={REQUIRED:e=>`Mandatory Field`,INVALID_EMAIL:`Please enter a valid email address.`,INVALID_PHONE:`Phone number must contain exactly 10 digits.`,INVALID_PASSWORD:`Password must contain uppercase, lowercase, number, special character and minimum 8 characters.`,INVALID_ALPHABETS:`Only alphabets and spaces are allowed.`,INVALID_ALPHANUMERIC:`Only letters, numbers and spaces are allowed.`,INVALID_NUMBER:`Only numbers are allowed.`,INVALID_URL:`Please enter a valid URL.`,INVALID_CANDIDATE_ID:e=>`${e} can contain only letters, numbers and hyphens.`,INVALID_REMARKS:`Remarks contain invalid characters.`,INVALID_DESIGNATION:`Designation contains invalid characters.`,INVALID_DOB:`DOB must be in MM/DD/YYYY format.`,INVALID_LINKEDIN:`Please enter a valid LinkedIn URL.`,INVALID_COMPANY_NAME:`Company name contains invalid characters.`,INVALID_FIRST_NAME:`First letter must be capital and spaces are not allowed.`,INVALID_FULL_NAME:`Each word must start with a capital letter.`,NO_SPACES_ALLOWED:`Spaces are not allowed.`,MUST_START_WITH_CAPITAL:`First letter must be capital.`,INVALID_FILE_TYPE:`Only JPG, PNG and PDF files are allowed.`,INVALID_FILE_SIZE:`File upload must be ${ox.MAX_FILE_SIZE} MB below.`,INVALID_FILE_TYPE:`Only JPG, PNG and PDF files are allowed.`,SINGLE_FILE_ONLY:`Only one file can be uploaded.`},cx={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},lx={REMARKS_MIN:10,REMARKS_MAX:250},ux={removeSpaces:(e=``)=>e.replace(/\s/g,``),capitalizeFirstLetter:(e=``)=>e.charAt(0).toUpperCase()+e.slice(1),capitalizeWords:(e=``)=>e.replace(/\b\w/g,e=>e.toUpperCase()),removeExtraSpaces:(e=``)=>e.replace(/\s+/g,` `).trim(),firstNameFormatter:(e=``)=>e.replace(/\s+/g,` `).trimStart().replace(/\b\w/g,e=>e.toUpperCase()),fullNameFormatter:(e=``)=>e.replace(/\s+/g,` `).trimStart().replace(/\b\w/g,e=>e.toUpperCase()),phoneFormatter:(e=``)=>e.replace(/\D/g,``).slice(0,10),dobFormatter:(e=``)=>{let t=e.replace(/\D/g,``);return t.length<=2?t:t.length<=4?`${t.slice(0,2)}/${t.slice(2)}`:`${t.slice(0,2)}/${t.slice(2,4)}/${t.slice(4,8)}`}},dx={required:(e=`Field`)=>({required:!0,message:sx.REQUIRED(e)}),email:()=>({pattern:ax.EMAIL,message:sx.INVALID_EMAIL}),phone:()=>({pattern:ax.PHONE,message:sx.INVALID_PHONE}),password:()=>({pattern:ax.PASSWORD,message:sx.INVALID_PASSWORD}),alphabets:()=>({pattern:ax.ALPHABETS,message:sx.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:ax.ALPHANUMERIC,message:sx.INVALID_ALPHANUMERIC}),number:()=>({pattern:ax.NUMBER,message:sx.INVALID_NUMBER}),url:()=>({pattern:ax.URL,message:sx.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:ax.CANDIDATE_ID,message:sx.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:ax.REMARKS,message:sx.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${lx.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${lx.REMARKS_MAX} characters.`}),designation:()=>({pattern:ax.DESIGNATION,message:sx.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!ax.DOB.test(n))return Promise.reject(Error(sx.INVALID_DOB));let r=(0,c.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(sx.INVALID_DOB));let i=(0,c.default)().endOf(`day`);return r.isAfter(i)?Promise.reject(Error(`Date of Birth cannot be a future date.`)):i.diff(r,`year`)<21?Promise.reject(Error(`Age must be at least 21 years.`)):Promise.resolve()}}),linkedin:()=>({pattern:ax.LINKEDIN,message:sx.INVALID_LINKEDIN}),companyName:()=>({pattern:ax.COMPANY_NAME,message:sx.INVALID_COMPANY_NAME}),firstName:()=>({pattern:ax.FIRST_NAME,message:sx.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${cx.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${cx.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:cx.FIRST_NAME_MIN,message:sx.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:cx.FIRST_NAME_MAX,message:sx.FIRST_NAME_MAX}),remarksMinLength:()=>({min:lx.REMARKS_MIN,message:sx.REMARKS_MIN}),remarksMaxLength:()=>({max:lx.REMARKS_MAX,message:sx.REMARKS_MAX}),fullName:()=>({pattern:ax.FULL_NAME,message:sx.INVALID_FULL_NAME}),noSpaces:()=>({pattern:ax.NO_SPACES,message:sx.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:ax.STARTS_WITH_CAPITAL,message:sx.MUST_START_WITH_CAPITAL}),fileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();for(let e of t){let t=e.originFileObj||e;if(!(t.size/1024/1024<=ox.MAX_FILE_SIZE))return i.message.error(sx.INVALID_FILE_SIZE),Promise.reject(Error(sx.INVALID_FILE_SIZE));if(!ox.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(sx.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>ox.SINGLE_FILE_COUNT)return Promise.reject(Error(sx.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<ox.MAX_FILE_SIZE?ox.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(sx.INVALID_FILE_TYPE)):Promise.reject(Error(sx.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>ox.MULTI_FILE_COUNT)return Promise.reject(Error(sx.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<ox.MAX_FILE_SIZE))return Promise.reject(Error(sx.INVALID_FILE_SIZE));if(!ox.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(sx.INVALID_FILE_TYPE))}return Promise.resolve()}})},fx={beforeUpload:e=>[`image/jpeg`,`image/png`,`application/pdf`].includes(e.type)?e.size/1024/1024<=2?!1:(i.message.error(`File upload must be 2 MB below.`),i.Upload.LIST_IGNORE):(i.message.error(`Only JPG, PNG and PDF files are allowed.`),i.Upload.LIST_IGNORE)},px=()=>{let[e]=i.Form.useForm();return(0,o.jsx)(`div`,{style:{padding:24},children:(0,o.jsxs)(i.Form,{form:e,layout:`vertical`,onFinish:e=>{console.log(`Form Values:`,e)},autoComplete:`off`,children:[(0,o.jsxs)(i.Row,{gutter:16,children:[(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Email`,name:`email`,rules:[dx.required(`Email`),dx.email()],children:(0,o.jsx)(i.Input,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Phone Number`,name:`phone`,rules:[dx.required(`Phone Number`),dx.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:ux.phoneFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Password`,name:`password`,rules:[dx.required(`Password`),dx.password()],children:(0,o.jsx)(i.Input.Password,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Full Name`,name:`fullName`,rules:[dx.required(`Full Name`),dx.alphabets(),dx.firstNameMinLength(),dx.firstNameMaxLength()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({fullName:ux.firstNameFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Username`,name:`username`,rules:[dx.required(`Username`),dx.alphanumeric()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({username:ux.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Website URL`,name:`website`,rules:[dx.required(`Website URL`),dx.url()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({website:ux.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`MSP Req ID`,name:`mspreqID`,rules:[dx.required(`MSP Req ID`),dx.candidateId(`MSP Req ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({mspreqID:ux.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[dx.required(`Candidate ID`),dx.candidateId(`Candidate ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({candidateId:ux.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:24,children:(0,o.jsx)(i.Form.Item,{label:`Remarks`,name:`remarks`,rules:[dx.required(`Remarks`),dx.remarks(),dx.remarksMinLength(),dx.remarksMaxLength()],children:(0,o.jsx)(i.Input.TextArea,{rows:4})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Designation`,name:`designation`,rules:[dx.required(`Designation`),dx.designation()],children:(0,o.jsx)(i.Input,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Date of Birth`,name:`dob`,rules:[dx.dob()],children:(0,o.jsx)(i.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:ux.dobFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Company Name`,name:`companyName`,rules:[dx.required(`Company Name`),dx.companyName()],children:(0,o.jsx)(i.Input,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{name:`contractType`,label:`Contract Type`,children:(0,o.jsxs)(i.Select,{showSearch:!0,allowClear:!0,filterOption:(e,t)=>(t?.label??``).toLowerCase().includes(e.toLowerCase()),children:[(0,o.jsx)(i.Select.Option,{value:`C2C`,label:`C2C`,children:`C2C`}),(0,o.jsx)(i.Select.Option,{value:`W2-Contract`,label:`W2-Contract`,children:`W2-Contract`}),(0,o.jsx)(i.Select.Option,{value:`W2-Fulltime`,label:`W2-Fulltime`,children:`W2-Fulltime`}),(0,o.jsx)(i.Select.Option,{value:`1099`,label:`1099`,children:`1099`})]})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{name:`candidateProposedRateCurrency`,label:`Currency`,children:(0,o.jsxs)(i.Select,{showSearch:!0,allowClear:!0,children:[(0,o.jsx)(i.Select.Option,{value:`$`,children:`$`}),(0,o.jsx)(i.Select.Option,{value:`₹`,children:`₹`}),(0,o.jsx)(i.Select.Option,{value:`€`,children:`€`}),(0,o.jsx)(i.Select.Option,{value:`zł`,children:`zł`}),(0,o.jsx)(i.Select.Option,{value:`£`,children:`£`}),(0,o.jsx)(i.Select.Option,{value:`kr`,children:`kr`}),(0,o.jsx)(i.Select.Option,{value:`Fr`,children:`Fr`}),(0,o.jsx)(i.Select.Option,{value:`kr`,children:`kr`})]})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Resume new`,name:`resume`,children:(0,o.jsx)(i.Upload,{beforeUpload:fx.beforeUpload,maxCount:1,children:(0,o.jsx)(i.Button,{children:`Upload Resume`})})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Documents`,name:`documents`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[dx.multiFileUpload()],children:(0,o.jsx)(i.Upload,{multiple:!0,beforeUpload:fx.beforeUpload,children:(0,o.jsx)(i.Button,{children:`Upload Documents`})})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Upload File`,name:`file`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[dx.fileUpload()],children:(0,o.jsx)(i.Upload,{beforeUpload:fx.beforeUpload,maxCount:1,children:(0,o.jsx)(i.Button,{children:`Upload`})})})})]}),(0,o.jsx)(i.Row,{children:(0,o.jsx)(i.Form.List,{name:`users`,children:(e,{add:t,remove:n})=>(0,o.jsxs)(o.Fragment,{children:[e.map(({key:e,name:t,...r})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{required:!0,...r,rules:[{required:!0,message:`First name is requried`}],name:[t,`first`],children:(0,o.jsx)(i.Input,{placeholder:`First Name`})})}),(0,o.jsx)(i.Col,{span:11,children:(0,o.jsx)(i.Form.Item,{...r,required:!0,name:[t,`last`],children:(0,o.jsx)(i.Input,{placeholder:`Last Name`})})}),(0,o.jsx)(i.Col,{span:1,children:(0,o.jsx)(a.MinusCircleOutlined,{onClick:()=>n(t)})})]})),(0,o.jsx)(i.Form.Item,{children:(0,o.jsx)(i.Button,{type:`dashed`,onClick:()=>t(),block:!0,icon:(0,o.jsx)(a.PlusOutlined,{}),children:`Add field`})})]})})}),(0,o.jsxs)(i.Form.Item,{children:[(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,children:`Submit`}),(0,o.jsx)(i.Button,{style:{marginLeft:10},onClick:()=>e.resetFields(),children:`Reset`})]})]})})};function mx(e){return(0,o.jsx)(Up,{children:(0,o.jsx)(Ev,{...e})})}var{Text:hx}=i.Typography,gx=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],_x={fileText:(0,o.jsx)(a.FileTextOutlined,{}),checkCircle:(0,o.jsx)(a.CheckCircleOutlined,{}),user:(0,o.jsx)(a.UserOutlined,{}),filter:(0,o.jsx)(a.FilterOutlined,{})};function vx({stats:e=gx}){return(0,o.jsx)(i.Card,{children:(0,o.jsx)(i.Row,{gutter:[12,12],children:e.map(e=>(0,o.jsx)(i.Col,{xs:24,sm:24,md:8,lg:8,xl:8,children:(0,o.jsxs)(i.Card,{className:`stats-inner-card`,children:[(0,o.jsxs)(i.Space,{align:`center`,children:[_x[e.icon]??_x.fileText,(0,o.jsx)(hx,{children:e.label})]}),(0,o.jsx)(i.Statistic,{value:e.value})]})},e.label))})})}var{Text:yx}=i.Typography;function bx(e){return e?.USER_NAME??e?.user_name??e?.username??e?.name??e?.full_name??e?.fullName??e?.email??`User ${e?.USER_ID??e?.user_id??`?`}`}function xx(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:bx(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function Sx(){let[t,n]=(0,r.useState)([]),[s,c]=(0,r.useState)(0),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(1),[p,m]=(0,r.useState)(10),[h,g]=(0,r.useState)(``),_=(0,r.useCallback)(async({offset:t,limit:r,searchQuery:a}={})=>{u(!0);try{let i=await e.Et({offset:t,limit:r,searchQuery:a??``}),o=(i.users??[]).map(xx);n(o),c(i.total??o.length)}catch{i.message.error(`Failed to load users`)}finally{u(!1)}},[]);return(0,r.useEffect)(()=>{queueMicrotask(()=>{_({offset:(d-1)*p,limit:p,searchQuery:h})})},[_,d,p,h]),(0,o.jsx)(Z,{icon:(0,o.jsx)(a.TeamOutlined,{}),title:`Users`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,o.jsx)(du,{listName:`Users`,dataSource:t,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,o.jsxs)(`div`,{children:[(0,o.jsx)(yx,{strong:!0,style:{fontSize:13},children:e}),t._email&&(0,o.jsx)(`div`,{style:{fontSize:11,color:`var(--color-text-muted)`},children:t._email})]})},{label:`Role`,value:`_role`,width:180}],loading:l,total:s,current:d,pageSize:p,onPageChange:e=>f(e),onPageSizeChange:e=>{m(e),f(1)},onSearch:e=>{g(e),f(1)}})})}var{Text:Cx}=i.Typography,wx=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],Tx=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function Ex({field:e,index:t,onToggle:n,onReorder:s}){let c=(0,r.useRef)(null),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(!1);function p(e){c.current=t,e.dataTransfer.effectAllowed=`move`,f(!0)}function m(){f(!1),u(!1)}function h(e){e.preventDefault(),u(!0)}function g(){u(!1)}function _(e){e.preventDefault(),u(!1),c.current!==null&&c.current!==t&&s(c.current,t),c.current=null}return(0,o.jsxs)(`div`,{draggable:!0,onDragStart:p,onDragEnd:m,onDragOver:h,onDragLeave:g,onDrop:_,className:`uss-field-row with-edit${l?` drag-over`:``}${d?` dragging`:``}`,children:[(0,o.jsx)(`span`,{className:`uss-drag-handle`,children:(0,o.jsx)(a.HolderOutlined,{})}),(0,o.jsxs)(`span`,{className:`uss-field-name`,children:[e.fieldName,(0,o.jsx)(`span`,{className:`uss-field-key`,children:e.fieldKey})]}),(0,o.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,o.jsx)(i.Switch,{size:`small`,checked:e.isVisible,onChange:e=>n(t,`isVisible`,e)})}),(0,o.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,o.jsx)(i.Switch,{size:`small`,checked:!!e.isEditable,onChange:e=>n(t,`isEditable`,e)})}),(0,o.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,o.jsx)(i.Switch,{size:`small`,checked:!!e.ismandatory,onChange:e=>n(t,`ismandatory`,e)})})]})}function Dx({team:t,configType:n}){let[a,s]=(0,r.useState)({}),[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)({}),[f,p]=(0,r.useState)(`job`);(0,r.useEffect)(()=>{t&&(l(!0),e.Xt(t,n).then(s).catch(()=>i.message.error(`Failed to load field config`)).finally(()=>l(!1)))},[t,n]);let m=a[f]??[];function h(e,t){s(n=>({...n,[e]:typeof t==`function`?t(n[e]??[]):t}))}function g(e,t,n){h(f,r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))}function _(e,t){h(f,n=>{let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r.map((e,t)=>({...e,order:t}))})}async function v(){let r=f;d(e=>({...e,[r]:!0}));try{await e.vn(t,r,m,n),i.message.success(`Saved`)}catch{i.message.error(`Save failed`)}finally{d(e=>({...e,[r]:!1}))}}return(0,o.jsxs)(i.Spin,{spinning:c,children:[(0,o.jsx)(i.Tabs,{size:`small`,activeKey:f,onChange:p,items:wx.map(e=>({key:e.key,label:e.label}))}),(0,o.jsxs)(`div`,{className:`uss-field-header with-edit`,children:[(0,o.jsx)(`span`,{}),(0,o.jsx)(`span`,{children:`Field`}),(0,o.jsx)(`span`,{style:{textAlign:`center`},children:`Visible`}),(0,o.jsx)(`span`,{style:{textAlign:`center`},children:`Editable`}),(0,o.jsx)(`span`,{style:{textAlign:`center`},children:`Mandatory`})]}),(0,o.jsxs)(`div`,{className:`uss-field-list`,children:[m.length===0&&!c&&(0,o.jsx)(`div`,{className:`uss-empty`,children:`No fields found.`}),m.map((e,t)=>(0,o.jsx)(Ex,{field:e,index:t,onToggle:g,onReorder:_},e.fieldKey??t))]}),(0,o.jsx)(`div`,{className:`uss-modal-footer`,children:(0,o.jsxs)(i.Button,{type:`primary`,size:`small`,loading:u[f],onClick:v,children:[`Save `,wx.find(e=>e.key===f)?.label]})})]})}function Ox(){let[t,n]=(0,r.useState)(null),[s,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(`listView`),[p,m]=(0,r.useState)([]),[h,g]=(0,r.useState)(0),[_,v]=(0,r.useState)(!1),[y,b]=(0,r.useState)(``),[x,S]=(0,r.useState)(!1),C=(0,r.useCallback)(async()=>{v(!0);try{let t=await e.Tt();m(t.teams),g(t.total)}catch{i.message.error(`Failed to load teams`)}finally{v(!1)}},[]);(0,r.useEffect)(()=>{C()},[C]);function w(e){n(e),f(`listView`),c(!0)}function T(e){n(e),b(e.teamName??``),u(!0)}async function E(){if(!y.trim()){i.message.warning(`Team name is required`);return}S(!0);try{await e._n(t,{teamName:y.trim(),managerId:t.managerId,memberIds:t.memberIds}),i.message.success(`Team updated`),u(!1),C()}catch{i.message.error(`Failed to update team`)}finally{S(!1)}}return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(Z,{icon:(0,o.jsx)(a.TeamOutlined,{}),title:`Teams`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,o.jsx)(du,{listName:`Teams`,dataSource:p,fields:[{label:`Team Name`,value:`teamName`,width:200},{label:`Manager`,value:`manager`,width:200},{label:`Members`,value:`memberCount`,width:90,sorter:!1},{label:`Actions`,value:`_actions`,width:160,sorter:!1,render:(e,t)=>(0,o.jsxs)(`div`,{style:{display:`flex`,gap:4},children:[(0,o.jsx)(i.Button,{size:`small`,type:`link`,onClick:()=>T(t),children:`Edit`}),(0,o.jsx)(i.Button,{size:`small`,type:`link`,onClick:()=>w(t),children:`Configure`})]})}],loading:_,total:h})}),(0,o.jsx)(i.Modal,{open:l,onCancel:()=>u(!1),title:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.TeamOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),`Edit Team`]}),width:420,footer:null,destroyOnClose:!0,children:(0,o.jsxs)(`div`,{className:`uss-edit-team-body`,style:{paddingTop:12},children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`uss-edit-team-label`,children:`Team Name`}),(0,o.jsx)(i.Input,{value:y,onChange:e=>b(e.target.value),onPressEnter:E,placeholder:`Enter team name`})]}),(0,o.jsxs)(`div`,{className:`uss-modal-footer`,children:[(0,o.jsx)(i.Button,{onClick:()=>u(!1),children:`Cancel`}),(0,o.jsx)(i.Button,{type:`primary`,loading:x,onClick:E,children:`Save`})]})]})}),(0,o.jsxs)(i.Modal,{className:`uss-modal`,open:s,onCancel:()=>c(!1),title:(0,o.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,o.jsx)(a.TeamOutlined,{style:{color:`var(--color-brand)`}}),(0,o.jsxs)(`span`,{children:[`Configure: `,t?.teamName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,o.jsx)(`div`,{style:{marginBottom:12},children:(0,o.jsx)(`div`,{className:`uss-config-toggle`,children:Tx.map(e=>(0,o.jsx)(`button`,{className:`uss-config-btn${d===e.key?` active`:``}`,onClick:()=>f(e.key),children:e.label},e.key))})}),t&&(0,o.jsx)(Dx,{team:t,configType:d},`${t?.teamId}-${d}`)]})]})}var kx=[`view`,`add`,`edit`,`delete`],Ax={view:`View`,add:`Add`,edit:`Edit`,delete:`Delete`,sourcing:`Sourcing`,assign:`Assign`,share:`Share`,change_status:`Status`,my_jobs:`My Jobs`,all_jobs:`All Jobs`};function jx(e){return Ax[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Mx(e){let t=kx.filter(t=>e.includes(t)),n=e.filter(e=>!kx.includes(e)).sort();return[...t,...n]}function Nx(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),Mx([...t])}function Px(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{Qm(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function Fx({value:e,onSave:t,className:n}){let[i,s]=(0,r.useState)(!1),[c,l]=(0,r.useState)(e);(0,r.useEffect)(()=>{l(e)},[e]);function u(){s(!1);let n=c.trim();n&&n!==e?t(n):l(e)}return i?(0,o.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input${n?` ${n}`:``}`,value:c,style:{width:Math.max(48,c.length*8)},onChange:e=>l(e.target.value),onBlur:u,onKeyDown:t=>{t.key===`Enter`&&u(),t.key===`Escape`&&(s(!1),l(e)),t.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,o.jsxs)(`span`,{className:`perm-editable-name${n?` ${n}`:``}`,onDoubleClick:e=>{e.stopPropagation(),s(!0)},children:[e,(0,o.jsx)(a.EditOutlined,{className:`perm-name-edit-icon`})]})}function Ix({entry:e,label:t,onToggle:n,onLabelSave:s}){let[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)(t),f=e?.value===`1`,p=!!e;(0,r.useEffect)(()=>{d(t)},[t]);function m(){l(!1);let e=u.trim();e&&e!==t?s(e):d(t)}return(0,o.jsx)(i.Tooltip,{title:p?f?`Click to disable`:`Click to enable`:`Not applicable for this module`,children:(0,o.jsxs)(`div`,{className:`perm-action-pill${f?` on`:``}${p?``:` na`}`,onClick:()=>{!c&&p&&n()},children:[(0,o.jsx)(`span`,{className:`perm-action-pill-dot${f?` on`:``}`}),c?(0,o.jsx)(`input`,{autoFocus:!0,className:`perm-pill-input`,value:u,style:{width:Math.max(36,u.length*7)},onChange:e=>d(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&(l(!1),d(t)),e.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,o.jsx)(`span`,{className:`perm-action-pill-label`,onDoubleClick:e=>{e.stopPropagation(),l(!0)},children:t}),f&&!c&&(0,o.jsx)(a.CheckOutlined,{className:`perm-action-pill-check`})]})})}function Lx({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:s,onActionLabelSave:c}){let l=t?.permissions??{},u=n.filter(t=>Qm(e,t)),d=u.filter(e=>l[e]?.value===`1`).length,f=u.filter(e=>l[e]).length,p=f>0&&d===f;return(0,o.jsxs)(`div`,{className:`perm-module-card${p?` all-on`:d>0&&!p?` some-on`:``}`,children:[(0,o.jsxs)(`div`,{className:`perm-module-card-header`,children:[(0,o.jsx)(Fx,{value:i,onSave:t=>s(e,t),className:`perm-module-card-name`}),f>0&&(0,o.jsxs)(`span`,{className:`perm-module-card-badge${d>0?` active`:``}`,children:[d,`/`,f]})]}),(0,o.jsx)(`div`,{className:`perm-module-card-body`,children:u.map(t=>(0,o.jsx)(Ix,{entry:l[t],label:a[t]??jx(t),onToggle:()=>r(e,t),onLabelSave:e=>c(t,e)},t))})]})}function Rx({role:t,moduleLabels:n={},actionLabels:s={},onModuleLabelSave:c=()=>{},onActionLabelSave:l=()=>{}}){let[u,d]=(0,r.useState)({}),[f,p]=(0,r.useState)({}),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)(!1),b=e.Kt(t);(0,r.useEffect)(()=>{b&&(h(!0),y(!1),e.Jt(b).then(e=>{d(e),p(e)}).catch(()=>i.message.error(`Failed to load permissions`)).finally(()=>h(!1)))},[b]);function x(e,t){y(!0),p(n=>{let r=n[e]??{menuId:u[e]?.menuId??0,permissions:{}},i=r.permissions?.[t]??{id:0,value:`0`};return{...n,[e]:{...r,permissions:{...r.permissions,[t]:{...i,value:i.value===`1`?`0`:`1`}}}}})}async function S(){_(!0);try{await e.hn(b,f),d(f),y(!1),i.message.success(`Permissions saved`)}catch(e){i.message.error(e?.message||`Save failed`)}finally{_(!1)}}let C=(0,r.useMemo)(()=>Object.keys(f).sort(),[f]),w=(0,r.useMemo)(()=>Nx(f),[f]),{enabled:T,total:E}=(0,r.useMemo)(()=>Px(f),[f]);return(0,o.jsxs)(i.Spin,{spinning:m,children:[(0,o.jsxs)(`div`,{className:`perm-panel-header`,children:[(0,o.jsxs)(`div`,{className:`perm-panel-title`,children:[(0,o.jsx)(a.LockOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),(0,o.jsx)(`span`,{children:t?.roleName}),!m&&E>0&&(0,o.jsxs)(i.Tag,{color:`blue`,style:{marginLeft:8,fontSize:11},children:[T,`/`,E,` enabled`]})]}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,icon:(0,o.jsx)(a.UnlockOutlined,{}),loading:g,disabled:!v,onClick:S,children:`Save Changes`})]}),(0,o.jsxs)(`div`,{className:`perm-hint`,children:[(0,o.jsx)(a.InfoCircleOutlined,{className:`perm-hint-icon`}),(0,o.jsxs)(`span`,{children:[`Click a pill to toggle. `,(0,o.jsx)(`strong`,{children:`Double-click`}),` a module name or action label to rename it — labels are saved locally.`]})]}),C.length===0&&!m?(0,o.jsx)(`div`,{className:`perm-empty`,children:`No permission entries found for this role.`}):(0,o.jsx)(`div`,{className:`perm-cards-grid`,children:C.map(e=>(0,o.jsx)(Lx,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:n[e]??e,actionLabels:s,onModuleLabelSave:c,onActionLabelSave:l},e))})]})}var{Text:zx}=i.Typography,Bx=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function Vx(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function Hx(e){return String(e||``).trim().toLowerCase()}function Ux(e){return e?.key||e?.collectionName||e?.value||``}function Wx(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=Ux(e);if(!t)return;let o=Hx(e.key||t),s=Hx(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||Vx(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=Hx(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:Vx(t),value:t,disabled:!1}))}),n}function Gx(){let[t,n]=(0,r.useState)(null),[s,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(`listView`),[d,f]=(0,r.useState)([]),[p,m]=(0,r.useState)(0),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)([]),[y,b]=(0,r.useState)([]),[x,S]=(0,r.useState)(!1),[C,w]=(0,r.useState)(!1),T=(0,r.useMemo)(()=>_.filter(e=>!e.disabled),[_]),E=!x&&T.length===0,D=(0,r.useCallback)(async()=>{g(!0);try{let t=await e.wt();f(t.roles),m(t.total)}catch{i.message.error(`Failed to load roles`)}finally{g(!1)}},[]),O=(0,r.useCallback)(async()=>{S(!0);try{let[t,n]=await Promise.all([e.Pt(),e.Ot()]),r=Wx(t.modules,n),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));v(r),b(e=>e.filter(e=>i.has(e)))}catch{i.message.error(`Failed to load seed status`)}finally{S(!1)}},[]);(0,r.useEffect)(()=>{D()},[D]),(0,r.useEffect)(()=>{O()},[O]);async function k(){if(y.length===0){i.message.warning(E?`All modules already seeded.`:`Select at least one module to seed.`);return}w(!0);try{await e.sn(y),i.message.success(`Role field config seeded`),b([]),await O()}catch(e){i.message.error(e?.message||`Seed failed`)}finally{w(!1)}}function A(e,t=`listView`){n(e),u(t),c(!0)}return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,o.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,o.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,o.jsx)(i.Select,{mode:`multiple`,allowClear:!0,showSearch:!0,value:y,options:_,placeholder:E?`All modules already seeded`:`Select modules or collections to seed`,disabled:x||C||E,loading:x,onChange:b,style:{width:`100%`}})}),(0,o.jsx)(i.Button,{type:`primary`,loading:C,disabled:x||y.length===0,onClick:k,children:`Seed Field Config`})]}),(0,o.jsx)(zx,{type:`secondary`,style:{display:`block`,marginTop:8,fontSize:12},children:E?`Seed is disabled because all configured modules already have role field config data.`:`Already seeded modules are disabled. New modules or collections can still be seeded.`})]}),(0,o.jsx)(Z,{icon:(0,o.jsx)(a.SafetyOutlined,{}),title:`Roles`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,o.jsx)(du,{listName:`Roles`,dataSource:d,fields:[{label:`Role Name`,value:`roleName`,width:200},{label:`Description`,value:`description`,width:240},{label:`Users`,value:`userCount`,width:70,sorter:!1},{label:`Actions`,value:`_configure`,width:200,sorter:!1,render:(e,t)=>(0,o.jsxs)(i.Space,{size:2,children:[(0,o.jsx)(i.Button,{size:`small`,type:`link`,onClick:()=>A(t),children:`Configure`}),(0,o.jsx)(i.Button,{size:`small`,type:`link`,icon:(0,o.jsx)(a.LockOutlined,{}),onClick:()=>A(t,`permissions`),children:`Permissions`})]})}],loading:h,total:p})}),(0,o.jsxs)(i.Modal,{className:`uss-modal`,open:s,onCancel:()=>c(!1),title:(0,o.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,o.jsx)(a.SafetyOutlined,{style:{color:`var(--color-brand)`}}),(0,o.jsxs)(`span`,{children:[`Configure: `,t?.roleName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,o.jsx)(`div`,{style:{marginBottom:12},children:(0,o.jsx)(`div`,{className:`uss-config-toggle`,children:Bx.map(e=>(0,o.jsx)(`button`,{className:`uss-config-btn${l===e.key?` active`:``}`,onClick:()=>u(e.key),children:e.label},e.key))})}),t&&(l===`permissions`?(0,o.jsx)(Rx,{role:t},t?.roleId):(0,o.jsx)(mh,{role:t,configType:l},`${t?.roleId}-${l}`))]})]})}var Kx=`perm-module-labels`,qx=`perm-action-labels`;function Jx(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function Yx(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function Xx({label:e,onSave:t,onDelete:n,loading:s}){let[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)(e);function f(){l(!1);let n=u.trim();n&&n!==e?t(n):d(e)}return(0,o.jsxs)(`div`,{className:`perm-manage-row`,children:[c?(0,o.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input`,value:u,style:{flex:1,minWidth:0},onChange:e=>d(e.target.value),onBlur:f,onKeyDown:t=>{t.key===`Enter`&&f(),t.key===`Escape`&&(l(!1),d(e))}}):(0,o.jsx)(`span`,{className:`perm-manage-row-label`,children:e}),(0,o.jsxs)(`div`,{className:`perm-manage-row-actions`,children:[(0,o.jsx)(i.Button,{type:`text`,size:`small`,icon:(0,o.jsx)(a.EditOutlined,{}),onClick:()=>{d(e),l(!0)},loading:s}),(0,o.jsx)(i.Popconfirm,{title:`Delete this item?`,onConfirm:n,okText:`Delete`,cancelText:`Cancel`,okType:`danger`,children:(0,o.jsx)(i.Button,{type:`text`,size:`small`,icon:(0,o.jsx)(a.DeleteOutlined,{}),danger:!0})})]})]})}function Zx({open:t,onClose:n}){let[s,c]=(0,r.useState)(`modules`),[l,u]=(0,r.useState)([]),[d,f]=(0,r.useState)(!1),[p,m]=(0,r.useState)(``),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)([]),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(``),[C,w]=(0,r.useState)(``),[T,E]=(0,r.useState)(!1);(0,r.useEffect)(()=>{t&&(D(),O())},[t]);async function D(){f(!0);try{u(await e.Rt())}catch{i.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await e.Lt())}catch{i.message.error(`Failed to load actions`)}finally{b(!1)}}async function k(){let t=p.trim();if(!t){i.message.warning(`Enter a module name`);return}g(!0);try{let n=await e.st({menuName:t});u(e=>[...e,n]),m(``),i.message.success(`Module added`)}catch{i.message.error(`Failed to add module`)}finally{g(!1)}}async function A(t,n){try{await e.dn(t,{menuName:n}),u(e=>e.map(e=>e.MENUID===t?{...e,MENUNAME:n}:e))}catch{i.message.error(`Failed to update module`)}}async function j(t){try{await e.ht(t),u(e=>e.filter(e=>e.MENUID!==t)),i.message.success(`Module deleted`)}catch{i.message.error(`Failed to delete module`)}}async function M(){let t=x.trim(),n=C.trim().toLowerCase().replace(/\s+/g,`_`);if(!t||!n){i.message.warning(`Enter both name and key`);return}E(!0);try{let r=await e.ot({permissionName:t,permissionKey:n});v(e=>[...e,r]),S(``),w(``),i.message.success(`Action added`)}catch(e){i.message.error(e?.message?.includes(`409`)||e?.status===409?`Permission key already exists`:`Failed to add action`)}finally{E(!1)}}async function N(t,n){try{await e.un(t,{permissionName:n}),v(e=>e.map(e=>e.permissionId===t?{...e,permissionName:n}:e))}catch{i.message.error(`Failed to update action`)}}async function P(t){try{await e.mt(t),v(e=>e.filter(e=>e.permissionId!==t)),i.message.success(`Action deleted`)}catch{i.message.error(`Failed to delete action`)}}let F=[{key:`modules`,label:`Modules`,children:(0,o.jsxs)(i.Spin,{spinning:d,children:[(0,o.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,o.jsx)(i.Input,{placeholder:`Module name`,value:p,onChange:e=>m(e.target.value),onPressEnter:k,style:{flex:1},size:`small`}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,icon:(0,o.jsx)(a.PlusOutlined,{}),loading:h,onClick:k,children:`Add`})]}),(0,o.jsxs)(`div`,{className:`perm-manage-list`,children:[l.length===0&&!d&&(0,o.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No modules found`}),l.map(e=>(0,o.jsx)(Xx,{label:e.MENUNAME,onSave:t=>A(e.MENUID,t),onDelete:()=>j(e.MENUID)},e.MENUID))]})]})},{key:`actions`,label:`Actions`,children:(0,o.jsxs)(i.Spin,{spinning:y,children:[(0,o.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,o.jsx)(i.Input,{placeholder:`Action name (e.g. Approve)`,value:x,onChange:e=>S(e.target.value),style:{flex:1},size:`small`}),(0,o.jsx)(i.Input,{placeholder:`Key (e.g. approve)`,value:C,onChange:e=>w(e.target.value),onPressEnter:M,style:{width:140},size:`small`}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,icon:(0,o.jsx)(a.PlusOutlined,{}),loading:T,onClick:M,children:`Add`})]}),(0,o.jsxs)(`div`,{className:`perm-manage-list`,children:[_.length===0&&!y&&(0,o.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No actions found`}),_.map(e=>(0,o.jsx)(Xx,{label:`${e.permissionName} (${e.permissionKey})`,onSave:t=>N(e.permissionId,t),onDelete:()=>P(e.permissionId)},e.permissionId))]})]})}];return(0,o.jsx)(i.Modal,{open:t,onCancel:n,title:(0,o.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,o.jsx)(a.SettingOutlined,{style:{color:`var(--color-brand)`}}),`Manage Modules & Actions`]}),width:520,footer:null,destroyOnClose:!0,children:(0,o.jsx)(i.Tabs,{activeKey:s,onChange:c,size:`small`,items:F})})}function Qx(){let[t,n]=(0,r.useState)([]),[s,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(null),[d,f]=(0,r.useState)(``),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(()=>Jx(Kx)),[_,v]=(0,r.useState)(()=>Jx(qx)),y=(0,r.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return Yx(Kx,r),r})},[]),b=(0,r.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return Yx(qx,r),r})},[]);function x(){g({}),v({}),Yx(Kx,{}),Yx(qx,{}),i.message.success(`Labels reset to defaults`)}let S=(0,r.useCallback)(async()=>{c(!0);try{let{roles:t}=await e.wt();n(t),t.length>0&&u(t[0])}catch{i.message.error(`Failed to load roles`)}finally{c(!1)}},[]);(0,r.useEffect)(()=>{S()},[S]);let C=(0,r.useMemo)(()=>{let e=d.trim().toLowerCase();return e?t.filter(t=>t.roleName.toLowerCase().includes(e)):t},[t,d]),w=Object.keys(h).length>0||Object.keys(_).length>0;return(0,o.jsxs)(`div`,{className:`perm-page`,children:[(0,o.jsxs)(Z,{className:`perm-left-card`,icon:(0,o.jsx)(a.SafetyOutlined,{}),title:`Roles`,bodyStyle:{padding:0},children:[(0,o.jsx)(`div`,{className:`perm-role-search`,children:(0,o.jsx)(i.Input,{prefix:(0,o.jsx)(a.SearchOutlined,{}),placeholder:`Search roles…`,allowClear:!0,size:`small`,value:d,onChange:e=>f(e.target.value)})}),(0,o.jsx)(i.Spin,{spinning:s,children:(0,o.jsxs)(`div`,{className:`perm-role-list`,children:[C.length===0&&!s&&(0,o.jsx)(`div`,{className:`perm-role-empty`,children:`No roles found`}),C.map(e=>{let t=l?.roleId===e.roleId,n=e.description&&e.description!==`N/A`?e.description:e.roleType===0?`Default role`:`Custom role`;return(0,o.jsxs)(`div`,{className:`perm-role-item${t?` active`:``}`,onClick:()=>u(e),children:[(0,o.jsx)(`div`,{className:`perm-role-item-name`,children:e.roleName}),(0,o.jsx)(`div`,{className:`perm-role-item-desc`,children:n})]},e.roleId)})]})})]}),(0,o.jsx)(Z,{className:`perm-right-card`,icon:(0,o.jsx)(a.LockOutlined,{}),title:`Module Permissions`,extra:(0,o.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[w&&(0,o.jsx)(`button`,{className:`perm-reset-btn`,onClick:x,children:`Reset labels`}),(0,o.jsx)(i.Button,{size:`small`,icon:(0,o.jsx)(a.SettingOutlined,{}),onClick:()=>m(!0),children:`Manage`})]}),bodyStyle:{padding:`12px 16px`},children:l?(0,o.jsx)(Rx,{role:l,moduleLabels:h,actionLabels:_,onModuleLabelSave:y,onActionLabelSave:b},l.roleId):(0,o.jsx)(`div`,{className:`perm-empty`,children:`Select a role from the left to manage its permissions.`})}),(0,o.jsx)(Zx,{open:p,onClose:()=>m(!1)})]})}var{Title:$x,Text:eS}=i.Typography,tS=[{label:`In Progress`,value:107,sub:`Under review`,color:`blue`},{label:`Hired`,value:2,sub:`Onboarded`,color:`green`},{label:`Project Completed`,value:2,sub:`Project cycle closed`,color:`purple`},{label:`Archive`,value:2,sub:`No longer active`,color:`peach`}];function nS({items:e=tS}){return(0,o.jsx)(i.Card,{className:`onboarding-card`,title:(0,o.jsx)($x,{level:5,children:`Onboarding`}),extra:(0,o.jsx)(i.Button,{type:`link`,children:`View all`}),children:(0,o.jsx)(i.Row,{gutter:[12,12],children:e.map(e=>(0,o.jsx)(i.Col,{xs:12,sm:6,md:6,lg:12,xl:12,children:(0,o.jsxs)(`div`,{className:`onboarding-item ${e.color}`,children:[(0,o.jsx)(eS,{className:`onboarding-item-label`,children:e.label}),(0,o.jsx)(i.Statistic,{value:e.value,className:`onboarding-stat`}),(0,o.jsx)(`div`,{className:`onboarding-item-footer`,children:(0,o.jsx)(eS,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:rS,Title:iS}=i.Typography,aS=[{group:`Dashboard`,items:[{id:`dashboard`,label:`Admin Dashboard`,icon:(0,o.jsx)(a.DashboardOutlined,{})}]},{group:`Settings`,items:[{id:`org`,label:`Organization`,icon:(0,o.jsx)(a.BankOutlined,{}),heading:`Organization Settings`,desc:`Manage your company profile and location details`,cards:[{label:`Company Information`,icon:(0,o.jsx)(a.BankOutlined,{}),desc:`Manage company profile, address and business details.`},{label:`Location`,icon:(0,o.jsx)(a.BuildOutlined,{}),desc:`Manage office locations, branches and regions.`}]},{id:`users`,label:`Users`,icon:(0,o.jsx)(a.UserOutlined,{}),heading:`Users`,desc:`Manage platform users and configure their field views.`,component:`users`},{id:`teams`,label:`Teams`,icon:(0,o.jsx)(a.TeamOutlined,{}),heading:`Teams`,desc:`Organize users into teams and configure field visibility per team.`,component:`teams`},{id:`roles`,label:`Roles`,icon:(0,o.jsx)(a.SafetyOutlined,{}),heading:`Roles`,desc:`Control permissions and configure field visibility per role.`,component:`roles`},{id:`permissions`,label:`Permissions`,icon:(0,o.jsx)(a.LockOutlined,{}),heading:`Permissions`,desc:`Manage module-wise action permissions (view, add, edit, delete, and more) per role.`,component:`permissions`},{id:`templates`,label:`Templates`,icon:(0,o.jsx)(a.FileTextOutlined,{}),heading:`Templates`,desc:`Email and signature templates for communications`,component:`templates`},{id:`ai-services`,label:`AI Services`,icon:(0,o.jsx)(a.ThunderboltOutlined,{}),heading:`AI Services`,desc:`Register the AI/automation backends (base URL + auth) that admin-configured AI Actions call.`,component:`ai-services`}]},{group:`Clients`,items:[{id:`clients`,label:`Clients`,icon:(0,o.jsx)(a.BankOutlined,{}),heading:`Clients`,desc:`Manage client accounts and settings`,cards:[{label:`Clients`,icon:(0,o.jsx)(a.BankOutlined,{}),desc:`Manage client companies and account details.`}]}]},{group:`Forms`,items:[{id:`form-groups`,label:`Form Groups`,icon:(0,o.jsx)(a.AppstoreAddOutlined,{}),heading:`Form Groups`,desc:`Define field groups for module add/edit forms with validations and dropdown sources.`,component:`form-groups`},{id:`detail-groups`,label:`Detail Groups`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),heading:`Detail Groups`,desc:`Customize the detail view per module: labels, prefix/suffix, colour, capitalization, reference lookups and merged fields.`,component:`detail-groups`},{id:`row-actions`,label:`Actions`,icon:(0,o.jsx)(a.ToolOutlined,{}),heading:`Actions`,desc:`Configure which action buttons appear per row in each module's list view, scoped per role.`,component:`row-actions`}]},{group:`Master`,items:[{id:`jobs`,label:`Jobs`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),heading:`Jobs Master`,desc:`Configure job sources and status types`,cards:[{label:`Sources`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),desc:`Manage job source master values.`},{label:`Job Status`,icon:(0,o.jsx)(a.CheckCircleOutlined,{}),desc:`Configure job workflow status.`}]},{id:`candidates`,label:`Candidates`,icon:(0,o.jsx)(a.UserOutlined,{}),heading:`Candidates Master`,desc:`Skills, sources and work authorization settings`,cards:[{label:`Sources`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),desc:`Manage candidate source values.`},{label:`Skills`,icon:(0,o.jsx)(a.SettingOutlined,{}),desc:`Manage skill master data.`},{label:`Work Authorization`,icon:(0,o.jsx)(a.SafetyOutlined,{}),desc:`Manage visa and authorization types.`}]},{id:`submissions`,label:`Submissions`,icon:(0,o.jsx)(a.FileTextOutlined,{}),heading:`Submissions Master`,desc:`Rejection reasons and submission status configuration`,cards:[{label:`Rejection Reasons`,icon:(0,o.jsx)(a.FileTextOutlined,{}),desc:`Manage common rejection reasons.`},{label:`Client Submission Status`,icon:(0,o.jsx)(a.CheckCircleOutlined,{}),desc:`Manage client submission statuses.`}]},{id:`clientmaster`,label:`Client Master`,icon:(0,o.jsx)(a.BankOutlined,{}),heading:`Client Master`,desc:`Payment terms, client types and contact types`,cards:[{label:`Payment Terms`,icon:(0,o.jsx)(a.FileTextOutlined,{}),desc:`Manage billing and payment terms.`},{label:`Client Type`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),desc:`Classify client business types.`},{label:`Client Contact Type`,icon:(0,o.jsx)(a.TeamOutlined,{}),desc:`Manage client contact categories.`}]}]}],oS=[{label:`Sourced`,count:312,color:`#378ADD`,pct:35},{label:`Screened`,count:223,color:`#7F77DD`,pct:25},{label:`Interview`,count:161,color:`#1D9E75`,pct:18},{label:`Offered`,count:107,color:`#EF9F27`,pct:12},{label:`Rejected`,count:89,color:`#E24B4A`,pct:10}],sS=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],cS=[{text:`New candidate Ravi Kumar added to Java Developer role`,time:`2 min ago`,color:`#378ADD`},{text:`Submission approved by Acme Corp for Sr. React Dev`,time:`18 min ago`,color:`#1D9E75`},{text:`User Priya S. added to Recruiters team`,time:`1 hr ago`,color:`#7F77DD`},{text:`Job Data Analyst — TechFlow moved to archived`,time:`3 hr ago`,color:`#EF9F27`},{text:`Candidate rejected — work authorization mismatch`,time:`5 hr ago`,color:`#E24B4A`}];function lS(){return(0,o.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.DashboardOutlined,{}),title:`Admin Dashboard`,children:[(0,o.jsx)(`div`,{className:`admin-accent-bar`}),(0,o.jsx)(iS,{level:5,children:`Admin Dashboard`}),(0,o.jsx)(rS,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,o.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,o.jsx)(vx,{stats:[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`},{label:`Total Candidates`,value:4320,icon:`team`},{label:`Submissions`,value:892,icon:`fileText`}]})}),(0,o.jsxs)(`div`,{className:`admin-dashboard-mid-row`,children:[(0,o.jsx)(nS,{}),(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,o.jsx)(rS,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,o.jsx)(`div`,{className:`admin-pipeline-bar`,children:oS.map(e=>(0,o.jsx)(`div`,{className:`admin-pipeline-seg`,style:{width:`${e.pct}%`,background:e.color}},e.label))}),(0,o.jsx)(`div`,{className:`admin-pipeline-legend`,children:oS.map(e=>(0,o.jsxs)(`div`,{className:`admin-pipeline-legend-item`,children:[(0,o.jsx)(`span`,{className:`admin-pipeline-dot`,style:{background:e.color}}),e.label,` `,e.count]},e.label))}),(0,o.jsx)(`div`,{className:`admin-divider`}),(0,o.jsx)(rS,{strong:!0,style:{fontSize:12},children:`Submission status`}),(0,o.jsxs)(`div`,{className:`admin-sub-status-list`,style:{marginTop:6},children:[(0,o.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,o.jsx)(rS,{style:{fontSize:13},children:`Pending client review`}),(0,o.jsx)(`span`,{className:`admin-badge warn`,children:`312`})]}),(0,o.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,o.jsx)(rS,{style:{fontSize:13},children:`Client approved`}),(0,o.jsx)(`span`,{className:`admin-badge success`,children:`248`})]}),(0,o.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,o.jsx)(rS,{style:{fontSize:13},children:`Rejected`}),(0,o.jsx)(`span`,{className:`admin-badge danger`,children:`89`})]})]})]})]}),(0,o.jsxs)(`div`,{className:`admin-dashboard-bottom-row`,children:[(0,o.jsx)(Z,{icon:(0,o.jsx)(a.BankOutlined,{}),title:`Top Clients`,extra:(0,o.jsx)(i.Button,{type:`link`,size:`small`,children:`View all`}),children:sS.map(e=>(0,o.jsxs)(`div`,{className:`admin-client-row`,children:[(0,o.jsxs)(`div`,{className:`admin-client-left`,children:[(0,o.jsx)(`div`,{className:`admin-client-icon`,children:(0,o.jsx)(a.BankOutlined,{})}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`admin-client-name`,children:e.name}),(0,o.jsxs)(`div`,{className:`admin-client-sub`,children:[e.jobs,` open jobs`]})]})]}),(0,o.jsxs)(`div`,{className:`admin-client-right`,children:[(0,o.jsx)(`div`,{className:`admin-client-val`,children:e.candidates}),(0,o.jsx)(`div`,{className:`admin-client-sub`,children:`candidates`})]})]},e.name))}),(0,o.jsx)(Z,{icon:(0,o.jsx)(a.BellOutlined,{}),title:`Recent Activity`,children:cS.map((e,t)=>(0,o.jsxs)(`div`,{className:`admin-activity-row`,children:[(0,o.jsx)(`div`,{className:`admin-activity-dot`,style:{background:e.color}}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`admin-activity-text`,children:e.text}),(0,o.jsx)(`div`,{className:`admin-activity-time`,children:e.time})]})]},t))})]}),(0,o.jsx)(Z,{icon:(0,o.jsx)(a.SettingOutlined,{}),title:`Admin Configuration Overview`,extra:(0,o.jsx)(i.Button,{type:`link`,size:`small`,children:`Manage`}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsxs)(i.Col,{span:8,children:[(0,o.jsx)(rS,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Settings`}),[[`Organization`,2],[`User Settings`,4],[`Templates`,2]].map(([e,t])=>(0,o.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,o.jsx)(rS,{style:{fontSize:12},children:e}),(0,o.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,o.jsxs)(i.Col,{span:8,children:[(0,o.jsx)(rS,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Master`}),[[`Jobs`,2],[`Candidates`,3],[`Submissions`,2]].map(([e,t])=>(0,o.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,o.jsx)(rS,{style:{fontSize:12},children:e}),(0,o.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,o.jsxs)(i.Col,{span:8,children:[(0,o.jsx)(rS,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`System`}),[[`Total Groups`,4],[`Total Modules`,9],[`Config Items`,19]].map(([e,t])=>(0,o.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,o.jsx)(rS,{style:{fontSize:12},children:e}),(0,o.jsx)(rS,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function uS({activeSection:e,activeGroup:t,filteredCards:n,searchText:r,setSearchText:s,allItems:c,handleNav:l}){return(0,o.jsxs)(i.Row,{gutter:[16,16],children:[(0,o.jsx)(i.Col,{span:24,children:(0,o.jsxs)(Z,{icon:e?.icon,title:e?.heading,extra:(0,o.jsx)(i.Input,{className:`admin-search`,prefix:(0,o.jsx)(a.SearchOutlined,{}),placeholder:`Search settings…`,allowClear:!0,value:r,onChange:e=>s(e.target.value)}),children:[(0,o.jsx)(`div`,{className:`admin-accent-bar`}),(0,o.jsx)(iS,{level:5,children:e?.heading}),(0,o.jsx)(rS,{type:`secondary`,children:e?.desc})]})}),(0,o.jsx)(i.Col,{xs:24,xl:16,style:{alignSelf:`flex-start`},children:(0,o.jsx)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Configuration Items`,extra:(0,o.jsxs)(rS,{type:`secondary`,children:[n.length,` item`,n.length===1?``:`s`]}),children:(0,o.jsx)(i.Row,{gutter:[14,14],children:n.length>0?n.map(e=>(0,o.jsx)(i.Col,{xs:24,sm:12,xl:8,children:(0,o.jsxs)(`div`,{className:`admin-config-item`,children:[(0,o.jsx)(`div`,{className:`admin-config-top-bar`}),(0,o.jsxs)(`div`,{className:`admin-config-body`,children:[(0,o.jsx)(`div`,{className:`admin-config-icon`,children:e.icon}),(0,o.jsxs)(`div`,{className:`admin-config-text`,children:[(0,o.jsx)(`span`,{className:`admin-config-label`,children:e.label}),(0,o.jsx)(`span`,{className:`admin-config-desc`,children:e.desc})]})]}),(0,o.jsx)(`div`,{className:`admin-config-divider`}),(0,o.jsx)(i.Button,{type:`link`,size:`small`,className:`admin-config-manage`,icon:(0,o.jsx)(a.RightOutlined,{}),iconPosition:`end`,children:`Manage`})]})},e.label)):(0,o.jsx)(i.Col,{span:24,children:(0,o.jsx)(`div`,{className:`admin-config-empty`,children:(0,o.jsx)(i.Empty,{description:`No settings found`,image:i.Empty.PRESENTED_IMAGE_SIMPLE})})})})})}),(0,o.jsx)(i.Col,{xs:24,xl:8,style:{alignSelf:`flex-start`},children:(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`Section Overview`,children:[(0,o.jsx)(`div`,{className:`admin-overview-list`,children:aS.filter(e=>e.group!==`Dashboard`).map(e=>{let n=e.group===t?.group;return(0,o.jsxs)(`div`,{className:`admin-overview-item${n?` active`:``}`,onClick:()=>{let t=e.items[0];t&&l(t.id)},children:[(0,o.jsxs)(`div`,{className:`admin-overview-left`,children:[(0,o.jsx)(`div`,{className:`admin-overview-icon`,children:e.items[0]?.icon}),(0,o.jsxs)(`div`,{className:`admin-overview-text`,children:[(0,o.jsx)(`span`,{className:`admin-overview-name`,children:e.group}),(0,o.jsxs)(`span`,{className:`admin-overview-sub`,children:[e.items.length,` module`,e.items.length===1?``:`s`]})]})]}),(0,o.jsx)(`span`,{className:`admin-overview-count${n?` active`:``}`,children:e.items.length})]},e.group)})}),(0,o.jsxs)(`div`,{className:`admin-overview-footer`,children:[(0,o.jsx)(`span`,{className:`admin-overview-footer-label`,children:`Total configuration items`}),(0,o.jsx)(`span`,{className:`admin-overview-footer-value`,children:c.filter(e=>e.cards).reduce((e,t)=>e+t.cards.length,0)})]})]})})]})}function dS(){let[e,t]=(0,r.useState)(`dashboard`),[n,s]=(0,r.useState)(``),c=(0,r.useMemo)(()=>aS.flatMap(e=>e.items),[]),l=(0,r.useMemo)(()=>c.find(t=>t.id===e),[c,e]),u=(0,r.useMemo)(()=>aS.find(t=>t.items.some(t=>t.id===e)),[e]),d=(0,r.useMemo)(()=>{if(!l?.cards)return[];let e=n.trim().toLowerCase();return e?l.cards.filter(t=>t.label.toLowerCase().includes(e)||t.desc.toLowerCase().includes(e)):l.cards},[l,n]),f=(0,r.useMemo)(()=>aS.map(e=>({key:e.group,type:`group`,label:e.group,children:e.items.map(e=>({key:e.id,icon:e.icon,label:e.label}))})),[]),p=e=>{t(e),s(``)};return e===`dashboard`||l?.heading,(0,o.jsxs)(`main`,{className:`admin-page`,children:[(0,o.jsx)(`div`,{className:`admin-breadcrumb`,children:(0,o.jsx)(i.Breadcrumb,{items:[{title:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.HomeOutlined,{}),` Home`]})},{title:`Admin`}]})}),(0,o.jsxs)(i.Row,{gutter:[16,16],className:`admin-wrapper`,children:[(0,o.jsx)(i.Col,{xs:24,lg:6,xl:5,children:(0,o.jsxs)(Z,{title:`Admin Console`,icon:(0,o.jsx)(a.SettingOutlined,{}),children:[(0,o.jsxs)(`div`,{className:`admin-sidebar-banner`,children:[(0,o.jsx)(`span`,{className:`admin-sidebar-banner-title`,children:`Admin Panel`}),(0,o.jsx)(`span`,{className:`admin-sidebar-banner-sub`,children:`Configuration Center`}),(0,o.jsxs)(i.Row,{gutter:[8,0],children:[(0,o.jsx)(i.Col,{span:12,children:(0,o.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,o.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Groups`}),(0,o.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:aS.length})]})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,o.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Modules`}),(0,o.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:c.length})]})})]})]}),(0,o.jsx)(i.Menu,{mode:`inline`,selectedKeys:[e],items:f,onClick:({key:e})=>p(e),className:`admin-sidebar-menu`})]})}),(0,o.jsx)(i.Col,{xs:24,lg:18,xl:19,children:e===`dashboard`?(0,o.jsx)(lS,{}):l?.component===`form-groups`?(0,o.jsx)(og,{}):l?.component===`detail-groups`?(0,o.jsx)(kg,{}):l?.component===`row-actions`?(0,o.jsx)(g_,{}):l?.component===`users`?(0,o.jsx)(Sx,{}):l?.component===`teams`?(0,o.jsx)(Ox,{}):l?.component===`roles`?(0,o.jsx)(Gx,{}):l?.component===`permissions`?(0,o.jsx)(Qx,{}):l?.component===`templates`?(0,o.jsx)(T_,{}):l?.component===`ai-services`?(0,o.jsx)(k_,{}):(0,o.jsx)(uS,{activeSection:l,activeGroup:u,filteredCards:d,searchText:n,setSearchText:s,allItems:c,handleNav:p})})]})]})}var{Title:fS}=i.Typography;function pS(){let e=(0,s.useNavigate)(),{state:t}=(0,s.useLocation)(),n=t?.moduleName||`stickyNotes`,r=t?.title||`Sticky Notes`,c={...t?.request,params:{...t?.request?.params,limit:200,offset:0}};return(0,o.jsxs)(`div`,{children:[(0,o.jsx)(i.Button,{type:`text`,icon:(0,o.jsx)(a.ArrowLeftOutlined,{}),onClick:()=>e(-1),style:{marginBottom:12},children:`Back`}),(0,o.jsx)(at,{moduleName:n,title:r,columns:4,request:c,viewAll:!1})]})}var{Text:mS,Title:hS}=i.Typography,gS=10*1024*1024,_S=`/templates/test_cases_flow_template.base64.txt`,vS=`test_cases_flow_template.xlsx`,yS=`module | subModule | step_order | description | actions | key | value | expected | scenario`,bS={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},xS=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function SS(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result).split(`,`)[1]),r.onerror=n,r.readAsDataURL(e)})}function CS(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function wS(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function TS({errors:e}){return(0,o.jsx)(`div`,{className:`bulk-tooltip-errors`,children:(e??[]).map((e,t)=>(0,o.jsx)(`div`,{children:e.message},`${e.field}-${t}`))})}function ES({errors:e,expanded:t,onToggle:n,onSummaryClick:r}){return e.length===0?null:(0,o.jsxs)(`div`,{className:`bulk-error-banner`,children:[(0,o.jsxs)(`div`,{className:`bulk-error-summary`,children:[(0,o.jsxs)(`button`,{type:`button`,className:`bulk-error-summary-main`,onClick:r,"aria-label":`Scroll to first invalid row`,children:[(0,o.jsx)(a.ExclamationCircleOutlined,{className:`bulk-error-icon`}),(0,o.jsxs)(`span`,{children:[e.length,` validation error(s) found`]})]}),(0,o.jsx)(i.Button,{type:`link`,onClick:n,"aria-expanded":t,children:t?`Hide Errors`:`View Errors`})]}),t&&(0,o.jsx)(`div`,{className:`bulk-error-list`,role:`region`,"aria-label":`Validation error details`,children:e.map((e,t)=>(0,o.jsxs)(`div`,{className:`bulk-error-line`,children:[(0,o.jsxs)(`span`,{className:`bulk-row-chip`,children:[`Row `,e.id]}),(0,o.jsx)(`span`,{children:e.message})]},`${e.id}-${e.field}-${t}`))})]})}function DS({rows:e,view:t,onViewChange:n,onConfirm:r,onReset:s,saving:c,firstInvalidRowId:l,firstInvalidRowRef:u}){let d=e.filter(e=>e.row_status===`invalid`),f=t===`errors`?d:e,p=d.length>0||c;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(i.Row,{justify:`space-between`,align:`middle`,gutter:[16,16],className:`bulk-table-toolbar`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space.Compact,{children:[(0,o.jsx)(i.Button,{type:t===`all`?`primary`:`default`,onClick:()=>n(`all`),children:`All rows`}),(0,o.jsx)(i.Button,{type:t===`errors`?`primary`:`default`,onClick:()=>n(`errors`),children:`Errors only`})]})}),(0,o.jsx)(i.Col,{children:(0,o.jsxs)(mS,{type:`secondary`,children:[e.length,` row(s)`]})})]}),(0,o.jsx)(`div`,{className:`bulk-table-wrap`,children:(0,o.jsxs)(`table`,{className:`bulk-preview-table`,children:[(0,o.jsx)(`thead`,{children:(0,o.jsxs)(`tr`,{children:[(0,o.jsx)(`th`,{className:`bulk-col-row`,children:`Row`}),(0,o.jsx)(`th`,{className:`bulk-col-flow`,children:`Submodule`}),(0,o.jsx)(`th`,{className:`bulk-col-description`,children:`Description`}),(0,o.jsx)(`th`,{className:`bulk-col-keyword`,children:`Action`}),(0,o.jsx)(`th`,{className:`bulk-col-target`,children:`Key`}),(0,o.jsx)(`th`,{className:`bulk-col-status`,children:`Status`}),(0,o.jsx)(`th`,{className:`bulk-col-error`,children:`Error`})]})}),(0,o.jsx)(`tbody`,{children:f.map(e=>{let t=e.errors??[],n=e.row_status===`invalid`;return(0,o.jsxs)(`tr`,{ref:n&&e.id===l?u:null,className:n?`bulk-row-invalid`:``,children:[(0,o.jsx)(`td`,{children:e.id}),(0,o.jsx)(`td`,{title:e.submodule,children:e.submodule}),(0,o.jsx)(`td`,{title:e.description,children:e.description?e.description:(0,o.jsx)(`span`,{className:`bulk-empty-text`,children:`-empty-`})}),(0,o.jsx)(`td`,{children:(0,o.jsx)(`code`,{className:`bulk-code-chip`,children:e.actions})}),(0,o.jsx)(`td`,{title:e.key,children:e.key}),(0,o.jsx)(`td`,{children:n?(0,o.jsx)(i.Tag,{color:`red`,children:`Error`}):(0,o.jsx)(i.Tag,{color:`green`,children:`Valid`})}),(0,o.jsx)(`td`,{children:n?(0,o.jsx)(i.Tooltip,{title:(0,o.jsx)(TS,{errors:t}),placement:`left`,children:(0,o.jsxs)(`button`,{type:`button`,className:`bulk-error-info`,"aria-label":`View ${t.length} error(s) for row ${e.id}`,children:[(0,o.jsx)(a.InfoCircleOutlined,{}),(0,o.jsx)(i.Badge,{count:t.length,size:`small`})]})}):(0,o.jsx)(`span`,{className:`bulk-error-none`,children:`-`})})]},`${e.id}-${e.step_order}`)})})]})}),(0,o.jsxs)(i.Space,{className:`bulk-actions`,children:[(0,o.jsx)(i.Button,{icon:(0,o.jsx)(a.ReloadOutlined,{}),onClick:s,children:`Reset`}),(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.SaveOutlined,{}),loading:c,disabled:p,onClick:r,children:d.length>0?`Fix ${d.length} error(s) to proceed`:`Save to database`})]})]})}function OS(){let n=(0,s.useNavigate)(),c=(0,r.useMemo)(()=>t.s(),[]),l=(0,r.useRef)(null),u=(0,r.useRef)(null),[d,f]=(0,r.useState)([]),[p,m]=(0,r.useState)(``),[h,g]=(0,r.useState)(`idle`),[_,v]=(0,r.useState)(!1),[y,b]=(0,r.useState)(null),[x,S]=(0,r.useState)([]),[C,w]=(0,r.useState)(`all`),[T,E]=(0,r.useState)(null),[D,O]=(0,r.useState)(null),[k,A]=(0,r.useState)(!1),j=d.map(e=>({value:e.modulename,label:e.modulename})),M=wS(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=bS[h]??0,I=x.find(e=>e.row_status===`invalid`)?.id,L=(0,r.useCallback)(()=>{m(``),g(`idle`),v(!1),b(null),S([]),w(`all`),E(null),O(null),l.current&&(l.current.value=``)},[]);(0,r.useEffect)(()=>{async function e(){try{f((await om({project:c?.name??``,activeOnly:!0}))?.items??[])}catch(e){console.error(e),i.message.error(`Unable to load modules.`)}}e()},[c?.name]);let R=e=>{m(e??``),S([]),O(null),E(null),b(null),A(!1),g(e?`module_set`:`idle`)},z=async e=>{if(!e||!P)return;let t=e.name.split(`.`).pop()?.toLowerCase();if(![`xlsx`,`csv`].includes(t)){g(`module_set`),E({message:`Invalid file type. Please upload an Excel .xlsx or CSV .csv file.`});return}if(e.size>gS){g(`module_set`),E({message:`File must be 10 MB or smaller.`});return}E(null),S([]),O(null),b({name:e.name,size:e.size}),g(`encoding`);try{let n=await SS(e);g(`validating`),S((await tm({filename:e.name,project:c?.name??``,module:p,file_base64:n,file_type:t}))?.rows??[]),w(`all`),g(`preview`)}catch(e){console.error(e),E(e.payload??{code:`NETWORK_ERROR`,message:e.message||`Could not reach the server.`}),g(`error`)}},B=async()=>{try{let e=await fetch(_S);if(!e.ok)throw Error(`Template file not found (${e.status})`);let t=(await e.text()).trim(),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);let a=new Blob([r],{type:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=vS,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o),i.message.success(`Sample template downloaded.`)}catch(e){console.error(e),i.message.error(`Unable to download sample template.`)}},V=async()=>{g(`inserting`),E(null);try{O(await nm({project:c?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:CS(x)})),g(`done`),i.message.success(`Bulk upload saved. Redirecting to view test cases...`),window.setTimeout(()=>n(`/viewTestCase`),900)}catch(e){console.error(e),E(e.payload??{code:`NETWORK_ERROR`,message:e.message||`Could not reach the server.`}),g(`preview`)}},H=(0,r.useCallback)(()=>{u.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[]),U=[`bulk-dropzone`,_?`bulk-dropzone-dragging`:``,y?`bulk-dropzone-has-file`:``,T&&h!==`preview`?`bulk-dropzone-error`:``,p?``:`bulk-dropzone-disabled`].filter(Boolean).join(` `);return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:xS})}),c?.name&&(0,o.jsx)(i.Col,{children:(0,o.jsx)(mS,{strong:!0,children:c.name})})]}),(0,o.jsxs)(`div`,{className:`zt-page zt-page-wide bulk-page`,children:[(0,o.jsxs)(`div`,{className:`bulk-header`,children:[(0,o.jsx)(hS,{level:3,children:`Bulk upload test cases`}),(0,o.jsxs)(i.Space,{direction:`vertical`,size:4,children:[(0,o.jsx)(mS,{type:`secondary`,children:yS}),(0,o.jsx)(mS,{type:`secondary`,children:`Use the sample template for the required columns. Uploaded rows are saved as Active by default.`})]})]}),(0,o.jsx)(`div`,{className:`bulk-stepbar`,children:[`Select`,`Upload`,`Validate`,`Save`].map((e,t)=>(0,o.jsxs)(`span`,{className:t<F?`bulk-step-active`:``,children:[t+1,` `,e]},e))}),(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:`1. Module selector`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,className:`bulk-module-select`,placeholder:`Choose a module`,options:j,value:p||void 0,onChange:R})}),p&&(0,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:`2. File upload`,extra:(0,o.jsx)(i.Button,{icon:(0,o.jsx)(a.DownloadOutlined,{}),onClick:B,children:`Download Sample Template`}),children:[(0,o.jsx)(i.Alert,{type:`info`,showIcon:!0,message:`First time uploading?`,description:`Download the sample template, keep the column names unchanged, fill your test steps, and upload either .xlsx or .csv.`,className:`bulk-inline-alert`}),(0,o.jsxs)(`button`,{type:`button`,className:U,disabled:!P,onClick:()=>l.current?.click(),onDragOver:e=>{e.preventDefault(),P&&v(!0)},onDragLeave:()=>v(!1),onDrop:e=>{e.preventDefault(),v(!1),z(e.dataTransfer.files?.[0])},children:[(0,o.jsx)(a.CloudUploadOutlined,{className:`bulk-upload-icon`}),y?(0,o.jsxs)(`span`,{className:`bulk-file-chip`,children:[y.name,` - `,Math.ceil(y.size/1024),` KB`]}):(0,o.jsx)(`span`,{children:`Drag & drop here, or click to browse`})]}),(0,o.jsx)(`input`,{ref:l,hidden:!0,type:`file`,accept:`.xlsx,.csv`,onChange:e=>z(e.target.files?.[0])}),N&&(0,o.jsx)(i.Progress,{percent:h===`encoding`?45:82,showInfo:!1,size:`small`}),T&&h!==`preview`&&(0,o.jsx)(i.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`})]}),x.length>0&&(0,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:`3. Validation result`,children:[(0,o.jsx)(ES,{errors:M,expanded:k,onToggle:()=>A(e=>!e),onSummaryClick:H}),T&&h===`preview`&&(0,o.jsx)(i.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`}),(0,o.jsx)(DS,{rows:x,view:C,onViewChange:w,onConfirm:V,onReset:L,saving:h===`inserting`,firstInvalidRowId:I,firstInvalidRowRef:u})]}),D&&h===`done`&&(0,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:`4. Upload complete`,children:[(0,o.jsxs)(i.Row,{gutter:[16,16],className:`bulk-metrics`,children:[(0,o.jsx)(i.Col,{xs:24,md:8,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(mS,{children:`Total`}),(0,o.jsx)(`strong`,{children:x.length})]})}),(0,o.jsx)(i.Col,{xs:24,md:8,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(mS,{children:`Inserted`}),(0,o.jsx)(`strong`,{children:D.inserted??0})]})}),(0,o.jsx)(i.Col,{xs:24,md:8,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(mS,{children:`Failed`}),(0,o.jsx)(`strong`,{children:D.failed??0})]})})]}),(0,o.jsx)(i.Alert,{type:`success`,showIcon:!0,icon:(0,o.jsx)(a.CheckCircleOutlined,{}),message:`${D.inserted??0} test cases saved to database - module: ${p}`,className:`bulk-inline-alert`}),(0,o.jsx)(i.Button,{icon:(0,o.jsx)(a.ReloadOutlined,{}),onClick:L,children:`Upload another file`})]})]})]})}var kS=[{value:`navigate`,label:`Navigate`},{value:`fill`,label:`Fill`},{value:`click`,label:`Click`},{value:`select`,label:`Select`},{value:`press_key`,label:`Press Key`},{value:`type_and_select`,label:`Type and Select`},{value:`type_and_select_modal`,label:`Type and Select (Modal)`},{value:`upload_file`,label:`Upload File`},{value:`check_checkbox`,label:`Check Checkbox`},{value:`check_filter_checkbox`,label:`Check Filter Checkbox`},{value:`select_page_size`,label:`Select Page Size`},{value:`check_n_checkboxes`,label:`Check N Checkboxes`},{value:`store_text`,label:`Store Text`},{value:`reset_session`,label:`Reset Session`},{value:`switch_to_new_tab`,label:`Switch To New Tab`},{value:`close_tab`,label:`Close Tab`},{value:`assert_visible`,label:`Assert Visible`},{value:`assert_hidden`,label:`Assert Hidden`},{value:`assert_text`,label:`Assert Text`},{value:`assert_url`,label:`Assert URL`},{value:`assert_body_contains`,label:`Assert Body Contains`},{value:`assert_button_disabled`,label:`Assert Button Disabled`},{value:`assert_field_error`,label:`Assert Field Error`},{value:`assert_field_accepted`,label:`Assert Field Accepted`},{value:`assert_children_disabled`,label:`Assert Children Disabled`},{value:`assert_children_visible`,label:`Assert Children Visible`},{value:`assert_element_count`,label:`Assert Element Count`},{value:`assert_toast`,label:`Assert Toast`},{value:`assert_toast_success`,label:`Assert Toast Success`},{value:`assert_toast_error`,label:`Assert Toast Error`},{value:`wait_for_visible`,label:`Wait For Visible`},{value:`wait_for_hidden`,label:`Wait For Hidden`},{value:`wait_for_text`,label:`Wait For Text`}],{Text:AS}=i.Typography,jS=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],MS={tags:`regression`,active:1},NS={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function PS(e=[]){return e.map(e=>({value:e,label:e}))}function FS(e=``){return String(e??``).trim()}function IS(e=``){return FS(e).toLowerCase()}function LS(e=[]){let t=new Map;return e.forEach(e=>{let n=FS(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function RS(e=[],t,n){let r=FS(t).toLowerCase(),i=FS(n).toLowerCase();return e.reduce((e,t)=>{let n=FS(t?.module).toLowerCase(),a=FS(t?.flow).toLowerCase();if(n!==r||a!==i)return e;let o=Number(t?.step_order)||0;return Math.max(e,o)},0)+1}function zS({icon:e,title:t}){return(0,o.jsxs)(i.Space,{size:10,align:`center`,children:[(0,o.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,o.jsx)(AS,{strong:!0,className:`v1-section-label`,children:t})]})}function BS(){let[t]=i.Form.useForm(),[n]=i.Form.useForm(),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)({open:!1,typeKey:`module`}),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)(!1),[w,T]=(0,r.useState)(!1),E=(0,s.useNavigate)(),D=NS[v.typeKey],O=(0,r.useMemo)(()=>PS(c),[c]),k=i.Form.useWatch(`module`,t),A=i.Form.useWatch(`flow`,t),j=!!FS(k),M=!!FS(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&l(t)},I=async()=>{h(!0);try{l((await Xp(NS.module.dbName))?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),i.message.error(`Unable to load testing options.`)}finally{h(!1)}},L=(0,r.useCallback)(async e=>{let n=FS(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await em({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(LS(t))}catch(e){console.error(`Unable to load flows:`,e),i.message.error(`Unable to load flows.`)}finally{_(!1)}}},[t]),R=(0,r.useCallback)(async(e,n,r)=>{let a=FS(e),o=FS(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}C(!0);try{t.setFieldsValue({step_order:RS(r,a,o)})}catch(e){console.error(`Unable to load step order:`,e),i.message.error(`Unable to load step order.`)}finally{C(!1)}},[t]);(0,r.useEffect)(()=>{Promise.resolve().then(I)},[]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>L(k))},[L,k]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>R(k,A,u))},[u,R,A,k]);let z=async e=>{let n={module:FS(e.module),flow:FS(e.flow),step_order:Number(e.step_order),description:FS(e.description),keyword:IS(e.keyword),target:FS(e.target),value:FS(e.value),expected:FS(e.expected),tags:e.tags?FS(e.tags):MS.tags,active:Number(e.active)};T(!0);try{await $p(n),i.message.success(`Test case details saved successfully.`),t.resetFields(),d([]),p([])}catch(e){console.error(`Unable to save test case:`,e),i.message.error(`Unable to save test case.`)}finally{T(!1)}},B=(e,n)=>{t.setFieldsValue({[e]:FS(n)})},V=e=>{t.setFieldsValue({module:FS(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:MS.tags,value:void 0,expected:void 0})},H=e=>{t.setFieldsValue({flow:FS(e),step_order:void 0})},U=e=>{let t=NS[e];y({open:!0,typeKey:e}),n.setFieldsValue({name:``,type:t.label})},W=()=>{y(e=>({...e,open:!1})),n.resetFields()},G=async()=>{try{let e=FS((await n.validateFields()).name),r=await Zp({name:e,type:D.dbName});F(v.typeKey,r?.items??[]),t.setFieldsValue({[D.formField]:e}),i.message.success(`${D.label} added successfully.`),W()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),i.message.error(`Unable to add ${D.label.toLowerCase()}.`)}finally{x(!1)}};return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:jS})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>E(`/zinnext-home`),children:`View Table`})})]}),(0,o.jsx)(`div`,{className:`v1-page`,children:(0,o.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,o.jsx)(`div`,{className:`v1-page-header`,children:(0,o.jsxs)(i.Space,{align:`center`,size:10,children:[(0,o.jsx)(a.ProfileOutlined,{className:`v1-outer-icon`}),(0,o.jsx)(`div`,{children:(0,o.jsx)(AS,{strong:!0,style:{fontSize:16},children:`Add Test Case`})})]})}),(0,o.jsx)(Z,{children:(0,o.jsxs)(i.Form,{form:t,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:MS,onFinish:z,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(zS,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,o.jsx)(AS,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsxs)(i.Space.Compact,{style:{width:`100%`},children:[(0,o.jsx)(i.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,loading:m,optionFilterProp:`label`,placeholder:`Select module`,options:O,onChange:V})}),(0,o.jsx)(i.Button,{"aria-label":`Add module`,icon:(0,o.jsx)(a.PlusOutlined,{}),style:{marginTop:30},onClick:()=>U(`module`)})]})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Flow`,name:`flow`,children:(0,o.jsx)(i.AutoComplete,{maxLength:100,allowClear:!0,disabled:N,options:f,placeholder:g?`Loading flows`:`Enter flow`,onChange:H,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,disabled:!0,placeholder:S?`Loading step order`:`Step order`})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Action`,name:`keyword`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,disabled:P,optionFilterProp:`label`,placeholder:`Select action`,options:kS,onChange:e=>t.setFieldsValue({keyword:IS(e)})})})}),(0,o.jsx)(i.Col,{xs:24,children:(0,o.jsx)(i.Form.Item,{label:`Description`,name:`description`,children:(0,o.jsx)(i.Input.TextArea,{rows:3,maxLength:255,disabled:P,placeholder:`Enter description`,showCount:!0,onBlur:e=>B(`description`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Key`,name:`target`,children:(0,o.jsx)(i.Input,{maxLength:255,disabled:P,placeholder:`Enter target`,onBlur:e=>B(`target`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Tags`,name:`tags`,children:(0,o.jsx)(i.Input,{maxLength:200,disabled:P,placeholder:`Enter tags`,prefix:(0,o.jsx)(a.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>B(`tags`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Value`,name:`value`,children:(0,o.jsx)(i.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter value`,onBlur:e=>B(`value`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Expected`,name:`expected`,children:(0,o.jsx)(i.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter expected result`,onBlur:e=>B(`expected`,e.target.value)})})})]})}),(0,o.jsx)(`div`,{className:`v1-form-actions`,children:(0,o.jsx)(i.Form.Item,{children:(0,o.jsxs)(i.Space,{children:[(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,loading:w,disabled:P,children:`Submit`}),(0,o.jsx)(i.Button,{onClick:()=>{t.resetFields(),d([]),p([])},children:`Reset`})]})})})]})}),(0,o.jsx)(i.Modal,{title:`Add ${D.label}`,open:v.open,confirmLoading:b,okText:`Add`,onCancel:W,onOk:()=>{x(!0),G()},destroyOnHidden:!0,children:(0,o.jsxs)(i.Form,{form:n,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,o.jsx)(i.Form.Item,{label:`Name`,name:`name`,children:(0,o.jsx)(i.Input,{maxLength:100,placeholder:`Enter ${D.label.toLowerCase()} name`,onBlur:e=>{n.setFieldsValue({name:FS(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var{Text:VS}=i.Typography,HS=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function US(e=``){return String(e??``).trim()}function WS(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var GS=[{label:`Step`,value:`step_order`,width:70},{label:`Action`,value:`actions`,width:140},{label:`Key`,value:`key`,width:160,ellipsis:!0},{label:`Value`,value:`value`,ellipsis:!0},{label:`Description`,value:`description`,ellipsis:!0},{label:`Scenario`,value:`scenario`,width:110,render:e=>e===1?(0,o.jsx)(i.Tag,{color:`green`,children:`Positive`}):(0,o.jsx)(i.Tag,{color:`red`,children:`Negative`})}],KS={key:!1,value:!1,expected:!1};function qS(e,t){return t?e[t]??KS:KS}function JS(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function YS(){let[n]=i.Form.useForm(),c=(0,s.useNavigate)(),[l]=(0,s.useSearchParams)(),u=l.get(`edit`),d=!!u,f=(0,r.useMemo)(()=>t.s(),[]),[p,m]=(0,r.useState)([]),[h,g]=(0,r.useState)([]),[_,v]=(0,r.useState)([]),[y,b]=(0,r.useState)(kS),[x,S]=(0,r.useState)({}),[C,w]=(0,r.useState)(!1),[T,E]=(0,r.useState)(!1),[D,O]=(0,r.useState)(!1),[k,A]=(0,r.useState)(!1),[j,M]=(0,r.useState)(!1),N=i.Form.useWatch(`module`,n),P=i.Form.useWatch(`submodule`,n),F=i.Form.useWatch(`actions`,n),I=!!N,L=!!P,R=(0,r.useMemo)(()=>qS(x,F),[x,F]),z=(0,r.useMemo)(()=>WS(p,`modulename`),[p]),B=(0,r.useMemo)(()=>WS(h,`submodulename`),[h]),V=(0,r.useMemo)(()=>p.find(e=>e.id===N)?.modulename??``,[p,N]),H=(0,r.useMemo)(()=>h.find(e=>e.id===P)?.submodulename??``,[P,h]),U=(0,r.useCallback)(async()=>{try{let e=await Qp();Array.isArray(e?.options)&&e.options.length>0&&b(e.options),e?.rules&&typeof e.rules==`object`&&S(e.rules)}catch(e){console.error(`Unable to load action field rules:`,e),i.message.error(`Unable to load action validation rules.`)}},[]),W=(0,r.useCallback)(async e=>{if(!e){m([]);return}w(!0);try{m((await om({project:e,activeOnly:!0}))?.items??[])}catch(e){console.error(`Unable to load modules:`,e),i.message.error(`Unable to load modules.`)}finally{w(!1)}},[]),G=(0,r.useCallback)(async(e,t)=>{if(!e||!t){g([]);return}E(!0);try{g((await lm({project:e,module:t,activeOnly:!0}))?.items??[])}catch(e){console.error(`Unable to load submodules:`,e),i.message.error(`Unable to load submodules.`)}finally{E(!1)}},[]),ee=(0,r.useCallback)(async(e,t,r,a=``)=>{if(!e||!t||!r){v([]),n.setFieldsValue({step_order:void 0});return}O(!0);try{let[i,o]=await Promise.all([fm({product_parent_ID:e,module_parent_ID:t,submodule_parent_ID:r,actions:a,limit:1e3}),hm({product_parent_ID:e,module_parent_ID:t,submodule_parent_ID:r})]);v(i?.items??[]),n.setFieldsValue({step_order:o?.step_order??1})}catch(e){console.error(`Unable to load flows:`,e),i.message.error(`Unable to load flows.`)}finally{O(!1)}},[n]),te=(0,r.useCallback)(async(e=``)=>{if(!(!f?.id||!N||!P)){O(!0);try{v((await fm({product_parent_ID:f.id,module_parent_ID:N,submodule_parent_ID:P,actions:e,limit:1e3}))?.items??[])}catch(e){console.error(`Unable to load action flows:`,e),i.message.error(`Unable to load action steps.`)}finally{O(!1)}}},[f?.id,N,P]),K=(0,r.useCallback)(async()=>{if(!(!u||!f?.name)){M(!0);try{let e=await mm(u);await G(f.name,e.module),v((await fm({product_parent_ID:e.product_parent_ID,module_parent_ID:e.module_parent_ID,submodule_parent_ID:e.submodule_parent_ID,limit:1e3}))?.items??[]),n.setFieldsValue({module:e.module_parent_ID,submodule:e.submodule_parent_ID,step_order:e.step_order,actions:e.actions,key:e.key,value:e.value,expected:e.expected,description:e.description,scenario:e.scenario===1,active:Number(e.active)!==0})}catch(e){console.error(`Unable to load test flow:`,e),i.message.error(`Unable to load test flow for edit.`),c(`/viewTestCase`)}finally{M(!1)}}},[u,n,G,c,f?.name]);return(0,r.useEffect)(()=>{if(!f){c(`/select-project`,{replace:!0});return}Promise.resolve().then(async()=>{await U(),await W(f.name),u&&await K()})},[f,c,U,W,u,K]),f?(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:HS})}),(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.ProjectOutlined,{}),(0,o.jsx)(VS,{strong:!0,children:f.name})]})})]}),(0,o.jsx)(`div`,{className:`zt-page`,children:(0,o.jsxs)(i.Form,{form:n,layout:`vertical`,colon:!1,className:`v1-form`,initialValues:{scenario:!0,active:!0},onFinish:async e=>{let t={product_parent_ID:Number(f?.id),module_parent_ID:Number(e.module),submodule_parent_ID:Number(e.submodule),description:US(e.description),actions:US(e.actions),key:US(e.key),value:US(e.value),expected:US(e.expected),scenario:+!!e.scenario,active:+!!e.active};A(!0);try{if(d){await gm(u,{...t,step_order:Number(e.step_order)}),i.message.success(`Test case updated successfully.`),c(`/viewTestCase`);return}await pm(t),i.message.success(`Step saved (#${e.step_order}).`),n.setFieldsValue({actions:void 0,key:void 0,value:void 0,expected:void 0,description:void 0}),await ee(t.product_parent_ID,t.module_parent_ID,t.submodule_parent_ID)}catch(e){console.error(`Unable to save test case:`,e),i.message.error(d?`Unable to update test case.`:`Unable to save step.`)}finally{A(!1)}},autoComplete:`off`,disabled:j,children:[(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:8,className:`zt-section-title`,children:[(0,o.jsx)(`span`,{className:`zt-step-tag`,children:`1`}),(0,o.jsx)(`span`,{children:`Module & Submodule`})]}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],align:`bottom`,children:[(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Module`,name:`module`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,loading:C,placeholder:`Select module`,options:z,onChange:e=>{let t=p.find(t=>t.id===e)?.modulename??``;n.setFieldsValue({module:e,submodule:void 0,step_order:void 0,actions:void 0,key:void 0,value:void 0,expected:void 0}),JS(n,[`actions`,`key`,`value`,`expected`]),g([]),v([]),G(f?.name,t)}})})}),(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Submodule`,name:`submodule`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,disabled:!I,loading:T,placeholder:I?`Select submodule`:`Select module first`,options:B,onChange:e=>{n.setFieldsValue({submodule:e,actions:void 0,key:void 0,value:void 0,expected:void 0}),JS(n,[`actions`,`key`,`value`,`expected`]),ee(f?.id,N,e)}})})}),(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Scenario`,name:`scenario`,valuePropName:`checked`,children:(0,o.jsx)(i.Switch,{disabled:!L,checkedChildren:`Positive`,unCheckedChildren:`Negative`})})}),(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Active`,name:`active`,valuePropName:`checked`,children:(0,o.jsx)(i.Switch,{checkedChildren:`Active`,unCheckedChildren:`Inactive`})})})]})}),L&&(0,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:8,className:`zt-section-title`,children:[(0,o.jsx)(`span`,{className:`zt-step-tag`,children:`2`}),(0,o.jsx)(a.FileTextOutlined,{}),(0,o.jsx)(`span`,{children:`Step Details`})]}),extra:(0,o.jsxs)(VS,{type:`secondary`,children:[V,` / `,H]}),children:[(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Step Order`,name:`step_order`,children:(0,o.jsx)(i.Input,{disabled:!0,placeholder:D?`Loading…`:`Auto`})})}),(0,o.jsx)(i.Col,{xs:24,md:18,children:(0,o.jsx)(i.Form.Item,{label:`Action`,name:`actions`,rules:[{required:!0,message:`Mandatory Field`}],children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,placeholder:`Select action`,options:y,onChange:e=>{let t=qS(x,e);n.setFieldsValue({actions:e,key:t.key?n.getFieldValue(`key`):void 0,value:t.value?n.getFieldValue(`value`):void 0,expected:t.expected?n.getFieldValue(`expected`):void 0}),JS(n,[`key`,`value`,`expected`]),te(e||``)}})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Key`,name:`key`,rules:[{required:R.key,message:`Key is required for this action`}],children:(0,o.jsx)(i.Input,{maxLength:255,disabled:F&&!R.key,placeholder:F?R.key?`Required — Enter selector / locator`:`Not needed for this action`:`Select an action first`})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Value`,name:`value`,rules:[{required:R.value,message:`Value is required for this action`}],children:(0,o.jsx)(i.Input.TextArea,{rows:1,autoSize:{minRows:1,maxRows:4},disabled:F&&!R.value,placeholder:F?R.value?`Required — Enter value`:`Not needed for this action`:`Select an action first`})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:R.expected,message:`Expected result is required for this action`}],children:(0,o.jsx)(i.Input.TextArea,{rows:2,disabled:F&&!R.expected,placeholder:F?R.expected?`Required — Enter expected result`:`Not needed for this action`:`Select an action first`})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Description`,name:`description`,children:(0,o.jsx)(i.Input.TextArea,{rows:2,maxLength:255,showCount:!0,placeholder:`Enter description`})})})]}),(0,o.jsxs)(i.Space,{className:`zt-actions`,children:[(0,o.jsx)(i.Button,{onClick:()=>{if(d){c(`/viewTestCase`);return}n.resetFields(),g([]),v([]),E(!1),O(!1)},children:`Cancel`}),(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,loading:k||j,children:d?`Update Test Case`:`Save & Continue`})]})]},`${N}-${P}`),L&&(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.TableOutlined,{}),(0,o.jsx)(`span`,{children:`Added Steps`})]}),extra:(0,o.jsx)(i.Tag,{children:F?`${_.length} ${F} step(s)`:`${_.length} step(s)`}),children:(0,o.jsx)(du,{listName:`Added Steps`,loading:D,fields:GS,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:XS}=i.Typography,ZS=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function QS(){let n=(0,s.useNavigate)(),c=(0,r.useMemo)(()=>t.s(),[]),[l,u]=(0,r.useState)([]),[d,f]=(0,r.useState)({}),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)(``),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(1),[C,w]=(0,r.useState)(10),T=(0,r.useCallback)(async e=>{if(!e){u([]);return}m(!0);try{let[t,n]=await Promise.all([om({project:e}),lm({project:e})]);u(t?.items??[]);let r={};(n?.items??[]).forEach(e=>{let t=e.modulename;r[t]=(r[t]??0)+1}),f(r)}catch(e){console.error(e),i.message.error(`Unable to load modules.`)}finally{m(!1)}},[]);(0,r.useEffect)(()=>{if(!c){n(`/select-project`,{replace:!0});return}Promise.resolve().then(()=>T(c.name))},[c,n,T]);let E=async(e,t)=>{try{await cm(e.id,+!!t),u(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),i.message.success(`Module ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),i.message.error(`Unable to update module status.`)}},D=async()=>{let e=_.trim();if(!e){i.message.warning(`Enter a module name.`);return}b(!0);try{await sm({project:c.name,modulename:e}),i.message.success(`Module added.`),g(!1),v(``),S(1),T(c.name)}catch(e){console.error(e),i.message.error(`Unable to add module (maybe it already exists).`)}finally{b(!1)}},O=e=>{n(`/test-cases/zinnext/submodules?module=${encodeURIComponent(e.modulename)}`)};return c?(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:ZS})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>n(`/addTestCase`),children:`Back to Form`})})]}),(0,o.jsxs)(`div`,{className:`zt-page`,children:[(0,o.jsx)(i.Card,{className:`v1-card zt-bar`,children:(0,o.jsxs)(i.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.ProjectOutlined,{}),(0,o.jsx)(`span`,{children:`Project:`}),(0,o.jsx)(XS,{strong:!0,children:c.name})]})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Module`})})]})}),(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.AppstoreOutlined,{}),(0,o.jsx)(`span`,{children:`Modules`})]}),children:(0,o.jsx)(du,{listName:`Modules`,loading:p,fields:[{label:`Module`,value:`modulename`},{label:`Submodules`,value:`submoduleCount`,width:140,render:(e,t)=>(0,o.jsxs)(i.Button,{type:`link`,className:`zt-count-link`,onClick:()=>O(t),children:[d[t.modulename]??0,` submodule(s)`]})},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,o.jsx)(i.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:l,current:x,pageSize:C,total:l.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,o.jsx)(i.Modal,{title:`Add Module`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,o.jsxs)(i.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,o.jsxs)(XS,{type:`secondary`,children:[`Project: `,(0,o.jsx)(`b`,{children:c.name})]}),(0,o.jsx)(i.Input,{placeholder:`Enter module name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]}):null}var{Text:$S}=i.Typography,eC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function tC(){let n=(0,s.useNavigate)(),[c]=(0,s.useSearchParams)(),l=(0,r.useMemo)(()=>t.s(),[]),u=c.get(`module`)??``,[d,f]=(0,r.useState)([]),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)(``),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(1),[C,w]=(0,r.useState)(10),T=(0,r.useCallback)(async(e,t)=>{if(!e||!t){f([]);return}m(!0);try{f((await lm({project:e,module:t}))?.items??[])}catch(e){console.error(e),i.message.error(`Unable to load submodules.`)}finally{m(!1)}},[]);(0,r.useEffect)(()=>{if(!l){n(`/select-project`,{replace:!0});return}if(!u){n(`/manageModules`,{replace:!0});return}Promise.resolve().then(()=>T(l.name,u))},[l,u,n,T]);let E=async(e,t)=>{try{await dm(e.id,+!!t),f(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),i.message.success(`Submodule ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),i.message.error(`Unable to update submodule status.`)}},D=async()=>{let e=_.trim();if(!e){i.message.warning(`Enter a submodule name.`);return}b(!0);try{await um({project:l.name,modulename:u,submodulename:e}),i.message.success(`Submodule added.`),g(!1),v(``),S(1),T(l.name,u)}catch(e){console.error(e),i.message.error(`Unable to add submodule (maybe it already exists).`)}finally{b(!1)}};return!l||!u?null:(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:eC})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>n(`/manageModules`),children:`Back to Modules`})})]}),(0,o.jsxs)(`div`,{className:`zt-page`,children:[(0,o.jsx)(i.Card,{className:`v1-card zt-bar`,children:(0,o.jsxs)(i.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space,{size:16,wrap:!0,className:`zt-section-title`,children:[(0,o.jsxs)(i.Space,{size:6,children:[(0,o.jsx)(a.ProjectOutlined,{}),(0,o.jsx)(`span`,{children:`Project:`}),(0,o.jsx)($S,{strong:!0,children:l.name})]}),(0,o.jsxs)(i.Space,{size:6,children:[(0,o.jsx)(a.AppstoreOutlined,{}),(0,o.jsx)(`span`,{children:`Module:`}),(0,o.jsx)($S,{strong:!0,children:u})]})]})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Submodule`})})]})}),(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.AppstoreOutlined,{}),(0,o.jsx)(`span`,{children:`Submodules`})]}),children:(0,o.jsx)(du,{listName:`Submodules`,loading:p,fields:[{label:`Submodule`,value:`submodulename`},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,o.jsx)(i.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:d,current:x,pageSize:C,total:d.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,o.jsx)(i.Modal,{title:`Add Submodule`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,o.jsxs)(i.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,o.jsxs)($S,{type:`secondary`,children:[`Project: `,(0,o.jsx)(`b`,{children:l.name}),` \xA0|\xA0 Module: `,(0,o.jsx)(`b`,{children:u})]}),(0,o.jsx)(i.Input,{placeholder:`Enter submodule name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]})}var{Text:nC}=i.Typography,rC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function iC(){let n=(0,s.useNavigate)(),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)(0),[f,p]=(0,r.useState)(!1),m=(0,r.useMemo)(()=>t.s(),[]),[h,g]=(0,r.useState)(``),[_,v]=(0,r.useState)(1),[y,b]=(0,r.useState)(20),[x,S]=(0,r.useState)(null),C=(0,r.useCallback)(async(e={})=>{p(!0);try{let t=await fm({product_parent_ID:e.project??m?.id??``,search:e.search??h??``,limit:e.pageSize??y,offset:((e.page??_)-1)*(e.pageSize??y)});l(t?.items??[]),d(t?.total??0)}catch(e){console.error(e),i.message.error(`Unable to load test flows.`)}finally{p(!1)}},[m?.id,h,_,y]),w=e=>{i.Modal.confirm({title:`Delete Test Case`,icon:(0,o.jsx)(a.ExclamationCircleOutlined,{}),content:`Are you sure you want to delete this test case?`,okText:`Delete`,okButtonProps:{danger:!0,loading:x===e.id},cancelText:`Cancel`,async onOk(){S(e.id);try{await _m(e.id),i.message.success(`Test case deleted successfully.`);let t=c.length===1&&_>1?_-1:_;v(t),await C({page:t})}catch(e){throw console.error(`Unable to delete test flow:`,e),i.message.error(`Unable to delete test case.`),e}finally{S(null)}}})};return(0,r.useEffect)(()=>{Promise.resolve().then(()=>{if(!m?.id){n(`/select-project`,{replace:!0});return}C({page:1})})},[]),(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:rC})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>n(`/addTestCase`),children:`Back to Form`})})]}),(0,o.jsx)(`div`,{className:`zt-page zt-page-wide`,children:(0,o.jsxs)(i.Card,{className:`v1-card`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.TableOutlined,{}),(0,o.jsx)(`span`,{children:`Test Flows`})]}),extra:(0,o.jsxs)(nC,{type:`secondary`,children:[u,` row(s)`]}),children:[(0,o.jsxs)(i.Space,{wrap:!0,className:`zt-toolbar`,children:[(0,o.jsx)(i.Input.Search,{allowClear:!0,className:`zt-search-filter`,placeholder:`Search module / key / description`,value:h,onChange:e=>g(e.target.value),onSearch:()=>{v(1),C({page:1})}}),(0,o.jsx)(i.Button,{icon:(0,o.jsx)(a.ReloadOutlined,{}),onClick:()=>C(),children:`Refresh`})]}),(0,o.jsx)(du,{listName:`Test Flows`,loading:f,fields:[{label:`Actions`,value:`rowActions`,width:112,fixed:`left`,sorter:!1,render:(e,t)=>(0,o.jsxs)(i.Space,{size:4,className:`zt-row-actions`,children:[(0,o.jsx)(i.Tooltip,{title:`Edit`,children:(0,o.jsx)(i.Button,{type:`text`,size:`small`,icon:(0,o.jsx)(a.EditOutlined,{}),onClick:()=>n(`/addTestCase?edit=${t.id}`)})}),(0,o.jsx)(i.Tooltip,{title:`Delete`,children:(0,o.jsx)(i.Button,{danger:!0,type:`text`,size:`small`,icon:(0,o.jsx)(a.DeleteOutlined,{}),loading:x===t.id,onClick:()=>w(t)})})]})},{label:`ID`,value:`id`,width:70,fixed:`left`},{label:`Project`,value:`project`,width:130},{label:`Module`,value:`module`,width:130},{label:`Submodule`,value:`submodule`,width:140},{label:`Step`,value:`step_order`,width:70},{label:`Action`,value:`actions`,width:140},{label:`Key`,value:`key`,width:160,ellipsis:!0},{label:`Value`,value:`value`,width:200,ellipsis:!0},{label:`Expected`,value:`expected`,width:180,ellipsis:!0},{label:`Description`,value:`description`,width:180,ellipsis:!0},{label:`Scenario`,value:`scenario`,width:110,render:e=>e===1?(0,o.jsx)(i.Tag,{color:`green`,children:`Positive`}):(0,o.jsx)(i.Tag,{color:`red`,children:`Negative`})},{label:`Active`,value:`active`,width:90,render:e=>e===1?(0,o.jsx)(i.Tag,{color:`blue`,children:`Active`}):(0,o.jsx)(i.Tag,{children:`Inactive`})}],dataSource:c,current:_,pageSize:y,total:u,onPageChange:e=>{v(e),C({page:e})},onPageSizeChange:e=>{v(1),b(e),C({page:1,pageSize:e})},rowSelection:!1,className:`zt-list-plain`})]})})]})}var aC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function oC(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:aC}),(0,o.jsx)(ha,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:sC}=i.Typography,cC=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],lC={tags:`regression`,active:1},uC={module:{dbName:`Modules`,formField:`module`,label:`Module`}},dC={key:!1,value:!1,expected:!1};function fC(e,t){return t?e[t]??dC:dC}function pC(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function mC(e=[]){return e.map(e=>({value:e,label:e}))}function hC(e=``){return String(e??``).trim()}function gC(e=[]){let t=new Map;return e.forEach(e=>{let n=hC(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function _C(e=[],t,n){let r=hC(t).toLowerCase(),i=hC(n).toLowerCase();return e.reduce((e,t)=>{let n=hC(t?.module).toLowerCase(),a=hC(t?.flow).toLowerCase();if(n!==r||a!==i)return e;let o=Number(t?.step_order)||0;return Math.max(e,o)},0)+1}function vC({icon:e,title:t}){return(0,o.jsxs)(i.Space,{size:10,align:`center`,children:[(0,o.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,o.jsx)(sC,{strong:!0,className:`v1-section-label`,children:t})]})}function yC(){let[t]=i.Form.useForm(),[n]=i.Form.useForm(),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)([]),[m,h]=(0,r.useState)(kS),[g,_]=(0,r.useState)({}),[v,y]=(0,r.useState)(!1),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)({open:!1,typeKey:`module`}),[w,T]=(0,r.useState)(!1),[E,D]=(0,r.useState)(!1),[O,k]=(0,r.useState)(!1),A=(0,s.useNavigate)(),j=uC[S.typeKey],M=(0,r.useMemo)(()=>mC(c),[c]),N=i.Form.useWatch(`module`,t),P=i.Form.useWatch(`flow`,t),F=i.Form.useWatch(`keyword`,t),I=!!hC(N),L=!!hC(P),R=!I,z=!I||!L,B=(0,r.useMemo)(()=>fC(g,F),[g,F]),V=(e,t=[])=>{e===`module`&&l(t)},H=async()=>{y(!0);try{l((await Xp(uC.module.dbName))?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),i.message.error(`Unable to load testing options.`)}finally{y(!1)}},U=async()=>{try{let e=await Qp();Array.isArray(e?.options)&&e.options.length>0&&h(e.options),e?.rules&&typeof e.rules==`object`&&_(e.rules)}catch(e){console.error(`Unable to load action field rules:`,e),i.message.error(`Unable to load action validation rules.`)}},W=(0,r.useCallback)(async e=>{let n=hC(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await im({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(gC(t))}catch(e){console.error(`Unable to load flows:`,e),i.message.error(`Unable to load flows.`)}finally{x(!1)}}},[t]),G=(0,r.useCallback)(async(e,n,r)=>{let a=hC(e),o=hC(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}D(!0);try{t.setFieldsValue({step_order:_C(r,a,o)})}catch(e){console.error(`Unable to load step order:`,e),i.message.error(`Unable to load step order.`)}finally{D(!1)}},[t]);(0,r.useEffect)(()=>{Promise.resolve().then(async()=>{await Promise.all([H(),U()])})},[]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>W(N))},[W,N]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>G(N,P,u))},[u,G,P,N]);let ee=async e=>{let n={module:hC(e.module),flow:hC(e.flow),step_order:Number(e.step_order),description:hC(e.description),keyword:hC(e.keyword),target:hC(e.target),value:hC(e.value),expected:hC(e.expected),tags:e.tags?hC(e.tags):lC.tags,active:Number(e.active)};k(!0);try{await rm(n),i.message.success(`LMS case details saved successfully.`),t.resetFields(),d([]),p([])}catch(e){console.error(`Unable to save LMS case:`,e),i.message.error(`Unable to save LMS case.`)}finally{k(!1)}},te=(e,n)=>{t.setFieldsValue({[e]:hC(n)})},K=e=>{t.setFieldsValue({module:hC(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:lC.tags,value:void 0,expected:void 0}),pC(t,[`keyword`,`target`,`value`,`expected`])},ne=e=>{t.setFieldsValue({flow:hC(e),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),pC(t,[`keyword`,`target`,`value`,`expected`])},re=e=>{let n=fC(g,e);t.setFieldsValue({keyword:hC(e),target:n.key?t.getFieldValue(`target`):void 0,value:n.value?t.getFieldValue(`value`):void 0,expected:n.expected?t.getFieldValue(`expected`):void 0}),pC(t,[`target`,`value`,`expected`])},q=e=>{let t=uC[e];C({open:!0,typeKey:e}),n.setFieldsValue({name:``,type:t.label})},J=()=>{C(e=>({...e,open:!1})),n.resetFields()},ie=async()=>{try{let e=hC((await n.validateFields()).name),r=await Zp({name:e,type:j.dbName});V(S.typeKey,r?.items??[]),t.setFieldsValue({[j.formField]:e}),i.message.success(`${j.label} added successfully.`),J()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),i.message.error(`Unable to add ${j.label.toLowerCase()}.`)}finally{T(!1)}};return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:cC})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>A(`/lms-home`),children:`View Table`})})]}),(0,o.jsx)(`div`,{className:`v1-page`,children:(0,o.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,o.jsx)(`div`,{className:`v1-page-header`,children:(0,o.jsxs)(i.Space,{align:`center`,size:10,children:[(0,o.jsx)(a.ProfileOutlined,{className:`v1-outer-icon`}),(0,o.jsx)(`div`,{children:(0,o.jsx)(sC,{strong:!0,style:{fontSize:16},children:`Add LMS Case`})})]})}),(0,o.jsx)(Z,{children:(0,o.jsxs)(i.Form,{form:t,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:lC,onFinish:ee,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(vC,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,o.jsx)(sC,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsxs)(i.Space.Compact,{style:{width:`100%`},children:[(0,o.jsx)(i.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,loading:v,optionFilterProp:`label`,placeholder:`Select module`,options:M,onChange:K})}),(0,o.jsx)(i.Button,{"aria-label":`Add module`,icon:(0,o.jsx)(a.PlusOutlined,{}),style:{marginTop:30},onClick:()=>q(`module`)})]})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Flow`,name:`flow`,children:(0,o.jsx)(i.AutoComplete,{maxLength:100,allowClear:!0,disabled:R,options:f,placeholder:b?`Loading flows`:`Enter flow`,onChange:ne,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,disabled:!0,placeholder:E?`Loading step order`:`Step order`})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Action`,name:`keyword`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,disabled:z,optionFilterProp:`label`,placeholder:`Select action`,options:m,onChange:re})})}),(0,o.jsx)(i.Col,{xs:24,children:(0,o.jsx)(i.Form.Item,{label:`Description`,name:`description`,children:(0,o.jsx)(i.Input.TextArea,{rows:3,maxLength:255,disabled:z,placeholder:`Enter description`,showCount:!0,onBlur:e=>te(`description`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Key`,name:`target`,rules:[{required:B.key,message:`Key is required for this action`}],children:(0,o.jsx)(i.Input,{maxLength:255,disabled:z||!!F&&!B.key,placeholder:z?`Select module and flow first`:F?B.key?`Required — Enter selector / locator`:`Not needed for this action`:`Select an action first`,onBlur:e=>te(`target`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Tags`,name:`tags`,children:(0,o.jsx)(i.Input,{maxLength:200,disabled:z,placeholder:`Enter tags`,prefix:(0,o.jsx)(a.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>te(`tags`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Value`,name:`value`,rules:[{required:B.value,message:`Value is required for this action`}],children:(0,o.jsx)(i.Input.TextArea,{rows:4,disabled:z||!!F&&!B.value,placeholder:z?`Select module and flow first`:F?B.value?`Required — Enter value`:`Not needed for this action`:`Select an action first`,onBlur:e=>te(`value`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:B.expected,message:`Expected result is required for this action`}],children:(0,o.jsx)(i.Input.TextArea,{rows:4,disabled:z||!!F&&!B.expected,placeholder:z?`Select module and flow first`:F?B.expected?`Required — Enter expected result`:`Not needed for this action`:`Select an action first`,onBlur:e=>te(`expected`,e.target.value)})})})]})}),(0,o.jsx)(`div`,{className:`v1-form-actions`,children:(0,o.jsx)(i.Form.Item,{children:(0,o.jsxs)(i.Space,{children:[(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,loading:O,disabled:z,children:`Submit`}),(0,o.jsx)(i.Button,{onClick:()=>{t.resetFields(),d([]),p([])},children:`Reset`})]})})})]})}),(0,o.jsx)(i.Modal,{title:`Add ${j.label}`,open:S.open,confirmLoading:w,okText:`Add`,onCancel:J,onOk:()=>{T(!0),ie()},destroyOnHidden:!0,children:(0,o.jsxs)(i.Form,{form:n,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,o.jsx)(i.Form.Item,{label:`Name`,name:`name`,children:(0,o.jsx)(i.Input,{maxLength:100,placeholder:`Enter ${j.label.toLowerCase()} name`,onBlur:e=>{n.setFieldsValue({name:hC(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var bC=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function xC(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:bC}),(0,o.jsx)(ha,{moduleName:`lms-flows`,rowKey:`id`})]})}var SC=e=>e?.data??e;function CC(e){return Array.isArray(e)&&e.every(e=>e&&typeof e==`object`&&`Key`in e)?e.reduce((e,{Key:t,Value:n})=>(e[t]=n,e),{}):e}function wC(e){return e?Array.isArray(e.data)?e.data.map(CC):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(CC):Array.isArray(e)?e.map(CC):[]:[]}async function TC(e=1,n=10){let r=await t.i(t.v,`/workflow/list/all?page=${e}&limit=${n}`),i=SC(r),a=Array.isArray(i)?i:i?.data??[];return{items:a,total:Number(r?.total??i?.total)||a.length,page:e,limit:n}}async function EC(e=100){let t=await TC(1,e),n=[...t.items],r=t.total,i=2;for(;n.length<r;){let t=await TC(i,e);if(!t.items.length)break;n.push(...t.items),i+=1}return{items:n,total:Math.max(r,n.length)}}async function DC(e,n){let r=SC(await t.i(t.v,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function OC(e,n){if(!e||!n)return null;try{let r=SC(await t.i(t.v,`/module-data-list?${new URLSearchParams({module:e,limit:`1`,offset:`0`,scope:`allJobs`,filters:JSON.stringify([{field:`_id`,op:`in`,values:[String(n)],operator:`and`}])})}`));if(Array.isArray(r))return r[0]??null;if(r?.data&&Array.isArray(r.data))return r.data[0]??null;let i=r?.rows??r?.records??r?.items??r?.list;return Array.isArray(i)?i[0]??null:r??null}catch(t){return console.error(`[getModuleRecordById] failed: ${e}/${n}`,t),null}}var kC=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function AC(e=kC){return function(t){if(!t||typeof t!=`object`)return``;for(let n of e){let e=t[n];if(e!=null&&e!==``)return String(e)}return``}}function jC(e,t=kC){if(!e||typeof e!=`object`)return[];let n=[];for(let r of t){let t=e[r];t!=null&&t!==``&&n.push(String(t))}return n}var MC=AC();function NC(e){return typeof e==`function`?e:typeof e==`string`?AC([e]):Array.isArray(e)?AC(e):MC}function PC(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:t.id??e.id??n}}function FC(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var IC=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function LC(e){let t=e?.data??e,n={};for(let r of IC){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var RC=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function zC(e,t,n){let r=(Array.isArray(n)?n:[n]).map(RC).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(RC(e?.value))||r.includes(RC(e?.label))):-1;if(i===-1)return[...e,...t];let a=Number(e[i]?.order),o=Number.isFinite(a)?t.map((e,n)=>e.order==null||e.order===``?{...e,order:a+(n+1)/(t.length+1)}:e):t;return[...e.slice(0,i+1),...o,...e.slice(i+1)]}var BC=(e,t)=>Qn(e,t).rows,VC=(e,t)=>{let{rows:n,total:r}=Qn(e,t);return{rows:n,total:r}};function HC({fetchPrimaryPage:e,extractPrimaryPage:t=VC,fetchSecondaryByKeys:n,fetchPrimary:r,extractPrimaryRows:i=BC,fetchSecondary:a,extractSecondaryRows:o=BC,fetchSecondaryById:s,primaryKey:c,secondaryKey:l,mergeRow:u=PC,secondaryFetchLimit:d=200,extraFields:f=[],extraFieldsAfter:p}){let m=NC(c),h=typeof l==`function`?e=>{let t=l(e);return t?[String(t)]:[]}:e=>jC(e,typeof l==`string`?[l]:Array.isArray(l)?l:kC),g=0;function _(e){let t=new Map;return e.forEach(e=>{for(let n of h(e))t.has(n)||t.set(n,e)}),t}async function v(e,t){if(!s||!t)return null;try{let n=await s(e,t);return n&&h(n).includes(String(t))?n:null}catch(e){return console.error(`[mergedListApi] per-id secondary lookup failed for "${t}"`,e),null}}async function y(e,t,n,r){return Promise.all(e.map(async e=>{let i=m(e);return u(e,t.get(i)??(r()?null:await v(n,i)),i)}))}function b(e,t,n){let r={};for(let e of n){if(!e)continue;let t=LC(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return f.length&&(r.fields=zC(r.fields??[],f,p)),FC(e,t,r)}async function x(r,i,a,s,c){let l=await e(r,i,a,s),u=t(l,r)??{},d=Array.isArray(u.rows)?u.rows:[],f=Number.isFinite(Number(u.total))?Number(u.total):d.length,p=[...new Set(d.map(m).filter(Boolean))],h=null,g=[];if(p.length&&n)try{h=await n(r,p,s),g=o(h,r)??[]}catch(e){console.error(`[mergedListApi] secondary fetch failed — rendering unenriched page`,e),h=null}return b(await y(d,_(g),r,c),f,[l,h])}async function S(e,t,n,s,c){let[l,u]=await Promise.allSettled([r(e,t,n,s),a?a(e,d,0,s):Promise.resolve(null)]);if(l.status===`rejected`)throw l.reason;let f=u.status===`fulfilled`?u.value:null;u.status===`rejected`&&console.error(`[mergedListApi] secondary fetch failed — rendering unenriched page`,u.reason);let p=i(l.value,e)??[],m=_(f?o(f,e)??[]:[]),h=p.length;return b(await y(p.slice(n,n+t),m,e,c),h,[l.value,f])}return async function(t,n=10,r=0,i={}){let a=++g,o=()=>a!==g;return e?x(t,n,r,i,o):S(t,n,r,i,o)}}function UC(e,t,n={}){return HC({fetchPrimary:()=>DC(e,t),extractPrimaryRows:wC,fetchSecondary:Ft,fetchSecondaryById:OC,secondaryFetchLimit:n.moduleFetchLimit??200})}function WC(e){let t=String(e??``).trim().split(/[^a-zA-Z0-9]+/).filter(Boolean);return t.length?`${t.map((e,t)=>t===0?e.toLowerCase():e[0].toUpperCase()+e.slice(1).toLowerCase()).join(``)}Count`:``}function GC(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=WC(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var KC=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function qC({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=PC(n,r,i),o=KC(a);return o!=null&&(console.log(`mergeJobWorkflowRow`,i,a?.[e],o),a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function JC(e={}){let t=qC(),n=HC({primaryKey:`_id`,secondaryKey:`entityId`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:Ft,fetchSecondaryByKeys:()=>EC(),extractSecondaryRows:e=>(e?.items??[]).map(GC),mergeRow:(e,n,r)=>{let i=t(e,n,r);return n?._id&&(i.workflowId=n._id),i}});return async function(e,t,r,i){return await n(e,t,r,i)}}async function YC(e,t=10,n=0,r={},i={}){return Qn(await JC(i)(e,t,n,r),e)}async function XC(e,t,n,r=10,i=0,a={}){return Qn(await UC(e,t)(n,r,i,a),n)}var ZC=mx,QC=bm(dS),$C=bm(pS),ew=bm(OS),tw=bm(BS),nw=bm(YS),rw=bm(QS),iw=bm(tC),aw=bm(iC),ow=bm(oC),sw=bm(yC),cw=bm(xC);exports.ADMIN_API_URL=t.h,exports.ADMIN_APP_ID=t.g,exports.APP_ID=t._,exports.AUTH_URL=t.v,exports.ActivityTab=Jo,exports.AddBatchCandidatePopup=Zb,exports.AddFormV1=No,exports.AdminDashboard=mx,exports.AdminDashboardContent=Ev,exports.AdminPage=ZC,exports.AppAlert=Po,exports.AppButton=Tr,exports.AppShell=Up,exports.ApprovalActionBar=Yd,exports.AssigneeAvatars=Yo,exports.AuthGuard=Vp,exports.BILLING_STATUS_FLOW=ju,exports.Breadcrumb=e.t,exports.BulkUploadPage=ew,exports.CANDIDATES_URL=t.y,exports.CONTRACT_C2C=mf,exports.CONTRACT_W2=pf,exports.CalendarCard=E,exports.CoreThemeAdminApp=Av,exports.CoreThemeAdminRoutes=kv,exports.CustomPagination=ge,exports.DayLogModal=Hd,exports.DescriptionBlock=cs,exports.DetailHeaderCard=Wc,exports.DetailViewPage=Zc,exports.DetailViewV1=Ys,exports.DocumentViewer=e.On,exports.DynamicCards=at,exports.DynamicPopup=ib,exports.DynamicPopupRoute=ex,exports.DynamicTabs=A,exports.EditFormV1=Ul,exports.FINANCE_APPROVAL_CONFIG=cf,exports.FINANCE_TYPE_CFO=rf,exports.FINANCE_TYPE_ONBOARDING_MANAGER=nf,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=of,exports.FINANCE_TYPE_SUBMISSION_MANAGER=tf,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=af,exports.FinanceApprovalPanel=Pf,exports.FinanceAvatar=md,exports.FinanceBadge=vd,exports.FinanceDayCell=Zd,exports.FinanceDetailHeader=wd,exports.FinanceDivider=id,exports.FinanceEmployeeCell=hd,exports.FinanceEmptyState=td,exports.FinanceEquation=ad,exports.FinanceHistoryTimeline=ld,exports.FinanceHoursGrid=ed,exports.FinanceKpiRow=$u,exports.FinanceLine=rd,exports.FinanceListToolbar=dd,exports.FinanceMarginBadge=yd,exports.FinanceMoneyCell=_d,exports.FinanceRecordsTable=Sd,exports.FinanceRowChevron=bd,exports.FinanceSection=nd,exports.FinanceStatusPill=Qu,exports.FinanceTextCell=gd,exports.FinanceTimesheetAnalysis=$d,exports.FinanceWorkflowSteps=od,exports.Header=pp,exports.JOBS_URL=t.b,exports.LegacyAdminPage=QC,exports.ListView=ha,exports.LmsHomePage=cw,exports.LmsTestForm=sw,exports.Login=Wp,exports.MailPopup=Rv,exports.ManageModules=rw,exports.ManageSubmodules=iw,exports.ModuleRowActions=Ql,exports.NotesPanel=Jd,exports.PAYROLL_STATUS_FLOW=Mu,exports.POPUP_CONFIGS=Wb,exports.ParamCardView=au,exports.ParamListView=du,exports.PreviewPopup=gy,exports.ProjectSelect=ym,exports.ProofUploadPreview=qd,exports.QuickLogBar=Gd,exports.QuickLogSelectionBar=Ud,exports.RejectionReasonModal=Wd,exports.SUBMISSIONS_URL=t.x,exports.Sidebar=Lp,exports.StatusBadge=pu,exports.StickyNotesFullPage=$C,exports.StylishDynamicTabs=hu,exports.TemplateEditor=bu,exports.TestForm=tw,exports.TestingHomePage=ow,exports.TimesheetDayCell=Ld,exports.TimesheetSummaryPanel=Kd,exports.TipTapEditor=e.kn,exports.UserForm=px,exports.VendorShareDrawer=ix,exports.ViewSummaryWidget=wr,exports.WizardPopup=Sy,exports.ZinnextTableView=aw,exports.ZinnextTestForm=nw,exports.approveSubmission=ie,exports.buildCsv=Ku,exports.buildDailyRows=Bu,exports.buildDayGradient=Fd,exports.buildRateHistoryEntries=Df,exports.buildWeeklyRollup=Uu,exports.clearSelectedProject=t.n,exports.colors=e.Mn,exports.computeFinance=Tf,exports.computeMarginBand=Wu,exports.configureCoreTheme=t.S,exports.createAllWorkflowsListFetcher=JC,exports.createWorkflowStageListFetcher=UC,exports.deriveDayStats=zu,exports.downloadCsv=Xu,exports.findEmployerRow=yf,exports.flattenGroups=vf,exports.formatFinanceMoney=Of,exports.formatHours=Cu,exports.formatMoney=Su,exports.formatRate=wu,exports.getActivity=e.Z,exports.getAllWorkflowsModuleList=YC,exports.getApprovalDate=Ou,exports.getBillingActionStates=Nu,exports.getCurrentRoleName=t.o,exports.getFieldLabel=Ju,exports.getFinanceApprovalConfig=uf,exports.getFormGroupsRaw=zf,exports.getModuleConfig=he,exports.getModuleDataDetail=e.$,exports.getPayrollActionStates=Pu,exports.getSelectedProject=t.s,exports.getStoredToken=t.c,exports.getStoredUser=t.l,exports.getUserRoles=t.u,exports.getVMSApprove=ae,exports.getValueStyle=Yu,exports.getWorkflowStageModuleList=XC,exports.getWorkflowSteps=Fu,exports.humanizeEvent=Du,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Na}}),exports.indexFieldConfig=qu,exports.initialsOf=Tu,exports.isTester=t.d,exports.logout=t.p,exports.marginIncludesReferral=ff,exports.matchLocationTax=wf,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return el}}),exports.normalizeContract=xf,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Xo}}),exports.rejectSubmission=oe,exports.resolveActivityMeta=Go,exports.resolveAndCompute=Ef,exports.resolveFinanceInputs=Cf,exports.resolveMergeKey=MC,exports.resolveRejectionReason=df,exports.resolveSubmissionFinance=Bf,exports.setSelectedProject=t.m,exports.stageCountKey=WC,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Gp}}),exports.useDropdownFields=Zt,exports.useDropdownValues=Er,exports.useEditForm=Vf,exports.useFieldConfig=Qt,exports.useFilterFields=$t,exports.useMenuPermission=on,exports.useModuleActions=Gl,exports.useRecordRefresh=Jc,exports.withAdminAppId=t.C,exports.withAppId=t.w,exports.withAuthGuard=bm;
9
+ `))}function Zv(e){let t=e.match(/^([A-Za-z][A-Za-z&/ ]{1,28}?)\s*:\s*(\S.+)$/);if(!t)return null;let n=t[1].trim(),r=t[2].trim();return n.split(/\s+/).length>3||r.length>60?null:{fieldKey:n.toLowerCase().replace(/\s+/g,`-`),fieldLabel:Kv(n),value:r}}function Qv(e){let t=e.toLowerCase().replace(/[\s:.\-–—]+$/,``).trim();return Hv.has(t)?Uv.test(t)?`education`:Wv.test(t)?`keySkills`:`overview`:null}function $v(e){let t=[],n={overview:[],keySkills:[],education:[]},r=`overview`;return e.forEach(e=>{let i=Qv(e);if(i){r=i;return}if(r===`overview`){let n=Zv(e);if(n){t.push(n);return}}n[r].push(e)}),{meta:t,overview:qv(n.overview),keySkills:qv(n.keySkills),education:qv(n.education)}}function ey(e){let t=[...Vv].sort((e,t)=>t.length-e.length),n=RegExp(`\\b(${t.map(Gv).join(`|`)})\\b\\s*:?`,`gi`),r=[...e.matchAll(n)];if(!r.length)return{meta:[],overview:qv(Xv(e)),keySkills:[],education:[]};let i={overview:[],keySkills:[],education:[]},a=e.slice(0,r[0].index).trim();return a&&i.overview.push(...Xv(a)),r.forEach((t,n)=>{let a=t[1].trim().toLowerCase(),o=t.index+t[0].length,s=n+1<r.length?r[n+1].index:e.length,c=Xv(e.slice(o,s).trim());c.length&&i[Uv.test(a)?`education`:Wv.test(a)?`keySkills`:`overview`].push(...c)}),{meta:[],overview:qv(i.overview),keySkills:qv(i.keySkills),education:qv(i.education)}}function ty(e){let t=Jv(e);if(!t)return{meta:[],overview:[],keySkills:[],education:[]};let n=Yv(t);return n.length>=4?$v(n):ey(t)}function ny({items:e}){return(0,o.jsx)(`ul`,{className:`jdv-ats-bullets`,children:e.map((e,t)=>(0,o.jsx)(`li`,{className:`jdv-ats-bullet-item`,children:e},t))})}function ry({raw:e=``,meta:t=[]}){let[n,i]=(0,r.useState)(!1),a=(0,r.useMemo)(()=>ty(e),[e]),s=t.length?t:a.meta,c=[];if(a.overview.length&&c.push({key:`overview`,title:`Overview`,items:a.overview}),a.keySkills.length&&c.push({key:`keySkills`,title:`Key Skills`,items:a.keySkills,card:!0,icon:`🛠️`}),a.education.length&&c.push({key:`education`,title:`Education`,items:a.education,card:!0,icon:`🎓`}),!s.length&&!c.length)return(0,o.jsx)(zv,{type:`secondary`,children:`No description available.`});let l=n?c:c.slice(0,Bv),u=c.length-Bv;return(0,o.jsxs)(`div`,{className:`jdv-ats-desc`,children:[s.length>0&&(0,o.jsx)(`div`,{className:`jdv-ats-meta-grid`,children:s.map(({fieldKey:e,fieldLabel:t,value:n})=>(0,o.jsxs)(`div`,{className:`jdv-ats-meta-row`,children:[(0,o.jsx)(`span`,{className:`jdv-ats-meta-key`,children:t}),(0,o.jsx)(`span`,{className:`jdv-ats-meta-val`,children:n})]},e??t))}),(0,o.jsx)(`div`,{className:`jdv-ats-sections`,children:l.map(e=>e.card?(0,o.jsxs)(`div`,{className:`education-block`,children:[(0,o.jsxs)(`div`,{className:`education-header`,children:[(0,o.jsx)(`span`,{children:e.icon}),(0,o.jsx)(`span`,{children:e.title})]}),(0,o.jsx)(`ul`,{className:`education-list`,children:e.items.map((e,t)=>(0,o.jsx)(`li`,{className:`education-list-item`,children:e},t))})]},e.key):(0,o.jsxs)(`div`,{className:`jdv-ats-section`,children:[(0,o.jsx)(`div`,{className:`jdv-ats-section-hd`,children:(0,o.jsx)(`span`,{children:e.title})}),(0,o.jsx)(ny,{items:e.items})]},e.key))}),u>0&&(0,o.jsx)(`span`,{className:`jdv-desc-toggle`,onClick:()=>i(e=>!e),children:n?`Show less`:`Show more (${u} more section${u>1?`s`:``})`})]})}var{Text:iy}=i.Typography;function ay(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function oy(e){return e?e.name?e.name:e.fullName?e.fullName:e.firstName||e.lastName?[e.firstName,e.lastName].filter(Boolean).join(` `):e.candidateName??e.clientName??e.jobTitle??``:``}function sy(e){return e?e.email??e.emailId??e.emailAddress??``:``}function cy(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function ly(e){return e==null||e===``?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.join(`, `):typeof e==`object`?e.label??e.name??Object.values(e).join(` `):String(e)}var uy=[`jobDescription`,`description`,`rawDescription`,`jobDescriptionText`];function dy(e){return String(e??``).toLowerCase()===`job`}function fy(e){let t=uy.includes(e.field),n=/description/i.test(e.label??``);return t||n}function py({steps:e,current:t,onStepClick:n}){return(0,o.jsx)(`div`,{className:`preview-stepper`,children:e.map((i,s)=>{let c=s<t,l=s===t,u=s===e.length-1;return(0,o.jsxs)(r.Fragment,{children:[(0,o.jsxs)(`button`,{type:`button`,className:`preview-stepper__item${l?` preview-stepper__item--active`:``}`,onClick:()=>n(s),"aria-label":`Go to step ${s+1}: ${i.title}`,"aria-current":l?`step`:void 0,children:[(0,o.jsx)(`div`,{className:[`preview-stepper__circle`,c?`preview-stepper__circle--done`:``,l?`preview-stepper__circle--active`:``].filter(Boolean).join(` `),children:c?(0,o.jsx)(a.CheckOutlined,{}):s+1}),(0,o.jsx)(`span`,{className:`preview-stepper__label${l?` preview-stepper__label--active`:``}`,children:i.title})]}),!u&&(0,o.jsx)(`div`,{className:`preview-stepper__line${c?` preview-stepper__line--done`:``}`})]},i.title??s)})})}function my({record:e}){let t=oy(e),n=sy(e),r=cy(e);return!t&&!n?null:(0,o.jsxs)(`div`,{className:`preview-profile-card`,children:[(0,o.jsxs)(`div`,{className:`preview-profile-card__info`,children:[(0,o.jsx)(i.Avatar,{className:`preview-profile-card__avatar`,children:ay(t)}),(0,o.jsxs)(`div`,{className:`preview-profile-card__text`,children:[t&&(0,o.jsx)(`span`,{className:`preview-profile-card__name`,children:t}),n&&(0,o.jsx)(`span`,{className:`preview-profile-card__email`,children:n})]})]}),r&&(0,o.jsx)(i.Tag,{className:`preview-profile-card__status`,children:r})]})}function hy({fields:e,moduleName:t}){return e?.length?(0,o.jsx)(`div`,{className:`preview-field-grid`,children:e.map(e=>{let n=e.value,r=Array.isArray(n)&&n.length>0,i=dy(t)&&fy(e)&&typeof n==`string`&&n.trim();return r?n.map((t,r)=>(0,o.jsxs)(`div`,{className:`preview-field-card`,children:[(0,o.jsxs)(`span`,{className:`preview-field-card__label`,children:[e.label,n.length>1?` (${r+1})`:``]}),(0,o.jsx)(`span`,{className:`preview-field-card__value`,children:ly(t)})]},`${e.field??e.label}-${r}`)):i?(0,o.jsxs)(`div`,{className:`preview-field-card preview-field-card--description`,children:[(0,o.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,o.jsx)(`div`,{className:`preview-field-card__description`,children:(0,o.jsx)(ry,{raw:n})})]},e.field??e.label):(0,o.jsxs)(`div`,{className:`preview-field-card`,children:[(0,o.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,o.jsx)(`span`,{className:`preview-field-card__value`,children:ly(n)})]},e.field??e.label)})}):null}function gy(){let t=(0,s.useNavigate)(),{moduleName:n=``,record:c=null}=(0,s.useLocation)().state??{},l=c?.id??c?._id,[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(!!(n&&l)),[m,h]=(0,r.useState)(null),[g,_]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(!n||!l)return;let t=!1;return e.Sn({module:n,id:l}).then(e=>{t||(d(Array.isArray(e)?e:[]),p(!1))}).catch(e=>{t||(h(e.message||`Failed to load preview`),p(!1))}),()=>{t=!0}},[n,l]);function v(){t(-1)}let y=u.length,b=y>1,x=u[g],S=y>4?`min(${y*105+80}px, min(95vw, 1200px))`:`min(680px, calc(100vw - 32px))`,C=u.map((e,t)=>({title:e.label??e.name??`Step ${t+1}`})),w=(0,o.jsxs)(`div`,{className:`preview-modal-header`,children:[(0,o.jsx)(`span`,{className:`preview-modal-module`,children:n.toUpperCase()}),(0,o.jsx)(`span`,{className:`preview-modal-title`,children:x?.label??(n?`Preview - ${n}`:`Preview`)})]}),T=(0,o.jsxs)(`div`,{className:`wizard-footer`,children:[b&&(0,o.jsxs)(iy,{className:`preview-footer-step-count`,children:[`Step `,g+1,` of `,y]}),(0,o.jsxs)(`div`,{className:`wizard-footer-nav`,children:[(0,o.jsx)(i.Button,{onClick:v,children:`Close`}),b&&g>0&&(0,o.jsx)(i.Button,{onClick:()=>_(e=>e-1),children:`Back`}),b&&(g<y-1?(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.RightOutlined,{}),iconPosition:`end`,onClick:()=>_(e=>e+1),children:`Next`}):(0,o.jsx)(i.Button,{type:`primary`,onClick:v,children:`Done`}))]})]});function E(){return!n||!l?(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`Preview id is missing.`}):f?(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:(0,o.jsx)(i.Spin,{size:`small`})}):m?(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status job-preview-error`,children:m}):u.length?u.map((e,t)=>(0,o.jsx)(`div`,{style:{display:t===g?`block`:`none`},children:e.fields?.length>0?(0,o.jsx)(hy,{fields:e.fields,moduleName:n}):(0,o.jsx)(iy,{type:`secondary`,children:`No fields in this group.`})},e.name??e.id??t)):(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`No form groups found.`})}return(0,o.jsxs)(i.Modal,{centered:!0,className:`wizard-modal preview-modal`,footer:T,open:!0,title:w,width:S,onCancel:v,maskClosable:!1,children:[b&&(0,o.jsx)(`div`,{className:`wizard-steps-container`,children:(0,o.jsx)(py,{steps:C,current:g,onStepClick:_})}),(0,o.jsxs)(`div`,{className:`wizard-body`,children:[c&&(0,o.jsx)(my,{record:c}),E()]})]})}var{Text:_y}=i.Typography,{TextArea:vy}=i.Input,yy=[{key:`basic`,title:`Basic Info`,description:`General details`,fields:[{name:`firstName`,label:`First Name`,type:`input`,required:!0,placeholder:`Enter first name`,span:12},{name:`lastName`,label:`Last Name`,type:`input`,required:!0,placeholder:`Enter last name`,span:12},{name:`email`,label:`Email Address`,type:`input`,required:!0,placeholder:`Enter email address`,rules:[{type:`email`,message:`Please enter a valid email`}]},{name:`phone`,label:`Phone`,type:`input`,placeholder:`Enter phone number`}]},{key:`details`,title:`Details`,description:`Additional info`,fields:[{name:`role`,label:`Role`,type:`select`,required:!0,placeholder:`Select a role`,span:12,options:[{label:`Developer`,value:`developer`},{label:`Designer`,value:`designer`},{label:`Manager`,value:`manager`},{label:`Analyst`,value:`analyst`}]},{name:`department`,label:`Department`,type:`select`,placeholder:`Select department`,span:12,options:[{label:`Engineering`,value:`engineering`},{label:`Product`,value:`product`},{label:`Operations`,value:`operations`},{label:`Finance`,value:`finance`}]},{name:`notes`,label:`Notes`,type:`textarea`,placeholder:`Any additional notes...`}]},{key:`confirm`,title:`Confirm`,description:`Review & submit`,isReview:!0}];function by(e){switch(e.type){case`select`:return(0,o.jsx)(i.Select,{placeholder:e.placeholder,options:e.options,style:{width:`100%`}});case`textarea`:return(0,o.jsx)(vy,{rows:3,placeholder:e.placeholder});case`number`:return(0,o.jsx)(i.InputNumber,{placeholder:e.placeholder,style:{width:`100%`}});default:return(0,o.jsx)(i.Input,{type:e.inputType||`text`,placeholder:e.placeholder})}}function xy({steps:e,form:t}){let n=t.getFieldsValue(),r=e.filter(e=>!e.isReview);return r.some(e=>(e.fields||[]).some(e=>n[e.name]!==void 0&&n[e.name]!==``))?(0,o.jsxs)(`div`,{className:`wizard-review-content`,children:[r.map(e=>(0,o.jsxs)(`div`,{className:`wizard-review-section`,children:[(0,o.jsx)(_y,{className:`wizard-review-section-title`,children:e.title}),(0,o.jsx)(`div`,{className:`wizard-review-grid`,children:(e.fields||[]).map(e=>{let t=n[e.name],r=t===void 0||t===``||t===null?`—`:String(t);return(0,o.jsxs)(`div`,{className:`wizard-review-row`,children:[(0,o.jsx)(`span`,{className:`wizard-review-label`,children:e.label}),(0,o.jsx)(`span`,{className:`wizard-review-separator`,children:`:`}),(0,o.jsx)(`span`,{className:`wizard-review-value`,children:r})]},e.name)})})]},e.key)),(0,o.jsxs)(`div`,{className:`wizard-review-confirm-note`,children:[(0,o.jsx)(a.CheckCircleOutlined,{className:`wizard-review-confirm-icon`}),(0,o.jsx)(_y,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,o.jsx)(`div`,{className:`wizard-review-empty`,children:(0,o.jsx)(_y,{type:`secondary`,children:`No data entered yet.`})})}function Sy(){let[e]=i.Form.useForm(),t=(0,s.useNavigate)(),{title:n=`Wizard`,moduleName:a=``,steps:c=yy,onSubmit:l}=(0,s.useLocation)().state??{},[u,d]=(0,r.useState)(0),f=c[u],p=u===c.length-1,m=u===0;function h(){t(-1)}function g(){let t=(f.fields||[]).map(e=>e.name);e.validateFields(t.length>0?t:void 0).then(()=>{d(e=>e+1)})}function _(){d(e=>e-1)}function v(){let n=e.getFieldsValue();typeof l==`function`&&l(n),t(-1)}let y=c.map((e,t)=>({title:e.title,description:e.description,status:t<u?`finish`:t===u?`process`:`wait`}));return(0,o.jsxs)(i.Modal,{open:!0,title:a?`${n} — ${a}`:n,footer:(0,o.jsxs)(`div`,{className:`wizard-footer`,children:[(0,o.jsx)(i.Button,{onClick:h,children:`Cancel`}),(0,o.jsxs)(`div`,{className:`wizard-footer-nav`,children:[!m&&(0,o.jsx)(i.Button,{onClick:_,children:`Back`}),p?(0,o.jsx)(i.Button,{type:`primary`,onClick:v,children:`Submit`}):(0,o.jsx)(i.Button,{type:`primary`,onClick:g,children:`Next`})]})]}),onCancel:h,width:`min(680px, calc(100vw - 32px))`,centered:!0,className:`wizard-modal`,children:[(0,o.jsx)(`div`,{className:`wizard-steps-container`,children:(0,o.jsx)(i.Steps,{current:u,items:y,size:`small`,className:`wizard-steps`})}),(0,o.jsx)(`div`,{className:`wizard-body`,children:(0,o.jsxs)(i.Form,{form:e,layout:`vertical`,children:[c.filter(e=>!e.isReview).map((e,t)=>(0,o.jsx)(`div`,{style:{display:t===u?`block`:`none`},children:(0,o.jsx)(i.Row,{gutter:16,children:(e.fields||[]).map(e=>(0,o.jsx)(i.Col,{span:e.span||24,children:(0,o.jsx)(i.Form.Item,{name:e.name,label:e.label,rules:[...e.required?[{required:!0,message:`${e.label} is required`}]:[],...e.rules||[]],children:by(e)})},e.name))})},e.key)),f.isReview&&(0,o.jsx)(xy,{steps:c,form:e})]})})]})}function Cy({titleText:e,titleIcon:t}){let n=t===`delete`;return(0,o.jsxs)(`span`,{className:`dynamic-popup__header`,children:[(0,o.jsx)(`span`,{className:`dynamic-popup__header-icon-box${n?` dynamic-popup__header-icon-box--danger`:``}`,children:n?(0,o.jsx)(a.DeleteOutlined,{}):(0,o.jsx)(a.AppstoreOutlined,{})}),(0,o.jsx)(`span`,{className:`dynamic-popup__header-label`,children:e})]})}function wy({note:t,description:n,showSelectedCount:r,count:i,itemLabel:a,bodyText:s,deleteError:c}){return(0,o.jsxs)(o.Fragment,{children:[t&&(0,o.jsx)(e.An,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:t}),n&&(0,o.jsx)(e.An,{variant:`body`,className:`dynamic-popup__description`,children:n}),r&&i>0&&(0,o.jsxs)(e.An,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,o.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),s&&(0,o.jsx)(e.An,{variant:`body`,children:s}),c&&(0,o.jsx)(e.An,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:c})]})}function Ty({footerNote:t}){return t?(0,o.jsx)(e.An,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:t}):null}var{TextArea:Ey}=i.Input,Dy=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],Oy=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function ky(e=[]){return e.map(e=>{if(!e||typeof e!=`object`)return e;let t=[e.value,e.user_id,e.userId,e.USER_ID,e.legacyUserId,e.id,e._id].find(e=>e!=null&&String(e).trim()!==``),n=t==null?``:String(t).trim();return{...e,value:n}}).filter(e=>typeof e!=`object`||!e||String(e.value??``).trim()!==``)}function Ay({field:e,value:t,onChange:n}){return(0,o.jsx)(i.Input,{value:t,onChange:n,placeholder:e.placeholder,maxLength:e.maxLength,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function jy({field:e,value:t,onChange:n}){return(0,o.jsx)(Ey,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function My({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{value:n,onChange:r,options:ky(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function Ny({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{mode:`multiple`,value:n,onChange:r,options:ky(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function Py({field:e,options:t,onSearch:n,value:r,onChange:s}){return(0,o.jsx)(i.Select,{showSearch:!0,filterOption:!1,notFoundContent:null,value:r,onChange:s,options:ky(t),placeholder:e.placeholder,onSearch:n,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function Fy({field:e,mentionOpts:t,onMentionSearch:n,value:r,onChange:a}){return(0,o.jsx)(i.Mentions,{value:r,onChange:a,rows:e.rows??5,placeholder:e.placeholder,prefix:`@`,options:t,onSearch:n,className:`dynamic-popup__mention-textarea`})}function Iy({value:e={},onChange:t}){let n=e.period??`Hourly`,r=e.isRange??!1;function a(n){t?.({...e,...n})}return(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(i.Space.Compact,{style:{width:`100%`},children:[r?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.InputNumber,{controls:!1,placeholder:`From`,value:e.minAmount,onChange:e=>a({minAmount:e}),style:{flex:1}}),(0,o.jsx)(i.InputNumber,{controls:!1,placeholder:`To`,value:e.maxAmount,onChange:e=>a({maxAmount:e}),style:{flex:1}})]}):(0,o.jsx)(i.InputNumber,{controls:!1,placeholder:`0`,value:e.amount,onChange:e=>a({amount:e}),style:{flex:2}}),(0,o.jsx)(i.Select,{value:e.currency??void 0,options:Dy,onChange:e=>a({currency:e}),style:{width:80}}),(0,o.jsx)(i.Select,{value:n,options:Oy,onChange:e=>a({period:e}),style:{width:110}})]}),(0,o.jsxs)(i.Space,{size:`small`,style:{marginTop:8},children:[(0,o.jsx)(i.Switch,{checked:r,onChange:e=>a({isRange:e})}),(0,o.jsx)(`span`,{children:`Range`})]})]})}function Ly({field:e,value:t,onChange:n}){return(0,o.jsx)(i.DatePicker,{value:t,onChange:n,placeholder:e.placeholder??`Select date`,style:{width:`100%`},format:`YYYY-MM-DD`})}function Ry({field:e,checked:t,onChange:n}){return(0,o.jsx)(i.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function zy({field:e,value:t,onChange:n}){return(0,o.jsx)(i.InputNumber,{value:t,onChange:n,min:e.min,max:e.max,placeholder:e.placeholder,style:{width:`100%`}})}function By({options:e,value:t,onChange:n}){return(0,o.jsx)(i.Radio.Group,{value:t,onChange:n,options:e})}var Vy={input:Ay,text:Ay,textarea:jy,select:My,"multi-select":Ny,"search-select":Py,"mention-textarea":Fy,"candidate-rate":Iy,"priority-checkbox":Ry,"date-picker":Ly,number:zy,radio:By};function Hy(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}function Uy(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function Wy(e){if(!e)return``;let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=Math.round((n(new Date)-n(t))/864e5);return r<=0?`Today`:r===1?`Yesterday`:`${r} days ago`}function Gy(e){let t=Array.isArray(e?.submissionHistory)?e.submissionHistory:[],n=[e?.lastSubmittedAt,e?.submittedAt,e?.updatedAt,...t.map(e=>e?.submittedAt||e?.updatedAt)].filter(Boolean);return n.length?n.reduce((e,t)=>new Date(t)>new Date(e)?t:e):null}function Ky(e,t){if(typeof e==`string`)return{label:e,value:e};if(e?.label!==void 0&&e?.value!==void 0&&!t?.labelTemplate&&!t?.valueKey)return e;let{labelKey:n,valueKey:r,labelTemplate:i}=t??{},a=i?.includes(`{lastdate}`)?{...e,lastdate:Wy(Gy(e))}:e,o=(i?Uy(i,a):null)||(n?e?.[n]:null)||e?.name||e?.fullName||e?.candidateName||e?.title||e?.displayName||e?.text||e?.applicantReferenceId||e?.applicantRefrenceId||String(Object.values(e||{})[0]??``),s=(r?e?.[r]:null)??e?.id??e?._id??e?.applicantReferenceId??e?.applicantRefrenceId??String(Object.values(e||{})[0]??``);return{label:String(o),value:String(s),_raw:e}}function qy(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>Ky(t,e))}function Jy(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var Yy=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function Xy({form:t,fields:n,initialValues:r,dynamicOptions:a,popupContext:s,extraData:c,removedIds:l,setRemovedIds:u,showAlreadyAssigned:d,onValuesChange:f,getSearchHandler:p,getMentionSearchHandler:m,mentionOptions:h}){let g=d&&c;return!n.length&&!g?null:(0,o.jsxs)(o.Fragment,{children:[g&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`dynamic-popup__already-assigned`,children:[(0,o.jsx)(e.An,{variant:`caption`,color:`secondary`,children:`Already Assigned People`}),(0,o.jsx)(`div`,{style:{marginTop:6,display:`flex`,flexWrap:`wrap`,gap:6},children:(c?.recruitersData??[]).filter(e=>{let t=String(e?.user_id??e?.id??e?.userId??``);return t&&!l.includes(t)}).map(e=>{let t=String(e?.user_id??e?.id??e?.userId??``),n=e?.name??e?.user_name??e?.userName??e?.email??t;return(0,o.jsx)(i.Tag,{closable:!0,onClose:()=>{t&&u(e=>Array.from(new Set([...e,t])))},children:n},t||n)})})]}),(0,o.jsx)(i.Divider,{style:{margin:`12px 0`}})]}),n.length>0&&(0,o.jsx)(i.Form,{form:t,layout:`vertical`,initialValues:r,onValuesChange:(e,t)=>f(t),children:Zy(n).map(t=>Qy(t,t=>{let n=a[t.name]??qy(t,s),r=p(t),c=m(t),l=h[t.name]??[],u=Hy(t.type),d=Vy[t.type],f=[];return t.required&&f.push({required:!0,message:`${t.label||`This field`} is required`}),typeof t.validator==`function`&&f.push({validator:(e,n)=>{let r=t.validator(n,s);return r?Promise.reject(Error(r)):Promise.resolve()}}),Yy.has(t.type)&&f.push(e.K({label:t.label,field:t.name,type:t.type})),(0,o.jsx)(i.Form.Item,{name:t.name,label:t.label,rules:f,...u,children:d?(0,o.jsx)(d,{field:t,options:n,onSearch:r,mentionOpts:l,onMentionSearch:c}):null},t.name)}))})]})}function Zy(e){let t=[];for(let n of e){let e=t[t.length-1];n.inlineRow&&e?.inlineRow===n.inlineRow?e.fields.push(n):t.push({inlineRow:n.inlineRow,fields:[n]})}return t.map(e=>e.fields)}function Qy(e,t){return e.length===1?t(e[0]):(0,o.jsx)(`div`,{style:{display:`flex`,gap:8,alignItems:`flex-start`},children:e.map((e,n)=>(0,o.jsx)(`div`,{style:{flex:n===0?2:1,minWidth:0},children:t(e)},e.name))},`row-${e.map(e=>e.name).join(`-`)}`)}function $y({open:e,config:t,api:n,fields:i,popupContext:a,formValues:o}){let[s,c]=(0,r.useState)({}),[l,u]=(0,r.useState)(null);return(0,r.useEffect)(()=>{e||(c({}),u(null))},[e]),(0,r.useEffect)(()=>{if(!e||!t||!n.getOptions)return;let r=new AbortController;return i.forEach(e=>{!e.fetchOptionsKey||e.fetchOptionsParamKey||Promise.resolve(n.getOptions(e,void 0,a)).then(t=>{r.signal.aborted||c(n=>({...n,[e.name]:t}))}).catch(t=>{r.signal.aborted||console.error(`[DynamicPopup] Failed to load options for field "${e.name}":`,t)})}),()=>r.abort()},[e,n,t,i,a]),(0,r.useEffect)(()=>{if(!e||!t||!n.getOptions)return;let r=i.filter(e=>e.fetchOptionsKey&&e.fetchOptionsParamKey);if(!r.length)return;let s=new AbortController;return r.forEach(e=>{let t=o[e.fetchOptionsParamKey]??a[e.fetchOptionsParamKey],r={[e.fetchOptionsParamKey]:t};Promise.resolve(n.getOptions(e,r,a)).then(t=>{s.signal.aborted||c(n=>({...n,[e.name]:t}))}).catch(t=>{s.signal.aborted||console.error(`[DynamicPopup] Failed to load param-dependent options for "${e.name}":`,t)})}),()=>s.abort()},[e,n,t,i,o,a]),(0,r.useEffect)(()=>{if(!e||!t||!n.loadExtraData)return;let r=new AbortController;return Promise.resolve(n.loadExtraData(a)).then(e=>{r.signal.aborted||u(e)}).catch(e=>{r.signal.aborted||(console.error(`[DynamicPopup] Failed to load extra data:`,e),u(null))}),()=>r.abort()},[e,n,t,a]),{dynamicOptions:s,setDynamicOptions:c,extraData:l}}var eb=500,tb=3;function nb({api:e,popupContext:t,setDynamicOptions:n}){let[i,a]=(0,r.useState)({}),o=(0,r.useRef)({}),s=(0,r.useRef)({}),c=(0,r.useRef)({});function l(r){if(!r.searchFetchKey&&!r.searchFetcher)return;let i=e.searchOptions??e.searchFetcher;if(typeof i==`function`)return e=>{if(clearTimeout(o.current[r.name]),e.length<tb){n(e=>({...e,[r.name]:[]}));return}o.current[r.name]=setTimeout(()=>{s.current[r.name]?.abort();let a=new AbortController;s.current[r.name]=a,Promise.resolve(i(r,e,t)).then(e=>{if(a.signal.aborted)return;let t=Array.isArray(e)?e:e?.items??e?.list??[];n(e=>({...e,[r.name]:t.map(e=>Ky(e,r))}))}).catch(e=>{a.signal.aborted||console.error(`[DynamicPopup] Search failed for field "${r.name}":`,e)})},eb)}}function u(n){let r=e.getMentionOptions??e.mentionFetcher;if(typeof r==`function`)return e=>{c.current[n.name]?.abort();let i=new AbortController;c.current[n.name]=i,Promise.resolve(r(n,e,t)).then(e=>{if(i.signal.aborted)return;let t=Array.isArray(e)?e:e?.items??e?.list??[];a(e=>({...e,[n.name]:t.map(e=>({value:e.user_name??e.userName??e.username??String(e),label:e.user_name??e.userName??e.username??String(e)}))}))}).catch(e=>{i.signal.aborted||console.error(`[DynamicPopup] Mention search failed for field "${n.name}":`,e)})}}return{mentionOptions:i,getSearchHandler:l,getMentionSearchHandler:u}}function rb({form:e,config:t,api:n,popupContext:a,resolvedIds:o,dynamicOptions:s,extraData:c,removedIds:l,fields:u,onClose:d,onSubmit:f}){let[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(null);async function _(e){let t={resolvedIds:o,dynamicOptions:s,extraData:c,removedIds:l};if(typeof n.submit==`function`)return n.submit(e,a,t);if(typeof f==`function`)return f(e,a,t)}function v(){if(t){if(!u.length){if(t.mode===`delete`&&typeof n.deleteItems==`function`){m(!0),g(null),Promise.resolve(n.deleteItems(o,a)).then(()=>d({success:!0})).catch(e=>{let t=e?.message||`Delete failed. Please try again.`;g(t),m(!1),i.message.error(t)});return}if(typeof n.onOk==`function`){m(!0),Promise.resolve(n.onOk(a)).then(()=>d({success:!0})).catch(e=>{let t=e?.message||`Failed. Please try again.`;i.message.error(t),m(!1)});return}if(typeof n.submit==`function`){m(!0),Promise.resolve(_({})).then(e=>{e?.navigated||(i.message.success(t.successMessage||`Saved successfully`),d({success:!0}))}).catch(e=>{i.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>m(!1));return}d();return}e.validateFields().then(async e=>{m(!0);try{if((await _(e))?.navigated)return;i.message.success(t.successMessage||`Saved successfully`),d({success:!0})}catch(e){i.message.error(e?.message||`Failed. Please try again.`)}finally{m(!1)}}).catch(()=>{})}}function y(){m(!1),g(null)}return{handleOk:v,confirming:p,deleteError:h,resetSubmitState:y}}function ib({open:e=!0,config:t,context:n={},onClose:a,onSubmit:s,api:l={}}){let[u]=i.Form.useForm(),[d,f]=(0,r.useState)({}),[p,m]=(0,r.useState)([]),h=i.Form.useWatch([],u,{preserve:!0})??{},g=(0,r.useMemo)(()=>Jy(n),[n]),{selectedIds:_=[],selectedRecords:v=[],moduleName:y=``}=g,b=(0,r.useMemo)(()=>_.map((e,t)=>{let n=v[t];return n?.id??n?._id??e}),[_,v]),x=(0,r.useMemo)(()=>t?typeof t.getFields==`function`?t.getFields(g):t.fields??[]:[],[t,g]),S=(0,r.useMemo)(()=>{let e={};return x.forEach(t=>{let n=g[t.initialValueKey];!t.initialValueKey||n===void 0||(e[t.name]=t.type===`date-picker`?(0,c.default)(n):n)}),e},[x,g]),{dynamicOptions:C,setDynamicOptions:w,extraData:T}=$y({open:e,config:t,api:l,fields:x,popupContext:g,formValues:d}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=nb({api:l,popupContext:g,setDynamicOptions:w});function k(e){typeof a==`function`&&a(e)}let{handleOk:A,confirming:j,deleteError:M,resetSubmitState:N}=rb({form:u,config:t,api:l,popupContext:g,resolvedIds:b,dynamicOptions:C,extraData:T,removedIds:p,fields:x,onClose:k,onSubmit:s});(0,r.useEffect)(()=>{e&&(u.resetFields(),f(S??{}),m(g.removedIds??[]),N())},[e,S]);let P=!!t?.autoSubmitWhenNoFields&&x.length===0;(0,r.useEffect)(()=>{!e||!P||A()},[e,P]);let F=_.length,I=String(y).replace(/s$/i,``),L=F===1?I:y,R=v[0]??{},z=t?.getTitleText?t.getTitleText(F,L,R,g):t?.title,B=F===1?R.jobTitle??R.title??R.name??R.fullName??R.candidateName??null:null,V=t?.getBodyText?t.getBodyText(F,I,L,B,g):t?.bodyText??null,H=typeof t?.getNote==`function`?t.getNote(g):t?.note,U=x.filter(e=>e.required).every(e=>{let t=h[e.name];return!(t==null||t===``||Array.isArray(t)&&t.length===0||typeof t==`object`&&!Array.isArray(t)&&Object.keys(t).length===0)}),W=t?.disabledUntilFilled&&!U;if(!t||!e||P)return null;let G=t.component;return G?(0,o.jsx)(i.Modal,{open:e,title:t.title||t.getTitleText?(0,o.jsx)(Cy,{titleText:z,titleIcon:t.titleIcon}):null,footer:null,width:t.width??760,centered:!0,maskClosable:!1,onCancel:()=>k(),className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:(0,o.jsx)(G,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:k})}):(0,o.jsxs)(i.Modal,{open:e,title:(0,o.jsx)(Cy,{titleText:z,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:A,onCancel:()=>k(),okButtonProps:{danger:t.okButtonDanger,disabled:W,loading:j},cancelButtonProps:{disabled:j},closable:!j,maskClosable:!1,width:t.width??480,centered:!0,className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:[(0,o.jsx)(wy,{note:H,description:t.description,showSelectedCount:t.showSelectedCount,count:F,itemLabel:L,bodyText:V,deleteError:M}),(0,o.jsx)(Ty,{footerNote:t.footerNote}),(0,o.jsx)(Xy,{form:u,fields:x,initialValues:S,dynamicOptions:C,popupContext:g,extraData:T,removedIds:p,setRemovedIds:m,showAlreadyAssigned:t.showAlreadyAssigned,onValuesChange:f,getSearchHandler:D,getMentionSearchHandler:O,mentionOptions:E})]})}var ab={mode:`delete`,getTitleText:(e,t)=>`Delete ${e>0?`${e} `:``}${t}`,titleIcon:`delete`,okText:`Delete`,okButtonDanger:!0,width:420,getBodyText:(e,t,n,r)=>r?`Are you sure you want to delete the ${r} ${t}?`:e>1?`Are you sure you want to delete ${e} selected ${n}?`:`Are you sure you want to delete this ${t}?`,footerNote:`This action cannot be undone.`,fields:[]},ob={deleteItems:async(e,t)=>{await F(t.moduleName,e)}},sb={title:`Quick Submit`,okText:`Submit`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getNote:e=>e.moduleName===`candidate`?`Note: Select a job to submit this candidate`:`Note: Select a candidate to submit for this job`,getFields:e=>e.jobId?[]:e.moduleName===`candidate`?[{name:`jobId`,label:`Job list`,type:`search-select`,required:!0,placeholder:`Search Job ID/Job name (minimum 3 characters)`,searchFetchKey:`quickSubmitJobList`}]:[{name:`candidate`,label:`Candidate`,type:`search-select`,required:!0,placeholder:`Search candidate name (minimum 3 character)`,optionsKey:`candidateOptions`,searchFetchKey:`quickSubmitCandidates`,labelTemplate:`{applicantRefrenceId} - {firstName} {lastName} - ({lastdate})`,valueKey:`applicantId`}]},cb={searchOptions:async(e,t,n)=>{if(e.searchFetchKey===`quickSubmitJobList`){let e=n.selectedRecords?.[0]??{},r=await Gt({searchQuery:t,candidateId:e.id??e._id??n.selectedIds?.[0]});return(Array.isArray(r?.data)?r.data:[]).map(e=>({label:[e.jobReferenceId,e.jobTitle].filter(Boolean).join(` - `)||String(e._id??``),value:e._id??``}))}if(e.searchFetchKey===`quickSubmitCandidates`){let e=n.selectedRecords?.[0]??{},r=n.jobId??e.jobId??e.id??e._id??n.selectedIds?.[0];return ga({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t})}return[]},submit:async(e,t,n)=>{let{navigate:r,selectedRecords:i=[],selectedIds:a=[],moduleName:o,isFromSubmission:s=!1}=t,c=i[0]??{},l,u;t.jobId?(l=t.jobId,u=c.id??c._id??a[0]??``):o===`candidate`?(l=e.jobId??``,u=c.id??c._id??a[0]??``):(l=c.jobId??c.id??c._id??a[0]??``,u=e.candidate??``);let d=n?.dynamicOptions?.candidate?.find(e=>e?._raw?.applicantId===u),f=s||!!d?._raw?.isFromSubmission,p=t.submissionId??d?._raw?.submissionId??c.submissionId??``,m=new URLSearchParams;if(u&&m.set(`candidateId`,u),m.set(`isFromSubmission`,String(!!f)),f)p&&m.set(`submissionId`,p);else if(l&&u){let{exists:e,submissionId:t}=await Y({jobId:l,applicantId:u});if(e)throw Error(`This candidate is already submitted for this job${t?` (submission ${t})`:``}.`)}return r(`/submission-create/${l}?${m.toString()}`),{navigated:!0}}},lb={title:`Add Notes & Share`,okText:`Save & Share`,width:480,fields:[{name:`notes`,type:`mention-textarea`,required:!0,rows:5,placeholder:`Add your notes on the job. Use '@' to mention someone.`,mentionFetchKey:`mentionUsers`}]},ub=e=>e?.data??e;async function db({relatedId:e,notes:n,title:r,notesFor:i}){return ub(await Dt(t.v,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var fb={getMentionOptions:async(e,t)=>L(t),submit:async(e,t)=>{let n=Array.isArray(t.selectedIds)?t.selectedIds[0]:t.selectedIds;if(!n)throw Error(`Please select a record before adding a note.`);await db({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},pb={name:`jobId`,label:`Job Title / ID`,type:`search-select`,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle}`},mb={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`goodfited`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},hb={title:`Tag to Job`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[mb]:[pb,mb]},gb={searchOptions:async(e,t)=>e.searchFetchKey===`tagToJobJobList`?I(t):[],submit:async(e,t)=>{await V({jobId:e.jobId??t.jobId,candidateIds:t.selectedIds,hiringStage:e.hiringStage??t.hiringStage})}},_b={title:`Change Status`,okText:`Apply`,width:420,showSelectedCount:!0,fields:[{name:`status`,label:`New Status`,type:`select`,required:!0,placeholder:`Select a status`,optionsKey:`statusOptions`,initialValueKey:`currentStatus`,defaultOptions:[{label:`Active`,value:`active`},{label:`Inactive`,value:`inactive`},{label:`Pending`,value:`pending`},{label:`Closed`,value:`closed`}]}]},vb={submit:async(e,t)=>{await P(t.moduleName,t.selectedIds,e.status)}},yb={getTitleText:e=>`Remove ${e>1?`${e} Candidates`:`Candidate`} from Shortlist`,titleIcon:`delete`,okText:`Remove`,okButtonDanger:!0,width:420,getBodyText:e=>e>1?`Are you sure you want to remove ${e} selected candidates from the shortlist?`:`Are you sure you want to remove this candidate from the shortlist?`,footerNote:`The candidate will be moved back to the pipeline.`,fields:[]},bb={onOk:async e=>{await se({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},xb={title:`Add to Groups`,description:`Select a group to add the selected candidate(s) to`,okText:`Add to Group`,width:480,disabledUntilFilled:!0,fields:[{name:`groupId`,label:`Group`,type:`select`,required:!0,placeholder:`Select a group`,fetchOptionsKey:`candidateGroups`}]},Sb={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?H():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await U({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},Cb={title:`Self Assign`,okText:`Yes`,cancelText:`No`,width:420,bodyText:`Are you sure you want to assign this job?`,fields:[]},wb={onOk:async e=>{await W({jobIds:e.selectedIds})}},Tb={getTitleText:(e,t,n)=>{let r=n?.jobTitle||n?.title||``;return r?`Assign - ${r}`:`Assign`},okText:`Assign`,width:520,disabledUntilFilled:!0,showAlreadyAssigned:!0,fields:[{name:`assignToUserId`,label:`Assign to`,type:`select`,required:!0,placeholder:`Select a user`,fetchOptionsKey:`assignToUsers`},{name:`candidateRate`,label:`Candidate Rate`,type:`candidate-rate`},{name:`priority`,label:`Priority`,type:`priority-checkbox`,checkboxLabel:`Mark as High`}]},Eb={getOptions:async e=>e.fetchOptionsKey===`assignToUsers`?ee():[],loadExtraData:async e=>te(e.selectedIds[0]),submit:async(e,t,{removedIds:n,extraData:r})=>{await q({jobIds:t.selectedIds,userId:e.assignToUserId,rate:e.candidateRate,priority:e.priority,removedIds:n,existingRecruiters:r?.recruitersData})}},Db={title:`Add Sticky Notes`,getTitleText:(e,t,n,r)=>r.editingNoteId?`Edit Sticky Notes`:`Add Sticky Notes`,okText:`Save`,width:480,fields:[{name:`heading`,label:`Heading`,type:`input`,required:!0,placeholder:`Enter heading`,initialValueKey:`editingHeading`},{name:`targetDate`,label:`Target Date`,type:`date-picker`,required:!1,initialValueKey:`editingTargetDate`},{name:`comments`,label:`Comments`,type:`mention-textarea`,required:!0,rows:5,placeholder:`Enter your note here... Use '@' to mention someone.`,mentionFetchKey:`mentionUsers`,initialValueKey:`editingComments`}]},Ob={getMentionOptions:async(e,t)=>L(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await z(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await R({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},kb={title:`Move to Onboarding`,bodyText:`Are you sure you want to move this candidate to onboarding?`,okText:`Yes`,cancelText:`No`,width:420,successMessage:`Moved to onboarding successfully`,fields:[{name:`sendOnboardingEmail`,type:`priority-checkbox`,checkboxLabel:`Send Onboarding Email`}]},Ab={submit:async(e,t)=>{await J({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function jb(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var Mb={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function Nb(e,t,n){let r=jb(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function Pb(e){let t=e.selectedRecords?.[0]??{},n=Nb(t,`candidateRate`,`candidateAcceptedRate`)??Nb(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=Nb(t,`candidateRate`,`candidateAcceptedCurrency`)??Nb(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:Nb(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??Nb(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??Mb[String(r??``).toUpperCase()]??(r||`$`),unit:Nb(t,`candidateRate`,`candidateAcceptedPayUnit`)??Nb(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var Fb={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=Pb(i);return`Candidate Rate: ${a?`${a.symbol}${a.amount}${a.unit?`/${a.unit}`:``}`:`-`}`},fields:[{name:`candidateProposedRate`,label:`Proposed Rate`,type:`number`,required:!0,placeholder:`Amount`,min:0,inlineRow:`proposedRate`,validator:(e,t)=>{if(e==null||e===``)return;let n=Pb(t);if(n&&Number(e)<=Number(n.amount))return`Proposed rate must be greater than Candidate Rate`}},{name:`candidateProposedRateCurrency`,label:`Currency`,type:`select`,required:!0,inlineRow:`proposedRate`,defaultOptions:[{label:`$ USD`,value:`$`},{label:`₹ INR`,value:`₹`},{label:`€ EUR`,value:`€`}]},{name:`candidateProposedRateUnit`,label:`Unit`,type:`select`,required:!0,inlineRow:`proposedRate`,defaultOptions:[{label:`Year`,value:`yr`},{label:`Month`,value:`mo`},{label:`Week`,value:`wk`},{label:`Hour`,value:`hr`},{label:`Daily`,value:`day`}]},{name:`submitVia`,label:`Submit Via`,type:`radio`,required:!0,defaultOptions:[{label:`Mail`,value:`Mail`},{label:`VMS`,value:`VMS`}]}]},Ib={submit:async(e,t)=>{let n=t.selectedIds[0];if(await ie(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await ae(n)}catch{i.message.warning(`Approved. VMS notification could not be sent — use Send Mail to notify the client.`)}else i.message.info(`Approved — use Send Mail to notify the client.`)}};function Lb(e,t={}){return{client:t.clientName??e.clientName,role:t.jobTitle??e.jobTitle??e.designation,reqId:t.reqId??e.jobClientRefrenceId??e.mspReqId??e.submissionId,name:t.candidateName||[e.firstName,e.lastName].filter(Boolean).join(` `)||e.candidateFullName,location:t.jobLocation??e.city??e.currentLocation??e.jobLocation,vendor:t.employerName??e.supplierName??e.submitSource,submittedBy:t.submittedBy??e.signatureEmail??e.recruiterName,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function Rb({selectedIds:e,selectedRecords:t,onClose:n}){let a=t?.[0]??{},s=e?.[0]??_f(a),[c,l]=(0,r.useState)(null),[u,d]=(0,r.useState)(!0);(0,r.useEffect)(()=>{let e=!1;return d(!0),Bf(s,a).then(t=>{e||l(t)}).catch(t=>{e||(i.message.error(t?.message??`Unable to load finance details`),l({record:{submission:a},lookups:{},display:{}}))}).finally(()=>{e||d(!1)}),()=>{e=!0}},[s]);let f=(0,r.useMemo)(()=>({submissionApprove:async({computed:e})=>{await ie(s,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currency,candidateProposedRateUnit:`hr`,submitVia:`Mail`}),i.message.success(`Submission approved`),n?.({success:!0})},submissionReject:async({reason:e})=>{await oe({submissionId:s,rejectReasonId:2,rejectReason:`Rate not approved`,rejectReasonComments:e}),i.message.success(`Submission rejected`),n?.({success:!0})}}),[s,n]);return u||!c?(0,o.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,o.jsx)(i.Spin,{size:`large`})}):(0,o.jsx)(Pf,{type:tf,record:c.record,lookups:c.lookups,identity:Lb(a,c.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:f,onClose:()=>n?.(),variant:`popup`})}Rb.propTypes={selectedIds:l.default.array,selectedRecords:l.default.array,onClose:l.default.func};var zb={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:Rb},Bb={submit:async()=>{}},Vb=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],Hb={title:`Reject`,okText:`Reject`,okButtonDanger:!0,width:480,successMessage:`Submission rejected successfully`,fields:[{name:`rejectReason`,label:`Rejection Reasons`,type:`select`,required:!0,placeholder:`Select rejection reasons`,defaultOptions:Vb.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},Ub={submit:async(e,t)=>{let n=Vb.find(t=>String(t.id)===String(e.rejectReason));await oe({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},Wb={delete:ab,"quick-submit":sb,"add-notes":lb,"tag-to-job":hb,"change-status":_b,"remove-from-shortlist":yb,"add-to-groups":xb,"self-assign":Cb,"others-assign":Tb,"sticky-notes":Db,"move-to-onboarding":kb,"approve-rate":Fb,"manager-approve":zb,reject:Hb},Gb={delete:ob,"quick-submit":cb,"add-notes":fb,"tag-to-job":gb,"change-status":vb,"remove-from-shortlist":bb,"add-to-groups":Sb,"self-assign":wb,"others-assign":Eb,"sticky-notes":Ob,"move-to-onboarding":Ab,"approve-rate":Ib,"manager-approve":Bb,reject:Ub};function Kb(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function qb(e,...t){for(let n of t){let t=String(n).split(`.`).reduce((e,t)=>e?.[t],e);if(t!=null&&t!==``)return t}return``}function Jb(e){let t=qb(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[qb(e,`firstName`,`first_name`),qb(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function Yb(e){return String(qb(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function Xb(e){return String(qb(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function Zb({open:n=!0,context:a={},onClose:s}){let[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(``),[m,h]=(0,r.useState)(!0),[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)(``),b=String(a.selectedIds?.[0]??a.selectedRecords?.[0]?._id??a.selectedRecords?.[0]?.id??a.batchId??``);(0,r.useEffect)(()=>{if(!n)return;let t=!1;return e.wn(`onboarding`,200,0).then(e=>{t||l(Kb(e))}).catch(e=>{t||y(e.message||`Unable to load onboarding candidates`)}).finally(()=>{t||h(!1)}),()=>{t=!0}},[n]);let x=(0,r.useMemo)(()=>{let e=f.trim().toLowerCase();return e?c.filter(t=>[Jb(t),qb(t,`email`,`candidateEmail`,`candidate_email`),qb(t,`status`,`onboardingStatus`,`onboarding_status`)].some(t=>String(t).toLowerCase().includes(e))):c},[c,f]);async function S(){if(!b){y(`Select a batch before adding candidates`);return}let n=c.filter(e=>u.includes(Xb(e)));if(n.length){_(!0),y(``);try{let{userId:r}=t.a();await Promise.all(n.map(t=>e.lt(`batchCandidates`,{schemaVersion:1,batchId:b,candidateId:Yb(t),workforceEngagementId:Xb(t),source:`ONBOARDING`,assignmentStatus:`ASSIGNED`,assignedAt:new Date().toISOString(),assignedBy:r??0,isDeleted:!1}))),i.message.success(`${n.length} candidate${n.length===1?``:`s`} added to the batch`),s?.({refresh:!0})}catch(e){y(e.message||`Unable to add candidates to the batch`)}finally{_(!1)}}}return(0,o.jsxs)(i.Modal,{open:n,title:`Add Candidate to Batch`,okText:`Add`,onOk:S,onCancel:()=>s?.(),okButtonProps:{disabled:u.length===0||!b,loading:g},cancelButtonProps:{disabled:g},closable:!g,maskClosable:!1,width:760,centered:!0,children:[v&&(0,o.jsx)(i.Alert,{type:`error`,showIcon:!0,message:v,style:{marginBottom:12}}),(0,o.jsx)(i.Input.Search,{allowClear:!0,placeholder:`Search onboarding candidates`,value:f,onChange:e=>p(e.target.value),style:{marginBottom:12}}),(0,o.jsx)(i.Table,{rowKey:e=>Xb(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>Jb(t)},{title:`Email`,key:`email`,render:(e,t)=>qb(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>qb(t,`status`,`onboardingStatus`,`onboarding_status`)||`—`}],dataSource:x,loading:m,size:`small`,pagination:{pageSize:10,showSizeChanger:!1},rowSelection:{selectedRowKeys:u,onChange:d,getCheckboxProps:e=>({disabled:!Yb(e)||!Xb(e)})},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var Qb={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function $b(e){if(!e)return null;let t=[...e.groups??[]].sort((e,t)=>Number(e.order??0)-Number(t.order??0)).flatMap(e=>[...e.fields??[]].filter(e=>e.show!==0&&e.show!==!1).sort((e,t)=>Number(e.order??0)-Number(t.order??0)).map(e=>({...e,name:e.name??e.field,label:e.label??e.field,type:Qb[String(e.type??`text`).toLowerCase()]??e.type??`input`,required:e.required??e.req===1,options:(e.options??[]).map(e=>({label:e.label??e.name??e.value,value:e.value??e.id??e.label}))})));return{title:e.label,fields:t}}function ex({apiMap:n={},extraConfigs:i={}}){let a=(0,r.useMemo)(()=>({...Gb,...n}),[n]),c=(0,r.useMemo)(()=>({...Wb,...i}),[i]),{popupKey:l}=(0,s.useParams)(),u=(0,s.useNavigate)(),{state:d={}}=(0,s.useLocation)(),[f,p]=(0,r.useState)({key:``,config:null});(0,r.useEffect)(()=>{let t=!1;if(!l||!d.moduleName)return;let n=`${d.moduleName}:${l}`;return e.jt(d.moduleName,`popup`,l).then(e=>{t||p({key:n,config:$b(e[0])})}).catch(()=>{t||p({key:n,config:null})}),()=>{t=!0}},[l,d.moduleName]);let m=(0,r.useMemo)(()=>{let e=c[l],t=`${d.moduleName}:${l}`,n=f.key===t?f.config:null;return n?{...e,...n}:e},[f,c,l,d.moduleName]),h=(0,r.useMemo)(()=>({selectedIds:d.selectedIds??[],selectedRecords:d.selectedRecords??[],moduleName:d.moduleName??``,navigate:u,...d.popupContext??{}}),[u,d.selectedIds,d.selectedRecords,d.moduleName,d.popupContext]),g=(0,r.useMemo)(()=>{let e=d.popupAction;return e?.apiPath?{submit:(n,r)=>{let i=String(e.apiMethod||`POST`).toUpperCase();return t.i(t.v,e.apiPath.startsWith(`/`)?e.apiPath:`/${e.apiPath}`,{method:i,body:[`GET`,`DELETE`].includes(i)?void 0:JSON.stringify({...n,selectedIds:r.selectedIds,selectedRecords:r.selectedRecords,moduleName:r.moduleName})})}}:{}},[d.popupAction]),_=()=>u(-1);return l===`add-batch-candidate`?(0,o.jsx)(Zb,{open:!0,context:h,onClose:_}):(0,o.jsx)(ib,{open:!0,config:m,context:h,onClose:_,api:{...a[l]??{},...g}})}var tx={title:`Vendor Share`,maxVendorSelect:1e3,defaultTab:`myVendor`,defaultPageSize:10,vendorTabs:[{key:`myVendor`,label:`My Vendors`},{key:`allVendor`,label:`All Vendors`}],vendorColumns:[{title:`Vendor Name`,dataIndex:`vendorName`,key:`vendorName`},{title:`Email`,dataIndex:`vendorEmail`,key:`vendorEmail`},{title:`Location`,dataIndex:`vendorLocation`,key:`vendorLocation`},{title:`Updated On`,dataIndex:`updatedOn`,key:`updatedOn`}]},nx={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>vt({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>yt(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>bt({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},rx=tx.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function ix(){let e=(0,s.useNavigate)(),t=(0,s.useLocation)(),{selectedIds:n=[],selectedRecords:c=[],recipients:l=[],subject:u=``,onSend:d,moduleName:f=``,popupAction:p={}}=t.state??{},m=n[0]??c[0]?._id??c[0]?.id,[h,g]=(0,r.useState)({to:l.join(`, `),cc:``,bcc:``,subject:u,contents:``,showCc:!1,showBcc:!1}),[_,v]=(0,r.useState)(!m),[y,b]=(0,r.useState)(tx.defaultTab),[x,S]=(0,r.useState)(``),[C,w]=(0,r.useState)([]),[T,E]=(0,r.useState)(0),[D,O]=(0,r.useState)(0),[k,A]=(0,r.useState)(0),[j,M]=(0,r.useState)(1),[N,P]=(0,r.useState)(tx.defaultPageSize),[F,I]=(0,r.useState)(!1),[L,R]=(0,r.useState)([]);(0,r.useEffect)(()=>{if(!m)return;let e=!1;I(!0);let t=x?100:N,n=x?0:(j-1)*N;return nx.getVendorList({jobId:m,limit:t,offset:n,type:y}).then(t=>{if(e)return;let n=t?.data?.vendorList??t?.data??[],r=t?.data?.myVendorCount??0,i=t?.data?.allVendorCount??0;w(Array.isArray(n)?n:[]),E(r),O(i),A(y===`myVendor`?r:i)}).catch(()=>{e||(w([]),A(0))}).finally(()=>{e||I(!1)}),()=>{e=!0}},[m,y,j,N,x]),(0,r.useEffect)(()=>{m&&nx.getMailDetails(m).then(e=>g(t=>({...t,subject:e.subject||t.subject,contents:e.contents||t.contents,to:e.toMail?.length?Array.isArray(e.toMail)?e.toMail.join(`, `):String(e.toMail):t.to,cc:e.ccMail?.length?Array.isArray(e.ccMail)?e.ccMail.join(`, `):String(e.ccMail):t.cc}))).catch(()=>{}).finally(()=>v(!0))},[m]);let z=(0,r.useMemo)(()=>L.map(e=>C.find(t=>t.vendorId===e)?.vendorEmail??``).filter(Boolean),[L,C]),B=(0,r.useMemo)(()=>({...h,bcc:[...new Set([...jv(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function V(e){let t=new Set(z);g({...e,bcc:jv(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let H=(jv(B.to).length||jv(B.bcc).length)&&Mv(B.to)&&Mv(B.cc)&&Mv(B.bcc)&&B.subject.trim(),U=e=>e===`myVendor`?T:D;function W(){e(-1)}function G(){H&&nx.submit({jobId:m,toMail:jv(B.to),ccMail:jv(B.cc),bccMail:jv(B.bcc),subject:B.subject,contents:B.contents}).then(t=>{t?.status===!0?(i.message.success(t?.data||`Mail sent successfully.`),typeof d==`function`&&d({...B,message:B.contents,selectedIds:n}),e(-1)):i.message.error(t?.message||t?.data||`Failed to send mail. Please try again.`)}).catch(e=>{i.message.error(e?.message||`Failed to send mail. Please try again.`)})}let ee=(0,r.useMemo)(()=>{if(!x)return C;let e=x.toLowerCase();return C.filter(t=>(t.vendorName??``).toLowerCase().includes(e)||(t.vendorEmail??``).toLowerCase().includes(e)||(t.vendorLocation??``).toLowerCase().includes(e))},[C,x]);return(0,o.jsx)(i.Drawer,{open:!0,placement:`right`,onClose:W,closable:!1,rootClassName:`vendor-share`,width:`95%`,footer:(0,o.jsxs)(`div`,{className:`vendor-share__footer`,children:[(0,o.jsx)(i.Button,{onClick:W,children:`Cancel`}),(0,o.jsx)(i.Button,{type:`primary`,disabled:!H,onClick:G,children:`Send`})]}),children:(0,o.jsxs)(`div`,{className:`vendor-share__body`,children:[(0,o.jsxs)(`div`,{className:`vendor-share__left`,children:[(0,o.jsxs)(`div`,{className:`vendor-share__vendor-header`,children:[(0,o.jsxs)(`div`,{className:`vendor-share__vendor-header-row`,children:[(0,o.jsx)(i.Button,{type:`text`,icon:(0,o.jsx)(a.CloseOutlined,{}),onClick:W,size:`small`,style:{marginRight:8}}),(0,o.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,o.jsx)(a.TeamOutlined,{})}),(0,o.jsx)(`span`,{className:`dynamic-popup__header-label`,children:`Vendor List`}),(0,o.jsxs)(`div`,{className:`vendor-share__vendor-search`,children:[(0,o.jsx)(a.SearchOutlined,{className:`vendor-share__search-icon`}),(0,o.jsx)(i.Input,{variant:`borderless`,placeholder:`Search vendor`,value:x,onChange:e=>{S(e.target.value),M(1)},className:`vendor-share__search-input`})]})]}),(0,o.jsx)(`div`,{className:`vendor-share__vendor-tabs`,children:tx.vendorTabs.map(e=>(0,o.jsxs)(`span`,{className:`vendor-share__vendor-tab${y===e.key?` vendor-share__vendor-tab--active`:``}`,onClick:()=>{b(e.key),M(1),R([])},children:[e.label,` (`,U(e.key),`)`]},e.key))})]}),(0,o.jsx)(`div`,{className:`vendor-share__vendor-table-wrapper`,children:(0,o.jsx)(i.Table,{rowKey:e=>e.vendorId,columns:rx,dataSource:ee,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>tx.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,o.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,o.jsx)(ge,{current:j,pageSize:N,total:k,onChange:e=>M(e),onPageSizeChange:e=>P(e)})})]}),(0,o.jsx)(`div`,{className:`vendor-share__right`,children:(0,o.jsx)(Lv,{value:B,onChange:V,moduleName:f,defaultTemplateId:p.defaultTemplateId??t.state?.defaultTemplateId??``,ready:_,contextRecords:c,title:`Share`,hint:`Select vendors or add email addresses`,bccHint:`Vendor emails are added automatically`,afterBcc:L.length>0?(0,o.jsxs)(`div`,{className:`vendor-share__selected-count`,children:[L.length,` / `,tx.maxVendorSelect,` Vendors selected`]}):null})})]})})}var ax={EMAIL:/^[a-zA-Z0-9._%+-]+@[a-zA-Z][a-zA-Z-]*\.[a-zA-Z]{2,}$/,PHONE:/^[0-9]{10}$/,PASSWORD:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/,ALPHABETS:/^[A-Za-z ]+$/,ALPHANUMERIC:/^(?!\s)[A-Za-z0-9 ]+$/,NUMBER:/^[0-9]+$/,URL:/^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+(com|org|net|in|co|io|gov|edu)(\/[^\s]*)?$/i,CANDIDATE_ID:/^[A-Za-z0-9-]+$/,REMARKS:/^[A-Za-z0-9\s.,'"\-()!?/@#$%&]*$/,DESIGNATION:/^[a-zA-Z0-9\s,.\-&()]{2,100}$/,DOB:/^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/\d{4}$/,COMPANY_NAME:/^[A-Za-z0-9\s&.,'()-]+$/,FIRST_NAME:/^[A-Z][a-zA-Z]*$/,FULL_NAME:/^[A-Z][a-zA-Z]*(?: [A-Z][a-zA-Z]*)*$/,NO_SPACES:/^\S+$/,STARTS_WITH_CAPITAL:/^[A-Z].*$/},ox={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},sx={REQUIRED:e=>`Mandatory Field`,INVALID_EMAIL:`Please enter a valid email address.`,INVALID_PHONE:`Phone number must contain exactly 10 digits.`,INVALID_PASSWORD:`Password must contain uppercase, lowercase, number, special character and minimum 8 characters.`,INVALID_ALPHABETS:`Only alphabets and spaces are allowed.`,INVALID_ALPHANUMERIC:`Only letters, numbers and spaces are allowed.`,INVALID_NUMBER:`Only numbers are allowed.`,INVALID_URL:`Please enter a valid URL.`,INVALID_CANDIDATE_ID:e=>`${e} can contain only letters, numbers and hyphens.`,INVALID_REMARKS:`Remarks contain invalid characters.`,INVALID_DESIGNATION:`Designation contains invalid characters.`,INVALID_DOB:`DOB must be in MM/DD/YYYY format.`,INVALID_LINKEDIN:`Please enter a valid LinkedIn URL.`,INVALID_COMPANY_NAME:`Company name contains invalid characters.`,INVALID_FIRST_NAME:`First letter must be capital and spaces are not allowed.`,INVALID_FULL_NAME:`Each word must start with a capital letter.`,NO_SPACES_ALLOWED:`Spaces are not allowed.`,MUST_START_WITH_CAPITAL:`First letter must be capital.`,INVALID_FILE_TYPE:`Only JPG, PNG and PDF files are allowed.`,INVALID_FILE_SIZE:`File upload must be ${ox.MAX_FILE_SIZE} MB below.`,INVALID_FILE_TYPE:`Only JPG, PNG and PDF files are allowed.`,SINGLE_FILE_ONLY:`Only one file can be uploaded.`},cx={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},lx={REMARKS_MIN:10,REMARKS_MAX:250},ux={removeSpaces:(e=``)=>e.replace(/\s/g,``),capitalizeFirstLetter:(e=``)=>e.charAt(0).toUpperCase()+e.slice(1),capitalizeWords:(e=``)=>e.replace(/\b\w/g,e=>e.toUpperCase()),removeExtraSpaces:(e=``)=>e.replace(/\s+/g,` `).trim(),firstNameFormatter:(e=``)=>e.replace(/\s+/g,` `).trimStart().replace(/\b\w/g,e=>e.toUpperCase()),fullNameFormatter:(e=``)=>e.replace(/\s+/g,` `).trimStart().replace(/\b\w/g,e=>e.toUpperCase()),phoneFormatter:(e=``)=>e.replace(/\D/g,``).slice(0,10),dobFormatter:(e=``)=>{let t=e.replace(/\D/g,``);return t.length<=2?t:t.length<=4?`${t.slice(0,2)}/${t.slice(2)}`:`${t.slice(0,2)}/${t.slice(2,4)}/${t.slice(4,8)}`}},dx={required:(e=`Field`)=>({required:!0,message:sx.REQUIRED(e)}),email:()=>({pattern:ax.EMAIL,message:sx.INVALID_EMAIL}),phone:()=>({pattern:ax.PHONE,message:sx.INVALID_PHONE}),password:()=>({pattern:ax.PASSWORD,message:sx.INVALID_PASSWORD}),alphabets:()=>({pattern:ax.ALPHABETS,message:sx.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:ax.ALPHANUMERIC,message:sx.INVALID_ALPHANUMERIC}),number:()=>({pattern:ax.NUMBER,message:sx.INVALID_NUMBER}),url:()=>({pattern:ax.URL,message:sx.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:ax.CANDIDATE_ID,message:sx.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:ax.REMARKS,message:sx.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${lx.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${lx.REMARKS_MAX} characters.`}),designation:()=>({pattern:ax.DESIGNATION,message:sx.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!ax.DOB.test(n))return Promise.reject(Error(sx.INVALID_DOB));let r=(0,c.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(sx.INVALID_DOB));let i=(0,c.default)().endOf(`day`);return r.isAfter(i)?Promise.reject(Error(`Date of Birth cannot be a future date.`)):i.diff(r,`year`)<21?Promise.reject(Error(`Age must be at least 21 years.`)):Promise.resolve()}}),linkedin:()=>({pattern:ax.LINKEDIN,message:sx.INVALID_LINKEDIN}),companyName:()=>({pattern:ax.COMPANY_NAME,message:sx.INVALID_COMPANY_NAME}),firstName:()=>({pattern:ax.FIRST_NAME,message:sx.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${cx.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${cx.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:cx.FIRST_NAME_MIN,message:sx.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:cx.FIRST_NAME_MAX,message:sx.FIRST_NAME_MAX}),remarksMinLength:()=>({min:lx.REMARKS_MIN,message:sx.REMARKS_MIN}),remarksMaxLength:()=>({max:lx.REMARKS_MAX,message:sx.REMARKS_MAX}),fullName:()=>({pattern:ax.FULL_NAME,message:sx.INVALID_FULL_NAME}),noSpaces:()=>({pattern:ax.NO_SPACES,message:sx.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:ax.STARTS_WITH_CAPITAL,message:sx.MUST_START_WITH_CAPITAL}),fileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();for(let e of t){let t=e.originFileObj||e;if(!(t.size/1024/1024<=ox.MAX_FILE_SIZE))return i.message.error(sx.INVALID_FILE_SIZE),Promise.reject(Error(sx.INVALID_FILE_SIZE));if(!ox.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(sx.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>ox.SINGLE_FILE_COUNT)return Promise.reject(Error(sx.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<ox.MAX_FILE_SIZE?ox.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(sx.INVALID_FILE_TYPE)):Promise.reject(Error(sx.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>ox.MULTI_FILE_COUNT)return Promise.reject(Error(sx.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<ox.MAX_FILE_SIZE))return Promise.reject(Error(sx.INVALID_FILE_SIZE));if(!ox.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(sx.INVALID_FILE_TYPE))}return Promise.resolve()}})},fx={beforeUpload:e=>[`image/jpeg`,`image/png`,`application/pdf`].includes(e.type)?e.size/1024/1024<=2?!1:(i.message.error(`File upload must be 2 MB below.`),i.Upload.LIST_IGNORE):(i.message.error(`Only JPG, PNG and PDF files are allowed.`),i.Upload.LIST_IGNORE)},px=()=>{let[e]=i.Form.useForm();return(0,o.jsx)(`div`,{style:{padding:24},children:(0,o.jsxs)(i.Form,{form:e,layout:`vertical`,onFinish:e=>{console.log(`Form Values:`,e)},autoComplete:`off`,children:[(0,o.jsxs)(i.Row,{gutter:16,children:[(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Email`,name:`email`,rules:[dx.required(`Email`),dx.email()],children:(0,o.jsx)(i.Input,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Phone Number`,name:`phone`,rules:[dx.required(`Phone Number`),dx.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:ux.phoneFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Password`,name:`password`,rules:[dx.required(`Password`),dx.password()],children:(0,o.jsx)(i.Input.Password,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Full Name`,name:`fullName`,rules:[dx.required(`Full Name`),dx.alphabets(),dx.firstNameMinLength(),dx.firstNameMaxLength()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({fullName:ux.firstNameFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Username`,name:`username`,rules:[dx.required(`Username`),dx.alphanumeric()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({username:ux.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Website URL`,name:`website`,rules:[dx.required(`Website URL`),dx.url()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({website:ux.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`MSP Req ID`,name:`mspreqID`,rules:[dx.required(`MSP Req ID`),dx.candidateId(`MSP Req ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({mspreqID:ux.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[dx.required(`Candidate ID`),dx.candidateId(`Candidate ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({candidateId:ux.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:24,children:(0,o.jsx)(i.Form.Item,{label:`Remarks`,name:`remarks`,rules:[dx.required(`Remarks`),dx.remarks(),dx.remarksMinLength(),dx.remarksMaxLength()],children:(0,o.jsx)(i.Input.TextArea,{rows:4})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Designation`,name:`designation`,rules:[dx.required(`Designation`),dx.designation()],children:(0,o.jsx)(i.Input,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Date of Birth`,name:`dob`,rules:[dx.dob()],children:(0,o.jsx)(i.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:ux.dobFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Company Name`,name:`companyName`,rules:[dx.required(`Company Name`),dx.companyName()],children:(0,o.jsx)(i.Input,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{name:`contractType`,label:`Contract Type`,children:(0,o.jsxs)(i.Select,{showSearch:!0,allowClear:!0,filterOption:(e,t)=>(t?.label??``).toLowerCase().includes(e.toLowerCase()),children:[(0,o.jsx)(i.Select.Option,{value:`C2C`,label:`C2C`,children:`C2C`}),(0,o.jsx)(i.Select.Option,{value:`W2-Contract`,label:`W2-Contract`,children:`W2-Contract`}),(0,o.jsx)(i.Select.Option,{value:`W2-Fulltime`,label:`W2-Fulltime`,children:`W2-Fulltime`}),(0,o.jsx)(i.Select.Option,{value:`1099`,label:`1099`,children:`1099`})]})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{name:`candidateProposedRateCurrency`,label:`Currency`,children:(0,o.jsxs)(i.Select,{showSearch:!0,allowClear:!0,children:[(0,o.jsx)(i.Select.Option,{value:`$`,children:`$`}),(0,o.jsx)(i.Select.Option,{value:`₹`,children:`₹`}),(0,o.jsx)(i.Select.Option,{value:`€`,children:`€`}),(0,o.jsx)(i.Select.Option,{value:`zł`,children:`zł`}),(0,o.jsx)(i.Select.Option,{value:`£`,children:`£`}),(0,o.jsx)(i.Select.Option,{value:`kr`,children:`kr`}),(0,o.jsx)(i.Select.Option,{value:`Fr`,children:`Fr`}),(0,o.jsx)(i.Select.Option,{value:`kr`,children:`kr`})]})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Resume new`,name:`resume`,children:(0,o.jsx)(i.Upload,{beforeUpload:fx.beforeUpload,maxCount:1,children:(0,o.jsx)(i.Button,{children:`Upload Resume`})})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Documents`,name:`documents`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[dx.multiFileUpload()],children:(0,o.jsx)(i.Upload,{multiple:!0,beforeUpload:fx.beforeUpload,children:(0,o.jsx)(i.Button,{children:`Upload Documents`})})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Upload File`,name:`file`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[dx.fileUpload()],children:(0,o.jsx)(i.Upload,{beforeUpload:fx.beforeUpload,maxCount:1,children:(0,o.jsx)(i.Button,{children:`Upload`})})})})]}),(0,o.jsx)(i.Row,{children:(0,o.jsx)(i.Form.List,{name:`users`,children:(e,{add:t,remove:n})=>(0,o.jsxs)(o.Fragment,{children:[e.map(({key:e,name:t,...r})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{required:!0,...r,rules:[{required:!0,message:`First name is requried`}],name:[t,`first`],children:(0,o.jsx)(i.Input,{placeholder:`First Name`})})}),(0,o.jsx)(i.Col,{span:11,children:(0,o.jsx)(i.Form.Item,{...r,required:!0,name:[t,`last`],children:(0,o.jsx)(i.Input,{placeholder:`Last Name`})})}),(0,o.jsx)(i.Col,{span:1,children:(0,o.jsx)(a.MinusCircleOutlined,{onClick:()=>n(t)})})]})),(0,o.jsx)(i.Form.Item,{children:(0,o.jsx)(i.Button,{type:`dashed`,onClick:()=>t(),block:!0,icon:(0,o.jsx)(a.PlusOutlined,{}),children:`Add field`})})]})})}),(0,o.jsxs)(i.Form.Item,{children:[(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,children:`Submit`}),(0,o.jsx)(i.Button,{style:{marginLeft:10},onClick:()=>e.resetFields(),children:`Reset`})]})]})})};function mx(e){return(0,o.jsx)(Up,{children:(0,o.jsx)(Ev,{...e})})}var{Text:hx}=i.Typography,gx=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],_x={fileText:(0,o.jsx)(a.FileTextOutlined,{}),checkCircle:(0,o.jsx)(a.CheckCircleOutlined,{}),user:(0,o.jsx)(a.UserOutlined,{}),filter:(0,o.jsx)(a.FilterOutlined,{})};function vx({stats:e=gx}){return(0,o.jsx)(i.Card,{children:(0,o.jsx)(i.Row,{gutter:[12,12],children:e.map(e=>(0,o.jsx)(i.Col,{xs:24,sm:24,md:8,lg:8,xl:8,children:(0,o.jsxs)(i.Card,{className:`stats-inner-card`,children:[(0,o.jsxs)(i.Space,{align:`center`,children:[_x[e.icon]??_x.fileText,(0,o.jsx)(hx,{children:e.label})]}),(0,o.jsx)(i.Statistic,{value:e.value})]})},e.label))})})}var{Text:yx}=i.Typography;function bx(e){return e?.USER_NAME??e?.user_name??e?.username??e?.name??e?.full_name??e?.fullName??e?.email??`User ${e?.USER_ID??e?.user_id??`?`}`}function xx(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:bx(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function Sx(){let[t,n]=(0,r.useState)([]),[s,c]=(0,r.useState)(0),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(1),[p,m]=(0,r.useState)(10),[h,g]=(0,r.useState)(``),_=(0,r.useCallback)(async({offset:t,limit:r,searchQuery:a}={})=>{u(!0);try{let i=await e.Et({offset:t,limit:r,searchQuery:a??``}),o=(i.users??[]).map(xx);n(o),c(i.total??o.length)}catch{i.message.error(`Failed to load users`)}finally{u(!1)}},[]);return(0,r.useEffect)(()=>{queueMicrotask(()=>{_({offset:(d-1)*p,limit:p,searchQuery:h})})},[_,d,p,h]),(0,o.jsx)(Z,{icon:(0,o.jsx)(a.TeamOutlined,{}),title:`Users`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,o.jsx)(du,{listName:`Users`,dataSource:t,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,o.jsxs)(`div`,{children:[(0,o.jsx)(yx,{strong:!0,style:{fontSize:13},children:e}),t._email&&(0,o.jsx)(`div`,{style:{fontSize:11,color:`var(--color-text-muted)`},children:t._email})]})},{label:`Role`,value:`_role`,width:180}],loading:l,total:s,current:d,pageSize:p,onPageChange:e=>f(e),onPageSizeChange:e=>{m(e),f(1)},onSearch:e=>{g(e),f(1)}})})}var{Text:Cx}=i.Typography,wx=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],Tx=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function Ex({field:e,index:t,onToggle:n,onReorder:s}){let c=(0,r.useRef)(null),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(!1);function p(e){c.current=t,e.dataTransfer.effectAllowed=`move`,f(!0)}function m(){f(!1),u(!1)}function h(e){e.preventDefault(),u(!0)}function g(){u(!1)}function _(e){e.preventDefault(),u(!1),c.current!==null&&c.current!==t&&s(c.current,t),c.current=null}return(0,o.jsxs)(`div`,{draggable:!0,onDragStart:p,onDragEnd:m,onDragOver:h,onDragLeave:g,onDrop:_,className:`uss-field-row with-edit${l?` drag-over`:``}${d?` dragging`:``}`,children:[(0,o.jsx)(`span`,{className:`uss-drag-handle`,children:(0,o.jsx)(a.HolderOutlined,{})}),(0,o.jsxs)(`span`,{className:`uss-field-name`,children:[e.fieldName,(0,o.jsx)(`span`,{className:`uss-field-key`,children:e.fieldKey})]}),(0,o.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,o.jsx)(i.Switch,{size:`small`,checked:e.isVisible,onChange:e=>n(t,`isVisible`,e)})}),(0,o.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,o.jsx)(i.Switch,{size:`small`,checked:!!e.isEditable,onChange:e=>n(t,`isEditable`,e)})}),(0,o.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,o.jsx)(i.Switch,{size:`small`,checked:!!e.ismandatory,onChange:e=>n(t,`ismandatory`,e)})})]})}function Dx({team:t,configType:n}){let[a,s]=(0,r.useState)({}),[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)({}),[f,p]=(0,r.useState)(`job`);(0,r.useEffect)(()=>{t&&(l(!0),e.Xt(t,n).then(s).catch(()=>i.message.error(`Failed to load field config`)).finally(()=>l(!1)))},[t,n]);let m=a[f]??[];function h(e,t){s(n=>({...n,[e]:typeof t==`function`?t(n[e]??[]):t}))}function g(e,t,n){h(f,r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))}function _(e,t){h(f,n=>{let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r.map((e,t)=>({...e,order:t}))})}async function v(){let r=f;d(e=>({...e,[r]:!0}));try{await e.vn(t,r,m,n),i.message.success(`Saved`)}catch{i.message.error(`Save failed`)}finally{d(e=>({...e,[r]:!1}))}}return(0,o.jsxs)(i.Spin,{spinning:c,children:[(0,o.jsx)(i.Tabs,{size:`small`,activeKey:f,onChange:p,items:wx.map(e=>({key:e.key,label:e.label}))}),(0,o.jsxs)(`div`,{className:`uss-field-header with-edit`,children:[(0,o.jsx)(`span`,{}),(0,o.jsx)(`span`,{children:`Field`}),(0,o.jsx)(`span`,{style:{textAlign:`center`},children:`Visible`}),(0,o.jsx)(`span`,{style:{textAlign:`center`},children:`Editable`}),(0,o.jsx)(`span`,{style:{textAlign:`center`},children:`Mandatory`})]}),(0,o.jsxs)(`div`,{className:`uss-field-list`,children:[m.length===0&&!c&&(0,o.jsx)(`div`,{className:`uss-empty`,children:`No fields found.`}),m.map((e,t)=>(0,o.jsx)(Ex,{field:e,index:t,onToggle:g,onReorder:_},e.fieldKey??t))]}),(0,o.jsx)(`div`,{className:`uss-modal-footer`,children:(0,o.jsxs)(i.Button,{type:`primary`,size:`small`,loading:u[f],onClick:v,children:[`Save `,wx.find(e=>e.key===f)?.label]})})]})}function Ox(){let[t,n]=(0,r.useState)(null),[s,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(`listView`),[p,m]=(0,r.useState)([]),[h,g]=(0,r.useState)(0),[_,v]=(0,r.useState)(!1),[y,b]=(0,r.useState)(``),[x,S]=(0,r.useState)(!1),C=(0,r.useCallback)(async()=>{v(!0);try{let t=await e.Tt();m(t.teams),g(t.total)}catch{i.message.error(`Failed to load teams`)}finally{v(!1)}},[]);(0,r.useEffect)(()=>{C()},[C]);function w(e){n(e),f(`listView`),c(!0)}function T(e){n(e),b(e.teamName??``),u(!0)}async function E(){if(!y.trim()){i.message.warning(`Team name is required`);return}S(!0);try{await e._n(t,{teamName:y.trim(),managerId:t.managerId,memberIds:t.memberIds}),i.message.success(`Team updated`),u(!1),C()}catch{i.message.error(`Failed to update team`)}finally{S(!1)}}return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(Z,{icon:(0,o.jsx)(a.TeamOutlined,{}),title:`Teams`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,o.jsx)(du,{listName:`Teams`,dataSource:p,fields:[{label:`Team Name`,value:`teamName`,width:200},{label:`Manager`,value:`manager`,width:200},{label:`Members`,value:`memberCount`,width:90,sorter:!1},{label:`Actions`,value:`_actions`,width:160,sorter:!1,render:(e,t)=>(0,o.jsxs)(`div`,{style:{display:`flex`,gap:4},children:[(0,o.jsx)(i.Button,{size:`small`,type:`link`,onClick:()=>T(t),children:`Edit`}),(0,o.jsx)(i.Button,{size:`small`,type:`link`,onClick:()=>w(t),children:`Configure`})]})}],loading:_,total:h})}),(0,o.jsx)(i.Modal,{open:l,onCancel:()=>u(!1),title:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.TeamOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),`Edit Team`]}),width:420,footer:null,destroyOnClose:!0,children:(0,o.jsxs)(`div`,{className:`uss-edit-team-body`,style:{paddingTop:12},children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`uss-edit-team-label`,children:`Team Name`}),(0,o.jsx)(i.Input,{value:y,onChange:e=>b(e.target.value),onPressEnter:E,placeholder:`Enter team name`})]}),(0,o.jsxs)(`div`,{className:`uss-modal-footer`,children:[(0,o.jsx)(i.Button,{onClick:()=>u(!1),children:`Cancel`}),(0,o.jsx)(i.Button,{type:`primary`,loading:x,onClick:E,children:`Save`})]})]})}),(0,o.jsxs)(i.Modal,{className:`uss-modal`,open:s,onCancel:()=>c(!1),title:(0,o.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,o.jsx)(a.TeamOutlined,{style:{color:`var(--color-brand)`}}),(0,o.jsxs)(`span`,{children:[`Configure: `,t?.teamName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,o.jsx)(`div`,{style:{marginBottom:12},children:(0,o.jsx)(`div`,{className:`uss-config-toggle`,children:Tx.map(e=>(0,o.jsx)(`button`,{className:`uss-config-btn${d===e.key?` active`:``}`,onClick:()=>f(e.key),children:e.label},e.key))})}),t&&(0,o.jsx)(Dx,{team:t,configType:d},`${t?.teamId}-${d}`)]})]})}var kx=[`view`,`add`,`edit`,`delete`],Ax={view:`View`,add:`Add`,edit:`Edit`,delete:`Delete`,sourcing:`Sourcing`,assign:`Assign`,share:`Share`,change_status:`Status`,my_jobs:`My Jobs`,all_jobs:`All Jobs`};function jx(e){return Ax[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Mx(e){let t=kx.filter(t=>e.includes(t)),n=e.filter(e=>!kx.includes(e)).sort();return[...t,...n]}function Nx(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),Mx([...t])}function Px(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{Qm(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function Fx({value:e,onSave:t,className:n}){let[i,s]=(0,r.useState)(!1),[c,l]=(0,r.useState)(e);(0,r.useEffect)(()=>{l(e)},[e]);function u(){s(!1);let n=c.trim();n&&n!==e?t(n):l(e)}return i?(0,o.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input${n?` ${n}`:``}`,value:c,style:{width:Math.max(48,c.length*8)},onChange:e=>l(e.target.value),onBlur:u,onKeyDown:t=>{t.key===`Enter`&&u(),t.key===`Escape`&&(s(!1),l(e)),t.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,o.jsxs)(`span`,{className:`perm-editable-name${n?` ${n}`:``}`,onDoubleClick:e=>{e.stopPropagation(),s(!0)},children:[e,(0,o.jsx)(a.EditOutlined,{className:`perm-name-edit-icon`})]})}function Ix({entry:e,label:t,onToggle:n,onLabelSave:s}){let[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)(t),f=e?.value===`1`,p=!!e;(0,r.useEffect)(()=>{d(t)},[t]);function m(){l(!1);let e=u.trim();e&&e!==t?s(e):d(t)}return(0,o.jsx)(i.Tooltip,{title:p?f?`Click to disable`:`Click to enable`:`Not applicable for this module`,children:(0,o.jsxs)(`div`,{className:`perm-action-pill${f?` on`:``}${p?``:` na`}`,onClick:()=>{!c&&p&&n()},children:[(0,o.jsx)(`span`,{className:`perm-action-pill-dot${f?` on`:``}`}),c?(0,o.jsx)(`input`,{autoFocus:!0,className:`perm-pill-input`,value:u,style:{width:Math.max(36,u.length*7)},onChange:e=>d(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&(l(!1),d(t)),e.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,o.jsx)(`span`,{className:`perm-action-pill-label`,onDoubleClick:e=>{e.stopPropagation(),l(!0)},children:t}),f&&!c&&(0,o.jsx)(a.CheckOutlined,{className:`perm-action-pill-check`})]})})}function Lx({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:s,onActionLabelSave:c}){let l=t?.permissions??{},u=n.filter(t=>Qm(e,t)),d=u.filter(e=>l[e]?.value===`1`).length,f=u.filter(e=>l[e]).length,p=f>0&&d===f;return(0,o.jsxs)(`div`,{className:`perm-module-card${p?` all-on`:d>0&&!p?` some-on`:``}`,children:[(0,o.jsxs)(`div`,{className:`perm-module-card-header`,children:[(0,o.jsx)(Fx,{value:i,onSave:t=>s(e,t),className:`perm-module-card-name`}),f>0&&(0,o.jsxs)(`span`,{className:`perm-module-card-badge${d>0?` active`:``}`,children:[d,`/`,f]})]}),(0,o.jsx)(`div`,{className:`perm-module-card-body`,children:u.map(t=>(0,o.jsx)(Ix,{entry:l[t],label:a[t]??jx(t),onToggle:()=>r(e,t),onLabelSave:e=>c(t,e)},t))})]})}function Rx({role:t,moduleLabels:n={},actionLabels:s={},onModuleLabelSave:c=()=>{},onActionLabelSave:l=()=>{}}){let[u,d]=(0,r.useState)({}),[f,p]=(0,r.useState)({}),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)(!1),b=e.Kt(t);(0,r.useEffect)(()=>{b&&(h(!0),y(!1),e.Jt(b).then(e=>{d(e),p(e)}).catch(()=>i.message.error(`Failed to load permissions`)).finally(()=>h(!1)))},[b]);function x(e,t){y(!0),p(n=>{let r=n[e]??{menuId:u[e]?.menuId??0,permissions:{}},i=r.permissions?.[t]??{id:0,value:`0`};return{...n,[e]:{...r,permissions:{...r.permissions,[t]:{...i,value:i.value===`1`?`0`:`1`}}}}})}async function S(){_(!0);try{await e.hn(b,f),d(f),y(!1),i.message.success(`Permissions saved`)}catch(e){i.message.error(e?.message||`Save failed`)}finally{_(!1)}}let C=(0,r.useMemo)(()=>Object.keys(f).sort(),[f]),w=(0,r.useMemo)(()=>Nx(f),[f]),{enabled:T,total:E}=(0,r.useMemo)(()=>Px(f),[f]);return(0,o.jsxs)(i.Spin,{spinning:m,children:[(0,o.jsxs)(`div`,{className:`perm-panel-header`,children:[(0,o.jsxs)(`div`,{className:`perm-panel-title`,children:[(0,o.jsx)(a.LockOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),(0,o.jsx)(`span`,{children:t?.roleName}),!m&&E>0&&(0,o.jsxs)(i.Tag,{color:`blue`,style:{marginLeft:8,fontSize:11},children:[T,`/`,E,` enabled`]})]}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,icon:(0,o.jsx)(a.UnlockOutlined,{}),loading:g,disabled:!v,onClick:S,children:`Save Changes`})]}),(0,o.jsxs)(`div`,{className:`perm-hint`,children:[(0,o.jsx)(a.InfoCircleOutlined,{className:`perm-hint-icon`}),(0,o.jsxs)(`span`,{children:[`Click a pill to toggle. `,(0,o.jsx)(`strong`,{children:`Double-click`}),` a module name or action label to rename it — labels are saved locally.`]})]}),C.length===0&&!m?(0,o.jsx)(`div`,{className:`perm-empty`,children:`No permission entries found for this role.`}):(0,o.jsx)(`div`,{className:`perm-cards-grid`,children:C.map(e=>(0,o.jsx)(Lx,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:n[e]??e,actionLabels:s,onModuleLabelSave:c,onActionLabelSave:l},e))})]})}var{Text:zx}=i.Typography,Bx=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function Vx(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function Hx(e){return String(e||``).trim().toLowerCase()}function Ux(e){return e?.key||e?.collectionName||e?.value||``}function Wx(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=Ux(e);if(!t)return;let o=Hx(e.key||t),s=Hx(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||Vx(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=Hx(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:Vx(t),value:t,disabled:!1}))}),n}function Gx(){let[t,n]=(0,r.useState)(null),[s,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(`listView`),[d,f]=(0,r.useState)([]),[p,m]=(0,r.useState)(0),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)([]),[y,b]=(0,r.useState)([]),[x,S]=(0,r.useState)(!1),[C,w]=(0,r.useState)(!1),T=(0,r.useMemo)(()=>_.filter(e=>!e.disabled),[_]),E=!x&&T.length===0,D=(0,r.useCallback)(async()=>{g(!0);try{let t=await e.wt();f(t.roles),m(t.total)}catch{i.message.error(`Failed to load roles`)}finally{g(!1)}},[]),O=(0,r.useCallback)(async()=>{S(!0);try{let[t,n]=await Promise.all([e.Pt(),e.Ot()]),r=Wx(t.modules,n),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));v(r),b(e=>e.filter(e=>i.has(e)))}catch{i.message.error(`Failed to load seed status`)}finally{S(!1)}},[]);(0,r.useEffect)(()=>{D()},[D]),(0,r.useEffect)(()=>{O()},[O]);async function k(){if(y.length===0){i.message.warning(E?`All modules already seeded.`:`Select at least one module to seed.`);return}w(!0);try{await e.sn(y),i.message.success(`Role field config seeded`),b([]),await O()}catch(e){i.message.error(e?.message||`Seed failed`)}finally{w(!1)}}function A(e,t=`listView`){n(e),u(t),c(!0)}return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,o.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,o.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,o.jsx)(i.Select,{mode:`multiple`,allowClear:!0,showSearch:!0,value:y,options:_,placeholder:E?`All modules already seeded`:`Select modules or collections to seed`,disabled:x||C||E,loading:x,onChange:b,style:{width:`100%`}})}),(0,o.jsx)(i.Button,{type:`primary`,loading:C,disabled:x||y.length===0,onClick:k,children:`Seed Field Config`})]}),(0,o.jsx)(zx,{type:`secondary`,style:{display:`block`,marginTop:8,fontSize:12},children:E?`Seed is disabled because all configured modules already have role field config data.`:`Already seeded modules are disabled. New modules or collections can still be seeded.`})]}),(0,o.jsx)(Z,{icon:(0,o.jsx)(a.SafetyOutlined,{}),title:`Roles`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,o.jsx)(du,{listName:`Roles`,dataSource:d,fields:[{label:`Role Name`,value:`roleName`,width:200},{label:`Description`,value:`description`,width:240},{label:`Users`,value:`userCount`,width:70,sorter:!1},{label:`Actions`,value:`_configure`,width:200,sorter:!1,render:(e,t)=>(0,o.jsxs)(i.Space,{size:2,children:[(0,o.jsx)(i.Button,{size:`small`,type:`link`,onClick:()=>A(t),children:`Configure`}),(0,o.jsx)(i.Button,{size:`small`,type:`link`,icon:(0,o.jsx)(a.LockOutlined,{}),onClick:()=>A(t,`permissions`),children:`Permissions`})]})}],loading:h,total:p})}),(0,o.jsxs)(i.Modal,{className:`uss-modal`,open:s,onCancel:()=>c(!1),title:(0,o.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,o.jsx)(a.SafetyOutlined,{style:{color:`var(--color-brand)`}}),(0,o.jsxs)(`span`,{children:[`Configure: `,t?.roleName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,o.jsx)(`div`,{style:{marginBottom:12},children:(0,o.jsx)(`div`,{className:`uss-config-toggle`,children:Bx.map(e=>(0,o.jsx)(`button`,{className:`uss-config-btn${l===e.key?` active`:``}`,onClick:()=>u(e.key),children:e.label},e.key))})}),t&&(l===`permissions`?(0,o.jsx)(Rx,{role:t},t?.roleId):(0,o.jsx)(mh,{role:t,configType:l},`${t?.roleId}-${l}`))]})]})}var Kx=`perm-module-labels`,qx=`perm-action-labels`;function Jx(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function Yx(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function Xx({label:e,onSave:t,onDelete:n,loading:s}){let[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)(e);function f(){l(!1);let n=u.trim();n&&n!==e?t(n):d(e)}return(0,o.jsxs)(`div`,{className:`perm-manage-row`,children:[c?(0,o.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input`,value:u,style:{flex:1,minWidth:0},onChange:e=>d(e.target.value),onBlur:f,onKeyDown:t=>{t.key===`Enter`&&f(),t.key===`Escape`&&(l(!1),d(e))}}):(0,o.jsx)(`span`,{className:`perm-manage-row-label`,children:e}),(0,o.jsxs)(`div`,{className:`perm-manage-row-actions`,children:[(0,o.jsx)(i.Button,{type:`text`,size:`small`,icon:(0,o.jsx)(a.EditOutlined,{}),onClick:()=>{d(e),l(!0)},loading:s}),(0,o.jsx)(i.Popconfirm,{title:`Delete this item?`,onConfirm:n,okText:`Delete`,cancelText:`Cancel`,okType:`danger`,children:(0,o.jsx)(i.Button,{type:`text`,size:`small`,icon:(0,o.jsx)(a.DeleteOutlined,{}),danger:!0})})]})]})}function Zx({open:t,onClose:n}){let[s,c]=(0,r.useState)(`modules`),[l,u]=(0,r.useState)([]),[d,f]=(0,r.useState)(!1),[p,m]=(0,r.useState)(``),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)([]),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(``),[C,w]=(0,r.useState)(``),[T,E]=(0,r.useState)(!1);(0,r.useEffect)(()=>{t&&(D(),O())},[t]);async function D(){f(!0);try{u(await e.Rt())}catch{i.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await e.Lt())}catch{i.message.error(`Failed to load actions`)}finally{b(!1)}}async function k(){let t=p.trim();if(!t){i.message.warning(`Enter a module name`);return}g(!0);try{let n=await e.st({menuName:t});u(e=>[...e,n]),m(``),i.message.success(`Module added`)}catch{i.message.error(`Failed to add module`)}finally{g(!1)}}async function A(t,n){try{await e.dn(t,{menuName:n}),u(e=>e.map(e=>e.MENUID===t?{...e,MENUNAME:n}:e))}catch{i.message.error(`Failed to update module`)}}async function j(t){try{await e.ht(t),u(e=>e.filter(e=>e.MENUID!==t)),i.message.success(`Module deleted`)}catch{i.message.error(`Failed to delete module`)}}async function M(){let t=x.trim(),n=C.trim().toLowerCase().replace(/\s+/g,`_`);if(!t||!n){i.message.warning(`Enter both name and key`);return}E(!0);try{let r=await e.ot({permissionName:t,permissionKey:n});v(e=>[...e,r]),S(``),w(``),i.message.success(`Action added`)}catch(e){i.message.error(e?.message?.includes(`409`)||e?.status===409?`Permission key already exists`:`Failed to add action`)}finally{E(!1)}}async function N(t,n){try{await e.un(t,{permissionName:n}),v(e=>e.map(e=>e.permissionId===t?{...e,permissionName:n}:e))}catch{i.message.error(`Failed to update action`)}}async function P(t){try{await e.mt(t),v(e=>e.filter(e=>e.permissionId!==t)),i.message.success(`Action deleted`)}catch{i.message.error(`Failed to delete action`)}}let F=[{key:`modules`,label:`Modules`,children:(0,o.jsxs)(i.Spin,{spinning:d,children:[(0,o.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,o.jsx)(i.Input,{placeholder:`Module name`,value:p,onChange:e=>m(e.target.value),onPressEnter:k,style:{flex:1},size:`small`}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,icon:(0,o.jsx)(a.PlusOutlined,{}),loading:h,onClick:k,children:`Add`})]}),(0,o.jsxs)(`div`,{className:`perm-manage-list`,children:[l.length===0&&!d&&(0,o.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No modules found`}),l.map(e=>(0,o.jsx)(Xx,{label:e.MENUNAME,onSave:t=>A(e.MENUID,t),onDelete:()=>j(e.MENUID)},e.MENUID))]})]})},{key:`actions`,label:`Actions`,children:(0,o.jsxs)(i.Spin,{spinning:y,children:[(0,o.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,o.jsx)(i.Input,{placeholder:`Action name (e.g. Approve)`,value:x,onChange:e=>S(e.target.value),style:{flex:1},size:`small`}),(0,o.jsx)(i.Input,{placeholder:`Key (e.g. approve)`,value:C,onChange:e=>w(e.target.value),onPressEnter:M,style:{width:140},size:`small`}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,icon:(0,o.jsx)(a.PlusOutlined,{}),loading:T,onClick:M,children:`Add`})]}),(0,o.jsxs)(`div`,{className:`perm-manage-list`,children:[_.length===0&&!y&&(0,o.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No actions found`}),_.map(e=>(0,o.jsx)(Xx,{label:`${e.permissionName} (${e.permissionKey})`,onSave:t=>N(e.permissionId,t),onDelete:()=>P(e.permissionId)},e.permissionId))]})]})}];return(0,o.jsx)(i.Modal,{open:t,onCancel:n,title:(0,o.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,o.jsx)(a.SettingOutlined,{style:{color:`var(--color-brand)`}}),`Manage Modules & Actions`]}),width:520,footer:null,destroyOnClose:!0,children:(0,o.jsx)(i.Tabs,{activeKey:s,onChange:c,size:`small`,items:F})})}function Qx(){let[t,n]=(0,r.useState)([]),[s,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(null),[d,f]=(0,r.useState)(``),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(()=>Jx(Kx)),[_,v]=(0,r.useState)(()=>Jx(qx)),y=(0,r.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return Yx(Kx,r),r})},[]),b=(0,r.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return Yx(qx,r),r})},[]);function x(){g({}),v({}),Yx(Kx,{}),Yx(qx,{}),i.message.success(`Labels reset to defaults`)}let S=(0,r.useCallback)(async()=>{c(!0);try{let{roles:t}=await e.wt();n(t),t.length>0&&u(t[0])}catch{i.message.error(`Failed to load roles`)}finally{c(!1)}},[]);(0,r.useEffect)(()=>{S()},[S]);let C=(0,r.useMemo)(()=>{let e=d.trim().toLowerCase();return e?t.filter(t=>t.roleName.toLowerCase().includes(e)):t},[t,d]),w=Object.keys(h).length>0||Object.keys(_).length>0;return(0,o.jsxs)(`div`,{className:`perm-page`,children:[(0,o.jsxs)(Z,{className:`perm-left-card`,icon:(0,o.jsx)(a.SafetyOutlined,{}),title:`Roles`,bodyStyle:{padding:0},children:[(0,o.jsx)(`div`,{className:`perm-role-search`,children:(0,o.jsx)(i.Input,{prefix:(0,o.jsx)(a.SearchOutlined,{}),placeholder:`Search roles…`,allowClear:!0,size:`small`,value:d,onChange:e=>f(e.target.value)})}),(0,o.jsx)(i.Spin,{spinning:s,children:(0,o.jsxs)(`div`,{className:`perm-role-list`,children:[C.length===0&&!s&&(0,o.jsx)(`div`,{className:`perm-role-empty`,children:`No roles found`}),C.map(e=>{let t=l?.roleId===e.roleId,n=e.description&&e.description!==`N/A`?e.description:e.roleType===0?`Default role`:`Custom role`;return(0,o.jsxs)(`div`,{className:`perm-role-item${t?` active`:``}`,onClick:()=>u(e),children:[(0,o.jsx)(`div`,{className:`perm-role-item-name`,children:e.roleName}),(0,o.jsx)(`div`,{className:`perm-role-item-desc`,children:n})]},e.roleId)})]})})]}),(0,o.jsx)(Z,{className:`perm-right-card`,icon:(0,o.jsx)(a.LockOutlined,{}),title:`Module Permissions`,extra:(0,o.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[w&&(0,o.jsx)(`button`,{className:`perm-reset-btn`,onClick:x,children:`Reset labels`}),(0,o.jsx)(i.Button,{size:`small`,icon:(0,o.jsx)(a.SettingOutlined,{}),onClick:()=>m(!0),children:`Manage`})]}),bodyStyle:{padding:`12px 16px`},children:l?(0,o.jsx)(Rx,{role:l,moduleLabels:h,actionLabels:_,onModuleLabelSave:y,onActionLabelSave:b},l.roleId):(0,o.jsx)(`div`,{className:`perm-empty`,children:`Select a role from the left to manage its permissions.`})}),(0,o.jsx)(Zx,{open:p,onClose:()=>m(!1)})]})}var{Title:$x,Text:eS}=i.Typography,tS=[{label:`In Progress`,value:107,sub:`Under review`,color:`blue`},{label:`Hired`,value:2,sub:`Onboarded`,color:`green`},{label:`Project Completed`,value:2,sub:`Project cycle closed`,color:`purple`},{label:`Archive`,value:2,sub:`No longer active`,color:`peach`}];function nS({items:e=tS}){return(0,o.jsx)(i.Card,{className:`onboarding-card`,title:(0,o.jsx)($x,{level:5,children:`Onboarding`}),extra:(0,o.jsx)(i.Button,{type:`link`,children:`View all`}),children:(0,o.jsx)(i.Row,{gutter:[12,12],children:e.map(e=>(0,o.jsx)(i.Col,{xs:12,sm:6,md:6,lg:12,xl:12,children:(0,o.jsxs)(`div`,{className:`onboarding-item ${e.color}`,children:[(0,o.jsx)(eS,{className:`onboarding-item-label`,children:e.label}),(0,o.jsx)(i.Statistic,{value:e.value,className:`onboarding-stat`}),(0,o.jsx)(`div`,{className:`onboarding-item-footer`,children:(0,o.jsx)(eS,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:rS,Title:iS}=i.Typography,aS=[{group:`Dashboard`,items:[{id:`dashboard`,label:`Admin Dashboard`,icon:(0,o.jsx)(a.DashboardOutlined,{})}]},{group:`Settings`,items:[{id:`org`,label:`Organization`,icon:(0,o.jsx)(a.BankOutlined,{}),heading:`Organization Settings`,desc:`Manage your company profile and location details`,cards:[{label:`Company Information`,icon:(0,o.jsx)(a.BankOutlined,{}),desc:`Manage company profile, address and business details.`},{label:`Location`,icon:(0,o.jsx)(a.BuildOutlined,{}),desc:`Manage office locations, branches and regions.`}]},{id:`users`,label:`Users`,icon:(0,o.jsx)(a.UserOutlined,{}),heading:`Users`,desc:`Manage platform users and configure their field views.`,component:`users`},{id:`teams`,label:`Teams`,icon:(0,o.jsx)(a.TeamOutlined,{}),heading:`Teams`,desc:`Organize users into teams and configure field visibility per team.`,component:`teams`},{id:`roles`,label:`Roles`,icon:(0,o.jsx)(a.SafetyOutlined,{}),heading:`Roles`,desc:`Control permissions and configure field visibility per role.`,component:`roles`},{id:`permissions`,label:`Permissions`,icon:(0,o.jsx)(a.LockOutlined,{}),heading:`Permissions`,desc:`Manage module-wise action permissions (view, add, edit, delete, and more) per role.`,component:`permissions`},{id:`templates`,label:`Templates`,icon:(0,o.jsx)(a.FileTextOutlined,{}),heading:`Templates`,desc:`Email and signature templates for communications`,component:`templates`},{id:`ai-services`,label:`AI Services`,icon:(0,o.jsx)(a.ThunderboltOutlined,{}),heading:`AI Services`,desc:`Register the AI/automation backends (base URL + auth) that admin-configured AI Actions call.`,component:`ai-services`}]},{group:`Clients`,items:[{id:`clients`,label:`Clients`,icon:(0,o.jsx)(a.BankOutlined,{}),heading:`Clients`,desc:`Manage client accounts and settings`,cards:[{label:`Clients`,icon:(0,o.jsx)(a.BankOutlined,{}),desc:`Manage client companies and account details.`}]}]},{group:`Forms`,items:[{id:`form-groups`,label:`Form Groups`,icon:(0,o.jsx)(a.AppstoreAddOutlined,{}),heading:`Form Groups`,desc:`Define field groups for module add/edit forms with validations and dropdown sources.`,component:`form-groups`},{id:`detail-groups`,label:`Detail Groups`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),heading:`Detail Groups`,desc:`Customize the detail view per module: labels, prefix/suffix, colour, capitalization, reference lookups and merged fields.`,component:`detail-groups`},{id:`row-actions`,label:`Actions`,icon:(0,o.jsx)(a.ToolOutlined,{}),heading:`Actions`,desc:`Configure which action buttons appear per row in each module's list view, scoped per role.`,component:`row-actions`}]},{group:`Master`,items:[{id:`jobs`,label:`Jobs`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),heading:`Jobs Master`,desc:`Configure job sources and status types`,cards:[{label:`Sources`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),desc:`Manage job source master values.`},{label:`Job Status`,icon:(0,o.jsx)(a.CheckCircleOutlined,{}),desc:`Configure job workflow status.`}]},{id:`candidates`,label:`Candidates`,icon:(0,o.jsx)(a.UserOutlined,{}),heading:`Candidates Master`,desc:`Skills, sources and work authorization settings`,cards:[{label:`Sources`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),desc:`Manage candidate source values.`},{label:`Skills`,icon:(0,o.jsx)(a.SettingOutlined,{}),desc:`Manage skill master data.`},{label:`Work Authorization`,icon:(0,o.jsx)(a.SafetyOutlined,{}),desc:`Manage visa and authorization types.`}]},{id:`submissions`,label:`Submissions`,icon:(0,o.jsx)(a.FileTextOutlined,{}),heading:`Submissions Master`,desc:`Rejection reasons and submission status configuration`,cards:[{label:`Rejection Reasons`,icon:(0,o.jsx)(a.FileTextOutlined,{}),desc:`Manage common rejection reasons.`},{label:`Client Submission Status`,icon:(0,o.jsx)(a.CheckCircleOutlined,{}),desc:`Manage client submission statuses.`}]},{id:`clientmaster`,label:`Client Master`,icon:(0,o.jsx)(a.BankOutlined,{}),heading:`Client Master`,desc:`Payment terms, client types and contact types`,cards:[{label:`Payment Terms`,icon:(0,o.jsx)(a.FileTextOutlined,{}),desc:`Manage billing and payment terms.`},{label:`Client Type`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),desc:`Classify client business types.`},{label:`Client Contact Type`,icon:(0,o.jsx)(a.TeamOutlined,{}),desc:`Manage client contact categories.`}]}]}],oS=[{label:`Sourced`,count:312,color:`#378ADD`,pct:35},{label:`Screened`,count:223,color:`#7F77DD`,pct:25},{label:`Interview`,count:161,color:`#1D9E75`,pct:18},{label:`Offered`,count:107,color:`#EF9F27`,pct:12},{label:`Rejected`,count:89,color:`#E24B4A`,pct:10}],sS=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],cS=[{text:`New candidate Ravi Kumar added to Java Developer role`,time:`2 min ago`,color:`#378ADD`},{text:`Submission approved by Acme Corp for Sr. React Dev`,time:`18 min ago`,color:`#1D9E75`},{text:`User Priya S. added to Recruiters team`,time:`1 hr ago`,color:`#7F77DD`},{text:`Job Data Analyst — TechFlow moved to archived`,time:`3 hr ago`,color:`#EF9F27`},{text:`Candidate rejected — work authorization mismatch`,time:`5 hr ago`,color:`#E24B4A`}];function lS(){return(0,o.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.DashboardOutlined,{}),title:`Admin Dashboard`,children:[(0,o.jsx)(`div`,{className:`admin-accent-bar`}),(0,o.jsx)(iS,{level:5,children:`Admin Dashboard`}),(0,o.jsx)(rS,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,o.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,o.jsx)(vx,{stats:[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`},{label:`Total Candidates`,value:4320,icon:`team`},{label:`Submissions`,value:892,icon:`fileText`}]})}),(0,o.jsxs)(`div`,{className:`admin-dashboard-mid-row`,children:[(0,o.jsx)(nS,{}),(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,o.jsx)(rS,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,o.jsx)(`div`,{className:`admin-pipeline-bar`,children:oS.map(e=>(0,o.jsx)(`div`,{className:`admin-pipeline-seg`,style:{width:`${e.pct}%`,background:e.color}},e.label))}),(0,o.jsx)(`div`,{className:`admin-pipeline-legend`,children:oS.map(e=>(0,o.jsxs)(`div`,{className:`admin-pipeline-legend-item`,children:[(0,o.jsx)(`span`,{className:`admin-pipeline-dot`,style:{background:e.color}}),e.label,` `,e.count]},e.label))}),(0,o.jsx)(`div`,{className:`admin-divider`}),(0,o.jsx)(rS,{strong:!0,style:{fontSize:12},children:`Submission status`}),(0,o.jsxs)(`div`,{className:`admin-sub-status-list`,style:{marginTop:6},children:[(0,o.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,o.jsx)(rS,{style:{fontSize:13},children:`Pending client review`}),(0,o.jsx)(`span`,{className:`admin-badge warn`,children:`312`})]}),(0,o.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,o.jsx)(rS,{style:{fontSize:13},children:`Client approved`}),(0,o.jsx)(`span`,{className:`admin-badge success`,children:`248`})]}),(0,o.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,o.jsx)(rS,{style:{fontSize:13},children:`Rejected`}),(0,o.jsx)(`span`,{className:`admin-badge danger`,children:`89`})]})]})]})]}),(0,o.jsxs)(`div`,{className:`admin-dashboard-bottom-row`,children:[(0,o.jsx)(Z,{icon:(0,o.jsx)(a.BankOutlined,{}),title:`Top Clients`,extra:(0,o.jsx)(i.Button,{type:`link`,size:`small`,children:`View all`}),children:sS.map(e=>(0,o.jsxs)(`div`,{className:`admin-client-row`,children:[(0,o.jsxs)(`div`,{className:`admin-client-left`,children:[(0,o.jsx)(`div`,{className:`admin-client-icon`,children:(0,o.jsx)(a.BankOutlined,{})}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`admin-client-name`,children:e.name}),(0,o.jsxs)(`div`,{className:`admin-client-sub`,children:[e.jobs,` open jobs`]})]})]}),(0,o.jsxs)(`div`,{className:`admin-client-right`,children:[(0,o.jsx)(`div`,{className:`admin-client-val`,children:e.candidates}),(0,o.jsx)(`div`,{className:`admin-client-sub`,children:`candidates`})]})]},e.name))}),(0,o.jsx)(Z,{icon:(0,o.jsx)(a.BellOutlined,{}),title:`Recent Activity`,children:cS.map((e,t)=>(0,o.jsxs)(`div`,{className:`admin-activity-row`,children:[(0,o.jsx)(`div`,{className:`admin-activity-dot`,style:{background:e.color}}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`admin-activity-text`,children:e.text}),(0,o.jsx)(`div`,{className:`admin-activity-time`,children:e.time})]})]},t))})]}),(0,o.jsx)(Z,{icon:(0,o.jsx)(a.SettingOutlined,{}),title:`Admin Configuration Overview`,extra:(0,o.jsx)(i.Button,{type:`link`,size:`small`,children:`Manage`}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsxs)(i.Col,{span:8,children:[(0,o.jsx)(rS,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Settings`}),[[`Organization`,2],[`User Settings`,4],[`Templates`,2]].map(([e,t])=>(0,o.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,o.jsx)(rS,{style:{fontSize:12},children:e}),(0,o.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,o.jsxs)(i.Col,{span:8,children:[(0,o.jsx)(rS,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Master`}),[[`Jobs`,2],[`Candidates`,3],[`Submissions`,2]].map(([e,t])=>(0,o.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,o.jsx)(rS,{style:{fontSize:12},children:e}),(0,o.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,o.jsxs)(i.Col,{span:8,children:[(0,o.jsx)(rS,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`System`}),[[`Total Groups`,4],[`Total Modules`,9],[`Config Items`,19]].map(([e,t])=>(0,o.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,o.jsx)(rS,{style:{fontSize:12},children:e}),(0,o.jsx)(rS,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function uS({activeSection:e,activeGroup:t,filteredCards:n,searchText:r,setSearchText:s,allItems:c,handleNav:l}){return(0,o.jsxs)(i.Row,{gutter:[16,16],children:[(0,o.jsx)(i.Col,{span:24,children:(0,o.jsxs)(Z,{icon:e?.icon,title:e?.heading,extra:(0,o.jsx)(i.Input,{className:`admin-search`,prefix:(0,o.jsx)(a.SearchOutlined,{}),placeholder:`Search settings…`,allowClear:!0,value:r,onChange:e=>s(e.target.value)}),children:[(0,o.jsx)(`div`,{className:`admin-accent-bar`}),(0,o.jsx)(iS,{level:5,children:e?.heading}),(0,o.jsx)(rS,{type:`secondary`,children:e?.desc})]})}),(0,o.jsx)(i.Col,{xs:24,xl:16,style:{alignSelf:`flex-start`},children:(0,o.jsx)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Configuration Items`,extra:(0,o.jsxs)(rS,{type:`secondary`,children:[n.length,` item`,n.length===1?``:`s`]}),children:(0,o.jsx)(i.Row,{gutter:[14,14],children:n.length>0?n.map(e=>(0,o.jsx)(i.Col,{xs:24,sm:12,xl:8,children:(0,o.jsxs)(`div`,{className:`admin-config-item`,children:[(0,o.jsx)(`div`,{className:`admin-config-top-bar`}),(0,o.jsxs)(`div`,{className:`admin-config-body`,children:[(0,o.jsx)(`div`,{className:`admin-config-icon`,children:e.icon}),(0,o.jsxs)(`div`,{className:`admin-config-text`,children:[(0,o.jsx)(`span`,{className:`admin-config-label`,children:e.label}),(0,o.jsx)(`span`,{className:`admin-config-desc`,children:e.desc})]})]}),(0,o.jsx)(`div`,{className:`admin-config-divider`}),(0,o.jsx)(i.Button,{type:`link`,size:`small`,className:`admin-config-manage`,icon:(0,o.jsx)(a.RightOutlined,{}),iconPosition:`end`,children:`Manage`})]})},e.label)):(0,o.jsx)(i.Col,{span:24,children:(0,o.jsx)(`div`,{className:`admin-config-empty`,children:(0,o.jsx)(i.Empty,{description:`No settings found`,image:i.Empty.PRESENTED_IMAGE_SIMPLE})})})})})}),(0,o.jsx)(i.Col,{xs:24,xl:8,style:{alignSelf:`flex-start`},children:(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`Section Overview`,children:[(0,o.jsx)(`div`,{className:`admin-overview-list`,children:aS.filter(e=>e.group!==`Dashboard`).map(e=>{let n=e.group===t?.group;return(0,o.jsxs)(`div`,{className:`admin-overview-item${n?` active`:``}`,onClick:()=>{let t=e.items[0];t&&l(t.id)},children:[(0,o.jsxs)(`div`,{className:`admin-overview-left`,children:[(0,o.jsx)(`div`,{className:`admin-overview-icon`,children:e.items[0]?.icon}),(0,o.jsxs)(`div`,{className:`admin-overview-text`,children:[(0,o.jsx)(`span`,{className:`admin-overview-name`,children:e.group}),(0,o.jsxs)(`span`,{className:`admin-overview-sub`,children:[e.items.length,` module`,e.items.length===1?``:`s`]})]})]}),(0,o.jsx)(`span`,{className:`admin-overview-count${n?` active`:``}`,children:e.items.length})]},e.group)})}),(0,o.jsxs)(`div`,{className:`admin-overview-footer`,children:[(0,o.jsx)(`span`,{className:`admin-overview-footer-label`,children:`Total configuration items`}),(0,o.jsx)(`span`,{className:`admin-overview-footer-value`,children:c.filter(e=>e.cards).reduce((e,t)=>e+t.cards.length,0)})]})]})})]})}function dS(){let[e,t]=(0,r.useState)(`dashboard`),[n,s]=(0,r.useState)(``),c=(0,r.useMemo)(()=>aS.flatMap(e=>e.items),[]),l=(0,r.useMemo)(()=>c.find(t=>t.id===e),[c,e]),u=(0,r.useMemo)(()=>aS.find(t=>t.items.some(t=>t.id===e)),[e]),d=(0,r.useMemo)(()=>{if(!l?.cards)return[];let e=n.trim().toLowerCase();return e?l.cards.filter(t=>t.label.toLowerCase().includes(e)||t.desc.toLowerCase().includes(e)):l.cards},[l,n]),f=(0,r.useMemo)(()=>aS.map(e=>({key:e.group,type:`group`,label:e.group,children:e.items.map(e=>({key:e.id,icon:e.icon,label:e.label}))})),[]),p=e=>{t(e),s(``)};return e===`dashboard`||l?.heading,(0,o.jsxs)(`main`,{className:`admin-page`,children:[(0,o.jsx)(`div`,{className:`admin-breadcrumb`,children:(0,o.jsx)(i.Breadcrumb,{items:[{title:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.HomeOutlined,{}),` Home`]})},{title:`Admin`}]})}),(0,o.jsxs)(i.Row,{gutter:[16,16],className:`admin-wrapper`,children:[(0,o.jsx)(i.Col,{xs:24,lg:6,xl:5,children:(0,o.jsxs)(Z,{title:`Admin Console`,icon:(0,o.jsx)(a.SettingOutlined,{}),children:[(0,o.jsxs)(`div`,{className:`admin-sidebar-banner`,children:[(0,o.jsx)(`span`,{className:`admin-sidebar-banner-title`,children:`Admin Panel`}),(0,o.jsx)(`span`,{className:`admin-sidebar-banner-sub`,children:`Configuration Center`}),(0,o.jsxs)(i.Row,{gutter:[8,0],children:[(0,o.jsx)(i.Col,{span:12,children:(0,o.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,o.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Groups`}),(0,o.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:aS.length})]})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,o.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Modules`}),(0,o.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:c.length})]})})]})]}),(0,o.jsx)(i.Menu,{mode:`inline`,selectedKeys:[e],items:f,onClick:({key:e})=>p(e),className:`admin-sidebar-menu`})]})}),(0,o.jsx)(i.Col,{xs:24,lg:18,xl:19,children:e===`dashboard`?(0,o.jsx)(lS,{}):l?.component===`form-groups`?(0,o.jsx)(og,{}):l?.component===`detail-groups`?(0,o.jsx)(kg,{}):l?.component===`row-actions`?(0,o.jsx)(g_,{}):l?.component===`users`?(0,o.jsx)(Sx,{}):l?.component===`teams`?(0,o.jsx)(Ox,{}):l?.component===`roles`?(0,o.jsx)(Gx,{}):l?.component===`permissions`?(0,o.jsx)(Qx,{}):l?.component===`templates`?(0,o.jsx)(T_,{}):l?.component===`ai-services`?(0,o.jsx)(k_,{}):(0,o.jsx)(uS,{activeSection:l,activeGroup:u,filteredCards:d,searchText:n,setSearchText:s,allItems:c,handleNav:p})})]})]})}var{Title:fS}=i.Typography;function pS(){let e=(0,s.useNavigate)(),{state:t}=(0,s.useLocation)(),n=t?.moduleName||`stickyNotes`,r=t?.title||`Sticky Notes`,c={...t?.request,params:{...t?.request?.params,limit:200,offset:0}};return(0,o.jsxs)(`div`,{children:[(0,o.jsx)(i.Button,{type:`text`,icon:(0,o.jsx)(a.ArrowLeftOutlined,{}),onClick:()=>e(-1),style:{marginBottom:12},children:`Back`}),(0,o.jsx)(at,{moduleName:n,title:r,columns:4,request:c,viewAll:!1})]})}var{Text:mS,Title:hS}=i.Typography,gS=10*1024*1024,_S=`/templates/test_cases_flow_template.base64.txt`,vS=`test_cases_flow_template.xlsx`,yS=`module | subModule | step_order | description | actions | key | value | expected | scenario`,bS={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},xS=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function SS(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result).split(`,`)[1]),r.onerror=n,r.readAsDataURL(e)})}function CS(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function wS(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function TS({errors:e}){return(0,o.jsx)(`div`,{className:`bulk-tooltip-errors`,children:(e??[]).map((e,t)=>(0,o.jsx)(`div`,{children:e.message},`${e.field}-${t}`))})}function ES({errors:e,expanded:t,onToggle:n,onSummaryClick:r}){return e.length===0?null:(0,o.jsxs)(`div`,{className:`bulk-error-banner`,children:[(0,o.jsxs)(`div`,{className:`bulk-error-summary`,children:[(0,o.jsxs)(`button`,{type:`button`,className:`bulk-error-summary-main`,onClick:r,"aria-label":`Scroll to first invalid row`,children:[(0,o.jsx)(a.ExclamationCircleOutlined,{className:`bulk-error-icon`}),(0,o.jsxs)(`span`,{children:[e.length,` validation error(s) found`]})]}),(0,o.jsx)(i.Button,{type:`link`,onClick:n,"aria-expanded":t,children:t?`Hide Errors`:`View Errors`})]}),t&&(0,o.jsx)(`div`,{className:`bulk-error-list`,role:`region`,"aria-label":`Validation error details`,children:e.map((e,t)=>(0,o.jsxs)(`div`,{className:`bulk-error-line`,children:[(0,o.jsxs)(`span`,{className:`bulk-row-chip`,children:[`Row `,e.id]}),(0,o.jsx)(`span`,{children:e.message})]},`${e.id}-${e.field}-${t}`))})]})}function DS({rows:e,view:t,onViewChange:n,onConfirm:r,onReset:s,saving:c,firstInvalidRowId:l,firstInvalidRowRef:u}){let d=e.filter(e=>e.row_status===`invalid`),f=t===`errors`?d:e,p=d.length>0||c;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(i.Row,{justify:`space-between`,align:`middle`,gutter:[16,16],className:`bulk-table-toolbar`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space.Compact,{children:[(0,o.jsx)(i.Button,{type:t===`all`?`primary`:`default`,onClick:()=>n(`all`),children:`All rows`}),(0,o.jsx)(i.Button,{type:t===`errors`?`primary`:`default`,onClick:()=>n(`errors`),children:`Errors only`})]})}),(0,o.jsx)(i.Col,{children:(0,o.jsxs)(mS,{type:`secondary`,children:[e.length,` row(s)`]})})]}),(0,o.jsx)(`div`,{className:`bulk-table-wrap`,children:(0,o.jsxs)(`table`,{className:`bulk-preview-table`,children:[(0,o.jsx)(`thead`,{children:(0,o.jsxs)(`tr`,{children:[(0,o.jsx)(`th`,{className:`bulk-col-row`,children:`Row`}),(0,o.jsx)(`th`,{className:`bulk-col-flow`,children:`Submodule`}),(0,o.jsx)(`th`,{className:`bulk-col-description`,children:`Description`}),(0,o.jsx)(`th`,{className:`bulk-col-keyword`,children:`Action`}),(0,o.jsx)(`th`,{className:`bulk-col-target`,children:`Key`}),(0,o.jsx)(`th`,{className:`bulk-col-status`,children:`Status`}),(0,o.jsx)(`th`,{className:`bulk-col-error`,children:`Error`})]})}),(0,o.jsx)(`tbody`,{children:f.map(e=>{let t=e.errors??[],n=e.row_status===`invalid`;return(0,o.jsxs)(`tr`,{ref:n&&e.id===l?u:null,className:n?`bulk-row-invalid`:``,children:[(0,o.jsx)(`td`,{children:e.id}),(0,o.jsx)(`td`,{title:e.submodule,children:e.submodule}),(0,o.jsx)(`td`,{title:e.description,children:e.description?e.description:(0,o.jsx)(`span`,{className:`bulk-empty-text`,children:`-empty-`})}),(0,o.jsx)(`td`,{children:(0,o.jsx)(`code`,{className:`bulk-code-chip`,children:e.actions})}),(0,o.jsx)(`td`,{title:e.key,children:e.key}),(0,o.jsx)(`td`,{children:n?(0,o.jsx)(i.Tag,{color:`red`,children:`Error`}):(0,o.jsx)(i.Tag,{color:`green`,children:`Valid`})}),(0,o.jsx)(`td`,{children:n?(0,o.jsx)(i.Tooltip,{title:(0,o.jsx)(TS,{errors:t}),placement:`left`,children:(0,o.jsxs)(`button`,{type:`button`,className:`bulk-error-info`,"aria-label":`View ${t.length} error(s) for row ${e.id}`,children:[(0,o.jsx)(a.InfoCircleOutlined,{}),(0,o.jsx)(i.Badge,{count:t.length,size:`small`})]})}):(0,o.jsx)(`span`,{className:`bulk-error-none`,children:`-`})})]},`${e.id}-${e.step_order}`)})})]})}),(0,o.jsxs)(i.Space,{className:`bulk-actions`,children:[(0,o.jsx)(i.Button,{icon:(0,o.jsx)(a.ReloadOutlined,{}),onClick:s,children:`Reset`}),(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.SaveOutlined,{}),loading:c,disabled:p,onClick:r,children:d.length>0?`Fix ${d.length} error(s) to proceed`:`Save to database`})]})]})}function OS(){let n=(0,s.useNavigate)(),c=(0,r.useMemo)(()=>t.s(),[]),l=(0,r.useRef)(null),u=(0,r.useRef)(null),[d,f]=(0,r.useState)([]),[p,m]=(0,r.useState)(``),[h,g]=(0,r.useState)(`idle`),[_,v]=(0,r.useState)(!1),[y,b]=(0,r.useState)(null),[x,S]=(0,r.useState)([]),[C,w]=(0,r.useState)(`all`),[T,E]=(0,r.useState)(null),[D,O]=(0,r.useState)(null),[k,A]=(0,r.useState)(!1),j=d.map(e=>({value:e.modulename,label:e.modulename})),M=wS(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=bS[h]??0,I=x.find(e=>e.row_status===`invalid`)?.id,L=(0,r.useCallback)(()=>{m(``),g(`idle`),v(!1),b(null),S([]),w(`all`),E(null),O(null),l.current&&(l.current.value=``)},[]);(0,r.useEffect)(()=>{async function e(){try{f((await om({project:c?.name??``,activeOnly:!0}))?.items??[])}catch(e){console.error(e),i.message.error(`Unable to load modules.`)}}e()},[c?.name]);let R=e=>{m(e??``),S([]),O(null),E(null),b(null),A(!1),g(e?`module_set`:`idle`)},z=async e=>{if(!e||!P)return;let t=e.name.split(`.`).pop()?.toLowerCase();if(![`xlsx`,`csv`].includes(t)){g(`module_set`),E({message:`Invalid file type. Please upload an Excel .xlsx or CSV .csv file.`});return}if(e.size>gS){g(`module_set`),E({message:`File must be 10 MB or smaller.`});return}E(null),S([]),O(null),b({name:e.name,size:e.size}),g(`encoding`);try{let n=await SS(e);g(`validating`),S((await tm({filename:e.name,project:c?.name??``,module:p,file_base64:n,file_type:t}))?.rows??[]),w(`all`),g(`preview`)}catch(e){console.error(e),E(e.payload??{code:`NETWORK_ERROR`,message:e.message||`Could not reach the server.`}),g(`error`)}},B=async()=>{try{let e=await fetch(_S);if(!e.ok)throw Error(`Template file not found (${e.status})`);let t=(await e.text()).trim(),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);let a=new Blob([r],{type:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=vS,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o),i.message.success(`Sample template downloaded.`)}catch(e){console.error(e),i.message.error(`Unable to download sample template.`)}},V=async()=>{g(`inserting`),E(null);try{O(await nm({project:c?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:CS(x)})),g(`done`),i.message.success(`Bulk upload saved. Redirecting to view test cases...`),window.setTimeout(()=>n(`/viewTestCase`),900)}catch(e){console.error(e),E(e.payload??{code:`NETWORK_ERROR`,message:e.message||`Could not reach the server.`}),g(`preview`)}},H=(0,r.useCallback)(()=>{u.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[]),U=[`bulk-dropzone`,_?`bulk-dropzone-dragging`:``,y?`bulk-dropzone-has-file`:``,T&&h!==`preview`?`bulk-dropzone-error`:``,p?``:`bulk-dropzone-disabled`].filter(Boolean).join(` `);return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:xS})}),c?.name&&(0,o.jsx)(i.Col,{children:(0,o.jsx)(mS,{strong:!0,children:c.name})})]}),(0,o.jsxs)(`div`,{className:`zt-page zt-page-wide bulk-page`,children:[(0,o.jsxs)(`div`,{className:`bulk-header`,children:[(0,o.jsx)(hS,{level:3,children:`Bulk upload test cases`}),(0,o.jsxs)(i.Space,{direction:`vertical`,size:4,children:[(0,o.jsx)(mS,{type:`secondary`,children:yS}),(0,o.jsx)(mS,{type:`secondary`,children:`Use the sample template for the required columns. Uploaded rows are saved as Active by default.`})]})]}),(0,o.jsx)(`div`,{className:`bulk-stepbar`,children:[`Select`,`Upload`,`Validate`,`Save`].map((e,t)=>(0,o.jsxs)(`span`,{className:t<F?`bulk-step-active`:``,children:[t+1,` `,e]},e))}),(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:`1. Module selector`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,className:`bulk-module-select`,placeholder:`Choose a module`,options:j,value:p||void 0,onChange:R})}),p&&(0,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:`2. File upload`,extra:(0,o.jsx)(i.Button,{icon:(0,o.jsx)(a.DownloadOutlined,{}),onClick:B,children:`Download Sample Template`}),children:[(0,o.jsx)(i.Alert,{type:`info`,showIcon:!0,message:`First time uploading?`,description:`Download the sample template, keep the column names unchanged, fill your test steps, and upload either .xlsx or .csv.`,className:`bulk-inline-alert`}),(0,o.jsxs)(`button`,{type:`button`,className:U,disabled:!P,onClick:()=>l.current?.click(),onDragOver:e=>{e.preventDefault(),P&&v(!0)},onDragLeave:()=>v(!1),onDrop:e=>{e.preventDefault(),v(!1),z(e.dataTransfer.files?.[0])},children:[(0,o.jsx)(a.CloudUploadOutlined,{className:`bulk-upload-icon`}),y?(0,o.jsxs)(`span`,{className:`bulk-file-chip`,children:[y.name,` - `,Math.ceil(y.size/1024),` KB`]}):(0,o.jsx)(`span`,{children:`Drag & drop here, or click to browse`})]}),(0,o.jsx)(`input`,{ref:l,hidden:!0,type:`file`,accept:`.xlsx,.csv`,onChange:e=>z(e.target.files?.[0])}),N&&(0,o.jsx)(i.Progress,{percent:h===`encoding`?45:82,showInfo:!1,size:`small`}),T&&h!==`preview`&&(0,o.jsx)(i.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`})]}),x.length>0&&(0,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:`3. Validation result`,children:[(0,o.jsx)(ES,{errors:M,expanded:k,onToggle:()=>A(e=>!e),onSummaryClick:H}),T&&h===`preview`&&(0,o.jsx)(i.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`}),(0,o.jsx)(DS,{rows:x,view:C,onViewChange:w,onConfirm:V,onReset:L,saving:h===`inserting`,firstInvalidRowId:I,firstInvalidRowRef:u})]}),D&&h===`done`&&(0,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:`4. Upload complete`,children:[(0,o.jsxs)(i.Row,{gutter:[16,16],className:`bulk-metrics`,children:[(0,o.jsx)(i.Col,{xs:24,md:8,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(mS,{children:`Total`}),(0,o.jsx)(`strong`,{children:x.length})]})}),(0,o.jsx)(i.Col,{xs:24,md:8,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(mS,{children:`Inserted`}),(0,o.jsx)(`strong`,{children:D.inserted??0})]})}),(0,o.jsx)(i.Col,{xs:24,md:8,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(mS,{children:`Failed`}),(0,o.jsx)(`strong`,{children:D.failed??0})]})})]}),(0,o.jsx)(i.Alert,{type:`success`,showIcon:!0,icon:(0,o.jsx)(a.CheckCircleOutlined,{}),message:`${D.inserted??0} test cases saved to database - module: ${p}`,className:`bulk-inline-alert`}),(0,o.jsx)(i.Button,{icon:(0,o.jsx)(a.ReloadOutlined,{}),onClick:L,children:`Upload another file`})]})]})]})}var kS=[{value:`navigate`,label:`Navigate`},{value:`fill`,label:`Fill`},{value:`click`,label:`Click`},{value:`select`,label:`Select`},{value:`press_key`,label:`Press Key`},{value:`type_and_select`,label:`Type and Select`},{value:`type_and_select_modal`,label:`Type and Select (Modal)`},{value:`upload_file`,label:`Upload File`},{value:`check_checkbox`,label:`Check Checkbox`},{value:`check_filter_checkbox`,label:`Check Filter Checkbox`},{value:`select_page_size`,label:`Select Page Size`},{value:`check_n_checkboxes`,label:`Check N Checkboxes`},{value:`store_text`,label:`Store Text`},{value:`reset_session`,label:`Reset Session`},{value:`switch_to_new_tab`,label:`Switch To New Tab`},{value:`close_tab`,label:`Close Tab`},{value:`assert_visible`,label:`Assert Visible`},{value:`assert_hidden`,label:`Assert Hidden`},{value:`assert_text`,label:`Assert Text`},{value:`assert_url`,label:`Assert URL`},{value:`assert_body_contains`,label:`Assert Body Contains`},{value:`assert_button_disabled`,label:`Assert Button Disabled`},{value:`assert_field_error`,label:`Assert Field Error`},{value:`assert_field_accepted`,label:`Assert Field Accepted`},{value:`assert_children_disabled`,label:`Assert Children Disabled`},{value:`assert_children_visible`,label:`Assert Children Visible`},{value:`assert_element_count`,label:`Assert Element Count`},{value:`assert_toast`,label:`Assert Toast`},{value:`assert_toast_success`,label:`Assert Toast Success`},{value:`assert_toast_error`,label:`Assert Toast Error`},{value:`wait_for_visible`,label:`Wait For Visible`},{value:`wait_for_hidden`,label:`Wait For Hidden`},{value:`wait_for_text`,label:`Wait For Text`}],{Text:AS}=i.Typography,jS=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],MS={tags:`regression`,active:1},NS={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function PS(e=[]){return e.map(e=>({value:e,label:e}))}function FS(e=``){return String(e??``).trim()}function IS(e=``){return FS(e).toLowerCase()}function LS(e=[]){let t=new Map;return e.forEach(e=>{let n=FS(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function RS(e=[],t,n){let r=FS(t).toLowerCase(),i=FS(n).toLowerCase();return e.reduce((e,t)=>{let n=FS(t?.module).toLowerCase(),a=FS(t?.flow).toLowerCase();if(n!==r||a!==i)return e;let o=Number(t?.step_order)||0;return Math.max(e,o)},0)+1}function zS({icon:e,title:t}){return(0,o.jsxs)(i.Space,{size:10,align:`center`,children:[(0,o.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,o.jsx)(AS,{strong:!0,className:`v1-section-label`,children:t})]})}function BS(){let[t]=i.Form.useForm(),[n]=i.Form.useForm(),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)({open:!1,typeKey:`module`}),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)(!1),[w,T]=(0,r.useState)(!1),E=(0,s.useNavigate)(),D=NS[v.typeKey],O=(0,r.useMemo)(()=>PS(c),[c]),k=i.Form.useWatch(`module`,t),A=i.Form.useWatch(`flow`,t),j=!!FS(k),M=!!FS(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&l(t)},I=async()=>{h(!0);try{l((await Xp(NS.module.dbName))?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),i.message.error(`Unable to load testing options.`)}finally{h(!1)}},L=(0,r.useCallback)(async e=>{let n=FS(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await em({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(LS(t))}catch(e){console.error(`Unable to load flows:`,e),i.message.error(`Unable to load flows.`)}finally{_(!1)}}},[t]),R=(0,r.useCallback)(async(e,n,r)=>{let a=FS(e),o=FS(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}C(!0);try{t.setFieldsValue({step_order:RS(r,a,o)})}catch(e){console.error(`Unable to load step order:`,e),i.message.error(`Unable to load step order.`)}finally{C(!1)}},[t]);(0,r.useEffect)(()=>{Promise.resolve().then(I)},[]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>L(k))},[L,k]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>R(k,A,u))},[u,R,A,k]);let z=async e=>{let n={module:FS(e.module),flow:FS(e.flow),step_order:Number(e.step_order),description:FS(e.description),keyword:IS(e.keyword),target:FS(e.target),value:FS(e.value),expected:FS(e.expected),tags:e.tags?FS(e.tags):MS.tags,active:Number(e.active)};T(!0);try{await $p(n),i.message.success(`Test case details saved successfully.`),t.resetFields(),d([]),p([])}catch(e){console.error(`Unable to save test case:`,e),i.message.error(`Unable to save test case.`)}finally{T(!1)}},B=(e,n)=>{t.setFieldsValue({[e]:FS(n)})},V=e=>{t.setFieldsValue({module:FS(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:MS.tags,value:void 0,expected:void 0})},H=e=>{t.setFieldsValue({flow:FS(e),step_order:void 0})},U=e=>{let t=NS[e];y({open:!0,typeKey:e}),n.setFieldsValue({name:``,type:t.label})},W=()=>{y(e=>({...e,open:!1})),n.resetFields()},G=async()=>{try{let e=FS((await n.validateFields()).name),r=await Zp({name:e,type:D.dbName});F(v.typeKey,r?.items??[]),t.setFieldsValue({[D.formField]:e}),i.message.success(`${D.label} added successfully.`),W()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),i.message.error(`Unable to add ${D.label.toLowerCase()}.`)}finally{x(!1)}};return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:jS})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>E(`/zinnext-home`),children:`View Table`})})]}),(0,o.jsx)(`div`,{className:`v1-page`,children:(0,o.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,o.jsx)(`div`,{className:`v1-page-header`,children:(0,o.jsxs)(i.Space,{align:`center`,size:10,children:[(0,o.jsx)(a.ProfileOutlined,{className:`v1-outer-icon`}),(0,o.jsx)(`div`,{children:(0,o.jsx)(AS,{strong:!0,style:{fontSize:16},children:`Add Test Case`})})]})}),(0,o.jsx)(Z,{children:(0,o.jsxs)(i.Form,{form:t,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:MS,onFinish:z,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(zS,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,o.jsx)(AS,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsxs)(i.Space.Compact,{style:{width:`100%`},children:[(0,o.jsx)(i.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,loading:m,optionFilterProp:`label`,placeholder:`Select module`,options:O,onChange:V})}),(0,o.jsx)(i.Button,{"aria-label":`Add module`,icon:(0,o.jsx)(a.PlusOutlined,{}),style:{marginTop:30},onClick:()=>U(`module`)})]})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Flow`,name:`flow`,children:(0,o.jsx)(i.AutoComplete,{maxLength:100,allowClear:!0,disabled:N,options:f,placeholder:g?`Loading flows`:`Enter flow`,onChange:H,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,disabled:!0,placeholder:S?`Loading step order`:`Step order`})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Action`,name:`keyword`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,disabled:P,optionFilterProp:`label`,placeholder:`Select action`,options:kS,onChange:e=>t.setFieldsValue({keyword:IS(e)})})})}),(0,o.jsx)(i.Col,{xs:24,children:(0,o.jsx)(i.Form.Item,{label:`Description`,name:`description`,children:(0,o.jsx)(i.Input.TextArea,{rows:3,maxLength:255,disabled:P,placeholder:`Enter description`,showCount:!0,onBlur:e=>B(`description`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Key`,name:`target`,children:(0,o.jsx)(i.Input,{maxLength:255,disabled:P,placeholder:`Enter target`,onBlur:e=>B(`target`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Tags`,name:`tags`,children:(0,o.jsx)(i.Input,{maxLength:200,disabled:P,placeholder:`Enter tags`,prefix:(0,o.jsx)(a.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>B(`tags`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Value`,name:`value`,children:(0,o.jsx)(i.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter value`,onBlur:e=>B(`value`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Expected`,name:`expected`,children:(0,o.jsx)(i.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter expected result`,onBlur:e=>B(`expected`,e.target.value)})})})]})}),(0,o.jsx)(`div`,{className:`v1-form-actions`,children:(0,o.jsx)(i.Form.Item,{children:(0,o.jsxs)(i.Space,{children:[(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,loading:w,disabled:P,children:`Submit`}),(0,o.jsx)(i.Button,{onClick:()=>{t.resetFields(),d([]),p([])},children:`Reset`})]})})})]})}),(0,o.jsx)(i.Modal,{title:`Add ${D.label}`,open:v.open,confirmLoading:b,okText:`Add`,onCancel:W,onOk:()=>{x(!0),G()},destroyOnHidden:!0,children:(0,o.jsxs)(i.Form,{form:n,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,o.jsx)(i.Form.Item,{label:`Name`,name:`name`,children:(0,o.jsx)(i.Input,{maxLength:100,placeholder:`Enter ${D.label.toLowerCase()} name`,onBlur:e=>{n.setFieldsValue({name:FS(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var{Text:VS}=i.Typography,HS=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function US(e=``){return String(e??``).trim()}function WS(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var GS=[{label:`Step`,value:`step_order`,width:70},{label:`Action`,value:`actions`,width:140},{label:`Key`,value:`key`,width:160,ellipsis:!0},{label:`Value`,value:`value`,ellipsis:!0},{label:`Description`,value:`description`,ellipsis:!0},{label:`Scenario`,value:`scenario`,width:110,render:e=>e===1?(0,o.jsx)(i.Tag,{color:`green`,children:`Positive`}):(0,o.jsx)(i.Tag,{color:`red`,children:`Negative`})}],KS={key:!1,value:!1,expected:!1};function qS(e,t){return t?e[t]??KS:KS}function JS(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function YS(){let[n]=i.Form.useForm(),c=(0,s.useNavigate)(),[l]=(0,s.useSearchParams)(),u=l.get(`edit`),d=!!u,f=(0,r.useMemo)(()=>t.s(),[]),[p,m]=(0,r.useState)([]),[h,g]=(0,r.useState)([]),[_,v]=(0,r.useState)([]),[y,b]=(0,r.useState)(kS),[x,S]=(0,r.useState)({}),[C,w]=(0,r.useState)(!1),[T,E]=(0,r.useState)(!1),[D,O]=(0,r.useState)(!1),[k,A]=(0,r.useState)(!1),[j,M]=(0,r.useState)(!1),N=i.Form.useWatch(`module`,n),P=i.Form.useWatch(`submodule`,n),F=i.Form.useWatch(`actions`,n),I=!!N,L=!!P,R=(0,r.useMemo)(()=>qS(x,F),[x,F]),z=(0,r.useMemo)(()=>WS(p,`modulename`),[p]),B=(0,r.useMemo)(()=>WS(h,`submodulename`),[h]),V=(0,r.useMemo)(()=>p.find(e=>e.id===N)?.modulename??``,[p,N]),H=(0,r.useMemo)(()=>h.find(e=>e.id===P)?.submodulename??``,[P,h]),U=(0,r.useCallback)(async()=>{try{let e=await Qp();Array.isArray(e?.options)&&e.options.length>0&&b(e.options),e?.rules&&typeof e.rules==`object`&&S(e.rules)}catch(e){console.error(`Unable to load action field rules:`,e),i.message.error(`Unable to load action validation rules.`)}},[]),W=(0,r.useCallback)(async e=>{if(!e){m([]);return}w(!0);try{m((await om({project:e,activeOnly:!0}))?.items??[])}catch(e){console.error(`Unable to load modules:`,e),i.message.error(`Unable to load modules.`)}finally{w(!1)}},[]),G=(0,r.useCallback)(async(e,t)=>{if(!e||!t){g([]);return}E(!0);try{g((await lm({project:e,module:t,activeOnly:!0}))?.items??[])}catch(e){console.error(`Unable to load submodules:`,e),i.message.error(`Unable to load submodules.`)}finally{E(!1)}},[]),ee=(0,r.useCallback)(async(e,t,r,a=``)=>{if(!e||!t||!r){v([]),n.setFieldsValue({step_order:void 0});return}O(!0);try{let[i,o]=await Promise.all([fm({product_parent_ID:e,module_parent_ID:t,submodule_parent_ID:r,actions:a,limit:1e3}),hm({product_parent_ID:e,module_parent_ID:t,submodule_parent_ID:r})]);v(i?.items??[]),n.setFieldsValue({step_order:o?.step_order??1})}catch(e){console.error(`Unable to load flows:`,e),i.message.error(`Unable to load flows.`)}finally{O(!1)}},[n]),te=(0,r.useCallback)(async(e=``)=>{if(!(!f?.id||!N||!P)){O(!0);try{v((await fm({product_parent_ID:f.id,module_parent_ID:N,submodule_parent_ID:P,actions:e,limit:1e3}))?.items??[])}catch(e){console.error(`Unable to load action flows:`,e),i.message.error(`Unable to load action steps.`)}finally{O(!1)}}},[f?.id,N,P]),K=(0,r.useCallback)(async()=>{if(!(!u||!f?.name)){M(!0);try{let e=await mm(u);await G(f.name,e.module),v((await fm({product_parent_ID:e.product_parent_ID,module_parent_ID:e.module_parent_ID,submodule_parent_ID:e.submodule_parent_ID,limit:1e3}))?.items??[]),n.setFieldsValue({module:e.module_parent_ID,submodule:e.submodule_parent_ID,step_order:e.step_order,actions:e.actions,key:e.key,value:e.value,expected:e.expected,description:e.description,scenario:e.scenario===1,active:Number(e.active)!==0})}catch(e){console.error(`Unable to load test flow:`,e),i.message.error(`Unable to load test flow for edit.`),c(`/viewTestCase`)}finally{M(!1)}}},[u,n,G,c,f?.name]);return(0,r.useEffect)(()=>{if(!f){c(`/select-project`,{replace:!0});return}Promise.resolve().then(async()=>{await U(),await W(f.name),u&&await K()})},[f,c,U,W,u,K]),f?(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:HS})}),(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.ProjectOutlined,{}),(0,o.jsx)(VS,{strong:!0,children:f.name})]})})]}),(0,o.jsx)(`div`,{className:`zt-page`,children:(0,o.jsxs)(i.Form,{form:n,layout:`vertical`,colon:!1,className:`v1-form`,initialValues:{scenario:!0,active:!0},onFinish:async e=>{let t={product_parent_ID:Number(f?.id),module_parent_ID:Number(e.module),submodule_parent_ID:Number(e.submodule),description:US(e.description),actions:US(e.actions),key:US(e.key),value:US(e.value),expected:US(e.expected),scenario:+!!e.scenario,active:+!!e.active};A(!0);try{if(d){await gm(u,{...t,step_order:Number(e.step_order)}),i.message.success(`Test case updated successfully.`),c(`/viewTestCase`);return}await pm(t),i.message.success(`Step saved (#${e.step_order}).`),n.setFieldsValue({actions:void 0,key:void 0,value:void 0,expected:void 0,description:void 0}),await ee(t.product_parent_ID,t.module_parent_ID,t.submodule_parent_ID)}catch(e){console.error(`Unable to save test case:`,e),i.message.error(d?`Unable to update test case.`:`Unable to save step.`)}finally{A(!1)}},autoComplete:`off`,disabled:j,children:[(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:8,className:`zt-section-title`,children:[(0,o.jsx)(`span`,{className:`zt-step-tag`,children:`1`}),(0,o.jsx)(`span`,{children:`Module & Submodule`})]}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],align:`bottom`,children:[(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Module`,name:`module`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,loading:C,placeholder:`Select module`,options:z,onChange:e=>{let t=p.find(t=>t.id===e)?.modulename??``;n.setFieldsValue({module:e,submodule:void 0,step_order:void 0,actions:void 0,key:void 0,value:void 0,expected:void 0}),JS(n,[`actions`,`key`,`value`,`expected`]),g([]),v([]),G(f?.name,t)}})})}),(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Submodule`,name:`submodule`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,disabled:!I,loading:T,placeholder:I?`Select submodule`:`Select module first`,options:B,onChange:e=>{n.setFieldsValue({submodule:e,actions:void 0,key:void 0,value:void 0,expected:void 0}),JS(n,[`actions`,`key`,`value`,`expected`]),ee(f?.id,N,e)}})})}),(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Scenario`,name:`scenario`,valuePropName:`checked`,children:(0,o.jsx)(i.Switch,{disabled:!L,checkedChildren:`Positive`,unCheckedChildren:`Negative`})})}),(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Active`,name:`active`,valuePropName:`checked`,children:(0,o.jsx)(i.Switch,{checkedChildren:`Active`,unCheckedChildren:`Inactive`})})})]})}),L&&(0,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:8,className:`zt-section-title`,children:[(0,o.jsx)(`span`,{className:`zt-step-tag`,children:`2`}),(0,o.jsx)(a.FileTextOutlined,{}),(0,o.jsx)(`span`,{children:`Step Details`})]}),extra:(0,o.jsxs)(VS,{type:`secondary`,children:[V,` / `,H]}),children:[(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Step Order`,name:`step_order`,children:(0,o.jsx)(i.Input,{disabled:!0,placeholder:D?`Loading…`:`Auto`})})}),(0,o.jsx)(i.Col,{xs:24,md:18,children:(0,o.jsx)(i.Form.Item,{label:`Action`,name:`actions`,rules:[{required:!0,message:`Mandatory Field`}],children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,placeholder:`Select action`,options:y,onChange:e=>{let t=qS(x,e);n.setFieldsValue({actions:e,key:t.key?n.getFieldValue(`key`):void 0,value:t.value?n.getFieldValue(`value`):void 0,expected:t.expected?n.getFieldValue(`expected`):void 0}),JS(n,[`key`,`value`,`expected`]),te(e||``)}})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Key`,name:`key`,rules:[{required:R.key,message:`Key is required for this action`}],children:(0,o.jsx)(i.Input,{maxLength:255,disabled:F&&!R.key,placeholder:F?R.key?`Required — Enter selector / locator`:`Not needed for this action`:`Select an action first`})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Value`,name:`value`,rules:[{required:R.value,message:`Value is required for this action`}],children:(0,o.jsx)(i.Input.TextArea,{rows:1,autoSize:{minRows:1,maxRows:4},disabled:F&&!R.value,placeholder:F?R.value?`Required — Enter value`:`Not needed for this action`:`Select an action first`})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:R.expected,message:`Expected result is required for this action`}],children:(0,o.jsx)(i.Input.TextArea,{rows:2,disabled:F&&!R.expected,placeholder:F?R.expected?`Required — Enter expected result`:`Not needed for this action`:`Select an action first`})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Description`,name:`description`,children:(0,o.jsx)(i.Input.TextArea,{rows:2,maxLength:255,showCount:!0,placeholder:`Enter description`})})})]}),(0,o.jsxs)(i.Space,{className:`zt-actions`,children:[(0,o.jsx)(i.Button,{onClick:()=>{if(d){c(`/viewTestCase`);return}n.resetFields(),g([]),v([]),E(!1),O(!1)},children:`Cancel`}),(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,loading:k||j,children:d?`Update Test Case`:`Save & Continue`})]})]},`${N}-${P}`),L&&(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.TableOutlined,{}),(0,o.jsx)(`span`,{children:`Added Steps`})]}),extra:(0,o.jsx)(i.Tag,{children:F?`${_.length} ${F} step(s)`:`${_.length} step(s)`}),children:(0,o.jsx)(du,{listName:`Added Steps`,loading:D,fields:GS,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:XS}=i.Typography,ZS=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function QS(){let n=(0,s.useNavigate)(),c=(0,r.useMemo)(()=>t.s(),[]),[l,u]=(0,r.useState)([]),[d,f]=(0,r.useState)({}),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)(``),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(1),[C,w]=(0,r.useState)(10),T=(0,r.useCallback)(async e=>{if(!e){u([]);return}m(!0);try{let[t,n]=await Promise.all([om({project:e}),lm({project:e})]);u(t?.items??[]);let r={};(n?.items??[]).forEach(e=>{let t=e.modulename;r[t]=(r[t]??0)+1}),f(r)}catch(e){console.error(e),i.message.error(`Unable to load modules.`)}finally{m(!1)}},[]);(0,r.useEffect)(()=>{if(!c){n(`/select-project`,{replace:!0});return}Promise.resolve().then(()=>T(c.name))},[c,n,T]);let E=async(e,t)=>{try{await cm(e.id,+!!t),u(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),i.message.success(`Module ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),i.message.error(`Unable to update module status.`)}},D=async()=>{let e=_.trim();if(!e){i.message.warning(`Enter a module name.`);return}b(!0);try{await sm({project:c.name,modulename:e}),i.message.success(`Module added.`),g(!1),v(``),S(1),T(c.name)}catch(e){console.error(e),i.message.error(`Unable to add module (maybe it already exists).`)}finally{b(!1)}},O=e=>{n(`/test-cases/zinnext/submodules?module=${encodeURIComponent(e.modulename)}`)};return c?(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:ZS})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>n(`/addTestCase`),children:`Back to Form`})})]}),(0,o.jsxs)(`div`,{className:`zt-page`,children:[(0,o.jsx)(i.Card,{className:`v1-card zt-bar`,children:(0,o.jsxs)(i.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.ProjectOutlined,{}),(0,o.jsx)(`span`,{children:`Project:`}),(0,o.jsx)(XS,{strong:!0,children:c.name})]})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Module`})})]})}),(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.AppstoreOutlined,{}),(0,o.jsx)(`span`,{children:`Modules`})]}),children:(0,o.jsx)(du,{listName:`Modules`,loading:p,fields:[{label:`Module`,value:`modulename`},{label:`Submodules`,value:`submoduleCount`,width:140,render:(e,t)=>(0,o.jsxs)(i.Button,{type:`link`,className:`zt-count-link`,onClick:()=>O(t),children:[d[t.modulename]??0,` submodule(s)`]})},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,o.jsx)(i.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:l,current:x,pageSize:C,total:l.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,o.jsx)(i.Modal,{title:`Add Module`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,o.jsxs)(i.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,o.jsxs)(XS,{type:`secondary`,children:[`Project: `,(0,o.jsx)(`b`,{children:c.name})]}),(0,o.jsx)(i.Input,{placeholder:`Enter module name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]}):null}var{Text:$S}=i.Typography,eC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function tC(){let n=(0,s.useNavigate)(),[c]=(0,s.useSearchParams)(),l=(0,r.useMemo)(()=>t.s(),[]),u=c.get(`module`)??``,[d,f]=(0,r.useState)([]),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)(``),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(1),[C,w]=(0,r.useState)(10),T=(0,r.useCallback)(async(e,t)=>{if(!e||!t){f([]);return}m(!0);try{f((await lm({project:e,module:t}))?.items??[])}catch(e){console.error(e),i.message.error(`Unable to load submodules.`)}finally{m(!1)}},[]);(0,r.useEffect)(()=>{if(!l){n(`/select-project`,{replace:!0});return}if(!u){n(`/manageModules`,{replace:!0});return}Promise.resolve().then(()=>T(l.name,u))},[l,u,n,T]);let E=async(e,t)=>{try{await dm(e.id,+!!t),f(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),i.message.success(`Submodule ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),i.message.error(`Unable to update submodule status.`)}},D=async()=>{let e=_.trim();if(!e){i.message.warning(`Enter a submodule name.`);return}b(!0);try{await um({project:l.name,modulename:u,submodulename:e}),i.message.success(`Submodule added.`),g(!1),v(``),S(1),T(l.name,u)}catch(e){console.error(e),i.message.error(`Unable to add submodule (maybe it already exists).`)}finally{b(!1)}};return!l||!u?null:(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:eC})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>n(`/manageModules`),children:`Back to Modules`})})]}),(0,o.jsxs)(`div`,{className:`zt-page`,children:[(0,o.jsx)(i.Card,{className:`v1-card zt-bar`,children:(0,o.jsxs)(i.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space,{size:16,wrap:!0,className:`zt-section-title`,children:[(0,o.jsxs)(i.Space,{size:6,children:[(0,o.jsx)(a.ProjectOutlined,{}),(0,o.jsx)(`span`,{children:`Project:`}),(0,o.jsx)($S,{strong:!0,children:l.name})]}),(0,o.jsxs)(i.Space,{size:6,children:[(0,o.jsx)(a.AppstoreOutlined,{}),(0,o.jsx)(`span`,{children:`Module:`}),(0,o.jsx)($S,{strong:!0,children:u})]})]})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Submodule`})})]})}),(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.AppstoreOutlined,{}),(0,o.jsx)(`span`,{children:`Submodules`})]}),children:(0,o.jsx)(du,{listName:`Submodules`,loading:p,fields:[{label:`Submodule`,value:`submodulename`},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,o.jsx)(i.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:d,current:x,pageSize:C,total:d.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,o.jsx)(i.Modal,{title:`Add Submodule`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,o.jsxs)(i.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,o.jsxs)($S,{type:`secondary`,children:[`Project: `,(0,o.jsx)(`b`,{children:l.name}),` \xA0|\xA0 Module: `,(0,o.jsx)(`b`,{children:u})]}),(0,o.jsx)(i.Input,{placeholder:`Enter submodule name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]})}var{Text:nC}=i.Typography,rC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function iC(){let n=(0,s.useNavigate)(),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)(0),[f,p]=(0,r.useState)(!1),m=(0,r.useMemo)(()=>t.s(),[]),[h,g]=(0,r.useState)(``),[_,v]=(0,r.useState)(1),[y,b]=(0,r.useState)(20),[x,S]=(0,r.useState)(null),C=(0,r.useCallback)(async(e={})=>{p(!0);try{let t=await fm({product_parent_ID:e.project??m?.id??``,search:e.search??h??``,limit:e.pageSize??y,offset:((e.page??_)-1)*(e.pageSize??y)});l(t?.items??[]),d(t?.total??0)}catch(e){console.error(e),i.message.error(`Unable to load test flows.`)}finally{p(!1)}},[m?.id,h,_,y]),w=e=>{i.Modal.confirm({title:`Delete Test Case`,icon:(0,o.jsx)(a.ExclamationCircleOutlined,{}),content:`Are you sure you want to delete this test case?`,okText:`Delete`,okButtonProps:{danger:!0,loading:x===e.id},cancelText:`Cancel`,async onOk(){S(e.id);try{await _m(e.id),i.message.success(`Test case deleted successfully.`);let t=c.length===1&&_>1?_-1:_;v(t),await C({page:t})}catch(e){throw console.error(`Unable to delete test flow:`,e),i.message.error(`Unable to delete test case.`),e}finally{S(null)}}})};return(0,r.useEffect)(()=>{Promise.resolve().then(()=>{if(!m?.id){n(`/select-project`,{replace:!0});return}C({page:1})})},[]),(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:rC})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>n(`/addTestCase`),children:`Back to Form`})})]}),(0,o.jsx)(`div`,{className:`zt-page zt-page-wide`,children:(0,o.jsxs)(i.Card,{className:`v1-card`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.TableOutlined,{}),(0,o.jsx)(`span`,{children:`Test Flows`})]}),extra:(0,o.jsxs)(nC,{type:`secondary`,children:[u,` row(s)`]}),children:[(0,o.jsxs)(i.Space,{wrap:!0,className:`zt-toolbar`,children:[(0,o.jsx)(i.Input.Search,{allowClear:!0,className:`zt-search-filter`,placeholder:`Search module / key / description`,value:h,onChange:e=>g(e.target.value),onSearch:()=>{v(1),C({page:1})}}),(0,o.jsx)(i.Button,{icon:(0,o.jsx)(a.ReloadOutlined,{}),onClick:()=>C(),children:`Refresh`})]}),(0,o.jsx)(du,{listName:`Test Flows`,loading:f,fields:[{label:`Actions`,value:`rowActions`,width:112,fixed:`left`,sorter:!1,render:(e,t)=>(0,o.jsxs)(i.Space,{size:4,className:`zt-row-actions`,children:[(0,o.jsx)(i.Tooltip,{title:`Edit`,children:(0,o.jsx)(i.Button,{type:`text`,size:`small`,icon:(0,o.jsx)(a.EditOutlined,{}),onClick:()=>n(`/addTestCase?edit=${t.id}`)})}),(0,o.jsx)(i.Tooltip,{title:`Delete`,children:(0,o.jsx)(i.Button,{danger:!0,type:`text`,size:`small`,icon:(0,o.jsx)(a.DeleteOutlined,{}),loading:x===t.id,onClick:()=>w(t)})})]})},{label:`ID`,value:`id`,width:70,fixed:`left`},{label:`Project`,value:`project`,width:130},{label:`Module`,value:`module`,width:130},{label:`Submodule`,value:`submodule`,width:140},{label:`Step`,value:`step_order`,width:70},{label:`Action`,value:`actions`,width:140},{label:`Key`,value:`key`,width:160,ellipsis:!0},{label:`Value`,value:`value`,width:200,ellipsis:!0},{label:`Expected`,value:`expected`,width:180,ellipsis:!0},{label:`Description`,value:`description`,width:180,ellipsis:!0},{label:`Scenario`,value:`scenario`,width:110,render:e=>e===1?(0,o.jsx)(i.Tag,{color:`green`,children:`Positive`}):(0,o.jsx)(i.Tag,{color:`red`,children:`Negative`})},{label:`Active`,value:`active`,width:90,render:e=>e===1?(0,o.jsx)(i.Tag,{color:`blue`,children:`Active`}):(0,o.jsx)(i.Tag,{children:`Inactive`})}],dataSource:c,current:_,pageSize:y,total:u,onPageChange:e=>{v(e),C({page:e})},onPageSizeChange:e=>{v(1),b(e),C({page:1,pageSize:e})},rowSelection:!1,className:`zt-list-plain`})]})})]})}var aC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function oC(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:aC}),(0,o.jsx)(ha,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:sC}=i.Typography,cC=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],lC={tags:`regression`,active:1},uC={module:{dbName:`Modules`,formField:`module`,label:`Module`}},dC={key:!1,value:!1,expected:!1};function fC(e,t){return t?e[t]??dC:dC}function pC(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function mC(e=[]){return e.map(e=>({value:e,label:e}))}function hC(e=``){return String(e??``).trim()}function gC(e=[]){let t=new Map;return e.forEach(e=>{let n=hC(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function _C(e=[],t,n){let r=hC(t).toLowerCase(),i=hC(n).toLowerCase();return e.reduce((e,t)=>{let n=hC(t?.module).toLowerCase(),a=hC(t?.flow).toLowerCase();if(n!==r||a!==i)return e;let o=Number(t?.step_order)||0;return Math.max(e,o)},0)+1}function vC({icon:e,title:t}){return(0,o.jsxs)(i.Space,{size:10,align:`center`,children:[(0,o.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,o.jsx)(sC,{strong:!0,className:`v1-section-label`,children:t})]})}function yC(){let[t]=i.Form.useForm(),[n]=i.Form.useForm(),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)([]),[m,h]=(0,r.useState)(kS),[g,_]=(0,r.useState)({}),[v,y]=(0,r.useState)(!1),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)({open:!1,typeKey:`module`}),[w,T]=(0,r.useState)(!1),[E,D]=(0,r.useState)(!1),[O,k]=(0,r.useState)(!1),A=(0,s.useNavigate)(),j=uC[S.typeKey],M=(0,r.useMemo)(()=>mC(c),[c]),N=i.Form.useWatch(`module`,t),P=i.Form.useWatch(`flow`,t),F=i.Form.useWatch(`keyword`,t),I=!!hC(N),L=!!hC(P),R=!I,z=!I||!L,B=(0,r.useMemo)(()=>fC(g,F),[g,F]),V=(e,t=[])=>{e===`module`&&l(t)},H=async()=>{y(!0);try{l((await Xp(uC.module.dbName))?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),i.message.error(`Unable to load testing options.`)}finally{y(!1)}},U=async()=>{try{let e=await Qp();Array.isArray(e?.options)&&e.options.length>0&&h(e.options),e?.rules&&typeof e.rules==`object`&&_(e.rules)}catch(e){console.error(`Unable to load action field rules:`,e),i.message.error(`Unable to load action validation rules.`)}},W=(0,r.useCallback)(async e=>{let n=hC(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await im({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(gC(t))}catch(e){console.error(`Unable to load flows:`,e),i.message.error(`Unable to load flows.`)}finally{x(!1)}}},[t]),G=(0,r.useCallback)(async(e,n,r)=>{let a=hC(e),o=hC(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}D(!0);try{t.setFieldsValue({step_order:_C(r,a,o)})}catch(e){console.error(`Unable to load step order:`,e),i.message.error(`Unable to load step order.`)}finally{D(!1)}},[t]);(0,r.useEffect)(()=>{Promise.resolve().then(async()=>{await Promise.all([H(),U()])})},[]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>W(N))},[W,N]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>G(N,P,u))},[u,G,P,N]);let ee=async e=>{let n={module:hC(e.module),flow:hC(e.flow),step_order:Number(e.step_order),description:hC(e.description),keyword:hC(e.keyword),target:hC(e.target),value:hC(e.value),expected:hC(e.expected),tags:e.tags?hC(e.tags):lC.tags,active:Number(e.active)};k(!0);try{await rm(n),i.message.success(`LMS case details saved successfully.`),t.resetFields(),d([]),p([])}catch(e){console.error(`Unable to save LMS case:`,e),i.message.error(`Unable to save LMS case.`)}finally{k(!1)}},te=(e,n)=>{t.setFieldsValue({[e]:hC(n)})},K=e=>{t.setFieldsValue({module:hC(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:lC.tags,value:void 0,expected:void 0}),pC(t,[`keyword`,`target`,`value`,`expected`])},ne=e=>{t.setFieldsValue({flow:hC(e),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),pC(t,[`keyword`,`target`,`value`,`expected`])},re=e=>{let n=fC(g,e);t.setFieldsValue({keyword:hC(e),target:n.key?t.getFieldValue(`target`):void 0,value:n.value?t.getFieldValue(`value`):void 0,expected:n.expected?t.getFieldValue(`expected`):void 0}),pC(t,[`target`,`value`,`expected`])},q=e=>{let t=uC[e];C({open:!0,typeKey:e}),n.setFieldsValue({name:``,type:t.label})},J=()=>{C(e=>({...e,open:!1})),n.resetFields()},ie=async()=>{try{let e=hC((await n.validateFields()).name),r=await Zp({name:e,type:j.dbName});V(S.typeKey,r?.items??[]),t.setFieldsValue({[j.formField]:e}),i.message.success(`${j.label} added successfully.`),J()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),i.message.error(`Unable to add ${j.label.toLowerCase()}.`)}finally{T(!1)}};return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:cC})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>A(`/lms-home`),children:`View Table`})})]}),(0,o.jsx)(`div`,{className:`v1-page`,children:(0,o.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,o.jsx)(`div`,{className:`v1-page-header`,children:(0,o.jsxs)(i.Space,{align:`center`,size:10,children:[(0,o.jsx)(a.ProfileOutlined,{className:`v1-outer-icon`}),(0,o.jsx)(`div`,{children:(0,o.jsx)(sC,{strong:!0,style:{fontSize:16},children:`Add LMS Case`})})]})}),(0,o.jsx)(Z,{children:(0,o.jsxs)(i.Form,{form:t,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:lC,onFinish:ee,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(vC,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,o.jsx)(sC,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsxs)(i.Space.Compact,{style:{width:`100%`},children:[(0,o.jsx)(i.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,loading:v,optionFilterProp:`label`,placeholder:`Select module`,options:M,onChange:K})}),(0,o.jsx)(i.Button,{"aria-label":`Add module`,icon:(0,o.jsx)(a.PlusOutlined,{}),style:{marginTop:30},onClick:()=>q(`module`)})]})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Flow`,name:`flow`,children:(0,o.jsx)(i.AutoComplete,{maxLength:100,allowClear:!0,disabled:R,options:f,placeholder:b?`Loading flows`:`Enter flow`,onChange:ne,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,disabled:!0,placeholder:E?`Loading step order`:`Step order`})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Action`,name:`keyword`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,disabled:z,optionFilterProp:`label`,placeholder:`Select action`,options:m,onChange:re})})}),(0,o.jsx)(i.Col,{xs:24,children:(0,o.jsx)(i.Form.Item,{label:`Description`,name:`description`,children:(0,o.jsx)(i.Input.TextArea,{rows:3,maxLength:255,disabled:z,placeholder:`Enter description`,showCount:!0,onBlur:e=>te(`description`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Key`,name:`target`,rules:[{required:B.key,message:`Key is required for this action`}],children:(0,o.jsx)(i.Input,{maxLength:255,disabled:z||!!F&&!B.key,placeholder:z?`Select module and flow first`:F?B.key?`Required — Enter selector / locator`:`Not needed for this action`:`Select an action first`,onBlur:e=>te(`target`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Tags`,name:`tags`,children:(0,o.jsx)(i.Input,{maxLength:200,disabled:z,placeholder:`Enter tags`,prefix:(0,o.jsx)(a.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>te(`tags`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Value`,name:`value`,rules:[{required:B.value,message:`Value is required for this action`}],children:(0,o.jsx)(i.Input.TextArea,{rows:4,disabled:z||!!F&&!B.value,placeholder:z?`Select module and flow first`:F?B.value?`Required — Enter value`:`Not needed for this action`:`Select an action first`,onBlur:e=>te(`value`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:B.expected,message:`Expected result is required for this action`}],children:(0,o.jsx)(i.Input.TextArea,{rows:4,disabled:z||!!F&&!B.expected,placeholder:z?`Select module and flow first`:F?B.expected?`Required — Enter expected result`:`Not needed for this action`:`Select an action first`,onBlur:e=>te(`expected`,e.target.value)})})})]})}),(0,o.jsx)(`div`,{className:`v1-form-actions`,children:(0,o.jsx)(i.Form.Item,{children:(0,o.jsxs)(i.Space,{children:[(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,loading:O,disabled:z,children:`Submit`}),(0,o.jsx)(i.Button,{onClick:()=>{t.resetFields(),d([]),p([])},children:`Reset`})]})})})]})}),(0,o.jsx)(i.Modal,{title:`Add ${j.label}`,open:S.open,confirmLoading:w,okText:`Add`,onCancel:J,onOk:()=>{T(!0),ie()},destroyOnHidden:!0,children:(0,o.jsxs)(i.Form,{form:n,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,o.jsx)(i.Form.Item,{label:`Name`,name:`name`,children:(0,o.jsx)(i.Input,{maxLength:100,placeholder:`Enter ${j.label.toLowerCase()} name`,onBlur:e=>{n.setFieldsValue({name:hC(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var bC=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function xC(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:bC}),(0,o.jsx)(ha,{moduleName:`lms-flows`,rowKey:`id`})]})}var SC=e=>e?.data??e;function CC(e){return Array.isArray(e)&&e.every(e=>e&&typeof e==`object`&&`Key`in e)?e.reduce((e,{Key:t,Value:n})=>(e[t]=n,e),{}):e}function wC(e){return e?Array.isArray(e.data)?e.data.map(CC):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(CC):Array.isArray(e)?e.map(CC):[]:[]}async function TC(e=1,n=10){let r=await t.i(t.v,`/workflow/list/all?page=${e}&limit=${n}`),i=SC(r),a=Array.isArray(i)?i:i?.data??[];return{items:a,total:Number(r?.total??i?.total)||a.length,page:e,limit:n}}async function EC(e=100){let t=await TC(1,e),n=[...t.items],r=t.total,i=2;for(;n.length<r;){let t=await TC(i,e);if(!t.items.length)break;n.push(...t.items),i+=1}return{items:n,total:Math.max(r,n.length)}}async function DC(e,n){let r=SC(await t.i(t.v,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function OC(e,n){if(!e||!n)return null;try{let r=SC(await t.i(t.v,`/module-data-list?${new URLSearchParams({module:e,limit:`1`,offset:`0`,scope:`allJobs`,filters:JSON.stringify([{field:`_id`,op:`in`,values:[String(n)],operator:`and`}])})}`));if(Array.isArray(r))return r[0]??null;if(r?.data&&Array.isArray(r.data))return r.data[0]??null;let i=r?.rows??r?.records??r?.items??r?.list;return Array.isArray(i)?i[0]??null:r??null}catch(t){return console.error(`[getModuleRecordById] failed: ${e}/${n}`,t),null}}var kC=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function AC(e=kC){return function(t){if(!t||typeof t!=`object`)return``;for(let n of e){let e=t[n];if(e!=null&&e!==``)return String(e)}return``}}function jC(e,t=kC){if(!e||typeof e!=`object`)return[];let n=[];for(let r of t){let t=e[r];t!=null&&t!==``&&n.push(String(t))}return n}var MC=AC();function NC(e){return typeof e==`function`?e:typeof e==`string`?AC([e]):Array.isArray(e)?AC(e):MC}function PC(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:t.id??e.id??n}}function FC(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var IC=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function LC(e){let t=e?.data??e,n={};for(let r of IC){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var RC=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function zC(e,t,n){let r=(Array.isArray(n)?n:[n]).map(RC).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(RC(e?.value))||r.includes(RC(e?.label))):-1;if(i===-1)return[...e,...t];let a=Number(e[i]?.order),o=Number.isFinite(a)?t.map((e,n)=>e.order==null||e.order===``?{...e,order:a+(n+1)/(t.length+1)}:e):t;return[...e.slice(0,i+1),...o,...e.slice(i+1)]}var BC=(e,t)=>Qn(e,t).rows,VC=(e,t)=>{let{rows:n,total:r}=Qn(e,t);return{rows:n,total:r}};function HC({fetchPrimaryPage:e,extractPrimaryPage:t=VC,fetchSecondaryByKeys:n,fetchPrimary:r,extractPrimaryRows:i=BC,fetchSecondary:a,extractSecondaryRows:o=BC,fetchSecondaryById:s,primaryKey:c,secondaryKey:l,mergeRow:u=PC,secondaryFetchLimit:d=200,extraFields:f=[],extraFieldsAfter:p}){let m=NC(c),h=typeof l==`function`?e=>{let t=l(e);return t?[String(t)]:[]}:e=>jC(e,typeof l==`string`?[l]:Array.isArray(l)?l:kC),g=0;function _(e){let t=new Map;return e.forEach(e=>{for(let n of h(e))t.has(n)||t.set(n,e)}),t}async function v(e,t){if(!s||!t)return null;try{let n=await s(e,t);return n&&h(n).includes(String(t))?n:null}catch(e){return console.error(`[mergedListApi] per-id secondary lookup failed for "${t}"`,e),null}}async function y(e,t,n,r){return Promise.all(e.map(async e=>{let i=m(e);return u(e,t.get(i)??(r()?null:await v(n,i)),i)}))}function b(e,t,n){let r={};for(let e of n){if(!e)continue;let t=LC(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return f.length&&(r.fields=zC(r.fields??[],f,p)),FC(e,t,r)}async function x(r,i,a,s,c){let l=await e(r,i,a,s),u=t(l,r)??{},d=Array.isArray(u.rows)?u.rows:[],f=Number.isFinite(Number(u.total))?Number(u.total):d.length,p=[...new Set(d.map(m).filter(Boolean))],h=null,g=[];if(p.length&&n)try{h=await n(r,p,s),g=o(h,r)??[]}catch(e){console.error(`[mergedListApi] secondary fetch failed — rendering unenriched page`,e),h=null}return b(await y(d,_(g),r,c),f,[l,h])}async function S(e,t,n,s,c){let[l,u]=await Promise.allSettled([r(e,t,n,s),a?a(e,d,0,s):Promise.resolve(null)]);if(l.status===`rejected`)throw l.reason;let f=u.status===`fulfilled`?u.value:null;u.status===`rejected`&&console.error(`[mergedListApi] secondary fetch failed — rendering unenriched page`,u.reason);let p=i(l.value,e)??[],m=_(f?o(f,e)??[]:[]),h=p.length;return b(await y(p.slice(n,n+t),m,e,c),h,[l.value,f])}return async function(t,n=10,r=0,i={}){let a=++g,o=()=>a!==g;return e?x(t,n,r,i,o):S(t,n,r,i,o)}}function UC(e,t,n={}){return HC({fetchPrimary:()=>DC(e,t),extractPrimaryRows:wC,fetchSecondary:Ft,fetchSecondaryById:OC,secondaryFetchLimit:n.moduleFetchLimit??200})}function WC(e){let t=String(e??``).trim().split(/[^a-zA-Z0-9]+/).filter(Boolean);return t.length?`${t.map((e,t)=>t===0?e.toLowerCase():e[0].toUpperCase()+e.slice(1).toLowerCase()).join(``)}Count`:``}function GC(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=WC(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var KC=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function qC({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=PC(n,r,i),o=KC(a);return o!=null&&(console.log(`mergeJobWorkflowRow`,i,a?.[e],o),a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function JC(e={}){let t=qC(),n=HC({primaryKey:`_id`,secondaryKey:`entityId`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:Ft,fetchSecondaryByKeys:()=>EC(),extractSecondaryRows:e=>(e?.items??[]).map(GC),mergeRow:(e,n,r)=>{let i=t(e,n,r);return n?._id&&(i.workflowId=n._id),i}});return async function(e,t,r,i){return await n(e,t,r,i)}}async function YC(e,t=10,n=0,r={},i={}){return Qn(await JC(i)(e,t,n,r),e)}async function XC(e,t,n,r=10,i=0,a={}){return Qn(await UC(e,t)(n,r,i,a),n)}var ZC=mx,QC=bm(dS),$C=bm(pS),ew=bm(OS),tw=bm(BS),nw=bm(YS),rw=bm(QS),iw=bm(tC),aw=bm(iC),ow=bm(oC),sw=bm(yC),cw=bm(xC);exports.ADMIN_API_URL=t.h,exports.ADMIN_APP_ID=t.g,exports.APP_ID=t._,exports.AUTH_URL=t.v,exports.ActivityTab=Jo,exports.AddBatchCandidatePopup=Zb,exports.AddFormV1=No,exports.AdminDashboard=mx,exports.AdminDashboardContent=Ev,exports.AdminPage=ZC,exports.AppAlert=Po,exports.AppButton=Tr,exports.AppShell=Up,exports.ApprovalActionBar=Yd,exports.AssigneeAvatars=Yo,exports.AuthGuard=Vp,exports.BILLING_STATUS_FLOW=ju,exports.Breadcrumb=e.t,exports.BulkUploadPage=ew,exports.CANDIDATES_URL=t.y,exports.CONTRACT_C2C=mf,exports.CONTRACT_W2=pf,exports.CalendarCard=E,exports.CoreThemeAdminApp=Av,exports.CoreThemeAdminRoutes=kv,exports.CustomPagination=ge,exports.DayLogModal=Hd,exports.DescriptionBlock=cs,exports.DetailHeaderCard=Wc,exports.DetailViewPage=Zc,exports.DetailViewV1=Ys,exports.DocumentViewer=e.On,exports.DynamicCards=at,exports.DynamicPopup=ib,exports.DynamicPopupRoute=ex,exports.DynamicTabs=A,exports.EditFormV1=Ul,exports.FINANCE_APPROVAL_CONFIG=cf,exports.FINANCE_TYPE_CFO=rf,exports.FINANCE_TYPE_ONBOARDING_MANAGER=nf,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=of,exports.FINANCE_TYPE_SUBMISSION_MANAGER=tf,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=af,exports.FinanceApprovalPanel=Pf,exports.FinanceAvatar=md,exports.FinanceBadge=vd,exports.FinanceDayCell=Zd,exports.FinanceDetailHeader=wd,exports.FinanceDivider=id,exports.FinanceEmployeeCell=hd,exports.FinanceEmptyState=td,exports.FinanceEquation=ad,exports.FinanceHistoryTimeline=ld,exports.FinanceHoursGrid=ed,exports.FinanceKpiRow=$u,exports.FinanceLine=rd,exports.FinanceListToolbar=dd,exports.FinanceMarginBadge=yd,exports.FinanceMoneyCell=_d,exports.FinanceRecordsTable=Sd,exports.FinanceRowChevron=bd,exports.FinanceSection=nd,exports.FinanceStatusPill=Qu,exports.FinanceTextCell=gd,exports.FinanceTimesheetAnalysis=$d,exports.FinanceWorkflowSteps=od,exports.Header=pp,exports.JOBS_URL=t.b,exports.LegacyAdminPage=QC,exports.ListView=ha,exports.LmsHomePage=cw,exports.LmsTestForm=sw,exports.Login=Wp,exports.MailPopup=Rv,exports.ManageModules=rw,exports.ManageSubmodules=iw,exports.ModuleRowActions=Ql,exports.NotesPanel=Jd,exports.PAYROLL_STATUS_FLOW=Mu,exports.POPUP_CONFIGS=Wb,exports.ParamCardView=au,exports.ParamListView=du,exports.PreviewPopup=gy,exports.ProjectSelect=ym,exports.ProofUploadPreview=qd,exports.QuickLogBar=Gd,exports.QuickLogSelectionBar=Ud,exports.RejectionReasonModal=Wd,exports.SUBMISSIONS_URL=t.x,exports.Sidebar=Lp,exports.StatusBadge=pu,exports.StickyNotesFullPage=$C,exports.StylishDynamicTabs=hu,exports.TemplateEditor=bu,exports.TestForm=tw,exports.TestingHomePage=ow,exports.TimesheetDayCell=Ld,exports.TimesheetSummaryPanel=Kd,exports.TipTapEditor=e.kn,exports.UserForm=px,exports.VendorShareDrawer=ix,exports.ViewSummaryWidget=wr,exports.WizardPopup=Sy,exports.ZinnextTableView=aw,exports.ZinnextTestForm=nw,exports.approveSubmission=ie,exports.buildCsv=Ku,exports.buildDailyRows=Bu,exports.buildDayGradient=Fd,exports.buildRateHistoryEntries=Df,exports.buildWeeklyRollup=Uu,exports.clearSelectedProject=t.n,exports.colors=e.Mn,exports.computeFinance=Tf,exports.computeMarginBand=Wu,exports.configureCoreTheme=t.S,exports.createAllWorkflowsListFetcher=JC,exports.createWorkflowStageListFetcher=UC,exports.deriveDayStats=zu,exports.downloadCsv=Xu,exports.findEmployerRow=yf,exports.flattenGroups=vf,exports.formatFinanceMoney=Of,exports.formatHours=Cu,exports.formatMoney=Su,exports.formatRate=wu,exports.getActivity=e.Z,exports.getAllWorkflowsModuleList=YC,exports.getApprovalDate=Ou,exports.getBillingActionStates=Nu,exports.getCurrentRoleName=t.o,exports.getFieldLabel=Ju,exports.getFinanceApprovalConfig=uf,exports.getFormGroupsRaw=zf,exports.getModuleConfig=he,exports.getModuleDataDetail=e.$,exports.getPayrollActionStates=Pu,exports.getSelectedProject=t.s,exports.getStoredToken=t.c,exports.getStoredUser=t.l,exports.getUserRoles=t.u,exports.getVMSApprove=ae,exports.getValueStyle=Yu,exports.getWorkflowStageModuleList=XC,exports.getWorkflowSteps=Fu,exports.humanizeEvent=Du,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Na}}),exports.indexFieldConfig=qu,exports.initialsOf=Tu,exports.isTester=t.d,exports.logout=t.p,exports.marginIncludesReferral=ff,exports.matchLocationTax=wf,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return el}}),exports.normalizeContract=xf,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Xo}}),exports.rejectSubmission=oe,exports.resolveActivityMeta=Go,exports.resolveAndCompute=Ef,exports.resolveFinanceInputs=Cf,exports.resolveMergeKey=MC,exports.resolveRejectionReason=df,exports.resolveSubmissionFinance=Bf,exports.setSelectedProject=t.m,exports.stageCountKey=WC,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Gp}}),exports.useDropdownFields=Zt,exports.useDropdownValues=Er,exports.useEditForm=Vf,exports.useFieldConfig=Qt,exports.useFilterFields=$t,exports.useMenuPermission=on,exports.useModuleActions=Gl,exports.useRecordRefresh=Jc,exports.withAdminAppId=t.C,exports.withAppId=t.w,exports.withAuthGuard=bm;
10
10
  //# sourceMappingURL=index.cjs.map