@realtek/core-theme 0.0.184 → 0.0.185
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/index.cjs.map +1 -1
- package/dist-lib/index.js +641 -589
- package/dist-lib/index.js.map +1 -1
- package/package.json +1 -1
package/dist-lib/index.cjs
CHANGED
|
@@ -6,5 +6,5 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
6
6
|
`).replace(/<[^>]+>/g,` `),t=t.replace(/ /gi,` `).replace(/&/gi,`&`).replace(/</gi,`<`).replace(/>/gi,`>`).replace(/'|'/gi,`'`).replace(/"/gi,`"`),t.replace(/[ \t\f\v]+/g,` `).replace(/\n{2,}/g,`
|
|
7
7
|
`).trim()}function Ny(e){return e.replace(/•/g,`
|
|
8
8
|
`).split(/\n+/).map(e=>e.trim().replace(/^[-–—•]\s*/,``).trim()).filter(Boolean)}function Py(e){return Ny(e.replace(/(?:^|\s)[-–—]\s+/g,`
|
|
9
|
-
`))}function Fy(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:Ay(n),value:r}}function Iy(e){let t=e.toLowerCase().replace(/[\s:.\-–—]+$/,``).trim();return Ey.has(t)?Dy.test(t)?`education`:Oy.test(t)?`keySkills`:`overview`:null}function Ly(e){let t=[],n={overview:[],keySkills:[],education:[]},r=`overview`;return e.forEach(e=>{let i=Iy(e);if(i){r=i;return}if(r===`overview`){let n=Fy(e);if(n){t.push(n);return}}n[r].push(e)}),{meta:t,overview:jy(n.overview),keySkills:jy(n.keySkills),education:jy(n.education)}}function Ry(e){let t=[...Ty].sort((e,t)=>t.length-e.length),n=RegExp(`\\b(${t.map(ky).join(`|`)})\\b\\s*:?`,`gi`),r=[...e.matchAll(n)];if(!r.length)return{meta:[],overview:jy(Py(e)),keySkills:[],education:[]};let i={overview:[],keySkills:[],education:[]},a=e.slice(0,r[0].index).trim();return a&&i.overview.push(...Py(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=Py(e.slice(o,s).trim());c.length&&i[Dy.test(a)?`education`:Oy.test(a)?`keySkills`:`overview`].push(...c)}),{meta:[],overview:jy(i.overview),keySkills:jy(i.keySkills),education:jy(i.education)}}function zy(e){let t=My(e);if(!t)return{meta:[],overview:[],keySkills:[],education:[]};let n=Ny(t);return n.length>=4?Ly(n):Ry(t)}function By({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 Vy({raw:e=``,meta:t=[]}){let[n,i]=(0,r.useState)(!1),a=(0,r.useMemo)(()=>zy(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)(Cy,{type:`secondary`,children:`No description available.`});let l=n?c:c.slice(0,wy),u=c.length-wy;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)(By,{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:Hy}=i.Typography;function Uy(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function Wy(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 Gy(e){return e?e.email??e.emailId??e.emailAddress??``:``}function Ky(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function qy(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 Jy=[`jobDescription`,`description`,`rawDescription`,`jobDescriptionText`];function Yy(e){return String(e??``).toLowerCase()===`job`}function Xy(e){let t=Jy.includes(e.field),n=/description/i.test(e.label??``);return t||n}function Zy({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 Qy({record:e}){let t=Wy(e),n=Gy(e),r=Ky(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:Uy(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 $y({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=Yy(t)&&Xy(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:qy(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)(Vy,{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:qy(n)})]},e.field??e.label)})}):null}function eb(){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.In({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)(Hy,{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)($y,{fields:e.fields,moduleName:n}):(0,o.jsx)(Hy,{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)(Zy,{steps:C,current:g,onStepClick:_})}),(0,o.jsxs)(`div`,{className:`wizard-body`,children:[c&&(0,o.jsx)(Qy,{record:c}),E()]})]})}var{Text:tb}=i.Typography,{TextArea:nb}=i.Input,rb=[{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 ib(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)(nb,{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 ab({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)(tb,{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)(tb,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,o.jsx)(`div`,{className:`wizard-review-empty`,children:(0,o.jsx)(tb,{type:`secondary`,children:`No data entered yet.`})})}function ob(){let[e]=i.Form.useForm(),t=(0,s.useNavigate)(),{title:n=`Wizard`,moduleName:a=``,steps:c=rb,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:ib(e)})},e.name))})},e.key)),f.isReview&&(0,o.jsx)(ab,{steps:c,form:e})]})})]})}function sb({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 cb({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.Wn,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:t}),n&&(0,o.jsx)(e.Wn,{variant:`body`,className:`dynamic-popup__description`,children:n}),r&&i>0&&(0,o.jsxs)(e.Wn,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,o.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),s&&(0,o.jsx)(e.Wn,{variant:`body`,children:s}),c&&(0,o.jsx)(e.Wn,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:c})]})}function lb({footerNote:t}){return t?(0,o.jsx)(e.Wn,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:t}):null}var{TextArea:ub}=i.Input,db=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],fb=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function pb(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 mb({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 hb({field:e,value:t,onChange:n}){return(0,o.jsx)(ub,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function gb({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{value:n,onChange:r,options:pb(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function _b({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{mode:`multiple`,value:n,onChange:r,options:pb(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function vb({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:pb(t),placeholder:e.placeholder,onSearch:n,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function yb({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 bb({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:db,onChange:e=>a({currency:e}),style:{width:80}}),(0,o.jsx)(i.Select,{value:n,options:fb,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 xb({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 Sb({field:e,checked:t,onChange:n}){return(0,o.jsx)(i.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function Cb({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 wb({options:e,value:t,onChange:n}){return(0,o.jsx)(i.Radio.Group,{value:t,onChange:n,options:e})}var Tb={input:mb,text:mb,textarea:hb,select:gb,"multi-select":_b,"search-select":vb,"mention-textarea":yb,"candidate-rate":bb,"priority-checkbox":Sb,"date-picker":xb,number:Cb,radio:wb};function Eb(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}function Db(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function Ob(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 kb(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 Ab(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:Ob(kb(e))}:e,o=(i?Db(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]??``),c=e?.disabled===!0||e?.disable===!0,l=String(e?.optionNote??``).trim(),u={label:l?`${String(o)} — ${l}`:String(o),value:String(s),_raw:e};return c&&(u.disabled=!0),l&&(u.title=l),u}function jb(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>Ab(t,e))}function Mb(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var Nb=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function Pb({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.Wn,{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:Fb(n).map(t=>Ib(t,t=>{let n=a[t.name]??jb(t,s),r=p(t),c=m(t),l=h[t.name]??[],u=Eb(t.type),d=Tb[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()}}),Nb.has(t.type)&&f.push(e.U({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 Fb(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 Ib(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 Lb({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 Rb=500,zb=3;function Bb({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<zb){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=>Ab(e,r))}))}).catch(e=>{a.signal.aborted||console.error(`[DynamicPopup] Search failed for field "${r.name}":`,e)})},Rb)}}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 Vb({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(()=>{i.message.success(t.successMessage||`Deleted successfully`),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 Hb({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)(()=>Mb(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}=Lb({open:e,config:t,api:l,fields:x,popupContext:g,formValues:d}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=Bb({api:l,open:e,popupContext:g,setDynamicOptions:w});function k(e){typeof a==`function`&&a(e)}let{handleOk:A,confirming:j,deleteError:M,resetSubmitState:N}=Vb({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)(sb,{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)(sb,{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)(cb,{note:H,description:t.description,showSelectedCount:t.showSelectedCount,count:F,itemLabel:L,bodyText:V,deleteError:M}),(0,o.jsx)(lb,{footerNote:t.footerNote}),(0,o.jsx)(Pb,{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 Ub={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:[]},Wb={deleteItems:async(e,t)=>{await I(t.moduleName,e)}},Gb={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`}]},Kb=`Already submitted`;function qb(e){return String(e?.applicantId??e?._id??e?.id??``)}function Jb(e,t){return{...e,label:`${e.label} — ${Kb}`,disabled:!0,title:`${Kb}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``}}var Yb={searchOptions:async(e,t,n)=>{if(e.searchFetchKey===`quickSubmitJobList`){let e=n.selectedRecords?.[0]??{},r=e.id??e._id??n.selectedIds?.[0],i,a=!0;try{i=await le({searchQuery:t,candidateId:r})}catch{a=!1;let e=await fn({searchQuery:t,candidateId:r});i=Array.isArray(e?.data)?e.data:[]}let o=i.map(e=>({label:[e.jobReferenceId??e.clientJobReferenceId,e.jobTitle].filter(Boolean).join(` - `)||String(e._id??``),value:e._id??``,_raw:e}));if(a)return o.map(e=>{if(e._raw?.alreadySubmitted)return Jb(e,e._raw?.submissionId||``);if(e._raw?.disable){let t=String(e._raw?.message??``).trim();return{...e,disabled:!0,label:t?`${e.label} — ${t}`:e.label,title:t}}return e});let s=await de({applicantId:r,jobIds:o.map(e=>e.value)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e.value));return t?Jb(e,t.submissionId):e})}if(e.searchFetchKey===`quickSubmitCandidates`){let e=n.selectedRecords?.[0]??{},r=n.jobId??e.jobId??e.id??e._id??n.selectedIds?.[0],i,a=new Map;try{i=await ue({search:t,jobId:r})}catch{let e=await Va({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await de({jobId:r,applicantIds:i.map(qb)}).catch(()=>new Map)}return i.map(e=>{let t=a.get(qb(e));if(!t&&!e?.isFromSubmission&&!e?.alreadySubmitted)return e;let n=t?.submissionId||e?.submissionId||``;return{...e,disabled:!0,optionNote:Kb,alreadySubmitted:!0,existingSubmissionId:n}})}return[]},submit:async(e,t,n)=>{let{navigate:r,selectedRecords:i=[],selectedIds:a=[],moduleName:o}=t,s=i[0]??{},c,l;t.jobId?(c=t.jobId,l=s.id??s._id??a[0]??``):o===`candidate`?(c=e.jobId??``,l=s.id??s._id??a[0]??``):(c=s.jobId??s.id??s._id??a[0]??``,l=e.candidate??``);let u=n?.dynamicOptions?.candidate?.find(e=>qb(e?._raw)===String(l)),d=n?.dynamicOptions?.jobId?.find(e=>String(e?.value)===String(c)),f=u?._raw?.alreadySubmitted||u?._raw?.isFromSubmission||d?.alreadySubmitted||d?._raw?.alreadySubmitted;if(!c||!l)throw Error(`Select both a job and a candidate to quick submit.`);let p=f,m=t.submissionId||u?._raw?.existingSubmissionId||u?._raw?.submissionId||d?.existingSubmissionId||s.submissionId||``;try{let e=await ce({jobId:c,applicantId:l});p||=!!e?.exists,m=e?.submissionId||m}catch(e){throw Error(`Could not verify existing submissions (${e?.message??`request failed`}). Please try again.`,{cause:e})}if(p)throw Error(`This candidate is already submitted for this job${m?` (submission ${m})`:``}.`);let h=new URLSearchParams;return l&&h.set(`candidateId`,l),h.set(`isFromSubmission`,`false`),r(`/submission-create/${c}?${h.toString()}`),{navigated:!0}}},Xb={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`}]},Zb=e=>e?.data??e;async function Qb({relatedId:e,notes:n,title:r,notesFor:i}){return Zb(await qt(t.v,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var $b={getMentionOptions:async(e,t)=>R(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 Qb({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},ex={name:`jobId`,label:`Job Title / ID`,type:`search-select`,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle}`},tx={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`goodfited`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},nx={title:`Tag to Job`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[tx]:[ex,tx]},rx={searchOptions:async(e,t)=>e.searchFetchKey===`tagToJobJobList`?L(t):[],submit:async(e,t)=>{await H({jobId:e.jobId??t.jobId,candidateIds:t.selectedIds,hiringStage:e.hiringStage??t.hiringStage})}},ix={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`}]}]},ax={submit:async(e,t)=>{await F(t.moduleName,t.selectedIds,e.status)}},ox={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:[]},sx={onOk:async e=>{await fe({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},cx={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`}]},lx={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?U():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await W({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},ux=[{title:`Name`,key:`name`,render:(e,t)=>`${t.first_name??``} ${t.last_name??``}`.trim()||t.user_name||t.name||`-`},{title:`Role`,dataIndex:`role_name`,key:`role`,render:e=>e||`-`},{title:`Reporting`,dataIndex:`reporting_name`,key:`reporting`,render:e=>e||`-`}];function dx({selectedIds:e,onClose:t}){let n=e?.[0],[s,c]=(0,r.useState)(!0),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)({assignedUsers:[],totalSubmissions:0,message:``});return(0,r.useEffect)(()=>{let e=!1;return c(!0),ee(n).then(t=>{e||f(t)}).catch(t=>{e||(i.message.error(t?.message??`Failed to load self-assign details`),f({assignedUsers:[],totalSubmissions:0,message:``}))}).finally(()=>{e||c(!1)}),()=>{e=!0}},[n]),s?(0,o.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,o.jsx)(i.Spin,{size:`large`})}):(0,o.jsxs)(`div`,{className:`self-assign-popup-body`,children:[Number(d.totalSubmissions)>0&&(d.assignedUsers?.length??0)>0?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{style:{fontWeight:700,marginBottom:8},children:`Team Members Allocated`}),(0,o.jsx)(i.Table,{columns:ux,dataSource:d.assignedUsers,pagination:!1,rowKey:e=>e.user_id??`${e.first_name}-${e.last_name}`,size:`small`,className:`mb-3 no-header-bg`,scroll:{y:200}}),(0,o.jsxs)(`div`,{className:`warning-card`,style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,o.jsx)(a.ExclamationCircleFilled,{style:{color:`#faad14`,fontSize:18}}),(0,o.jsx)(`div`,{style:{fontSize:13},children:`These users are already assigned to this job. Do you still want to assign yourself as well?`})]})]}):(0,o.jsx)(`div`,{style:{padding:`8px 0`},children:d.message||`Are you sure you want to assign this job?`}),(0,o.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:12,marginTop:24},children:[(0,o.jsx)(i.Button,{size:`small`,onClick:()=>t?.(),disabled:l,children:`No`}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,onClick:async()=>{u(!0);try{await G({jobIds:[n]}),i.message.success(`Job assigned successfully`),t?.({success:!0})}catch(e){i.message.error(e?.message??`Failed to assign job`)}finally{u(!1)}},loading:l,children:`Yes`})]})]})}dx.propTypes={selectedIds:l.default.array,onClose:l.default.func};var fx={title:`Self Assign`,width:480,className:`self-assign-modal`,component:dx},px={submit:async()=>{}},mx={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`}]},hx={getOptions:async e=>e.fetchOptionsKey===`assignToUsers`?K():[],loadExtraData:async e=>ne(e.selectedIds[0]),submit:async(e,t,{removedIds:n,extraData:r})=>{await re({jobIds:t.selectedIds,userId:e.assignToUserId,rate:e.candidateRate,priority:e.priority,removedIds:n,existingRecruiters:r?.recruitersData})}},gx={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`}]},_x={getMentionOptions:async(e,t)=>R(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await B(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await z({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},vx={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`}]},yx={submit:async(e,t)=>{await ie({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function bx(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var xx={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function Sx(e,t,n){let r=bx(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function Cx(e){let t=e.selectedRecords?.[0]??{},n=Sx(t,`candidateRate`,`candidateAcceptedRate`)??Sx(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=Sx(t,`candidateRate`,`candidateAcceptedCurrency`)??Sx(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:Sx(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??Sx(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??xx[String(r??``).toUpperCase()]??(r||`$`),unit:Sx(t,`candidateRate`,`candidateAcceptedPayUnit`)??Sx(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var wx={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=Cx(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=Cx(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`}]}]},Tx={submit:async(e,t)=>{let n=t.selectedIds[0];if(await ae(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await oe(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 Ex(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 Dx({selectedIds:e,selectedRecords:t,onClose:n}){let a=t?.[0]??{},s=e?.[0]??Gf(a),[c,l]=(0,r.useState)(null),[u,d]=(0,r.useState)(!0);(0,r.useEffect)(()=>{let e=!1;return d(!0),hp(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 ae(s,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currency,candidateProposedRateUnit:`hr`,submitVia:`Mail`}),i.message.success(`Submission approved`),n?.({success:!0})},submissionReject:async({reason:e})=>{await se({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)(lp,{type:Ef,record:c.record,lookups:c.lookups,identity:Ex(a,c.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:f,onClose:()=>n?.(),variant:`popup`})}Dx.propTypes={selectedIds:l.default.array,selectedRecords:l.default.array,onClose:l.default.func};var Ox={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:Dx},kx={submit:async()=>{}};function Ax(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 jx(e){let t=Array.isArray(e)?e:[];for(let e=t.length-1;e>=0;--e)if(String(t[e]?.activityType??``).trim().toLowerCase()===`cfo rejected`)return t[e];return null}function Mx({selectedIds:t,selectedRecords:n,onClose:a}){let s=n?.[0]??{},c=t?.[0]??Gf(s),[l,u]=(0,r.useState)(null),[d,f]=(0,r.useState)(!0);(0,r.useEffect)(()=>{let t=!1;return f(!0),Promise.all([hp(c,s),e.tt(`submission`,c).catch(()=>[])]).then(([e,n])=>{if(t)return;let r=jx(n);u({...e,record:{...e.record,submission:{...e.record.submission,cfoRejectionReason:r?.activityComments??``,cfoRejectedAt:r?.activityTime??null}}})}).catch(e=>{t||(i.message.error(e?.message??`Unable to load finance details`),u({record:{submission:s},lookups:{},display:{}}))}).finally(()=>{t||f(!1)}),()=>{t=!0}},[c]);let p=(0,r.useMemo)(()=>({submissionApprove:async({computed:e})=>{await ae(c,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currency,candidateProposedRateUnit:`hr`,submitVia:`Mail`}),i.message.success(`Submission re-approved`),a?.({success:!0})},submissionReject:async({reason:e})=>{await se({submissionId:c,rejectReasonId:2,rejectReason:`Rate not approved`,rejectReasonComments:e}),i.message.success(`Submission rejected`),a?.({success:!0})}}),[c,a]);return d||!l?(0,o.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,o.jsx)(i.Spin,{size:`large`})}):(0,o.jsx)(lp,{type:kf,record:l.record,lookups:l.lookups,identity:Ax(s,l.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:p,onClose:()=>a?.(),variant:`popup`})}Mx.propTypes={selectedIds:l.default.array,selectedRecords:l.default.array,onClose:l.default.func};var Nx={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:Mx},Px={submit:async()=>{}},Fx=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],Ix={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:Fx.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},Lx={submit:async(e,t)=>{let n=Fx.find(t=>String(t.id)===String(e.rejectReason));await se({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},Rx={delete:Ub,"quick-submit":Gb,"add-notes":Xb,"tag-to-job":nx,"change-status":ix,"remove-from-shortlist":ox,"add-to-groups":cx,"self-assign":fx,"others-assign":mx,"sticky-notes":gx,"move-to-onboarding":vx,"approve-rate":wx,"manager-approve":Ox,"manager-reapprove":Nx,reject:Ix},zx={delete:Wb,"quick-submit":Yb,"add-notes":$b,"tag-to-job":rx,"change-status":ax,"remove-from-shortlist":sx,"add-to-groups":lx,"self-assign":px,"others-assign":hx,"sticky-notes":_x,"move-to-onboarding":yx,"approve-rate":Tx,"manager-approve":kx,"manager-reapprove":Px,reject:Lx};function Bx(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function Vx(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 Hx(e){let t=Vx(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[Vx(e,`firstName`,`first_name`),Vx(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function Ux(e){return String(Vx(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function Wx(e){return String(Vx(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function Gx({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.Rn(`onboarding`,200,0).then(e=>{t||l(Bx(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=>[Hx(t),Vx(t,`email`,`candidateEmail`,`candidate_email`),Vx(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(Wx(e)));if(n.length){_(!0),y(``);try{let{userId:r}=t.a();await Promise.all(n.map(t=>e.mt(`batchCandidates`,{schemaVersion:1,batchId:b,candidateId:Ux(t),workforceEngagementId:Wx(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=>Wx(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>Hx(t)},{title:`Email`,key:`email`,render:(e,t)=>Vx(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>Vx(t,`status`,`onboardingStatus`,`onboarding_status`)||`—`}],dataSource:x,loading:m,size:`small`,pagination:{pageSize:10,showSizeChanger:!1},rowSelection:{selectedRowKeys:u,onChange:d,getCheckboxProps:e=>({disabled:!Ux(e)||!Wx(e)})},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var Kx={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function qx(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:Kx[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 Jx({apiMap:n={},extraConfigs:i={}}){let a=(0,r.useMemo)(()=>({...zx,...n}),[n]),c=(0,r.useMemo)(()=>({...Rx,...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.zt(d.moduleName,`popup`,l).then(e=>{t||p({key:n,config:qx(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]),_=e=>{let t=d.background;if(e?.success&&t?.pathname){u(`${t.pathname}${t.search??``}`,{replace:!0,state:{...t.state??{},refreshTimestamp:Date.now()}});return}u(-1)};return l===`add-batch-candidate`?(0,o.jsx)(Gx,{open:!0,context:h,onClose:_}):(0,o.jsx)(Hb,{open:!0,config:m,context:h,onClose:_,api:{...a[l]??{},...g}})}var Yx={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`}]},Xx={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>zt({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>Bt(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>Vt({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},Zx=Yx.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function Qx(){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)(Yx.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)(Yx.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 Xx.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&&Xx.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([...hy(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function V(e){let t=new Set(z);g({...e,bcc:hy(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let H=(hy(B.to).length||hy(B.bcc).length)&&gy(B.to)&&gy(B.cc)&&gy(B.bcc)&&B.subject.trim(),U=e=>e===`myVendor`?T:D;function W(){e(-1)}function G(){H&&Xx.submit({jobId:m,toMail:hy(B.to),ccMail:hy(B.cc),bccMail:hy(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:Yx.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:Zx,dataSource:ee,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>Yx.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,o.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,o.jsx)(xe,{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)(xy,{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,` / `,Yx.maxVendorSelect,` Vendors selected`]}):null})})]})})}var $x={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].*$/},eS={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},tS={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 ${eS.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.`},nS={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},rS={REMARKS_MIN:10,REMARKS_MAX:250},iS={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)}`}},aS={required:(e=`Field`)=>({required:!0,message:tS.REQUIRED(e)}),email:()=>({pattern:$x.EMAIL,message:tS.INVALID_EMAIL}),phone:()=>({pattern:$x.PHONE,message:tS.INVALID_PHONE}),password:()=>({pattern:$x.PASSWORD,message:tS.INVALID_PASSWORD}),alphabets:()=>({pattern:$x.ALPHABETS,message:tS.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:$x.ALPHANUMERIC,message:tS.INVALID_ALPHANUMERIC}),number:()=>({pattern:$x.NUMBER,message:tS.INVALID_NUMBER}),url:()=>({pattern:$x.URL,message:tS.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:$x.CANDIDATE_ID,message:tS.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:$x.REMARKS,message:tS.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${rS.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${rS.REMARKS_MAX} characters.`}),designation:()=>({pattern:$x.DESIGNATION,message:tS.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!$x.DOB.test(n))return Promise.reject(Error(tS.INVALID_DOB));let r=(0,c.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(tS.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:$x.LINKEDIN,message:tS.INVALID_LINKEDIN}),companyName:()=>({pattern:$x.COMPANY_NAME,message:tS.INVALID_COMPANY_NAME}),firstName:()=>({pattern:$x.FIRST_NAME,message:tS.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${nS.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${nS.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:nS.FIRST_NAME_MIN,message:tS.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:nS.FIRST_NAME_MAX,message:tS.FIRST_NAME_MAX}),remarksMinLength:()=>({min:rS.REMARKS_MIN,message:tS.REMARKS_MIN}),remarksMaxLength:()=>({max:rS.REMARKS_MAX,message:tS.REMARKS_MAX}),fullName:()=>({pattern:$x.FULL_NAME,message:tS.INVALID_FULL_NAME}),noSpaces:()=>({pattern:$x.NO_SPACES,message:tS.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:$x.STARTS_WITH_CAPITAL,message:tS.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<=eS.MAX_FILE_SIZE))return i.message.error(tS.INVALID_FILE_SIZE),Promise.reject(Error(tS.INVALID_FILE_SIZE));if(!eS.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(tS.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>eS.SINGLE_FILE_COUNT)return Promise.reject(Error(tS.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<eS.MAX_FILE_SIZE?eS.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(tS.INVALID_FILE_TYPE)):Promise.reject(Error(tS.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>eS.MULTI_FILE_COUNT)return Promise.reject(Error(tS.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<eS.MAX_FILE_SIZE))return Promise.reject(Error(tS.INVALID_FILE_SIZE));if(!eS.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(tS.INVALID_FILE_TYPE))}return Promise.resolve()}})},oS={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)},sS=()=>{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:[aS.required(`Email`),aS.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:[aS.required(`Phone Number`),aS.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:iS.phoneFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Password`,name:`password`,rules:[aS.required(`Password`),aS.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:[aS.required(`Full Name`),aS.alphabets(),aS.firstNameMinLength(),aS.firstNameMaxLength()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({fullName:iS.firstNameFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Username`,name:`username`,rules:[aS.required(`Username`),aS.alphanumeric()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({username:iS.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Website URL`,name:`website`,rules:[aS.required(`Website URL`),aS.url()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({website:iS.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:[aS.required(`MSP Req ID`),aS.candidateId(`MSP Req ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({mspreqID:iS.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[aS.required(`Candidate ID`),aS.candidateId(`Candidate ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({candidateId:iS.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:24,children:(0,o.jsx)(i.Form.Item,{label:`Remarks`,name:`remarks`,rules:[aS.required(`Remarks`),aS.remarks(),aS.remarksMinLength(),aS.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:[aS.required(`Designation`),aS.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:[aS.dob()],children:(0,o.jsx)(i.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:iS.dobFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Company Name`,name:`companyName`,rules:[aS.required(`Company Name`),aS.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:oS.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:[aS.multiFileUpload()],children:(0,o.jsx)(i.Upload,{multiple:!0,beforeUpload:oS.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:[aS.fileUpload()],children:(0,o.jsx)(i.Upload,{beforeUpload:oS.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 cS(e){return(0,o.jsx)(ym,{children:(0,o.jsx)(uy,{...e})})}var{Text:lS}=i.Typography,uS=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],dS={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 fS({stats:e=uS}){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:[dS[e.icon]??dS.fileText,(0,o.jsx)(lS,{children:e.label})]}),(0,o.jsx)(i.Statistic,{value:e.value})]})},e.label))})})}var{Text:pS}=i.Typography;function mS(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 hS(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:mS(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function gS(){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.Mt({offset:t,limit:r,searchQuery:a??``}),o=(i.users??[]).map(hS);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)(Lu,{listName:`Users`,dataSource:t,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,o.jsxs)(`div`,{children:[(0,o.jsx)(pS,{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:_S}=i.Typography,vS=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],yS=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function bS({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 xS({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.sn(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.Mn(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:vS.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)(bS,{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 `,vS.find(e=>e.key===f)?.label]})})]})}function SS(){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.jt();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.jn(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)(Lu,{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:yS.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)(xS,{team:t,configType:d},`${t?.teamId}-${d}`)]})]})}var CS=[`view`,`add`,`edit`,`delete`],wS={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 TS(e){return wS[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function ES(e){let t=CS.filter(t=>e.includes(t)),n=e.filter(e=>!CS.includes(e)).sort();return[...t,...n]}function DS(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),ES([...t])}function OS(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{Oh(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function kS({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 AS({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 jS({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:s,onActionLabelSave:c}){let l=t?.permissions??{},u=n.filter(t=>Oh(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)(kS,{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)(AS,{entry:l[t],label:a[t]??TS(t),onToggle:()=>r(e,t),onLabelSave:e=>c(t,e)},t))})]})}function MS({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.rn(t);(0,r.useEffect)(()=>{b&&(h(!0),y(!1),e.an(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.kn(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)(()=>DS(f),[f]),{enabled:T,total:E}=(0,r.useMemo)(()=>OS(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)(jS,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:n[e]??e,actionLabels:s,onModuleLabelSave:c,onActionLabelSave:l},e))})]})}var{Text:NS}=i.Typography,PS=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function FS(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function IS(e){return String(e||``).trim().toLowerCase()}function LS(e){return e?.key||e?.collectionName||e?.value||``}function RS(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=LS(e);if(!t)return;let o=IS(e.key||t),s=IS(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||FS(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=IS(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:FS(t),value:t,disabled:!1}))}),n}function zS(){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.At();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.Ht(),e.Pt()]),r=RS(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.bn(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)(NS,{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)(Lu,{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:PS.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)(MS,{role:t},t?.roleId):(0,o.jsx)(Wh,{role:t,configType:l},`${t?.roleId}-${l}`))]})]})}var BS=`perm-module-labels`,VS=`perm-action-labels`;function HS(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function US(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function WS({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 GS({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.Yt())}catch{i.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await e.Jt())}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.ft({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.Tn(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.xt(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.dt({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.wn(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.bt(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)(WS,{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)(WS,{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 KS(){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)(()=>HS(BS)),[_,v]=(0,r.useState)(()=>HS(VS)),y=(0,r.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return US(BS,r),r})},[]),b=(0,r.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return US(VS,r),r})},[]);function x(){g({}),v({}),US(BS,{}),US(VS,{}),i.message.success(`Labels reset to defaults`)}let S=(0,r.useCallback)(async()=>{c(!0);try{let{roles:t}=await e.At();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)(MS,{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)(GS,{open:p,onClose:()=>m(!1)})]})}var{Title:qS,Text:JS}=i.Typography,YS=[{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 XS({items:e=YS}){return(0,o.jsx)(i.Card,{className:`onboarding-card`,title:(0,o.jsx)(qS,{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)(JS,{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)(JS,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:ZS,Title:QS}=i.Typography,$S=[{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`},{id:`bgc-integration`,label:`Integrations`,icon:(0,o.jsx)(a.SafetyOutlined,{}),heading:`Integrations`,desc:`Manage manual and API integrations used across application workflows.`,component:`bgc-integration`}]},{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.`}]}]}],eC=[{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}],tC=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],nC=[{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 rC(){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)(QS,{level:5,children:`Admin Dashboard`}),(0,o.jsx)(ZS,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,o.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,o.jsx)(fS,{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)(XS,{}),(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,o.jsx)(ZS,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,o.jsx)(`div`,{className:`admin-pipeline-bar`,children:eC.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:eC.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)(ZS,{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)(ZS,{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)(ZS,{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)(ZS,{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:tC.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:nC.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)(ZS,{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)(ZS,{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)(ZS,{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)(ZS,{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)(ZS,{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)(ZS,{style:{fontSize:12},children:e}),(0,o.jsx)(ZS,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function iC({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)(QS,{level:5,children:e?.heading}),(0,o.jsx)(ZS,{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)(ZS,{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:$S.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 aC(){let[e,t]=(0,r.useState)(`dashboard`),[n,s]=(0,r.useState)(``),c=(0,r.useMemo)(()=>$S.flatMap(e=>e.items),[]),l=(0,r.useMemo)(()=>c.find(t=>t.id===e),[c,e]),u=(0,r.useMemo)(()=>$S.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)(()=>$S.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:$S.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)(rC,{}):l?.component===`form-groups`?(0,o.jsx)(Lg,{}):l?.component===`detail-groups`?(0,o.jsx)(o_,{}):l?.component===`row-actions`?(0,o.jsx)(J_,{}):l?.component===`users`?(0,o.jsx)(gS,{}):l?.component===`teams`?(0,o.jsx)(SS,{}):l?.component===`roles`?(0,o.jsx)(zS,{}):l?.component===`permissions`?(0,o.jsx)(KS,{}):l?.component===`templates`?(0,o.jsx)(rv,{}):l?.component===`ai-services`?(0,o.jsx)(sv,{}):l?.component===`bgc-integration`?(0,o.jsx)(pv,{}):(0,o.jsx)(iC,{activeSection:l,activeGroup:u,filteredCards:d,searchText:n,setSearchText:s,allItems:c,handleNav:p})})]})]})}var{Title:oC}=i.Typography;function sC(){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)(bt,{moduleName:n,title:r,columns:4,request:c,viewAll:!1})]})}var{Text:cC,Title:lC}=i.Typography,uC=10*1024*1024,dC=`/templates/test_cases_flow_template.base64.txt`,fC=`test_cases_flow_template.xlsx`,pC=`module | subModule | step_order | description | actions | key | value | expected | scenario`,mC={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},hC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function gC(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 _C(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function vC(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function yC({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 bC({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 xC({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)(cC,{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)(yC,{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 SC(){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=vC(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=mC[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 Im({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>uC){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 gC(e);g(`validating`),S((await jm({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(dC);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=fC,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 Mm({project:c?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:_C(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:hC})}),c?.name&&(0,o.jsx)(i.Col,{children:(0,o.jsx)(cC,{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)(lC,{level:3,children:`Bulk upload test cases`}),(0,o.jsxs)(i.Space,{direction:`vertical`,size:4,children:[(0,o.jsx)(cC,{type:`secondary`,children:pC}),(0,o.jsx)(cC,{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)(bC,{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)(xC,{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)(cC,{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)(cC,{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)(cC,{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 CC=[{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:wC}=i.Typography,TC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],EC={tags:`regression`,active:1},DC={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function OC(e=[]){return e.map(e=>({value:e,label:e}))}function kC(e=``){return String(e??``).trim()}function AC(e=``){return kC(e).toLowerCase()}function jC(e=[]){let t=new Map;return e.forEach(e=>{let n=kC(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function MC(e=[],t,n){let r=kC(t).toLowerCase(),i=kC(n).toLowerCase();return e.reduce((e,t)=>{let n=kC(t?.module).toLowerCase(),a=kC(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 NC({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)(wC,{strong:!0,className:`v1-section-label`,children:t})]})}function PC(){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=DC[v.typeKey],O=(0,r.useMemo)(()=>OC(c),[c]),k=i.Form.useWatch(`module`,t),A=i.Form.useWatch(`flow`,t),j=!!kC(k),M=!!kC(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&l(t)},I=async()=>{h(!0);try{l((await Em(DC.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=kC(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await Am({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(jC(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=kC(e),o=kC(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}C(!0);try{t.setFieldsValue({step_order:MC(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:kC(e.module),flow:kC(e.flow),step_order:Number(e.step_order),description:kC(e.description),keyword:AC(e.keyword),target:kC(e.target),value:kC(e.value),expected:kC(e.expected),tags:e.tags?kC(e.tags):EC.tags,active:Number(e.active)};T(!0);try{await km(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]:kC(n)})},V=e=>{t.setFieldsValue({module:kC(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:EC.tags,value:void 0,expected:void 0})},H=e=>{t.setFieldsValue({flow:kC(e),step_order:void 0})},U=e=>{let t=DC[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=kC((await n.validateFields()).name),r=await Dm({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:TC})}),(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)(wC,{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:EC,onFinish:z,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(NC,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,o.jsx)(wC,{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:CC,onChange:e=>t.setFieldsValue({keyword:AC(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:kC(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var{Text:FC}=i.Typography,IC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function LC(e=``){return String(e??``).trim()}function RC(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var zC=[{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`})}],BC={key:!1,value:!1,expected:!1};function VC(e,t){return t?e[t]??BC:BC}function HC(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function UC(){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)(CC),[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)(()=>VC(x,F),[x,F]),z=(0,r.useMemo)(()=>RC(p,`modulename`),[p]),B=(0,r.useMemo)(()=>RC(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 Om();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 Im({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 zm({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([Hm({product_parent_ID:e,module_parent_ID:t,submodule_parent_ID:r,actions:a,limit:1e3}),Gm({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 Hm({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 Wm(u);await G(f.name,e.module),v((await Hm({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:IC})}),(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)(FC,{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:LC(e.description),actions:LC(e.actions),key:LC(e.key),value:LC(e.value),expected:LC(e.expected),scenario:+!!e.scenario,active:+!!e.active};A(!0);try{if(d){await Km(u,{...t,step_order:Number(e.step_order)}),i.message.success(`Test case updated successfully.`),c(`/viewTestCase`);return}await Um(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}),HC(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}),HC(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)(FC,{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=VC(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}),HC(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)(Lu,{listName:`Added Steps`,loading:D,fields:zC,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:WC}=i.Typography,GC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function KC(){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([Im({project:e}),zm({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 Rm(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 Lm({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:GC})}),(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)(WC,{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)(Lu,{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)(WC,{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:qC}=i.Typography,JC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function YC(){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 zm({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 Vm(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 Bm({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:JC})}),(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)(qC,{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)(qC,{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)(Lu,{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)(qC,{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:XC}=i.Typography,ZC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function QC(){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 Hm({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 qm(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:ZC})}),(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)(XC,{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)(Lu,{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 $C=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function ew(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:$C}),(0,o.jsx)(Ba,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:tw}=i.Typography,nw=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],rw={tags:`regression`,active:1},iw={module:{dbName:`Modules`,formField:`module`,label:`Module`}},aw={key:!1,value:!1,expected:!1};function ow(e,t){return t?e[t]??aw:aw}function sw(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function cw(e=[]){return e.map(e=>({value:e,label:e}))}function lw(e=``){return String(e??``).trim()}function uw(e=[]){let t=new Map;return e.forEach(e=>{let n=lw(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function dw(e=[],t,n){let r=lw(t).toLowerCase(),i=lw(n).toLowerCase();return e.reduce((e,t)=>{let n=lw(t?.module).toLowerCase(),a=lw(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 fw({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)(tw,{strong:!0,className:`v1-section-label`,children:t})]})}function pw(){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)(CC),[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=iw[S.typeKey],M=(0,r.useMemo)(()=>cw(c),[c]),N=i.Form.useWatch(`module`,t),P=i.Form.useWatch(`flow`,t),F=i.Form.useWatch(`keyword`,t),I=!!lw(N),L=!!lw(P),R=!I,z=!I||!L,B=(0,r.useMemo)(()=>ow(g,F),[g,F]),V=(e,t=[])=>{e===`module`&&l(t)},H=async()=>{y(!0);try{l((await Em(iw.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 Om();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=lw(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await Pm({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(uw(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=lw(e),o=lw(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}D(!0);try{t.setFieldsValue({step_order:dw(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:lw(e.module),flow:lw(e.flow),step_order:Number(e.step_order),description:lw(e.description),keyword:lw(e.keyword),target:lw(e.target),value:lw(e.value),expected:lw(e.expected),tags:e.tags?lw(e.tags):rw.tags,active:Number(e.active)};k(!0);try{await Nm(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]:lw(n)})},K=e=>{t.setFieldsValue({module:lw(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:rw.tags,value:void 0,expected:void 0}),sw(t,[`keyword`,`target`,`value`,`expected`])},ne=e=>{t.setFieldsValue({flow:lw(e),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),sw(t,[`keyword`,`target`,`value`,`expected`])},q=e=>{let n=ow(g,e);t.setFieldsValue({keyword:lw(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}),sw(t,[`target`,`value`,`expected`])},J=e=>{let t=iw[e];C({open:!0,typeKey:e}),n.setFieldsValue({name:``,type:t.label})},Y=()=>{C(e=>({...e,open:!1})),n.resetFields()},re=async()=>{try{let e=lw((await n.validateFields()).name),r=await Dm({name:e,type:j.dbName});V(S.typeKey,r?.items??[]),t.setFieldsValue({[j.formField]:e}),i.message.success(`${j.label} added successfully.`),Y()}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:nw})}),(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)(tw,{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:rw,onFinish:ee,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(fw,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,o.jsx)(tw,{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:()=>J(`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:q})})}),(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:Y,onOk:()=>{T(!0),re()},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:lw(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var mw=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function hw(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:mw}),(0,o.jsx)(Ba,{moduleName:`lms-flows`,rowKey:`id`})]})}var gw=e=>e?.data??e;function _w(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 vw(e){return e?Array.isArray(e.data)?e.data.map(_w):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(_w):Array.isArray(e)?e.map(_w):[]:[]}async function yw(e=1,n=10){let r=await t.i(t.v,`/workflow/list/all?page=${e}&limit=${n}`),i=gw(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 bw(e=100){let t=await yw(1,e),n=[...t.items],r=t.total,i=2;for(;n.length<r;){let t=await yw(i,e);if(!t.items.length)break;n.push(...t.items),i+=1}return{items:n,total:Math.max(r,n.length)}}async function xw(e,n){let r=gw(await t.i(t.v,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function Sw(e,n){if(!e||!n)return null;try{let r=gw(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 Cw=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function ww(e=Cw){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 Tw(e,t=Cw){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 Ew=ww();function Dw(e){return typeof e==`function`?e:typeof e==`string`?ww([e]):Array.isArray(e)?ww(e):Ew}function Ow(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:t.id??e.id??n}}function kw(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var Aw=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function jw(e){let t=e?.data??e,n={};for(let r of Aw){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var Mw=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function Nw(e,t,n){let r=(Array.isArray(n)?n:[n]).map(Mw).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(Mw(e?.value))||r.includes(Mw(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 Pw=(e,t)=>Sr(e,t).rows,Fw=(e,t)=>{let{rows:n,total:r}=Sr(e,t);return{rows:n,total:r}};function Iw({fetchPrimaryPage:e,extractPrimaryPage:t=Fw,fetchSecondaryByKeys:n,fetchPrimary:r,extractPrimaryRows:i=Pw,fetchSecondary:a,extractSecondaryRows:o=Pw,fetchSecondaryById:s,primaryKey:c,secondaryKey:l,mergeRow:u=Ow,secondaryFetchLimit:d=200,extraFields:f=[],extraFieldsAfter:p}){let m=Dw(c),h=typeof l==`function`?e=>{let t=l(e);return t?[String(t)]:[]}:e=>Tw(e,typeof l==`string`?[l]:Array.isArray(l)?l:Cw),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=jw(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return f.length&&(r.fields=Nw(r.fields??[],f,p)),kw(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 Lw(e,t,n={}){return Iw({fetchPrimary:()=>xw(e,t),extractPrimaryRows:vw,fetchSecondary:tn,fetchSecondaryById:Sw,secondaryFetchLimit:n.moduleFetchLimit??200})}function Rw(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 zw(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=Rw(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var Bw=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function Vw({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=Ow(n,r,i),o=Bw(a);return o!=null&&(console.log(`mergeJobWorkflowRow`,i,a?.[e],o),a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function Hw(e={}){let t=Vw(),n=Iw({primaryKey:`_id`,secondaryKey:`entityId`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:tn,fetchSecondaryByKeys:()=>bw(),extractSecondaryRows:e=>(e?.items??[]).map(zw),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 Uw(e,t=10,n=0,r={},i={}){return Sr(await Hw(i)(e,t,n,r),e)}async function Ww(e,t,n,r=10,i=0,a={}){return Sr(await Lw(e,t)(n,r,i,a),n)}var Gw=cS,Kw=Xm(aC),qw=Xm(sC),Jw=Xm(SC),Yw=Xm(PC),Xw=Xm(UC),Zw=Xm(KC),Qw=Xm(YC),$w=Xm(QC),eT=Xm(ew),tT=Xm(pw),nT=Xm(hw);exports.ADMIN_API_URL=t.h,exports.ADMIN_APP_ID=t.g,exports.APP_ID=t._,exports.AUTH_URL=t.v,exports.ActivityTab=bs,exports.AddBatchCandidatePopup=Gx,exports.AddFormV1=is,exports.AdminDashboard=cS,exports.AdminDashboardContent=uy,exports.AdminPage=Gw,exports.AppAlert=as,exports.AppButton=Yr,exports.AppShell=ym,exports.ApprovalActionBar=bf,exports.AssigneeAvatars=xs,exports.AuthGuard=_m,exports.BILLING_STATUS_FLOW=rd,exports.Breadcrumb=e.t,exports.BulkUploadPage=Jw,exports.CANDIDATES_URL=t.y,exports.CONTRACT_C2C=Rf,exports.CONTRACT_W2=Lf,exports.CalendarCard=D,exports.CoreThemeAdminApp=my,exports.CoreThemeAdminRoutes=py,exports.CustomPagination=xe,exports.DayLogModal=mf,exports.DescriptionBlock=Ps,exports.DetailHeaderCard=gl,exports.DetailViewPage=Cl,exports.DetailViewV1=xc,exports.DocumentViewer=e.Hn,exports.DynamicCards=bt,exports.DynamicPopup=Hb,exports.DynamicPopupRoute=Jx,exports.DynamicTabs=j,exports.EditFormV1=hu,exports.FINANCE_APPROVAL_CONFIG=Mf,exports.FINANCE_TYPE_CFO=Of,exports.FINANCE_TYPE_ONBOARDING_MANAGER=Df,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=Af,exports.FINANCE_TYPE_SUBMISSION_MANAGER=Ef,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=kf,exports.FileListCard=gp,exports.FinanceApprovalPanel=lp,exports.FinanceAvatar=Bd,exports.FinanceBadge=Wd,exports.FinanceDayCell=Sf,exports.FinanceDetailHeader=Xd,exports.FinanceDivider=Ad,exports.FinanceEmployeeCell=Vd,exports.FinanceEmptyState=Dd,exports.FinanceEquation=jd,exports.FinanceHistoryTimeline=Fd,exports.FinanceHoursGrid=Ed,exports.FinanceKpiRow=Td,exports.FinanceLine=kd,exports.FinanceListToolbar=Ld,exports.FinanceMarginBadge=Gd,exports.FinanceMoneyCell=Ud,exports.FinanceRecordsTable=Jd,exports.FinanceRowChevron=Kd,exports.FinanceSection=Od,exports.FinanceStatusPill=wd,exports.FinanceTextCell=Hd,exports.FinanceTimesheetAnalysis=wf,exports.FinanceWorkflowSteps=Md,exports.Header=Up,exports.HierarchyUserFilter=Tt,exports.JOBS_URL=t.b,exports.LegacyAdminPage=Kw,exports.ListView=Ba,exports.LmsHomePage=nT,exports.LmsTestForm=tT,exports.Login=bm,exports.MailPopup=Sy,exports.ManageModules=Zw,exports.ManageSubmodules=Qw,exports.ModuleRowActions=wu,exports.NotesPanel=yf,exports.PAYROLL_STATUS_FLOW=id,exports.POPUP_CONFIGS=Rx,exports.ParamCardView=ju,exports.ParamListView=Lu,exports.PreviewPopup=eb,exports.ProjectSelect=Ym,exports.ProofUploadPreview=vf,exports.QuickLogBar=_f,exports.QuickLogSelectionBar=hf,exports.RejectionReasonModal=gf,exports.SUBMISSIONS_URL=t.x,exports.Sidebar=pm,exports.StatusBadge=zu,exports.StatusBadgeTag=$d,exports.StickyNotesFullPage=qw,exports.StylishDynamicTabs=Vu,exports.TemplateEditor=Ku,exports.TestForm=Yw,exports.TestingHomePage=eT,exports.TimelineGroups=fs,exports.TimesheetDayCell=lf,exports.TipTapEditor=e.Un,exports.UserForm=sS,exports.VendorShareDrawer=Qx,exports.ViewSummaryWidget=Jr,exports.WizardPopup=ob,exports.ZinnextTableView=$w,exports.ZinnextTestForm=Xw,exports.applyIntegrationStatus=e.ct,exports.approveSubmission=ae,exports.buildCsv=vd,exports.buildDailyRows=fd,exports.buildDayGradient=sf,exports.buildRateHistoryEntries=tp,exports.buildWeeklyRollup=hd,exports.clearSelectedProject=t.n,exports.colors=e.Kn,exports.computeFinance=$f,exports.computeMarginBand=gd,exports.configureCoreTheme=t.S,exports.createAllWorkflowsListFetcher=Hw,exports.createWorkflowStageListFetcher=Lw,exports.deleteIntegrationConfig=e.yt,exports.deriveDayStats=dd,exports.downloadCsv=Sd,exports.findEmployerRow=qf,exports.flattenGroups=Kf,exports.formatFinanceMoney=np,exports.formatHours=Yu,exports.formatMoney=Ju,exports.formatRate=Xu,exports.getActivity=e.tt,exports.getAllWorkflowsModuleList=Uw,exports.getApprovalDate=ed,exports.getBgcIntegrationConfig=e.It,exports.getBgcIntegrationSummary=e.Lt,exports.getBillingActionStates=ad,exports.getCurrentRoleName=t.o,exports.getFieldLabel=bd,exports.getFinanceApprovalConfig=Pf,exports.getFormGroupsRaw=mp,exports.getIntegrationConfig=e.Ut,exports.getIntegrationConfigs=e.Wt,exports.getIntegrationSummary=e.Gt,exports.getModuleConfig=be,exports.getModuleDataDetail=e.rt,exports.getPayrollActionStates=od,exports.getSelectedProject=t.s,exports.getStoredToken=t.c,exports.getStoredUser=t.l,exports.getUserRoles=t.u,exports.getVMSApprove=oe,exports.getValueStyle=xd,exports.getWorkflowStageModuleList=Ww,exports.getWorkflowSteps=sd,exports.humanizeEvent=$u,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return io}}),exports.indexFieldConfig=yd,exports.initialsOf=Zu,exports.isTester=t.d,exports.logout=t.p,exports.marginIncludesReferral=If,exports.matchLocationTax=Qf,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return El}}),exports.normalizeContract=Yf,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Ss}}),exports.rejectSubmission=se,exports.resolveActivityMeta=_s,exports.resolveAndCompute=ep,exports.resolveFinanceInputs=Zf,exports.resolveMergeKey=Ew,exports.resolveRejectionReason=Ff,exports.resolveSubmissionFinance=hp,exports.saveBgcIntegrationConfig=e.fn,exports.saveIntegrationConfig=e.hn,exports.setSelectedProject=t.m,exports.stageCountKey=Rw,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return xm}}),exports.testIntegrationConnection=e.xn,exports.useDropdownFields=vn,exports.useDropdownValues=Xr,exports.useEditForm=_p,exports.useFieldConfig=yn,exports.useFilterFields=bn,exports.useMenuPermission=En,exports.useModuleActions=_u,exports.useRecordRefresh=bl,exports.withAdminAppId=t.C,exports.withAppId=t.w,exports.withAuthGuard=Xm;
|
|
9
|
+
`))}function Fy(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:Ay(n),value:r}}function Iy(e){let t=e.toLowerCase().replace(/[\s:.\-–—]+$/,``).trim();return Ey.has(t)?Dy.test(t)?`education`:Oy.test(t)?`keySkills`:`overview`:null}function Ly(e){let t=[],n={overview:[],keySkills:[],education:[]},r=`overview`;return e.forEach(e=>{let i=Iy(e);if(i){r=i;return}if(r===`overview`){let n=Fy(e);if(n){t.push(n);return}}n[r].push(e)}),{meta:t,overview:jy(n.overview),keySkills:jy(n.keySkills),education:jy(n.education)}}function Ry(e){let t=[...Ty].sort((e,t)=>t.length-e.length),n=RegExp(`\\b(${t.map(ky).join(`|`)})\\b\\s*:?`,`gi`),r=[...e.matchAll(n)];if(!r.length)return{meta:[],overview:jy(Py(e)),keySkills:[],education:[]};let i={overview:[],keySkills:[],education:[]},a=e.slice(0,r[0].index).trim();return a&&i.overview.push(...Py(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=Py(e.slice(o,s).trim());c.length&&i[Dy.test(a)?`education`:Oy.test(a)?`keySkills`:`overview`].push(...c)}),{meta:[],overview:jy(i.overview),keySkills:jy(i.keySkills),education:jy(i.education)}}function zy(e){let t=My(e);if(!t)return{meta:[],overview:[],keySkills:[],education:[]};let n=Ny(t);return n.length>=4?Ly(n):Ry(t)}function By({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 Vy({raw:e=``,meta:t=[]}){let[n,i]=(0,r.useState)(!1),a=(0,r.useMemo)(()=>zy(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)(Cy,{type:`secondary`,children:`No description available.`});let l=n?c:c.slice(0,wy),u=c.length-wy;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)(By,{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:Hy}=i.Typography;function Uy(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function Wy(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 Gy(e){return e?e.email??e.emailId??e.emailAddress??``:``}function Ky(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function qy(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 Jy=[`jobDescription`,`description`,`rawDescription`,`jobDescriptionText`];function Yy(e){return String(e??``).toLowerCase()===`job`}function Xy(e){let t=Jy.includes(e.field),n=/description/i.test(e.label??``);return t||n}function Zy({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 Qy({record:e}){let t=Wy(e),n=Gy(e),r=Ky(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:Uy(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 $y({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=Yy(t)&&Xy(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:qy(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)(Vy,{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:qy(n)})]},e.field??e.label)})}):null}function eb(){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.In({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)(Hy,{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)($y,{fields:e.fields,moduleName:n}):(0,o.jsx)(Hy,{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)(Zy,{steps:C,current:g,onStepClick:_})}),(0,o.jsxs)(`div`,{className:`wizard-body`,children:[c&&(0,o.jsx)(Qy,{record:c}),E()]})]})}var{Text:tb}=i.Typography,{TextArea:nb}=i.Input,rb=[{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 ib(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)(nb,{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 ab({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)(tb,{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)(tb,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,o.jsx)(`div`,{className:`wizard-review-empty`,children:(0,o.jsx)(tb,{type:`secondary`,children:`No data entered yet.`})})}function ob(){let[e]=i.Form.useForm(),t=(0,s.useNavigate)(),{title:n=`Wizard`,moduleName:a=``,steps:c=rb,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:ib(e)})},e.name))})},e.key)),f.isReview&&(0,o.jsx)(ab,{steps:c,form:e})]})})]})}function sb({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 cb({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.Wn,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:t}),n&&(0,o.jsx)(e.Wn,{variant:`body`,className:`dynamic-popup__description`,children:n}),r&&i>0&&(0,o.jsxs)(e.Wn,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,o.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),s&&(0,o.jsx)(e.Wn,{variant:`body`,children:s}),c&&(0,o.jsx)(e.Wn,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:c})]})}function lb({footerNote:t}){return t?(0,o.jsx)(e.Wn,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:t}):null}var{TextArea:ub}=i.Input,db=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],fb=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function pb(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 mb({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 hb({field:e,value:t,onChange:n}){return(0,o.jsx)(ub,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function gb({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{value:n,onChange:r,options:pb(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function _b({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{mode:`multiple`,value:n,onChange:r,options:pb(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function vb({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:pb(t),placeholder:e.placeholder,onSearch:n,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function yb({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 bb({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:db,onChange:e=>a({currency:e}),style:{width:80}}),(0,o.jsx)(i.Select,{value:n,options:fb,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 xb({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 Sb({field:e,checked:t,onChange:n}){return(0,o.jsx)(i.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function Cb({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 wb({options:e,value:t,onChange:n}){return(0,o.jsx)(i.Radio.Group,{value:t,onChange:n,options:e})}var Tb={input:mb,text:mb,textarea:hb,select:gb,"multi-select":_b,"search-select":vb,"mention-textarea":yb,"candidate-rate":bb,"priority-checkbox":Sb,"date-picker":xb,number:Cb,radio:wb};function Eb(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}function Db(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function Ob(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 kb(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 Ab(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:Ob(kb(e))}:e,o=(i?Db(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]??``),c=e?.disabled===!0||e?.disable===!0,l=String(e?.optionNote??``).trim(),u={label:l?`${String(o)} — ${l}`:String(o),value:String(s),_raw:e};return c&&(u.disabled=!0),l&&(u.title=l),u}function jb(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>Ab(t,e))}function Mb(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var Nb=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function Pb({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.Wn,{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:Fb(n).map(t=>Ib(t,t=>{let n=a[t.name]??jb(t,s),r=p(t),c=m(t),l=h[t.name]??[],u=Eb(t.type),d=Tb[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()}}),Nb.has(t.type)&&f.push(e.U({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 Fb(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 Ib(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 Lb({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 Rb=500,zb=3;function Bb({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<zb){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=>Ab(e,r))}))}).catch(e=>{a.signal.aborted||console.error(`[DynamicPopup] Search failed for field "${r.name}":`,e)})},Rb)}}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 Vb({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(()=>{i.message.success(t.successMessage||`Deleted successfully`),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 Hb({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)(()=>Mb(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}=Lb({open:e,config:t,api:l,fields:x,popupContext:g,formValues:d}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=Bb({api:l,open:e,popupContext:g,setDynamicOptions:w});function k(e){typeof a==`function`&&a(e)}let{handleOk:A,confirming:j,deleteError:M,resetSubmitState:N}=Vb({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)(sb,{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)(sb,{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)(cb,{note:H,description:t.description,showSelectedCount:t.showSelectedCount,count:F,itemLabel:L,bodyText:V,deleteError:M}),(0,o.jsx)(lb,{footerNote:t.footerNote}),(0,o.jsx)(Pb,{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 Ub={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:[]},Wb={deleteItems:async(e,t)=>{await I(t.moduleName,e)}},Gb={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`}]},Kb=`Already submitted`;function qb(e){return String(e?.applicantId??e?._id??e?.id??``)}function Jb(e,t){return{...e,label:`${e.label} — ${Kb}`,disabled:!0,title:`${Kb}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``}}var Yb={searchOptions:async(e,t,n)=>{if(e.searchFetchKey===`quickSubmitJobList`){let e=n.selectedRecords?.[0]??{},r=e.id??e._id??n.selectedIds?.[0],i,a=!0;try{i=await le({searchQuery:t,candidateId:r})}catch{a=!1;let e=await fn({searchQuery:t,candidateId:r});i=Array.isArray(e?.data)?e.data:[]}let o=i.map(e=>({label:[e.jobReferenceId??e.clientJobReferenceId,e.jobTitle].filter(Boolean).join(` - `)||String(e._id??``),value:e._id??``,_raw:e}));if(a)return o.map(e=>{if(e._raw?.alreadySubmitted)return Jb(e,e._raw?.submissionId||``);if(e._raw?.disable){let t=String(e._raw?.message??``).trim();return{...e,disabled:!0,label:t?`${e.label} — ${t}`:e.label,title:t}}return e});let s=await de({applicantId:r,jobIds:o.map(e=>e.value)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e.value));return t?Jb(e,t.submissionId):e})}if(e.searchFetchKey===`quickSubmitCandidates`){let e=n.selectedRecords?.[0]??{},r=n.jobId??e.jobId??e.id??e._id??n.selectedIds?.[0],i,a=new Map;try{i=await ue({search:t,jobId:r})}catch{let e=await Va({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await de({jobId:r,applicantIds:i.map(qb)}).catch(()=>new Map)}return i.map(e=>{let t=a.get(qb(e));if(!t&&!e?.isFromSubmission&&!e?.alreadySubmitted)return e;let n=t?.submissionId||e?.submissionId||``;return{...e,disabled:!0,optionNote:Kb,alreadySubmitted:!0,existingSubmissionId:n}})}return[]},submit:async(e,t,n)=>{let{navigate:r,selectedRecords:i=[],selectedIds:a=[],moduleName:o}=t,s=i[0]??{},c,l;t.jobId?(c=t.jobId,l=s.id??s._id??a[0]??``):o===`candidate`?(c=e.jobId??``,l=s.id??s._id??a[0]??``):(c=s.jobId??s.id??s._id??a[0]??``,l=e.candidate??``);let u=n?.dynamicOptions?.candidate?.find(e=>qb(e?._raw)===String(l)),d=n?.dynamicOptions?.jobId?.find(e=>String(e?.value)===String(c)),f=u?._raw?.alreadySubmitted||u?._raw?.isFromSubmission||d?.alreadySubmitted||d?._raw?.alreadySubmitted;if(!c||!l)throw Error(`Select both a job and a candidate to quick submit.`);let p=f,m=t.submissionId||u?._raw?.existingSubmissionId||u?._raw?.submissionId||d?.existingSubmissionId||s.submissionId||``;try{let e=await ce({jobId:c,applicantId:l});p||=!!e?.exists,m=e?.submissionId||m}catch(e){throw Error(`Could not verify existing submissions (${e?.message??`request failed`}). Please try again.`,{cause:e})}if(p)throw Error(`This candidate is already submitted for this job${m?` (submission ${m})`:``}.`);let h=new URLSearchParams;return l&&h.set(`candidateId`,l),h.set(`isFromSubmission`,`false`),r(`/submission-create/${c}?${h.toString()}`),{navigated:!0}}},Xb={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`}]},Zb=e=>e?.data??e;async function Qb({relatedId:e,notes:n,title:r,notesFor:i}){return Zb(await qt(t.v,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var $b={getMentionOptions:async(e,t)=>R(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 Qb({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},ex={name:`jobId`,label:`Job Title / ID`,type:`search-select`,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle}`},tx={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},nx={title:`Tag to Job`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[tx]:[ex,tx]},rx=e=>e?.data??e;function ix(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 ax(e){return e?Array.isArray(e.data)?e.data.map(ix):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(ix):Array.isArray(e)?e.map(ix):[]:[]}async function ox(e=1,n=10){let r=await t.i(t.v,`/workflow/list/all?page=${e}&limit=${n}`),i=rx(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 sx(e=100){let t=await ox(1,e),n=[...t.items],r=t.total,i=2;for(;n.length<r;){let t=await ox(i,e);if(!t.items.length)break;n.push(...t.items),i+=1}return{items:n,total:Math.max(r,n.length)}}async function cx(e,n){let r=rx(await t.i(t.v,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function lx(e,n){if(!e||!n)return null;try{let r=rx(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}}async function ux(e){return rx(await t.i(t.b,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var dx={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`};function fx(e,...t){for(let n of t){let t=String(n).split(`.`).reduce((e,t)=>e?.[t],e);if(t!=null&&t!==``)return t}}function px(e){let t=String(e??``).trim();return t?dx[t.toLowerCase()]??t:``}function mx(e,t){let n=fx(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t;if(!n)return null;let r=(fx(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[fx(e,`firstName`,`first_name`),fx(e,`lastName`,`last_name`)].filter(Boolean).join(` `))||void 0,i={candidateId:String(n),candidateName:r,phone:fx(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:fx(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:fx(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:fx(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:fx(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:fx(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:fx(e,`screeningScore`,`screening.score`,`score`),assignedDate:fx(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var hx={searchOptions:async(e,t)=>e.searchFetchKey===`tagToJobJobList`?L(t):[],submit:async(e,t)=>{let n=e.jobId??t.jobId,r=px(e.hiringStage??t.hiringStage),i=Array.isArray(t.selectedIds)?t.selectedIds:[],a=Array.isArray(t.selectedRecords)?t.selectedRecords:[],o=Math.max(i.length,a.length,1);for(let e=0;e<o;e+=1){let t=i[e]?String(i[e]):``,o=mx(a[e]??{},t);await ux({jobId:n,module:`jobs`,currentStage:r,...o?{candidateDetails:o}:{}})}await H({jobId:n,candidateIds:t.selectedIds,hiringStage:r})}},gx={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`}]}]},_x={submit:async(e,t)=>{await F(t.moduleName,t.selectedIds,e.status)}},vx={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:[]},yx={onOk:async e=>{await fe({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},bx={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`}]},xx={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?U():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await W({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},Sx=[{title:`Name`,key:`name`,render:(e,t)=>`${t.first_name??``} ${t.last_name??``}`.trim()||t.user_name||t.name||`-`},{title:`Role`,dataIndex:`role_name`,key:`role`,render:e=>e||`-`},{title:`Reporting`,dataIndex:`reporting_name`,key:`reporting`,render:e=>e||`-`}];function Cx({selectedIds:e,onClose:t}){let n=e?.[0],[s,c]=(0,r.useState)(!0),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)({assignedUsers:[],totalSubmissions:0,message:``});return(0,r.useEffect)(()=>{let e=!1;return c(!0),ee(n).then(t=>{e||f(t)}).catch(t=>{e||(i.message.error(t?.message??`Failed to load self-assign details`),f({assignedUsers:[],totalSubmissions:0,message:``}))}).finally(()=>{e||c(!1)}),()=>{e=!0}},[n]),s?(0,o.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,o.jsx)(i.Spin,{size:`large`})}):(0,o.jsxs)(`div`,{className:`self-assign-popup-body`,children:[Number(d.totalSubmissions)>0&&(d.assignedUsers?.length??0)>0?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{style:{fontWeight:700,marginBottom:8},children:`Team Members Allocated`}),(0,o.jsx)(i.Table,{columns:Sx,dataSource:d.assignedUsers,pagination:!1,rowKey:e=>e.user_id??`${e.first_name}-${e.last_name}`,size:`small`,className:`mb-3 no-header-bg`,scroll:{y:200}}),(0,o.jsxs)(`div`,{className:`warning-card`,style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,o.jsx)(a.ExclamationCircleFilled,{style:{color:`#faad14`,fontSize:18}}),(0,o.jsx)(`div`,{style:{fontSize:13},children:`These users are already assigned to this job. Do you still want to assign yourself as well?`})]})]}):(0,o.jsx)(`div`,{style:{padding:`8px 0`},children:d.message||`Are you sure you want to assign this job?`}),(0,o.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:12,marginTop:24},children:[(0,o.jsx)(i.Button,{size:`small`,onClick:()=>t?.(),disabled:l,children:`No`}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,onClick:async()=>{u(!0);try{await G({jobIds:[n]}),i.message.success(`Job assigned successfully`),t?.({success:!0})}catch(e){i.message.error(e?.message??`Failed to assign job`)}finally{u(!1)}},loading:l,children:`Yes`})]})]})}Cx.propTypes={selectedIds:l.default.array,onClose:l.default.func};var wx={title:`Self Assign`,width:480,className:`self-assign-modal`,component:Cx},Tx={submit:async()=>{}},Ex={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`}]},Dx={getOptions:async e=>e.fetchOptionsKey===`assignToUsers`?K():[],loadExtraData:async e=>ne(e.selectedIds[0]),submit:async(e,t,{removedIds:n,extraData:r})=>{await re({jobIds:t.selectedIds,userId:e.assignToUserId,rate:e.candidateRate,priority:e.priority,removedIds:n,existingRecruiters:r?.recruitersData})}},Ox={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`}]},kx={getMentionOptions:async(e,t)=>R(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await B(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await z({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},Ax={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`}]},jx={submit:async(e,t)=>{await ie({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function Mx(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var Nx={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function Px(e,t,n){let r=Mx(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function Fx(e){let t=e.selectedRecords?.[0]??{},n=Px(t,`candidateRate`,`candidateAcceptedRate`)??Px(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=Px(t,`candidateRate`,`candidateAcceptedCurrency`)??Px(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:Px(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??Px(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??Nx[String(r??``).toUpperCase()]??(r||`$`),unit:Px(t,`candidateRate`,`candidateAcceptedPayUnit`)??Px(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var Ix={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=Fx(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=Fx(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`}]}]},Lx={submit:async(e,t)=>{let n=t.selectedIds[0];if(await ae(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await oe(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 Rx(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 zx({selectedIds:e,selectedRecords:t,onClose:n}){let a=t?.[0]??{},s=e?.[0]??Gf(a),[c,l]=(0,r.useState)(null),[u,d]=(0,r.useState)(!0);(0,r.useEffect)(()=>{let e=!1;return d(!0),hp(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 ae(s,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currency,candidateProposedRateUnit:`hr`,submitVia:`Mail`}),i.message.success(`Submission approved`),n?.({success:!0})},submissionReject:async({reason:e})=>{await se({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)(lp,{type:Ef,record:c.record,lookups:c.lookups,identity:Rx(a,c.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:f,onClose:()=>n?.(),variant:`popup`})}zx.propTypes={selectedIds:l.default.array,selectedRecords:l.default.array,onClose:l.default.func};var Bx={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:zx},Vx={submit:async()=>{}};function Hx(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 Ux(e){let t=Array.isArray(e)?e:[];for(let e=t.length-1;e>=0;--e)if(String(t[e]?.activityType??``).trim().toLowerCase()===`cfo rejected`)return t[e];return null}function Wx({selectedIds:t,selectedRecords:n,onClose:a}){let s=n?.[0]??{},c=t?.[0]??Gf(s),[l,u]=(0,r.useState)(null),[d,f]=(0,r.useState)(!0);(0,r.useEffect)(()=>{let t=!1;return f(!0),Promise.all([hp(c,s),e.tt(`submission`,c).catch(()=>[])]).then(([e,n])=>{if(t)return;let r=Ux(n);u({...e,record:{...e.record,submission:{...e.record.submission,cfoRejectionReason:r?.activityComments??``,cfoRejectedAt:r?.activityTime??null}}})}).catch(e=>{t||(i.message.error(e?.message??`Unable to load finance details`),u({record:{submission:s},lookups:{},display:{}}))}).finally(()=>{t||f(!1)}),()=>{t=!0}},[c]);let p=(0,r.useMemo)(()=>({submissionApprove:async({computed:e})=>{await ae(c,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currency,candidateProposedRateUnit:`hr`,submitVia:`Mail`}),i.message.success(`Submission re-approved`),a?.({success:!0})},submissionReject:async({reason:e})=>{await se({submissionId:c,rejectReasonId:2,rejectReason:`Rate not approved`,rejectReasonComments:e}),i.message.success(`Submission rejected`),a?.({success:!0})}}),[c,a]);return d||!l?(0,o.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,o.jsx)(i.Spin,{size:`large`})}):(0,o.jsx)(lp,{type:kf,record:l.record,lookups:l.lookups,identity:Hx(s,l.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:p,onClose:()=>a?.(),variant:`popup`})}Wx.propTypes={selectedIds:l.default.array,selectedRecords:l.default.array,onClose:l.default.func};var Gx={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:Wx},Kx={submit:async()=>{}},qx=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],Jx={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:qx.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},Yx={submit:async(e,t)=>{let n=qx.find(t=>String(t.id)===String(e.rejectReason));await se({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},Xx={delete:Ub,"quick-submit":Gb,"add-notes":Xb,"tag-to-job":nx,"change-status":gx,"remove-from-shortlist":vx,"add-to-groups":bx,"self-assign":wx,"others-assign":Ex,"sticky-notes":Ox,"move-to-onboarding":Ax,"approve-rate":Ix,"manager-approve":Bx,"manager-reapprove":Gx,reject:Jx},Zx={delete:Wb,"quick-submit":Yb,"add-notes":$b,"tag-to-job":hx,"change-status":_x,"remove-from-shortlist":yx,"add-to-groups":xx,"self-assign":Tx,"others-assign":Dx,"sticky-notes":kx,"move-to-onboarding":jx,"approve-rate":Lx,"manager-approve":Vx,"manager-reapprove":Kx,reject:Yx};function Qx(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function $x(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 eS(e){let t=$x(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[$x(e,`firstName`,`first_name`),$x(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function tS(e){return String($x(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function nS(e){return String($x(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function rS({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.Rn(`onboarding`,200,0).then(e=>{t||l(Qx(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=>[eS(t),$x(t,`email`,`candidateEmail`,`candidate_email`),$x(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(nS(e)));if(n.length){_(!0),y(``);try{let{userId:r}=t.a();await Promise.all(n.map(t=>e.mt(`batchCandidates`,{schemaVersion:1,batchId:b,candidateId:tS(t),workforceEngagementId:nS(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=>nS(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>eS(t)},{title:`Email`,key:`email`,render:(e,t)=>$x(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>$x(t,`status`,`onboardingStatus`,`onboarding_status`)||`—`}],dataSource:x,loading:m,size:`small`,pagination:{pageSize:10,showSizeChanger:!1},rowSelection:{selectedRowKeys:u,onChange:d,getCheckboxProps:e=>({disabled:!tS(e)||!nS(e)})},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var iS={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function aS(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:iS[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 oS({apiMap:n={},extraConfigs:i={}}){let a=(0,r.useMemo)(()=>({...Zx,...n}),[n]),c=(0,r.useMemo)(()=>({...Xx,...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.zt(d.moduleName,`popup`,l).then(e=>{t||p({key:n,config:aS(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]),_=e=>{let t=d.background;if(e?.success&&t?.pathname){u(`${t.pathname}${t.search??``}`,{replace:!0,state:{...t.state??{},refreshTimestamp:Date.now()}});return}u(-1)};return l===`add-batch-candidate`?(0,o.jsx)(rS,{open:!0,context:h,onClose:_}):(0,o.jsx)(Hb,{open:!0,config:m,context:h,onClose:_,api:{...a[l]??{},...g}})}var sS={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`}]},cS={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>zt({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>Bt(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>Vt({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},lS=sS.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function uS(){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)(sS.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)(sS.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 cS.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&&cS.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([...hy(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function V(e){let t=new Set(z);g({...e,bcc:hy(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let H=(hy(B.to).length||hy(B.bcc).length)&&gy(B.to)&&gy(B.cc)&&gy(B.bcc)&&B.subject.trim(),U=e=>e===`myVendor`?T:D;function W(){e(-1)}function G(){H&&cS.submit({jobId:m,toMail:hy(B.to),ccMail:hy(B.cc),bccMail:hy(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:sS.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:lS,dataSource:ee,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>sS.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,o.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,o.jsx)(xe,{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)(xy,{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,` / `,sS.maxVendorSelect,` Vendors selected`]}):null})})]})})}var dS={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].*$/},fS={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},pS={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 ${fS.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.`},mS={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},hS={REMARKS_MIN:10,REMARKS_MAX:250},gS={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)}`}},_S={required:(e=`Field`)=>({required:!0,message:pS.REQUIRED(e)}),email:()=>({pattern:dS.EMAIL,message:pS.INVALID_EMAIL}),phone:()=>({pattern:dS.PHONE,message:pS.INVALID_PHONE}),password:()=>({pattern:dS.PASSWORD,message:pS.INVALID_PASSWORD}),alphabets:()=>({pattern:dS.ALPHABETS,message:pS.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:dS.ALPHANUMERIC,message:pS.INVALID_ALPHANUMERIC}),number:()=>({pattern:dS.NUMBER,message:pS.INVALID_NUMBER}),url:()=>({pattern:dS.URL,message:pS.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:dS.CANDIDATE_ID,message:pS.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:dS.REMARKS,message:pS.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${hS.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${hS.REMARKS_MAX} characters.`}),designation:()=>({pattern:dS.DESIGNATION,message:pS.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!dS.DOB.test(n))return Promise.reject(Error(pS.INVALID_DOB));let r=(0,c.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(pS.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:dS.LINKEDIN,message:pS.INVALID_LINKEDIN}),companyName:()=>({pattern:dS.COMPANY_NAME,message:pS.INVALID_COMPANY_NAME}),firstName:()=>({pattern:dS.FIRST_NAME,message:pS.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${mS.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${mS.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:mS.FIRST_NAME_MIN,message:pS.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:mS.FIRST_NAME_MAX,message:pS.FIRST_NAME_MAX}),remarksMinLength:()=>({min:hS.REMARKS_MIN,message:pS.REMARKS_MIN}),remarksMaxLength:()=>({max:hS.REMARKS_MAX,message:pS.REMARKS_MAX}),fullName:()=>({pattern:dS.FULL_NAME,message:pS.INVALID_FULL_NAME}),noSpaces:()=>({pattern:dS.NO_SPACES,message:pS.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:dS.STARTS_WITH_CAPITAL,message:pS.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<=fS.MAX_FILE_SIZE))return i.message.error(pS.INVALID_FILE_SIZE),Promise.reject(Error(pS.INVALID_FILE_SIZE));if(!fS.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(pS.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>fS.SINGLE_FILE_COUNT)return Promise.reject(Error(pS.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<fS.MAX_FILE_SIZE?fS.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(pS.INVALID_FILE_TYPE)):Promise.reject(Error(pS.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>fS.MULTI_FILE_COUNT)return Promise.reject(Error(pS.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<fS.MAX_FILE_SIZE))return Promise.reject(Error(pS.INVALID_FILE_SIZE));if(!fS.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(pS.INVALID_FILE_TYPE))}return Promise.resolve()}})},vS={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)},yS=()=>{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:[_S.required(`Email`),_S.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:[_S.required(`Phone Number`),_S.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:gS.phoneFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Password`,name:`password`,rules:[_S.required(`Password`),_S.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:[_S.required(`Full Name`),_S.alphabets(),_S.firstNameMinLength(),_S.firstNameMaxLength()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({fullName:gS.firstNameFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Username`,name:`username`,rules:[_S.required(`Username`),_S.alphanumeric()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({username:gS.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Website URL`,name:`website`,rules:[_S.required(`Website URL`),_S.url()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({website:gS.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:[_S.required(`MSP Req ID`),_S.candidateId(`MSP Req ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({mspreqID:gS.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[_S.required(`Candidate ID`),_S.candidateId(`Candidate ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({candidateId:gS.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:24,children:(0,o.jsx)(i.Form.Item,{label:`Remarks`,name:`remarks`,rules:[_S.required(`Remarks`),_S.remarks(),_S.remarksMinLength(),_S.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:[_S.required(`Designation`),_S.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:[_S.dob()],children:(0,o.jsx)(i.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:gS.dobFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Company Name`,name:`companyName`,rules:[_S.required(`Company Name`),_S.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:vS.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:[_S.multiFileUpload()],children:(0,o.jsx)(i.Upload,{multiple:!0,beforeUpload:vS.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:[_S.fileUpload()],children:(0,o.jsx)(i.Upload,{beforeUpload:vS.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 bS(e){return(0,o.jsx)(ym,{children:(0,o.jsx)(uy,{...e})})}var{Text:xS}=i.Typography,SS=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],CS={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 wS({stats:e=SS}){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:[CS[e.icon]??CS.fileText,(0,o.jsx)(xS,{children:e.label})]}),(0,o.jsx)(i.Statistic,{value:e.value})]})},e.label))})})}var{Text:TS}=i.Typography;function ES(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 DS(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:ES(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function OS(){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.Mt({offset:t,limit:r,searchQuery:a??``}),o=(i.users??[]).map(DS);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)(Lu,{listName:`Users`,dataSource:t,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,o.jsxs)(`div`,{children:[(0,o.jsx)(TS,{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:kS}=i.Typography,AS=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],jS=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function MS({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 NS({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.sn(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.Mn(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:AS.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)(MS,{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 `,AS.find(e=>e.key===f)?.label]})})]})}function PS(){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.jt();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.jn(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)(Lu,{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:jS.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)(NS,{team:t,configType:d},`${t?.teamId}-${d}`)]})]})}var FS=[`view`,`add`,`edit`,`delete`],IS={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 LS(e){return IS[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function RS(e){let t=FS.filter(t=>e.includes(t)),n=e.filter(e=>!FS.includes(e)).sort();return[...t,...n]}function zS(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),RS([...t])}function BS(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{Oh(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function VS({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 HS({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 US({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:s,onActionLabelSave:c}){let l=t?.permissions??{},u=n.filter(t=>Oh(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)(VS,{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)(HS,{entry:l[t],label:a[t]??LS(t),onToggle:()=>r(e,t),onLabelSave:e=>c(t,e)},t))})]})}function WS({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.rn(t);(0,r.useEffect)(()=>{b&&(h(!0),y(!1),e.an(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.kn(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)(()=>zS(f),[f]),{enabled:T,total:E}=(0,r.useMemo)(()=>BS(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)(US,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:n[e]??e,actionLabels:s,onModuleLabelSave:c,onActionLabelSave:l},e))})]})}var{Text:GS}=i.Typography,KS=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function qS(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function JS(e){return String(e||``).trim().toLowerCase()}function YS(e){return e?.key||e?.collectionName||e?.value||``}function XS(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=YS(e);if(!t)return;let o=JS(e.key||t),s=JS(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||qS(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=JS(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:qS(t),value:t,disabled:!1}))}),n}function ZS(){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.At();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.Ht(),e.Pt()]),r=XS(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.bn(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)(GS,{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)(Lu,{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:KS.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)(WS,{role:t},t?.roleId):(0,o.jsx)(Wh,{role:t,configType:l},`${t?.roleId}-${l}`))]})]})}var QS=`perm-module-labels`,$S=`perm-action-labels`;function eC(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function tC(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function nC({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 rC({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.Yt())}catch{i.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await e.Jt())}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.ft({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.Tn(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.xt(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.dt({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.wn(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.bt(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)(nC,{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)(nC,{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 iC(){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)(()=>eC(QS)),[_,v]=(0,r.useState)(()=>eC($S)),y=(0,r.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return tC(QS,r),r})},[]),b=(0,r.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return tC($S,r),r})},[]);function x(){g({}),v({}),tC(QS,{}),tC($S,{}),i.message.success(`Labels reset to defaults`)}let S=(0,r.useCallback)(async()=>{c(!0);try{let{roles:t}=await e.At();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)(WS,{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)(rC,{open:p,onClose:()=>m(!1)})]})}var{Title:aC,Text:oC}=i.Typography,sC=[{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 cC({items:e=sC}){return(0,o.jsx)(i.Card,{className:`onboarding-card`,title:(0,o.jsx)(aC,{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)(oC,{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)(oC,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:lC,Title:uC}=i.Typography,dC=[{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`},{id:`bgc-integration`,label:`Integrations`,icon:(0,o.jsx)(a.SafetyOutlined,{}),heading:`Integrations`,desc:`Manage manual and API integrations used across application workflows.`,component:`bgc-integration`}]},{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.`}]}]}],fC=[{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}],pC=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],mC=[{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 hC(){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)(uC,{level:5,children:`Admin Dashboard`}),(0,o.jsx)(lC,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,o.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,o.jsx)(wS,{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)(cC,{}),(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,o.jsx)(lC,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,o.jsx)(`div`,{className:`admin-pipeline-bar`,children:fC.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:fC.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)(lC,{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)(lC,{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)(lC,{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)(lC,{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:pC.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:mC.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)(lC,{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)(lC,{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)(lC,{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)(lC,{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)(lC,{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)(lC,{style:{fontSize:12},children:e}),(0,o.jsx)(lC,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function gC({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)(uC,{level:5,children:e?.heading}),(0,o.jsx)(lC,{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)(lC,{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:dC.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 _C(){let[e,t]=(0,r.useState)(`dashboard`),[n,s]=(0,r.useState)(``),c=(0,r.useMemo)(()=>dC.flatMap(e=>e.items),[]),l=(0,r.useMemo)(()=>c.find(t=>t.id===e),[c,e]),u=(0,r.useMemo)(()=>dC.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)(()=>dC.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:dC.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)(hC,{}):l?.component===`form-groups`?(0,o.jsx)(Lg,{}):l?.component===`detail-groups`?(0,o.jsx)(o_,{}):l?.component===`row-actions`?(0,o.jsx)(J_,{}):l?.component===`users`?(0,o.jsx)(OS,{}):l?.component===`teams`?(0,o.jsx)(PS,{}):l?.component===`roles`?(0,o.jsx)(ZS,{}):l?.component===`permissions`?(0,o.jsx)(iC,{}):l?.component===`templates`?(0,o.jsx)(rv,{}):l?.component===`ai-services`?(0,o.jsx)(sv,{}):l?.component===`bgc-integration`?(0,o.jsx)(pv,{}):(0,o.jsx)(gC,{activeSection:l,activeGroup:u,filteredCards:d,searchText:n,setSearchText:s,allItems:c,handleNav:p})})]})]})}var{Title:vC}=i.Typography;function yC(){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)(bt,{moduleName:n,title:r,columns:4,request:c,viewAll:!1})]})}var{Text:bC,Title:xC}=i.Typography,SC=10*1024*1024,CC=`/templates/test_cases_flow_template.base64.txt`,wC=`test_cases_flow_template.xlsx`,TC=`module | subModule | step_order | description | actions | key | value | expected | scenario`,EC={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},DC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function OC(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 kC(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function AC(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function jC({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 MC({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 NC({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)(bC,{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)(jC,{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 PC(){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=AC(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=EC[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 Im({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>SC){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 OC(e);g(`validating`),S((await jm({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(CC);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=wC,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 Mm({project:c?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:kC(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:DC})}),c?.name&&(0,o.jsx)(i.Col,{children:(0,o.jsx)(bC,{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)(xC,{level:3,children:`Bulk upload test cases`}),(0,o.jsxs)(i.Space,{direction:`vertical`,size:4,children:[(0,o.jsx)(bC,{type:`secondary`,children:TC}),(0,o.jsx)(bC,{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)(MC,{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)(NC,{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)(bC,{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)(bC,{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)(bC,{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 FC=[{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:IC}=i.Typography,LC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],RC={tags:`regression`,active:1},zC={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function BC(e=[]){return e.map(e=>({value:e,label:e}))}function VC(e=``){return String(e??``).trim()}function HC(e=``){return VC(e).toLowerCase()}function UC(e=[]){let t=new Map;return e.forEach(e=>{let n=VC(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function WC(e=[],t,n){let r=VC(t).toLowerCase(),i=VC(n).toLowerCase();return e.reduce((e,t)=>{let n=VC(t?.module).toLowerCase(),a=VC(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 GC({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)(IC,{strong:!0,className:`v1-section-label`,children:t})]})}function KC(){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=zC[v.typeKey],O=(0,r.useMemo)(()=>BC(c),[c]),k=i.Form.useWatch(`module`,t),A=i.Form.useWatch(`flow`,t),j=!!VC(k),M=!!VC(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&l(t)},I=async()=>{h(!0);try{l((await Em(zC.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=VC(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await Am({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(UC(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=VC(e),o=VC(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}C(!0);try{t.setFieldsValue({step_order:WC(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:VC(e.module),flow:VC(e.flow),step_order:Number(e.step_order),description:VC(e.description),keyword:HC(e.keyword),target:VC(e.target),value:VC(e.value),expected:VC(e.expected),tags:e.tags?VC(e.tags):RC.tags,active:Number(e.active)};T(!0);try{await km(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]:VC(n)})},V=e=>{t.setFieldsValue({module:VC(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:RC.tags,value:void 0,expected:void 0})},H=e=>{t.setFieldsValue({flow:VC(e),step_order:void 0})},U=e=>{let t=zC[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=VC((await n.validateFields()).name),r=await Dm({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:LC})}),(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)(IC,{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:RC,onFinish:z,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(GC,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,o.jsx)(IC,{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:FC,onChange:e=>t.setFieldsValue({keyword:HC(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:VC(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var{Text:qC}=i.Typography,JC=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function YC(e=``){return String(e??``).trim()}function XC(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var ZC=[{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`})}],QC={key:!1,value:!1,expected:!1};function $C(e,t){return t?e[t]??QC:QC}function ew(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function tw(){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)(FC),[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)(()=>$C(x,F),[x,F]),z=(0,r.useMemo)(()=>XC(p,`modulename`),[p]),B=(0,r.useMemo)(()=>XC(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 Om();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 Im({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 zm({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([Hm({product_parent_ID:e,module_parent_ID:t,submodule_parent_ID:r,actions:a,limit:1e3}),Gm({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 Hm({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 Wm(u);await G(f.name,e.module),v((await Hm({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:JC})}),(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)(qC,{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:YC(e.description),actions:YC(e.actions),key:YC(e.key),value:YC(e.value),expected:YC(e.expected),scenario:+!!e.scenario,active:+!!e.active};A(!0);try{if(d){await Km(u,{...t,step_order:Number(e.step_order)}),i.message.success(`Test case updated successfully.`),c(`/viewTestCase`);return}await Um(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}),ew(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}),ew(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)(qC,{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=$C(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}),ew(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)(Lu,{listName:`Added Steps`,loading:D,fields:ZC,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:nw}=i.Typography,rw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function iw(){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([Im({project:e}),zm({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 Rm(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 Lm({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:rw})}),(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)(nw,{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)(Lu,{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)(nw,{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:aw}=i.Typography,ow=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function sw(){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 zm({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 Vm(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 Bm({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:ow})}),(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)(aw,{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)(aw,{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)(Lu,{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)(aw,{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:cw}=i.Typography,lw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function uw(){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 Hm({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 qm(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:lw})}),(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)(cw,{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)(Lu,{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 dw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function fw(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:dw}),(0,o.jsx)(Ba,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:pw}=i.Typography,mw=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],hw={tags:`regression`,active:1},gw={module:{dbName:`Modules`,formField:`module`,label:`Module`}},_w={key:!1,value:!1,expected:!1};function vw(e,t){return t?e[t]??_w:_w}function yw(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function bw(e=[]){return e.map(e=>({value:e,label:e}))}function xw(e=``){return String(e??``).trim()}function Sw(e=[]){let t=new Map;return e.forEach(e=>{let n=xw(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function Cw(e=[],t,n){let r=xw(t).toLowerCase(),i=xw(n).toLowerCase();return e.reduce((e,t)=>{let n=xw(t?.module).toLowerCase(),a=xw(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 ww({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)(pw,{strong:!0,className:`v1-section-label`,children:t})]})}function Tw(){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)(FC),[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=gw[S.typeKey],M=(0,r.useMemo)(()=>bw(c),[c]),N=i.Form.useWatch(`module`,t),P=i.Form.useWatch(`flow`,t),F=i.Form.useWatch(`keyword`,t),I=!!xw(N),L=!!xw(P),R=!I,z=!I||!L,B=(0,r.useMemo)(()=>vw(g,F),[g,F]),V=(e,t=[])=>{e===`module`&&l(t)},H=async()=>{y(!0);try{l((await Em(gw.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 Om();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=xw(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await Pm({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(Sw(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=xw(e),o=xw(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}D(!0);try{t.setFieldsValue({step_order:Cw(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:xw(e.module),flow:xw(e.flow),step_order:Number(e.step_order),description:xw(e.description),keyword:xw(e.keyword),target:xw(e.target),value:xw(e.value),expected:xw(e.expected),tags:e.tags?xw(e.tags):hw.tags,active:Number(e.active)};k(!0);try{await Nm(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]:xw(n)})},K=e=>{t.setFieldsValue({module:xw(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:hw.tags,value:void 0,expected:void 0}),yw(t,[`keyword`,`target`,`value`,`expected`])},ne=e=>{t.setFieldsValue({flow:xw(e),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),yw(t,[`keyword`,`target`,`value`,`expected`])},q=e=>{let n=vw(g,e);t.setFieldsValue({keyword:xw(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}),yw(t,[`target`,`value`,`expected`])},J=e=>{let t=gw[e];C({open:!0,typeKey:e}),n.setFieldsValue({name:``,type:t.label})},Y=()=>{C(e=>({...e,open:!1})),n.resetFields()},re=async()=>{try{let e=xw((await n.validateFields()).name),r=await Dm({name:e,type:j.dbName});V(S.typeKey,r?.items??[]),t.setFieldsValue({[j.formField]:e}),i.message.success(`${j.label} added successfully.`),Y()}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:mw})}),(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)(pw,{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:hw,onFinish:ee,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(ww,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,o.jsx)(pw,{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:()=>J(`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:q})})}),(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:Y,onOk:()=>{T(!0),re()},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:xw(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var Ew=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function Dw(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:Ew}),(0,o.jsx)(Ba,{moduleName:`lms-flows`,rowKey:`id`})]})}var Ow=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function kw(e=Ow){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 Aw(e,t=Ow){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 jw=kw();function Mw(e){return typeof e==`function`?e:typeof e==`string`?kw([e]):Array.isArray(e)?kw(e):jw}function Nw(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:t.id??e.id??n}}function Pw(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var Fw=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function Iw(e){let t=e?.data??e,n={};for(let r of Fw){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var Lw=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function Rw(e,t,n){let r=(Array.isArray(n)?n:[n]).map(Lw).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(Lw(e?.value))||r.includes(Lw(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 zw=(e,t)=>Sr(e,t).rows,Bw=(e,t)=>{let{rows:n,total:r}=Sr(e,t);return{rows:n,total:r}};function Vw({fetchPrimaryPage:e,extractPrimaryPage:t=Bw,fetchSecondaryByKeys:n,fetchPrimary:r,extractPrimaryRows:i=zw,fetchSecondary:a,extractSecondaryRows:o=zw,fetchSecondaryById:s,primaryKey:c,secondaryKey:l,mergeRow:u=Nw,secondaryFetchLimit:d=200,extraFields:f=[],extraFieldsAfter:p}){let m=Mw(c),h=typeof l==`function`?e=>{let t=l(e);return t?[String(t)]:[]}:e=>Aw(e,typeof l==`string`?[l]:Array.isArray(l)?l:Ow),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=Iw(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return f.length&&(r.fields=Rw(r.fields??[],f,p)),Pw(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 Hw(e,t,n={}){return Vw({fetchPrimary:()=>cx(e,t),extractPrimaryRows:ax,fetchSecondary:tn,fetchSecondaryById:lx,secondaryFetchLimit:n.moduleFetchLimit??200})}function Uw(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 Ww(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=Uw(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var Gw=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function Kw({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=Nw(n,r,i),o=Gw(a);return o!=null&&(console.log(`mergeJobWorkflowRow`,i,a?.[e],o),a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function qw(e={}){let t=Kw(),n=Vw({primaryKey:`_id`,secondaryKey:`entityId`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:tn,fetchSecondaryByKeys:()=>sx(),extractSecondaryRows:e=>(e?.items??[]).map(Ww),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 Jw(e,t=10,n=0,r={},i={}){return Sr(await qw(i)(e,t,n,r),e)}async function Yw(e,t,n,r=10,i=0,a={}){return Sr(await Hw(e,t)(n,r,i,a),n)}var Xw=bS,Zw=Xm(_C),Qw=Xm(yC),$w=Xm(PC),eT=Xm(KC),tT=Xm(tw),nT=Xm(iw),rT=Xm(sw),iT=Xm(uw),aT=Xm(fw),oT=Xm(Tw),sT=Xm(Dw);exports.ADMIN_API_URL=t.h,exports.ADMIN_APP_ID=t.g,exports.APP_ID=t._,exports.AUTH_URL=t.v,exports.ActivityTab=bs,exports.AddBatchCandidatePopup=rS,exports.AddFormV1=is,exports.AdminDashboard=bS,exports.AdminDashboardContent=uy,exports.AdminPage=Xw,exports.AppAlert=as,exports.AppButton=Yr,exports.AppShell=ym,exports.ApprovalActionBar=bf,exports.AssigneeAvatars=xs,exports.AuthGuard=_m,exports.BILLING_STATUS_FLOW=rd,exports.Breadcrumb=e.t,exports.BulkUploadPage=$w,exports.CANDIDATES_URL=t.y,exports.CONTRACT_C2C=Rf,exports.CONTRACT_W2=Lf,exports.CalendarCard=D,exports.CoreThemeAdminApp=my,exports.CoreThemeAdminRoutes=py,exports.CustomPagination=xe,exports.DayLogModal=mf,exports.DescriptionBlock=Ps,exports.DetailHeaderCard=gl,exports.DetailViewPage=Cl,exports.DetailViewV1=xc,exports.DocumentViewer=e.Hn,exports.DynamicCards=bt,exports.DynamicPopup=Hb,exports.DynamicPopupRoute=oS,exports.DynamicTabs=j,exports.EditFormV1=hu,exports.FINANCE_APPROVAL_CONFIG=Mf,exports.FINANCE_TYPE_CFO=Of,exports.FINANCE_TYPE_ONBOARDING_MANAGER=Df,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=Af,exports.FINANCE_TYPE_SUBMISSION_MANAGER=Ef,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=kf,exports.FileListCard=gp,exports.FinanceApprovalPanel=lp,exports.FinanceAvatar=Bd,exports.FinanceBadge=Wd,exports.FinanceDayCell=Sf,exports.FinanceDetailHeader=Xd,exports.FinanceDivider=Ad,exports.FinanceEmployeeCell=Vd,exports.FinanceEmptyState=Dd,exports.FinanceEquation=jd,exports.FinanceHistoryTimeline=Fd,exports.FinanceHoursGrid=Ed,exports.FinanceKpiRow=Td,exports.FinanceLine=kd,exports.FinanceListToolbar=Ld,exports.FinanceMarginBadge=Gd,exports.FinanceMoneyCell=Ud,exports.FinanceRecordsTable=Jd,exports.FinanceRowChevron=Kd,exports.FinanceSection=Od,exports.FinanceStatusPill=wd,exports.FinanceTextCell=Hd,exports.FinanceTimesheetAnalysis=wf,exports.FinanceWorkflowSteps=Md,exports.Header=Up,exports.HierarchyUserFilter=Tt,exports.JOBS_URL=t.b,exports.LegacyAdminPage=Zw,exports.ListView=Ba,exports.LmsHomePage=sT,exports.LmsTestForm=oT,exports.Login=bm,exports.MailPopup=Sy,exports.ManageModules=nT,exports.ManageSubmodules=rT,exports.ModuleRowActions=wu,exports.NotesPanel=yf,exports.PAYROLL_STATUS_FLOW=id,exports.POPUP_CONFIGS=Xx,exports.ParamCardView=ju,exports.ParamListView=Lu,exports.PreviewPopup=eb,exports.ProjectSelect=Ym,exports.ProofUploadPreview=vf,exports.QuickLogBar=_f,exports.QuickLogSelectionBar=hf,exports.RejectionReasonModal=gf,exports.SUBMISSIONS_URL=t.x,exports.Sidebar=pm,exports.StatusBadge=zu,exports.StatusBadgeTag=$d,exports.StickyNotesFullPage=Qw,exports.StylishDynamicTabs=Vu,exports.TemplateEditor=Ku,exports.TestForm=eT,exports.TestingHomePage=aT,exports.TimelineGroups=fs,exports.TimesheetDayCell=lf,exports.TipTapEditor=e.Un,exports.UserForm=yS,exports.VendorShareDrawer=uS,exports.ViewSummaryWidget=Jr,exports.WizardPopup=ob,exports.ZinnextTableView=iT,exports.ZinnextTestForm=tT,exports.applyIntegrationStatus=e.ct,exports.approveSubmission=ae,exports.buildCsv=vd,exports.buildDailyRows=fd,exports.buildDayGradient=sf,exports.buildRateHistoryEntries=tp,exports.buildWeeklyRollup=hd,exports.clearSelectedProject=t.n,exports.colors=e.Kn,exports.computeFinance=$f,exports.computeMarginBand=gd,exports.configureCoreTheme=t.S,exports.createAllWorkflowsListFetcher=qw,exports.createWorkflowStageListFetcher=Hw,exports.deleteIntegrationConfig=e.yt,exports.deriveDayStats=dd,exports.downloadCsv=Sd,exports.findEmployerRow=qf,exports.flattenGroups=Kf,exports.formatFinanceMoney=np,exports.formatHours=Yu,exports.formatMoney=Ju,exports.formatRate=Xu,exports.getActivity=e.tt,exports.getAllWorkflowsModuleList=Jw,exports.getApprovalDate=ed,exports.getBgcIntegrationConfig=e.It,exports.getBgcIntegrationSummary=e.Lt,exports.getBillingActionStates=ad,exports.getCurrentRoleName=t.o,exports.getFieldLabel=bd,exports.getFinanceApprovalConfig=Pf,exports.getFormGroupsRaw=mp,exports.getIntegrationConfig=e.Ut,exports.getIntegrationConfigs=e.Wt,exports.getIntegrationSummary=e.Gt,exports.getModuleConfig=be,exports.getModuleDataDetail=e.rt,exports.getPayrollActionStates=od,exports.getSelectedProject=t.s,exports.getStoredToken=t.c,exports.getStoredUser=t.l,exports.getUserRoles=t.u,exports.getVMSApprove=oe,exports.getValueStyle=xd,exports.getWorkflowStageModuleList=Yw,exports.getWorkflowSteps=sd,exports.humanizeEvent=$u,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return io}}),exports.indexFieldConfig=yd,exports.initialsOf=Zu,exports.isTester=t.d,exports.logout=t.p,exports.marginIncludesReferral=If,exports.matchLocationTax=Qf,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return El}}),exports.normalizeContract=Yf,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Ss}}),exports.rejectSubmission=se,exports.resolveActivityMeta=_s,exports.resolveAndCompute=ep,exports.resolveFinanceInputs=Zf,exports.resolveMergeKey=jw,exports.resolveRejectionReason=Ff,exports.resolveSubmissionFinance=hp,exports.saveBgcIntegrationConfig=e.fn,exports.saveIntegrationConfig=e.hn,exports.setSelectedProject=t.m,exports.stageCountKey=Uw,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return xm}}),exports.testIntegrationConnection=e.xn,exports.useDropdownFields=vn,exports.useDropdownValues=Xr,exports.useEditForm=_p,exports.useFieldConfig=yn,exports.useFilterFields=bn,exports.useMenuPermission=En,exports.useModuleActions=_u,exports.useRecordRefresh=bl,exports.withAdminAppId=t.C,exports.withAppId=t.w,exports.withAuthGuard=Xm;
|
|
10
10
|
//# sourceMappingURL=index.cjs.map
|