@realtek/core-theme 0.0.360 → 0.0.361

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.
@@ -13,11 +13,11 @@ Upload the résumé first — we can read the details straight from it`})}),(0,l
13
13
  max-height: 420px !important;
14
14
  }
15
15
  }
16
- `}),(0,l.jsxs)(s.Form,{form:u,layout:`vertical`,initialValues:MT,disabled:h,className:`template-editor-form`,children:[(0,l.jsxs)(`div`,{className:`template-editor-grid`,children:[(0,l.jsx)(s.Form.Item,{name:`name`,label:`Template name`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`Candidate introduction`})}),(0,l.jsx)(s.Form.Item,{name:`module`,label:`Module`,rules:[{required:!0}],children:(0,l.jsx)(s.Select,{showSearch:!0,optionFilterProp:`label`,options:r,onChange:e=>{u.setFieldValue(`action`,``),C(e)}})}),(0,l.jsx)(s.Form.Item,{name:`action`,label:`Action`,rules:[{required:!0}],tooltip:`Pick a Row Action, or TYPE a system action key. Not every email comes from a row action — the credentials mail sent when an employer's recruiters are provisioned uses "accountCreated", which is raised by a workflow and so never appears in this list.`,children:(0,l.jsx)(s.Select,{showSearch:!0,mode:`tags`,maxCount:1,optionFilterProp:`label`,options:_,placeholder:`Select a row action, or type a system key (e.g. accountCreated)`})}),(0,l.jsx)(s.Form.Item,{name:`clientId`,label:`Client scope (optional)`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,options:i,placeholder:`Available to every client`})})]}),(0,l.jsx)(s.Form.Item,{name:`description`,label:`Description`,children:(0,l.jsx)(s.Input.TextArea,{rows:2})}),(0,l.jsxs)(`div`,{className:`template-editor-grid template-editor-grid--three`,children:[(0,l.jsx)(s.Form.Item,{name:`toMail`,label:`Default To`,children:(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`]})}),(0,l.jsx)(s.Form.Item,{name:`ccMail`,label:`Default Cc`,children:(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`]})}),(0,l.jsx)(s.Form.Item,{name:`bccMail`,label:`Default Bcc`,children:(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`]})})]}),(0,l.jsxs)(`div`,{className:`template-editor-workspace`,style:{display:`grid`,gridTemplateColumns:`minmax(0, 1.2fr) minmax(360px, 0.8fr)`,gap:20,alignItems:`start`,marginTop:4},children:[(0,l.jsxs)(`div`,{className:`template-editor-compose-pane`,style:{minWidth:0,padding:16,border:`1px solid #e5e7eb`,borderRadius:10,background:`#fff`},children:[(0,l.jsx)(jT,{strong:!0,style:{display:`block`,marginBottom:12},children:`Email content`}),(0,l.jsx)(s.Form.Item,{name:`subject`,label:`Subject`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`Email subject — drag placeholders here`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`copy`}})}),(0,l.jsx)(s.Form.Item,{label:`Message`,required:!0,style:{marginBottom:0},children:(0,l.jsx)(`div`,{onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`copy`},style:{minHeight:320},children:(0,l.jsx)(n.On,{value:d,onChange:f,placeholder:`Write the reusable email body… Drag placeholders from the right panel.`})})})]}),(0,l.jsxs)(`div`,{className:`template-placeholder-panel`,style:{position:`sticky`,top:0,maxHeight:`calc(100vh - 190px)`,overflowY:`auto`,padding:16,border:`1px solid #dbeafe`,borderRadius:10,background:`#f8fbff`},children:[(0,l.jsx)(jT,{strong:!0,style:{display:`block`},children:`All module placeholders`}),(0,l.jsx)(jT,{type:`secondary`,style:{display:`block`,marginTop:4},children:`Drag a placeholder into Subject or Message. You can also click a placeholder to append it to the message.`}),A.map(e=>(0,l.jsxs)(`div`,{style:{marginTop:14},children:[(0,l.jsx)(jT,{type:`secondary`,strong:!0,children:e.label||e.moduleName}),(0,l.jsx)(`div`,{className:`template-placeholder-list`,style:{marginTop:6},children:e.fields.map(t=>(0,l.jsx)(s.Tooltip,{title:`${t.label||t.key} · ${t.value}`,children:(0,l.jsx)(s.Tag,{color:`blue`,draggable:!0,onDragStart:e=>D(e,t),onClick:()=>E(t),style:{cursor:`grab`,userSelect:`none`,marginBottom:6},children:`{{.${t.key}}}`})},`${e.moduleName}:${t.key}:${t.value}`))})]},e.moduleName)),!A.length&&(0,l.jsx)(s.Empty,{image:s.Empty.PRESENTED_IMAGE_SIMPLE,description:`No module fields available`})]})]}),(0,l.jsx)(s.Form.Item,{name:`isActive`,label:`Available in mail composer`,valuePropName:`checked`,style:{marginTop:16},children:(0,l.jsx)(s.Switch,{})})]})]})}function zT(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(1),[h,g]=(0,o.useState)(20),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)([]),[x,S]=(0,o.useState)(null),[C,w]=(0,o.useState)(!1),T=(0,o.useMemo)(()=>_.map(e=>({value:e.key??e.module??e.value,label:e.label??e.name??e.key??e.module??e.value})).filter(e=>e.value),[_]);function E(e=p,n=h,r=d){u(!0),Gw({offset:(e-1)*n,limit:n,search:r}).then(({items:e,totalCount:n})=>{t(e),i(n)}).catch(e=>s.message.error(e?.message||`Could not load templates`)).finally(()=>u(!1))}(0,o.useEffect)(()=>{queueMicrotask(()=>{E(1,h,``)})},[]),(0,o.useEffect)(()=>{Promise.all([n.Sr(),n.mr({limit:200})]).then(([e,t])=>{v(hS(e).map(({value:e,label:t})=>({key:e,label:t}))),b(t)}).catch(()=>{})},[]);async function D(e,n){let r=NT(e);try{await Jw(r,{...e,isActive:n}),t(e=>e.map(e=>NT(e)===r?{...e,isActive:n}:e))}catch(e){s.message.error(e?.message||`Could not update status`)}}async function O(e){try{await Yw(e),s.message.success(`Template deleted`),E(1),m(1)}catch(e){s.message.error(e?.message||`Could not delete template`)}}let k=[{title:`Template`,key:`template`,width:300,ellipsis:!0,render:(e,t)=>(0,l.jsxs)(`div`,{className:`admin-config-primary-cell templates-primary-cell`,children:[(0,l.jsx)(jT,{strong:!0,ellipsis:{tooltip:t.name},children:t.name}),(0,l.jsx)(jT,{type:`secondary`,ellipsis:{tooltip:t.description||t.subject},children:t.description||t.subject||`No description`})]})},{title:`Module`,dataIndex:`module`,key:`module`,width:140,ellipsis:!0,responsive:[`sm`],render:e=>e?(0,l.jsx)(s.Tag,{color:`blue`,children:e}):`—`},{title:`Action`,dataIndex:`action`,key:`action`,width:180,ellipsis:!0,responsive:[`md`],render:e=>e?(0,l.jsx)(jT,{code:!0,ellipsis:{tooltip:e},children:e}):`—`},{title:`Recipients`,key:`recipients`,width:130,responsive:[`lg`],render:(e,t)=>`${(t.toMail?.length??0)+(t.ccMail?.length??0)+(t.bccMail?.length??0)} defaults`},{title:`Active`,dataIndex:`isActive`,key:`active`,width:80,render:(e,t)=>(0,l.jsx)(s.Switch,{size:`small`,checked:e,onChange:e=>D(t,e)})},{title:``,key:`actions`,width:84,fixed:`right`,render:(e,t)=>(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{S(NT(t)),w(!0)}})}),(0,l.jsx)(s.Popconfirm,{title:`Delete this template?`,onConfirm:()=>O(NT(t)),children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],A=y.map(e=>({value:e._id??e.id,label:e.clientName??e.name??e._id})).filter(e=>e.value);return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.MailOutlined,{}),title:`Email templates`,extra:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{S(null),w(!0)},children:`New template`}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(jT,{type:`secondary`,children:`Create reusable, module-aware email content. Modules, actions and placeholders are read from DB configuration.`})]}),(0,l.jsxs)(Z,{title:`${r} template${r===1?``:`s`}`,extra:(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:()=>E(),children:`Reload`}),children:[(0,l.jsx)(`div`,{className:`admin-config-table-tools`,children:(0,l.jsx)(s.Input,{allowClear:!0,prefix:(0,l.jsx)(c.SearchOutlined,{}),placeholder:`Search templates`,value:d,onChange:e=>{let t=e.target.value;f(t),m(1),E(1,h,t)}})}),(0,l.jsx)(`div`,{className:`templates-table-viewport`,children:(0,l.jsx)(s.Table,{rowKey:NT,columns:k,dataSource:e,loading:a,className:`fg-table`,size:`small`,tableLayout:`fixed`,sticky:!0,scroll:{x:914,y:`calc(100vh - 410px)`},pagination:{current:p,pageSize:h,total:r,showSizeChanger:!0,responsive:!0,onChange:(e,t)=>{m(e),g(t),E(e,t)}}})})]}),(0,l.jsx)(RT,{open:C,templateId:x,modules:T,clients:A,onClose:()=>w(!1),onSaved:()=>{w(!1),E()}})]})}function BT({open:e,signatureId:t,onClose:r,onSaved:i}){let[a,c]=(0,o.useState)(``),[u,d]=(0,o.useState)(``),[f,p]=(0,o.useState)({module:`userSignature`,keys:[]}),[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(!e)return;let n=!1;return queueMicrotask(()=>{_(!0),Promise.all([t?eT(t):Promise.resolve(null),Qw()]).then(([e,t])=>{n||(c(e?.signatureName??``),d(e?.signature??``),p(t??{module:`userSignature`,keys:[]}))}).catch(()=>{n||s.message.error(`Could not load signature details`)}).finally(()=>{n||_(!1)})}),()=>{n=!0}},[e,t]);function v(e){let t=`{{.${e.key}}}`;d(e=>`${e}${e?` `:``}${t}`)}async function y(){if(!a.trim())return s.message.error(`Signature name is required`);if(!u.trim())return s.message.error(`Signature content is required`);h(!0);try{let e=LT(u),n=(f.keys??[]).filter(t=>e.has(t.key)).map(e=>({key:e.key,value:e.value})),r={signatureId:t,signatureName:a,signature:u,signatureLogoPath:``,placeHolder:n.length?[{moduleName:f.module||`userSignature`,holders:n}]:[]};t?await nT(r):await tT(r),s.message.success(t?`Signature updated`:`Signature created`),i()}catch(e){s.message.error(e?.message||`Could not save signature`)}finally{h(!1)}}let b=(f.keys??[]).filter(e=>![`Role_id`,`Role_name`,`Reporting_manager`].includes(e.key)),x=(f.keys??[]).filter(e=>[`Role_id`,`Role_name`,`Reporting_manager`].includes(e.key)),S=e=>(0,l.jsx)(`div`,{className:`template-placeholder-list`,children:e.map(e=>(0,l.jsx)(s.Tooltip,{title:`Mongo field: ${e.value}`,children:(0,l.jsx)(s.Tag,{color:`blue`,style:{cursor:`pointer`},onClick:()=>v(e),children:`{{.${e.key}}}`})},e.key))});return(0,l.jsx)(s.Drawer,{open:e,onClose:r,width:`min(820px, 96vw)`,title:t?`Edit signature`:`New signature`,destroyOnClose:!0,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:m,onClick:y,children:t?`Update`:`Create`})]}),children:(0,l.jsxs)(s.Form,{layout:`vertical`,children:[(0,l.jsx)(s.Form.Item,{label:`Signature name`,required:!0,children:(0,l.jsx)(s.Input,{value:a,onChange:e=>c(e.target.value)})}),(0,l.jsx)(s.Form.Item,{label:`Signature content`,required:!0,children:(0,l.jsx)(n.On,{value:u,onChange:d,placeholder:`Create the reusable signature…`})}),(0,l.jsxs)(`div`,{className:`template-placeholder-panel`,children:[(0,l.jsx)(jT,{strong:!0,children:`Signature placeholders`}),(0,l.jsx)(jT,{type:`secondary`,children:`Click a placeholder to add it to the signature. Values resolve from MongoDB users and roles when mail is generated.`}),g?(0,l.jsx)(jT,{type:`secondary`,children:`Loading placeholders…`}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{style:{marginTop:10},children:[(0,l.jsx)(jT,{strong:!0,children:`User details`}),S(b)]}),(0,l.jsxs)(`div`,{style:{marginTop:10},children:[(0,l.jsx)(jT,{strong:!0,children:`Role details`}),S(x)]}),!f.keys?.length&&(0,l.jsx)(s.Empty,{image:s.Empty.PRESENTED_IMAGE_SIMPLE,description:`No signature placeholders available`})]})]})]})})}function VT(){let[e,t]=(0,o.useState)([]),[n,r]=(0,o.useState)(0),[i,a]=(0,o.useState)(!1),[u,d]=(0,o.useState)(``),[f,p]=(0,o.useState)(1),[m,h]=(0,o.useState)(20),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(null);function b(e=f,n=m,i=u){a(!0),$w({offset:(e-1)*n,limit:n,search:i}).then(({items:e,totalCount:n})=>{t(e),r(n)}).catch(()=>s.message.error(`Could not load signatures`)).finally(()=>a(!1))}(0,o.useEffect)(()=>{queueMicrotask(()=>{b(1,m,``)})},[]);async function x(e,n){try{await iT(e.signatureId,n),t(t=>t.map(t=>t.signatureId===e.signatureId?{...t,isActive:n}:t))}catch{s.message.error(`Could not update status`)}}async function S(e){try{await rT(e),s.message.success(`Signature deleted`),p(1),b(1)}catch{s.message.error(`Could not delete signature`)}}return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsx)(Z,{icon:(0,l.jsx)(c.MailOutlined,{}),title:`Signature templates`,extra:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{y(null),_(!0)},children:`New signature`}),children:(0,l.jsx)(jT,{type:`secondary`,children:`Existing company and user signatures from the shared DB.`})}),(0,l.jsxs)(Z,{title:`${n} signature${n===1?``:`s`}`,children:[(0,l.jsx)(`div`,{className:`admin-config-table-tools`,children:(0,l.jsx)(s.Input,{allowClear:!0,prefix:(0,l.jsx)(c.SearchOutlined,{}),value:u,placeholder:`Search signatures`,onChange:e=>{d(e.target.value),p(1),b(1,m,e.target.value)}})}),(0,l.jsx)(`div`,{className:`templates-table-viewport`,children:(0,l.jsx)(s.Table,{rowKey:`signatureId`,dataSource:e,columns:[{title:`Signature`,dataIndex:`templateName`,key:`name`,width:300,ellipsis:!0,render:e=>(0,l.jsx)(jT,{strong:!0,ellipsis:{tooltip:e},children:e||`Untitled signature`})},{title:`Created`,dataIndex:`createdDt`,key:`created`,width:150,responsive:[`md`],render:e=>e?new Date(e).toLocaleDateString():`—`},{title:`Active`,dataIndex:`isActive`,key:`active`,width:80,render:(e,t)=>(0,l.jsx)(s.Switch,{size:`small`,checked:e,onChange:e=>x(t,e)})},{title:``,key:`actions`,width:84,fixed:`right`,render:(e,t)=>(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{y(t.signatureId),_(!0)}}),(0,l.jsx)(s.Popconfirm,{title:`Delete this signature?`,onConfirm:()=>S(t.signatureId),children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],loading:i,className:`fg-table`,size:`small`,tableLayout:`fixed`,sticky:!0,scroll:{x:614,y:`calc(100vh - 410px)`},pagination:{current:f,pageSize:m,total:n,responsive:!0,onChange:(e,t)=>{p(e),h(t),b(e,t)}}})})]}),(0,l.jsx)(BT,{open:g,signatureId:v,onClose:()=>_(!1),onSaved:()=>{_(!1),b()}})]})}function HT(){return(0,l.jsx)(s.Tabs,{defaultActiveKey:`email`,className:`admin-config-tabs`,items:[{key:`email`,label:`Email templates`,children:(0,l.jsx)(zT,{})},{key:`signature`,label:`Signatures`,children:(0,l.jsx)(VT,{})}]})}var{Text:UT}=s.Typography,WT={serviceKey:``,label:``,baseUrl:``,authHeader:``,authValue:``,enabled:!0};function GT({open:e,service:t,onClose:r,onSaved:i}){let[a]=s.Form.useForm(),[c,u]=(0,o.useState)(!1);(0,o.useEffect)(()=>{e&&a.setFieldsValue({...WT,...t,authValue:``})},[e,t,a]);async function d(){try{let e=await a.validateFields();u(!0),await n.ti(e),s.message.success(`AI service saved`),i()}catch(e){e?.errorFields||s.message.error(e?.message||`Could not save AI service`)}finally{u(!1)}}return(0,l.jsx)(s.Drawer,{open:e,onClose:r,width:`min(560px, 96vw)`,title:t?`Edit AI service`:`New AI service`,destroyOnClose:!0,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:c,onClick:d,children:`Save`})]}),children:(0,l.jsxs)(s.Form,{form:a,layout:`vertical`,initialValues:WT,children:[(0,l.jsx)(s.Form.Item,{name:`serviceKey`,label:`Service Key`,rules:[{required:!0,message:`Service key is required`}],tooltip:`Referenced by an AI Action's Service Key on any form field (e.g. pyOps).`,children:(0,l.jsx)(s.Input,{placeholder:`pyOps`,disabled:!!t,className:`fg-mono-input`})}),(0,l.jsx)(s.Form.Item,{name:`label`,label:`Label`,children:(0,l.jsx)(s.Input,{placeholder:`Resume/JD Parsing Service`})}),(0,l.jsx)(s.Form.Item,{name:`baseUrl`,label:`Base URL`,rules:[{required:!0,message:`Base URL is required`}],children:(0,l.jsx)(s.Input,{placeholder:`https://ai.example.com`,className:`fg-mono-input`})}),(0,l.jsx)(s.Form.Item,{name:`authHeader`,label:`Auth Header (optional)`,children:(0,l.jsx)(s.Input,{placeholder:`x-api-key`,className:`fg-mono-input`})}),(0,l.jsx)(s.Form.Item,{name:`authValue`,label:`Auth Value`,tooltip:`Write-only — leave blank to keep the currently saved value.`,children:(0,l.jsx)(s.Input.Password,{placeholder:t?`Unchanged`:``})}),(0,l.jsx)(s.Form.Item,{name:`enabled`,label:`Enabled`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{})})]})})}function KT(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null);function p(){i(!0),n.gr().then(e=>t(Array.isArray(e)?e:[])).catch(e=>s.message.error(e?.message||`Could not load AI services`)).finally(()=>i(!1))}(0,o.useEffect)(()=>{queueMicrotask(()=>{p()})},[]);async function m(e,r){try{await n.ti({...e,enabled:r}),t(t=>t.map(t=>t.serviceKey===e.serviceKey?{...t,enabled:r}:t))}catch(e){s.message.error(e?.message||`Could not update AI service`)}}async function h(e){try{await n.rr(e),s.message.success(`AI service deleted`),p()}catch(e){s.message.error(e?.message||`Could not delete AI service`)}}return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.ThunderboltOutlined,{}),title:`AI Services`,extra:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{f(null),u(!0)},children:`New service`}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(UT,{type:`secondary`,children:`Register the AI/automation backends that admin-configured "AI Actions" (Generate/Parse-style buttons on any form field) call. A field's AI Action names a Service Key here — no URL is ever hardcoded in the app.`})]}),(0,l.jsx)(Z,{title:`${e.length} service${e.length===1?``:`s`}`,extra:(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:p,children:`Reload`}),children:(0,l.jsx)(s.Table,{rowKey:`serviceKey`,columns:[{title:`Service`,key:`service`,render:(e,t)=>(0,l.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,l.jsx)(UT,{strong:!0,children:t.label||t.serviceKey}),(0,l.jsx)(UT,{type:`secondary`,code:!0,children:t.serviceKey})]})},{title:`Base URL`,dataIndex:`baseUrl`,key:`baseUrl`,ellipsis:!0,render:e=>(0,l.jsx)(UT,{code:!0,ellipsis:{tooltip:e},children:e})},{title:`Auth Header`,dataIndex:`authHeader`,key:`authHeader`,width:140,render:e=>e||`—`},{title:`Enabled`,dataIndex:`enabled`,key:`enabled`,width:90,render:(e,t)=>(0,l.jsx)(s.Switch,{size:`small`,checked:e,onChange:e=>m(t,e)})},{title:``,key:`actions`,width:84,fixed:`right`,render:(e,t)=>(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{f(t),u(!0)}})}),(0,l.jsx)(s.Popconfirm,{title:`Delete this AI service?`,onConfirm:()=>h(t.serviceKey),children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],dataSource:e,loading:r,className:`fg-table`,size:`small`})}),(0,l.jsx)(GT,{open:a,service:d,onClose:()=>u(!1),onSaved:()=>{u(!1),p()}})]})}var{Text:qT}=s.Typography,JT={integrationKey:``,label:``,category:`GENERAL`,updateMethod:`MANUAL`,enabled:!0,provider:``,baseUrl:``,authType:`API_KEY`,authHeader:`x-api-key`,authValue:``,clientId:``,clientSecret:``,tokenUrl:``,createPath:``,statusPath:``,testPath:``,webhookSecret:``,targetModule:``,targetField:``,stageMatchField:``,stageMatchValue:``,stageStatusField:``,providerStatusPath:``,providerReferencePath:``,statusMappings:[{providerStatus:``,applicationStatus:``}]},YT=[{label:`API Key`,value:`API_KEY`},{label:`Bearer Token`,value:`BEARER_TOKEN`},{label:`Basic Authentication`,value:`BASIC_AUTH`},{label:`OAuth 2.0 Client Credentials`,value:`OAUTH2_CLIENT_CREDENTIALS`}];function XT(e){let t=Object.fromEntries((e.statusMappings??[]).filter(e=>e?.providerStatus&&e?.applicationStatus).map(e=>[e.providerStatus.trim(),e.applicationStatus.trim()])),n={...e,statusMapping:e.updateMethod===`API`?{targetModule:e.targetModule,targetField:e.targetField,stageMatchField:e.stageMatchField,stageMatchValue:e.stageMatchValue,stageStatusField:e.stageStatusField,providerStatusPath:e.providerStatusPath,providerReferencePath:e.providerReferencePath,values:t}:void 0};return[`statusMappings`,`targetModule`,`targetField`,`stageMatchField`,`stageMatchValue`,`stageStatusField`,`providerStatusPath`,`providerReferencePath`].forEach(e=>delete n[e]),n}function ZT({open:e,integration:t,onClose:r,onSaved:i}){let[a]=s.Form.useForm(),[u,d]=(0,o.useState)(!1),[f,p]=(0,o.useState)(!1),m=s.Form.useWatch(`updateMethod`,a),h=s.Form.useWatch(`authType`,a),g=m===`API`,_=h===`OAUTH2_CLIENT_CREDENTIALS`;(0,o.useEffect)(()=>{if(!e)return;let n=t?.statusMapping??{};a.setFieldsValue({...JT,...t,authValue:``,clientSecret:``,webhookSecret:``,targetModule:n.targetModule??``,targetField:n.targetField??``,stageMatchField:n.stageMatchField??``,stageMatchValue:n.stageMatchValue??``,stageStatusField:n.stageStatusField??``,providerStatusPath:n.providerStatusPath??``,providerReferencePath:n.providerReferencePath??``,statusMappings:Object.entries(n.values??{}).map(([e,t])=>({providerStatus:e,applicationStatus:t})).concat(Object.keys(n.values??{}).length?[]:[{providerStatus:``,applicationStatus:``}])})},[a,t,e]);async function v(){try{let e=XT(await a.validateFields());d(!0),await n.ai(e),s.message.success(`Integration saved`),i()}catch(e){e?.errorFields||s.message.error(e?.message||`Could not save integration`)}finally{d(!1)}}async function y(){try{let e=await a.validateFields([`integrationKey`,`baseUrl`,`testPath`,`authType`,`authHeader`,`authValue`,`clientId`,`clientSecret`,`tokenUrl`]);p(!0);let t=await n.fi(XT({...a.getFieldsValue(!0),...e}));s.message.success(t?.message||`Connection successful${t?.statusCode?` (${t.statusCode})`:``}`)}catch(e){e?.errorFields||s.message.error(e?.message||`Connection test failed`)}finally{p(!1)}}return(0,l.jsx)(s.Drawer,{open:e,onClose:r,width:`min(680px, 96vw)`,title:t?`Edit ${t.label}`:`Add Integration`,destroyOnClose:!0,extra:(0,l.jsxs)(s.Space,{children:[g&&(0,l.jsx)(s.Button,{loading:f,onClick:y,children:`Test Connection`}),(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:u,onClick:v,children:`Save`})]}),children:(0,l.jsxs)(s.Form,{form:a,layout:`vertical`,initialValues:JT,children:[(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`label`,label:`Integration Name`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`Background Check`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`integrationKey`,label:`Integration Key`,rules:[{required:!0},{pattern:/^[a-z][a-z0-9_-]{1,63}$/,message:`Use lowercase letters, numbers, _ or -`}],children:(0,l.jsx)(s.Input,{placeholder:`bgc`,disabled:!!t})})})]}),(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`category`,label:`Category`,children:(0,l.jsx)(s.Select,{options:[{value:`ONBOARDING`,label:`Onboarding`},{value:`HRMS`,label:`HRMS`},{value:`PAYROLL`,label:`Payroll`},{value:`ESIGNATURE`,label:`E-Signature`},{value:`VMS`,label:`VMS`},{value:`GENERAL`,label:`General / Custom`}]})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`enabled`,label:`Enabled`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{})})})]}),(0,l.jsx)(s.Form.Item,{name:`updateMethod`,label:`Update Method`,rules:[{required:!0}],children:(0,l.jsx)(s.Radio.Group,{optionType:`button`,buttonStyle:`solid`,options:[{label:`Manual Update`,value:`MANUAL`},{label:`API Integration`,value:`API`}]})}),!g&&(0,l.jsx)(s.Alert,{type:`info`,showIcon:!0,message:`This integration will use manual updates.`}),g&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Alert,{type:t?.credentialsConfigured?`success`:`warning`,showIcon:!0,message:t?.credentialsConfigured?`Credentials configured`:`Credentials required`,description:`Secrets are write-only. Leave a secret blank while editing to keep its current value.`,style:{marginBottom:16}}),(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`provider`,label:`Provider`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`Provider name`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`baseUrl`,label:`API Base URL`,rules:[{required:!0,type:`url`}],children:(0,l.jsx)(s.Input,{placeholder:`https://api.provider.com`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`createPath`,label:`Create/Submit Path`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`/v1/requests`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`statusPath`,label:`Status Path`,rules:[{required:!0}],tooltip:`Use {referenceId} as a placeholder.`,children:(0,l.jsx)(s.Input,{placeholder:`/v1/requests/{referenceId}`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`testPath`,label:`Test Connection Path`,rules:[{required:!0}],tooltip:`A safe GET endpoint used only to validate URL and credentials.`,children:(0,l.jsx)(s.Input,{placeholder:`/v1/health`})})})]}),(0,l.jsx)(s.Form.Item,{name:`authType`,label:`Authentication Type`,rules:[{required:!0}],children:(0,l.jsx)(s.Select,{options:YT})}),_?(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`clientId`,label:`Client ID`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`clientSecret`,label:`Client Secret`,children:(0,l.jsx)(s.Input.Password,{placeholder:t?.credentialsConfigured?`Unchanged`:`Required`})})}),(0,l.jsx)(s.Col,{xs:24,children:(0,l.jsx)(s.Form.Item,{name:`tokenUrl`,label:`Token URL`,rules:[{required:!0,type:`url`}],children:(0,l.jsx)(s.Input,{})})})]}):(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`authHeader`,label:`Authentication Header`,children:(0,l.jsx)(s.Input,{placeholder:`x-api-key`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`authValue`,label:`API Credential`,children:(0,l.jsx)(s.Input.Password,{placeholder:t?.credentialsConfigured?`Unchanged`:`Required`})})})]}),(0,l.jsx)(s.Form.Item,{name:`webhookSecret`,label:`Webhook Signing Secret (optional)`,children:(0,l.jsx)(s.Input.Password,{placeholder:t?.webhookConfigured?`Unchanged`:``})}),(0,l.jsxs)(Z,{title:`Status Mapping`,children:[(0,l.jsx)(qT,{type:`secondary`,children:`Map a status from the provider response into a module field or a matching workflow stage.`}),(0,l.jsxs)(s.Row,{gutter:16,style:{marginTop:16},children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`targetModule`,label:`Target Module`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`onboarding`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`targetField`,label:`Target Field`,rules:[{required:!0}],tooltip:`Use stages for a stage-array update, or a direct field name.`,children:(0,l.jsx)(s.Input,{placeholder:`stages`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`providerStatusPath`,label:`Provider Status JSON Path`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`data.status`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`providerReferencePath`,label:`Provider Reference JSON Path`,children:(0,l.jsx)(s.Input,{placeholder:`data.id`})})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsx)(s.Form.Item,{name:`stageMatchField`,label:`Stage Match Field`,children:(0,l.jsx)(s.Input,{placeholder:`stageCode`})})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsx)(s.Form.Item,{name:`stageMatchValue`,label:`Stage Match Value`,children:(0,l.jsx)(s.Input,{placeholder:`BGC`})})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsx)(s.Form.Item,{name:`stageStatusField`,label:`Stage Status Field`,children:(0,l.jsx)(s.Input,{placeholder:`status`})})})]}),(0,l.jsx)(qT,{strong:!0,children:`Status Values`}),(0,l.jsx)(s.Form.List,{name:`statusMappings`,children:(e,{add:t,remove:n})=>(0,l.jsxs)(s.Space,{direction:`vertical`,style:{width:`100%`,marginTop:8},children:[e.map(e=>(0,l.jsxs)(s.Row,{gutter:12,children:[(0,l.jsx)(s.Col,{flex:`1 1 220px`,children:(0,l.jsx)(s.Form.Item,{...e,name:[e.name,`providerStatus`],rules:[{required:!0,message:`Provider status is required`}],children:(0,l.jsx)(s.Input,{placeholder:`Provider status, e.g. completed`})})}),(0,l.jsx)(s.Col,{flex:`1 1 220px`,children:(0,l.jsx)(s.Form.Item,{...e,name:[e.name,`applicationStatus`],rules:[{required:!0,message:`Application status is required`}],children:(0,l.jsx)(s.Input,{placeholder:`Zinnext status, e.g. CLEARED`})})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{danger:!0,onClick:()=>n(e.name),children:`Remove`})})]},e.key)),(0,l.jsx)(s.Button,{type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>t({providerStatus:``,applicationStatus:``}),children:`Add Status Mapping`})]})})]})]})]})})}function QT(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null),p=(0,o.useCallback)(()=>{i(!0),n.jr().then(e=>t(Array.isArray(e)?e:[])).catch(e=>s.message.error(e?.message||`Could not load integrations`)).finally(()=>i(!1))},[]);(0,o.useEffect)(()=>{queueMicrotask(p)},[p]);async function m(e){try{await n.ar(e),s.message.success(`Integration deleted`),p()}catch(e){s.message.error(e?.message||`Could not delete integration`)}}return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.ApiOutlined,{}),title:`Integrations`,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:p,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{f(null),u(!0)},children:`Add Integration`})]}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(qT,{type:`secondary`,children:`Configure reusable manual or API integrations for onboarding, payroll, e-signature, VMS, HRMS, and custom workflows.`})]}),(0,l.jsx)(Z,{title:`${e.length} integration${e.length===1?``:`s`}`,children:(0,l.jsx)(s.Table,{rowKey:`integrationKey`,columns:[{title:`Integration`,key:`name`,render:(e,t)=>(0,l.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,l.jsx)(qT,{strong:!0,children:t.label}),(0,l.jsx)(qT,{type:`secondary`,code:!0,children:t.integrationKey})]})},{title:`Category`,dataIndex:`category`,width:130,render:e=>e||`GENERAL`},{title:`Method`,dataIndex:`updateMethod`,width:110,render:e=>(0,l.jsx)(s.Tag,{color:e===`API`?`blue`:`default`,children:e})},{title:`Provider`,dataIndex:`provider`,render:e=>e||`—`},{title:`Enabled`,dataIndex:`enabled`,width:90,render:e=>(0,l.jsx)(s.Tag,{color:e?`green`:`default`,children:e?`Yes`:`No`})},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{f(t),u(!0)}}),(0,l.jsx)(s.Popconfirm,{title:`Delete this integration?`,onConfirm:()=>m(t.integrationKey),children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],dataSource:e,loading:r,size:`small`,className:`fg-table`})}),(0,l.jsx)(ZT,{open:a,integration:d,onClose:()=>u(!1),onSaved:()=>{u(!1),p()}})]})}var $T=`${t.v}/admin/facebook`;async function eE(e,n={}){let r=t.u(),i=await fetch(`${$T}${e}`,{...n,headers:{"Content-Type":`application/json`,...t.D({"X-App-Id":String(t.y)}),...r?{Authorization:`Bearer ${r}`}:{},...n.headers||{}}}),a=await i.json().catch(()=>({}));if(!i.ok||a?.status===!1)throw Error(a?.error||a?.message||a?.reason||`HTTP ${i.status}`);return a?.data??a}var tE=()=>eE(`/forms`),nE=()=>eE(`/courses`),rE=()=>eE(`/course-mappings`),iE=(e,t=!1)=>eE(t?`/course-mappings/${encodeURIComponent(e.formId)}`:`/course-mappings`,{method:t?`PUT`:`POST`,body:JSON.stringify(e)}),aE=e=>eE(`/course-mappings/${encodeURIComponent(e)}`,{method:`DELETE`}),{Text:oE,Title:sE}=s.Typography,cE=`Unmapped`,lE={fontSize:12,color:`#6b7280`};function uE(e,t){return Array.isArray(e)?e:Array.isArray(e?.[t])?e[t]:[]}function dE(){let[e,t]=(0,o.useState)([]),[n,r]=(0,o.useState)([]),[i,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(!1),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(``),[g,_]=(0,o.useState)(`all`),[v,y]=(0,o.useState)(!1),[b,x]=(0,o.useState)(null),[S,C]=(0,o.useState)(``),[w]=s.Form.useForm(),T=(0,o.useCallback)(async()=>{d(!0),C(``);let[e,n,i]=await Promise.allSettled([tE(),nE(),rE()]),o=[];e.status===`fulfilled`?t(uE(e.value,`forms`)):o.push(`Facebook forms: ${e.reason.message}`),n.status===`fulfilled`?r(uE(n.value,`courses`)):o.push(`LMS courses: ${n.reason.message}`),i.status===`fulfilled`?a(uE(i.value,`mappings`)):o.push(`Saved mappings: ${i.reason.message}`),C(o.join(` | `)),d(!1)},[]);(0,o.useEffect)(()=>{T()},[T]);let E=(0,o.useMemo)(()=>new Map(i.map(e=>[String(e.formId),e])),[i]),D=(0,o.useMemo)(()=>new Map(n.map(e=>[String(e.courseId),e.courseName])),[n]),O=(0,o.useMemo)(()=>{let t=e.map(e=>({formId:String(e.id),formName:e.name||String(e.id),formStatus:e.status})),n=new Set(t.map(e=>e.formId));return i.forEach(e=>{n.has(e.formId)||t.push({formId:e.formId,formName:e.formName||e.formId,formStatus:`Unknown`})}),t.map(e=>{let t=E.get(e.formId);return{...e,key:e.formId,mapping:t,courseName:t?D.get(t.courseId)||t.courseName:``,status:t?t.isActive?`active`:`inactive`:`unmapped`}})},[e,i,E,D]),k=(0,o.useMemo)(()=>O.filter(e=>g!==`all`&&e.status!==g?!1:`${e.formName} ${e.formId} ${e.courseName}`.toLowerCase().includes(m.trim().toLowerCase())),[O,g,m]),A=O.filter(e=>e.status===`active`).length,j=O.filter(e=>e.status===`unmapped`).length,M=(e=null)=>{x(e?.formId||null),w.resetFields(),w.setFieldsValue({formId:e?.formId,courseId:e?.mapping?.courseId,isActive:e?.mapping?.isActive??!0}),y(!0)},N=async()=>{try{let e=await w.validateFields();p(!0),await iE(e,!!(b&&E.has(b))),s.message.success(`Facebook form mapped to LMS course`),y(!1),await T()}catch(e){e?.errorFields||s.message.error(e?.message||`Could not save mapping`)}finally{p(!1)}},P=async e=>{try{await aE(e),s.message.success(`Mapping removed; future leads will be unmapped unless another rule matches`),await T()}catch(e){s.message.error(e?.message||`Could not remove mapping`)}};return(0,l.jsxs)(`div`,{className:`facebook-course-mapping`,style:{padding:`4px 0 18px`},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,gap:12,flexWrap:`wrap`,alignItems:`center`,marginBottom:16},children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(sE,{level:4,style:{marginBottom:4},children:`Facebook Lead Form → Course Mapping`}),(0,l.jsx)(oE,{type:`secondary`,children:`One LMS course may receive leads from multiple Facebook forms and advertisements.`})]}),(0,l.jsxs)(s.Space,{wrap:!0,children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:T,loading:u,children:`Sync Facebook Forms`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>M(),children:`Add Mapping`})]})]}),S&&(0,l.jsx)(s.Alert,{showIcon:!0,type:`warning`,message:`Some configuration data could not be loaded`,description:S,style:{marginBottom:16}}),(0,l.jsxs)(s.Row,{gutter:[12,12],style:{marginBottom:16},children:[(0,l.jsx)(s.Col,{xs:12,md:6,children:(0,l.jsx)(s.Card,{size:`small`,children:(0,l.jsx)(s.Statistic,{title:`Facebook Forms`,value:O.length,prefix:(0,l.jsx)(c.LinkOutlined,{})})})}),(0,l.jsx)(s.Col,{xs:12,md:6,children:(0,l.jsx)(s.Card,{size:`small`,children:(0,l.jsx)(s.Statistic,{title:`Active Mappings`,value:A,prefix:(0,l.jsx)(c.CheckCircleOutlined,{})})})}),(0,l.jsx)(s.Col,{xs:12,md:6,children:(0,l.jsx)(s.Card,{size:`small`,children:(0,l.jsx)(s.Statistic,{title:`Unmapped Forms`,value:j,prefix:(0,l.jsx)(c.WarningOutlined,{})})})}),(0,l.jsx)(s.Col,{xs:12,md:6,children:(0,l.jsx)(s.Card,{size:`small`,children:(0,l.jsx)(s.Statistic,{title:`Available Courses`,value:n.length,prefix:(0,l.jsx)(c.BookOutlined,{})})})})]}),(0,l.jsxs)(s.Card,{size:`small`,children:[(0,l.jsxs)(s.Space,{wrap:!0,style:{marginBottom:14,width:`100%`,display:`flex`},children:[(0,l.jsx)(s.Input,{allowClear:!0,style:{width:320,maxWidth:`100%`},placeholder:`Search form, Form ID or course`,prefix:(0,l.jsx)(c.SearchOutlined,{}),value:m,onChange:e=>h(e.target.value)}),(0,l.jsx)(s.Select,{style:{width:185},value:g,onChange:_,options:[{value:`all`,label:`All mappings`},{value:`active`,label:`Active`},{value:`inactive`,label:`Inactive`},{value:`unmapped`,label:`Unmapped`}]})]}),(0,l.jsx)(s.Table,{rowKey:`formId`,columns:[{title:`Facebook Form`,dataIndex:`formName`,key:`formName`,width:`31%`,render:(e,t)=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(oE,{strong:!0,children:e}),(0,l.jsxs)(`div`,{style:lE,children:[`Form ID: `,t.formId]})]})},{title:`LMS Course`,dataIndex:`courseName`,key:`courseName`,render:(e,t)=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(oE,{children:e||cE}),t.mapping&&(0,l.jsx)(`div`,{style:lE,children:t.mapping.courseId})]})},{title:`Mapping Status`,dataIndex:`status`,key:`status`,width:158,render:e=>e===`active`?(0,l.jsx)(s.Tag,{color:`success`,children:`Active`}):e===`inactive`?(0,l.jsx)(s.Tag,{color:`default`,children:`Inactive`}):(0,l.jsx)(s.Tag,{color:`warning`,children:`Unmapped`})},{title:`Actions`,key:`actions`,width:116,render:(e,t)=>(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{size:`small`,title:`Add or edit mapping`,icon:t.mapping?(0,l.jsx)(c.EditOutlined,{}):(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>M(t)}),t.mapping&&(0,l.jsx)(s.Popconfirm,{title:`Remove this mapping?`,description:`Existing LMS leads will not be changed.`,onConfirm:()=>P(t.formId),children:(0,l.jsx)(s.Button,{size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],dataSource:k,loading:u,size:`middle`,scroll:{x:680},pagination:{pageSize:10,showSizeChanger:!1,showTotal:e=>`${e} Facebook forms`},locale:{emptyText:(0,l.jsx)(s.Empty,{description:`No Facebook forms found`})}}),(0,l.jsx)(oE,{type:`secondary`,style:{fontSize:12},children:`Ad count isn't available from the current forms API. Multiple ads using one Form ID need just one mapping. Multiple Form IDs can select the same LMS course. Existing lead courses are not changed when mappings are edited.`})]}),(0,l.jsx)(s.Drawer,{title:b&&E.has(b)?`Edit Course Mapping`:`Add Course Mapping`,width:440,open:v,destroyOnClose:!0,onClose:()=>y(!1),extra:(0,l.jsx)(s.Button,{type:`primary`,onClick:N,loading:f,children:`Save Mapping`}),children:(0,l.jsxs)(s.Form,{form:w,layout:`vertical`,initialValues:{isActive:!0},children:[(0,l.jsx)(s.Form.Item,{name:`formId`,label:`Facebook Lead Form`,rules:[{required:!0,message:`Select a Facebook form`}],children:(0,l.jsx)(s.Select,{showSearch:!0,optionFilterProp:`label`,placeholder:`Select Facebook form`,disabled:!!b,options:O.map(e=>({value:e.formId,label:`${e.formName} (${e.formId})`,disabled:!b&&!!e.mapping}))})}),(0,l.jsx)(s.Form.Item,{name:`courseId`,label:`Available LMS Course`,rules:[{required:!0,message:`Select an LMS course`}],children:(0,l.jsx)(s.Select,{showSearch:!0,optionFilterProp:`label`,placeholder:`Select LMS course`,options:n.map(e=>({value:e.courseId,label:e.courseName}))})}),(0,l.jsx)(s.Form.Item,{name:`isActive`,label:`Mapping Status`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{checkedChildren:`Active`,unCheckedChildren:`Inactive`})}),(0,l.jsx)(s.Alert,{type:`info`,showIcon:!0,message:`Multiple forms can map to the same course`,description:`The selected course will be saved as courseId on newly imported Facebook leads. Forms without an active mapping can still import with course mapping pending.`})]})})]})}var{Text:$}=s.Typography;function fE({rows:e,onChange:t,keyPlaceholder:n,valuePlaceholder:r}){let i=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e)),a=n=>t(e.filter((e,t)=>t!==n));return(0,l.jsxs)(`div`,{children:[e.map((e,t)=>(0,l.jsxs)(`div`,{style:{display:`flex`,gap:6,marginTop:6},children:[(0,l.jsx)(s.Input,{size:`small`,style:{flex:1},placeholder:n,value:e.key,onChange:e=>i(t,{key:e.target.value}),className:`fg-mono-input`}),(0,l.jsx)(`span`,{style:{color:`#94a3b8`,alignSelf:`center`},children:`→`}),(0,l.jsx)(s.Input,{size:`small`,style:{flex:1},placeholder:r,value:e.value,onChange:e=>i(t,{value:e.target.value}),className:`fg-mono-input`}),(0,l.jsx)(s.Button,{size:`small`,type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),onClick:()=>a(t)})]},t)),(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:6},onClick:()=>t([...e,{key:``,value:``}]),children:`Add`})]})}function pE({rows:e,onChange:t,keyPlaceholder:n=`field`,valuePlaceholder:r=`literal or {{field.path}}`}){let i=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e)),a=n=>t(e.filter((e,t)=>t!==n));return(0,l.jsxs)(`div`,{children:[e.map((e,t)=>(0,l.jsxs)(`div`,{style:{display:`flex`,gap:6,marginTop:6},children:[(0,l.jsx)(s.Input,{size:`small`,style:{flex:1},placeholder:n,value:e.key,onChange:e=>i(t,{key:e.target.value}),className:`fg-mono-input`}),(0,l.jsx)(s.Input,{size:`small`,style:{flex:1.6},placeholder:r,value:e.value,onChange:e=>i(t,{value:e.target.value}),className:`fg-mono-input`}),(0,l.jsx)(s.Button,{size:`small`,type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),onClick:()=>a(t)})]},t)),(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:6},onClick:()=>t([...e,{key:``,value:``}]),children:`Add`}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:4},children:[`Values are read as JSON when possible (true, 123, ["a","b"]) — otherwise kept as literal text. Use `,(0,l.jsx)(`code`,{children:`{{field.path}}`}),` to reference a payload field, or `,(0,l.jsx)(`code`,{children:`{{now}}`}),` for the current time.`]})]})}function mE(e){return Object.entries(e??{}).map(([e,t])=>({key:e,value:String(t??``)}))}function hE(e){let t={};for(let n of e??[])n.key?.trim()&&(t[n.key.trim()]=n.value??``);return t}function gE(e){return Object.entries(e??{}).map(([e,t])=>({key:e,value:typeof t==`string`?t:JSON.stringify(t)}))}function _E(e){let t={};for(let n of e??[]){if(!n.key?.trim())continue;let e=n.value;if(typeof e==`string`){let t=e.trim();if(t!==``)try{e=JSON.parse(t)}catch{}}t[n.key.trim()]=e}return t}function vE({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,o.useState)(()=>({sourceModule:``,sourceIdField:``,required:!1,...t??{},fieldMapRows:mE(t?.fieldMap)})),u=(e,t)=>a(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:n,width:640,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.DatabaseOutlined,{}),` `,t?`Edit Denormalize Rule`:`New Denormalize Rule`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:n,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!i.sourceModule?.trim())return s.message.error(`Source module is required`);if(!i.sourceIdField?.trim())return s.message.error(`Source id field is required`);let{fieldMapRows:e,...t}=i;r({...t,fieldMap:hE(e)})},children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source module`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`job`,value:i.sourceModule??``,onChange:e=>u(`sourceModule`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source id field (on THIS payload)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`jobId`,value:i.sourceIdField??``,onChange:e=>u(`sourceIdField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!i.required,onChange:e=>u(`required`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Required — block the write if the source record can't be found`})]}),(0,l.jsxs)(`div`,{style:{marginTop:16},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Field map (source field → this payload's field)`}),(0,l.jsx)(fE,{rows:i.fieldMapRows??[],onChange:e=>u(`fieldMapRows`,e),keyPlaceholder:`jobTitle`,valuePlaceholder:`jobTitle`})]})]})})}function yE({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,o.useState)(()=>({sourceField:``,targetField:``,sourceCollection:``,idField:``,idOutputKey:``,stampNow:``,...t??{},fieldMapRows:mE(t?.fieldMap)})),u=(e,t)=>a(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:n,width:640,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.ApartmentOutlined,{}),` `,t?`Edit Array Enrichment`:`New Array Enrichment`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:n,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!i.sourceField?.trim())return s.message.error(`Source field is required`);if(!i.targetField?.trim())return s.message.error(`Target field is required`);let{fieldMapRows:e,...t}=i;r({...t,fieldMap:hE(e)})},children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source field (array of ids on this payload)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`recruitersData`,value:i.sourceField??``,onChange:e=>u(`sourceField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Target field (enriched array written here)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`recruiters`,value:i.targetField??``,onChange:e=>u(`targetField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source collection`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`users (default)`,value:i.sourceCollection??``,onChange:e=>u(`sourceCollection`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Id field on that collection`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`legacyUserId (default)`,value:i.idField??``,onChange:e=>u(`idField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{style:{marginTop:16},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Field map (source collection field → output key)`}),(0,l.jsx)(fE,{rows:i.fieldMapRows??[],onChange:e=>u(`fieldMapRows`,e),keyPlaceholder:`firstName`,valuePlaceholder:`recruiterName`})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Also write the matched id as`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`recruiterId`,value:i.idOutputKey??``,onChange:e=>u(`idOutputKey`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Also stamp the current time as`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`assignedDateTime`,value:i.stampNow??``,onChange:e=>u(`stampNow`,e.target.value),className:`fg-mono-input`})]})]})]})})}function bE({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,o.useState)(()=>({sourceField:``,targetField:``,uploadedFileNameField:``,uniqueNameField:``,uploadedAtField:``,uploadedByField:``,arrayMode:!1,nameFromField:``,nameOutputField:``,historyField:``,historySnapshotKey:``,historyReason:``,...t??{},staticFieldRows:mE(t?.staticFields),arrayFieldNameRows:mE(t?.arrayFieldNames)})),u=(e,t)=>a(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:n,width:760,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.DatabaseOutlined,{}),` `,t?`Edit File Field Map`:`New File Field Map`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:n,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!i.sourceField?.trim())return s.message.error(`Source field (the multipart upload key) is required`);if(!i.targetField?.trim())return s.message.error(`Target field is required`);let{staticFieldRows:e,arrayFieldNameRows:t,...n}=i;r({...n,staticFields:hE(e),arrayFieldNames:hE(t)})},children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Turns one uploaded file field into a nested object (or array of objects) instead of a flat S3 path string — for schemas like a candidate's resume/passport/visa that store location + filename + who/when as sub-fields.`}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source field (multipart upload key)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume`,value:i.sourceField??``,onChange:e=>u(`sourceField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12},children:[`Target field `,i.arrayMode?`(array)`:`(location sub-field)`]}),(0,l.jsx)(s.Input,{size:`small`,placeholder:i.arrayMode?`documents`:`resume.location`,value:i.targetField??``,onChange:e=>u(`targetField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!i.arrayMode,onChange:e=>u(`arrayMode`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Array mode — every uploaded file becomes one element (e.g. "documents")`})]}),i.arrayMode?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Sub-field names (location / uploadedFileName / uniqueName → this schema's names)`}),(0,l.jsx)(fE,{rows:i.arrayFieldNameRows??[],onChange:e=>u(`arrayFieldNameRows`,e),keyPlaceholder:`location`,valuePlaceholder:`documentCopyLocation`})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Take each element's display name from (payload array field)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`documents`,value:i.nameFromField??``,onChange:e=>u(`nameFromField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`...reading its field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`documentName`,value:i.nameOutputField??``,onChange:e=>u(`nameOutputField`,e.target.value),className:`fg-mono-input`})]})]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Original filename field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume.uploadedFileName`,value:i.uploadedFileNameField??``,onChange:e=>u(`uploadedFileNameField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Unique name field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume.uniqueName`,value:i.uniqueNameField??``,onChange:e=>u(`uniqueNameField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Uploaded-at field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume.uploadedAt`,value:i.uploadedAtField??``,onChange:e=>u(`uploadedAtField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Uploaded-by field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume.uploadedBy`,value:i.uploadedByField??``,onChange:e=>u(`uploadedByField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Static fields (literal value written alongside the upload)`}),(0,l.jsx)(fE,{rows:i.staticFieldRows??[],onChange:e=>u(`staticFieldRows`,e),keyPlaceholder:`resume.source`,valuePlaceholder:`candidate`})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Append a snapshot to (history array field)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resumeHistory`,value:i.historyField??``,onChange:e=>u(`historyField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`...under snapshot key`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume`,value:i.historySnapshotKey??``,onChange:e=>u(`historySnapshotKey`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`...with reason`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`Initial resume upload`,value:i.historyReason??``,onChange:e=>u(`historyReason`,e.target.value),className:`fg-mono-input`})]})]})]})]})})}function xE({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,o.useState)(()=>({name:``,seedField:``,direction:`up`,stopRole:0,includeSeed:!0,...t??{}})),u=(e,t)=>a(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:n,width:620,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.ApartmentOutlined,{}),` `,t?`Edit Hierarchy Expansion`:`New Hierarchy Expansion`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:n,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!i.name?.trim())return s.message.error(`Name is required — this is how RelatedUpdates/Notify reference the result`);if(!/^[a-zA-Z0-9_]+$/.test(i.name))return s.message.error(`Name: letters, numbers, underscores only`);r(i)},children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Name`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`chain`,value:i.name??``,onChange:e=>u(`name`,e.target.value),className:`fg-mono-input`}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:11},children:[`Referenced as `,(0,l.jsx)(`code`,{children:`{{hierarchy.`+(i.name||`name`)+`}}`})]})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Seed field (blank = the caller)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`recruitersData`,value:i.seedField??``,onChange:e=>u(`seedField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Direction`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:i.direction||`up`,onChange:e=>u(`direction`,e),options:[{value:`up`,label:`Up — toward admin (reporting chain)`},{value:`down`,label:`Down — toward subordinates (team)`}]})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Stop at role id (up only, 0 = walk to the top)`}),(0,l.jsx)(s.InputNumber,{size:`small`,style:{width:`100%`},min:0,value:i.stopRole??0,onChange:e=>u(`stopRole`,e??0),disabled:i.direction!==`up`})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:i.includeSeed!==!1,onChange:e=>u(`includeSeed`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Include the seed user(s) themselves in the result`})]})]})})}function SE({open:e,rule:t,hierarchyNames:n,onClose:r,onSave:i}){let[a,u]=(0,o.useState)(()=>({collectionName:``,targetModule:``,matchField:``,scopeTenant:!1,forEach:``,insertMode:!!(t?.insertIfMissing&&Object.keys(t.insertIfMissing).length),...t??{},extraFilterRows:gE(t?.extraFilter),pullRows:gE(t?.pull),pushRows:gE(t?.push),setRows:gE(t?.set),setIfNonBlankRows:gE(t?.setIfNonBlank),insertIfMissingRows:gE(t?.insertIfMissing)})),d=(e,t)=>u(n=>({...n,[e]:t})),f=()=>{if(!a.collectionName?.trim()&&!a.targetModule?.trim())return s.message.error(`Set either a collection name or a target module`);let{extraFilterRows:e,pullRows:t,pushRows:n,setRows:r,setIfNonBlankRows:o,insertIfMissingRows:c,insertMode:l,...u}=a;i({...u,extraFilter:_E(e),pull:l?{}:_E(t),push:l?{}:_E(n),set:l?{}:_E(r),setIfNonBlank:l?{}:_E(o),insertIfMissing:l?_E(c):{}})},p=(n??[]).map(e=>({value:`hierarchy.${e}`,label:`{{hierarchy.${e}}}`}));return(0,l.jsx)(s.Modal,{open:e,onCancel:r,width:820,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.ThunderboltOutlined,{}),` `,t?`Edit Related Update`:`New Related Update`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:f,children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsx)(`div`,{className:`fg-form-section-label`,children:`Target`}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Collection name (used verbatim)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`hiringProgress`,value:a.collectionName??``,onChange:e=>d(`collectionName`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`— or — target module`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`job`,value:a.targetModule??``,onChange:e=>d(`targetModule`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Match field (this payload's field holding the target _id)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`jobId (blank for a tenant-scoped board)`,value:a.matchField??``,onChange:e=>d(`matchField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Repeat once per element of (ForEach)`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},allowClear:!0,showSearch:!0,placeholder:`e.g. {{hierarchy.chain}}`,value:a.forEach||void 0,onChange:e=>d(`forEach`,e??``),options:p})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!a.scopeTenant,onChange:e=>d(`scopeTenant`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Scope filter to the caller's tenant/business/businessUnit`})]}),(0,l.jsxs)(`div`,{style:{marginTop:14},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Extra filter (merged into the match filter)`}),(0,l.jsx)(pE,{rows:a.extraFilterRows??[],onChange:e=>d(`extraFilterRows`,e),keyPlaceholder:`recruiterId`,valuePlaceholder:`{"$in":"{{hierarchy.chain}}"}`})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:18},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!a.insertMode,onChange:e=>d(`insertMode`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Insert-only-if-missing (seed a new document instead of updating an existing one)`})]}),a.insertMode?(0,l.jsxs)(`div`,{style:{marginTop:10},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Document to insert when the filter matches nothing`}),(0,l.jsx)(pE,{rows:a.insertIfMissingRows??[],onChange:e=>d(`insertIfMissingRows`,e),keyPlaceholder:`hiringProgressJobStatus`,valuePlaceholder:`"unread"`})]}):(0,l.jsx)(s.Tabs,{size:`small`,style:{marginTop:10},items:[{key:`pull`,label:`Pull`,children:(0,l.jsx)(pE,{rows:a.pullRows??[],onChange:e=>d(`pullRows`,e),keyPlaceholder:`submitted`,valuePlaceholder:`{"candidateId":"{{applicantId}}"}`})},{key:`push`,label:`Push`,children:(0,l.jsx)(pE,{rows:a.pushRows??[],onChange:e=>d(`pushRows`,e),keyPlaceholder:`submitted`,valuePlaceholder:`{"status":"{{submissionStatus}}"}`})},{key:`set`,label:`Set`,children:(0,l.jsx)(pE,{rows:a.setRows??[],onChange:e=>d(`setRows`,e),keyPlaceholder:`hiringProgressJobStatus`,valuePlaceholder:`"unread"`})},{key:`setIfNonBlank`,label:`Set if non-blank`,children:(0,l.jsx)(pE,{rows:a.setIfNonBlankRows??[],onChange:e=>d(`setIfNonBlankRows`,e),keyPlaceholder:`resume.location`,valuePlaceholder:`{{resume.location}}`})}]})]})})}function CE({icon:e,title:t,description:n,rules:r,columns:i,onAdd:a,onEdit:o,onDelete:u}){return(0,l.jsxs)(Z,{title:(0,l.jsxs)(`span`,{children:[e,` `,t]}),extra:(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:a,children:`Add`}),styles:{body:{paddingTop:8}},children:[n&&(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:n}),(0,l.jsx)(s.Table,{rowKey:(e,t)=>t,dataSource:r,columns:[...i,{title:``,key:`actions`,width:80,align:`right`,render:(e,t,n)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>o(n,t)})}),(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),onClick:()=>u(n)})})]})}],pagination:!1,size:`small`,className:`fg-table`,locale:{emptyText:(0,l.jsx)(s.Empty,{image:s.Empty.PRESENTED_IMAGE_SIMPLE,description:`Not configured`})}})]})}var wE={sequence:null,duplicateCheck:null,fileVersioning:null,denormalizations:[],arrayEnrichments:[],fileFieldMaps:[],sanitizeFields:[],defaults:{},hierarchyExpands:[],relatedUpdates:[],notify:null,cacheInvalidate:[]};function TE(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!0),[a,u]=(0,o.useState)(``),[d,f]=(0,o.useState)({storage:`mongo`}),[p,m]=(0,o.useState)(`mongo`),[h,g]=(0,o.useState)(wE),[_,v]=(0,o.useState)(!1),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)(null),[T,E]=(0,o.useState)(null),[D,O]=(0,o.useState)(null),[k,A]=(0,o.useState)(null),[j,M]=(0,o.useState)(null);(0,o.useEffect)(()=>{n.Sr().then(e=>{let n=hS(e).map(({value:e,label:t})=>({key:e,label:t}));t(n),n.length&&u(n[0].key)}).catch(()=>t([])).finally(()=>i(!1))},[]),(0,o.useEffect)(()=>{if(!a)return;let e=!1;return(async()=>{v(!0),S(``);try{let t=await n.Rr(a);if(e)return;let r=t.gateway??{storage:`mongo`};f(r),m(r.storage||`mongo`),g({...wE,...t.strategies??{}})}catch(t){e||S(t?.message||`Failed to load automations`)}finally{e||v(!1)}})(),()=>{e=!0}},[a]);let N=(0,o.useMemo)(()=>(h.hierarchyExpands??[]).map(e=>e.name).filter(Boolean),[h.hierarchyExpands]);function P(e,t){g(n=>({...n,[e]:t}))}function F(e,t){g(n=>{let r=n.duplicateCheck??{},i=[...r.stages??[]];return i[e]=t,{...n,duplicateCheck:{...r,stages:i}}})}function I(){b(!0);let e={...h,denormalizations:h.denormalizations?.length?h.denormalizations:void 0,arrayEnrichments:h.arrayEnrichments?.length?h.arrayEnrichments:void 0,fileFieldMaps:h.fileFieldMaps?.length?h.fileFieldMaps:void 0,sanitizeFields:h.sanitizeFields?.length?h.sanitizeFields:void 0,hierarchyExpands:h.hierarchyExpands?.length?h.hierarchyExpands:void 0,relatedUpdates:h.relatedUpdates?.length?h.relatedUpdates:void 0,cacheInvalidate:h.cacheInvalidate?.length?h.cacheInvalidate:void 0,defaults:Object.keys(h.defaults??{}).length?h.defaults:void 0};n.oi(a,{gateway:d,strategies:e}).then(()=>{m(d.storage||`mongo`),s.message.success(`Automations saved`)}).catch(e=>s.message.error(e?.message||`Could not save automations`)).finally(()=>b(!1))}function L(){if((d.storage||`mongo`)!==p){s.Modal.confirm({title:`Change how this module persists writes?`,content:`You're switching ${a} from "${p}" to "${d.storage}". `+(d.storage===`mongo`?`This module will stop calling its downstream service and this gateway will own the write + every Strategy below.`:`This module will stop using the Strategies below and go back to calling its downstream service.`)+` Make sure the downstream service / e2e checks are ready before confirming.`,okText:`Confirm cutover`,okButtonProps:{danger:!0},onOk:I});return}I()}let R=[{title:`Source module`,dataIndex:`sourceModule`,key:`sourceModule`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Source id field`,dataIndex:`sourceIdField`,key:`sourceIdField`},{title:`Fields`,key:`fields`,render:(e,t)=>(0,l.jsx)(s.Badge,{count:Object.keys(t.fieldMap??{}).length,showZero:!0,color:`var(--color-brand)`})},{title:`Required`,dataIndex:`required`,key:`required`,width:90,render:e=>e?(0,l.jsx)(s.Tag,{color:`volcano`,children:`Required`}):(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`optional`})}],z=[{title:`Source field`,dataIndex:`sourceField`,key:`sourceField`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Target field`,dataIndex:`targetField`,key:`targetField`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`From collection`,key:`coll`,render:(e,t)=>t.sourceCollection||`users`},{title:`Fields`,key:`fields`,render:(e,t)=>(0,l.jsx)(s.Badge,{count:Object.keys(t.fieldMap??{}).length,showZero:!0,color:`var(--color-brand)`})}],B=[{title:`Source field`,dataIndex:`sourceField`,key:`sourceField`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Target field`,dataIndex:`targetField`,key:`targetField`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Mode`,dataIndex:`arrayMode`,key:`arrayMode`,width:100,render:e=>e?(0,l.jsx)(s.Tag,{color:`blue`,children:`Array`}):(0,l.jsx)(s.Tag,{children:`Single`})},{title:`History`,dataIndex:`historyField`,key:`historyField`,render:e=>e||(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`—`})}],V=[{title:`Name`,dataIndex:`name`,key:`name`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:`{{hierarchy.`+e+`}}`})},{title:`Seed field`,dataIndex:`seedField`,key:`seedField`,render:e=>e||(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`caller`})},{title:`Direction`,dataIndex:`direction`,key:`direction`,render:e=>(0,l.jsx)(s.Tag,{color:e===`down`?`blue`:`purple`,children:e===`down`?`Down — team`:`Up — chain`})},{title:`Stop role`,dataIndex:`stopRole`,key:`stopRole`,width:90,render:e=>e||(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`top`})}],H=[{title:`Target`,key:`target`,render:(e,t)=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:t.collectionName||t.targetModule})},{title:`Match`,key:`match`,render:(e,t)=>t.matchField||(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`tenant-scoped`})},{title:`For each`,key:`forEach`,render:(e,t)=>t.forEach?(0,l.jsx)(s.Tag,{color:`geekblue`,children:`{{${t.forEach}}}`}):(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`once`})},{title:`Mode`,key:`mode`,render:(e,t)=>Object.keys(t.insertIfMissing??{}).length?(0,l.jsx)(s.Tag,{color:`green`,children:`Insert if missing`}):(0,l.jsx)(s.Tag,{children:`Update`})}],ee=e.map(e=>({key:e.key,label:e.label}));return(0,l.jsxs)(`div`,{className:`fg-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.ThunderboltOutlined,{}),title:`Automations`,extra:(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:y,disabled:!a,onClick:L,children:`Save Automations`}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)($,{type:`secondary`,style:{fontSize:13},children:`Config-driven side-effects the common CRUD gateway runs around a create — reference ids, duplicate checks, cross-module field snapshots, reporting-chain hierarchy expansion, board updates, notifications, cache invalidation. Nothing here is module-specific: the same engine serves every module.`})]}),(0,l.jsx)(Z,{styles:{body:{paddingTop:8}},children:(0,l.jsxs)(s.Spin,{spinning:r,children:[(0,l.jsx)(s.Tabs,{activeKey:a,onChange:u,items:ee.map(e=>({...e,children:null})),className:`admin-module-tabs`}),x&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:x,style:{marginBottom:12}}),(0,l.jsxs)(s.Spin,{spinning:_,children:[(0,l.jsxs)(Z,{title:`Gateway`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Selects how a write to this module persists. "Proxy" forwards to a downstream microservice (which owns every side-effect below itself). "Mongo" makes THIS gateway own the write and run every Strategy configured below.`}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Storage`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:d.storage||`mongo`,onChange:e=>f(t=>({...t,storage:e})),options:[{value:`mongo`,label:`Mongo — this gateway owns the write`},{value:`proxy`,label:`Proxy — forward to a downstream service`}]})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`File field key`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`file`,value:d.fileKey??``,onChange:e=>f(t=>({...t,fileKey:e.target.value})),className:`fg-mono-input`})]})]}),d.storage===`proxy`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Base URL env var`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`JOBS_SERVICE_URL`,value:d.baseUrlEnv??``,onChange:e=>f(t=>({...t,baseUrlEnv:e.target.value})),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Base URL (fallback)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`http://...`,value:d.baseUrl??``,onChange:e=>f(t=>({...t,baseUrl:e.target.value})),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Create path`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`/v1/jobs`,value:d.createPath??``,onChange:e=>f(t=>({...t,createPath:e.target.value})),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Update path (%s = id)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`/v1/edit/%s`,value:d.updatePath??``,onChange:e=>f(t=>({...t,updatePath:e.target.value})),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Update method`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:d.updateMethod||`PUT`,onChange:e=>f(t=>({...t,updateMethod:e})),options:[`PUT`,`POST`,`PATCH`].map(e=>({value:e,label:e}))})]})]})]})]}),(0,l.jsxs)(Z,{title:`Reference ID (Sequence)`,styles:{body:{paddingTop:8}},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.sequence,onChange:e=>P(`sequence`,e?{field:``,prefix:``,counterKey:``}:null)}),(0,l.jsxs)($,{style:{fontSize:13},children:[`Generate a "`,`{prefix}{n}`,`" reference id on create`]})]}),h.sequence&&(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Payload field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`submissionId`,value:h.sequence.field??``,onChange:e=>P(`sequence`,{...h.sequence,field:e.target.value}),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Prefix`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`sub`,value:h.sequence.prefix??``,onChange:e=>P(`sequence`,{...h.sequence,prefix:e.target.value}),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Counter key`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`submissions`,value:h.sequence.counterKey??``,onChange:e=>P(`sequence`,{...h.sequence,counterKey:e.target.value}),className:`fg-mono-input`})]})]})]}),(0,l.jsxs)(Z,{title:`Check for someone already on file`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Before a new record is saved, look for one that already matches. This is what stops the same person being added twice under slightly different details.`}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.duplicateCheck,onChange:e=>P(`duplicateCheck`,e?{stages:[],policy:`prompt`,displayFields:[],message:``}:null)}),(0,l.jsx)($,{style:{fontSize:13},children:`Check before saving a new record`})]}),h.duplicateCheck&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:6},children:[(0,l.jsx)(`b`,{children:`Checks run in order, top first, and stop at the first match.`}),` Put your most certain check first — matching an email or a phone number is near proof; matching a name alone is only a maybe, so it belongs lower down.`]}),(h.duplicateCheck.stages??[]).map((e,t)=>(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginBottom:8,alignItems:`flex-end`},children:[(0,l.jsxs)(`div`,{style:{flex:1.6},children:[(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12},children:[`Check `,t+1,` — compare these`]}),(0,l.jsx)(s.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`email, contactNumber`,value:e.fields??[],onChange:n=>F(t,{...e,fields:n})})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Counts as a match when`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:e.match??`all`,onChange:n=>F(t,{...e,match:n}),options:[{value:`any`,label:`Any one of them matches`},{value:`all`,label:`All of them match`}]})]}),(0,l.jsxs)(`div`,{style:{flex:.8},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`How sure is it?`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:e.weight??`strong`,onChange:n=>F(t,{...e,weight:n}),options:[{value:`strong`,label:`Almost certainly the same`},{value:`weak`,label:`Possibly the same`}]})]}),(0,l.jsxs)(`div`,{style:{flex:2},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`What to tell the user`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`A candidate with this email already exists — {name}, last updated {age}.`,value:e.message??``,onChange:n=>F(t,{...e,message:n.target.value})})]}),(0,l.jsx)(s.Button,{size:`small`,danger:!0,type:`text`,onClick:()=>P(`duplicateCheck`,{...h.duplicateCheck,stages:(h.duplicateCheck.stages??[]).filter((e,n)=>n!==t)}),children:`Remove`})]},t)),(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,style:{marginBottom:12},onClick:()=>P(`duplicateCheck`,{...h.duplicateCheck,stages:[...h.duplicateCheck.stages??[],{fields:[],match:`any`,weight:`strong`}]}),children:`Add another check`}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`When a match is found`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:h.duplicateCheck.policy??`prompt`,onChange:e=>P(`duplicateCheck`,{...h.duplicateCheck,policy:e}),options:[{value:`prompt`,label:`Ask, and offer to update the existing one`},{value:`block`,label:`Refuse to save, and name the existing one`}]})]}),(0,l.jsxs)(`div`,{style:{flex:1.2},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Which details identify the record`}),(0,l.jsx)(s.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`firstName, lastName, email`,value:h.duplicateCheck.displayFields??[],onChange:e=>P(`duplicateCheck`,{...h.duplicateCheck,displayFields:e})})]})]}),(0,l.jsx)(`div`,{className:`fg-field-meta-row`,style:{marginTop:10},children:(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Where to open the existing record`}),(0,l.jsx)(s.Input,{size:`small`,className:`fg-mono-input`,placeholder:`/candidate/edit/:id`,value:h.duplicateCheck.editRoute??``,onChange:e=>P(`duplicateCheck`,{...h.duplicateCheck,editRoute:e.target.value})})]})}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:6},children:[`The page that opens when someone chooses to update the record you already have. Use `,(0,l.jsx)(`b`,{children:`:id`}),` where the record's id goes. This has to be filled in — it cannot be worked out, because addresses follow no single pattern (this app uses `,(0,l.jsx)(`code`,{children:`/candidate/edit/:id`}),` but `,(0,l.jsx)(`code`,{children:`/clients/edit/:id`}),`). Left blank, the dialog still appears and simply does not navigate, rather than sending anyone to a page that does not exist.`]}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:8},children:[`In any message you can use `,(0,l.jsx)(`b`,{children:`{name}`}),` for the matched record and`,(0,l.jsxs)(`b`,{children:[` `,`{age}`]}),` for how long ago it was last touched ("about 2 months ago"). `,(0,l.jsx)(`b`,{children:`{updatedOn}`}),` gives the date instead. Only the details listed above are shown — nothing else about the record is revealed.`]})]})]}),(0,l.jsxs)(Z,{title:`Keep previous versions of an uploaded file`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Normally a new upload replaces the old one and it is gone. Turn this on and the last few are kept instead — useful when someone sends an updated CV and you may want to look back at the earlier one. Everywhere in the app still shows the newest; the older ones sit behind it.`}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.fileVersioning,onChange:e=>P(`fileVersioning`,e?{fields:[],keep:2,historyKey:``,s3Prefix:``,deleteEvicted:!1}:null)}),(0,l.jsx)($,{style:{fontSize:13},children:`Keep previous uploads`})]}),h.fileVersioning&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{style:{marginBottom:10},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`},children:`Where the older versions are kept`}),(0,l.jsxs)(s.Radio.Group,{size:`small`,value:h.fileVersioning.store===`documents`?`documents`:`record`,onChange:e=>{let t=e.target.value,n={...h.fileVersioning,store:t===`documents`?`documents`:``};t===`documents`&&(n.linkField=n.linkField||`documentIds`,n.clearRecordKeys=n.clearRecordKeys?.length?n.clearRecordKeys:(n.fields??[]).flatMap(e=>[`${e}History`,`${e}Versions`])),P(`fileVersioning`,n)},children:[(0,l.jsx)(s.Radio,{value:`documents`,children:`In Documents (recommended)`}),(0,l.jsx)(s.Radio,{value:`record`,children:`On the record itself`})]}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:6},children:[(0,l.jsx)(`b`,{children:`In Documents`}),` keeps the file and all its earlier versions in one place, the same place every other document lives. The record just points at it — so when a candidate is submitted for a job, the submission shows the very same file, and replacing it updates both at once. `,(0,l.jsx)(`b`,{children:`On the record itself`}),` is the older way: each record keeps its own copy of the history, which is why the same résumé could end up recorded several times over and the copies could disagree.`]})]}),h.fileVersioning.store===`documents`&&(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginBottom:10},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`List of attached documents is kept in`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`documentIds`,value:h.fileVersioning.linkField??``,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,linkField:e.target.value})})]}),(0,l.jsxs)(`div`,{style:{flex:1.6},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Old history fields to clear off the record`}),(0,l.jsx)(s.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`resumeHistory`,value:h.fileVersioning.clearRecordKeys??[],onChange:e=>P(`fileVersioning`,{...h.fileVersioning,clearRecordKeys:e})})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1.4},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Which uploads`}),(0,l.jsx)(s.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`resume`,value:h.fileVersioning.fields??[],onChange:e=>P(`fileVersioning`,{...h.fileVersioning,fields:e})})]}),(0,l.jsxs)(`div`,{style:{flex:.7},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`How many to keep`}),(0,l.jsx)(s.Input,{size:`small`,type:`number`,min:1,value:h.fileVersioning.keep??2,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,keep:Number(e.target.value)||1})})]}),(0,l.jsxs)(`div`,{style:{flex:1.4},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Where the files are grouped`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`candidates/{recordId}/resume`,value:h.fileVersioning.s3Prefix??``,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,s3Prefix:e.target.value})})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.fileVersioning.deleteEvicted,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,deleteEvicted:e})}),(0,l.jsx)($,{style:{fontSize:13},children:`Also delete the file once it drops off the end`})]}),(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:6},children:`Leave that switch OFF unless you are sure. With it off, an older file simply stops being shown and can still be recovered. With it on, it is deleted from storage permanently and cannot be brought back. Keeping 2 means a third upload pushes the first one off the end.`})]})]}),(0,l.jsx)(CE,{icon:(0,l.jsx)(c.DatabaseOutlined,{}),title:`Denormalizations`,description:`Copy fields from ANOTHER module's record onto this payload before insert (e.g. a submission snapshotting job title/client).`,rules:h.denormalizations??[],columns:R,onAdd:()=>w({index:null,rule:null}),onEdit:(e,t)=>w({index:e,rule:t}),onDelete:e=>P(`denormalizations`,(h.denormalizations??[]).filter((t,n)=>n!==e))}),(0,l.jsx)(CE,{icon:(0,l.jsx)(c.ApartmentOutlined,{}),title:`Array Enrichments`,description:`Enrich a payload array of ids (e.g. recruitersData) into objects carrying looked-up fields (name, email) before insert.`,rules:h.arrayEnrichments??[],columns:z,onAdd:()=>E({index:null,rule:null}),onEdit:(e,t)=>E({index:e,rule:t}),onDelete:e=>P(`arrayEnrichments`,(h.arrayEnrichments??[]).filter((t,n)=>n!==e))}),(0,l.jsx)(CE,{icon:(0,l.jsx)(c.DatabaseOutlined,{}),title:`File Field Maps`,description:`Turn an uploaded file field into a nested object (location + filename + who/when) or an array of such objects, instead of a flat S3 path string — needed for schemas like resume/passport/visa.`,rules:h.fileFieldMaps??[],columns:B,onAdd:()=>O({index:null,rule:null}),onEdit:(e,t)=>O({index:e,rule:t}),onDelete:e=>P(`fileFieldMaps`,(h.fileFieldMaps??[]).filter((t,n)=>n!==e))}),(0,l.jsxs)(Z,{title:`Sanitize Fields`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:`Trim and HTML-escape these payload fields before anything else runs — basic XSS-safety for free-text fields (e.g. firstName/lastName) that might later be embedded in an HTML activity comment or email.`}),(0,l.jsx)(s.Select,{mode:`tags`,style:{width:`100%`},placeholder:`firstName, lastName, email`,value:h.sanitizeFields??[],onChange:e=>P(`sanitizeFields`,e)})]}),(0,l.jsxs)(Z,{title:`Defaults`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:`Set a field only when the payload doesn't already carry a non-blank value — status defaults, empty arrays.`}),(0,l.jsx)(pE,{rows:gE(h.defaults),onChange:e=>P(`defaults`,_E(e)),keyPlaceholder:`internalSubmissionStatus.internalSubmissionStatusText`,valuePlaceholder:`"Under Evaluation"`})]}),(0,l.jsx)(CE,{icon:(0,l.jsx)(c.ApartmentOutlined,{}),title:`Hierarchy Expansions`,description:`Walk the reporting chain up (toward admin) or down (toward a team) from a seed user, publishing the result as {{hierarchy.<name>}} for Related Updates / Notify to use.`,rules:h.hierarchyExpands??[],columns:V,onAdd:()=>A({index:null,rule:null}),onEdit:(e,t)=>A({index:e,rule:t}),onDelete:e=>P(`hierarchyExpands`,(h.hierarchyExpands??[]).filter((t,n)=>n!==e))}),(0,l.jsx)(CE,{icon:(0,l.jsx)(c.ThunderboltOutlined,{}),title:`Related Updates`,description:`Best-effort side-effect writes to other collections after a successful insert — board state, activity logs. Combine with ForEach + a Hierarchy Expansion to seed one document per user in a chain.`,rules:h.relatedUpdates??[],columns:H,onAdd:()=>M({index:null,rule:null}),onEdit:(e,t)=>M({index:e,rule:t}),onDelete:e=>P(`relatedUpdates`,(h.relatedUpdates??[]).filter((t,n)=>n!==e))}),(0,l.jsxs)(Z,{title:`Notify`,styles:{body:{paddingTop:8}},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.notify,onChange:e=>P(`notify`,e?{action:``,subjectDefault:``,bodyDefault:``,toReportingManager:!1,toHierarchy:``}:null)}),(0,l.jsx)($,{style:{fontSize:13},children:`Send a best-effort email after a successful insert`})]}),h.notify&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Action (matched against an EmailTemplates doc)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`internalSubmit`,value:h.notify.action??``,onChange:e=>P(`notify`,{...h.notify,action:e.target.value}),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Notify entire hierarchy chain`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},allowClear:!0,placeholder:`pick a Hierarchy Expansion`,value:h.notify.toHierarchy||void 0,onChange:e=>P(`notify`,{...h.notify,toHierarchy:e??``}),options:N.map(e=>({value:e,label:e}))})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.notify.toReportingManager,onChange:e=>P(`notify`,{...h.notify,toReportingManager:e})}),(0,l.jsx)($,{style:{fontSize:13},children:`Also notify the caller's direct reporting manager`})]}),(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Default subject`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`New submission`,value:h.notify.subjectDefault??``,onChange:e=>P(`notify`,{...h.notify,subjectDefault:e.target.value})})]}),(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Default body (used when no EmailTemplates doc matches)`}),(0,l.jsx)(s.Input.TextArea,{rows:4,value:h.notify.bodyDefault??``,onChange:e=>P(`notify`,{...h.notify,bodyDefault:e.target.value}),className:`fg-mono-input`})]})]})]}),(0,l.jsxs)(Z,{title:`Cache Invalidate`,styles:{body:{paddingTop:8}},children:[(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:[`Redis key patterns (with `,`{{field}}`,` tokens) to SCAN+DEL after a successful insert.`]}),(0,l.jsx)(s.Select,{mode:`tags`,style:{width:`100%`},placeholder:`jobs:{{tenantId}}:{{businessId}}:{{businessUnitId}}:*`,value:h.cacheInvalidate??[],onChange:e=>P(`cacheInvalidate`,e)})]})]})]})}),(0,l.jsx)(vE,{open:!!C,rule:C?.rule,onClose:()=>w(null),onSave:e=>{P(`denormalizations`,C.index===null?[...h.denormalizations??[],e]:(h.denormalizations??[]).map((t,n)=>n===C.index?e:t)),w(null)}},C?`denorm-${C.index??`new`}`:`denorm-closed`),(0,l.jsx)(yE,{open:!!T,rule:T?.rule,onClose:()=>E(null),onSave:e=>{P(`arrayEnrichments`,T.index===null?[...h.arrayEnrichments??[],e]:(h.arrayEnrichments??[]).map((t,n)=>n===T.index?e:t)),E(null)}},T?`enrich-${T.index??`new`}`:`enrich-closed`),(0,l.jsx)(bE,{open:!!D,rule:D?.rule,onClose:()=>O(null),onSave:e=>{P(`fileFieldMaps`,D.index===null?[...h.fileFieldMaps??[],e]:(h.fileFieldMaps??[]).map((t,n)=>n===D.index?e:t)),O(null)}},D?`filemap-${D.index??`new`}`:`filemap-closed`),(0,l.jsx)(xE,{open:!!k,rule:k?.rule,onClose:()=>A(null),onSave:e=>{P(`hierarchyExpands`,k.index===null?[...h.hierarchyExpands??[],e]:(h.hierarchyExpands??[]).map((t,n)=>n===k.index?e:t)),A(null)}},k?`hier-${k.index??`new`}`:`hier-closed`),(0,l.jsx)(SE,{open:!!j,rule:j?.rule,hierarchyNames:N,onClose:()=>M(null),onSave:e=>{P(`relatedUpdates`,j.index===null?[...h.relatedUpdates??[],e]:(h.relatedUpdates??[]).map((t,n)=>n===j.index?e:t)),M(null)}},j?`ru-${j.index??`new`}`:`ru-closed`)]})}var{Text:EE}=s.Typography,DE=[`beforeCreate`,`afterCreate`,`beforeUpdate`,`afterUpdate`,`beforeDelete`,`afterDelete`],OE=[`sanitizeFields`,`generateSequence`,`duplicateCheck`,`copyFields`,`arrayEnrich`,`setDefaults`,`resolve`,`updateRelated`,`notify`,`invalidateCache`,`webhook`,`linkDocuments`,`captureFileUrls`,`resolveUploads`],kE={resolveUploads:{text:`Turn one submit into a list with ONE ENTRY PER UPLOADED FILE, so the actions after it can create one record per document instead of a single record holding all of them. Works for both shapes: a repeatable (Add Row) group gives one entry per row — carrying that row’s own values — and a multi-file upload field gives one entry per file. Publishes {{uploads.<as>}} (all entries), {{uploads.<as>First}} (the first, as an object) and {{uploads.<as>Rest}} (all but the first). Each entry has groupName, groupLabel, groupModule, fieldName, rowIndex, fileName, uniqueName, contentType, fileSize, s3Key, tenantId/businessId/businessUnitId, the row under "row", and the row’s own values at the top level. Leave "groups" empty for every group with an upload field. Set "heading" to "label" to use the group heading text instead of its name — note the heading changes whenever an admin renames the group, while the name does not.`,sample:{as:`docs`,groups:[],includeEmptyRows:!1,heading:`name`}},updateRelated:{text:`Update this record or another configured collection with values from the event. For uploaded files, after* workflows can read {{__uploads.<field>.fieldName|fileName|contentType|fileSize|s3Key|uniqueName}}. Add a $notEmpty condition on the upload s3Key so unrelated edits do not run it. To create one record PER FILE, run resolveUploads first, then set forEach to "uploads.<as>Rest" with insertIfMissing (an extraFilter on {{forEach.value.s3Key}} keeps a re-save from inserting duplicates). "unset" removes exact fields and "unsetPrefixes" removes a repeatable upload’s generated keys (document[0], document[1], …) in the SAME write — use it on the record being reused as the first row, and put that action LAST with Stop on error enabled so nothing is cleared when the inserts failed.`,sample:{targetModule:`documents`,matchField:`_id`,scopeTenant:!0,set:{module:`{{module}}`,moduleRefId:`{{_id}}`,fieldName:`{{__uploads.docPan.fieldName}}`,fileName:`{{__uploads.docPan.fileName}}`,contentType:`{{__uploads.docPan.contentType}}`,fileSize:`{{__uploads.docPan.fileSize}}`,s3Key:`{{__uploads.docPan.s3Key}}`,uniqueName:`{{__uploads.docPan.uniqueName}}`}}},linkDocuments:{text:`Share one record’s uploaded files with another, without making a second copy. Used so a submission shows the candidate’s résumé and paperwork, and anything uploaded during the submission appears on the candidate too. Both records get the list of document ids written onto them.`,sample:{sourceModule:`candidates`,sourceIdField:`applicantId`,targetModule:`submissions`,linkField:`documentIds`,fieldNames:[],backLink:!0}},captureFileUrls:{text:`File a document that was generated elsewhere and handed to us as a link — a formatted résumé or an attestation PDF — so it sits with every other attachment instead of being a loose field on the record.`,sample:{linkField:`documentIds`,files:[{urlField:`resumeUrl`,nameField:`resumeFileName`,fieldName:`formattedResume`,defaultName:`Formatted Resume.pdf`},{urlField:`attestationUrl`,nameField:`attestationFileName`,fieldName:`attestation`,defaultName:`Attestation.pdf`}]}}};function AE(e){return JSON.stringify(e??{},null,2)}function jE({action:e,onChange:t,onRemove:n}){let[r,i]=(0,o.useState)(()=>AE(e.config)),[a,u]=(0,o.useState)(!1);return(0,l.jsxs)(`div`,{style:{border:`1px solid #e2e8f0`,borderRadius:8,padding:10,marginTop:8},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`},children:[(0,l.jsx)(s.Select,{size:`small`,style:{width:200},showSearch:!0,value:e.type||void 0,placeholder:`action type`,options:OE.map(e=>({value:e})),onChange:n=>{let r=e.config&&Object.keys(e.config).length>0,i=kE[n]?.sample;t(r||!i?{...e,type:n}:{...e,type:n,config:i})}}),a&&(0,l.jsx)(s.Tag,{color:`red`,children:`invalid JSON`}),(0,l.jsx)(s.Button,{size:`small`,type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),style:{marginLeft:`auto`},onClick:n})]}),kE[e.type]&&(0,l.jsx)(`p`,{style:{margin:`8px 0 0`,fontSize:12,color:`#64748b`,lineHeight:1.5},children:kE[e.type].text}),(0,l.jsx)(s.Input.TextArea,{rows:Math.min(14,Math.max(3,r.split(`
17
- `).length)),value:r,className:`fg-mono-input`,style:{marginTop:8,fontSize:12},onChange:n=>{i(n.target.value);try{t({...e,config:JSON.parse(n.target.value||`{}`)}),u(!1)}catch{u(!0)}}})]})}function ME({open:e,doc:t,moduleOptions:n,onClose:r,onSave:i}){let[a,u]=(0,o.useState)(()=>({key:``,module:``,event:`afterCreate`,order:10,isActive:!0,stopOnError:!1,condition:{},actions:[],...t??{}})),[d,f]=(0,o.useState)(()=>AE(t?.condition)),[p,m]=(0,o.useState)(!1),h=(e,t)=>u(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:r,width:840,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.ApartmentOutlined,{}),` `,t?`Edit Workflow`:`New Workflow`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!a.key?.trim())return s.message.error(`Key is required`);if(!a.module?.trim())return s.message.error(`Module is required`);if(p)return s.message.error(`Condition JSON is invalid`);if(!(a.actions??[]).length)return s.message.error(`At least one action is required`);if((a.actions??[]).some(e=>!e.type))return s.message.error(`Every action needs a type`);let e={...a};delete e.id,delete e._id,i(e)},children:`Save Workflow`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)(EE,{type:`secondary`,style:{fontSize:12},children:`Key`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`jobs-create-after`,value:a.key??``,onChange:e=>h(`key`,e.target.value),className:`fg-mono-input`,disabled:!!t})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)(EE,{type:`secondary`,style:{fontSize:12},children:`Module`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},showSearch:!0,value:a.module||void 0,options:n,onChange:e=>h(`module`,e),placeholder:`jobs`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)(EE,{type:`secondary`,style:{fontSize:12},children:`Event`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:a.event,options:DE.map(e=>({value:e})),onChange:e=>h(`event`,e)})]}),(0,l.jsxs)(`div`,{style:{width:90},children:[(0,l.jsx)(EE,{type:`secondary`,style:{fontSize:12},children:`Order`}),(0,l.jsx)(s.InputNumber,{size:`small`,style:{width:`100%`},value:a.order??10,onChange:e=>h(`order`,e??10)})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:24,marginTop:12},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:a.isActive!==!1,onChange:e=>h(`isActive`,e)}),(0,l.jsx)(EE,{style:{fontSize:13},children:`Active`})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:a.stopOnError===!0,onChange:e=>h(`stopOnError`,e)}),(0,l.jsx)(s.Tooltip,{title:`Off (default): if an action fails after the record is saved, it is logged and the next action still runs — right for independent side effects like a notification and a cache clear. On: the remaining actions are skipped, for a sequence whose later steps are only safe because the earlier ones worked (creating records and THEN clearing the data they came from).`,children:(0,l.jsx)(EE,{style:{fontSize:13},children:`Stop on error`})})]})]}),(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsxs)(EE,{type:`secondary`,style:{fontSize:12},children:[`Condition (all must match the payload; empty = always run) `,p&&(0,l.jsx)(s.Tag,{color:`red`,children:`invalid JSON`})]}),(0,l.jsx)(s.Input.TextArea,{rows:2,value:d,className:`fg-mono-input`,style:{fontSize:12},onChange:e=>{f(e.target.value);try{h(`condition`,JSON.parse(e.target.value||`{}`)),m(!1)}catch{m(!0)}}})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginTop:14},children:[(0,l.jsx)(EE,{strong:!0,style:{fontSize:13},children:`Actions (run in order)`}),(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>h(`actions`,[...a.actions??[],{type:``,config:{}}]),children:`Add Action`})]}),(a.actions??[]).map((e,t)=>(0,l.jsx)(jE,{action:e,onChange:e=>h(`actions`,a.actions.map((n,r)=>r===t?e:n)),onRemove:()=>h(`actions`,a.actions.filter((e,n)=>n!==t))},t)),(0,l.jsxs)(EE,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:8},children:[`Config supports `,(0,l.jsx)(`code`,{children:`{{field.path}}`}),`, `,(0,l.jsx)(`code`,{children:`{{now}}`}),`, `,(0,l.jsx)(`code`,{children:`{{__userId}}`}),`,`,` `,(0,l.jsx)(`code`,{children:`{{__userName}}`}),`, and `,(0,l.jsx)(`code`,{children:`{{hierarchy.<name>}}`}),` from a `,(0,l.jsx)(`code`,{children:`resolve`}),` action.`]})]})})}function NE(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)(!0),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(null),[h,g]=(0,o.useState)(``),[_,v]=(0,o.useState)(0);(0,o.useEffect)(()=>{let e=!1;return n.$r(`workflows`).then(n=>{e||t(n)}).catch(t=>{e||f(t?.message||`Failed to load workflows`)}).finally(()=>{e||u(!1)}),()=>{e=!0}},[_]),(0,o.useEffect)(()=>{n.Sr().then(e=>i(hS(e).map(({value:e,label:t})=>({value:e,label:t})))).catch(()=>i([]))},[]);let y=()=>{u(!0),f(``),v(e=>e+1)};async function b(e){try{await n.li(`workflows`,e),s.message.success(`Workflow "${e.key}" saved`),m(null),y()}catch(e){s.message.error(e?.message||`Could not save workflow`)}}async function x(e){try{await n.ur(`workflows`,e),s.message.success(`Workflow "${e}" deleted`),y()}catch(e){s.message.error(e?.message||`Could not delete workflow`)}}async function S(e,t){let r={...e};delete r.id,delete r._id;try{await n.li(`workflows`,{...r,isActive:t}),y()}catch(e){s.message.error(e?.message||`Could not update workflow`)}}let C=(0,o.useMemo)(()=>e.filter(e=>!h||e.module===h),[e,h]);return(0,l.jsxs)(`div`,{className:`fg-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.ApartmentOutlined,{}),title:`Workflows`,extra:(0,l.jsxs)(s.Space,{size:8,children:[(0,l.jsx)(s.Select,{size:`small`,style:{minWidth:160},allowClear:!0,placeholder:`Filter by module`,options:r,value:h||void 0,onChange:e=>g(e??``)}),(0,l.jsx)(s.Button,{size:`small`,icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:y,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>m({doc:null}),children:`New Workflow`})]}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsxs)(EE,{type:`secondary`,style:{fontSize:13},children:[`Event-driven behavior per module — reference ids, duplicate checks, snapshots, hierarchy fan-outs, board updates, notifications, cache — executed by the platform Workflow Engine on every create/update/delete.`,(0,l.jsx)(s.Tag,{style:{marginLeft:8},children:`before*`}),` actions can block the write; `,(0,l.jsx)(s.Tag,{children:`after*`}),` actions are best-effort.`]})]}),(0,l.jsxs)(Z,{styles:{body:{paddingTop:8}},children:[d&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:d,style:{marginBottom:12}}),(0,l.jsxs)(s.Spin,{spinning:a,children:[(0,l.jsxs)(`div`,{style:{marginBottom:8},children:[(0,l.jsx)(s.Badge,{count:C.length,showZero:!0,color:`var(--color-brand)`}),` `,(0,l.jsx)(EE,{type:`secondary`,style:{fontSize:12},children:`workflows`})]}),(0,l.jsx)(s.Table,{rowKey:`key`,dataSource:C,columns:[{title:`Key`,dataIndex:`key`,key:`key`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Module`,dataIndex:`module`,key:`module`,width:130,render:e=>(0,l.jsx)(s.Tag,{color:`geekblue`,children:e})},{title:`Event`,dataIndex:`event`,key:`event`,width:130,render:e=>(0,l.jsx)(s.Tag,{color:String(e).startsWith(`before`)?`purple`:`green`,children:e})},{title:`Actions`,key:`acts`,render:(e,t)=>(0,l.jsx)(s.Space,{size:4,wrap:!0,children:(t.actions??[]).map((e,t)=>(0,l.jsx)(s.Tag,{style:{margin:0},children:e.type},t))})},{title:`Order`,dataIndex:`order`,key:`order`,width:70,align:`center`},{title:`Active`,key:`active`,width:80,align:`center`,render:(e,t)=>(0,l.jsx)(s.Switch,{size:`small`,checked:t.isActive!==!1,onChange:e=>S(t,e)})},{title:``,key:`ops`,width:90,align:`right`,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>m({doc:t})})}),(0,l.jsx)(s.Popconfirm,{title:`Delete workflow "${t.key}"?`,onConfirm:()=>x(t.key),children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],pagination:!1,size:`small`,className:`fg-table`,locale:{emptyText:(0,l.jsx)(s.Empty,{description:`No workflows configured.`,image:s.Empty.PRESENTED_IMAGE_SIMPLE})}})]})]}),(0,l.jsx)(ME,{open:!!p,doc:p?.doc,moduleOptions:r,onClose:()=>m(null),onSave:b},p?p.doc?.key??`new`:`closed`)]})}var{Text:PE}=s.Typography,FE=e=>e?._id??e?.id,IE=`masters`;function LE(){return{tenantId:localStorage.getItem(`tenantId`)||``,businessId:localStorage.getItem(`businessId`)||``,businessUnitId:localStorage.getItem(`businessUnitId`)||``}}function RE(e){return e&&typeof e==`object`?e.$oid??e.oid??e.id??``:e??``}function zE(e,t){return t.map(t=>RE(e?.[t])).find(e=>e!=null&&e!==``)??``}function BE(e,t){return[[t.tenantId,[`tid`,`tenantId`]],[t.businessId,[`bid`,`businessId`]],[t.businessUnitId,[`buid`,`businessUnitId`]]].every(([t,n])=>{if(!t)return!0;let r=String(zE(e,n));return!r||r===String(t)})}function VE(e){return Array.isArray(e?.masterFeeds)?e.masterFeeds:[]}function HE(e){return e.reduce((e,t)=>Math.max(e,Number(t?.uniqueId)||0),0)+1}function UE(e){return Array.isArray(e?.taxHistory)?e.taxHistory:[]}function WE(e){let t=e?.taxValue;if(t!=null&&t!==``)return Number(t);let n=UE(e).at(-1),r=n?.taxValue??n?.value;return r!=null&&r!==``?Number(r):void 0}function GE(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}function KE(e){let t=UE(e).at(-1);return t?.updatedAt??t?.timestamp??e?.updatedAt}function qE({open:e,record:t,onClose:r,onSaved:i}){let[a]=s.Form.useForm(),[c,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(!1),h=(0,o.useRef)(null),g=!!t;(0,o.useEffect)(()=>{e&&queueMicrotask(()=>{a.resetFields(),a.setFieldsValue({name:t?.name??void 0,taxValue:WE(t)}),f(t?.name?[{label:t.name,value:t.name}]:[])})},[e,t,a]);function _(e){if(h.current&&clearTimeout(h.current),!e||e.trim().length<2){f([]);return}m(!0),h.current=setTimeout(()=>{n.Nr(e.trim()).then(f).catch(()=>f([])).finally(()=>m(!1))},350)}async function v(){let e=await a.validateFields(),r=Number(e.taxValue),o={name:e.name,taxValue:r,taxHistory:{taxValue:r}};u(!0);try{g?await n.vi(`locations`,FE(t),o):await n.er(`locations`,o),s.message.success(g?`Tax updated`:`Location and tax created`),i()}catch(e){s.message.error(e?.message||`Could not save location and tax`)}finally{u(!1)}}return(0,l.jsx)(s.Modal,{open:e,onCancel:r,onOk:v,confirmLoading:c,destroyOnHidden:!0,title:g?`Edit Tax — ${t?.name??``}`:`New Location`,children:(0,l.jsxs)(s.Form,{form:a,layout:`vertical`,children:[(0,l.jsx)(s.Form.Item,{name:`name`,label:`Location`,rules:[{required:!0,message:`Location is required`}],tooltip:g?`Location cannot be changed once created — only the tax is editable.`:`Search and pick from the location master.`,children:(0,l.jsx)(s.Select,{showSearch:!0,disabled:g,placeholder:`Type at least 2 characters to search…`,filterOption:!1,onSearch:_,notFoundContent:p?`Searching…`:null,options:d})}),(0,l.jsx)(s.Form.Item,{name:`taxValue`,label:`Tax`,rules:[{required:!0,message:`Tax is required`},{type:`number`,min:0,max:100,message:`Tax must be between 0 and 100`}],children:(0,l.jsx)(s.InputNumber,{style:{width:`100%`},min:0,max:100,step:.01,suffix:`%`,placeholder:`8.875`,autoFocus:g})})]})})}function JE({record:e}){let t=[...UE(e)].reverse();return t.length?(0,l.jsx)(s.Space,{direction:`vertical`,size:4,style:{padding:`4px 8px`},children:t.map((e,t)=>(0,l.jsxs)(s.Space,{size:10,children:[(0,l.jsxs)(s.Tag,{color:t===0?`green`:`default`,style:{margin:0},children:[e.taxValue??e.value,`%`]}),(0,l.jsx)(PE,{type:`secondary`,style:{fontSize:12},children:GE(e.updatedAt??e.timestamp)}),t===0&&(0,l.jsx)(PE,{type:`secondary`,style:{fontSize:12},children:`(current)`})]},t))}):(0,l.jsx)(s.Empty,{image:s.Empty.PRESENTED_IMAGE_SIMPLE,description:`No tax history yet`})}function YE(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null);function p(){i(!0),n.Qr(`locations`).then(({items:e})=>t(e)).catch(e=>s.message.error(e?.message||`Could not load locations`)).finally(()=>i(!1))}(0,o.useEffect)(()=>{queueMicrotask(p)},[]);async function m(e){try{await n.lr(`locations`,e),s.message.success(`Location deleted`),p()}catch(e){s.message.error(e?.message||`Could not delete location`)}}return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsx)(Z,{title:`${e.length} location${e.length===1?``:`s`}`,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:p,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{f(null),u(!0)},children:`New location`})]}),children:(0,l.jsx)(s.Table,{rowKey:FE,columns:[{title:`Location`,dataIndex:`name`,key:`name`},{title:`Tax`,key:`taxValue`,width:100,render:(e,t)=>{let n=WE(t);return Number.isFinite(n)?(0,l.jsxs)(s.Tag,{color:`blue`,children:[n,`%`]}):`—`}},{title:`Tax updated`,key:`taxUpdatedAt`,render:(e,t)=>GE(KE(t))},{title:`Created`,key:`createdAt`,responsive:[`lg`],render:(e,t)=>GE(t?.createdAt)},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit tax`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{f(t),u(!0)}})}),(0,l.jsx)(s.Popconfirm,{title:`Delete this location?`,onConfirm:()=>m(FE(t)),children:(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})})]})}],dataSource:e,loading:r,size:`small`,pagination:!1,className:`fg-table`,expandable:{expandedRowRender:e=>(0,l.jsx)(JE,{record:e}),rowExpandable:e=>UE(e).length>0},locale:{emptyText:`No locations yet. Click "New location" to add one.`}})}),(0,l.jsx)(qE,{open:a,record:d,onClose:()=>u(!1),onSaved:()=>{u(!1),p()}})]})}function XE({open:e,record:t,onClose:r,onSaved:i}){let[a]=s.Form.useForm(),[u,d]=(0,o.useState)(!1),f=!!t,p=s.Form.useWatch(`masterName`,a),m=s.Form.useWatch(`masterFeeds`,a)??[],h=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(p??t?.masterName??``).trim().toLowerCase()),g=m.map(e=>({label:String(e?.name??``).trim()||`Status ${e?.uniqueId??``}`,value:Number(e?.uniqueId)})).filter(e=>Number.isInteger(e.value)&&e.value>0);function _(e,t){if(!t){a.setFieldValue([`masterFeeds`,e,`isInitialStatus`],!1);return}(a.getFieldValue(`masterFeeds`)??[]).forEach((t,n)=>{a.setFieldValue([`masterFeeds`,n,`isInitialStatus`],n===e)})}function v(e,t){a.setFieldValue([`masterFeeds`,e,`isTerminalStatus`],t),t&&a.setFieldValue([`masterFeeds`,e,`allowedNextStatusIds`],[])}(0,o.useEffect)(()=>{e&&queueMicrotask(()=>{a.resetFields();let e=t?.masterName??``,n=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(e).trim().toLowerCase()),r=VE(t),i=r.length?r.map(e=>({...e})):[{uniqueId:1,name:``,type:`neutral`,status:!0,isdeleted:!1}];if(n&&!i.some(e=>e?.status!==!1&&e?.isdeleted!==!0&&e?.isInitialStatus===!0)){let e=i.findIndex(e=>e?.status!==!1&&e?.isdeleted!==!0);e>=0&&(i=i.map((t,n)=>({...t,isInitialStatus:n===e,isTerminalStatus:t?.isTerminalStatus===!0,allowedNextStatusIds:Array.isArray(t?.allowedNextStatusIds)?t.allowedNextStatusIds:[]})))}a.setFieldsValue({masterName:e,schemaVersion:t?.schemaVersion??1,masterFeeds:i})})},[e,t,a]),(0,o.useEffect)(()=>{!e||!h||(Number(a.getFieldValue(`schemaVersion`))||1)<2&&a.setFieldValue(`schemaVersion`,2)},[e,h,a]);async function y(){let e=await a.validateFields(),r=LE(),o=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(e.masterName??``).trim().toLowerCase()),c=(e.masterFeeds??[]).map((e,t)=>{let n=Number(e.uniqueId)||t+1,r=o&&e.isTerminalStatus===!0,i=o&&!r?[...new Set((e.allowedNextStatusIds??[]).map(Number).filter(e=>Number.isInteger(e)&&e>0&&e!==n))]:[];return{uniqueId:n,name:String(e.name??``).trim(),type:String(e.type??``).trim(),status:e.status!==!1,...o?{isInitialStatus:e.isInitialStatus===!0,isTerminalStatus:r,allowedNextStatusIds:i}:{},isdeleted:e.isdeleted===!0}}).filter(e=>e.name);if(o){let e=c.filter(e=>e.status&&!e.isdeleted&&e.isInitialStatus);if(e.length===0){let t=c.findIndex(e=>e.status&&!e.isdeleted);t>=0&&(c[t]={...c[t],isInitialStatus:!0},e=[c[t]],a.setFieldValue([`masterFeeds`,t,`isInitialStatus`],!0))}if(e.length!==1){s.message.error(`Client Submission Status must have exactly one active Initial Status.`);return}}let l={...r,tid:r.tenantId,bid:r.businessId,buid:r.businessUnitId,schemaVersion:o?Math.max(2,Number(e.schemaVersion)||2):Number(e.schemaVersion)||1,masterName:e.masterName.trim(),masterFeeds:c};d(!0);try{f?await n.vi(IE,FE(t),l):await n.er(IE,l),s.message.success(f?`Master value updated`:`Master value created`),i()}catch(e){s.message.error(e?.message||`Could not save master value`)}finally{d(!1)}}return(0,l.jsx)(s.Modal,{open:e,onCancel:r,onOk:y,confirmLoading:u,destroyOnHidden:!0,title:f?`Edit Master Feed`:`New Master Feed`,width:1040,children:(0,l.jsxs)(s.Form,{form:a,layout:`vertical`,children:[(0,l.jsx)(s.Form.Item,{name:`masterName`,label:`Master Name`,rules:[{required:!0,message:`Master name is required`}],children:(0,l.jsx)(s.Input,{placeholder:`blacklistType`,autoFocus:!f,disabled:f})}),(0,l.jsx)(s.Form.Item,{name:`schemaVersion`,label:`Schema Version`,children:(0,l.jsx)(s.InputNumber,{min:1,style:{width:`100%`}})}),(0,l.jsx)(s.Form.List,{name:`masterFeeds`,children:(e,{add:t,remove:n})=>(0,l.jsxs)(s.Space,{direction:`vertical`,style:{width:`100%`},size:10,children:[e.map(({key:e,name:t})=>(0,l.jsxs)(s.Space,{align:`baseline`,wrap:!0,children:[(0,l.jsx)(s.Form.Item,{name:[t,`uniqueId`],label:`ID`,rules:[{required:!0,message:`ID required`}],children:(0,l.jsx)(s.InputNumber,{min:1,style:{width:90}})}),(0,l.jsx)(s.Form.Item,{name:[t,`name`],label:`Name`,rules:[{required:!0,message:`Name required`}],children:(0,l.jsx)(s.Input,{placeholder:`Dropdown label`,style:{width:280}})}),(0,l.jsx)(s.Form.Item,{name:[t,`type`],label:`Type`,children:(0,l.jsx)(s.Select,{allowClear:!0,placeholder:`Select type`,style:{width:120},options:[{label:`Positive`,value:`positive`},{label:`Neutral`,value:`neutral`},{label:`Negative`,value:`negative`}]})}),(0,l.jsx)(s.Form.Item,{name:[t,`status`],label:`Status`,initialValue:!0,children:(0,l.jsx)(s.Select,{style:{width:110},options:[{label:`Active`,value:!0},{label:`Inactive`,value:!1}]})}),(0,l.jsx)(s.Form.Item,{name:[t,`isdeleted`],label:`Deleted`,initialValue:!1,children:(0,l.jsx)(s.Select,{style:{width:110},options:[{label:`No`,value:!1},{label:`Yes`,value:!0}]})}),h&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Form.Item,{name:[t,`isInitialStatus`],label:`Initial`,initialValue:!1,tooltip:`The initial status is the only option shown before a candidate has a client submission status. Only one active initial status is allowed.`,children:(0,l.jsx)(s.Select,{style:{width:100},onChange:e=>_(t,e===!0),options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]})}),(0,l.jsx)(s.Form.Item,{name:[t,`isTerminalStatus`],label:`End Status`,initialValue:!1,tooltip:`End Status stops the configured client submission flow. Once reached, Change Status is hidden and no next statuses are allowed.`,children:(0,l.jsx)(s.Select,{style:{width:105},onChange:e=>v(t,e===!0),options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]})}),(0,l.jsx)(s.Form.Item,{noStyle:!0,shouldUpdate:(e,n)=>e?.masterFeeds?.[t]?.isTerminalStatus!==n?.masterFeeds?.[t]?.isTerminalStatus||e?.masterFeeds?.[t]?.uniqueId!==n?.masterFeeds?.[t]?.uniqueId||e?.masterFeeds!==n?.masterFeeds,children:({getFieldValue:e})=>{let n=e([`masterFeeds`,t,`isTerminalStatus`])===!0,r=Number(e([`masterFeeds`,t,`uniqueId`]));return(0,l.jsx)(s.Form.Item,{name:[t,`allowedNextStatusIds`],label:`Allowed Next Statuses`,tooltip:n?`End Status cannot move to another status.`:`Only these statuses will appear after the current status is saved.`,children:(0,l.jsx)(s.Select,{mode:`multiple`,allowClear:!0,disabled:n,placeholder:n?`End status`:`Select next statuses`,style:{minWidth:280},options:g.filter(e=>e.value!==r)})})}})]}),(0,l.jsx)(s.Tooltip,{title:`Remove row`,children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),onClick:()=>n(t)})})]},e)),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>t({uniqueId:HE(a.getFieldValue(`masterFeeds`)??[]),name:``,type:`neutral`,status:!0,isdeleted:!1,...h?{isInitialStatus:!1,isTerminalStatus:!1,allowedNextStatusIds:[]}:{}}),children:`Add feed value`})]})})]})})}function ZE(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null),[p,m]=(0,o.useState)(``);function h(){let e=LE();i(!0),n.Qr(IE,{limit:500}).then(({items:n})=>{let r=n.filter(t=>BE(t,e));t(r)}).catch(e=>s.message.error(e?.message||`Could not load master values`)).finally(()=>i(!1))}(0,o.useEffect)(()=>{queueMicrotask(h)},[]);async function g(e){try{await n.lr(IE,e),s.message.success(`Master value deleted`),h()}catch(e){s.message.error(e?.message||`Could not delete master value`)}}let _=p?e.filter(e=>String(e?.masterName??``).toLowerCase()===p.toLowerCase()):e,v=[...new Set(e.map(e=>e?.masterName).filter(Boolean))].sort((e,t)=>String(e).localeCompare(String(t))).map(e=>({label:e,value:e}));return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsx)(Z,{title:`${_.length} master${_.length===1?``:`s`}`,extra:(0,l.jsxs)(s.Space,{wrap:!0,children:[(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,placeholder:`Filter master name`,value:p||void 0,options:v,onChange:e=>m(e??``),style:{minWidth:220}}),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:h,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{f(null),u(!0)},children:`New master`})]}),children:(0,l.jsx)(s.Table,{rowKey:FE,columns:[{title:`Master Name`,dataIndex:`masterName`,key:`masterName`,width:180},{title:`Feed Values`,key:`masterFeeds`,render:(e,t)=>(0,l.jsx)(s.Space,{wrap:!0,children:VE(t).filter(e=>!e.isdeleted).map(e=>(0,l.jsx)(s.Tag,{color:e.status===!1?`default`:`blue`,children:e.name},e.uniqueId??e.name))})},{title:`Count`,key:`count`,width:90,render:(e,t)=>VE(t).filter(e=>!e.isdeleted).length},{title:`Updated`,key:`updatedAt`,responsive:[`lg`],render:(e,t)=>GE(t?.updatedAt)},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{f(t),u(!0)}})}),(0,l.jsx)(s.Popconfirm,{title:`Delete this master?`,onConfirm:()=>g(FE(t)),children:(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})})]})}],dataSource:_,loading:r,size:`small`,pagination:{pageSize:10,showSizeChanger:!0},className:`fg-table`,locale:{emptyText:`No masters yet. Click "New master" to add one.`}})}),(0,l.jsx)(XE,{open:a,record:d,onClose:()=>u(!1),onSaved:()=>{u(!1),h()}})]})}function QE(){return(0,l.jsxs)(`div`,{className:`fg-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.DatabaseOutlined,{}),title:`Master Collections`,children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(PE,{type:`secondary`,style:{fontSize:13},children:`Create, update, and delete master documents, then customize multiple dropdown values inside masterFeeds. Records are saved with the current tenant, business, business unit, and master name.`})]}),(0,l.jsx)(ZE,{}),(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.DatabaseOutlined,{}),title:`Location Tax Master`,children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(PE,{type:`secondary`,style:{fontSize:13},children:`Pick a location from the master list and set its tax. Once added, only the tax can be changed — every change is kept in a timeline with its timestamp. Expand a row to see the full tax history.`})]}),(0,l.jsx)(YE,{})]})}var{Text:$E}=s.Typography,eD={employerMsaValidityDays:365,referralMsaValidityDays:365,expiryWarningDays:30};function tD(){let[e]=s.Form.useForm(),[t,r]=(0,o.useState)(!0),[i,a]=(0,o.useState)(!1),u=async()=>{r(!0);try{let t=await n.Wr();e.setFieldsValue({...eD,...t||{}})}catch(t){s.message.error(t?.message||`Could not load PO/MSA settings`),e.setFieldsValue(eD)}finally{r(!1)}};return(0,o.useEffect)(()=>{u()},[]),(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.SettingOutlined,{}),title:`PO/MSA Validity Settings`,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:u,disabled:i,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:i,onClick:async()=>{try{let t=await e.validateFields();a(!0);let r=await n.ci(t);e.setFieldsValue({...eD,...r||t}),s.message.success(`PO/MSA validity settings saved`)}catch(e){e?.errorFields||s.message.error(e?.message||`Could not save PO/MSA settings`)}finally{a(!1)}},children:`Save`})]}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)($E,{type:`secondary`,children:`Configure how long a signed MSA remains valid. Employer/referral status is calculated from the signed MSA date plus these values; no validity period is hardcoded in the onboarding UI.`})]}),(0,l.jsx)(Z,{title:`Validity Rules`,children:(0,l.jsx)(s.Spin,{spinning:t,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,initialValues:eD,style:{maxWidth:620},children:[(0,l.jsx)(s.Form.Item,{name:`employerMsaValidityDays`,label:`Employer MSA Validity Days`,tooltip:`Number of days an employer MSA remains active from its signed date.`,rules:[{required:!0,message:`Employer MSA validity is required`}],children:(0,l.jsx)(s.InputNumber,{min:1,max:3650,precision:0,style:{width:`100%`},addonAfter:`days`})}),(0,l.jsx)(s.Form.Item,{name:`referralMsaValidityDays`,label:`Referral MSA Validity Days`,tooltip:`Number of days a referral MSA remains active from its signed date.`,rules:[{required:!0,message:`Referral MSA validity is required`}],children:(0,l.jsx)(s.InputNumber,{min:1,max:3650,precision:0,style:{width:`100%`},addonAfter:`days`})}),(0,l.jsx)(s.Form.Item,{name:`expiryWarningDays`,label:`Expiry Warning Days`,tooltip:`Reserved for upcoming-expiry indicators and notifications.`,rules:[{required:!0,message:`Expiry warning days is required`}],children:(0,l.jsx)(s.InputNumber,{min:0,max:3650,precision:0,style:{width:`100%`},addonAfter:`days`})})]})})})]})}var{Text:nD,Title:rD}=s.Typography,iD=[{value:`Dashboard`,label:`Dashboard`,icon:(0,l.jsx)(c.DashboardOutlined,{})},{value:`ClientManagement`,label:`Client Management`,icon:(0,l.jsx)(c.BankOutlined,{})},{value:`EmployerManagement`,label:`Employer / Referral`,icon:(0,l.jsx)(c.TeamOutlined,{})},{value:`Candidates`,label:`Candidates`,icon:(0,l.jsx)(c.UsergroupAddOutlined,{})},{value:`Jobs`,label:`Jobs`,icon:(0,l.jsx)(c.FileTextOutlined,{})},{value:`Submissions`,label:`Submissions`,icon:(0,l.jsx)(c.FileTextOutlined,{})},{value:`Onboarding`,label:`Onboarding`,icon:(0,l.jsx)(c.UserOutlined,{})},{value:`Assignments`,label:`Assignments`,icon:(0,l.jsx)(c.AppstoreOutlined,{})},{value:`Timesheet`,label:`Timesheet`,icon:(0,l.jsx)(c.CalendarOutlined,{})},{value:`Campaign`,label:`Campaign`,icon:(0,l.jsx)(c.TeamOutlined,{})},{value:`FileProtectOutlined`,label:`PO / MSA`,icon:(0,l.jsx)(c.FileProtectOutlined,{})},{value:`FolderOpenOutlined`,label:`Batches`,icon:(0,l.jsx)(c.FolderOpenOutlined,{})},{value:`BankOutlined`,label:`Billing / Finance`,icon:(0,l.jsx)(c.BankOutlined,{})},{value:`SettingOutlined`,label:`Settings / Admin`,icon:(0,l.jsx)(c.SettingOutlined,{})},{value:`UploadOutlined`,label:`Upload`,icon:(0,l.jsx)(c.UploadOutlined,{})},{value:`AppstoreOutlined`,label:`General Module`,icon:(0,l.jsx)(c.AppstoreOutlined,{})}];function aD({option:e}){return(0,l.jsxs)(s.Space,{size:8,children:[(0,l.jsx)(`span`,{style:{display:`inline-flex`,fontSize:16},children:e.icon}),(0,l.jsx)(`span`,{children:e.label}),(0,l.jsx)(nD,{type:`secondary`,style:{fontSize:11},children:e.value})]})}function oD(e,t){let n=localStorage.getItem(`menu`);if(n)try{let r=JSON.parse(n),i=Array.isArray(r)?r:r?.menu;if(!Array.isArray(i))return;let a=String(e??t.menu_key??``).trim().toLowerCase(),o=e=>e.map(e=>{let n=String(e?.key??``).trim().toLowerCase()===a?{...e,icon:t.icon??e.icon,label:t.menu_name??e.label,status:String(t.status??e.status??`ACTIVE`).toLowerCase()}:e;return Array.isArray(n?.children)?{...n,children:o(n.children)}:n}),s=o(i);localStorage.setItem(`menu`,JSON.stringify(Array.isArray(r)?s:{...r,menu:s})),window.dispatchEvent(new Event(`menu:updated`))}catch{}}function sD(){let[e]=s.Form.useForm(),[t,n]=(0,o.useState)([]),[r,i]=(0,o.useState)(!0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null),[p,m]=(0,o.useState)(!1);async function h(){i(!0);try{n(await Rx())}catch(e){s.message.error(e.message||`Unable to load menus`)}finally{i(!1)}}(0,o.useEffect)(()=>{h()},[]);let g=(0,o.useMemo)(()=>t.filter(e=>!d||e.menu_id!==d.menu_id).map(e=>({label:e.menu_name,value:e.menu_id})),[d,t]);function _(){f(null),e.resetFields(),e.setFieldsValue({menu_type:`MENU`,display_order:t.length+1,status:`ACTIVE`}),m(!0)}function v(t){f(t),e.setFieldsValue(t),m(!0)}async function y(e){u(!0);try{d?(await Bx(d.menu_id,e),oD(d.menu_key,e)):await zx(e),s.message.success(d?`Menu updated`:`Menu created`),m(!1),await h()}catch(e){s.message.error(e.message||`Unable to save menu`)}finally{u(!1)}}async function b(e){try{await Vx(e),s.message.success(`Menu deleted`),await h()}catch(e){s.message.error(e.message||`Unable to delete menu`)}}return(0,l.jsxs)(`section`,{className:`admin-section`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(rD,{level:4,children:`Menus`}),(0,l.jsx)(nD,{type:`secondary`,children:`Manage records in the MongoDB menus collection.`})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:_,children:`Add Menu`})]}),(0,l.jsx)(s.Table,{rowKey:`menu_id`,loading:r,columns:[{title:`Name`,dataIndex:`menu_name`},{title:`Key`,dataIndex:`menu_key`,render:e=>(0,l.jsx)(s.Tag,{children:e})},{title:`Route / API`,dataIndex:`api_url`},{title:`Icon`,dataIndex:`icon`,width:170,render:e=>(0,l.jsx)(s.Tag,{children:e||`Auto`})},{title:`Type`,dataIndex:`menu_type`,width:110},{title:`Order`,dataIndex:`display_order`,width:80},{title:`Status`,dataIndex:`status`,width:100,render:e=>(0,l.jsx)(s.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Button,{"aria-label":`Edit menu`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>v(t)}),(0,l.jsx)(s.Popconfirm,{title:`Delete menu?`,onConfirm:()=>b(t.menu_id),children:(0,l.jsx)(s.Button,{"aria-label":`Delete menu`,danger:!0,size:`small`,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],dataSource:t,size:`small`,pagination:{pageSize:10}}),(0,l.jsx)(s.Modal,{title:d?`Edit Menu`:`Add Menu`,open:p,onCancel:()=>m(!1),onOk:()=>e.submit(),confirmLoading:a,destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,onFinish:y,children:[(0,l.jsx)(s.Form.Item,{name:`menu_name`,label:`Menu name`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{})}),(0,l.jsx)(s.Form.Item,{name:`menu_key`,label:`Menu key`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`jobs`})}),(0,l.jsx)(s.Form.Item,{name:`api_url`,label:`Route / API URL`,children:(0,l.jsx)(s.Input,{placeholder:`/jobs`})}),(0,l.jsx)(s.Form.Item,{name:`component_name`,label:`Component`,children:(0,l.jsx)(s.Input,{placeholder:`Jobs`})}),(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{name:`menu_type`,label:`Type`,children:(0,l.jsx)(s.Select,{options:[{value:`MENU`},{value:`FOOTER`},{value:`CHILD`}]})}),(0,l.jsx)(s.Form.Item,{name:`parent_menu_id`,label:`Parent`,children:(0,l.jsx)(s.Select,{allowClear:!0,options:g})})]}),(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{name:`display_order`,label:`Display order`,children:(0,l.jsx)(s.InputNumber,{min:0})}),(0,l.jsx)(s.Form.Item,{name:`status`,label:`Status`,children:(0,l.jsx)(s.Select,{options:[{value:`ACTIVE`},{value:`INACTIVE`}]})})]}),(0,l.jsx)(s.Form.Item,{name:`icon`,label:`Sidebar icon`,extra:`Saved in the menus collection and used dynamically in the application sidebar.`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,placeholder:`Select sidebar icon`,optionFilterProp:`label`,options:iD.map(({value:e,label:t})=>({value:e,label:t})),optionRender:e=>{let t=e?.value??e?.data?.value,n=iD.find(e=>e.value===t);return n?(0,l.jsx)(aD,{option:n}):t}})})]})})]})}var{Content:cD,Header:lD,Sider:uD}=s.Layout,{Text:dD,Title:fD}=s.Typography;function pD(e){return String(e??``).trim().replace(/[\s_-]+/g,` `).toUpperCase()}function mD(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function hD(e){return String(e||``).trim().toLowerCase()}function gD(e){return e?.key||e?.collectionName||e?.value||``}function _D(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=gD(e);if(!t)return;let o=hD(e.key||t),s=hD(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||mD(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=hD(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:mD(t),value:t,disabled:!1}))}),n}function vD(e){return pD(e?.user_type_name??e?.userTypeName??e?.name)===`SUPER ADMIN`}function yD(e){return`${e?.first_name??e?.firstName??``} ${e?.last_name??e?.lastName??``}`.trim()||e?.username||e?.userName||e?.email||`User ${e?.user_id??e?.userId??``}`}function bD(e){return e.flatMap(e=>{let t=e.menu_id??e.menuId??e.MenuID,n=e.menu_name??e.menuName??e.MenuName??`Menu ${t??``}`,r=e.menu_key??e.menuKey??e.MenuKey??``,i=e.permissions??e.Permissions??{};return Object.entries(i).map(([e,i])=>{let a=i.permission_id??i.permissionId??i.PermissionID,o=i.permission_key??i.permissionKey??i.PermissionKey??e,s=i.value??i.Value??i.access_value??i.accessValue??i;return{key:`${r??n??t}:${a??o}`,menuId:t,menuName:n,menuKey:r,permissionId:a,permissionKey:o,accessValue:+(Number(s)===1)}})})}function xD(e){return String(e.menuKey??e.menuName??e.menuId).trim().toLowerCase()}var SD=[{permissionId:null,permissionKey:`sendApprove`,permissionName:`Send Approve`}];function CD(e){let t=Array.isArray(e)?e:e?.permissions??e?.actions??e?.data??e,n=(Array.isArray(t)?t:Object.values(t??{})).map(e=>({permissionId:e.permission_id??e.permissionId??e.legacyPermissionId??e.id??null,permissionKey:e.permission_key??e.permissionKey??e.key,permissionName:e.permission_name??e.permissionName??e.name??e.label})).filter(e=>e.permissionKey),r=new Set(n.map(e=>String(e.permissionKey).trim().toLowerCase()));return SD.forEach(e=>{r.has(e.permissionKey.toLowerCase())||n.push(e)}),n}function wD(e={}){return String(e.permissionName??``).trim()||String(e.permissionKey??``).replaceAll(`_`,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/\b\w/g,e=>e.toUpperCase())}function TD({title:e,description:t,selectedName:n,loading:r,saving:i,rows:a,onChange:o,onMove:u,onSave:d}){let f=Object.values(a.reduce((e,t)=>{let n=xD(t);return e[n]||(e[n]={key:n,menuName:t.menuName,menuKey:t.menuKey,permissions:[]}),e[n].permissions.push(t),e},{}));return(0,l.jsxs)(`section`,{className:`admin-editor`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(fD,{level:4,children:e}),(0,l.jsx)(dD,{type:`secondary`,children:n||t})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:i,disabled:!n||a.length===0,onClick:d,children:`Save`})]}),r?(0,l.jsx)(`div`,{className:`admin-loading`,children:(0,l.jsx)(s.Spin,{})}):f.length?(0,l.jsx)(s.Table,{size:`small`,rowKey:`key`,columns:[{title:`Menu`,dataIndex:`menuName`,width:220,render:(e,t)=>(0,l.jsxs)(`div`,{className:`admin-menu-order-cell`,children:[(0,l.jsxs)(`div`,{className:`admin-menu-cell`,children:[(0,l.jsx)(`span`,{children:e}),(0,l.jsx)(dD,{type:`secondary`,children:t.menuKey})]}),(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Button,{size:`small`,type:`text`,icon:(0,l.jsx)(c.ArrowUpOutlined,{}),onClick:()=>u(t.key,-1),"aria-label":`Move ${e} up`}),(0,l.jsx)(s.Button,{size:`small`,type:`text`,icon:(0,l.jsx)(c.ArrowDownOutlined,{}),onClick:()=>u(t.key,1),"aria-label":`Move ${e} down`})]})]})},{title:`Actions`,dataIndex:`permissions`,render:e=>(0,l.jsx)(`div`,{className:`admin-permission-controls`,children:e.filter(e=>Kx(e.menuName??e.menuKey,e.permissionKey)).map(e=>(0,l.jsx)(`label`,{className:`admin-permission-control`,children:(0,l.jsx)(s.Checkbox,{checked:e.accessValue===1,onChange:t=>o(e.key,+!!t.target.checked),"aria-label":`${e.menuName} ${e.permissionKey}`,children:wD(e)})},e.key))})}],dataSource:f,pagination:!1,scroll:{y:420}}):(0,l.jsx)(s.Empty,{description:`Select a record to customize permissions`})]})}function ED({onLogout:e}){let[r]=s.Form.useForm(),[i]=s.Form.useForm(),[a,u]=(0,o.useState)(`users`),[d,f]=(0,o.useState)(!0),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)(0),[x,S]=(0,o.useState)(1),[C,w]=(0,o.useState)(10),[T,E]=(0,o.useState)(``),[D,O]=(0,o.useState)(!1),[k,A]=(0,o.useState)([]),[j,M]=(0,o.useState)([]),[N,P]=(0,o.useState)([]),[F,I]=(0,o.useState)(null),[L,R]=(0,o.useState)([]),[z,B]=(0,o.useState)(!1),[V,H]=(0,o.useState)(null),[ee,U]=(0,o.useState)(!1),[te,ne]=(0,o.useState)(null),[re,ie]=(0,o.useState)([]),[ae,W]=(0,o.useState)(!1),[oe,se]=(0,o.useState)(!1),[ce,le]=(0,o.useState)(null),[ue,de]=(0,o.useState)(!1),[G,fe]=(0,o.useState)(null),[pe,me]=(0,o.useState)(`listView`),[he,ge]=(0,o.useState)([]),[_e,ve]=(0,o.useState)([]),[ye,be]=(0,o.useState)(!1),[xe,K]=(0,o.useState)(!1),q=t.d(),Se=(0,o.useMemo)(()=>he.filter(e=>!e.disabled),[he]),Ce=!ye&&Se.length===0,we=(0,o.useCallback)(async()=>{be(!0);try{let[e,t]=await Promise.all([n.kr(),n.xr()]),r=_D(e.modules,t),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));ge(r),ve(e=>e.filter(e=>i.has(e)))}catch{s.message.error(`Failed to load seed status`)}finally{be(!1)}},[]);(0,o.useEffect)(()=>{we()},[we]);async function Te(){if(_e.length===0){s.message.warning(Ce?`All modules already seeded.`:`Select at least one module to seed.`);return}K(!0);try{await n.di(_e),s.message.success(`User type field config seeded`),ve([]),await we()}catch(e){s.message.error(e?.message||`Seed failed`)}finally{K(!1)}}async function Ee(){f(!0);try{let[e,t,n]=await Promise.allSettled([Px(),Rx(),Hx()]),r=e.status===`fulfilled`?e.value:[];e.status===`rejected`&&s.message.error(e.reason?.message||`Unable to load user types`),A(r??[]),M(t.status===`fulfilled`?t.value??[]:[]),P(n.status===`fulfilled`?CD(n.value):[]),I((r??[])[0]?.user_type_id??null)}catch(e){s.message.error(e.message||`Unable to load admin data`)}finally{f(!1)}}(0,o.useEffect)(()=>{queueMicrotask(()=>{Ee()})},[]);let De=(0,o.useCallback)(async()=>{O(!0);try{let{users:e,total:t}=await kx({limit:C,offset:(x-1)*C,search:T});v(e??[]),b(t??0)}catch(e){s.message.error(e?.message||`Unable to load users`),v([]),b(0)}finally{O(!1)}},[x,C,T]);(0,o.useEffect)(()=>{De()},[De]),(0,o.useEffect)(()=>{queueMicrotask(()=>{if(!F){R([]);return}m(!0),console.log(`DEBUG requesting role permissions for selectedUserTypeId=`,F,`localStorage scope=`,{tenantId:localStorage.getItem(`tenantId`),businessId:localStorage.getItem(`businessId`),businessUnitId:localStorage.getItem(`businessUnitId`)}),Ux(F).then(e=>{console.log(`DEBUG raw groups from /get-role-details`,e);let t=bD(e??[]);console.log(`DEBUG savedRows (jobs only)`,t.filter(e=>xD(e)===`jobs`||xD(e)===`job`));let n=new Map(t.map(e=>[`${xD(e)}:${String(e.permissionKey).toLowerCase()}`,e.accessValue]));console.log(`DEBUG savedAccess keys`,[...n.keys()]),console.log(`DEBUG menus (jobs only)`,j.filter(e=>String(e.menu_key??e.menu_name??e.menu_id).trim().toLowerCase()===`jobs`));let r=j.flatMap(e=>N.map(t=>{let r=String(e.menu_key??e.menu_name??e.menu_id).trim().toLowerCase(),i=String(t.permissionKey).toLowerCase();return{key:`${e.menu_key??e.menu_name??e.menu_id}:${t.permissionId??t.permissionKey}`,menuId:e.menu_id,menuName:e.menu_name,menuKey:e.menu_key,permissionId:t.permissionId,permissionKey:t.permissionKey,accessValue:n.get(`${r}:${i}`)??0}}));console.log(`DEBUG final rows (jobs only)`,r.filter(e=>xD(e)===`jobs`||xD(e)===`job`)),R(r)}).catch(e=>s.message.error(e.message||`Unable to load role permissions`)).finally(()=>m(!1))})},[F,j,N]);let Oe=(0,o.useMemo)(()=>k.find(e=>e.user_type_id===F),[F,k]),ke=(0,o.useMemo)(()=>k.reduce((e,t)=>({...e,[t.user_type_id]:t.user_type_name}),{}),[k]),Ae=(0,o.useMemo)(()=>_.reduce((e,t)=>({...e,[t.user_id]:yD(t)}),{}),[_]),je=(0,o.useMemo)(()=>k.filter(e=>!vD(e)),[k]),J=(0,o.useMemo)(()=>_.filter(e=>!vD({user_type_id:e.user_type_id,user_type_name:ke[e.user_type_id]})),[ke,_]);(0,o.useEffect)(()=>{if(!z){ie([]);return}let e=Number(r.getFieldValue(`user_type_id`)??0);if(!e){ie([]);return}let t=!1;return W(!0),Ax(e).then(e=>{t||ie(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{t||(s.message.error(e.message||`Unable to load reporting users`),ie([]))}).finally(()=>{t||W(!1)}),()=>{t=!0}},[V,r,z]);let Me=(0,o.useMemo)(()=>{let e=re.map(e=>({label:yD(e),value:e.user_id})),t=Number(V?.reporting_id??V?.reportingId??0);return!t||e.some(e=>Number(e.value)===t)?e:[{label:V?.reportingName??V?.reporting_name??Ae[t]??`User ${t}`,value:t},...e]},[V,re,Ae]),Ne=(0,o.useMemo)(()=>{let e=je.map(e=>({label:e.user_type_name,value:e.user_type_id}));if(!V)return e;let t=Number(V.user_type_id??0);return e.some(e=>Number(e.value)===t)?e:[{label:ke[t]??V.userType??V.roleName??(t>0?`Type ${t}`:`Unassigned`),value:t},...e]},[V,je,ke]);k.length,j.length;let Pe=[{key:`form-groups`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.AppstoreAddOutlined,{}),` Form Groups`]}),title:`Form Groups`,description:`Build module add and edit form groups with validations, dropdowns, and custom forms.`,component:(0,l.jsx)(ow,{})},{key:`detail-groups`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.BgColorsOutlined,{}),` Detail Groups`]}),title:`Detail Groups`,description:`Control detail-view labels, rendering, lookups, merged fields, and display defaults.`,component:(0,l.jsx)(Vw,{})},{key:`actions`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ThunderboltOutlined,{}),` Actions`]}),title:`Actions`,description:`Manage row action buttons and their visibility rules from one workspace.`,component:(0,l.jsx)(AT,{})},{key:`templates`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.MailOutlined,{}),` Templates`]}),title:`Templates`,description:`Manage reusable email templates and signatures.`,component:(0,l.jsx)(HT,{})},{key:`ai-services`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ThunderboltOutlined,{}),` AI Services`]}),title:`AI Services`,description:`Register the AI and automation services used by admin-configured AI actions.`,component:(0,l.jsx)(KT,{})},{key:`bgc-integration`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.SafetyCertificateOutlined,{}),` Integrations`]}),title:`Integrations`,description:`Manage manual and API integrations used across application workflows.`,component:(0,l.jsx)(QT,{})},{key:`automations`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ApartmentOutlined,{}),` Automations`]}),title:`Automations`,description:`Reference ids, duplicate checks, cross-module snapshots, reporting-chain hierarchy expansion, board updates, notifications, and cache invalidation — per module, config-driven.`,component:(0,l.jsx)(TE,{})},{key:`workflows`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ApartmentOutlined,{}),` Workflows`]}),title:`Workflows`,description:`Event-driven behavior per module (beforeCreate/afterCreate/…): the metadata the platform Workflow Engine executes — where the jobs, candidates, and submissions create flows live.`,component:(0,l.jsx)(NE,{})},{key:`po-msa-settings`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.SafetyCertificateOutlined,{}),` PO/MSA Settings`]}),title:`PO/MSA Settings`,description:`Configure employer and referral MSA validity and expiry warning days.`,component:(0,l.jsx)(tD,{})},{key:`masters`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.AppstoreAddOutlined,{}),` Masters`]}),title:`Masters`,description:`Shared Location and Tax lists used across modules (e.g. the submission form’s W2 employer section).`,component:(0,l.jsx)(QE,{})}],Fe=[{key:`users`,icon:(0,l.jsx)(c.UserOutlined,{}),label:`Users`},{key:`roles`,icon:(0,l.jsx)(c.TeamOutlined,{}),label:`User Types`},{key:`menus`,icon:(0,l.jsx)(c.MenuOutlined,{}),label:`Menus`},{key:`configurations`,icon:(0,l.jsx)(c.AppstoreAddOutlined,{}),label:`Configurations`},{key:`integrations`,icon:(0,l.jsx)(c.SafetyCertificateOutlined,{}),label:`Integrations`}];function Ie(e,t){R(n=>{let r=n.filter(t=>t.key===e).length;return console.log(`DEBUG updateRolePermission`,{key:e,value:t,matchCount:r}),n.map(n=>n.key===e?{...n,accessValue:t}:n)})}async function Le(){g(!0);try{console.log(`DEBUG saveRolePermissions jobs rows`,L.filter(e=>xD(e)===`jobs`||xD(e)===`job`)),await Wx(F,L.map(e=>({menu_id:e.menuId,menu_name:e.menuName,menu_key:e.menuKey,permission_id:e.permissionId,permission_key:e.permissionKey,access_value:e.accessValue,updated_by:q?.userId??null}))),s.message.success(`Role permissions updated`)}catch(e){s.message.error(e.message||`Unable to save role permissions`)}finally{g(!1)}}function Re(){H(null),r.resetFields(),r.setFieldsValue({status:`ACTIVE`,user_type_id:je[0]?.user_type_id,reporting_id:0}),B(!0)}function ze(e){H(e),r.setFieldsValue({first_name:e.first_name,last_name:e.last_name,username:e.username,email:e.email,mobile:e.mobile,user_type_id:e.user_type_id,reporting_id:e.reporting_id??e.reportingId??0,profile_image:e.profile_image,status:e.status}),B(!0)}async function Be(e){U(!0);try{let t={...e,status:e.status===1||e.status===`1`||e.status===!0?`ACTIVE`:e.status===0||e.status===`0`||e.status===!1?`INACTIVE`:String(e.status??`ACTIVE`).toUpperCase(),updated_by:q?.userId??null,created_by:q?.userId??null};t.password||delete t.password,V?(await Mx(V.user_id,t),s.message.success(`User updated`)):(await jx(t),s.message.success(`User created`)),B(!1),H(null),await De()}catch(e){s.message.error(e.message||`Unable to save user`)}finally{U(!1)}}async function Y(e){ne(e);try{await Nx(e),s.message.success(`User deleted`),await De()}catch(e){s.message.error(e.message||`Unable to delete user`)}finally{ne(null)}}function Ve(e,t){me(`listView`),fe({kind:e,record:t}),e===`role`&&I(t.user_type_id)}function He(e,t){R(n=>{let r=[...new Set(n.map(xD))],i=r.indexOf(e),a=i+t;if(i<0||a<0||a>=r.length)return n;[r[i],r[a]]=[r[a],r[i]];let o=new Map(r.map((e,t)=>[e,t]));return[...n].sort((e,t)=>o.get(xD(e))-o.get(xD(t)))})}function Ue(){le(null),i.resetFields(),i.setFieldsValue({status:`ACTIVE`}),se(!0)}function X(e){le(e),se(!0),i.setFieldsValue(e)}async function We(e){de(!0);try{let t=q?.userId??null,n=!!ce,r=n?await Ix(ce.user_type_id,{...e,updated_by:t}):await Fx({...e,created_by:t,visible_menu_ids:[]}),i=r.user_type_id;s.message.success(n?`User type updated`:`User type created. Customize its menus and permissions.`),se(!1),await Ee(),I(i),n||(me(`permissions`),fe({kind:`role`,record:{...e,...r,user_type_id:i,user_type_name:r.user_type_name??e.user_type_name}}))}catch(e){s.message.error(e.message||`Unable to save role`)}finally{de(!1)}}async function Ge(e){try{await Lx(e),s.message.success(`Role deleted`),await Ee()}catch(e){s.message.error(e.message||`Unable to delete role`)}}return(0,l.jsxs)(s.Layout,{className:`admin-shell`,children:[(0,l.jsx)(uD,{width:248,className:`admin-sider`,children:(0,l.jsxs)(`div`,{className:`admin-sidebar-nav`,children:[(0,l.jsx)(dD,{className:`admin-sidebar-title`,children:`Admin Menu`}),(0,l.jsx)(s.Menu,{theme:`dark`,mode:`inline`,selectedKeys:[a],onClick:({key:e})=>u(e),items:Fe})]})}),(0,l.jsx)(s.Layout,{children:(0,l.jsxs)(cD,{className:`admin-content`,children:[(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(s.Tabs,{activeKey:a,onChange:u,tabBarStyle:{display:`none`},items:[{key:`users`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.UserOutlined,{}),` Users`]}),children:(0,l.jsx)(`div`,{className:`admin-stack`,children:(0,l.jsxs)(`section`,{className:`admin-section`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(fD,{level:4,children:`Users`}),(0,l.jsx)(dD,{type:`secondary`,children:`Create and manage users with non-super-admin user types.`})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:Re,children:`Add`})]}),(0,l.jsx)($m,{listName:`Users`,loading:D,fields:[{label:`Name`,value:`first_name`,render:(e,t)=>`${e??``} ${t.last_name??``}`.trim()||t.username},{label:`Email`,value:`email`},{label:`User Type`,value:`user_type_id`,width:160,render:(e,t)=>ke[e]||t?.userType||t?.user_type||(Number(e)>0?`Type ${e}`:`—`)},{label:`Reporting Manager`,value:`reporting_id`,width:180,render:(e,t)=>Ae[e]||t?.reportingName||t?.reporting_name||(Number(e)>0?`User ${e}`:`None`)},{label:`Status`,value:`status`,width:110,sorter:!1,render:e=>(0,l.jsx)(s.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{label:`Actions`,value:`_actions`,width:150,sorter:!1,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Button,{"aria-label":`Edit user`,icon:(0,l.jsx)(c.EditOutlined,{}),size:`small`,onClick:()=>ze(t)}),(0,l.jsx)(s.Popconfirm,{title:`Delete user?`,description:`This removes the user from the auth database.`,okText:`Delete`,okButtonProps:{danger:!0},onConfirm:()=>Y(t.user_id),children:(0,l.jsx)(s.Button,{danger:!0,"aria-label":`Delete user`,icon:(0,l.jsx)(c.DeleteOutlined,{}),loading:te===t.user_id,size:`small`})})]})}],dataSource:J.map(e=>({...e,key:e.user_id})),total:y,current:x,pageSize:C,onPageChange:S,onPageSizeChange:e=>{w(e),S(1)},onSearch:e=>{E(e??``),S(1)},rowSelection:!1})]})})},{key:`roles`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.TeamOutlined,{}),` User Types`]}),children:(0,l.jsxs)(`div`,{className:`admin-stack`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,l.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,l.jsx)(s.Select,{mode:`multiple`,allowClear:!0,showSearch:!0,value:_e,options:he,placeholder:Ce?`All modules already seeded`:`Select modules or collections to seed`,disabled:ye||xe||Ce,loading:ye,onChange:ve,style:{width:`100%`}})}),(0,l.jsx)(s.Button,{type:`primary`,loading:xe,disabled:ye||_e.length===0,onClick:Te,children:`Seed Field Config`})]}),(0,l.jsx)(dD,{type:`secondary`,style:{display:`block`,marginTop:8,fontSize:12},children:Ce?`Seed is disabled because all configured modules already have user type field config data.`:`Already seeded modules are disabled. New modules or collections can still be seeded.`})]}),(0,l.jsxs)(`section`,{className:`admin-section`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(fD,{level:4,children:`User Types`}),(0,l.jsx)(dD,{type:`secondary`,children:`Role level permissions are inherited by users.`})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:Ue,children:`Add Role`})]}),(0,l.jsx)($m,{listName:`User Types`,loading:d,fields:[{label:`User Type`,value:`user_type_name`},{label:`Description`,value:`description`},{label:`Status`,value:`status`,width:110,sorter:!1,render:e=>(0,l.jsx)(s.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{label:`Actions`,value:`_actions`,width:260,sorter:!1,render:(e,t)=>{let n=Number(t.role_type)===1;return(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Button,{"aria-label":`Configure role`,size:`small`,onClick:()=>Ve(`role`,t),children:`Config`}),(0,l.jsx)(s.Button,{"aria-label":`Edit role`,disabled:!n,icon:(0,l.jsx)(c.EditOutlined,{}),size:`small`,onClick:()=>X(t)}),n&&!vD(t)&&(0,l.jsx)(s.Popconfirm,{title:`Delete role?`,onConfirm:()=>Ge(t.user_type_id),children:(0,l.jsx)(s.Button,{"aria-label":`Delete role`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),size:`small`})})]})}}],dataSource:k.map(e=>({...e,key:e.user_type_id,roleId:e.user_type_id,roleName:e.user_type_name})),total:k.length,rowSelection:!1})]})]})},{key:`menus`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.MenuOutlined,{}),` Menus`]}),children:(0,l.jsx)(sD,{})},{key:`configurations`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.AppstoreAddOutlined,{}),` Configurations`]}),children:(0,l.jsxs)(`section`,{className:`admin-section admin-config-workspace`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(fD,{level:4,children:`Configuration Center`}),(0,l.jsx)(dD,{type:`secondary`,children:`CORE-THEME admin modules embedded into the admin dashboard.`})]}),(0,l.jsxs)(s.Tag,{color:`blue`,children:[Pe.length,` configurations`]})]}),(0,l.jsx)(s.Tabs,{className:`admin-config-tabs`,defaultActiveKey:`form-groups`,tabPosition:`left`,items:Pe.map(e=>({key:e.key,label:e.label,children:(0,l.jsxs)(`div`,{className:`admin-config-panel`,children:[(0,l.jsx)(`div`,{className:`admin-config-panel-head`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(fD,{level:4,children:e.title}),(0,l.jsx)(dD,{type:`secondary`,children:e.description})]})}),(0,l.jsx)(`div`,{className:`admin-config-panel-body`,children:e.component})]})}))})]})},{key:`integrations`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.SafetyCertificateOutlined,{}),` Integrations`]}),children:(0,l.jsxs)(`section`,{className:`admin-section admin-config-workspace`,children:[(0,l.jsx)(`div`,{className:`admin-section-head`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(fD,{level:4,children:`Integrations`}),(0,l.jsx)(dD,{type:`secondary`,children:`Configure external services used by onboarding and other workflows.`})]})}),(0,l.jsx)(`div`,{className:`admin-config-panel`,children:(0,l.jsx)(`div`,{className:`admin-config-panel-body`,children:(0,l.jsx)(s.Tabs,{defaultActiveKey:`facebook-courses`,items:[{key:`facebook-courses`,label:`Facebook Form → Course Mapping`,children:(0,l.jsx)(dE,{})},{key:`service-integrations`,label:`Other Integrations`,children:(0,l.jsx)(QT,{})}]})})})]})}]})}),(0,l.jsxs)(s.Modal,{className:`uss-modal`,title:`Configure User Type: ${G?.record?.user_type_name??``}`,open:!!G,onCancel:()=>fe(null),footer:null,destroyOnHidden:!0,width:900,children:[(0,l.jsx)(`div`,{className:`uss-config-toggle`,style:{marginBottom:12},children:[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`},{key:`actions`,label:`Actions`}].map(e=>(0,l.jsx)(`button`,{type:`button`,className:`uss-config-btn${pe===e.key?` active`:``}`,onClick:()=>me(e.key),children:e.label},e.key))}),G&&pe===`permissions`?(0,l.jsx)(TD,{title:`Role Permissions`,description:`Configure menu permissions for this user type`,selectedName:Oe?.user_type_name,loading:p,saving:h,rows:L,onChange:Ie,onMove:He,onSave:Le}):G&&pe===`actions`?(0,l.jsx)(OS,{role:{...G.record,roleId:G.record.user_type_id,roleName:G.record.user_type_name}},`${G.record?.user_type_id}-actions`):G&&pe===`form`?(0,l.jsx)(bS,{role:{...G.record,roleId:G.record.user_type_id,roleName:G.record.user_type_name}},`${G.record?.user_type_id}-form`):G?(0,l.jsx)(lS,{role:{...G.record,roleId:G.record.user_type_id,roleName:G.record.user_type_name},configType:pe},`${G.record?.user_type_id}-${pe}`):null]}),(0,l.jsx)(s.Modal,{className:`admin-role-modal`,title:ce?`Edit User Type`:`Create User Type`,open:oe,onCancel:()=>se(!1),onOk:()=>i.submit(),okText:ce?`Save`:`Next`,confirmLoading:ue,destroyOnHidden:!0,width:900,children:(0,l.jsxs)(s.Form,{form:i,layout:`vertical`,onFinish:We,children:[(0,l.jsx)(s.Form.Item,{name:`user_type_name`,label:`Role name`,rules:[{required:!0,message:`Role name is required`}],children:(0,l.jsx)(s.Input,{placeholder:`Recruiter`})}),(0,l.jsx)(s.Form.Item,{name:`description`,label:`Description`,children:(0,l.jsx)(s.Input.TextArea,{rows:3})}),(0,l.jsx)(s.Form.Item,{name:`status`,label:`Status`,children:(0,l.jsx)(s.Select,{options:[{value:`ACTIVE`},{value:`INACTIVE`}]})})]})}),(0,l.jsx)(s.Modal,{className:`admin-user-modal`,title:V?`Edit User`:`Add User`,open:z,onCancel:()=>B(!1),onOk:()=>r.submit(),confirmLoading:ee,destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:r,layout:`vertical`,requiredMark:!1,onFinish:Be,children:[(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{label:`First Name`,name:`first_name`,rules:[{required:!0,message:`First name is required`}],children:(0,l.jsx)(s.Input,{placeholder:`John`})}),(0,l.jsx)(s.Form.Item,{label:`Last Name`,name:`last_name`,children:(0,l.jsx)(s.Input,{placeholder:`Doe`})})]}),(0,l.jsx)(s.Form.Item,{label:`Username`,name:`username`,rules:[{required:!0,message:`Username is required`}],children:(0,l.jsx)(s.Input,{placeholder:`john.doe`})}),(0,l.jsx)(s.Form.Item,{label:`Email`,name:`email`,rules:[{required:!0,message:`Email is required`},{type:`email`,message:`Enter a valid email`}],children:(0,l.jsx)(s.Input,{placeholder:`john@example.com`})}),(0,l.jsx)(s.Form.Item,{label:`Password`,name:`password`,rules:V?[]:[{required:!0,message:`Password is required`}],children:(0,l.jsx)(s.Input.Password,{placeholder:V?`Leave empty to keep current password`:`Password`})}),(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{label:`Mobile`,name:`mobile`,children:(0,l.jsx)(s.Input,{placeholder:`9999999999`})}),(0,l.jsx)(s.Form.Item,{label:`User Type`,name:`user_type_id`,rules:[{required:!0,message:`User type is required`}],children:(0,l.jsx)(s.Select,{placeholder:`Select user type`,onChange:()=>{ie([]),queueMicrotask(()=>{let e=Number(r.getFieldValue(`user_type_id`)??0);e&&(W(!0),Ax(e).then(e=>{ie(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{s.message.error(e.message||`Unable to load reporting users`),ie([])}).finally(()=>{W(!1)}))})},options:Ne})})]}),(0,l.jsx)(s.Form.Item,{label:`Reporting Manager`,name:`reporting_id`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,loading:ae,placeholder:`Select reporting manager`,optionFilterProp:`label`,options:[{label:`None`,value:0},...Me]})}),(0,l.jsx)(s.Form.Item,{label:`Profile Image`,name:`profile_image`,children:(0,l.jsx)(s.Input,{placeholder:`https://...`})}),(0,l.jsx)(s.Form.Item,{label:`Status`,name:`status`,children:(0,l.jsx)(s.Select,{options:[{label:`ACTIVE`,value:`ACTIVE`},{label:`INACTIVE`,value:`INACTIVE`}]})})]})})]})})]})}var DD=ED;function OD(e,t){return String(e||t).replace(/\/\*$/,``).replace(/\/+$/,``)||t}function kD({loginPath:e=`/login`,adminPath:t=`/admin`,fallbackPath:n=`/`}){let r=(0,d.useNavigate)(),i=OD(e,`/login`),a=OD(t,`/admin`),o=`${a}/*`;return(0,l.jsxs)(d.Routes,{children:[(0,l.jsx)(d.Route,{path:i,element:(0,l.jsx)(Fb,{defaultRedirectPath:a,onLogin:()=>r(a,{replace:!0})})}),(0,l.jsx)(d.Route,{path:o,element:(0,l.jsx)(Db,{loginPath:i,children:(0,l.jsx)(Pb,{children:(0,l.jsx)(DD,{onLogout:()=>r(i,{replace:!0})})})})}),(0,l.jsx)(d.Route,{path:n,element:(0,l.jsx)(d.Navigate,{to:a,replace:!0})}),(0,l.jsx)(d.Route,{path:`*`,element:(0,l.jsx)(d.Navigate,{to:a,replace:!0})})]})}function AD(e){return(0,l.jsx)(d.BrowserRouter,{children:(0,l.jsx)(kD,{...e})})}function jD(e){return Array.isArray(e)?e.map(String).map(e=>e.trim()).filter(Boolean):String(e??``).split(`,`).map(e=>e.trim()).filter(Boolean)}function MD(e){return jD(e).every(e=>/^[^,\s@]+@[^,\s@]+\.[^\s@]{2,}$/.test(e))}var{Text:ND}=s.Typography,PD=new Set([`file`,`document`,`attachment`]);function FD(e){return PD.has(String(e?.type??``).trim().toLowerCase())}function ID(e){return String(e??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``)}function LD(e){return e?typeof e==`string`?e:String(typeof e==`object`?e?._id??e?.id??e?.$oid??``:e):``}function RD(e,t,n){if(!e)return``;let r=ID(t),i=ID(n);if(!r||r===i||r.replace(/s$/,``)===i.replace(/s$/,``))return LD(e?._id??e?.id);let a=r.replace(/s$/,``),o=[`${a}Id`,`${r}Id`,a,r,`${a}._id`,`${r}._id`];for(let t of o){let n=LD(UD(e,t));if(n)return n}return``}async function zD(e){let t=e?.fileUrl??e?.url??e?.downloadUrl;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load attachment ${e?.fileName||``}`.trim());let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.uniqueName??`attachment`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function BD(e,t,r){if(!t)return[];let i=[];(e?.placeholders??[]).forEach(e=>{(e?.holders??[]).filter(FD).forEach(a=>{let o=RD(t,e?.moduleName,r);o&&i.push((async()=>{let t=await n.yn(e.moduleName,o,a.value);return Promise.all((t?.data??[]).map(zD))})())})});let a=(await Promise.all(i)).flat().filter(Boolean),o=new Set;return a.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!o.has(t)&&(o.add(t),!0)})}function VD(e,t){return[...new Set([...jD(e),...jD(t)])].join(`, `)}function HD(e=[],t=[]){let n=new Set;return[...e,...t].filter(e=>{if(!e)return!1;let t=`${e.name}:${e.size}:${e.type}`;return!n.has(t)&&(n.add(t),!0)})}function UD(e,t,n=``){let r=String(n??``).trim().toLowerCase();return String(t??``).split(`.`).reduce((e,t)=>{let n=e;return Array.isArray(n)&&r===`last`&&(n=n.at(-1)),n?.[t]},e)}function WD(e,t,n){if(!n)return String(e??``);let r=new Map;return(t??[]).forEach(e=>(e.holders??[]).forEach(e=>{r.set(e.key,FD(e)?``:UD(n,e.value,e.arrayMode))})),String(e??``).replace(/{{\.?([\w.]+)}}/g,(e,t)=>{let n=r.get(t);return n==null?e:String(n)})}function GD({value:e,onChange:t,defaultTemplateId:r=``,ready:i=!0,title:a=`Mail`,hint:u,bccHint:d,afterBcc:f,beforeFields:p,className:m=``,contextRecords:h=[],moduleName:g=``}){let _=(0,o.useRef)(``),v=n=>t?.({...e,...n});async function y(t,n=!1){if(t)try{let r=await Zw(t),i=h[0],a=await BD(r,i,g);v({to:VD(e.to,(r?.toMail??[]).map(e=>WD(e,r?.placeholders,i))),cc:VD(e.cc,(r?.ccMail??[]).map(e=>WD(e,r?.placeholders,i))),bcc:VD(e.bcc,(r?.bccMail??[]).map(e=>WD(e,r?.placeholders,i))),subject:WD(r?.subject,r?.placeholders,i),contents:WD(r?.body,r?.placeholders,i),attachments:HD(e.attachments,a)}),n||s.message.success(`Loaded ${r?.name||`email template`}`)}catch(e){n||s.message.error(e?.message||`Could not load email template`)}}return(0,o.useEffect)(()=>{!i||!r||_.current===r||(_.current=r,y(r,!0))},[r,i]),(0,l.jsxs)(`div`,{className:`common-mail-composer ${m}`.trim(),children:[(0,l.jsx)(`div`,{className:`mail-popup__header`,children:(0,l.jsxs)(`div`,{className:`mail-popup__header-brand`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,l.jsx)(c.MailOutlined,{})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`span`,{className:`dynamic-popup__header-label`,children:a}),u&&(0,l.jsx)(ND,{type:`secondary`,className:`mail-popup__header-hint`,children:u})]})]})}),(0,l.jsxs)(`div`,{className:`mail-popup__body`,children:[p&&(0,l.jsxs)(l.Fragment,{children:[p,(0,l.jsx)(s.Divider,{})]}),(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(ND,{type:`secondary`,className:`mail-popup__field-label`,children:`To`}),(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:jD(e.to),onChange:e=>v({to:e.join(`, `)}),variant:`borderless`,className:`mail-popup__recipient-select`,placeholder:`Add email addresses`}),(0,l.jsxs)(`div`,{className:`mail-popup__cc-bcc-actions`,children:[!e.showCc&&(0,l.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>v({showCc:!0}),children:`Cc`}),!e.showBcc&&(0,l.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>v({showBcc:!0}),children:`Bcc`})]})]}),(0,l.jsx)(s.Divider,{}),e.showCc&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(ND,{type:`secondary`,className:`mail-popup__field-label`,children:`Cc`}),(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:jD(e.cc),onChange:e=>v({cc:e.join(`, `)}),variant:`borderless`,className:`mail-popup__recipient-select`})]}),(0,l.jsx)(s.Divider,{})]}),e.showBcc&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(ND,{type:`secondary`,className:`mail-popup__field-label`,children:`Bcc`}),(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:jD(e.bcc),onChange:e=>v({bcc:e.join(`, `)}),variant:`borderless`,className:`mail-popup__recipient-select`,placeholder:d})]}),f,(0,l.jsx)(s.Divider,{})]}),(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(ND,{type:`secondary`,className:`mail-popup__field-label`,children:`Subject`}),(0,l.jsx)(s.Input,{variant:`borderless`,value:e.subject,onChange:e=>v({subject:e.target.value}),placeholder:`Enter subject`,className:`mail-popup__field-input`})]}),(0,l.jsx)(s.Divider,{}),!!e.attachments?.length&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(ND,{type:`secondary`,className:`mail-popup__field-label`,children:`Attachments`}),(0,l.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6,padding:`4px 0`},children:e.attachments.map((e,t)=>(0,l.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,l.jsx)(c.PaperClipOutlined,{}),e.name]},`${e.name}:${e.size}:${t}`))})]}),(0,l.jsx)(s.Divider,{})]}),(0,l.jsxs)(`div`,{className:`mail-popup__message-section`,children:[(0,l.jsx)(ND,{type:`secondary`,className:`mail-popup__message-label`,children:`Message`}),(0,l.jsx)(n.On,{value:e.contents,onChange:e=>v({contents:e})})]})]})]})}var{Text:KD}=s.Typography,qD=/^[a-fA-F0-9]{24}$/,JD=new Set([`file`,`document`,`attachment`]);function YD(e){return e?typeof e==`object`?YD(e.$oid??e._id??e.id??e.oid):String(e).trim():``}async function XD(e){let t=e?.fileUrl??e?.url??e?.downloadUrl;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load attachment ${e?.fileName||``}`.trim());let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.uniqueName??`attachment`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function ZD(e,t,r=[]){let i=String(e??``);if(!i||!r.length||!t)return{contents:i,attachments:[]};let a=(await n.Hr(t).catch(()=>[])).filter(e=>JD.has(String(e?.type??``).trim().toLowerCase())).filter(e=>{let t=String(e?.value??e?.field??e?.fieldKey??e?.key??e?.name??``).replace(/^\./,``);return t&&(i.includes(`{{.${t}}}`)||i.includes(`{{${t}}}`))});if(!a.length)return{contents:i,attachments:[]};let o=[];for(let e of a){let a=String(e?.value??e?.field??e?.fieldKey??e?.key??e?.name??``).replace(/^\./,``);i=i.replaceAll(`{{.${a}}}`,``).replaceAll(`{{${a}}}`,``);for(let e of r){let r=String(e?._id??e?.id??``);if(!qD.test(r))continue;let i=await n.yn(t,r,a).catch(()=>({data:[]})),s=await Promise.all((i?.data??[]).map(XD));o.push(...s.filter(Boolean))}}let s=new Set,c=o.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!s.has(t)&&(s.add(t),!0)});return{contents:i,attachments:c}}function QD(e){return e===!0?!0:typeof e==`number`?e===1:typeof e==`string`&&[`true`,`1`,`yes`,`y`,`on`].includes(e.trim().toLowerCase())}function $D(e){return[`candidate`,`candidates`].includes(String(e??``).trim().toLowerCase())}function eO(e,...t){for(let n of t){let t=String(n).split(`.`).reduce((e,t)=>e?.[t],e);if(t!=null&&String(t).trim()!==``)return t}}function tO(e){return[eO(e,`jobReferenceId`,`clientJobId`,`jobCode`,`reqId`,`jobId`),eO(e,`jobTitle`,`title`,`name`)].filter(Boolean).join(` - `)||String(eO(e,`_id`,`id`)??`Job`)}function nO(e){let t=eO(e,`_id`,`id`,`jobId`);return t?{value:String(t),label:tO(e),raw:e}:null}function rO(e=[],t=[]){let n=[...t,`email`,`candidateEmail`,`candidate_email`,`emailId`,`mailId`,`alternateEmail`,`altEmail`,`basicDetails.email`,`basicDetails.alternateEmail`,`basicDetails.altEmail`,`candidate.email`,`candidate.emailId`,`submission.email`,`submission.candidateEmail`].filter(Boolean);return e.flatMap(e=>n.map(t=>eO(e,t))).flatMap(e=>Array.isArray(e)?e:[e]).flatMap(jD)}function iO(e){return e?.data?.record??e?.record??e?.data??e}function aO(e){let t=eO(e,`jobId`,`job_id`,`job._id`,`job.id`,`jobs._id`,`jobs.id`);return typeof t==`object`?eO(t,`_id`,`id`,`$oid`):t}function oO(e={}){return{subject:e.subject??e.Subject??``,contents:e.contents??e.Contents??e.body??e.Body??``,toMail:e.toMail??e.ToMail??[],ccMail:e.ccMail??e.CcMail??[],bccMail:e.bccMail??e.BccMail??[]}}function sO(){let e=(0,d.useNavigate)(),{state:t={}}=(0,d.useLocation)(),{selectedIds:r=[],selectedRecords:i=[],recipients:a=[],subject:c=``,contents:u=``,attachments:f=[],onSend:p,moduleName:m=``,popupAction:h={}}=t,g=String(t.mailTarget??``).toLowerCase()===`lead`||String(m??``).trim().toLowerCase()===`lead`,_=g?YD(t.leadId??i[0]?.leadId??i[0]?._id??i[0]?.id??r[0]):``,v=!g&&(QD(h.requireJobId)||QD(t.requireJobId)||$D(m)),y=(0,o.useMemo)(()=>[h.recipientField,h.recipientPath,t.recipientField,t.recipientPath],[h.recipientField,h.recipientPath,t.recipientField,t.recipientPath]),b=r.join(`|`),x=(0,o.useMemo)(()=>[...a,...rO(i,y)],[a,i,y]),S=g?``:String(t.jobId??aO(i[0])??``).trim(),C=g?``:r[0]??i[0]?._id??i[0]?.id??``,[w,T]=(0,o.useState)(S),[E,D]=(0,o.useState)(v?S:String(S||C||``)),[O,k]=(0,o.useState)({to:[...new Set(x)].join(`, `),cc:``,bcc:``,subject:c,contents:u,attachments:f,showCc:!1,showBcc:!1}),[A,j]=(0,o.useState)(!E),[M,N]=(0,o.useState)(!1),[P,F]=(0,o.useState)([]),[I,L]=(0,o.useState)(!1),[R,z]=(0,o.useState)(!1),B=(0,o.useRef)(!1),V=(0,o.useRef)(``),H=(0,o.useRef)(0);(0,o.useEffect)(()=>{if(!$D(m)||B.current||jD(O.to).length>0||r.length===0||V.current===b)return;let e=!1;return V.current=b,Promise.all(r.map(e=>n.hn(m,e).catch(()=>null))).then(t=>{if(e)return;let n=rO(t.map(iO).filter(Boolean),y);n.length&&k(e=>jD(e.to).length>0?e:{...e,to:[...new Set(n)].join(`, `)})}),()=>{e=!0}},[O.to,m,y,b,r]),(0,o.useEffect)(()=>{if(!E){j(!0);return}let e=++H.current,t=!1;async function n(){j(!1),N(!0),k(e=>({...e,contents:``}));try{let n=oO(await dn(E)),r=await ZD(n.contents||``,m,i),a=r.contents;if(a.trim())try{a=await fn(a,n.subject||c)}catch(n){!t&&e===H.current&&s.message.warning(n?.message||`Mail content formatting failed. Showing original content.`)}if(t||e!==H.current)return;k(e=>({...e,subject:n.subject||e.subject,to:n.toMail?.length?Array.isArray(n.toMail)?n.toMail.join(`, `):String(n.toMail):e.to,cc:n.ccMail?.length?Array.isArray(n.ccMail)?n.ccMail.join(`, `):String(n.ccMail):e.cc,bcc:n.bccMail?.length?Array.isArray(n.bccMail)?n.bccMail.join(`, `):String(n.bccMail):e.bcc,contents:a||r.contents||e.contents,attachments:r.attachments,showCc:e.showCc||!!n.ccMail?.length,showBcc:e.showBcc||!!n.bccMail?.length}))}catch(n){!t&&e===H.current&&v&&s.message.error(n?.message||`Could not load mail template for this Job ID`)}finally{!t&&e===H.current&&(j(!0),N(!1))}}return n(),()=>{t=!0}},[E,v]);function ee(e=w){let t=String(e??``).trim();if(!qD.test(t)){D(``),t&&s.message.warning(`Enter a valid 24-character Job ID`);return}if(t===E){D(``),queueMicrotask(()=>D(t));return}D(t)}function U(e,t){if(!e){D(``),T(``);return}let n=t?.label??``;T(String(n||(e??``))),ee(e)}function te(e){let t=String(e??``).trim();if(T(t),t.length<3){F([]);return}L(!0),ie(t).then(e=>{let t=(Array.isArray(e)?e:[]).map(nO).filter(Boolean);F(t)}).catch(e=>s.message.error(e?.message||`Unable to search jobs`)).finally(()=>L(!1))}let ne=A&&(!v||qD.test(E))&&(!g||qD.test(_))&&jD(O.to).length+jD(O.cc).length+jD(O.bcc).length>0&&MD(O.to)&&MD(O.cc)&&MD(O.bcc)&&O.subject.trim()&&O.contents.trim();async function re(){if(!(!ne||R)){z(!0);try{await pn({jobId:E,leadId:_,toMail:jD(O.to),ccMail:jD(O.cc),bccMail:jD(O.bcc),subject:O.subject,contents:O.contents,attachments:O.attachments??[]}),s.message.success(`Mail sent successfully`),typeof p==`function`&&p({...O,message:O.contents,selectedIds:r}),e(-1)}catch(e){s.message.error(e?.message||`Failed to send mail`)}finally{z(!1)}}}function ae(e){e?.to!==O.to&&(B.current=!0),k(e)}return(0,l.jsx)(s.Drawer,{open:!0,placement:`right`,onClose:()=>e(-1),closable:!1,rootClassName:`mail-popup`,width:620,maskClosable:!1,footer:(0,l.jsxs)(`div`,{className:`mail-popup__footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>e(-1),children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:R,disabled:!ne,onClick:re,children:`Send`})]}),children:(0,l.jsx)(s.Spin,{spinning:M,tip:`Loading mail content...`,size:`large`,children:(0,l.jsx)(GD,{value:O,onChange:ae,moduleName:m,defaultTemplateId:v?``:h.defaultTemplateId??t.defaultTemplateId??``,ready:A,contextRecords:i,beforeFields:v?(0,l.jsxs)(`div`,{className:`mail-popup__job-row`,children:[(0,l.jsx)(KD,{type:`secondary`,className:`mail-popup__field-label`,children:`Job Title / ID`}),(0,l.jsx)(s.Select,{showSearch:!0,allowClear:!0,filterOption:!1,value:E||void 0,searchValue:w,onSearch:te,onChange:U,onClear:()=>{D(``),T(``),F([])},placeholder:`Minimum 3 characters`,notFoundContent:I||M?(0,l.jsx)(s.Spin,{size:`small`}):null,options:P,className:`mail-popup__job-input`})]}):null})})})}var{Text:cO}=s.Typography,lO=2,uO=`overview.summary.role summary.job summary.role overview.job description.description.about the role.about the job.job title.role.responsibilities.roles responsibilities.roles and responsibilities.roles & responsibilities.key responsibilities.requirements.required skills.preferred skills.technical skills.key skills.skills.competencies.nice to have.good to have.qualifications.required qualifications.preferred qualifications.education.experience.benefits`.split(`.`),dO=new Set(uO),fO=/(education|qualification)/i,pO=/(skill|competenc)/i,mO=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),hO=e=>e.replace(/\w[^\s/]*/g,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()),gO=e=>[...new Set(e)];function _O(e){let t=String(e);return t=t.replace(/<\s*(br|\/p|\/div|\/h[1-6]|\/li|\/tr)\s*\/?>/gi,`
16
+ `}),(0,l.jsxs)(s.Form,{form:u,layout:`vertical`,initialValues:MT,disabled:h,className:`template-editor-form`,children:[(0,l.jsxs)(`div`,{className:`template-editor-grid`,children:[(0,l.jsx)(s.Form.Item,{name:`name`,label:`Template name`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`Candidate introduction`})}),(0,l.jsx)(s.Form.Item,{name:`module`,label:`Module`,rules:[{required:!0}],children:(0,l.jsx)(s.Select,{showSearch:!0,optionFilterProp:`label`,options:r,onChange:e=>{u.setFieldValue(`action`,``),C(e)}})}),(0,l.jsx)(s.Form.Item,{name:`action`,label:`Action`,rules:[{required:!0}],tooltip:`Pick a Row Action, or TYPE a system action key. Not every email comes from a row action — the credentials mail sent when an employer's recruiters are provisioned uses "accountCreated", which is raised by a workflow and so never appears in this list.`,children:(0,l.jsx)(s.Select,{showSearch:!0,mode:`tags`,maxCount:1,optionFilterProp:`label`,options:_,placeholder:`Select a row action, or type a system key (e.g. accountCreated)`})}),(0,l.jsx)(s.Form.Item,{name:`clientId`,label:`Client scope (optional)`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,options:i,placeholder:`Available to every client`})})]}),(0,l.jsx)(s.Form.Item,{name:`description`,label:`Description`,children:(0,l.jsx)(s.Input.TextArea,{rows:2})}),(0,l.jsxs)(`div`,{className:`template-editor-grid template-editor-grid--three`,children:[(0,l.jsx)(s.Form.Item,{name:`toMail`,label:`Default To`,children:(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`]})}),(0,l.jsx)(s.Form.Item,{name:`ccMail`,label:`Default Cc`,children:(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`]})}),(0,l.jsx)(s.Form.Item,{name:`bccMail`,label:`Default Bcc`,children:(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`]})})]}),(0,l.jsxs)(`div`,{className:`template-editor-workspace`,style:{display:`grid`,gridTemplateColumns:`minmax(0, 1.2fr) minmax(360px, 0.8fr)`,gap:20,alignItems:`start`,marginTop:4},children:[(0,l.jsxs)(`div`,{className:`template-editor-compose-pane`,style:{minWidth:0,padding:16,border:`1px solid #e5e7eb`,borderRadius:10,background:`#fff`},children:[(0,l.jsx)(jT,{strong:!0,style:{display:`block`,marginBottom:12},children:`Email content`}),(0,l.jsx)(s.Form.Item,{name:`subject`,label:`Subject`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`Email subject — drag placeholders here`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`copy`}})}),(0,l.jsx)(s.Form.Item,{label:`Message`,required:!0,style:{marginBottom:0},children:(0,l.jsx)(`div`,{onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`copy`},style:{minHeight:320},children:(0,l.jsx)(n.On,{value:d,onChange:f,placeholder:`Write the reusable email body… Drag placeholders from the right panel.`})})})]}),(0,l.jsxs)(`div`,{className:`template-placeholder-panel`,style:{position:`sticky`,top:0,maxHeight:`calc(100vh - 190px)`,overflowY:`auto`,padding:16,border:`1px solid #dbeafe`,borderRadius:10,background:`#f8fbff`},children:[(0,l.jsx)(jT,{strong:!0,style:{display:`block`},children:`All module placeholders`}),(0,l.jsx)(jT,{type:`secondary`,style:{display:`block`,marginTop:4},children:`Drag a placeholder into Subject or Message. You can also click a placeholder to append it to the message.`}),A.map(e=>(0,l.jsxs)(`div`,{style:{marginTop:14},children:[(0,l.jsx)(jT,{type:`secondary`,strong:!0,children:e.label||e.moduleName}),(0,l.jsx)(`div`,{className:`template-placeholder-list`,style:{marginTop:6},children:e.fields.map(t=>(0,l.jsx)(s.Tooltip,{title:`${t.label||t.key} · ${t.value}`,children:(0,l.jsx)(s.Tag,{color:`blue`,draggable:!0,onDragStart:e=>D(e,t),onClick:()=>E(t),style:{cursor:`grab`,userSelect:`none`,marginBottom:6},children:`{{.${t.key}}}`})},`${e.moduleName}:${t.key}:${t.value}`))})]},e.moduleName)),!A.length&&(0,l.jsx)(s.Empty,{image:s.Empty.PRESENTED_IMAGE_SIMPLE,description:`No module fields available`})]})]}),(0,l.jsx)(s.Form.Item,{name:`isActive`,label:`Available in mail composer`,valuePropName:`checked`,style:{marginTop:16},children:(0,l.jsx)(s.Switch,{})})]})]})}function zT(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(1),[h,g]=(0,o.useState)(20),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)([]),[x,S]=(0,o.useState)(null),[C,w]=(0,o.useState)(!1),T=(0,o.useMemo)(()=>_.map(e=>({value:e.key??e.module??e.value,label:e.label??e.name??e.key??e.module??e.value})).filter(e=>e.value),[_]);function E(e=p,n=h,r=d){u(!0),Gw({offset:(e-1)*n,limit:n,search:r}).then(({items:e,totalCount:n})=>{t(e),i(n)}).catch(e=>s.message.error(e?.message||`Could not load templates`)).finally(()=>u(!1))}(0,o.useEffect)(()=>{queueMicrotask(()=>{E(1,h,``)})},[]),(0,o.useEffect)(()=>{Promise.all([n.Sr(),n.mr({limit:200})]).then(([e,t])=>{v(hS(e).map(({value:e,label:t})=>({key:e,label:t}))),b(t)}).catch(()=>{})},[]);async function D(e,n){let r=NT(e);try{await Jw(r,{...e,isActive:n}),t(e=>e.map(e=>NT(e)===r?{...e,isActive:n}:e))}catch(e){s.message.error(e?.message||`Could not update status`)}}async function O(e){try{await Yw(e),s.message.success(`Template deleted`),E(1),m(1)}catch(e){s.message.error(e?.message||`Could not delete template`)}}let k=[{title:`Template`,key:`template`,width:300,ellipsis:!0,render:(e,t)=>(0,l.jsxs)(`div`,{className:`admin-config-primary-cell templates-primary-cell`,children:[(0,l.jsx)(jT,{strong:!0,ellipsis:{tooltip:t.name},children:t.name}),(0,l.jsx)(jT,{type:`secondary`,ellipsis:{tooltip:t.description||t.subject},children:t.description||t.subject||`No description`})]})},{title:`Module`,dataIndex:`module`,key:`module`,width:140,ellipsis:!0,responsive:[`sm`],render:e=>e?(0,l.jsx)(s.Tag,{color:`blue`,children:e}):`—`},{title:`Action`,dataIndex:`action`,key:`action`,width:180,ellipsis:!0,responsive:[`md`],render:e=>e?(0,l.jsx)(jT,{code:!0,ellipsis:{tooltip:e},children:e}):`—`},{title:`Recipients`,key:`recipients`,width:130,responsive:[`lg`],render:(e,t)=>`${(t.toMail?.length??0)+(t.ccMail?.length??0)+(t.bccMail?.length??0)} defaults`},{title:`Active`,dataIndex:`isActive`,key:`active`,width:80,render:(e,t)=>(0,l.jsx)(s.Switch,{size:`small`,checked:e,onChange:e=>D(t,e)})},{title:``,key:`actions`,width:84,fixed:`right`,render:(e,t)=>(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{S(NT(t)),w(!0)}})}),(0,l.jsx)(s.Popconfirm,{title:`Delete this template?`,onConfirm:()=>O(NT(t)),children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],A=y.map(e=>({value:e._id??e.id,label:e.clientName??e.name??e._id})).filter(e=>e.value);return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.MailOutlined,{}),title:`Email templates`,extra:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{S(null),w(!0)},children:`New template`}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(jT,{type:`secondary`,children:`Create reusable, module-aware email content. Modules, actions and placeholders are read from DB configuration.`})]}),(0,l.jsxs)(Z,{title:`${r} template${r===1?``:`s`}`,extra:(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:()=>E(),children:`Reload`}),children:[(0,l.jsx)(`div`,{className:`admin-config-table-tools`,children:(0,l.jsx)(s.Input,{allowClear:!0,prefix:(0,l.jsx)(c.SearchOutlined,{}),placeholder:`Search templates`,value:d,onChange:e=>{let t=e.target.value;f(t),m(1),E(1,h,t)}})}),(0,l.jsx)(`div`,{className:`templates-table-viewport`,children:(0,l.jsx)(s.Table,{rowKey:NT,columns:k,dataSource:e,loading:a,className:`fg-table`,size:`small`,tableLayout:`fixed`,sticky:!0,scroll:{x:914,y:`calc(100vh - 410px)`},pagination:{current:p,pageSize:h,total:r,showSizeChanger:!0,responsive:!0,onChange:(e,t)=>{m(e),g(t),E(e,t)}}})})]}),(0,l.jsx)(RT,{open:C,templateId:x,modules:T,clients:A,onClose:()=>w(!1),onSaved:()=>{w(!1),E()}})]})}function BT({open:e,signatureId:t,onClose:r,onSaved:i}){let[a,c]=(0,o.useState)(``),[u,d]=(0,o.useState)(``),[f,p]=(0,o.useState)({module:`userSignature`,keys:[]}),[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(!e)return;let n=!1;return queueMicrotask(()=>{_(!0),Promise.all([t?eT(t):Promise.resolve(null),Qw()]).then(([e,t])=>{n||(c(e?.signatureName??``),d(e?.signature??``),p(t??{module:`userSignature`,keys:[]}))}).catch(()=>{n||s.message.error(`Could not load signature details`)}).finally(()=>{n||_(!1)})}),()=>{n=!0}},[e,t]);function v(e){let t=`{{.${e.key}}}`;d(e=>`${e}${e?` `:``}${t}`)}async function y(){if(!a.trim())return s.message.error(`Signature name is required`);if(!u.trim())return s.message.error(`Signature content is required`);h(!0);try{let e=LT(u),n=(f.keys??[]).filter(t=>e.has(t.key)).map(e=>({key:e.key,value:e.value})),r={signatureId:t,signatureName:a,signature:u,signatureLogoPath:``,placeHolder:n.length?[{moduleName:f.module||`userSignature`,holders:n}]:[]};t?await nT(r):await tT(r),s.message.success(t?`Signature updated`:`Signature created`),i()}catch(e){s.message.error(e?.message||`Could not save signature`)}finally{h(!1)}}let b=(f.keys??[]).filter(e=>![`Role_id`,`Role_name`,`Reporting_manager`].includes(e.key)),x=(f.keys??[]).filter(e=>[`Role_id`,`Role_name`,`Reporting_manager`].includes(e.key)),S=e=>(0,l.jsx)(`div`,{className:`template-placeholder-list`,children:e.map(e=>(0,l.jsx)(s.Tooltip,{title:`Mongo field: ${e.value}`,children:(0,l.jsx)(s.Tag,{color:`blue`,style:{cursor:`pointer`},onClick:()=>v(e),children:`{{.${e.key}}}`})},e.key))});return(0,l.jsx)(s.Drawer,{open:e,onClose:r,width:`min(820px, 96vw)`,title:t?`Edit signature`:`New signature`,destroyOnClose:!0,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:m,onClick:y,children:t?`Update`:`Create`})]}),children:(0,l.jsxs)(s.Form,{layout:`vertical`,children:[(0,l.jsx)(s.Form.Item,{label:`Signature name`,required:!0,children:(0,l.jsx)(s.Input,{value:a,onChange:e=>c(e.target.value)})}),(0,l.jsx)(s.Form.Item,{label:`Signature content`,required:!0,children:(0,l.jsx)(n.On,{value:u,onChange:d,placeholder:`Create the reusable signature…`})}),(0,l.jsxs)(`div`,{className:`template-placeholder-panel`,children:[(0,l.jsx)(jT,{strong:!0,children:`Signature placeholders`}),(0,l.jsx)(jT,{type:`secondary`,children:`Click a placeholder to add it to the signature. Values resolve from MongoDB users and roles when mail is generated.`}),g?(0,l.jsx)(jT,{type:`secondary`,children:`Loading placeholders…`}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{style:{marginTop:10},children:[(0,l.jsx)(jT,{strong:!0,children:`User details`}),S(b)]}),(0,l.jsxs)(`div`,{style:{marginTop:10},children:[(0,l.jsx)(jT,{strong:!0,children:`Role details`}),S(x)]}),!f.keys?.length&&(0,l.jsx)(s.Empty,{image:s.Empty.PRESENTED_IMAGE_SIMPLE,description:`No signature placeholders available`})]})]})]})})}function VT(){let[e,t]=(0,o.useState)([]),[n,r]=(0,o.useState)(0),[i,a]=(0,o.useState)(!1),[u,d]=(0,o.useState)(``),[f,p]=(0,o.useState)(1),[m,h]=(0,o.useState)(20),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(null);function b(e=f,n=m,i=u){a(!0),$w({offset:(e-1)*n,limit:n,search:i}).then(({items:e,totalCount:n})=>{t(e),r(n)}).catch(()=>s.message.error(`Could not load signatures`)).finally(()=>a(!1))}(0,o.useEffect)(()=>{queueMicrotask(()=>{b(1,m,``)})},[]);async function x(e,n){try{await iT(e.signatureId,n),t(t=>t.map(t=>t.signatureId===e.signatureId?{...t,isActive:n}:t))}catch{s.message.error(`Could not update status`)}}async function S(e){try{await rT(e),s.message.success(`Signature deleted`),p(1),b(1)}catch{s.message.error(`Could not delete signature`)}}return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsx)(Z,{icon:(0,l.jsx)(c.MailOutlined,{}),title:`Signature templates`,extra:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{y(null),_(!0)},children:`New signature`}),children:(0,l.jsx)(jT,{type:`secondary`,children:`Existing company and user signatures from the shared DB.`})}),(0,l.jsxs)(Z,{title:`${n} signature${n===1?``:`s`}`,children:[(0,l.jsx)(`div`,{className:`admin-config-table-tools`,children:(0,l.jsx)(s.Input,{allowClear:!0,prefix:(0,l.jsx)(c.SearchOutlined,{}),value:u,placeholder:`Search signatures`,onChange:e=>{d(e.target.value),p(1),b(1,m,e.target.value)}})}),(0,l.jsx)(`div`,{className:`templates-table-viewport`,children:(0,l.jsx)(s.Table,{rowKey:`signatureId`,dataSource:e,columns:[{title:`Signature`,dataIndex:`templateName`,key:`name`,width:300,ellipsis:!0,render:e=>(0,l.jsx)(jT,{strong:!0,ellipsis:{tooltip:e},children:e||`Untitled signature`})},{title:`Created`,dataIndex:`createdDt`,key:`created`,width:150,responsive:[`md`],render:e=>e?new Date(e).toLocaleDateString():`—`},{title:`Active`,dataIndex:`isActive`,key:`active`,width:80,render:(e,t)=>(0,l.jsx)(s.Switch,{size:`small`,checked:e,onChange:e=>x(t,e)})},{title:``,key:`actions`,width:84,fixed:`right`,render:(e,t)=>(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{y(t.signatureId),_(!0)}}),(0,l.jsx)(s.Popconfirm,{title:`Delete this signature?`,onConfirm:()=>S(t.signatureId),children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],loading:i,className:`fg-table`,size:`small`,tableLayout:`fixed`,sticky:!0,scroll:{x:614,y:`calc(100vh - 410px)`},pagination:{current:f,pageSize:m,total:n,responsive:!0,onChange:(e,t)=>{p(e),h(t),b(e,t)}}})})]}),(0,l.jsx)(BT,{open:g,signatureId:v,onClose:()=>_(!1),onSaved:()=>{_(!1),b()}})]})}function HT(){return(0,l.jsx)(s.Tabs,{defaultActiveKey:`email`,className:`admin-config-tabs`,items:[{key:`email`,label:`Email templates`,children:(0,l.jsx)(zT,{})},{key:`signature`,label:`Signatures`,children:(0,l.jsx)(VT,{})}]})}var{Text:UT}=s.Typography,WT={serviceKey:``,label:``,baseUrl:``,authHeader:``,authValue:``,enabled:!0};function GT({open:e,service:t,onClose:r,onSaved:i}){let[a]=s.Form.useForm(),[c,u]=(0,o.useState)(!1);(0,o.useEffect)(()=>{e&&a.setFieldsValue({...WT,...t,authValue:``})},[e,t,a]);async function d(){try{let e=await a.validateFields();u(!0),await n.ti(e),s.message.success(`AI service saved`),i()}catch(e){e?.errorFields||s.message.error(e?.message||`Could not save AI service`)}finally{u(!1)}}return(0,l.jsx)(s.Drawer,{open:e,onClose:r,width:`min(560px, 96vw)`,title:t?`Edit AI service`:`New AI service`,destroyOnClose:!0,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:c,onClick:d,children:`Save`})]}),children:(0,l.jsxs)(s.Form,{form:a,layout:`vertical`,initialValues:WT,children:[(0,l.jsx)(s.Form.Item,{name:`serviceKey`,label:`Service Key`,rules:[{required:!0,message:`Service key is required`}],tooltip:`Referenced by an AI Action's Service Key on any form field (e.g. pyOps).`,children:(0,l.jsx)(s.Input,{placeholder:`pyOps`,disabled:!!t,className:`fg-mono-input`})}),(0,l.jsx)(s.Form.Item,{name:`label`,label:`Label`,children:(0,l.jsx)(s.Input,{placeholder:`Resume/JD Parsing Service`})}),(0,l.jsx)(s.Form.Item,{name:`baseUrl`,label:`Base URL`,rules:[{required:!0,message:`Base URL is required`}],children:(0,l.jsx)(s.Input,{placeholder:`https://ai.example.com`,className:`fg-mono-input`})}),(0,l.jsx)(s.Form.Item,{name:`authHeader`,label:`Auth Header (optional)`,children:(0,l.jsx)(s.Input,{placeholder:`x-api-key`,className:`fg-mono-input`})}),(0,l.jsx)(s.Form.Item,{name:`authValue`,label:`Auth Value`,tooltip:`Write-only — leave blank to keep the currently saved value.`,children:(0,l.jsx)(s.Input.Password,{placeholder:t?`Unchanged`:``})}),(0,l.jsx)(s.Form.Item,{name:`enabled`,label:`Enabled`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{})})]})})}function KT(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null);function p(){i(!0),n.gr().then(e=>t(Array.isArray(e)?e:[])).catch(e=>s.message.error(e?.message||`Could not load AI services`)).finally(()=>i(!1))}(0,o.useEffect)(()=>{queueMicrotask(()=>{p()})},[]);async function m(e,r){try{await n.ti({...e,enabled:r}),t(t=>t.map(t=>t.serviceKey===e.serviceKey?{...t,enabled:r}:t))}catch(e){s.message.error(e?.message||`Could not update AI service`)}}async function h(e){try{await n.rr(e),s.message.success(`AI service deleted`),p()}catch(e){s.message.error(e?.message||`Could not delete AI service`)}}return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.ThunderboltOutlined,{}),title:`AI Services`,extra:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{f(null),u(!0)},children:`New service`}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(UT,{type:`secondary`,children:`Register the AI/automation backends that admin-configured "AI Actions" (Generate/Parse-style buttons on any form field) call. A field's AI Action names a Service Key here — no URL is ever hardcoded in the app.`})]}),(0,l.jsx)(Z,{title:`${e.length} service${e.length===1?``:`s`}`,extra:(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:p,children:`Reload`}),children:(0,l.jsx)(s.Table,{rowKey:`serviceKey`,columns:[{title:`Service`,key:`service`,render:(e,t)=>(0,l.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,l.jsx)(UT,{strong:!0,children:t.label||t.serviceKey}),(0,l.jsx)(UT,{type:`secondary`,code:!0,children:t.serviceKey})]})},{title:`Base URL`,dataIndex:`baseUrl`,key:`baseUrl`,ellipsis:!0,render:e=>(0,l.jsx)(UT,{code:!0,ellipsis:{tooltip:e},children:e})},{title:`Auth Header`,dataIndex:`authHeader`,key:`authHeader`,width:140,render:e=>e||`—`},{title:`Enabled`,dataIndex:`enabled`,key:`enabled`,width:90,render:(e,t)=>(0,l.jsx)(s.Switch,{size:`small`,checked:e,onChange:e=>m(t,e)})},{title:``,key:`actions`,width:84,fixed:`right`,render:(e,t)=>(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{f(t),u(!0)}})}),(0,l.jsx)(s.Popconfirm,{title:`Delete this AI service?`,onConfirm:()=>h(t.serviceKey),children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],dataSource:e,loading:r,className:`fg-table`,size:`small`})}),(0,l.jsx)(GT,{open:a,service:d,onClose:()=>u(!1),onSaved:()=>{u(!1),p()}})]})}var{Text:qT}=s.Typography,JT={integrationKey:``,label:``,category:`GENERAL`,updateMethod:`MANUAL`,enabled:!0,provider:``,baseUrl:``,authType:`API_KEY`,authHeader:`x-api-key`,authValue:``,clientId:``,clientSecret:``,tokenUrl:``,createPath:``,statusPath:``,testPath:``,webhookSecret:``,targetModule:``,targetField:``,stageMatchField:``,stageMatchValue:``,stageStatusField:``,providerStatusPath:``,providerReferencePath:``,statusMappings:[{providerStatus:``,applicationStatus:``}]},YT=[{label:`API Key`,value:`API_KEY`},{label:`Bearer Token`,value:`BEARER_TOKEN`},{label:`Basic Authentication`,value:`BASIC_AUTH`},{label:`OAuth 2.0 Client Credentials`,value:`OAUTH2_CLIENT_CREDENTIALS`}];function XT(e){let t=Object.fromEntries((e.statusMappings??[]).filter(e=>e?.providerStatus&&e?.applicationStatus).map(e=>[e.providerStatus.trim(),e.applicationStatus.trim()])),n={...e,statusMapping:e.updateMethod===`API`?{targetModule:e.targetModule,targetField:e.targetField,stageMatchField:e.stageMatchField,stageMatchValue:e.stageMatchValue,stageStatusField:e.stageStatusField,providerStatusPath:e.providerStatusPath,providerReferencePath:e.providerReferencePath,values:t}:void 0};return[`statusMappings`,`targetModule`,`targetField`,`stageMatchField`,`stageMatchValue`,`stageStatusField`,`providerStatusPath`,`providerReferencePath`].forEach(e=>delete n[e]),n}function ZT({open:e,integration:t,onClose:r,onSaved:i}){let[a]=s.Form.useForm(),[u,d]=(0,o.useState)(!1),[f,p]=(0,o.useState)(!1),m=s.Form.useWatch(`updateMethod`,a),h=s.Form.useWatch(`authType`,a),g=m===`API`,_=h===`OAUTH2_CLIENT_CREDENTIALS`;(0,o.useEffect)(()=>{if(!e)return;let n=t?.statusMapping??{};a.setFieldsValue({...JT,...t,authValue:``,clientSecret:``,webhookSecret:``,targetModule:n.targetModule??``,targetField:n.targetField??``,stageMatchField:n.stageMatchField??``,stageMatchValue:n.stageMatchValue??``,stageStatusField:n.stageStatusField??``,providerStatusPath:n.providerStatusPath??``,providerReferencePath:n.providerReferencePath??``,statusMappings:Object.entries(n.values??{}).map(([e,t])=>({providerStatus:e,applicationStatus:t})).concat(Object.keys(n.values??{}).length?[]:[{providerStatus:``,applicationStatus:``}])})},[a,t,e]);async function v(){try{let e=XT(await a.validateFields());d(!0),await n.ai(e),s.message.success(`Integration saved`),i()}catch(e){e?.errorFields||s.message.error(e?.message||`Could not save integration`)}finally{d(!1)}}async function y(){try{let e=await a.validateFields([`integrationKey`,`baseUrl`,`testPath`,`authType`,`authHeader`,`authValue`,`clientId`,`clientSecret`,`tokenUrl`]);p(!0);let t=await n.fi(XT({...a.getFieldsValue(!0),...e}));s.message.success(t?.message||`Connection successful${t?.statusCode?` (${t.statusCode})`:``}`)}catch(e){e?.errorFields||s.message.error(e?.message||`Connection test failed`)}finally{p(!1)}}return(0,l.jsx)(s.Drawer,{open:e,onClose:r,width:`min(680px, 96vw)`,title:t?`Edit ${t.label}`:`Add Integration`,destroyOnClose:!0,extra:(0,l.jsxs)(s.Space,{children:[g&&(0,l.jsx)(s.Button,{loading:f,onClick:y,children:`Test Connection`}),(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:u,onClick:v,children:`Save`})]}),children:(0,l.jsxs)(s.Form,{form:a,layout:`vertical`,initialValues:JT,children:[(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`label`,label:`Integration Name`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`Background Check`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`integrationKey`,label:`Integration Key`,rules:[{required:!0},{pattern:/^[a-z][a-z0-9_-]{1,63}$/,message:`Use lowercase letters, numbers, _ or -`}],children:(0,l.jsx)(s.Input,{placeholder:`bgc`,disabled:!!t})})})]}),(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`category`,label:`Category`,children:(0,l.jsx)(s.Select,{options:[{value:`ONBOARDING`,label:`Onboarding`},{value:`HRMS`,label:`HRMS`},{value:`PAYROLL`,label:`Payroll`},{value:`ESIGNATURE`,label:`E-Signature`},{value:`VMS`,label:`VMS`},{value:`GENERAL`,label:`General / Custom`}]})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`enabled`,label:`Enabled`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{})})})]}),(0,l.jsx)(s.Form.Item,{name:`updateMethod`,label:`Update Method`,rules:[{required:!0}],children:(0,l.jsx)(s.Radio.Group,{optionType:`button`,buttonStyle:`solid`,options:[{label:`Manual Update`,value:`MANUAL`},{label:`API Integration`,value:`API`}]})}),!g&&(0,l.jsx)(s.Alert,{type:`info`,showIcon:!0,message:`This integration will use manual updates.`}),g&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Alert,{type:t?.credentialsConfigured?`success`:`warning`,showIcon:!0,message:t?.credentialsConfigured?`Credentials configured`:`Credentials required`,description:`Secrets are write-only. Leave a secret blank while editing to keep its current value.`,style:{marginBottom:16}}),(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`provider`,label:`Provider`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`Provider name`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`baseUrl`,label:`API Base URL`,rules:[{required:!0,type:`url`}],children:(0,l.jsx)(s.Input,{placeholder:`https://api.provider.com`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`createPath`,label:`Create/Submit Path`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`/v1/requests`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`statusPath`,label:`Status Path`,rules:[{required:!0}],tooltip:`Use {referenceId} as a placeholder.`,children:(0,l.jsx)(s.Input,{placeholder:`/v1/requests/{referenceId}`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`testPath`,label:`Test Connection Path`,rules:[{required:!0}],tooltip:`A safe GET endpoint used only to validate URL and credentials.`,children:(0,l.jsx)(s.Input,{placeholder:`/v1/health`})})})]}),(0,l.jsx)(s.Form.Item,{name:`authType`,label:`Authentication Type`,rules:[{required:!0}],children:(0,l.jsx)(s.Select,{options:YT})}),_?(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`clientId`,label:`Client ID`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`clientSecret`,label:`Client Secret`,children:(0,l.jsx)(s.Input.Password,{placeholder:t?.credentialsConfigured?`Unchanged`:`Required`})})}),(0,l.jsx)(s.Col,{xs:24,children:(0,l.jsx)(s.Form.Item,{name:`tokenUrl`,label:`Token URL`,rules:[{required:!0,type:`url`}],children:(0,l.jsx)(s.Input,{})})})]}):(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`authHeader`,label:`Authentication Header`,children:(0,l.jsx)(s.Input,{placeholder:`x-api-key`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`authValue`,label:`API Credential`,children:(0,l.jsx)(s.Input.Password,{placeholder:t?.credentialsConfigured?`Unchanged`:`Required`})})})]}),(0,l.jsx)(s.Form.Item,{name:`webhookSecret`,label:`Webhook Signing Secret (optional)`,children:(0,l.jsx)(s.Input.Password,{placeholder:t?.webhookConfigured?`Unchanged`:``})}),(0,l.jsxs)(Z,{title:`Status Mapping`,children:[(0,l.jsx)(qT,{type:`secondary`,children:`Map a status from the provider response into a module field or a matching workflow stage.`}),(0,l.jsxs)(s.Row,{gutter:16,style:{marginTop:16},children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`targetModule`,label:`Target Module`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`onboarding`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`targetField`,label:`Target Field`,rules:[{required:!0}],tooltip:`Use stages for a stage-array update, or a direct field name.`,children:(0,l.jsx)(s.Input,{placeholder:`stages`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`providerStatusPath`,label:`Provider Status JSON Path`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`data.status`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`providerReferencePath`,label:`Provider Reference JSON Path`,children:(0,l.jsx)(s.Input,{placeholder:`data.id`})})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsx)(s.Form.Item,{name:`stageMatchField`,label:`Stage Match Field`,children:(0,l.jsx)(s.Input,{placeholder:`stageCode`})})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsx)(s.Form.Item,{name:`stageMatchValue`,label:`Stage Match Value`,children:(0,l.jsx)(s.Input,{placeholder:`BGC`})})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsx)(s.Form.Item,{name:`stageStatusField`,label:`Stage Status Field`,children:(0,l.jsx)(s.Input,{placeholder:`status`})})})]}),(0,l.jsx)(qT,{strong:!0,children:`Status Values`}),(0,l.jsx)(s.Form.List,{name:`statusMappings`,children:(e,{add:t,remove:n})=>(0,l.jsxs)(s.Space,{direction:`vertical`,style:{width:`100%`,marginTop:8},children:[e.map(e=>(0,l.jsxs)(s.Row,{gutter:12,children:[(0,l.jsx)(s.Col,{flex:`1 1 220px`,children:(0,l.jsx)(s.Form.Item,{...e,name:[e.name,`providerStatus`],rules:[{required:!0,message:`Provider status is required`}],children:(0,l.jsx)(s.Input,{placeholder:`Provider status, e.g. completed`})})}),(0,l.jsx)(s.Col,{flex:`1 1 220px`,children:(0,l.jsx)(s.Form.Item,{...e,name:[e.name,`applicationStatus`],rules:[{required:!0,message:`Application status is required`}],children:(0,l.jsx)(s.Input,{placeholder:`Zinnext status, e.g. CLEARED`})})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{danger:!0,onClick:()=>n(e.name),children:`Remove`})})]},e.key)),(0,l.jsx)(s.Button,{type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>t({providerStatus:``,applicationStatus:``}),children:`Add Status Mapping`})]})})]})]})]})})}function QT(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null),p=(0,o.useCallback)(()=>{i(!0),n.jr().then(e=>t(Array.isArray(e)?e:[])).catch(e=>s.message.error(e?.message||`Could not load integrations`)).finally(()=>i(!1))},[]);(0,o.useEffect)(()=>{queueMicrotask(p)},[p]);async function m(e){try{await n.ar(e),s.message.success(`Integration deleted`),p()}catch(e){s.message.error(e?.message||`Could not delete integration`)}}return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.ApiOutlined,{}),title:`Integrations`,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:p,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{f(null),u(!0)},children:`Add Integration`})]}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(qT,{type:`secondary`,children:`Configure reusable manual or API integrations for onboarding, payroll, e-signature, VMS, HRMS, and custom workflows.`})]}),(0,l.jsx)(Z,{title:`${e.length} integration${e.length===1?``:`s`}`,children:(0,l.jsx)(s.Table,{rowKey:`integrationKey`,columns:[{title:`Integration`,key:`name`,render:(e,t)=>(0,l.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,l.jsx)(qT,{strong:!0,children:t.label}),(0,l.jsx)(qT,{type:`secondary`,code:!0,children:t.integrationKey})]})},{title:`Category`,dataIndex:`category`,width:130,render:e=>e||`GENERAL`},{title:`Method`,dataIndex:`updateMethod`,width:110,render:e=>(0,l.jsx)(s.Tag,{color:e===`API`?`blue`:`default`,children:e})},{title:`Provider`,dataIndex:`provider`,render:e=>e||`—`},{title:`Enabled`,dataIndex:`enabled`,width:90,render:e=>(0,l.jsx)(s.Tag,{color:e?`green`:`default`,children:e?`Yes`:`No`})},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{f(t),u(!0)}}),(0,l.jsx)(s.Popconfirm,{title:`Delete this integration?`,onConfirm:()=>m(t.integrationKey),children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],dataSource:e,loading:r,size:`small`,className:`fg-table`})}),(0,l.jsx)(ZT,{open:a,integration:d,onClose:()=>u(!1),onSaved:()=>{u(!1),p()}})]})}var $T=`${t.v}/admin/facebook`;async function eE(e,n={}){let r=t.u(),i=await fetch(`${$T}${e}`,{...n,headers:{"Content-Type":`application/json`,...t.D({"X-App-Id":String(t.y)}),...r?{Authorization:`Bearer ${r}`}:{},...n.headers||{}}}),a=await i.json().catch(()=>({}));if(!i.ok||a?.status===!1)throw Error(a?.error||a?.message||a?.reason||`HTTP ${i.status}`);return a?.data??a}var tE=()=>eE(`/forms`),nE=()=>eE(`/courses`),rE=()=>eE(`/course-mappings`),iE=(e,t=!1)=>eE(t?`/course-mappings/${encodeURIComponent(e.formId)}`:`/course-mappings`,{method:t?`PUT`:`POST`,body:JSON.stringify(e)}),aE=e=>eE(`/course-mappings/${encodeURIComponent(e)}`,{method:`DELETE`}),oE=`${t.v}/admin/facebook`;async function sE(e,n={}){let r=t.u();if(!r)throw Error(`Admin login is required`);let i=await fetch(`${oE}${e}`,{...n,headers:{"Content-Type":`application/json`,...t.D({"X-App-Id":String(t.y)}),Authorization:`Bearer ${r}`,...n.headers||{}}}),a=await i.json().catch(()=>({}));if(!i.ok||a.status===!1)throw Error(a.error||a.message||`HTTP ${i.status}`);return a.data??a}var cE=()=>sE(`/distributions`).then(e=>Array.isArray(e)?e:e.distributions||[]);async function lE(){let e=[];for(let t=1;t<=1e3;t++){let n=await sE(`/counsellors?page=${t}&limit=100`);if(!Array.isArray(n.counsellors))throw Error(`Unexpected LMS counsellors response`);if(e.push(...n.counsellors),t>=Number(n.totalPages||0)||!n.counsellors.length)return e}throw Error(`Counsellor list exceeds pagination safety limit`)}var uE=({formId:e,counsellorIds:t,isActive:n},r)=>sE(r?`/distribution/${encodeURIComponent(e)}`:`/distribution`,{method:r?`PUT`:`POST`,body:JSON.stringify({formId:e,counsellorIds:t,isActive:n})});function dE({page:e=1,limit:t=20,formId:n=``}={}){let r=new URLSearchParams({page:String(e),limit:String(t)});return n&&r.set(`formId`,n),sE(`/distribution-skips?${r}`)}function fE({status:e=`unassigned`,page:t=1,limit:n=20,formId:r=``}={}){let i=new URLSearchParams({status:e,page:String(t),limit:String(n)});return r&&i.set(`formId`,r),sE(`/unassigned-leads?${i}`)}var{Text:pE,Title:mE}=s.Typography,hE=e=>e?new Date(e).toLocaleString():`—`,gE=e=>String(e?.userId||``);function _E(e,t,n){if(t===n||t<0||n<0||t>=e.length||n>=e.length)return e;let r=[...e],[i]=r.splice(t,1);return r.splice(n,0,i),r}function vE(e,t){if(!t.length)return``;let n=(e?.counsellors||[]).map(gE).filter(Boolean),r=String(e?.nextUserId||``);if(n.length===t.length&&n.every((e,n)=>e===t[n])&&t.includes(r))return r;let i=String(e?.lastAssignedUserId||``);if(!i&&n.includes(r)&&(i=n[(n.indexOf(r)-1+n.length)%n.length]),t.includes(i))return t[(t.indexOf(i)+1)%t.length];if(n.includes(i)){let e=n.indexOf(i);for(let r=1;r<=n.length;r++){let i=n[(e+r)%n.length];if(t.includes(i))return i}}return t.includes(r)?r:t[0]}function yE({open:e,row:t,current:n,counsellors:r=[],saving:i,onClose:a,onSave:u}){let[d,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(``),[h,g]=(0,o.useState)(!0),_=(0,o.useRef)(null),[v,y]=(0,o.useState)(null);(0,o.useEffect)(()=>{e&&(f((n?.counsellors||[]).map(gE).filter(Boolean)),m(``),g(n?.isActive!==!1),y(null))},[e,t?.formId,n]);let b=(0,o.useMemo)(()=>{let e=new Map(r.map(e=>[gE(e),{...e,isActive:!0}]));return(n?.counsellors||[]).forEach(t=>{let n=gE(t);e.has(n)||e.set(n,{...t,isActive:!1})}),e},[r,n]),x=(0,o.useMemo)(()=>new Set(d),[d]),S=d.map(e=>b.get(e)).filter(Boolean),C=[...r].filter(e=>!x.has(gE(e))).sort((e,t)=>String(e.name).localeCompare(String(t.name))),w=[...S,...C].filter(e=>`${e.name||``} ${e.email||``} ${e.legacyUserId||``}`.toLowerCase().includes(p.trim().toLowerCase())),T=S.filter(e=>!e.isActive),E=S.length-T.length,D=(n?.counsellors||[]).map(gE).filter(Boolean),O=D.length!==d.length||D.some((e,t)=>e!==d[t]),k=vE(n,d),A=d.indexOf(k),j=(A<0?d:[...d.slice(A),...d.slice(0,A)]).find(e=>b.get(e)?.isActive)||``,M=b.get(String(j))?.name||`Not selected`,N=(e,t)=>f(n=>t?[...n.filter(t=>t!==e),e]:n.filter(t=>t!==e)),P=()=>{if(t?.formId){if(!d.length)return s.message.warning(`Select at least one active LMS counsellor`);if(T.length)return s.message.warning(`Remove inactive or unavailable counsellors before saving`);if(d.length>50)return s.message.warning(`Maximum 50 counsellors can be selected`);u({formId:t.formId,counsellorIds:d,isActive:h},!!n)}},F=e=>{let t=_.current;y(null),_.current=null,!(!x.has(t)||!x.has(e)||t===e)&&f(n=>_E(n,n.indexOf(t),n.indexOf(e)))};return(0,l.jsxs)(s.Modal,{open:e,onCancel:a,width:610,className:`fb-distribution-editor`,title:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(c.TeamOutlined,{style:{color:`#784ce2`}}),n?`Change Distribution`:`Set Distribution`,` `,(0,l.jsx)(s.Tag,{color:`green`,children:`Live LMS data`})]}),footer:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{onClick:a,disabled:i,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:i,onClick:P,children:n?`Update Distribution`:`Save Distribution`})]}),children:[(0,l.jsxs)(`div`,{className:`fb-dist-form-banner`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(pE,{type:`secondary`,children:`Facebook form`}),(0,l.jsx)(`div`,{children:(0,l.jsx)(pE,{strong:!0,children:t?.formName})}),(0,l.jsxs)(pE,{type:`secondary`,style:{fontSize:11},children:[`Form ID: `,t?.formId]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(pE,{type:`secondary`,children:`Mapped LMS course`}),(0,l.jsx)(`div`,{children:(0,l.jsx)(pE,{strong:!0,children:t?.courseName||`Unmapped`})})]})]}),(0,l.jsxs)(`div`,{className:`fb-dist-control-line`,children:[(0,l.jsx)(pE,{strong:!0,children:`Choose counsellors and drag to change the order`}),(0,l.jsxs)(s.Tag,{color:`purple`,children:[d.length,` selected`]})]}),(0,l.jsxs)(`div`,{className:`fb-dist-control-line`,style:{marginBottom:9},children:[(0,l.jsx)(s.Input,{allowClear:!0,value:p,prefix:(0,l.jsx)(c.SearchOutlined,{}),placeholder:`Search LMS counsellors`,onChange:e=>m(e.target.value)}),(0,l.jsx)(s.Tooltip,{title:`Pause or enable future distribution for this form`,children:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(pE,{type:`secondary`,children:`Enabled`}),(0,l.jsx)(s.Switch,{size:`small`,checked:h,onChange:g})]})})]}),(0,l.jsx)(`div`,{className:`fb-dist-draggable-list`,children:w.length===0?(0,l.jsx)(s.Empty,{description:r.length?`No matching counsellors`:`No eligible LMS counsellors returned by backend`}):w.map(e=>{let t=gE(e),n=x.has(t),r=d.indexOf(t);return(0,l.jsxs)(`div`,{className:`fb-dist-unified-row ${n?`selected`:``} ${v===t?`drag-over`:``}`,draggable:n&&e.isActive&&!i,onDragStart:e=>{_.current=t,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},onDragOver:e=>{n&&_.current&&_.current!==t&&(e.preventDefault(),y(t))},onDrop:e=>{e.preventDefault(),F(t)},onDragEnd:()=>{_.current=null,y(null)},children:[(0,l.jsx)(s.Checkbox,{checked:n,disabled:i||!e.isActive&&!n,onChange:e=>N(t,e.target.checked)}),(0,l.jsx)(`span`,{className:`fb-dist-grip ${n?``:`placeholder`}`,"aria-label":`Drag selected counsellor`,children:(0,l.jsx)(c.DragOutlined,{})}),(0,l.jsx)(`span`,{className:`fb-dist-rank`,children:n?r+1:`·`}),(0,l.jsx)(`span`,{className:`fb-dist-avatar`,children:(e.name||`?`).charAt(0).toUpperCase()}),(0,l.jsxs)(`div`,{className:`fb-dist-person-name`,children:[(0,l.jsx)(pE,{strong:n,children:e.name||`Unnamed counsellor`}),e.email&&(0,l.jsx)(pE,{type:`secondary`,style:{fontSize:11},ellipsis:!0,children:e.email})]}),(0,l.jsx)(s.Tag,{color:e.isActive?`green`:`red`,children:e.isActive?`Active`:`Inactive`}),n&&(0,l.jsxs)(s.Space,{size:0,className:`fb-dist-order-buttons`,children:[(0,l.jsx)(s.Tooltip,{title:`Move up`,children:(0,l.jsx)(s.Button,{size:`small`,type:`text`,icon:(0,l.jsx)(c.ArrowUpOutlined,{}),disabled:r<=0||i,onClick:()=>f(e=>_E(e,r,r-1))})}),(0,l.jsx)(s.Tooltip,{title:`Move down`,children:(0,l.jsx)(s.Button,{size:`small`,type:`text`,icon:(0,l.jsx)(c.ArrowDownOutlined,{}),disabled:r>=d.length-1||i,onClick:()=>f(e=>_E(e,r,r+1))})})]})]},t)})}),(0,l.jsxs)(`div`,{className:`fb-dist-next-line`,children:[(0,l.jsx)(c.CheckCircleOutlined,{}),(0,l.jsxs)(`span`,{children:[`Selected: `,(0,l.jsxs)(`strong`,{children:[E,` active`]}),` · `,O?`Next after save`:`Next in saved order`,`: `,(0,l.jsx)(`strong`,{children:M})]})]}),T.length>0&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,style:{marginTop:10},message:`An existing selected counsellor is no longer eligible`,description:`Uncheck inactive counsellors before updating this distribution.`}),(0,l.jsx)(s.Alert,{type:`info`,showIcon:!0,style:{marginTop:12},message:`Changing the order affects future leads only`,description:`After any order or membership change, assignment continues with the person following the last assigned counsellor in the updated order. If that person was removed, the backend selects the next remaining person from the previous rotation. Existing lead owners are unchanged.`})]})}function bE({rows:e=[]}){let[t,n]=(0,o.useState)(`skips`),[r,i]=(0,o.useState)(1),[a,u]=(0,o.useState)(``),[d,f]=(0,o.useState)(`unassigned`),[p,m]=(0,o.useState)(null),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)(``),[y,b]=(0,o.useState)(0);(0,o.useEffect)(()=>{let e=!0;g(!0),v(``);let n={page:r,limit:20,formId:a};return(t===`skips`?dE(n):fE({...n,status:d})).then(t=>{e&&m(t)}).catch(t=>{e&&(m(null),v(t.message))}).finally(()=>{e&&g(!1)}),()=>{e=!1}},[t,r,a,d,y]);let x=(t===`skips`?p?.skips:p?.leads)||[],S=Number(p?.total||0),C=t===`skips`?[{title:`Form`,dataIndex:`formName`,render:(e,t)=>e||t.formId},{title:`Facebook Lead ID`,dataIndex:`facebookLeadId`},{title:`Skipped counsellor`,dataIndex:`skippedCounsellorName`,render:(e,t)=>e||t.skippedCounsellorLegacyId},{title:`Reason`,dataIndex:`reason`,render:e=>(0,l.jsx)(s.Tag,{color:`orange`,children:e||`—`})},{title:`Assigned to`,dataIndex:`assignedToName`,render:(e,t)=>e||t.assignedToLegacyUserId||`—`},{title:`Clarification`,dataIndex:`clarificationStatus`,render:e=>(0,l.jsx)(s.Tag,{color:e===`pending`?`orange`:`default`,children:e||`—`})},{title:`Skipped at`,dataIndex:`skippedAt`,render:hE}]:[{title:`Form`,dataIndex:`formName`,render:(e,t)=>e||t.formId},{title:`Facebook Lead ID`,dataIndex:`facebookLeadId`},{title:`Reason`,dataIndex:`reason`,render:e=>e||`—`},{title:`Status`,dataIndex:`status`,render:e=>(0,l.jsx)(s.Tag,{color:e===`unassigned`?`orange`:`green`,children:e})},{title:`First seen`,dataIndex:`firstSeenAt`,render:hE},{title:`Resolved at`,dataIndex:`resolvedAt`,render:hE}];return(0,l.jsxs)(s.Card,{size:`small`,className:`fb-dist-monitor`,children:[(0,l.jsxs)(`div`,{className:`fb-dist-control-line`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(mE,{level:5,style:{margin:0},children:`Live Distribution Monitoring`}),(0,l.jsx)(pE,{type:`secondary`,children:`Read-only records from the LMS backend`})]}),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),loading:h,onClick:()=>b(e=>e+1),children:`Refresh`})]}),(0,l.jsxs)(s.Space,{wrap:!0,style:{margin:`12px 0`},children:[(0,l.jsx)(s.Button,{type:t===`skips`?`primary`:`default`,icon:(0,l.jsx)(c.ClockCircleOutlined,{}),onClick:()=>{n(`skips`),i(1)},children:`Skip Audit`}),(0,l.jsxs)(s.Button,{type:t===`queue`?`primary`:`default`,icon:(0,l.jsx)(c.WarningOutlined,{}),onClick:()=>{n(`queue`),i(1)},children:[`Unassigned Leads `,t===`queue`&&`(${p?.unassignedCount??0})`]}),(0,l.jsx)(s.Select,{style:{minWidth:220},value:a,onChange:e=>{u(e),i(1)},options:[{value:``,label:`All Facebook forms`},...e.map(e=>({value:e.formId,label:e.formName}))]}),t===`queue`&&(0,l.jsx)(s.Select,{style:{minWidth:145},value:d,onChange:e=>{f(e),i(1)},options:[{value:`unassigned`,label:`Unassigned`},{value:`resolved`,label:`Resolved`},{value:`all`,label:`All`}]})]}),_&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:`Could not load live monitoring data`,description:_,style:{marginBottom:12}}),t===`queue`&&!_&&(0,l.jsx)(s.Alert,{type:p?.unassignedCount?`warning`:`info`,showIcon:!0,style:{marginBottom:10},message:`${p?.unassignedCount??0} currently unassigned Facebook leads`}),(0,l.jsx)(s.Table,{size:`small`,rowKey:e=>String(e.id||`${e.facebookLeadId}-${e.formId}-${e.skippedCounsellorLegacyId||``}`),loading:h,dataSource:x,columns:C,scroll:{x:900},locale:{emptyText:`No records match these filters`},pagination:{current:r,pageSize:20,total:S,showSizeChanger:!1,onChange:i}}),(0,l.jsx)(pE,{type:`secondary`,style:{fontSize:12},children:`Skipping and unassigned events are recorded by the backend assignment worker. This screen does not create, assign or resolve leads.`})]})}function xE({configurations:e,counsellorCount:t,onRefresh:n,loading:r}){let i=e.length,a=e.filter(e=>e.isActive).length;return(0,l.jsxs)(`div`,{className:`fb-dist-summary`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(c.TeamOutlined,{style:{color:`#764ae1`}}),` `,(0,l.jsxs)(`span`,{children:[(0,l.jsx)(`small`,{children:`Saved distributions`}),(0,l.jsx)(`strong`,{children:i})]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(c.CheckCircleOutlined,{style:{color:`#0a9557`}}),` `,(0,l.jsxs)(`span`,{children:[(0,l.jsx)(`small`,{children:`Enabled distributions`}),(0,l.jsx)(`strong`,{children:a})]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(c.TeamOutlined,{style:{color:`#1677ff`}}),` `,(0,l.jsxs)(`span`,{children:[(0,l.jsx)(`small`,{children:`Eligible LMS counsellors`}),(0,l.jsx)(`strong`,{children:t??`—`})]})]}),(0,l.jsx)(s.Button,{loading:r,icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:n,children:`Refresh`})]})}var{Text:SE,Title:CE}=s.Typography,wE=`Unmapped`,TE={fontSize:12,color:`#6b7280`};function EE(e,t){return Array.isArray(e)?e:Array.isArray(e?.[t])?e[t]:[]}function DE(){let[e,t]=(0,o.useState)([]),[n,r]=(0,o.useState)([]),[i,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(!1),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(``),[g,_]=(0,o.useState)(`all`),[v,y]=(0,o.useState)(!1),[b,x]=(0,o.useState)(null),[S,C]=(0,o.useState)(``),[w]=s.Form.useForm(),[T,E]=(0,o.useState)([]),[D,O]=(0,o.useState)([]),[k,A]=(0,o.useState)(``),[j,M]=(0,o.useState)(!1),[N,P]=(0,o.useState)(null),[F,I]=(0,o.useState)(`forms`),L=(0,o.useCallback)(async()=>{d(!0),C(``);let[e,n,i,o,s]=await Promise.allSettled([tE(),nE(),rE(),cE(),lE()]),c=[];e.status===`fulfilled`?t(EE(e.value,`forms`)):c.push(`Facebook forms: ${e.reason.message}`),n.status===`fulfilled`?r(EE(n.value,`courses`)):c.push(`LMS courses: ${n.reason.message}`),i.status===`fulfilled`?a(EE(i.value,`mappings`)):c.push(`Saved mappings: ${i.reason.message}`),o.status===`fulfilled`?E(o.value):c.push(`Saved distributions: ${o.reason.message}`),s.status===`fulfilled`?O(s.value):c.push(`Active LMS counsellors: ${s.reason.message}`),C(c.join(` | `)),d(!1)},[]);(0,o.useEffect)(()=>{L()},[L]);let R=(0,o.useMemo)(()=>new Map(T.map(e=>[String(e.formId),e])),[T]),z=(0,o.useMemo)(()=>new Map(i.map(e=>[String(e.formId),e])),[i]),B=(0,o.useMemo)(()=>new Map(n.map(e=>[String(e.courseId),e.courseName])),[n]),V=(0,o.useMemo)(()=>{let t=e.map(e=>({formId:String(e.id),formName:e.name||String(e.id),formStatus:e.status})),n=new Set(t.map(e=>e.formId));return i.forEach(e=>{n.has(e.formId)||t.push({formId:e.formId,formName:e.formName||e.formId,formStatus:`Unknown`})}),t.map(e=>{let t=z.get(e.formId);return{...e,key:e.formId,mapping:t,courseName:t?B.get(t.courseId)||t.courseName:``,status:t?t.isActive?`active`:`inactive`:`unmapped`}})},[e,i,z,B]),H=(0,o.useMemo)(()=>V.filter(e=>g!==`all`&&e.status!==g?!1:`${e.formName} ${e.formId} ${e.courseName}`.toLowerCase().includes(m.trim().toLowerCase())),[V,g,m]),ee=V.filter(e=>e.status===`active`).length,U=V.filter(e=>e.status===`unmapped`).length,te=(e=null)=>{x(e?.formId||null),w.resetFields(),w.setFieldsValue({formId:e?.formId,courseId:e?.mapping?.courseId,isActive:e?.mapping?.isActive??!0}),y(!0)},ne=async()=>{try{let e=await w.validateFields();p(!0),await iE(e,!!(b&&z.has(b))),s.message.success(`Facebook form mapped to LMS course`),y(!1),await L()}catch(e){e?.errorFields||s.message.error(e?.message||`Could not save mapping`)}finally{p(!1)}},re=async e=>{try{await aE(e),s.message.success(`Mapping removed; future leads will be unmapped unless another rule matches`),await L()}catch(e){s.message.error(e?.message||`Could not remove mapping`)}},ie=async e=>{A(e.formId);try{let[t,n]=await Promise.all([lE(),cE()]);O(t),E(n),P(e)}catch(e){s.message.error(e.message||`Could not load live LMS counsellors`)}finally{A(``)}};return(0,l.jsxs)(`div`,{className:`facebook-course-mapping`,style:{padding:`4px 0 18px`},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,gap:12,flexWrap:`wrap`,alignItems:`center`,marginBottom:16},children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(CE,{level:4,style:{marginBottom:4},children:`Facebook Lead Form → Course Mapping`}),(0,l.jsx)(SE,{type:`secondary`,children:`One LMS course may receive leads from multiple Facebook forms and advertisements.`})]}),(0,l.jsxs)(s.Space,{wrap:!0,children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:L,loading:u,children:`Sync Facebook Forms`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>te(),children:`Add Mapping`})]})]}),S&&(0,l.jsx)(s.Alert,{showIcon:!0,type:`warning`,message:`Some configuration data could not be loaded`,description:S,style:{marginBottom:16}}),(0,l.jsxs)(s.Row,{gutter:[12,12],style:{marginBottom:16},children:[(0,l.jsx)(s.Col,{xs:12,md:6,children:(0,l.jsx)(s.Card,{size:`small`,children:(0,l.jsx)(s.Statistic,{title:`Facebook Forms`,value:V.length,prefix:(0,l.jsx)(c.LinkOutlined,{})})})}),(0,l.jsx)(s.Col,{xs:12,md:6,children:(0,l.jsx)(s.Card,{size:`small`,children:(0,l.jsx)(s.Statistic,{title:`Active Mappings`,value:ee,prefix:(0,l.jsx)(c.CheckCircleOutlined,{})})})}),(0,l.jsx)(s.Col,{xs:12,md:6,children:(0,l.jsx)(s.Card,{size:`small`,children:(0,l.jsx)(s.Statistic,{title:`Unmapped Forms`,value:U,prefix:(0,l.jsx)(c.WarningOutlined,{})})})}),(0,l.jsx)(s.Col,{xs:12,md:6,children:(0,l.jsx)(s.Card,{size:`small`,children:(0,l.jsx)(s.Statistic,{title:`Available Courses`,value:n.length,prefix:(0,l.jsx)(c.BookOutlined,{})})})})]}),(0,l.jsx)(xE,{configurations:T,counsellorCount:D.length,onRefresh:L,loading:u}),(0,l.jsxs)(s.Space,{wrap:!0,style:{display:`flex`,marginBottom:12},children:[(0,l.jsx)(s.Button,{type:F===`forms`?`primary`:`default`,onClick:()=>I(`forms`),children:`Facebook Forms & Distribution`}),(0,l.jsx)(s.Button,{type:F===`monitoring`?`primary`:`default`,onClick:()=>I(`monitoring`),children:`Skip Audit & Unassigned Leads`})]}),F===`forms`?(0,l.jsxs)(s.Card,{size:`small`,children:[(0,l.jsxs)(s.Space,{wrap:!0,style:{marginBottom:14,width:`100%`,display:`flex`},children:[(0,l.jsx)(s.Input,{allowClear:!0,style:{width:320,maxWidth:`100%`},placeholder:`Search form, Form ID or course`,prefix:(0,l.jsx)(c.SearchOutlined,{}),value:m,onChange:e=>h(e.target.value)}),(0,l.jsx)(s.Select,{style:{width:185},value:g,onChange:_,options:[{value:`all`,label:`All mappings`},{value:`active`,label:`Active`},{value:`inactive`,label:`Inactive`},{value:`unmapped`,label:`Unmapped`}]})]}),(0,l.jsx)(s.Table,{rowKey:`formId`,columns:[{title:`Facebook Form`,dataIndex:`formName`,key:`formName`,width:`31%`,render:(e,t)=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(SE,{strong:!0,children:e}),(0,l.jsxs)(`div`,{style:TE,children:[`Form ID: `,t.formId]})]})},{title:`LMS Course`,dataIndex:`courseName`,key:`courseName`,render:(e,t)=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(SE,{children:e||wE}),t.mapping&&(0,l.jsx)(`div`,{style:TE,children:t.mapping.courseId})]})},{title:`Mapping Status`,dataIndex:`status`,key:`status`,width:158,render:e=>e===`active`?(0,l.jsx)(s.Tag,{color:`success`,children:`Active`}):e===`inactive`?(0,l.jsx)(s.Tag,{color:`default`,children:`Inactive`}):(0,l.jsx)(s.Tag,{color:`warning`,children:`Unmapped`})},{title:`Distribution`,key:`distribution`,width:155,render:(e,t)=>(0,l.jsx)(`span`,{className:`fb-dist-status`,children:R.has(t.formId)?(0,l.jsx)(s.Tooltip,{title:`Next: ${R.get(t.formId)?.counsellors?.find(e=>String(e.userId)===String(R.get(t.formId)?.nextUserId))?.name||`Not set`}`,children:(0,l.jsx)(s.Tag,{color:R.get(t.formId)?.isActive?`green`:`orange`,children:R.get(t.formId)?.isActive?`Configured`:`Paused`})}):(0,l.jsx)(s.Tag,{children:`Not configured`})})},{title:`Actions`,key:`actions`,width:160,render:(e,t)=>(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{size:`small`,title:`Add or edit mapping`,icon:t.mapping?(0,l.jsx)(c.EditOutlined,{}):(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>te(t)}),(0,l.jsx)(s.Button,{size:`small`,title:t.status===`active`?`Set or change live distribution`:`Activate course mapping before setting distribution`,disabled:t.status!==`active`,loading:k===t.formId,icon:(0,l.jsx)(c.TeamOutlined,{}),onClick:()=>ie(t)}),t.mapping&&(0,l.jsx)(s.Popconfirm,{title:`Remove this mapping?`,description:`Existing LMS leads will not be changed.`,onConfirm:()=>re(t.formId),children:(0,l.jsx)(s.Button,{size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],dataSource:H,loading:u,size:`middle`,scroll:{x:880},pagination:{pageSize:10,showSizeChanger:!1,showTotal:e=>`${e} Facebook forms`},locale:{emptyText:(0,l.jsx)(s.Empty,{description:`No Facebook forms found`})}}),(0,l.jsx)(SE,{type:`secondary`,style:{fontSize:12},children:`Ad count isn't available from the current forms API. Multiple ads using one Form ID need just one mapping. Multiple Form IDs can select the same LMS course. Existing lead courses are not changed when mappings are edited.`})]}):(0,l.jsx)(bE,{rows:V}),(0,l.jsx)(yE,{open:!!N,row:N,current:N?R.get(N.formId):null,counsellors:D,saving:j,onClose:()=>P(null),onSave:async(e,t)=>{M(!0);try{await uE(e,t);let n=await cE();E(n),P(null),s.message.success(t?`Distribution updated successfully`:`Distribution saved successfully`)}catch(e){s.message.error(e.message||`Could not save distribution`)}finally{M(!1)}}}),(0,l.jsx)(s.Drawer,{title:b&&z.has(b)?`Edit Course Mapping`:`Add Course Mapping`,width:440,open:v,destroyOnClose:!0,onClose:()=>y(!1),extra:(0,l.jsx)(s.Button,{type:`primary`,onClick:ne,loading:f,children:`Save Mapping`}),children:(0,l.jsxs)(s.Form,{form:w,layout:`vertical`,initialValues:{isActive:!0},children:[(0,l.jsx)(s.Form.Item,{name:`formId`,label:`Facebook Lead Form`,rules:[{required:!0,message:`Select a Facebook form`}],children:(0,l.jsx)(s.Select,{showSearch:!0,optionFilterProp:`label`,placeholder:`Select Facebook form`,disabled:!!b,options:V.map(e=>({value:e.formId,label:`${e.formName} (${e.formId})`,disabled:!b&&!!e.mapping}))})}),(0,l.jsx)(s.Form.Item,{name:`courseId`,label:`Available LMS Course`,rules:[{required:!0,message:`Select an LMS course`}],children:(0,l.jsx)(s.Select,{showSearch:!0,optionFilterProp:`label`,placeholder:`Select LMS course`,options:n.map(e=>({value:e.courseId,label:e.courseName}))})}),(0,l.jsx)(s.Form.Item,{name:`isActive`,label:`Mapping Status`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{checkedChildren:`Active`,unCheckedChildren:`Inactive`})}),(0,l.jsx)(s.Alert,{type:`info`,showIcon:!0,message:`Multiple forms can map to the same course`,description:`The selected course will be saved as courseId on newly imported Facebook leads. Forms without an active mapping can still import with course mapping pending.`})]})})]})}var{Text:$}=s.Typography;function OE({rows:e,onChange:t,keyPlaceholder:n,valuePlaceholder:r}){let i=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e)),a=n=>t(e.filter((e,t)=>t!==n));return(0,l.jsxs)(`div`,{children:[e.map((e,t)=>(0,l.jsxs)(`div`,{style:{display:`flex`,gap:6,marginTop:6},children:[(0,l.jsx)(s.Input,{size:`small`,style:{flex:1},placeholder:n,value:e.key,onChange:e=>i(t,{key:e.target.value}),className:`fg-mono-input`}),(0,l.jsx)(`span`,{style:{color:`#94a3b8`,alignSelf:`center`},children:`→`}),(0,l.jsx)(s.Input,{size:`small`,style:{flex:1},placeholder:r,value:e.value,onChange:e=>i(t,{value:e.target.value}),className:`fg-mono-input`}),(0,l.jsx)(s.Button,{size:`small`,type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),onClick:()=>a(t)})]},t)),(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:6},onClick:()=>t([...e,{key:``,value:``}]),children:`Add`})]})}function kE({rows:e,onChange:t,keyPlaceholder:n=`field`,valuePlaceholder:r=`literal or {{field.path}}`}){let i=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e)),a=n=>t(e.filter((e,t)=>t!==n));return(0,l.jsxs)(`div`,{children:[e.map((e,t)=>(0,l.jsxs)(`div`,{style:{display:`flex`,gap:6,marginTop:6},children:[(0,l.jsx)(s.Input,{size:`small`,style:{flex:1},placeholder:n,value:e.key,onChange:e=>i(t,{key:e.target.value}),className:`fg-mono-input`}),(0,l.jsx)(s.Input,{size:`small`,style:{flex:1.6},placeholder:r,value:e.value,onChange:e=>i(t,{value:e.target.value}),className:`fg-mono-input`}),(0,l.jsx)(s.Button,{size:`small`,type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),onClick:()=>a(t)})]},t)),(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:6},onClick:()=>t([...e,{key:``,value:``}]),children:`Add`}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:4},children:[`Values are read as JSON when possible (true, 123, ["a","b"]) — otherwise kept as literal text. Use `,(0,l.jsx)(`code`,{children:`{{field.path}}`}),` to reference a payload field, or `,(0,l.jsx)(`code`,{children:`{{now}}`}),` for the current time.`]})]})}function AE(e){return Object.entries(e??{}).map(([e,t])=>({key:e,value:String(t??``)}))}function jE(e){let t={};for(let n of e??[])n.key?.trim()&&(t[n.key.trim()]=n.value??``);return t}function ME(e){return Object.entries(e??{}).map(([e,t])=>({key:e,value:typeof t==`string`?t:JSON.stringify(t)}))}function NE(e){let t={};for(let n of e??[]){if(!n.key?.trim())continue;let e=n.value;if(typeof e==`string`){let t=e.trim();if(t!==``)try{e=JSON.parse(t)}catch{}}t[n.key.trim()]=e}return t}function PE({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,o.useState)(()=>({sourceModule:``,sourceIdField:``,required:!1,...t??{},fieldMapRows:AE(t?.fieldMap)})),u=(e,t)=>a(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:n,width:640,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.DatabaseOutlined,{}),` `,t?`Edit Denormalize Rule`:`New Denormalize Rule`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:n,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!i.sourceModule?.trim())return s.message.error(`Source module is required`);if(!i.sourceIdField?.trim())return s.message.error(`Source id field is required`);let{fieldMapRows:e,...t}=i;r({...t,fieldMap:jE(e)})},children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source module`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`job`,value:i.sourceModule??``,onChange:e=>u(`sourceModule`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source id field (on THIS payload)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`jobId`,value:i.sourceIdField??``,onChange:e=>u(`sourceIdField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!i.required,onChange:e=>u(`required`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Required — block the write if the source record can't be found`})]}),(0,l.jsxs)(`div`,{style:{marginTop:16},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Field map (source field → this payload's field)`}),(0,l.jsx)(OE,{rows:i.fieldMapRows??[],onChange:e=>u(`fieldMapRows`,e),keyPlaceholder:`jobTitle`,valuePlaceholder:`jobTitle`})]})]})})}function FE({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,o.useState)(()=>({sourceField:``,targetField:``,sourceCollection:``,idField:``,idOutputKey:``,stampNow:``,...t??{},fieldMapRows:AE(t?.fieldMap)})),u=(e,t)=>a(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:n,width:640,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.ApartmentOutlined,{}),` `,t?`Edit Array Enrichment`:`New Array Enrichment`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:n,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!i.sourceField?.trim())return s.message.error(`Source field is required`);if(!i.targetField?.trim())return s.message.error(`Target field is required`);let{fieldMapRows:e,...t}=i;r({...t,fieldMap:jE(e)})},children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source field (array of ids on this payload)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`recruitersData`,value:i.sourceField??``,onChange:e=>u(`sourceField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Target field (enriched array written here)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`recruiters`,value:i.targetField??``,onChange:e=>u(`targetField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source collection`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`users (default)`,value:i.sourceCollection??``,onChange:e=>u(`sourceCollection`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Id field on that collection`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`legacyUserId (default)`,value:i.idField??``,onChange:e=>u(`idField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{style:{marginTop:16},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Field map (source collection field → output key)`}),(0,l.jsx)(OE,{rows:i.fieldMapRows??[],onChange:e=>u(`fieldMapRows`,e),keyPlaceholder:`firstName`,valuePlaceholder:`recruiterName`})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Also write the matched id as`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`recruiterId`,value:i.idOutputKey??``,onChange:e=>u(`idOutputKey`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Also stamp the current time as`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`assignedDateTime`,value:i.stampNow??``,onChange:e=>u(`stampNow`,e.target.value),className:`fg-mono-input`})]})]})]})})}function IE({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,o.useState)(()=>({sourceField:``,targetField:``,uploadedFileNameField:``,uniqueNameField:``,uploadedAtField:``,uploadedByField:``,arrayMode:!1,nameFromField:``,nameOutputField:``,historyField:``,historySnapshotKey:``,historyReason:``,...t??{},staticFieldRows:AE(t?.staticFields),arrayFieldNameRows:AE(t?.arrayFieldNames)})),u=(e,t)=>a(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:n,width:760,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.DatabaseOutlined,{}),` `,t?`Edit File Field Map`:`New File Field Map`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:n,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!i.sourceField?.trim())return s.message.error(`Source field (the multipart upload key) is required`);if(!i.targetField?.trim())return s.message.error(`Target field is required`);let{staticFieldRows:e,arrayFieldNameRows:t,...n}=i;r({...n,staticFields:jE(e),arrayFieldNames:jE(t)})},children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Turns one uploaded file field into a nested object (or array of objects) instead of a flat S3 path string — for schemas like a candidate's resume/passport/visa that store location + filename + who/when as sub-fields.`}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source field (multipart upload key)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume`,value:i.sourceField??``,onChange:e=>u(`sourceField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12},children:[`Target field `,i.arrayMode?`(array)`:`(location sub-field)`]}),(0,l.jsx)(s.Input,{size:`small`,placeholder:i.arrayMode?`documents`:`resume.location`,value:i.targetField??``,onChange:e=>u(`targetField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!i.arrayMode,onChange:e=>u(`arrayMode`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Array mode — every uploaded file becomes one element (e.g. "documents")`})]}),i.arrayMode?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Sub-field names (location / uploadedFileName / uniqueName → this schema's names)`}),(0,l.jsx)(OE,{rows:i.arrayFieldNameRows??[],onChange:e=>u(`arrayFieldNameRows`,e),keyPlaceholder:`location`,valuePlaceholder:`documentCopyLocation`})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Take each element's display name from (payload array field)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`documents`,value:i.nameFromField??``,onChange:e=>u(`nameFromField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`...reading its field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`documentName`,value:i.nameOutputField??``,onChange:e=>u(`nameOutputField`,e.target.value),className:`fg-mono-input`})]})]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Original filename field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume.uploadedFileName`,value:i.uploadedFileNameField??``,onChange:e=>u(`uploadedFileNameField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Unique name field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume.uniqueName`,value:i.uniqueNameField??``,onChange:e=>u(`uniqueNameField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Uploaded-at field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume.uploadedAt`,value:i.uploadedAtField??``,onChange:e=>u(`uploadedAtField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Uploaded-by field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume.uploadedBy`,value:i.uploadedByField??``,onChange:e=>u(`uploadedByField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Static fields (literal value written alongside the upload)`}),(0,l.jsx)(OE,{rows:i.staticFieldRows??[],onChange:e=>u(`staticFieldRows`,e),keyPlaceholder:`resume.source`,valuePlaceholder:`candidate`})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Append a snapshot to (history array field)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resumeHistory`,value:i.historyField??``,onChange:e=>u(`historyField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`...under snapshot key`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume`,value:i.historySnapshotKey??``,onChange:e=>u(`historySnapshotKey`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`...with reason`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`Initial resume upload`,value:i.historyReason??``,onChange:e=>u(`historyReason`,e.target.value),className:`fg-mono-input`})]})]})]})]})})}function LE({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,o.useState)(()=>({name:``,seedField:``,direction:`up`,stopRole:0,includeSeed:!0,...t??{}})),u=(e,t)=>a(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:n,width:620,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.ApartmentOutlined,{}),` `,t?`Edit Hierarchy Expansion`:`New Hierarchy Expansion`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:n,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!i.name?.trim())return s.message.error(`Name is required — this is how RelatedUpdates/Notify reference the result`);if(!/^[a-zA-Z0-9_]+$/.test(i.name))return s.message.error(`Name: letters, numbers, underscores only`);r(i)},children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Name`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`chain`,value:i.name??``,onChange:e=>u(`name`,e.target.value),className:`fg-mono-input`}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:11},children:[`Referenced as `,(0,l.jsx)(`code`,{children:`{{hierarchy.`+(i.name||`name`)+`}}`})]})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Seed field (blank = the caller)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`recruitersData`,value:i.seedField??``,onChange:e=>u(`seedField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Direction`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:i.direction||`up`,onChange:e=>u(`direction`,e),options:[{value:`up`,label:`Up — toward admin (reporting chain)`},{value:`down`,label:`Down — toward subordinates (team)`}]})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Stop at role id (up only, 0 = walk to the top)`}),(0,l.jsx)(s.InputNumber,{size:`small`,style:{width:`100%`},min:0,value:i.stopRole??0,onChange:e=>u(`stopRole`,e??0),disabled:i.direction!==`up`})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:i.includeSeed!==!1,onChange:e=>u(`includeSeed`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Include the seed user(s) themselves in the result`})]})]})})}function RE({open:e,rule:t,hierarchyNames:n,onClose:r,onSave:i}){let[a,u]=(0,o.useState)(()=>({collectionName:``,targetModule:``,matchField:``,scopeTenant:!1,forEach:``,insertMode:!!(t?.insertIfMissing&&Object.keys(t.insertIfMissing).length),...t??{},extraFilterRows:ME(t?.extraFilter),pullRows:ME(t?.pull),pushRows:ME(t?.push),setRows:ME(t?.set),setIfNonBlankRows:ME(t?.setIfNonBlank),insertIfMissingRows:ME(t?.insertIfMissing)})),d=(e,t)=>u(n=>({...n,[e]:t})),f=()=>{if(!a.collectionName?.trim()&&!a.targetModule?.trim())return s.message.error(`Set either a collection name or a target module`);let{extraFilterRows:e,pullRows:t,pushRows:n,setRows:r,setIfNonBlankRows:o,insertIfMissingRows:c,insertMode:l,...u}=a;i({...u,extraFilter:NE(e),pull:l?{}:NE(t),push:l?{}:NE(n),set:l?{}:NE(r),setIfNonBlank:l?{}:NE(o),insertIfMissing:l?NE(c):{}})},p=(n??[]).map(e=>({value:`hierarchy.${e}`,label:`{{hierarchy.${e}}}`}));return(0,l.jsx)(s.Modal,{open:e,onCancel:r,width:820,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.ThunderboltOutlined,{}),` `,t?`Edit Related Update`:`New Related Update`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:f,children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsx)(`div`,{className:`fg-form-section-label`,children:`Target`}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Collection name (used verbatim)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`hiringProgress`,value:a.collectionName??``,onChange:e=>d(`collectionName`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`— or — target module`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`job`,value:a.targetModule??``,onChange:e=>d(`targetModule`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Match field (this payload's field holding the target _id)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`jobId (blank for a tenant-scoped board)`,value:a.matchField??``,onChange:e=>d(`matchField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Repeat once per element of (ForEach)`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},allowClear:!0,showSearch:!0,placeholder:`e.g. {{hierarchy.chain}}`,value:a.forEach||void 0,onChange:e=>d(`forEach`,e??``),options:p})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!a.scopeTenant,onChange:e=>d(`scopeTenant`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Scope filter to the caller's tenant/business/businessUnit`})]}),(0,l.jsxs)(`div`,{style:{marginTop:14},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Extra filter (merged into the match filter)`}),(0,l.jsx)(kE,{rows:a.extraFilterRows??[],onChange:e=>d(`extraFilterRows`,e),keyPlaceholder:`recruiterId`,valuePlaceholder:`{"$in":"{{hierarchy.chain}}"}`})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:18},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!a.insertMode,onChange:e=>d(`insertMode`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Insert-only-if-missing (seed a new document instead of updating an existing one)`})]}),a.insertMode?(0,l.jsxs)(`div`,{style:{marginTop:10},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Document to insert when the filter matches nothing`}),(0,l.jsx)(kE,{rows:a.insertIfMissingRows??[],onChange:e=>d(`insertIfMissingRows`,e),keyPlaceholder:`hiringProgressJobStatus`,valuePlaceholder:`"unread"`})]}):(0,l.jsx)(s.Tabs,{size:`small`,style:{marginTop:10},items:[{key:`pull`,label:`Pull`,children:(0,l.jsx)(kE,{rows:a.pullRows??[],onChange:e=>d(`pullRows`,e),keyPlaceholder:`submitted`,valuePlaceholder:`{"candidateId":"{{applicantId}}"}`})},{key:`push`,label:`Push`,children:(0,l.jsx)(kE,{rows:a.pushRows??[],onChange:e=>d(`pushRows`,e),keyPlaceholder:`submitted`,valuePlaceholder:`{"status":"{{submissionStatus}}"}`})},{key:`set`,label:`Set`,children:(0,l.jsx)(kE,{rows:a.setRows??[],onChange:e=>d(`setRows`,e),keyPlaceholder:`hiringProgressJobStatus`,valuePlaceholder:`"unread"`})},{key:`setIfNonBlank`,label:`Set if non-blank`,children:(0,l.jsx)(kE,{rows:a.setIfNonBlankRows??[],onChange:e=>d(`setIfNonBlankRows`,e),keyPlaceholder:`resume.location`,valuePlaceholder:`{{resume.location}}`})}]})]})})}function zE({icon:e,title:t,description:n,rules:r,columns:i,onAdd:a,onEdit:o,onDelete:u}){return(0,l.jsxs)(Z,{title:(0,l.jsxs)(`span`,{children:[e,` `,t]}),extra:(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:a,children:`Add`}),styles:{body:{paddingTop:8}},children:[n&&(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:n}),(0,l.jsx)(s.Table,{rowKey:(e,t)=>t,dataSource:r,columns:[...i,{title:``,key:`actions`,width:80,align:`right`,render:(e,t,n)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>o(n,t)})}),(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),onClick:()=>u(n)})})]})}],pagination:!1,size:`small`,className:`fg-table`,locale:{emptyText:(0,l.jsx)(s.Empty,{image:s.Empty.PRESENTED_IMAGE_SIMPLE,description:`Not configured`})}})]})}var BE={sequence:null,duplicateCheck:null,fileVersioning:null,denormalizations:[],arrayEnrichments:[],fileFieldMaps:[],sanitizeFields:[],defaults:{},hierarchyExpands:[],relatedUpdates:[],notify:null,cacheInvalidate:[]};function VE(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!0),[a,u]=(0,o.useState)(``),[d,f]=(0,o.useState)({storage:`mongo`}),[p,m]=(0,o.useState)(`mongo`),[h,g]=(0,o.useState)(BE),[_,v]=(0,o.useState)(!1),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)(null),[T,E]=(0,o.useState)(null),[D,O]=(0,o.useState)(null),[k,A]=(0,o.useState)(null),[j,M]=(0,o.useState)(null);(0,o.useEffect)(()=>{n.Sr().then(e=>{let n=hS(e).map(({value:e,label:t})=>({key:e,label:t}));t(n),n.length&&u(n[0].key)}).catch(()=>t([])).finally(()=>i(!1))},[]),(0,o.useEffect)(()=>{if(!a)return;let e=!1;return(async()=>{v(!0),S(``);try{let t=await n.Rr(a);if(e)return;let r=t.gateway??{storage:`mongo`};f(r),m(r.storage||`mongo`),g({...BE,...t.strategies??{}})}catch(t){e||S(t?.message||`Failed to load automations`)}finally{e||v(!1)}})(),()=>{e=!0}},[a]);let N=(0,o.useMemo)(()=>(h.hierarchyExpands??[]).map(e=>e.name).filter(Boolean),[h.hierarchyExpands]);function P(e,t){g(n=>({...n,[e]:t}))}function F(e,t){g(n=>{let r=n.duplicateCheck??{},i=[...r.stages??[]];return i[e]=t,{...n,duplicateCheck:{...r,stages:i}}})}function I(){b(!0);let e={...h,denormalizations:h.denormalizations?.length?h.denormalizations:void 0,arrayEnrichments:h.arrayEnrichments?.length?h.arrayEnrichments:void 0,fileFieldMaps:h.fileFieldMaps?.length?h.fileFieldMaps:void 0,sanitizeFields:h.sanitizeFields?.length?h.sanitizeFields:void 0,hierarchyExpands:h.hierarchyExpands?.length?h.hierarchyExpands:void 0,relatedUpdates:h.relatedUpdates?.length?h.relatedUpdates:void 0,cacheInvalidate:h.cacheInvalidate?.length?h.cacheInvalidate:void 0,defaults:Object.keys(h.defaults??{}).length?h.defaults:void 0};n.oi(a,{gateway:d,strategies:e}).then(()=>{m(d.storage||`mongo`),s.message.success(`Automations saved`)}).catch(e=>s.message.error(e?.message||`Could not save automations`)).finally(()=>b(!1))}function L(){if((d.storage||`mongo`)!==p){s.Modal.confirm({title:`Change how this module persists writes?`,content:`You're switching ${a} from "${p}" to "${d.storage}". `+(d.storage===`mongo`?`This module will stop calling its downstream service and this gateway will own the write + every Strategy below.`:`This module will stop using the Strategies below and go back to calling its downstream service.`)+` Make sure the downstream service / e2e checks are ready before confirming.`,okText:`Confirm cutover`,okButtonProps:{danger:!0},onOk:I});return}I()}let R=[{title:`Source module`,dataIndex:`sourceModule`,key:`sourceModule`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Source id field`,dataIndex:`sourceIdField`,key:`sourceIdField`},{title:`Fields`,key:`fields`,render:(e,t)=>(0,l.jsx)(s.Badge,{count:Object.keys(t.fieldMap??{}).length,showZero:!0,color:`var(--color-brand)`})},{title:`Required`,dataIndex:`required`,key:`required`,width:90,render:e=>e?(0,l.jsx)(s.Tag,{color:`volcano`,children:`Required`}):(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`optional`})}],z=[{title:`Source field`,dataIndex:`sourceField`,key:`sourceField`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Target field`,dataIndex:`targetField`,key:`targetField`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`From collection`,key:`coll`,render:(e,t)=>t.sourceCollection||`users`},{title:`Fields`,key:`fields`,render:(e,t)=>(0,l.jsx)(s.Badge,{count:Object.keys(t.fieldMap??{}).length,showZero:!0,color:`var(--color-brand)`})}],B=[{title:`Source field`,dataIndex:`sourceField`,key:`sourceField`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Target field`,dataIndex:`targetField`,key:`targetField`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Mode`,dataIndex:`arrayMode`,key:`arrayMode`,width:100,render:e=>e?(0,l.jsx)(s.Tag,{color:`blue`,children:`Array`}):(0,l.jsx)(s.Tag,{children:`Single`})},{title:`History`,dataIndex:`historyField`,key:`historyField`,render:e=>e||(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`—`})}],V=[{title:`Name`,dataIndex:`name`,key:`name`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:`{{hierarchy.`+e+`}}`})},{title:`Seed field`,dataIndex:`seedField`,key:`seedField`,render:e=>e||(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`caller`})},{title:`Direction`,dataIndex:`direction`,key:`direction`,render:e=>(0,l.jsx)(s.Tag,{color:e===`down`?`blue`:`purple`,children:e===`down`?`Down — team`:`Up — chain`})},{title:`Stop role`,dataIndex:`stopRole`,key:`stopRole`,width:90,render:e=>e||(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`top`})}],H=[{title:`Target`,key:`target`,render:(e,t)=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:t.collectionName||t.targetModule})},{title:`Match`,key:`match`,render:(e,t)=>t.matchField||(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`tenant-scoped`})},{title:`For each`,key:`forEach`,render:(e,t)=>t.forEach?(0,l.jsx)(s.Tag,{color:`geekblue`,children:`{{${t.forEach}}}`}):(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`once`})},{title:`Mode`,key:`mode`,render:(e,t)=>Object.keys(t.insertIfMissing??{}).length?(0,l.jsx)(s.Tag,{color:`green`,children:`Insert if missing`}):(0,l.jsx)(s.Tag,{children:`Update`})}],ee=e.map(e=>({key:e.key,label:e.label}));return(0,l.jsxs)(`div`,{className:`fg-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.ThunderboltOutlined,{}),title:`Automations`,extra:(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:y,disabled:!a,onClick:L,children:`Save Automations`}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)($,{type:`secondary`,style:{fontSize:13},children:`Config-driven side-effects the common CRUD gateway runs around a create — reference ids, duplicate checks, cross-module field snapshots, reporting-chain hierarchy expansion, board updates, notifications, cache invalidation. Nothing here is module-specific: the same engine serves every module.`})]}),(0,l.jsx)(Z,{styles:{body:{paddingTop:8}},children:(0,l.jsxs)(s.Spin,{spinning:r,children:[(0,l.jsx)(s.Tabs,{activeKey:a,onChange:u,items:ee.map(e=>({...e,children:null})),className:`admin-module-tabs`}),x&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:x,style:{marginBottom:12}}),(0,l.jsxs)(s.Spin,{spinning:_,children:[(0,l.jsxs)(Z,{title:`Gateway`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Selects how a write to this module persists. "Proxy" forwards to a downstream microservice (which owns every side-effect below itself). "Mongo" makes THIS gateway own the write and run every Strategy configured below.`}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Storage`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:d.storage||`mongo`,onChange:e=>f(t=>({...t,storage:e})),options:[{value:`mongo`,label:`Mongo — this gateway owns the write`},{value:`proxy`,label:`Proxy — forward to a downstream service`}]})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`File field key`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`file`,value:d.fileKey??``,onChange:e=>f(t=>({...t,fileKey:e.target.value})),className:`fg-mono-input`})]})]}),d.storage===`proxy`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Base URL env var`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`JOBS_SERVICE_URL`,value:d.baseUrlEnv??``,onChange:e=>f(t=>({...t,baseUrlEnv:e.target.value})),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Base URL (fallback)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`http://...`,value:d.baseUrl??``,onChange:e=>f(t=>({...t,baseUrl:e.target.value})),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Create path`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`/v1/jobs`,value:d.createPath??``,onChange:e=>f(t=>({...t,createPath:e.target.value})),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Update path (%s = id)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`/v1/edit/%s`,value:d.updatePath??``,onChange:e=>f(t=>({...t,updatePath:e.target.value})),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Update method`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:d.updateMethod||`PUT`,onChange:e=>f(t=>({...t,updateMethod:e})),options:[`PUT`,`POST`,`PATCH`].map(e=>({value:e,label:e}))})]})]})]})]}),(0,l.jsxs)(Z,{title:`Reference ID (Sequence)`,styles:{body:{paddingTop:8}},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.sequence,onChange:e=>P(`sequence`,e?{field:``,prefix:``,counterKey:``}:null)}),(0,l.jsxs)($,{style:{fontSize:13},children:[`Generate a "`,`{prefix}{n}`,`" reference id on create`]})]}),h.sequence&&(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Payload field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`submissionId`,value:h.sequence.field??``,onChange:e=>P(`sequence`,{...h.sequence,field:e.target.value}),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Prefix`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`sub`,value:h.sequence.prefix??``,onChange:e=>P(`sequence`,{...h.sequence,prefix:e.target.value}),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Counter key`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`submissions`,value:h.sequence.counterKey??``,onChange:e=>P(`sequence`,{...h.sequence,counterKey:e.target.value}),className:`fg-mono-input`})]})]})]}),(0,l.jsxs)(Z,{title:`Check for someone already on file`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Before a new record is saved, look for one that already matches. This is what stops the same person being added twice under slightly different details.`}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.duplicateCheck,onChange:e=>P(`duplicateCheck`,e?{stages:[],policy:`prompt`,displayFields:[],message:``}:null)}),(0,l.jsx)($,{style:{fontSize:13},children:`Check before saving a new record`})]}),h.duplicateCheck&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:6},children:[(0,l.jsx)(`b`,{children:`Checks run in order, top first, and stop at the first match.`}),` Put your most certain check first — matching an email or a phone number is near proof; matching a name alone is only a maybe, so it belongs lower down.`]}),(h.duplicateCheck.stages??[]).map((e,t)=>(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginBottom:8,alignItems:`flex-end`},children:[(0,l.jsxs)(`div`,{style:{flex:1.6},children:[(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12},children:[`Check `,t+1,` — compare these`]}),(0,l.jsx)(s.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`email, contactNumber`,value:e.fields??[],onChange:n=>F(t,{...e,fields:n})})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Counts as a match when`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:e.match??`all`,onChange:n=>F(t,{...e,match:n}),options:[{value:`any`,label:`Any one of them matches`},{value:`all`,label:`All of them match`}]})]}),(0,l.jsxs)(`div`,{style:{flex:.8},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`How sure is it?`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:e.weight??`strong`,onChange:n=>F(t,{...e,weight:n}),options:[{value:`strong`,label:`Almost certainly the same`},{value:`weak`,label:`Possibly the same`}]})]}),(0,l.jsxs)(`div`,{style:{flex:2},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`What to tell the user`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`A candidate with this email already exists — {name}, last updated {age}.`,value:e.message??``,onChange:n=>F(t,{...e,message:n.target.value})})]}),(0,l.jsx)(s.Button,{size:`small`,danger:!0,type:`text`,onClick:()=>P(`duplicateCheck`,{...h.duplicateCheck,stages:(h.duplicateCheck.stages??[]).filter((e,n)=>n!==t)}),children:`Remove`})]},t)),(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,style:{marginBottom:12},onClick:()=>P(`duplicateCheck`,{...h.duplicateCheck,stages:[...h.duplicateCheck.stages??[],{fields:[],match:`any`,weight:`strong`}]}),children:`Add another check`}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`When a match is found`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:h.duplicateCheck.policy??`prompt`,onChange:e=>P(`duplicateCheck`,{...h.duplicateCheck,policy:e}),options:[{value:`prompt`,label:`Ask, and offer to update the existing one`},{value:`block`,label:`Refuse to save, and name the existing one`}]})]}),(0,l.jsxs)(`div`,{style:{flex:1.2},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Which details identify the record`}),(0,l.jsx)(s.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`firstName, lastName, email`,value:h.duplicateCheck.displayFields??[],onChange:e=>P(`duplicateCheck`,{...h.duplicateCheck,displayFields:e})})]})]}),(0,l.jsx)(`div`,{className:`fg-field-meta-row`,style:{marginTop:10},children:(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Where to open the existing record`}),(0,l.jsx)(s.Input,{size:`small`,className:`fg-mono-input`,placeholder:`/candidate/edit/:id`,value:h.duplicateCheck.editRoute??``,onChange:e=>P(`duplicateCheck`,{...h.duplicateCheck,editRoute:e.target.value})})]})}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:6},children:[`The page that opens when someone chooses to update the record you already have. Use `,(0,l.jsx)(`b`,{children:`:id`}),` where the record's id goes. This has to be filled in — it cannot be worked out, because addresses follow no single pattern (this app uses `,(0,l.jsx)(`code`,{children:`/candidate/edit/:id`}),` but `,(0,l.jsx)(`code`,{children:`/clients/edit/:id`}),`). Left blank, the dialog still appears and simply does not navigate, rather than sending anyone to a page that does not exist.`]}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:8},children:[`In any message you can use `,(0,l.jsx)(`b`,{children:`{name}`}),` for the matched record and`,(0,l.jsxs)(`b`,{children:[` `,`{age}`]}),` for how long ago it was last touched ("about 2 months ago"). `,(0,l.jsx)(`b`,{children:`{updatedOn}`}),` gives the date instead. Only the details listed above are shown — nothing else about the record is revealed.`]})]})]}),(0,l.jsxs)(Z,{title:`Keep previous versions of an uploaded file`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Normally a new upload replaces the old one and it is gone. Turn this on and the last few are kept instead — useful when someone sends an updated CV and you may want to look back at the earlier one. Everywhere in the app still shows the newest; the older ones sit behind it.`}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.fileVersioning,onChange:e=>P(`fileVersioning`,e?{fields:[],keep:2,historyKey:``,s3Prefix:``,deleteEvicted:!1}:null)}),(0,l.jsx)($,{style:{fontSize:13},children:`Keep previous uploads`})]}),h.fileVersioning&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{style:{marginBottom:10},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`},children:`Where the older versions are kept`}),(0,l.jsxs)(s.Radio.Group,{size:`small`,value:h.fileVersioning.store===`documents`?`documents`:`record`,onChange:e=>{let t=e.target.value,n={...h.fileVersioning,store:t===`documents`?`documents`:``};t===`documents`&&(n.linkField=n.linkField||`documentIds`,n.clearRecordKeys=n.clearRecordKeys?.length?n.clearRecordKeys:(n.fields??[]).flatMap(e=>[`${e}History`,`${e}Versions`])),P(`fileVersioning`,n)},children:[(0,l.jsx)(s.Radio,{value:`documents`,children:`In Documents (recommended)`}),(0,l.jsx)(s.Radio,{value:`record`,children:`On the record itself`})]}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:6},children:[(0,l.jsx)(`b`,{children:`In Documents`}),` keeps the file and all its earlier versions in one place, the same place every other document lives. The record just points at it — so when a candidate is submitted for a job, the submission shows the very same file, and replacing it updates both at once. `,(0,l.jsx)(`b`,{children:`On the record itself`}),` is the older way: each record keeps its own copy of the history, which is why the same résumé could end up recorded several times over and the copies could disagree.`]})]}),h.fileVersioning.store===`documents`&&(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginBottom:10},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`List of attached documents is kept in`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`documentIds`,value:h.fileVersioning.linkField??``,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,linkField:e.target.value})})]}),(0,l.jsxs)(`div`,{style:{flex:1.6},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Old history fields to clear off the record`}),(0,l.jsx)(s.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`resumeHistory`,value:h.fileVersioning.clearRecordKeys??[],onChange:e=>P(`fileVersioning`,{...h.fileVersioning,clearRecordKeys:e})})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1.4},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Which uploads`}),(0,l.jsx)(s.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`resume`,value:h.fileVersioning.fields??[],onChange:e=>P(`fileVersioning`,{...h.fileVersioning,fields:e})})]}),(0,l.jsxs)(`div`,{style:{flex:.7},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`How many to keep`}),(0,l.jsx)(s.Input,{size:`small`,type:`number`,min:1,value:h.fileVersioning.keep??2,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,keep:Number(e.target.value)||1})})]}),(0,l.jsxs)(`div`,{style:{flex:1.4},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Where the files are grouped`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`candidates/{recordId}/resume`,value:h.fileVersioning.s3Prefix??``,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,s3Prefix:e.target.value})})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.fileVersioning.deleteEvicted,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,deleteEvicted:e})}),(0,l.jsx)($,{style:{fontSize:13},children:`Also delete the file once it drops off the end`})]}),(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:6},children:`Leave that switch OFF unless you are sure. With it off, an older file simply stops being shown and can still be recovered. With it on, it is deleted from storage permanently and cannot be brought back. Keeping 2 means a third upload pushes the first one off the end.`})]})]}),(0,l.jsx)(zE,{icon:(0,l.jsx)(c.DatabaseOutlined,{}),title:`Denormalizations`,description:`Copy fields from ANOTHER module's record onto this payload before insert (e.g. a submission snapshotting job title/client).`,rules:h.denormalizations??[],columns:R,onAdd:()=>w({index:null,rule:null}),onEdit:(e,t)=>w({index:e,rule:t}),onDelete:e=>P(`denormalizations`,(h.denormalizations??[]).filter((t,n)=>n!==e))}),(0,l.jsx)(zE,{icon:(0,l.jsx)(c.ApartmentOutlined,{}),title:`Array Enrichments`,description:`Enrich a payload array of ids (e.g. recruitersData) into objects carrying looked-up fields (name, email) before insert.`,rules:h.arrayEnrichments??[],columns:z,onAdd:()=>E({index:null,rule:null}),onEdit:(e,t)=>E({index:e,rule:t}),onDelete:e=>P(`arrayEnrichments`,(h.arrayEnrichments??[]).filter((t,n)=>n!==e))}),(0,l.jsx)(zE,{icon:(0,l.jsx)(c.DatabaseOutlined,{}),title:`File Field Maps`,description:`Turn an uploaded file field into a nested object (location + filename + who/when) or an array of such objects, instead of a flat S3 path string — needed for schemas like resume/passport/visa.`,rules:h.fileFieldMaps??[],columns:B,onAdd:()=>O({index:null,rule:null}),onEdit:(e,t)=>O({index:e,rule:t}),onDelete:e=>P(`fileFieldMaps`,(h.fileFieldMaps??[]).filter((t,n)=>n!==e))}),(0,l.jsxs)(Z,{title:`Sanitize Fields`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:`Trim and HTML-escape these payload fields before anything else runs — basic XSS-safety for free-text fields (e.g. firstName/lastName) that might later be embedded in an HTML activity comment or email.`}),(0,l.jsx)(s.Select,{mode:`tags`,style:{width:`100%`},placeholder:`firstName, lastName, email`,value:h.sanitizeFields??[],onChange:e=>P(`sanitizeFields`,e)})]}),(0,l.jsxs)(Z,{title:`Defaults`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:`Set a field only when the payload doesn't already carry a non-blank value — status defaults, empty arrays.`}),(0,l.jsx)(kE,{rows:ME(h.defaults),onChange:e=>P(`defaults`,NE(e)),keyPlaceholder:`internalSubmissionStatus.internalSubmissionStatusText`,valuePlaceholder:`"Under Evaluation"`})]}),(0,l.jsx)(zE,{icon:(0,l.jsx)(c.ApartmentOutlined,{}),title:`Hierarchy Expansions`,description:`Walk the reporting chain up (toward admin) or down (toward a team) from a seed user, publishing the result as {{hierarchy.<name>}} for Related Updates / Notify to use.`,rules:h.hierarchyExpands??[],columns:V,onAdd:()=>A({index:null,rule:null}),onEdit:(e,t)=>A({index:e,rule:t}),onDelete:e=>P(`hierarchyExpands`,(h.hierarchyExpands??[]).filter((t,n)=>n!==e))}),(0,l.jsx)(zE,{icon:(0,l.jsx)(c.ThunderboltOutlined,{}),title:`Related Updates`,description:`Best-effort side-effect writes to other collections after a successful insert — board state, activity logs. Combine with ForEach + a Hierarchy Expansion to seed one document per user in a chain.`,rules:h.relatedUpdates??[],columns:H,onAdd:()=>M({index:null,rule:null}),onEdit:(e,t)=>M({index:e,rule:t}),onDelete:e=>P(`relatedUpdates`,(h.relatedUpdates??[]).filter((t,n)=>n!==e))}),(0,l.jsxs)(Z,{title:`Notify`,styles:{body:{paddingTop:8}},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.notify,onChange:e=>P(`notify`,e?{action:``,subjectDefault:``,bodyDefault:``,toReportingManager:!1,toHierarchy:``}:null)}),(0,l.jsx)($,{style:{fontSize:13},children:`Send a best-effort email after a successful insert`})]}),h.notify&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Action (matched against an EmailTemplates doc)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`internalSubmit`,value:h.notify.action??``,onChange:e=>P(`notify`,{...h.notify,action:e.target.value}),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Notify entire hierarchy chain`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},allowClear:!0,placeholder:`pick a Hierarchy Expansion`,value:h.notify.toHierarchy||void 0,onChange:e=>P(`notify`,{...h.notify,toHierarchy:e??``}),options:N.map(e=>({value:e,label:e}))})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.notify.toReportingManager,onChange:e=>P(`notify`,{...h.notify,toReportingManager:e})}),(0,l.jsx)($,{style:{fontSize:13},children:`Also notify the caller's direct reporting manager`})]}),(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Default subject`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`New submission`,value:h.notify.subjectDefault??``,onChange:e=>P(`notify`,{...h.notify,subjectDefault:e.target.value})})]}),(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Default body (used when no EmailTemplates doc matches)`}),(0,l.jsx)(s.Input.TextArea,{rows:4,value:h.notify.bodyDefault??``,onChange:e=>P(`notify`,{...h.notify,bodyDefault:e.target.value}),className:`fg-mono-input`})]})]})]}),(0,l.jsxs)(Z,{title:`Cache Invalidate`,styles:{body:{paddingTop:8}},children:[(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:[`Redis key patterns (with `,`{{field}}`,` tokens) to SCAN+DEL after a successful insert.`]}),(0,l.jsx)(s.Select,{mode:`tags`,style:{width:`100%`},placeholder:`jobs:{{tenantId}}:{{businessId}}:{{businessUnitId}}:*`,value:h.cacheInvalidate??[],onChange:e=>P(`cacheInvalidate`,e)})]})]})]})}),(0,l.jsx)(PE,{open:!!C,rule:C?.rule,onClose:()=>w(null),onSave:e=>{P(`denormalizations`,C.index===null?[...h.denormalizations??[],e]:(h.denormalizations??[]).map((t,n)=>n===C.index?e:t)),w(null)}},C?`denorm-${C.index??`new`}`:`denorm-closed`),(0,l.jsx)(FE,{open:!!T,rule:T?.rule,onClose:()=>E(null),onSave:e=>{P(`arrayEnrichments`,T.index===null?[...h.arrayEnrichments??[],e]:(h.arrayEnrichments??[]).map((t,n)=>n===T.index?e:t)),E(null)}},T?`enrich-${T.index??`new`}`:`enrich-closed`),(0,l.jsx)(IE,{open:!!D,rule:D?.rule,onClose:()=>O(null),onSave:e=>{P(`fileFieldMaps`,D.index===null?[...h.fileFieldMaps??[],e]:(h.fileFieldMaps??[]).map((t,n)=>n===D.index?e:t)),O(null)}},D?`filemap-${D.index??`new`}`:`filemap-closed`),(0,l.jsx)(LE,{open:!!k,rule:k?.rule,onClose:()=>A(null),onSave:e=>{P(`hierarchyExpands`,k.index===null?[...h.hierarchyExpands??[],e]:(h.hierarchyExpands??[]).map((t,n)=>n===k.index?e:t)),A(null)}},k?`hier-${k.index??`new`}`:`hier-closed`),(0,l.jsx)(RE,{open:!!j,rule:j?.rule,hierarchyNames:N,onClose:()=>M(null),onSave:e=>{P(`relatedUpdates`,j.index===null?[...h.relatedUpdates??[],e]:(h.relatedUpdates??[]).map((t,n)=>n===j.index?e:t)),M(null)}},j?`ru-${j.index??`new`}`:`ru-closed`)]})}var{Text:HE}=s.Typography,UE=[`beforeCreate`,`afterCreate`,`beforeUpdate`,`afterUpdate`,`beforeDelete`,`afterDelete`],WE=[`sanitizeFields`,`generateSequence`,`duplicateCheck`,`copyFields`,`arrayEnrich`,`setDefaults`,`resolve`,`updateRelated`,`notify`,`invalidateCache`,`webhook`,`linkDocuments`,`captureFileUrls`,`resolveUploads`],GE={resolveUploads:{text:`Turn one submit into a list with ONE ENTRY PER UPLOADED FILE, so the actions after it can create one record per document instead of a single record holding all of them. Works for both shapes: a repeatable (Add Row) group gives one entry per row — carrying that row’s own values — and a multi-file upload field gives one entry per file. Publishes {{uploads.<as>}} (all entries), {{uploads.<as>First}} (the first, as an object) and {{uploads.<as>Rest}} (all but the first). Each entry has groupName, groupLabel, groupModule, fieldName, rowIndex, fileName, uniqueName, contentType, fileSize, s3Key, tenantId/businessId/businessUnitId, the row under "row", and the row’s own values at the top level. Leave "groups" empty for every group with an upload field. Set "heading" to "label" to use the group heading text instead of its name — note the heading changes whenever an admin renames the group, while the name does not.`,sample:{as:`docs`,groups:[],includeEmptyRows:!1,heading:`name`}},updateRelated:{text:`Update this record or another configured collection with values from the event. For uploaded files, after* workflows can read {{__uploads.<field>.fieldName|fileName|contentType|fileSize|s3Key|uniqueName}}. Add a $notEmpty condition on the upload s3Key so unrelated edits do not run it. To create one record PER FILE, run resolveUploads first, then set forEach to "uploads.<as>Rest" with insertIfMissing (an extraFilter on {{forEach.value.s3Key}} keeps a re-save from inserting duplicates). "unset" removes exact fields and "unsetPrefixes" removes a repeatable upload’s generated keys (document[0], document[1], …) in the SAME write — use it on the record being reused as the first row, and put that action LAST with Stop on error enabled so nothing is cleared when the inserts failed.`,sample:{targetModule:`documents`,matchField:`_id`,scopeTenant:!0,set:{module:`{{module}}`,moduleRefId:`{{_id}}`,fieldName:`{{__uploads.docPan.fieldName}}`,fileName:`{{__uploads.docPan.fileName}}`,contentType:`{{__uploads.docPan.contentType}}`,fileSize:`{{__uploads.docPan.fileSize}}`,s3Key:`{{__uploads.docPan.s3Key}}`,uniqueName:`{{__uploads.docPan.uniqueName}}`}}},linkDocuments:{text:`Share one record’s uploaded files with another, without making a second copy. Used so a submission shows the candidate’s résumé and paperwork, and anything uploaded during the submission appears on the candidate too. Both records get the list of document ids written onto them.`,sample:{sourceModule:`candidates`,sourceIdField:`applicantId`,targetModule:`submissions`,linkField:`documentIds`,fieldNames:[],backLink:!0}},captureFileUrls:{text:`File a document that was generated elsewhere and handed to us as a link — a formatted résumé or an attestation PDF — so it sits with every other attachment instead of being a loose field on the record.`,sample:{linkField:`documentIds`,files:[{urlField:`resumeUrl`,nameField:`resumeFileName`,fieldName:`formattedResume`,defaultName:`Formatted Resume.pdf`},{urlField:`attestationUrl`,nameField:`attestationFileName`,fieldName:`attestation`,defaultName:`Attestation.pdf`}]}}};function KE(e){return JSON.stringify(e??{},null,2)}function qE({action:e,onChange:t,onRemove:n}){let[r,i]=(0,o.useState)(()=>KE(e.config)),[a,u]=(0,o.useState)(!1);return(0,l.jsxs)(`div`,{style:{border:`1px solid #e2e8f0`,borderRadius:8,padding:10,marginTop:8},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`},children:[(0,l.jsx)(s.Select,{size:`small`,style:{width:200},showSearch:!0,value:e.type||void 0,placeholder:`action type`,options:WE.map(e=>({value:e})),onChange:n=>{let r=e.config&&Object.keys(e.config).length>0,i=GE[n]?.sample;t(r||!i?{...e,type:n}:{...e,type:n,config:i})}}),a&&(0,l.jsx)(s.Tag,{color:`red`,children:`invalid JSON`}),(0,l.jsx)(s.Button,{size:`small`,type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),style:{marginLeft:`auto`},onClick:n})]}),GE[e.type]&&(0,l.jsx)(`p`,{style:{margin:`8px 0 0`,fontSize:12,color:`#64748b`,lineHeight:1.5},children:GE[e.type].text}),(0,l.jsx)(s.Input.TextArea,{rows:Math.min(14,Math.max(3,r.split(`
17
+ `).length)),value:r,className:`fg-mono-input`,style:{marginTop:8,fontSize:12},onChange:n=>{i(n.target.value);try{t({...e,config:JSON.parse(n.target.value||`{}`)}),u(!1)}catch{u(!0)}}})]})}function JE({open:e,doc:t,moduleOptions:n,onClose:r,onSave:i}){let[a,u]=(0,o.useState)(()=>({key:``,module:``,event:`afterCreate`,order:10,isActive:!0,stopOnError:!1,condition:{},actions:[],...t??{}})),[d,f]=(0,o.useState)(()=>KE(t?.condition)),[p,m]=(0,o.useState)(!1),h=(e,t)=>u(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:r,width:840,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.ApartmentOutlined,{}),` `,t?`Edit Workflow`:`New Workflow`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!a.key?.trim())return s.message.error(`Key is required`);if(!a.module?.trim())return s.message.error(`Module is required`);if(p)return s.message.error(`Condition JSON is invalid`);if(!(a.actions??[]).length)return s.message.error(`At least one action is required`);if((a.actions??[]).some(e=>!e.type))return s.message.error(`Every action needs a type`);let e={...a};delete e.id,delete e._id,i(e)},children:`Save Workflow`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)(HE,{type:`secondary`,style:{fontSize:12},children:`Key`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`jobs-create-after`,value:a.key??``,onChange:e=>h(`key`,e.target.value),className:`fg-mono-input`,disabled:!!t})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)(HE,{type:`secondary`,style:{fontSize:12},children:`Module`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},showSearch:!0,value:a.module||void 0,options:n,onChange:e=>h(`module`,e),placeholder:`jobs`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)(HE,{type:`secondary`,style:{fontSize:12},children:`Event`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:a.event,options:UE.map(e=>({value:e})),onChange:e=>h(`event`,e)})]}),(0,l.jsxs)(`div`,{style:{width:90},children:[(0,l.jsx)(HE,{type:`secondary`,style:{fontSize:12},children:`Order`}),(0,l.jsx)(s.InputNumber,{size:`small`,style:{width:`100%`},value:a.order??10,onChange:e=>h(`order`,e??10)})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:24,marginTop:12},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:a.isActive!==!1,onChange:e=>h(`isActive`,e)}),(0,l.jsx)(HE,{style:{fontSize:13},children:`Active`})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:a.stopOnError===!0,onChange:e=>h(`stopOnError`,e)}),(0,l.jsx)(s.Tooltip,{title:`Off (default): if an action fails after the record is saved, it is logged and the next action still runs — right for independent side effects like a notification and a cache clear. On: the remaining actions are skipped, for a sequence whose later steps are only safe because the earlier ones worked (creating records and THEN clearing the data they came from).`,children:(0,l.jsx)(HE,{style:{fontSize:13},children:`Stop on error`})})]})]}),(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsxs)(HE,{type:`secondary`,style:{fontSize:12},children:[`Condition (all must match the payload; empty = always run) `,p&&(0,l.jsx)(s.Tag,{color:`red`,children:`invalid JSON`})]}),(0,l.jsx)(s.Input.TextArea,{rows:2,value:d,className:`fg-mono-input`,style:{fontSize:12},onChange:e=>{f(e.target.value);try{h(`condition`,JSON.parse(e.target.value||`{}`)),m(!1)}catch{m(!0)}}})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginTop:14},children:[(0,l.jsx)(HE,{strong:!0,style:{fontSize:13},children:`Actions (run in order)`}),(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>h(`actions`,[...a.actions??[],{type:``,config:{}}]),children:`Add Action`})]}),(a.actions??[]).map((e,t)=>(0,l.jsx)(qE,{action:e,onChange:e=>h(`actions`,a.actions.map((n,r)=>r===t?e:n)),onRemove:()=>h(`actions`,a.actions.filter((e,n)=>n!==t))},t)),(0,l.jsxs)(HE,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:8},children:[`Config supports `,(0,l.jsx)(`code`,{children:`{{field.path}}`}),`, `,(0,l.jsx)(`code`,{children:`{{now}}`}),`, `,(0,l.jsx)(`code`,{children:`{{__userId}}`}),`,`,` `,(0,l.jsx)(`code`,{children:`{{__userName}}`}),`, and `,(0,l.jsx)(`code`,{children:`{{hierarchy.<name>}}`}),` from a `,(0,l.jsx)(`code`,{children:`resolve`}),` action.`]})]})})}function YE(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)(!0),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(null),[h,g]=(0,o.useState)(``),[_,v]=(0,o.useState)(0);(0,o.useEffect)(()=>{let e=!1;return n.$r(`workflows`).then(n=>{e||t(n)}).catch(t=>{e||f(t?.message||`Failed to load workflows`)}).finally(()=>{e||u(!1)}),()=>{e=!0}},[_]),(0,o.useEffect)(()=>{n.Sr().then(e=>i(hS(e).map(({value:e,label:t})=>({value:e,label:t})))).catch(()=>i([]))},[]);let y=()=>{u(!0),f(``),v(e=>e+1)};async function b(e){try{await n.li(`workflows`,e),s.message.success(`Workflow "${e.key}" saved`),m(null),y()}catch(e){s.message.error(e?.message||`Could not save workflow`)}}async function x(e){try{await n.ur(`workflows`,e),s.message.success(`Workflow "${e}" deleted`),y()}catch(e){s.message.error(e?.message||`Could not delete workflow`)}}async function S(e,t){let r={...e};delete r.id,delete r._id;try{await n.li(`workflows`,{...r,isActive:t}),y()}catch(e){s.message.error(e?.message||`Could not update workflow`)}}let C=(0,o.useMemo)(()=>e.filter(e=>!h||e.module===h),[e,h]);return(0,l.jsxs)(`div`,{className:`fg-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.ApartmentOutlined,{}),title:`Workflows`,extra:(0,l.jsxs)(s.Space,{size:8,children:[(0,l.jsx)(s.Select,{size:`small`,style:{minWidth:160},allowClear:!0,placeholder:`Filter by module`,options:r,value:h||void 0,onChange:e=>g(e??``)}),(0,l.jsx)(s.Button,{size:`small`,icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:y,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>m({doc:null}),children:`New Workflow`})]}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsxs)(HE,{type:`secondary`,style:{fontSize:13},children:[`Event-driven behavior per module — reference ids, duplicate checks, snapshots, hierarchy fan-outs, board updates, notifications, cache — executed by the platform Workflow Engine on every create/update/delete.`,(0,l.jsx)(s.Tag,{style:{marginLeft:8},children:`before*`}),` actions can block the write; `,(0,l.jsx)(s.Tag,{children:`after*`}),` actions are best-effort.`]})]}),(0,l.jsxs)(Z,{styles:{body:{paddingTop:8}},children:[d&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:d,style:{marginBottom:12}}),(0,l.jsxs)(s.Spin,{spinning:a,children:[(0,l.jsxs)(`div`,{style:{marginBottom:8},children:[(0,l.jsx)(s.Badge,{count:C.length,showZero:!0,color:`var(--color-brand)`}),` `,(0,l.jsx)(HE,{type:`secondary`,style:{fontSize:12},children:`workflows`})]}),(0,l.jsx)(s.Table,{rowKey:`key`,dataSource:C,columns:[{title:`Key`,dataIndex:`key`,key:`key`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Module`,dataIndex:`module`,key:`module`,width:130,render:e=>(0,l.jsx)(s.Tag,{color:`geekblue`,children:e})},{title:`Event`,dataIndex:`event`,key:`event`,width:130,render:e=>(0,l.jsx)(s.Tag,{color:String(e).startsWith(`before`)?`purple`:`green`,children:e})},{title:`Actions`,key:`acts`,render:(e,t)=>(0,l.jsx)(s.Space,{size:4,wrap:!0,children:(t.actions??[]).map((e,t)=>(0,l.jsx)(s.Tag,{style:{margin:0},children:e.type},t))})},{title:`Order`,dataIndex:`order`,key:`order`,width:70,align:`center`},{title:`Active`,key:`active`,width:80,align:`center`,render:(e,t)=>(0,l.jsx)(s.Switch,{size:`small`,checked:t.isActive!==!1,onChange:e=>S(t,e)})},{title:``,key:`ops`,width:90,align:`right`,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>m({doc:t})})}),(0,l.jsx)(s.Popconfirm,{title:`Delete workflow "${t.key}"?`,onConfirm:()=>x(t.key),children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],pagination:!1,size:`small`,className:`fg-table`,locale:{emptyText:(0,l.jsx)(s.Empty,{description:`No workflows configured.`,image:s.Empty.PRESENTED_IMAGE_SIMPLE})}})]})]}),(0,l.jsx)(JE,{open:!!p,doc:p?.doc,moduleOptions:r,onClose:()=>m(null),onSave:b},p?p.doc?.key??`new`:`closed`)]})}var{Text:XE}=s.Typography,ZE=e=>e?._id??e?.id,QE=`masters`;function $E(){return{tenantId:localStorage.getItem(`tenantId`)||``,businessId:localStorage.getItem(`businessId`)||``,businessUnitId:localStorage.getItem(`businessUnitId`)||``}}function eD(e){return e&&typeof e==`object`?e.$oid??e.oid??e.id??``:e??``}function tD(e,t){return t.map(t=>eD(e?.[t])).find(e=>e!=null&&e!==``)??``}function nD(e,t){return[[t.tenantId,[`tid`,`tenantId`]],[t.businessId,[`bid`,`businessId`]],[t.businessUnitId,[`buid`,`businessUnitId`]]].every(([t,n])=>{if(!t)return!0;let r=String(tD(e,n));return!r||r===String(t)})}function rD(e){return Array.isArray(e?.masterFeeds)?e.masterFeeds:[]}function iD(e){return e.reduce((e,t)=>Math.max(e,Number(t?.uniqueId)||0),0)+1}function aD(e){return Array.isArray(e?.taxHistory)?e.taxHistory:[]}function oD(e){let t=e?.taxValue;if(t!=null&&t!==``)return Number(t);let n=aD(e).at(-1),r=n?.taxValue??n?.value;return r!=null&&r!==``?Number(r):void 0}function sD(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}function cD(e){let t=aD(e).at(-1);return t?.updatedAt??t?.timestamp??e?.updatedAt}function lD({open:e,record:t,onClose:r,onSaved:i}){let[a]=s.Form.useForm(),[c,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(!1),h=(0,o.useRef)(null),g=!!t;(0,o.useEffect)(()=>{e&&queueMicrotask(()=>{a.resetFields(),a.setFieldsValue({name:t?.name??void 0,taxValue:oD(t)}),f(t?.name?[{label:t.name,value:t.name}]:[])})},[e,t,a]);function _(e){if(h.current&&clearTimeout(h.current),!e||e.trim().length<2){f([]);return}m(!0),h.current=setTimeout(()=>{n.Nr(e.trim()).then(f).catch(()=>f([])).finally(()=>m(!1))},350)}async function v(){let e=await a.validateFields(),r=Number(e.taxValue),o={name:e.name,taxValue:r,taxHistory:{taxValue:r}};u(!0);try{g?await n.vi(`locations`,ZE(t),o):await n.er(`locations`,o),s.message.success(g?`Tax updated`:`Location and tax created`),i()}catch(e){s.message.error(e?.message||`Could not save location and tax`)}finally{u(!1)}}return(0,l.jsx)(s.Modal,{open:e,onCancel:r,onOk:v,confirmLoading:c,destroyOnHidden:!0,title:g?`Edit Tax — ${t?.name??``}`:`New Location`,children:(0,l.jsxs)(s.Form,{form:a,layout:`vertical`,children:[(0,l.jsx)(s.Form.Item,{name:`name`,label:`Location`,rules:[{required:!0,message:`Location is required`}],tooltip:g?`Location cannot be changed once created — only the tax is editable.`:`Search and pick from the location master.`,children:(0,l.jsx)(s.Select,{showSearch:!0,disabled:g,placeholder:`Type at least 2 characters to search…`,filterOption:!1,onSearch:_,notFoundContent:p?`Searching…`:null,options:d})}),(0,l.jsx)(s.Form.Item,{name:`taxValue`,label:`Tax`,rules:[{required:!0,message:`Tax is required`},{type:`number`,min:0,max:100,message:`Tax must be between 0 and 100`}],children:(0,l.jsx)(s.InputNumber,{style:{width:`100%`},min:0,max:100,step:.01,suffix:`%`,placeholder:`8.875`,autoFocus:g})})]})})}function uD({record:e}){let t=[...aD(e)].reverse();return t.length?(0,l.jsx)(s.Space,{direction:`vertical`,size:4,style:{padding:`4px 8px`},children:t.map((e,t)=>(0,l.jsxs)(s.Space,{size:10,children:[(0,l.jsxs)(s.Tag,{color:t===0?`green`:`default`,style:{margin:0},children:[e.taxValue??e.value,`%`]}),(0,l.jsx)(XE,{type:`secondary`,style:{fontSize:12},children:sD(e.updatedAt??e.timestamp)}),t===0&&(0,l.jsx)(XE,{type:`secondary`,style:{fontSize:12},children:`(current)`})]},t))}):(0,l.jsx)(s.Empty,{image:s.Empty.PRESENTED_IMAGE_SIMPLE,description:`No tax history yet`})}function dD(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null);function p(){i(!0),n.Qr(`locations`).then(({items:e})=>t(e)).catch(e=>s.message.error(e?.message||`Could not load locations`)).finally(()=>i(!1))}(0,o.useEffect)(()=>{queueMicrotask(p)},[]);async function m(e){try{await n.lr(`locations`,e),s.message.success(`Location deleted`),p()}catch(e){s.message.error(e?.message||`Could not delete location`)}}return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsx)(Z,{title:`${e.length} location${e.length===1?``:`s`}`,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:p,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{f(null),u(!0)},children:`New location`})]}),children:(0,l.jsx)(s.Table,{rowKey:ZE,columns:[{title:`Location`,dataIndex:`name`,key:`name`},{title:`Tax`,key:`taxValue`,width:100,render:(e,t)=>{let n=oD(t);return Number.isFinite(n)?(0,l.jsxs)(s.Tag,{color:`blue`,children:[n,`%`]}):`—`}},{title:`Tax updated`,key:`taxUpdatedAt`,render:(e,t)=>sD(cD(t))},{title:`Created`,key:`createdAt`,responsive:[`lg`],render:(e,t)=>sD(t?.createdAt)},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit tax`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{f(t),u(!0)}})}),(0,l.jsx)(s.Popconfirm,{title:`Delete this location?`,onConfirm:()=>m(ZE(t)),children:(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})})]})}],dataSource:e,loading:r,size:`small`,pagination:!1,className:`fg-table`,expandable:{expandedRowRender:e=>(0,l.jsx)(uD,{record:e}),rowExpandable:e=>aD(e).length>0},locale:{emptyText:`No locations yet. Click "New location" to add one.`}})}),(0,l.jsx)(lD,{open:a,record:d,onClose:()=>u(!1),onSaved:()=>{u(!1),p()}})]})}function fD({open:e,record:t,onClose:r,onSaved:i}){let[a]=s.Form.useForm(),[u,d]=(0,o.useState)(!1),f=!!t,p=s.Form.useWatch(`masterName`,a),m=s.Form.useWatch(`masterFeeds`,a)??[],h=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(p??t?.masterName??``).trim().toLowerCase()),g=m.map(e=>({label:String(e?.name??``).trim()||`Status ${e?.uniqueId??``}`,value:Number(e?.uniqueId)})).filter(e=>Number.isInteger(e.value)&&e.value>0);function _(e,t){if(!t){a.setFieldValue([`masterFeeds`,e,`isInitialStatus`],!1);return}(a.getFieldValue(`masterFeeds`)??[]).forEach((t,n)=>{a.setFieldValue([`masterFeeds`,n,`isInitialStatus`],n===e)})}function v(e,t){a.setFieldValue([`masterFeeds`,e,`isTerminalStatus`],t),t&&a.setFieldValue([`masterFeeds`,e,`allowedNextStatusIds`],[])}(0,o.useEffect)(()=>{e&&queueMicrotask(()=>{a.resetFields();let e=t?.masterName??``,n=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(e).trim().toLowerCase()),r=rD(t),i=r.length?r.map(e=>({...e})):[{uniqueId:1,name:``,type:`neutral`,status:!0,isdeleted:!1}];if(n&&!i.some(e=>e?.status!==!1&&e?.isdeleted!==!0&&e?.isInitialStatus===!0)){let e=i.findIndex(e=>e?.status!==!1&&e?.isdeleted!==!0);e>=0&&(i=i.map((t,n)=>({...t,isInitialStatus:n===e,isTerminalStatus:t?.isTerminalStatus===!0,allowedNextStatusIds:Array.isArray(t?.allowedNextStatusIds)?t.allowedNextStatusIds:[]})))}a.setFieldsValue({masterName:e,schemaVersion:t?.schemaVersion??1,masterFeeds:i})})},[e,t,a]),(0,o.useEffect)(()=>{!e||!h||(Number(a.getFieldValue(`schemaVersion`))||1)<2&&a.setFieldValue(`schemaVersion`,2)},[e,h,a]);async function y(){let e=await a.validateFields(),r=$E(),o=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(e.masterName??``).trim().toLowerCase()),c=(e.masterFeeds??[]).map((e,t)=>{let n=Number(e.uniqueId)||t+1,r=o&&e.isTerminalStatus===!0,i=o&&!r?[...new Set((e.allowedNextStatusIds??[]).map(Number).filter(e=>Number.isInteger(e)&&e>0&&e!==n))]:[];return{uniqueId:n,name:String(e.name??``).trim(),type:String(e.type??``).trim(),status:e.status!==!1,...o?{isInitialStatus:e.isInitialStatus===!0,isTerminalStatus:r,allowedNextStatusIds:i}:{},isdeleted:e.isdeleted===!0}}).filter(e=>e.name);if(o){let e=c.filter(e=>e.status&&!e.isdeleted&&e.isInitialStatus);if(e.length===0){let t=c.findIndex(e=>e.status&&!e.isdeleted);t>=0&&(c[t]={...c[t],isInitialStatus:!0},e=[c[t]],a.setFieldValue([`masterFeeds`,t,`isInitialStatus`],!0))}if(e.length!==1){s.message.error(`Client Submission Status must have exactly one active Initial Status.`);return}}let l={...r,tid:r.tenantId,bid:r.businessId,buid:r.businessUnitId,schemaVersion:o?Math.max(2,Number(e.schemaVersion)||2):Number(e.schemaVersion)||1,masterName:e.masterName.trim(),masterFeeds:c};d(!0);try{f?await n.vi(QE,ZE(t),l):await n.er(QE,l),s.message.success(f?`Master value updated`:`Master value created`),i()}catch(e){s.message.error(e?.message||`Could not save master value`)}finally{d(!1)}}return(0,l.jsx)(s.Modal,{open:e,onCancel:r,onOk:y,confirmLoading:u,destroyOnHidden:!0,title:f?`Edit Master Feed`:`New Master Feed`,width:1040,children:(0,l.jsxs)(s.Form,{form:a,layout:`vertical`,children:[(0,l.jsx)(s.Form.Item,{name:`masterName`,label:`Master Name`,rules:[{required:!0,message:`Master name is required`}],children:(0,l.jsx)(s.Input,{placeholder:`blacklistType`,autoFocus:!f,disabled:f})}),(0,l.jsx)(s.Form.Item,{name:`schemaVersion`,label:`Schema Version`,children:(0,l.jsx)(s.InputNumber,{min:1,style:{width:`100%`}})}),(0,l.jsx)(s.Form.List,{name:`masterFeeds`,children:(e,{add:t,remove:n})=>(0,l.jsxs)(s.Space,{direction:`vertical`,style:{width:`100%`},size:10,children:[e.map(({key:e,name:t})=>(0,l.jsxs)(s.Space,{align:`baseline`,wrap:!0,children:[(0,l.jsx)(s.Form.Item,{name:[t,`uniqueId`],label:`ID`,rules:[{required:!0,message:`ID required`}],children:(0,l.jsx)(s.InputNumber,{min:1,style:{width:90}})}),(0,l.jsx)(s.Form.Item,{name:[t,`name`],label:`Name`,rules:[{required:!0,message:`Name required`}],children:(0,l.jsx)(s.Input,{placeholder:`Dropdown label`,style:{width:280}})}),(0,l.jsx)(s.Form.Item,{name:[t,`type`],label:`Type`,children:(0,l.jsx)(s.Select,{allowClear:!0,placeholder:`Select type`,style:{width:120},options:[{label:`Positive`,value:`positive`},{label:`Neutral`,value:`neutral`},{label:`Negative`,value:`negative`}]})}),(0,l.jsx)(s.Form.Item,{name:[t,`status`],label:`Status`,initialValue:!0,children:(0,l.jsx)(s.Select,{style:{width:110},options:[{label:`Active`,value:!0},{label:`Inactive`,value:!1}]})}),(0,l.jsx)(s.Form.Item,{name:[t,`isdeleted`],label:`Deleted`,initialValue:!1,children:(0,l.jsx)(s.Select,{style:{width:110},options:[{label:`No`,value:!1},{label:`Yes`,value:!0}]})}),h&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Form.Item,{name:[t,`isInitialStatus`],label:`Initial`,initialValue:!1,tooltip:`The initial status is the only option shown before a candidate has a client submission status. Only one active initial status is allowed.`,children:(0,l.jsx)(s.Select,{style:{width:100},onChange:e=>_(t,e===!0),options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]})}),(0,l.jsx)(s.Form.Item,{name:[t,`isTerminalStatus`],label:`End Status`,initialValue:!1,tooltip:`End Status stops the configured client submission flow. Once reached, Change Status is hidden and no next statuses are allowed.`,children:(0,l.jsx)(s.Select,{style:{width:105},onChange:e=>v(t,e===!0),options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]})}),(0,l.jsx)(s.Form.Item,{noStyle:!0,shouldUpdate:(e,n)=>e?.masterFeeds?.[t]?.isTerminalStatus!==n?.masterFeeds?.[t]?.isTerminalStatus||e?.masterFeeds?.[t]?.uniqueId!==n?.masterFeeds?.[t]?.uniqueId||e?.masterFeeds!==n?.masterFeeds,children:({getFieldValue:e})=>{let n=e([`masterFeeds`,t,`isTerminalStatus`])===!0,r=Number(e([`masterFeeds`,t,`uniqueId`]));return(0,l.jsx)(s.Form.Item,{name:[t,`allowedNextStatusIds`],label:`Allowed Next Statuses`,tooltip:n?`End Status cannot move to another status.`:`Only these statuses will appear after the current status is saved.`,children:(0,l.jsx)(s.Select,{mode:`multiple`,allowClear:!0,disabled:n,placeholder:n?`End status`:`Select next statuses`,style:{minWidth:280},options:g.filter(e=>e.value!==r)})})}})]}),(0,l.jsx)(s.Tooltip,{title:`Remove row`,children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),onClick:()=>n(t)})})]},e)),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>t({uniqueId:iD(a.getFieldValue(`masterFeeds`)??[]),name:``,type:`neutral`,status:!0,isdeleted:!1,...h?{isInitialStatus:!1,isTerminalStatus:!1,allowedNextStatusIds:[]}:{}}),children:`Add feed value`})]})})]})})}function pD(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null),[p,m]=(0,o.useState)(``);function h(){let e=$E();i(!0),n.Qr(QE,{limit:500}).then(({items:n})=>{let r=n.filter(t=>nD(t,e));t(r)}).catch(e=>s.message.error(e?.message||`Could not load master values`)).finally(()=>i(!1))}(0,o.useEffect)(()=>{queueMicrotask(h)},[]);async function g(e){try{await n.lr(QE,e),s.message.success(`Master value deleted`),h()}catch(e){s.message.error(e?.message||`Could not delete master value`)}}let _=p?e.filter(e=>String(e?.masterName??``).toLowerCase()===p.toLowerCase()):e,v=[...new Set(e.map(e=>e?.masterName).filter(Boolean))].sort((e,t)=>String(e).localeCompare(String(t))).map(e=>({label:e,value:e}));return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsx)(Z,{title:`${_.length} master${_.length===1?``:`s`}`,extra:(0,l.jsxs)(s.Space,{wrap:!0,children:[(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,placeholder:`Filter master name`,value:p||void 0,options:v,onChange:e=>m(e??``),style:{minWidth:220}}),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:h,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{f(null),u(!0)},children:`New master`})]}),children:(0,l.jsx)(s.Table,{rowKey:ZE,columns:[{title:`Master Name`,dataIndex:`masterName`,key:`masterName`,width:180},{title:`Feed Values`,key:`masterFeeds`,render:(e,t)=>(0,l.jsx)(s.Space,{wrap:!0,children:rD(t).filter(e=>!e.isdeleted).map(e=>(0,l.jsx)(s.Tag,{color:e.status===!1?`default`:`blue`,children:e.name},e.uniqueId??e.name))})},{title:`Count`,key:`count`,width:90,render:(e,t)=>rD(t).filter(e=>!e.isdeleted).length},{title:`Updated`,key:`updatedAt`,responsive:[`lg`],render:(e,t)=>sD(t?.updatedAt)},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{f(t),u(!0)}})}),(0,l.jsx)(s.Popconfirm,{title:`Delete this master?`,onConfirm:()=>g(ZE(t)),children:(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})})]})}],dataSource:_,loading:r,size:`small`,pagination:{pageSize:10,showSizeChanger:!0},className:`fg-table`,locale:{emptyText:`No masters yet. Click "New master" to add one.`}})}),(0,l.jsx)(fD,{open:a,record:d,onClose:()=>u(!1),onSaved:()=>{u(!1),h()}})]})}function mD(){return(0,l.jsxs)(`div`,{className:`fg-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.DatabaseOutlined,{}),title:`Master Collections`,children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(XE,{type:`secondary`,style:{fontSize:13},children:`Create, update, and delete master documents, then customize multiple dropdown values inside masterFeeds. Records are saved with the current tenant, business, business unit, and master name.`})]}),(0,l.jsx)(pD,{}),(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.DatabaseOutlined,{}),title:`Location Tax Master`,children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(XE,{type:`secondary`,style:{fontSize:13},children:`Pick a location from the master list and set its tax. Once added, only the tax can be changed — every change is kept in a timeline with its timestamp. Expand a row to see the full tax history.`})]}),(0,l.jsx)(dD,{})]})}var{Text:hD}=s.Typography,gD={employerMsaValidityDays:365,referralMsaValidityDays:365,expiryWarningDays:30};function _D(){let[e]=s.Form.useForm(),[t,r]=(0,o.useState)(!0),[i,a]=(0,o.useState)(!1),u=async()=>{r(!0);try{let t=await n.Wr();e.setFieldsValue({...gD,...t||{}})}catch(t){s.message.error(t?.message||`Could not load PO/MSA settings`),e.setFieldsValue(gD)}finally{r(!1)}};return(0,o.useEffect)(()=>{u()},[]),(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.SettingOutlined,{}),title:`PO/MSA Validity Settings`,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:u,disabled:i,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:i,onClick:async()=>{try{let t=await e.validateFields();a(!0);let r=await n.ci(t);e.setFieldsValue({...gD,...r||t}),s.message.success(`PO/MSA validity settings saved`)}catch(e){e?.errorFields||s.message.error(e?.message||`Could not save PO/MSA settings`)}finally{a(!1)}},children:`Save`})]}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(hD,{type:`secondary`,children:`Configure how long a signed MSA remains valid. Employer/referral status is calculated from the signed MSA date plus these values; no validity period is hardcoded in the onboarding UI.`})]}),(0,l.jsx)(Z,{title:`Validity Rules`,children:(0,l.jsx)(s.Spin,{spinning:t,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,initialValues:gD,style:{maxWidth:620},children:[(0,l.jsx)(s.Form.Item,{name:`employerMsaValidityDays`,label:`Employer MSA Validity Days`,tooltip:`Number of days an employer MSA remains active from its signed date.`,rules:[{required:!0,message:`Employer MSA validity is required`}],children:(0,l.jsx)(s.InputNumber,{min:1,max:3650,precision:0,style:{width:`100%`},addonAfter:`days`})}),(0,l.jsx)(s.Form.Item,{name:`referralMsaValidityDays`,label:`Referral MSA Validity Days`,tooltip:`Number of days a referral MSA remains active from its signed date.`,rules:[{required:!0,message:`Referral MSA validity is required`}],children:(0,l.jsx)(s.InputNumber,{min:1,max:3650,precision:0,style:{width:`100%`},addonAfter:`days`})}),(0,l.jsx)(s.Form.Item,{name:`expiryWarningDays`,label:`Expiry Warning Days`,tooltip:`Reserved for upcoming-expiry indicators and notifications.`,rules:[{required:!0,message:`Expiry warning days is required`}],children:(0,l.jsx)(s.InputNumber,{min:0,max:3650,precision:0,style:{width:`100%`},addonAfter:`days`})})]})})})]})}var{Text:vD,Title:yD}=s.Typography,bD=[{value:`Dashboard`,label:`Dashboard`,icon:(0,l.jsx)(c.DashboardOutlined,{})},{value:`ClientManagement`,label:`Client Management`,icon:(0,l.jsx)(c.BankOutlined,{})},{value:`EmployerManagement`,label:`Employer / Referral`,icon:(0,l.jsx)(c.TeamOutlined,{})},{value:`Candidates`,label:`Candidates`,icon:(0,l.jsx)(c.UsergroupAddOutlined,{})},{value:`Jobs`,label:`Jobs`,icon:(0,l.jsx)(c.FileTextOutlined,{})},{value:`Submissions`,label:`Submissions`,icon:(0,l.jsx)(c.FileTextOutlined,{})},{value:`Onboarding`,label:`Onboarding`,icon:(0,l.jsx)(c.UserOutlined,{})},{value:`Assignments`,label:`Assignments`,icon:(0,l.jsx)(c.AppstoreOutlined,{})},{value:`Timesheet`,label:`Timesheet`,icon:(0,l.jsx)(c.CalendarOutlined,{})},{value:`Campaign`,label:`Campaign`,icon:(0,l.jsx)(c.TeamOutlined,{})},{value:`FileProtectOutlined`,label:`PO / MSA`,icon:(0,l.jsx)(c.FileProtectOutlined,{})},{value:`FolderOpenOutlined`,label:`Batches`,icon:(0,l.jsx)(c.FolderOpenOutlined,{})},{value:`BankOutlined`,label:`Billing / Finance`,icon:(0,l.jsx)(c.BankOutlined,{})},{value:`SettingOutlined`,label:`Settings / Admin`,icon:(0,l.jsx)(c.SettingOutlined,{})},{value:`UploadOutlined`,label:`Upload`,icon:(0,l.jsx)(c.UploadOutlined,{})},{value:`AppstoreOutlined`,label:`General Module`,icon:(0,l.jsx)(c.AppstoreOutlined,{})}];function xD({option:e}){return(0,l.jsxs)(s.Space,{size:8,children:[(0,l.jsx)(`span`,{style:{display:`inline-flex`,fontSize:16},children:e.icon}),(0,l.jsx)(`span`,{children:e.label}),(0,l.jsx)(vD,{type:`secondary`,style:{fontSize:11},children:e.value})]})}function SD(e,t){let n=localStorage.getItem(`menu`);if(n)try{let r=JSON.parse(n),i=Array.isArray(r)?r:r?.menu;if(!Array.isArray(i))return;let a=String(e??t.menu_key??``).trim().toLowerCase(),o=e=>e.map(e=>{let n=String(e?.key??``).trim().toLowerCase()===a?{...e,icon:t.icon??e.icon,label:t.menu_name??e.label,status:String(t.status??e.status??`ACTIVE`).toLowerCase()}:e;return Array.isArray(n?.children)?{...n,children:o(n.children)}:n}),s=o(i);localStorage.setItem(`menu`,JSON.stringify(Array.isArray(r)?s:{...r,menu:s})),window.dispatchEvent(new Event(`menu:updated`))}catch{}}function CD(){let[e]=s.Form.useForm(),[t,n]=(0,o.useState)([]),[r,i]=(0,o.useState)(!0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null),[p,m]=(0,o.useState)(!1);async function h(){i(!0);try{n(await Rx())}catch(e){s.message.error(e.message||`Unable to load menus`)}finally{i(!1)}}(0,o.useEffect)(()=>{h()},[]);let g=(0,o.useMemo)(()=>t.filter(e=>!d||e.menu_id!==d.menu_id).map(e=>({label:e.menu_name,value:e.menu_id})),[d,t]);function _(){f(null),e.resetFields(),e.setFieldsValue({menu_type:`MENU`,display_order:t.length+1,status:`ACTIVE`}),m(!0)}function v(t){f(t),e.setFieldsValue(t),m(!0)}async function y(e){u(!0);try{d?(await Bx(d.menu_id,e),SD(d.menu_key,e)):await zx(e),s.message.success(d?`Menu updated`:`Menu created`),m(!1),await h()}catch(e){s.message.error(e.message||`Unable to save menu`)}finally{u(!1)}}async function b(e){try{await Vx(e),s.message.success(`Menu deleted`),await h()}catch(e){s.message.error(e.message||`Unable to delete menu`)}}return(0,l.jsxs)(`section`,{className:`admin-section`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(yD,{level:4,children:`Menus`}),(0,l.jsx)(vD,{type:`secondary`,children:`Manage records in the MongoDB menus collection.`})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:_,children:`Add Menu`})]}),(0,l.jsx)(s.Table,{rowKey:`menu_id`,loading:r,columns:[{title:`Name`,dataIndex:`menu_name`},{title:`Key`,dataIndex:`menu_key`,render:e=>(0,l.jsx)(s.Tag,{children:e})},{title:`Route / API`,dataIndex:`api_url`},{title:`Icon`,dataIndex:`icon`,width:170,render:e=>(0,l.jsx)(s.Tag,{children:e||`Auto`})},{title:`Type`,dataIndex:`menu_type`,width:110},{title:`Order`,dataIndex:`display_order`,width:80},{title:`Status`,dataIndex:`status`,width:100,render:e=>(0,l.jsx)(s.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Button,{"aria-label":`Edit menu`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>v(t)}),(0,l.jsx)(s.Popconfirm,{title:`Delete menu?`,onConfirm:()=>b(t.menu_id),children:(0,l.jsx)(s.Button,{"aria-label":`Delete menu`,danger:!0,size:`small`,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],dataSource:t,size:`small`,pagination:{pageSize:10}}),(0,l.jsx)(s.Modal,{title:d?`Edit Menu`:`Add Menu`,open:p,onCancel:()=>m(!1),onOk:()=>e.submit(),confirmLoading:a,destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,onFinish:y,children:[(0,l.jsx)(s.Form.Item,{name:`menu_name`,label:`Menu name`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{})}),(0,l.jsx)(s.Form.Item,{name:`menu_key`,label:`Menu key`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`jobs`})}),(0,l.jsx)(s.Form.Item,{name:`api_url`,label:`Route / API URL`,children:(0,l.jsx)(s.Input,{placeholder:`/jobs`})}),(0,l.jsx)(s.Form.Item,{name:`component_name`,label:`Component`,children:(0,l.jsx)(s.Input,{placeholder:`Jobs`})}),(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{name:`menu_type`,label:`Type`,children:(0,l.jsx)(s.Select,{options:[{value:`MENU`},{value:`FOOTER`},{value:`CHILD`}]})}),(0,l.jsx)(s.Form.Item,{name:`parent_menu_id`,label:`Parent`,children:(0,l.jsx)(s.Select,{allowClear:!0,options:g})})]}),(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{name:`display_order`,label:`Display order`,children:(0,l.jsx)(s.InputNumber,{min:0})}),(0,l.jsx)(s.Form.Item,{name:`status`,label:`Status`,children:(0,l.jsx)(s.Select,{options:[{value:`ACTIVE`},{value:`INACTIVE`}]})})]}),(0,l.jsx)(s.Form.Item,{name:`icon`,label:`Sidebar icon`,extra:`Saved in the menus collection and used dynamically in the application sidebar.`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,placeholder:`Select sidebar icon`,optionFilterProp:`label`,options:bD.map(({value:e,label:t})=>({value:e,label:t})),optionRender:e=>{let t=e?.value??e?.data?.value,n=bD.find(e=>e.value===t);return n?(0,l.jsx)(xD,{option:n}):t}})})]})})]})}var{Content:wD,Header:TD,Sider:ED}=s.Layout,{Text:DD,Title:OD}=s.Typography;function kD(e){return String(e??``).trim().replace(/[\s_-]+/g,` `).toUpperCase()}function AD(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function jD(e){return String(e||``).trim().toLowerCase()}function MD(e){return e?.key||e?.collectionName||e?.value||``}function ND(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=MD(e);if(!t)return;let o=jD(e.key||t),s=jD(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||AD(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=jD(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:AD(t),value:t,disabled:!1}))}),n}function PD(e){return kD(e?.user_type_name??e?.userTypeName??e?.name)===`SUPER ADMIN`}function FD(e){return`${e?.first_name??e?.firstName??``} ${e?.last_name??e?.lastName??``}`.trim()||e?.username||e?.userName||e?.email||`User ${e?.user_id??e?.userId??``}`}function ID(e){return e.flatMap(e=>{let t=e.menu_id??e.menuId??e.MenuID,n=e.menu_name??e.menuName??e.MenuName??`Menu ${t??``}`,r=e.menu_key??e.menuKey??e.MenuKey??``,i=e.permissions??e.Permissions??{};return Object.entries(i).map(([e,i])=>{let a=i.permission_id??i.permissionId??i.PermissionID,o=i.permission_key??i.permissionKey??i.PermissionKey??e,s=i.value??i.Value??i.access_value??i.accessValue??i;return{key:`${r??n??t}:${a??o}`,menuId:t,menuName:n,menuKey:r,permissionId:a,permissionKey:o,accessValue:+(Number(s)===1)}})})}function LD(e){return String(e.menuKey??e.menuName??e.menuId).trim().toLowerCase()}var RD=[{permissionId:null,permissionKey:`sendApprove`,permissionName:`Send Approve`}];function zD(e){let t=Array.isArray(e)?e:e?.permissions??e?.actions??e?.data??e,n=(Array.isArray(t)?t:Object.values(t??{})).map(e=>({permissionId:e.permission_id??e.permissionId??e.legacyPermissionId??e.id??null,permissionKey:e.permission_key??e.permissionKey??e.key,permissionName:e.permission_name??e.permissionName??e.name??e.label})).filter(e=>e.permissionKey),r=new Set(n.map(e=>String(e.permissionKey).trim().toLowerCase()));return RD.forEach(e=>{r.has(e.permissionKey.toLowerCase())||n.push(e)}),n}function BD(e={}){return String(e.permissionName??``).trim()||String(e.permissionKey??``).replaceAll(`_`,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/\b\w/g,e=>e.toUpperCase())}function VD({title:e,description:t,selectedName:n,loading:r,saving:i,rows:a,onChange:o,onMove:u,onSave:d}){let f=Object.values(a.reduce((e,t)=>{let n=LD(t);return e[n]||(e[n]={key:n,menuName:t.menuName,menuKey:t.menuKey,permissions:[]}),e[n].permissions.push(t),e},{}));return(0,l.jsxs)(`section`,{className:`admin-editor`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(OD,{level:4,children:e}),(0,l.jsx)(DD,{type:`secondary`,children:n||t})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:i,disabled:!n||a.length===0,onClick:d,children:`Save`})]}),r?(0,l.jsx)(`div`,{className:`admin-loading`,children:(0,l.jsx)(s.Spin,{})}):f.length?(0,l.jsx)(s.Table,{size:`small`,rowKey:`key`,columns:[{title:`Menu`,dataIndex:`menuName`,width:220,render:(e,t)=>(0,l.jsxs)(`div`,{className:`admin-menu-order-cell`,children:[(0,l.jsxs)(`div`,{className:`admin-menu-cell`,children:[(0,l.jsx)(`span`,{children:e}),(0,l.jsx)(DD,{type:`secondary`,children:t.menuKey})]}),(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Button,{size:`small`,type:`text`,icon:(0,l.jsx)(c.ArrowUpOutlined,{}),onClick:()=>u(t.key,-1),"aria-label":`Move ${e} up`}),(0,l.jsx)(s.Button,{size:`small`,type:`text`,icon:(0,l.jsx)(c.ArrowDownOutlined,{}),onClick:()=>u(t.key,1),"aria-label":`Move ${e} down`})]})]})},{title:`Actions`,dataIndex:`permissions`,render:e=>(0,l.jsx)(`div`,{className:`admin-permission-controls`,children:e.filter(e=>Kx(e.menuName??e.menuKey,e.permissionKey)).map(e=>(0,l.jsx)(`label`,{className:`admin-permission-control`,children:(0,l.jsx)(s.Checkbox,{checked:e.accessValue===1,onChange:t=>o(e.key,+!!t.target.checked),"aria-label":`${e.menuName} ${e.permissionKey}`,children:BD(e)})},e.key))})}],dataSource:f,pagination:!1,scroll:{y:420}}):(0,l.jsx)(s.Empty,{description:`Select a record to customize permissions`})]})}function HD({onLogout:e}){let[r]=s.Form.useForm(),[i]=s.Form.useForm(),[a,u]=(0,o.useState)(`users`),[d,f]=(0,o.useState)(!0),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)(0),[x,S]=(0,o.useState)(1),[C,w]=(0,o.useState)(10),[T,E]=(0,o.useState)(``),[D,O]=(0,o.useState)(!1),[k,A]=(0,o.useState)([]),[j,M]=(0,o.useState)([]),[N,P]=(0,o.useState)([]),[F,I]=(0,o.useState)(null),[L,R]=(0,o.useState)([]),[z,B]=(0,o.useState)(!1),[V,H]=(0,o.useState)(null),[ee,U]=(0,o.useState)(!1),[te,ne]=(0,o.useState)(null),[re,ie]=(0,o.useState)([]),[ae,W]=(0,o.useState)(!1),[oe,se]=(0,o.useState)(!1),[ce,le]=(0,o.useState)(null),[ue,de]=(0,o.useState)(!1),[G,fe]=(0,o.useState)(null),[pe,me]=(0,o.useState)(`listView`),[he,ge]=(0,o.useState)([]),[_e,ve]=(0,o.useState)([]),[ye,be]=(0,o.useState)(!1),[xe,K]=(0,o.useState)(!1),q=t.d(),Se=(0,o.useMemo)(()=>he.filter(e=>!e.disabled),[he]),Ce=!ye&&Se.length===0,we=(0,o.useCallback)(async()=>{be(!0);try{let[e,t]=await Promise.all([n.kr(),n.xr()]),r=ND(e.modules,t),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));ge(r),ve(e=>e.filter(e=>i.has(e)))}catch{s.message.error(`Failed to load seed status`)}finally{be(!1)}},[]);(0,o.useEffect)(()=>{we()},[we]);async function Te(){if(_e.length===0){s.message.warning(Ce?`All modules already seeded.`:`Select at least one module to seed.`);return}K(!0);try{await n.di(_e),s.message.success(`User type field config seeded`),ve([]),await we()}catch(e){s.message.error(e?.message||`Seed failed`)}finally{K(!1)}}async function Ee(){f(!0);try{let[e,t,n]=await Promise.allSettled([Px(),Rx(),Hx()]),r=e.status===`fulfilled`?e.value:[];e.status===`rejected`&&s.message.error(e.reason?.message||`Unable to load user types`),A(r??[]),M(t.status===`fulfilled`?t.value??[]:[]),P(n.status===`fulfilled`?zD(n.value):[]),I((r??[])[0]?.user_type_id??null)}catch(e){s.message.error(e.message||`Unable to load admin data`)}finally{f(!1)}}(0,o.useEffect)(()=>{queueMicrotask(()=>{Ee()})},[]);let De=(0,o.useCallback)(async()=>{O(!0);try{let{users:e,total:t}=await kx({limit:C,offset:(x-1)*C,search:T});v(e??[]),b(t??0)}catch(e){s.message.error(e?.message||`Unable to load users`),v([]),b(0)}finally{O(!1)}},[x,C,T]);(0,o.useEffect)(()=>{De()},[De]),(0,o.useEffect)(()=>{queueMicrotask(()=>{if(!F){R([]);return}m(!0),console.log(`DEBUG requesting role permissions for selectedUserTypeId=`,F,`localStorage scope=`,{tenantId:localStorage.getItem(`tenantId`),businessId:localStorage.getItem(`businessId`),businessUnitId:localStorage.getItem(`businessUnitId`)}),Ux(F).then(e=>{console.log(`DEBUG raw groups from /get-role-details`,e);let t=ID(e??[]);console.log(`DEBUG savedRows (jobs only)`,t.filter(e=>LD(e)===`jobs`||LD(e)===`job`));let n=new Map(t.map(e=>[`${LD(e)}:${String(e.permissionKey).toLowerCase()}`,e.accessValue]));console.log(`DEBUG savedAccess keys`,[...n.keys()]),console.log(`DEBUG menus (jobs only)`,j.filter(e=>String(e.menu_key??e.menu_name??e.menu_id).trim().toLowerCase()===`jobs`));let r=j.flatMap(e=>N.map(t=>{let r=String(e.menu_key??e.menu_name??e.menu_id).trim().toLowerCase(),i=String(t.permissionKey).toLowerCase();return{key:`${e.menu_key??e.menu_name??e.menu_id}:${t.permissionId??t.permissionKey}`,menuId:e.menu_id,menuName:e.menu_name,menuKey:e.menu_key,permissionId:t.permissionId,permissionKey:t.permissionKey,accessValue:n.get(`${r}:${i}`)??0}}));console.log(`DEBUG final rows (jobs only)`,r.filter(e=>LD(e)===`jobs`||LD(e)===`job`)),R(r)}).catch(e=>s.message.error(e.message||`Unable to load role permissions`)).finally(()=>m(!1))})},[F,j,N]);let Oe=(0,o.useMemo)(()=>k.find(e=>e.user_type_id===F),[F,k]),ke=(0,o.useMemo)(()=>k.reduce((e,t)=>({...e,[t.user_type_id]:t.user_type_name}),{}),[k]),Ae=(0,o.useMemo)(()=>_.reduce((e,t)=>({...e,[t.user_id]:FD(t)}),{}),[_]),je=(0,o.useMemo)(()=>k.filter(e=>!PD(e)),[k]),J=(0,o.useMemo)(()=>_.filter(e=>!PD({user_type_id:e.user_type_id,user_type_name:ke[e.user_type_id]})),[ke,_]);(0,o.useEffect)(()=>{if(!z){ie([]);return}let e=Number(r.getFieldValue(`user_type_id`)??0);if(!e){ie([]);return}let t=!1;return W(!0),Ax(e).then(e=>{t||ie(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{t||(s.message.error(e.message||`Unable to load reporting users`),ie([]))}).finally(()=>{t||W(!1)}),()=>{t=!0}},[V,r,z]);let Me=(0,o.useMemo)(()=>{let e=re.map(e=>({label:FD(e),value:e.user_id})),t=Number(V?.reporting_id??V?.reportingId??0);return!t||e.some(e=>Number(e.value)===t)?e:[{label:V?.reportingName??V?.reporting_name??Ae[t]??`User ${t}`,value:t},...e]},[V,re,Ae]),Ne=(0,o.useMemo)(()=>{let e=je.map(e=>({label:e.user_type_name,value:e.user_type_id}));if(!V)return e;let t=Number(V.user_type_id??0);return e.some(e=>Number(e.value)===t)?e:[{label:ke[t]??V.userType??V.roleName??(t>0?`Type ${t}`:`Unassigned`),value:t},...e]},[V,je,ke]);k.length,j.length;let Pe=[{key:`form-groups`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.AppstoreAddOutlined,{}),` Form Groups`]}),title:`Form Groups`,description:`Build module add and edit form groups with validations, dropdowns, and custom forms.`,component:(0,l.jsx)(ow,{})},{key:`detail-groups`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.BgColorsOutlined,{}),` Detail Groups`]}),title:`Detail Groups`,description:`Control detail-view labels, rendering, lookups, merged fields, and display defaults.`,component:(0,l.jsx)(Vw,{})},{key:`actions`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ThunderboltOutlined,{}),` Actions`]}),title:`Actions`,description:`Manage row action buttons and their visibility rules from one workspace.`,component:(0,l.jsx)(AT,{})},{key:`templates`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.MailOutlined,{}),` Templates`]}),title:`Templates`,description:`Manage reusable email templates and signatures.`,component:(0,l.jsx)(HT,{})},{key:`ai-services`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ThunderboltOutlined,{}),` AI Services`]}),title:`AI Services`,description:`Register the AI and automation services used by admin-configured AI actions.`,component:(0,l.jsx)(KT,{})},{key:`bgc-integration`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.SafetyCertificateOutlined,{}),` Integrations`]}),title:`Integrations`,description:`Manage manual and API integrations used across application workflows.`,component:(0,l.jsx)(QT,{})},{key:`automations`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ApartmentOutlined,{}),` Automations`]}),title:`Automations`,description:`Reference ids, duplicate checks, cross-module snapshots, reporting-chain hierarchy expansion, board updates, notifications, and cache invalidation — per module, config-driven.`,component:(0,l.jsx)(VE,{})},{key:`workflows`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ApartmentOutlined,{}),` Workflows`]}),title:`Workflows`,description:`Event-driven behavior per module (beforeCreate/afterCreate/…): the metadata the platform Workflow Engine executes — where the jobs, candidates, and submissions create flows live.`,component:(0,l.jsx)(YE,{})},{key:`po-msa-settings`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.SafetyCertificateOutlined,{}),` PO/MSA Settings`]}),title:`PO/MSA Settings`,description:`Configure employer and referral MSA validity and expiry warning days.`,component:(0,l.jsx)(_D,{})},{key:`masters`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.AppstoreAddOutlined,{}),` Masters`]}),title:`Masters`,description:`Shared Location and Tax lists used across modules (e.g. the submission form’s W2 employer section).`,component:(0,l.jsx)(mD,{})}],Fe=[{key:`users`,icon:(0,l.jsx)(c.UserOutlined,{}),label:`Users`},{key:`roles`,icon:(0,l.jsx)(c.TeamOutlined,{}),label:`User Types`},{key:`menus`,icon:(0,l.jsx)(c.MenuOutlined,{}),label:`Menus`},{key:`configurations`,icon:(0,l.jsx)(c.AppstoreAddOutlined,{}),label:`Configurations`},{key:`integrations`,icon:(0,l.jsx)(c.SafetyCertificateOutlined,{}),label:`Integrations`}];function Ie(e,t){R(n=>{let r=n.filter(t=>t.key===e).length;return console.log(`DEBUG updateRolePermission`,{key:e,value:t,matchCount:r}),n.map(n=>n.key===e?{...n,accessValue:t}:n)})}async function Le(){g(!0);try{console.log(`DEBUG saveRolePermissions jobs rows`,L.filter(e=>LD(e)===`jobs`||LD(e)===`job`)),await Wx(F,L.map(e=>({menu_id:e.menuId,menu_name:e.menuName,menu_key:e.menuKey,permission_id:e.permissionId,permission_key:e.permissionKey,access_value:e.accessValue,updated_by:q?.userId??null}))),s.message.success(`Role permissions updated`)}catch(e){s.message.error(e.message||`Unable to save role permissions`)}finally{g(!1)}}function Re(){H(null),r.resetFields(),r.setFieldsValue({status:`ACTIVE`,user_type_id:je[0]?.user_type_id,reporting_id:0}),B(!0)}function ze(e){H(e),r.setFieldsValue({first_name:e.first_name,last_name:e.last_name,username:e.username,email:e.email,mobile:e.mobile,user_type_id:e.user_type_id,reporting_id:e.reporting_id??e.reportingId??0,profile_image:e.profile_image,status:e.status}),B(!0)}async function Be(e){U(!0);try{let t={...e,status:e.status===1||e.status===`1`||e.status===!0?`ACTIVE`:e.status===0||e.status===`0`||e.status===!1?`INACTIVE`:String(e.status??`ACTIVE`).toUpperCase(),updated_by:q?.userId??null,created_by:q?.userId??null};t.password||delete t.password,V?(await Mx(V.user_id,t),s.message.success(`User updated`)):(await jx(t),s.message.success(`User created`)),B(!1),H(null),await De()}catch(e){s.message.error(e.message||`Unable to save user`)}finally{U(!1)}}async function Y(e){ne(e);try{await Nx(e),s.message.success(`User deleted`),await De()}catch(e){s.message.error(e.message||`Unable to delete user`)}finally{ne(null)}}function Ve(e,t){me(`listView`),fe({kind:e,record:t}),e===`role`&&I(t.user_type_id)}function He(e,t){R(n=>{let r=[...new Set(n.map(LD))],i=r.indexOf(e),a=i+t;if(i<0||a<0||a>=r.length)return n;[r[i],r[a]]=[r[a],r[i]];let o=new Map(r.map((e,t)=>[e,t]));return[...n].sort((e,t)=>o.get(LD(e))-o.get(LD(t)))})}function Ue(){le(null),i.resetFields(),i.setFieldsValue({status:`ACTIVE`}),se(!0)}function X(e){le(e),se(!0),i.setFieldsValue(e)}async function We(e){de(!0);try{let t=q?.userId??null,n=!!ce,r=n?await Ix(ce.user_type_id,{...e,updated_by:t}):await Fx({...e,created_by:t,visible_menu_ids:[]}),i=r.user_type_id;s.message.success(n?`User type updated`:`User type created. Customize its menus and permissions.`),se(!1),await Ee(),I(i),n||(me(`permissions`),fe({kind:`role`,record:{...e,...r,user_type_id:i,user_type_name:r.user_type_name??e.user_type_name}}))}catch(e){s.message.error(e.message||`Unable to save role`)}finally{de(!1)}}async function Ge(e){try{await Lx(e),s.message.success(`Role deleted`),await Ee()}catch(e){s.message.error(e.message||`Unable to delete role`)}}return(0,l.jsxs)(s.Layout,{className:`admin-shell`,children:[(0,l.jsx)(ED,{width:248,className:`admin-sider`,children:(0,l.jsxs)(`div`,{className:`admin-sidebar-nav`,children:[(0,l.jsx)(DD,{className:`admin-sidebar-title`,children:`Admin Menu`}),(0,l.jsx)(s.Menu,{theme:`dark`,mode:`inline`,selectedKeys:[a],onClick:({key:e})=>u(e),items:Fe})]})}),(0,l.jsx)(s.Layout,{children:(0,l.jsxs)(wD,{className:`admin-content`,children:[(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(s.Tabs,{activeKey:a,onChange:u,tabBarStyle:{display:`none`},items:[{key:`users`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.UserOutlined,{}),` Users`]}),children:(0,l.jsx)(`div`,{className:`admin-stack`,children:(0,l.jsxs)(`section`,{className:`admin-section`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(OD,{level:4,children:`Users`}),(0,l.jsx)(DD,{type:`secondary`,children:`Create and manage users with non-super-admin user types.`})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:Re,children:`Add`})]}),(0,l.jsx)($m,{listName:`Users`,loading:D,fields:[{label:`Name`,value:`first_name`,render:(e,t)=>`${e??``} ${t.last_name??``}`.trim()||t.username},{label:`Email`,value:`email`},{label:`User Type`,value:`user_type_id`,width:160,render:(e,t)=>ke[e]||t?.userType||t?.user_type||(Number(e)>0?`Type ${e}`:`—`)},{label:`Reporting Manager`,value:`reporting_id`,width:180,render:(e,t)=>Ae[e]||t?.reportingName||t?.reporting_name||(Number(e)>0?`User ${e}`:`None`)},{label:`Status`,value:`status`,width:110,sorter:!1,render:e=>(0,l.jsx)(s.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{label:`Actions`,value:`_actions`,width:150,sorter:!1,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Button,{"aria-label":`Edit user`,icon:(0,l.jsx)(c.EditOutlined,{}),size:`small`,onClick:()=>ze(t)}),(0,l.jsx)(s.Popconfirm,{title:`Delete user?`,description:`This removes the user from the auth database.`,okText:`Delete`,okButtonProps:{danger:!0},onConfirm:()=>Y(t.user_id),children:(0,l.jsx)(s.Button,{danger:!0,"aria-label":`Delete user`,icon:(0,l.jsx)(c.DeleteOutlined,{}),loading:te===t.user_id,size:`small`})})]})}],dataSource:J.map(e=>({...e,key:e.user_id})),total:y,current:x,pageSize:C,onPageChange:S,onPageSizeChange:e=>{w(e),S(1)},onSearch:e=>{E(e??``),S(1)},rowSelection:!1})]})})},{key:`roles`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.TeamOutlined,{}),` User Types`]}),children:(0,l.jsxs)(`div`,{className:`admin-stack`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,l.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,l.jsx)(s.Select,{mode:`multiple`,allowClear:!0,showSearch:!0,value:_e,options:he,placeholder:Ce?`All modules already seeded`:`Select modules or collections to seed`,disabled:ye||xe||Ce,loading:ye,onChange:ve,style:{width:`100%`}})}),(0,l.jsx)(s.Button,{type:`primary`,loading:xe,disabled:ye||_e.length===0,onClick:Te,children:`Seed Field Config`})]}),(0,l.jsx)(DD,{type:`secondary`,style:{display:`block`,marginTop:8,fontSize:12},children:Ce?`Seed is disabled because all configured modules already have user type field config data.`:`Already seeded modules are disabled. New modules or collections can still be seeded.`})]}),(0,l.jsxs)(`section`,{className:`admin-section`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(OD,{level:4,children:`User Types`}),(0,l.jsx)(DD,{type:`secondary`,children:`Role level permissions are inherited by users.`})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:Ue,children:`Add Role`})]}),(0,l.jsx)($m,{listName:`User Types`,loading:d,fields:[{label:`User Type`,value:`user_type_name`},{label:`Description`,value:`description`},{label:`Status`,value:`status`,width:110,sorter:!1,render:e=>(0,l.jsx)(s.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{label:`Actions`,value:`_actions`,width:260,sorter:!1,render:(e,t)=>{let n=Number(t.role_type)===1;return(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Button,{"aria-label":`Configure role`,size:`small`,onClick:()=>Ve(`role`,t),children:`Config`}),(0,l.jsx)(s.Button,{"aria-label":`Edit role`,disabled:!n,icon:(0,l.jsx)(c.EditOutlined,{}),size:`small`,onClick:()=>X(t)}),n&&!PD(t)&&(0,l.jsx)(s.Popconfirm,{title:`Delete role?`,onConfirm:()=>Ge(t.user_type_id),children:(0,l.jsx)(s.Button,{"aria-label":`Delete role`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),size:`small`})})]})}}],dataSource:k.map(e=>({...e,key:e.user_type_id,roleId:e.user_type_id,roleName:e.user_type_name})),total:k.length,rowSelection:!1})]})]})},{key:`menus`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.MenuOutlined,{}),` Menus`]}),children:(0,l.jsx)(CD,{})},{key:`configurations`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.AppstoreAddOutlined,{}),` Configurations`]}),children:(0,l.jsxs)(`section`,{className:`admin-section admin-config-workspace`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(OD,{level:4,children:`Configuration Center`}),(0,l.jsx)(DD,{type:`secondary`,children:`CORE-THEME admin modules embedded into the admin dashboard.`})]}),(0,l.jsxs)(s.Tag,{color:`blue`,children:[Pe.length,` configurations`]})]}),(0,l.jsx)(s.Tabs,{className:`admin-config-tabs`,defaultActiveKey:`form-groups`,tabPosition:`left`,items:Pe.map(e=>({key:e.key,label:e.label,children:(0,l.jsxs)(`div`,{className:`admin-config-panel`,children:[(0,l.jsx)(`div`,{className:`admin-config-panel-head`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(OD,{level:4,children:e.title}),(0,l.jsx)(DD,{type:`secondary`,children:e.description})]})}),(0,l.jsx)(`div`,{className:`admin-config-panel-body`,children:e.component})]})}))})]})},{key:`integrations`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.SafetyCertificateOutlined,{}),` Integrations`]}),children:(0,l.jsxs)(`section`,{className:`admin-section admin-config-workspace`,children:[(0,l.jsx)(`div`,{className:`admin-section-head`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(OD,{level:4,children:`Integrations`}),(0,l.jsx)(DD,{type:`secondary`,children:`Configure external services used by onboarding and other workflows.`})]})}),(0,l.jsx)(`div`,{className:`admin-config-panel`,children:(0,l.jsx)(`div`,{className:`admin-config-panel-body`,children:(0,l.jsx)(s.Tabs,{defaultActiveKey:`facebook-courses`,items:[{key:`facebook-courses`,label:`Facebook Form → Course Mapping`,children:(0,l.jsx)(DE,{})},{key:`service-integrations`,label:`Other Integrations`,children:(0,l.jsx)(QT,{})}]})})})]})}]})}),(0,l.jsxs)(s.Modal,{className:`uss-modal`,title:`Configure User Type: ${G?.record?.user_type_name??``}`,open:!!G,onCancel:()=>fe(null),footer:null,destroyOnHidden:!0,width:900,children:[(0,l.jsx)(`div`,{className:`uss-config-toggle`,style:{marginBottom:12},children:[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`},{key:`actions`,label:`Actions`}].map(e=>(0,l.jsx)(`button`,{type:`button`,className:`uss-config-btn${pe===e.key?` active`:``}`,onClick:()=>me(e.key),children:e.label},e.key))}),G&&pe===`permissions`?(0,l.jsx)(VD,{title:`Role Permissions`,description:`Configure menu permissions for this user type`,selectedName:Oe?.user_type_name,loading:p,saving:h,rows:L,onChange:Ie,onMove:He,onSave:Le}):G&&pe===`actions`?(0,l.jsx)(OS,{role:{...G.record,roleId:G.record.user_type_id,roleName:G.record.user_type_name}},`${G.record?.user_type_id}-actions`):G&&pe===`form`?(0,l.jsx)(bS,{role:{...G.record,roleId:G.record.user_type_id,roleName:G.record.user_type_name}},`${G.record?.user_type_id}-form`):G?(0,l.jsx)(lS,{role:{...G.record,roleId:G.record.user_type_id,roleName:G.record.user_type_name},configType:pe},`${G.record?.user_type_id}-${pe}`):null]}),(0,l.jsx)(s.Modal,{className:`admin-role-modal`,title:ce?`Edit User Type`:`Create User Type`,open:oe,onCancel:()=>se(!1),onOk:()=>i.submit(),okText:ce?`Save`:`Next`,confirmLoading:ue,destroyOnHidden:!0,width:900,children:(0,l.jsxs)(s.Form,{form:i,layout:`vertical`,onFinish:We,children:[(0,l.jsx)(s.Form.Item,{name:`user_type_name`,label:`Role name`,rules:[{required:!0,message:`Role name is required`}],children:(0,l.jsx)(s.Input,{placeholder:`Recruiter`})}),(0,l.jsx)(s.Form.Item,{name:`description`,label:`Description`,children:(0,l.jsx)(s.Input.TextArea,{rows:3})}),(0,l.jsx)(s.Form.Item,{name:`status`,label:`Status`,children:(0,l.jsx)(s.Select,{options:[{value:`ACTIVE`},{value:`INACTIVE`}]})})]})}),(0,l.jsx)(s.Modal,{className:`admin-user-modal`,title:V?`Edit User`:`Add User`,open:z,onCancel:()=>B(!1),onOk:()=>r.submit(),confirmLoading:ee,destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:r,layout:`vertical`,requiredMark:!1,onFinish:Be,children:[(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{label:`First Name`,name:`first_name`,rules:[{required:!0,message:`First name is required`}],children:(0,l.jsx)(s.Input,{placeholder:`John`})}),(0,l.jsx)(s.Form.Item,{label:`Last Name`,name:`last_name`,children:(0,l.jsx)(s.Input,{placeholder:`Doe`})})]}),(0,l.jsx)(s.Form.Item,{label:`Username`,name:`username`,rules:[{required:!0,message:`Username is required`}],children:(0,l.jsx)(s.Input,{placeholder:`john.doe`})}),(0,l.jsx)(s.Form.Item,{label:`Email`,name:`email`,rules:[{required:!0,message:`Email is required`},{type:`email`,message:`Enter a valid email`}],children:(0,l.jsx)(s.Input,{placeholder:`john@example.com`})}),(0,l.jsx)(s.Form.Item,{label:`Password`,name:`password`,rules:V?[]:[{required:!0,message:`Password is required`}],children:(0,l.jsx)(s.Input.Password,{placeholder:V?`Leave empty to keep current password`:`Password`})}),(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{label:`Mobile`,name:`mobile`,children:(0,l.jsx)(s.Input,{placeholder:`9999999999`})}),(0,l.jsx)(s.Form.Item,{label:`User Type`,name:`user_type_id`,rules:[{required:!0,message:`User type is required`}],children:(0,l.jsx)(s.Select,{placeholder:`Select user type`,onChange:()=>{ie([]),queueMicrotask(()=>{let e=Number(r.getFieldValue(`user_type_id`)??0);e&&(W(!0),Ax(e).then(e=>{ie(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{s.message.error(e.message||`Unable to load reporting users`),ie([])}).finally(()=>{W(!1)}))})},options:Ne})})]}),(0,l.jsx)(s.Form.Item,{label:`Reporting Manager`,name:`reporting_id`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,loading:ae,placeholder:`Select reporting manager`,optionFilterProp:`label`,options:[{label:`None`,value:0},...Me]})}),(0,l.jsx)(s.Form.Item,{label:`Profile Image`,name:`profile_image`,children:(0,l.jsx)(s.Input,{placeholder:`https://...`})}),(0,l.jsx)(s.Form.Item,{label:`Status`,name:`status`,children:(0,l.jsx)(s.Select,{options:[{label:`ACTIVE`,value:`ACTIVE`},{label:`INACTIVE`,value:`INACTIVE`}]})})]})})]})})]})}var UD=HD;function WD(e,t){return String(e||t).replace(/\/\*$/,``).replace(/\/+$/,``)||t}function GD({loginPath:e=`/login`,adminPath:t=`/admin`,fallbackPath:n=`/`}){let r=(0,d.useNavigate)(),i=WD(e,`/login`),a=WD(t,`/admin`),o=`${a}/*`;return(0,l.jsxs)(d.Routes,{children:[(0,l.jsx)(d.Route,{path:i,element:(0,l.jsx)(Fb,{defaultRedirectPath:a,onLogin:()=>r(a,{replace:!0})})}),(0,l.jsx)(d.Route,{path:o,element:(0,l.jsx)(Db,{loginPath:i,children:(0,l.jsx)(Pb,{children:(0,l.jsx)(UD,{onLogout:()=>r(i,{replace:!0})})})})}),(0,l.jsx)(d.Route,{path:n,element:(0,l.jsx)(d.Navigate,{to:a,replace:!0})}),(0,l.jsx)(d.Route,{path:`*`,element:(0,l.jsx)(d.Navigate,{to:a,replace:!0})})]})}function KD(e){return(0,l.jsx)(d.BrowserRouter,{children:(0,l.jsx)(GD,{...e})})}function qD(e){return Array.isArray(e)?e.map(String).map(e=>e.trim()).filter(Boolean):String(e??``).split(`,`).map(e=>e.trim()).filter(Boolean)}function JD(e){return qD(e).every(e=>/^[^,\s@]+@[^,\s@]+\.[^\s@]{2,}$/.test(e))}var{Text:YD}=s.Typography,XD=new Set([`file`,`document`,`attachment`]);function ZD(e){return XD.has(String(e?.type??``).trim().toLowerCase())}function QD(e){return String(e??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``)}function $D(e){return e?typeof e==`string`?e:String(typeof e==`object`?e?._id??e?.id??e?.$oid??``:e):``}function eO(e,t,n){if(!e)return``;let r=QD(t),i=QD(n);if(!r||r===i||r.replace(/s$/,``)===i.replace(/s$/,``))return $D(e?._id??e?.id);let a=r.replace(/s$/,``),o=[`${a}Id`,`${r}Id`,a,r,`${a}._id`,`${r}._id`];for(let t of o){let n=$D(aO(e,t));if(n)return n}return``}async function tO(e){let t=e?.fileUrl??e?.url??e?.downloadUrl;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load attachment ${e?.fileName||``}`.trim());let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.uniqueName??`attachment`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function nO(e,t,r){if(!t)return[];let i=[];(e?.placeholders??[]).forEach(e=>{(e?.holders??[]).filter(ZD).forEach(a=>{let o=eO(t,e?.moduleName,r);o&&i.push((async()=>{let t=await n.yn(e.moduleName,o,a.value);return Promise.all((t?.data??[]).map(tO))})())})});let a=(await Promise.all(i)).flat().filter(Boolean),o=new Set;return a.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!o.has(t)&&(o.add(t),!0)})}function rO(e,t){return[...new Set([...qD(e),...qD(t)])].join(`, `)}function iO(e=[],t=[]){let n=new Set;return[...e,...t].filter(e=>{if(!e)return!1;let t=`${e.name}:${e.size}:${e.type}`;return!n.has(t)&&(n.add(t),!0)})}function aO(e,t,n=``){let r=String(n??``).trim().toLowerCase();return String(t??``).split(`.`).reduce((e,t)=>{let n=e;return Array.isArray(n)&&r===`last`&&(n=n.at(-1)),n?.[t]},e)}function oO(e,t,n){if(!n)return String(e??``);let r=new Map;return(t??[]).forEach(e=>(e.holders??[]).forEach(e=>{r.set(e.key,ZD(e)?``:aO(n,e.value,e.arrayMode))})),String(e??``).replace(/{{\.?([\w.]+)}}/g,(e,t)=>{let n=r.get(t);return n==null?e:String(n)})}function sO({value:e,onChange:t,defaultTemplateId:r=``,ready:i=!0,title:a=`Mail`,hint:u,bccHint:d,afterBcc:f,beforeFields:p,className:m=``,contextRecords:h=[],moduleName:g=``}){let _=(0,o.useRef)(``),v=n=>t?.({...e,...n});async function y(t,n=!1){if(t)try{let r=await Zw(t),i=h[0],a=await nO(r,i,g);v({to:rO(e.to,(r?.toMail??[]).map(e=>oO(e,r?.placeholders,i))),cc:rO(e.cc,(r?.ccMail??[]).map(e=>oO(e,r?.placeholders,i))),bcc:rO(e.bcc,(r?.bccMail??[]).map(e=>oO(e,r?.placeholders,i))),subject:oO(r?.subject,r?.placeholders,i),contents:oO(r?.body,r?.placeholders,i),attachments:iO(e.attachments,a)}),n||s.message.success(`Loaded ${r?.name||`email template`}`)}catch(e){n||s.message.error(e?.message||`Could not load email template`)}}return(0,o.useEffect)(()=>{!i||!r||_.current===r||(_.current=r,y(r,!0))},[r,i]),(0,l.jsxs)(`div`,{className:`common-mail-composer ${m}`.trim(),children:[(0,l.jsx)(`div`,{className:`mail-popup__header`,children:(0,l.jsxs)(`div`,{className:`mail-popup__header-brand`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,l.jsx)(c.MailOutlined,{})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`span`,{className:`dynamic-popup__header-label`,children:a}),u&&(0,l.jsx)(YD,{type:`secondary`,className:`mail-popup__header-hint`,children:u})]})]})}),(0,l.jsxs)(`div`,{className:`mail-popup__body`,children:[p&&(0,l.jsxs)(l.Fragment,{children:[p,(0,l.jsx)(s.Divider,{})]}),(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(YD,{type:`secondary`,className:`mail-popup__field-label`,children:`To`}),(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:qD(e.to),onChange:e=>v({to:e.join(`, `)}),variant:`borderless`,className:`mail-popup__recipient-select`,placeholder:`Add email addresses`}),(0,l.jsxs)(`div`,{className:`mail-popup__cc-bcc-actions`,children:[!e.showCc&&(0,l.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>v({showCc:!0}),children:`Cc`}),!e.showBcc&&(0,l.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>v({showBcc:!0}),children:`Bcc`})]})]}),(0,l.jsx)(s.Divider,{}),e.showCc&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(YD,{type:`secondary`,className:`mail-popup__field-label`,children:`Cc`}),(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:qD(e.cc),onChange:e=>v({cc:e.join(`, `)}),variant:`borderless`,className:`mail-popup__recipient-select`})]}),(0,l.jsx)(s.Divider,{})]}),e.showBcc&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(YD,{type:`secondary`,className:`mail-popup__field-label`,children:`Bcc`}),(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:qD(e.bcc),onChange:e=>v({bcc:e.join(`, `)}),variant:`borderless`,className:`mail-popup__recipient-select`,placeholder:d})]}),f,(0,l.jsx)(s.Divider,{})]}),(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(YD,{type:`secondary`,className:`mail-popup__field-label`,children:`Subject`}),(0,l.jsx)(s.Input,{variant:`borderless`,value:e.subject,onChange:e=>v({subject:e.target.value}),placeholder:`Enter subject`,className:`mail-popup__field-input`})]}),(0,l.jsx)(s.Divider,{}),!!e.attachments?.length&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(YD,{type:`secondary`,className:`mail-popup__field-label`,children:`Attachments`}),(0,l.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6,padding:`4px 0`},children:e.attachments.map((e,t)=>(0,l.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,l.jsx)(c.PaperClipOutlined,{}),e.name]},`${e.name}:${e.size}:${t}`))})]}),(0,l.jsx)(s.Divider,{})]}),(0,l.jsxs)(`div`,{className:`mail-popup__message-section`,children:[(0,l.jsx)(YD,{type:`secondary`,className:`mail-popup__message-label`,children:`Message`}),(0,l.jsx)(n.On,{value:e.contents,onChange:e=>v({contents:e})})]})]})]})}var{Text:cO}=s.Typography,lO=/^[a-fA-F0-9]{24}$/,uO=new Set([`file`,`document`,`attachment`]);function dO(e){return e?typeof e==`object`?dO(e.$oid??e._id??e.id??e.oid):String(e).trim():``}async function fO(e){let t=e?.fileUrl??e?.url??e?.downloadUrl;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load attachment ${e?.fileName||``}`.trim());let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.uniqueName??`attachment`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function pO(e,t,r=[]){let i=String(e??``);if(!i||!r.length||!t)return{contents:i,attachments:[]};let a=(await n.Hr(t).catch(()=>[])).filter(e=>uO.has(String(e?.type??``).trim().toLowerCase())).filter(e=>{let t=String(e?.value??e?.field??e?.fieldKey??e?.key??e?.name??``).replace(/^\./,``);return t&&(i.includes(`{{.${t}}}`)||i.includes(`{{${t}}}`))});if(!a.length)return{contents:i,attachments:[]};let o=[];for(let e of a){let a=String(e?.value??e?.field??e?.fieldKey??e?.key??e?.name??``).replace(/^\./,``);i=i.replaceAll(`{{.${a}}}`,``).replaceAll(`{{${a}}}`,``);for(let e of r){let r=String(e?._id??e?.id??``);if(!lO.test(r))continue;let i=await n.yn(t,r,a).catch(()=>({data:[]})),s=await Promise.all((i?.data??[]).map(fO));o.push(...s.filter(Boolean))}}let s=new Set,c=o.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!s.has(t)&&(s.add(t),!0)});return{contents:i,attachments:c}}function mO(e){return e===!0?!0:typeof e==`number`?e===1:typeof e==`string`&&[`true`,`1`,`yes`,`y`,`on`].includes(e.trim().toLowerCase())}function hO(e){return[`candidate`,`candidates`].includes(String(e??``).trim().toLowerCase())}function gO(e,...t){for(let n of t){let t=String(n).split(`.`).reduce((e,t)=>e?.[t],e);if(t!=null&&String(t).trim()!==``)return t}}function _O(e){return[gO(e,`jobReferenceId`,`clientJobId`,`jobCode`,`reqId`,`jobId`),gO(e,`jobTitle`,`title`,`name`)].filter(Boolean).join(` - `)||String(gO(e,`_id`,`id`)??`Job`)}function vO(e){let t=gO(e,`_id`,`id`,`jobId`);return t?{value:String(t),label:_O(e),raw:e}:null}function yO(e=[],t=[]){let n=[...t,`email`,`candidateEmail`,`candidate_email`,`emailId`,`mailId`,`alternateEmail`,`altEmail`,`basicDetails.email`,`basicDetails.alternateEmail`,`basicDetails.altEmail`,`candidate.email`,`candidate.emailId`,`submission.email`,`submission.candidateEmail`].filter(Boolean);return e.flatMap(e=>n.map(t=>gO(e,t))).flatMap(e=>Array.isArray(e)?e:[e]).flatMap(qD)}function bO(e){return e?.data?.record??e?.record??e?.data??e}function xO(e){let t=gO(e,`jobId`,`job_id`,`job._id`,`job.id`,`jobs._id`,`jobs.id`);return typeof t==`object`?gO(t,`_id`,`id`,`$oid`):t}function SO(e={}){return{subject:e.subject??e.Subject??``,contents:e.contents??e.Contents??e.body??e.Body??``,toMail:e.toMail??e.ToMail??[],ccMail:e.ccMail??e.CcMail??[],bccMail:e.bccMail??e.BccMail??[]}}function CO(){let e=(0,d.useNavigate)(),{state:t={}}=(0,d.useLocation)(),{selectedIds:r=[],selectedRecords:i=[],recipients:a=[],subject:c=``,contents:u=``,attachments:f=[],onSend:p,moduleName:m=``,popupAction:h={}}=t,g=String(t.mailTarget??``).toLowerCase()===`lead`||String(m??``).trim().toLowerCase()===`lead`,_=g?dO(t.leadId??i[0]?.leadId??i[0]?._id??i[0]?.id??r[0]):``,v=!g&&(mO(h.requireJobId)||mO(t.requireJobId)||hO(m)),y=(0,o.useMemo)(()=>[h.recipientField,h.recipientPath,t.recipientField,t.recipientPath],[h.recipientField,h.recipientPath,t.recipientField,t.recipientPath]),b=r.join(`|`),x=(0,o.useMemo)(()=>[...a,...yO(i,y)],[a,i,y]),S=g?``:String(t.jobId??xO(i[0])??``).trim(),C=g?``:r[0]??i[0]?._id??i[0]?.id??``,[w,T]=(0,o.useState)(S),[E,D]=(0,o.useState)(v?S:String(S||C||``)),[O,k]=(0,o.useState)({to:[...new Set(x)].join(`, `),cc:``,bcc:``,subject:c,contents:u,attachments:f,showCc:!1,showBcc:!1}),[A,j]=(0,o.useState)(!E),[M,N]=(0,o.useState)(!1),[P,F]=(0,o.useState)([]),[I,L]=(0,o.useState)(!1),[R,z]=(0,o.useState)(!1),B=(0,o.useRef)(!1),V=(0,o.useRef)(``),H=(0,o.useRef)(0);(0,o.useEffect)(()=>{if(!hO(m)||B.current||qD(O.to).length>0||r.length===0||V.current===b)return;let e=!1;return V.current=b,Promise.all(r.map(e=>n.hn(m,e).catch(()=>null))).then(t=>{if(e)return;let n=yO(t.map(bO).filter(Boolean),y);n.length&&k(e=>qD(e.to).length>0?e:{...e,to:[...new Set(n)].join(`, `)})}),()=>{e=!0}},[O.to,m,y,b,r]),(0,o.useEffect)(()=>{if(!E){j(!0);return}let e=++H.current,t=!1;async function n(){j(!1),N(!0),k(e=>({...e,contents:``}));try{let n=SO(await dn(E)),r=await pO(n.contents||``,m,i),a=r.contents;if(a.trim())try{a=await fn(a,n.subject||c)}catch(n){!t&&e===H.current&&s.message.warning(n?.message||`Mail content formatting failed. Showing original content.`)}if(t||e!==H.current)return;k(e=>({...e,subject:n.subject||e.subject,to:n.toMail?.length?Array.isArray(n.toMail)?n.toMail.join(`, `):String(n.toMail):e.to,cc:n.ccMail?.length?Array.isArray(n.ccMail)?n.ccMail.join(`, `):String(n.ccMail):e.cc,bcc:n.bccMail?.length?Array.isArray(n.bccMail)?n.bccMail.join(`, `):String(n.bccMail):e.bcc,contents:a||r.contents||e.contents,attachments:r.attachments,showCc:e.showCc||!!n.ccMail?.length,showBcc:e.showBcc||!!n.bccMail?.length}))}catch(n){!t&&e===H.current&&v&&s.message.error(n?.message||`Could not load mail template for this Job ID`)}finally{!t&&e===H.current&&(j(!0),N(!1))}}return n(),()=>{t=!0}},[E,v]);function ee(e=w){let t=String(e??``).trim();if(!lO.test(t)){D(``),t&&s.message.warning(`Enter a valid 24-character Job ID`);return}if(t===E){D(``),queueMicrotask(()=>D(t));return}D(t)}function U(e,t){if(!e){D(``),T(``);return}let n=t?.label??``;T(String(n||(e??``))),ee(e)}function te(e){let t=String(e??``).trim();if(T(t),t.length<3){F([]);return}L(!0),ie(t).then(e=>{let t=(Array.isArray(e)?e:[]).map(vO).filter(Boolean);F(t)}).catch(e=>s.message.error(e?.message||`Unable to search jobs`)).finally(()=>L(!1))}let ne=A&&(!v||lO.test(E))&&(!g||lO.test(_))&&qD(O.to).length+qD(O.cc).length+qD(O.bcc).length>0&&JD(O.to)&&JD(O.cc)&&JD(O.bcc)&&O.subject.trim()&&O.contents.trim();async function re(){if(!(!ne||R)){z(!0);try{await pn({jobId:E,leadId:_,toMail:qD(O.to),ccMail:qD(O.cc),bccMail:qD(O.bcc),subject:O.subject,contents:O.contents,attachments:O.attachments??[]}),s.message.success(`Mail sent successfully`),typeof p==`function`&&p({...O,message:O.contents,selectedIds:r}),e(-1)}catch(e){s.message.error(e?.message||`Failed to send mail`)}finally{z(!1)}}}function ae(e){e?.to!==O.to&&(B.current=!0),k(e)}return(0,l.jsx)(s.Drawer,{open:!0,placement:`right`,onClose:()=>e(-1),closable:!1,rootClassName:`mail-popup`,width:620,maskClosable:!1,footer:(0,l.jsxs)(`div`,{className:`mail-popup__footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>e(-1),children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:R,disabled:!ne,onClick:re,children:`Send`})]}),children:(0,l.jsx)(s.Spin,{spinning:M,tip:`Loading mail content...`,size:`large`,children:(0,l.jsx)(sO,{value:O,onChange:ae,moduleName:m,defaultTemplateId:v?``:h.defaultTemplateId??t.defaultTemplateId??``,ready:A,contextRecords:i,beforeFields:v?(0,l.jsxs)(`div`,{className:`mail-popup__job-row`,children:[(0,l.jsx)(cO,{type:`secondary`,className:`mail-popup__field-label`,children:`Job Title / ID`}),(0,l.jsx)(s.Select,{showSearch:!0,allowClear:!0,filterOption:!1,value:E||void 0,searchValue:w,onSearch:te,onChange:U,onClear:()=>{D(``),T(``),F([])},placeholder:`Minimum 3 characters`,notFoundContent:I||M?(0,l.jsx)(s.Spin,{size:`small`}):null,options:P,className:`mail-popup__job-input`})]}):null})})})}var{Text:wO}=s.Typography,TO=2,EO=`overview.summary.role summary.job summary.role overview.job description.description.about the role.about the job.job title.role.responsibilities.roles responsibilities.roles and responsibilities.roles & responsibilities.key responsibilities.requirements.required skills.preferred skills.technical skills.key skills.skills.competencies.nice to have.good to have.qualifications.required qualifications.preferred qualifications.education.experience.benefits`.split(`.`),DO=new Set(EO),OO=/(education|qualification)/i,kO=/(skill|competenc)/i,AO=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),jO=e=>e.replace(/\w[^\s/]*/g,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()),MO=e=>[...new Set(e)];function NO(e){let t=String(e);return t=t.replace(/<\s*(br|\/p|\/div|\/h[1-6]|\/li|\/tr)\s*\/?>/gi,`
18
18
  `).replace(/<\s*li[^>]*>/gi,`
19
19
  `).replace(/<[^>]+>/g,` `),t=t.replace(/&nbsp;/gi,` `).replace(/&amp;/gi,`&`).replace(/&lt;/gi,`<`).replace(/&gt;/gi,`>`).replace(/&#39;|&apos;/gi,`'`).replace(/&quot;/gi,`"`),t.replace(/[ \t\f\v]+/g,` `).replace(/\n{2,}/g,`
20
- `).trim()}function vO(e){return e.replace(/•/g,`
21
- `).split(/\n+/).map(e=>e.trim().replace(/^[-–—•]\s*/,``).trim()).filter(Boolean)}function yO(e){return vO(e.replace(/(?:^|\s)[-–—]\s+/g,`
22
- `))}function bO(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:hO(n),value:r}}function xO(e){let t=e.toLowerCase().replace(/[\s:.\-–—]+$/,``).trim();return dO.has(t)?fO.test(t)?`education`:pO.test(t)?`keySkills`:`overview`:null}function SO(e){let t=[],n={overview:[],keySkills:[],education:[]},r=`overview`;return e.forEach(e=>{let i=xO(e);if(i){r=i;return}if(r===`overview`){let n=bO(e);if(n){t.push(n);return}}n[r].push(e)}),{meta:t,overview:gO(n.overview),keySkills:gO(n.keySkills),education:gO(n.education)}}function CO(e){let t=[...uO].sort((e,t)=>t.length-e.length),n=RegExp(`\\b(${t.map(mO).join(`|`)})\\b\\s*:?`,`gi`),r=[...e.matchAll(n)];if(!r.length)return{meta:[],overview:gO(yO(e)),keySkills:[],education:[]};let i={overview:[],keySkills:[],education:[]},a=e.slice(0,r[0].index).trim();return a&&i.overview.push(...yO(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=yO(e.slice(o,s).trim());if(!c.length)return;let l=fO.test(a)?`education`:pO.test(a)?`keySkills`:`overview`;i[l].push(...c)}),{meta:[],overview:gO(i.overview),keySkills:gO(i.keySkills),education:gO(i.education)}}function wO(e){let t=_O(e);if(!t)return{meta:[],overview:[],keySkills:[],education:[]};let n=vO(t);return n.length>=4?SO(n):CO(t)}function TO({items:e}){return(0,l.jsx)(`ul`,{className:`jdv-ats-bullets`,children:e.map((e,t)=>(0,l.jsx)(`li`,{className:`jdv-ats-bullet-item`,children:e},t))})}function EO({raw:e=``,meta:t=[]}){let[n,r]=(0,o.useState)(!1),i=(0,o.useMemo)(()=>wO(e),[e]),a=t.length?t:i.meta,s=[];if(i.overview.length&&s.push({key:`overview`,title:`Overview`,items:i.overview}),i.keySkills.length&&s.push({key:`keySkills`,title:`Key Skills`,items:i.keySkills,card:!0,icon:`🛠️`}),i.education.length&&s.push({key:`education`,title:`Education`,items:i.education,card:!0,icon:`🎓`}),!a.length&&!s.length)return(0,l.jsx)(cO,{type:`secondary`,children:`No description available.`});let c=n?s:s.slice(0,lO),u=s.length-lO;return(0,l.jsxs)(`div`,{className:`jdv-ats-desc`,children:[a.length>0&&(0,l.jsx)(`div`,{className:`jdv-ats-meta-grid`,children:a.map(({fieldKey:e,fieldLabel:t,value:n})=>(0,l.jsxs)(`div`,{className:`jdv-ats-meta-row`,children:[(0,l.jsx)(`span`,{className:`jdv-ats-meta-key`,children:t}),(0,l.jsx)(`span`,{className:`jdv-ats-meta-val`,children:n})]},e??t))}),(0,l.jsx)(`div`,{className:`jdv-ats-sections`,children:c.map(e=>e.card?(0,l.jsxs)(`div`,{className:`education-block`,children:[(0,l.jsxs)(`div`,{className:`education-header`,children:[(0,l.jsx)(`span`,{children:e.icon}),(0,l.jsx)(`span`,{children:e.title})]}),(0,l.jsx)(`ul`,{className:`education-list`,children:e.items.map((e,t)=>(0,l.jsx)(`li`,{className:`education-list-item`,children:e},t))})]},e.key):(0,l.jsxs)(`div`,{className:`jdv-ats-section`,children:[(0,l.jsx)(`div`,{className:`jdv-ats-section-hd`,children:(0,l.jsx)(`span`,{children:e.title})}),(0,l.jsx)(TO,{items:e.items})]},e.key))}),u>0&&(0,l.jsx)(`span`,{className:`jdv-desc-toggle`,onClick:()=>r(e=>!e),children:n?`Show less`:`Show more (${u} more section${u>1?`s`:``})`})]})}var{Text:DO}=s.Typography;function OO(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function kO(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 AO(e){return e?e.email??e.emailId??e.emailAddress??``:``}function jO(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function MO(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 NO=[`jobDescription`,`description`,`rawDescription`,`jobDescriptionText`];function PO(e){return String(e??``).toLowerCase()===`job`}function FO(e){let t=NO.includes(e.field),n=/description/i.test(e.label??``);return t||n}function IO({record:e}){let t=kO(e),n=AO(e),r=jO(e);return!t&&!n?null:(0,l.jsxs)(`div`,{className:`preview-profile-card`,children:[(0,l.jsxs)(`div`,{className:`preview-profile-card__info`,children:[(0,l.jsx)(s.Avatar,{className:`preview-profile-card__avatar`,children:OO(t)}),(0,l.jsxs)(`div`,{className:`preview-profile-card__text`,children:[t&&(0,l.jsx)(`span`,{className:`preview-profile-card__name`,children:t}),n&&(0,l.jsx)(`span`,{className:`preview-profile-card__email`,children:n})]})]}),r&&(0,l.jsx)(s.Tag,{className:`preview-profile-card__status`,children:r})]})}function LO({fields:e,moduleName:t,centralDocuments:r=[]}){let[i,a]=(0,o.useState)([]),[s,c]=(0,o.useState)(0),[u,d]=(0,o.useState)(!1);if(!e?.length)return null;function f(e){let t=String(e?.type??``).trim().toLowerCase(),n=`${e?.field??``} ${e?.label??``}`;return[`file`,`document`,`upload`].includes(t)||/resume|cv|document|attachment/i.test(n)}function p(e,t){a(e),c(t),d(!0)}return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`preview-field-grid`,children:e.map(e=>{let i=e.value,a=Array.isArray(i)&&i.length>0,o=PO(t)&&FO(e)&&typeof i==`string`&&i.trim(),s=f(e)?r.filter(t=>{let n=String(t?.fieldName??t?.field??t?.formField??t?.key??``).trim().toLowerCase(),r=String(e?.field??``).trim().toLowerCase();if(n&&r&&n===r)return!0;let i=`${e?.field??``} ${e?.label??``}`;return/resume|cv/i.test(i)?/resume|cv/i.test(`${n} ${t?.fileName??``} ${t?.name??``}`):!1}).map(t=>({name:t?.fileName||t?.name||t?.uploadedFileName||t?.originalName||e?.label||`Document`,url:t?.fileUrl||t?.downloadUrl||t?.signedUrl||t?.url||``,type:t?.mimeType||t?.contentType||t?.type})).filter(e=>e.url):[],c=f(e)?s.length?s:n.Bt(i).filter(e=>e.url):[];return c.length?(0,l.jsxs)(`div`,{className:`preview-field-card preview-field-card--documents`,children:[(0,l.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,l.jsx)(`div`,{className:`preview-document-list`,children:c.map((e,t)=>(0,l.jsxs)(`button`,{type:`button`,className:`preview-document-link`,onClick:()=>p(c,t),title:`Preview ${e.name||`document`}`,children:[(0,l.jsx)(`span`,{className:`preview-document-link__icon`,"aria-hidden":`true`,children:`▣`}),(0,l.jsx)(`span`,{className:`preview-document-link__name`,children:e.name||`Document ${t+1}`}),(0,l.jsx)(`span`,{className:`preview-document-link__action`,children:`Preview`})]},`${e.url}-${t}`))})]},e.field??e.label):a?i.map((t,n)=>(0,l.jsxs)(`div`,{className:`preview-field-card`,children:[(0,l.jsxs)(`span`,{className:`preview-field-card__label`,children:[e.label,i.length>1?` (${n+1})`:``]}),(0,l.jsx)(`span`,{className:`preview-field-card__value`,children:MO(t)})]},`${e.field??e.label}-${n}`)):o?(0,l.jsxs)(`div`,{className:`preview-field-card preview-field-card--description`,children:[(0,l.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,l.jsx)(`div`,{className:`preview-field-card__description`,children:(0,l.jsx)(EO,{raw:i})})]},e.field??e.label):(0,l.jsxs)(`div`,{className:`preview-field-card`,children:[(0,l.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,l.jsx)(`span`,{className:`preview-field-card__value`,children:MO(i)})]},e.field??e.label)})}),(0,l.jsx)(n.En,{documents:i,open:u,onClose:()=>d(!1),initialIndex:s})]})}function RO(){let e=(0,d.useNavigate)(),{moduleName:t=``,record:r=null}=(0,d.useLocation)().state??{},i=r?.id??r?._id,[c,u]=(0,o.useState)([]),[f,p]=(0,o.useState)(!!(t&&i)),[m,h]=(0,o.useState)(null),[g,_]=(0,o.useState)([]),[v,y]=(0,o.useState)(0),b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)([]),C=(0,o.useRef)([]);(0,o.useEffect)(()=>{if(!t||!i)return;let e=!1;return Promise.all([a.r({module:t,id:i}),n.yn(t,i).catch(()=>({data:[]}))]).then(([t,n])=>{e||(u(Array.isArray(t)?t:[]),_(Array.isArray(n)?n:n?.data??[]),p(!1))}).catch(t=>{e||(h(t.message||`Failed to load preview`),_([]),p(!1))}),()=>{e=!0}},[t,i]);function w(){e(-1)}function T(e,t){return e?.label??e?.name??`Section ${t+1}`}function E(e){let t=b.current,n=C.current[e];if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=(t.querySelector(`.preview-stepper-wrap`)?.offsetHeight??0)+12,o=t.scrollTop+i.top-r.top-a;y(e),t.scrollTo({top:Math.max(0,o),behavior:`smooth`})}function D(){let e=b.current;if(!e||!C.current.length)return;let t=e.getBoundingClientRect().top+(e.querySelector(`.preview-stepper-wrap`)?.offsetHeight??0)+24,n=0;C.current.forEach((e,r)=>{e&&e.getBoundingClientRect().top<=t&&(n=r)}),y(e=>e===n?e:n)}(0,o.useEffect)(()=>{let e=x.current,t=S.current[v];if(!e||!t)return;let n=t.offsetLeft-(e.clientWidth-t.offsetWidth)/2,r=Math.max(0,e.scrollWidth-e.clientWidth);e.scrollTo({left:Math.min(Math.max(0,n),r),behavior:`smooth`})},[v,c.length]);function O(){return c.length?(0,l.jsx)(`div`,{ref:x,className:`preview-stepper-wrap`,"aria-label":`Preview sections`,children:(0,l.jsx)(`div`,{className:`preview-stepper`,children:c.map((e,t)=>(0,l.jsxs)(`div`,{className:`preview-stepper__segment`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`preview-stepper__item`,ref:e=>{S.current[t]=e},onClick:()=>E(t),"aria-current":v===t?`step`:void 0,title:`Go to ${T(e,t)}`,children:[(0,l.jsx)(`span`,{className:[`preview-stepper__circle`,t<v?`preview-stepper__circle--done`:``,t===v?`preview-stepper__circle--active`:``].filter(Boolean).join(` `),children:t+1}),(0,l.jsx)(`span`,{className:[`preview-stepper__label`,t===v?`preview-stepper__label--active`:``].filter(Boolean).join(` `),children:T(e,t)})]}),t<c.length-1&&(0,l.jsx)(`span`,{className:[`preview-stepper__line`,t<v?`preview-stepper__line--done`:``].filter(Boolean).join(` `),"aria-hidden":`true`})]},e.name??e.id??t))})}):null}let k=(0,l.jsxs)(`div`,{className:`preview-modal-header`,children:[(0,l.jsx)(`span`,{className:`preview-modal-module`,children:t.toUpperCase()}),(0,l.jsx)(`span`,{className:`preview-modal-title`,children:t?` Details`:`Preview`})]}),A=(0,l.jsx)(`div`,{className:`wizard-footer preview-scroll-footer`,children:(0,l.jsx)(`div`,{className:`wizard-footer-nav`,children:(0,l.jsx)(s.Button,{onClick:w,children:`Close`})})});function j(){return!t||!i?(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`Preview id is missing.`}):f?(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:(0,l.jsx)(s.Spin,{size:`small`})}):m?(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status job-preview-error`,children:m}):c.length?(0,l.jsx)(`div`,{className:`preview-section-list`,children:c.map((e,n)=>(0,l.jsxs)(`section`,{ref:e=>{C.current[n]=e},className:`preview-section-card`,"data-section-index":n,children:[(0,l.jsxs)(`div`,{className:`preview-section-card__header`,children:[(0,l.jsx)(`span`,{className:`preview-section-card__number`,children:n+1}),(0,l.jsx)(`span`,{className:`preview-section-card__title`,children:T(e,n)})]}),(0,l.jsx)(`div`,{className:`preview-section-card__body`,children:e.fields?.length>0?(0,l.jsx)(LO,{fields:e.fields,moduleName:t,centralDocuments:g}):(0,l.jsx)(DO,{type:`secondary`,children:`No fields in this group.`})})]},e.name??e.id??n))}):(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`No form groups found.`})}return(0,l.jsx)(s.Modal,{centered:!0,className:`wizard-modal preview-modal preview-scroll-modal`,footer:A,open:!0,title:k,width:`min(900px, calc(100vw - 32px))`,onCancel:w,maskClosable:!1,children:(0,l.jsxs)(`div`,{ref:b,className:`wizard-body preview-scroll-body`,onScroll:D,children:[!f&&!m&&c.length>0&&O(),r&&(0,l.jsx)(IO,{record:r}),j()]})})}var{Text:zO}=s.Typography,{TextArea:BO}=s.Input,VO=[{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 HO(e){switch(e.type){case`select`:return(0,l.jsx)(s.Select,{placeholder:e.placeholder,options:e.options,style:{width:`100%`}});case`textarea`:return(0,l.jsx)(BO,{rows:3,placeholder:e.placeholder});case`number`:return(0,l.jsx)(s.InputNumber,{placeholder:e.placeholder,style:{width:`100%`}});default:return(0,l.jsx)(s.Input,{type:e.inputType||`text`,placeholder:e.placeholder})}}function UO({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,l.jsxs)(`div`,{className:`wizard-review-content`,children:[r.map(e=>(0,l.jsxs)(`div`,{className:`wizard-review-section`,children:[(0,l.jsx)(zO,{className:`wizard-review-section-title`,children:e.title}),(0,l.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,l.jsxs)(`div`,{className:`wizard-review-row`,children:[(0,l.jsx)(`span`,{className:`wizard-review-label`,children:e.label}),(0,l.jsx)(`span`,{className:`wizard-review-separator`,children:`:`}),(0,l.jsx)(`span`,{className:`wizard-review-value`,children:r})]},e.name)})})]},e.key)),(0,l.jsxs)(`div`,{className:`wizard-review-confirm-note`,children:[(0,l.jsx)(c.CheckCircleOutlined,{className:`wizard-review-confirm-icon`}),(0,l.jsx)(zO,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,l.jsx)(`div`,{className:`wizard-review-empty`,children:(0,l.jsx)(zO,{type:`secondary`,children:`No data entered yet.`})})}function WO(){let[e]=s.Form.useForm(),t=(0,d.useNavigate)(),{title:n=`Wizard`,moduleName:r=``,steps:i=VO,onSubmit:a}=(0,d.useLocation)().state??{},[c,u]=(0,o.useState)(0),f=i[c],p=c===i.length-1,m=c===0;function h(){t(-1)}function g(){let t=(f.fields||[]).map(e=>e.name);e.validateFields(t.length>0?t:void 0).then(()=>{u(e=>e+1)})}function _(){u(e=>e-1)}function v(){let n=e.getFieldsValue();typeof a==`function`&&a(n),t(-1)}let y=i.map((e,t)=>({title:e.title,description:e.description,status:t<c?`finish`:t===c?`process`:`wait`})),b=r?`${n} — ${r}`:n;return(0,l.jsxs)(s.Modal,{open:!0,title:b,footer:(0,l.jsxs)(`div`,{className:`wizard-footer`,children:[(0,l.jsx)(s.Button,{onClick:h,children:`Cancel`}),(0,l.jsxs)(`div`,{className:`wizard-footer-nav`,children:[!m&&(0,l.jsx)(s.Button,{onClick:_,children:`Back`}),p?(0,l.jsx)(s.Button,{type:`primary`,onClick:v,children:`Submit`}):(0,l.jsx)(s.Button,{type:`primary`,onClick:g,children:`Next`})]})]}),onCancel:h,width:`min(680px, calc(100vw - 32px))`,centered:!0,className:`wizard-modal`,children:[(0,l.jsx)(`div`,{className:`wizard-steps-container`,children:(0,l.jsx)(s.Steps,{current:c,items:y,size:`small`,className:`wizard-steps`})}),(0,l.jsx)(`div`,{className:`wizard-body`,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,children:[i.filter(e=>!e.isReview).map((e,t)=>(0,l.jsx)(`div`,{style:{display:t===c?`block`:`none`},children:(0,l.jsx)(s.Row,{gutter:16,children:(e.fields||[]).map(e=>(0,l.jsx)(s.Col,{span:e.span||24,children:(0,l.jsx)(s.Form.Item,{name:e.name,label:e.label,rules:[...e.required?[{required:!0,message:`${e.label} is required`}]:[],...e.rules||[]],children:HO(e)})},e.name))})},e.key)),f.isReview&&(0,l.jsx)(UO,{steps:i,form:e})]})})]})}function GO({titleText:e,titleIcon:t}){let n=t===`delete`;return(0,l.jsxs)(`span`,{className:`dynamic-popup__header`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__header-icon-box${n?` dynamic-popup__header-icon-box--danger`:``}`,children:n?(0,l.jsx)(c.DeleteOutlined,{}):(0,l.jsx)(c.AppstoreOutlined,{})}),(0,l.jsx)(`span`,{className:`dynamic-popup__header-label`,children:e})]})}function KO({note:e,description:t,showSelectedCount:r,count:i,itemLabel:a,bodyText:o,deleteError:s}){return(0,l.jsxs)(l.Fragment,{children:[e&&(0,l.jsx)(n.kn,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:e}),t&&(0,l.jsx)(n.kn,{variant:`body`,className:`dynamic-popup__description`,children:t}),r&&i>0&&(0,l.jsxs)(n.kn,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,l.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),o&&(0,l.jsx)(n.kn,{variant:`body`,children:o}),s&&(0,l.jsx)(n.kn,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:s})]})}function qO({footerNote:e}){return e?(0,l.jsx)(n.kn,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:e}):null}function JO(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function YO(e){return String(e).replace(/\(\s*\)/g,``).replace(/\s+/g,` `).replace(/(^|\s)([-–—·|])(?=\s*\2)/g,``).replace(/^[\s\-–—·|]+/,``).replace(/[\s\-–—·|]+$/,``).trim()}function XO(e){if(!e)return!1;let t=new Date(e).getTime();return Number.isNaN(t)||t<=0?!1:t<=Date.now()+864e5}function ZO(e){if(!XO(e))return``;let t=new Date(e),n=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date,i=Math.round((n(r)-n(t))/864e5);if(i<=0)return`Today`;if(i===1)return`Yesterday`;if(i<=30)return`${i} days ago`;let a=(r.getFullYear()-t.getFullYear())*12+(r.getMonth()-t.getMonth());if(r.getDate()<t.getDate()&&--a,a=Math.max(1,a),a<12)return`${a} month${a===1?``:`s`} ago`;let o=Math.floor(a/12);return`${o} year${o===1?``:`s`} ago`}function QO(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 $O(e){let t=Array.isArray(e?.submissionHistory)?e.submissionHistory:[],n=[e?.lastSubmittedAt,e?.submittedAt,...t.map(e=>e?.submittedAt)].filter(Boolean);return n.length?n.reduce((e,t)=>new Date(t)>new Date(e)?t:e):null}function ek(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:ZO(QO(e))}:e,o=(i?YO(JO(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};if(c&&(u.disabled=!0),l&&(u.title=l),e?.isSubmitted===!0||e?.alreadySubmitted===!0){u.alreadySubmitted=!0,u.existingSubmissionId=String(e?.existingSubmissionId??e?.jobSubmissionId??e?.submissionId??``);let t=e?.submittedAt||$O(e);t&&(u.submittedAt=t)}if(e?.isFromSubmission===!0&&e?.submissionId){u.isFromSubmission=!0,u.priorSubmissionId=String(e.submissionId);let t=e?.lastSubmittedAt||$O(e);t&&(u.priorSubmittedAt=t)}return u}function tk(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>ek(t,e))}function nk(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var rk=`DD MMM YYYY`,ik=`DD MMM YYYY, h:mm A`;function ak(e,t){if(e==null||e===``)return``;let n=(0,u.default)(e);return n.isValid()?t===`relative`?ZO(e)||(XO(e)?n.format(rk):`Not updated`):XO(e)?n.format(rk):``:String(e)}function ok(e,t){return e?String(e).includes(`{`)?YO(JO(e,t)):String(t?.[e]??e).trim():``}function sk(e){if(e?.alreadySubmitted){let t=e?.submittedAt?(0,u.default)(e.submittedAt):null;return{tone:`blocked`,tooltip:t?.isValid()?`Already submitted to this job on ${t.format(ik)}`:`Already submitted to this job — a candidate can only be submitted once per job`}}if(e?.isFromSubmission){let t=e?.priorSubmittedAt?(0,u.default)(e.priorSubmittedAt):null;return{tone:`history`,tooltip:t?.isValid()?`Previously submitted on ${t.format(ik)} — this form will prefill from it`:`Submitted to another job before — this form will prefill from it`}}return null}function ck(e,t){return e?.alreadySubmitted||!e?.disabled?``:String(t?.message??e?.title??``).trim()}function lk({meta:e}){return(0,l.jsx)(`div`,{className:`dynamic-popup__option-dates`,children:e.map(e=>(0,l.jsxs)(o.Fragment,{children:[(0,l.jsx)(`span`,{className:`dynamic-popup__option-date-label`,children:e.label}),(0,l.jsx)(`span`,{className:`dynamic-popup__option-date-value`,children:e.text})]},e.label))})}function uk({option:e,layout:t}){let n=e?._raw??e??{},r=ok(t.id,n),i=ok(t.title,n)||String(e?.label??``),a=ok(t.subtitle,n),o=ok(t.titleAccent?.key,n),u=ok(t.titleAccent?.toneKey,n),d=t.titleAccent?.prefix??``,f=(t.meta??[]).map(e=>({label:e.label,text:ak(n?.[e.key],e.type)})).filter(e=>e.text),p=ck(e,n),m=sk(e);return(0,l.jsxs)(`div`,{className:`dynamic-popup__option`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__option-tick${m?` dynamic-popup__option-tick--${m.tone}`:``}`,children:m&&(0,l.jsx)(s.Tooltip,{title:m.tooltip,placement:`topLeft`,children:(0,l.jsx)(c.CheckCircleFilled,{"aria-label":m.tooltip})})}),(0,l.jsxs)(`div`,{className:`dynamic-popup__option-main`,children:[(0,l.jsxs)(`div`,{className:`dynamic-popup__option-head`,children:[r&&(0,l.jsx)(`span`,{className:`dynamic-popup__option-id`,children:r}),(0,l.jsxs)(`span`,{className:`dynamic-popup__option-title`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__option-title-text`,children:i}),o&&(0,l.jsx)(`span`,{className:`dynamic-popup__option-title-accent${u?` dynamic-popup__option-title-accent--${u}`:``}`,children:`${d}${o}`})]}),p&&(0,l.jsx)(`span`,{className:`dynamic-popup__option-flag`,children:p})]}),a&&(0,l.jsx)(`div`,{className:`dynamic-popup__option-sub`,children:a})]}),e?.alreadySubmitted?(0,l.jsx)(`span`,{className:`dynamic-popup__option-onjob`,children:`On this job`}):f.length>0&&(0,l.jsx)(lk,{meta:f})]})}var{Text:dk}=s.Typography,{TextArea:fk}=s.Input,pk=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],mk=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function hk(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 gk({field:e,value:t,onChange:n}){return(0,l.jsx)(s.Input,{value:t,onChange:n,placeholder:e.placeholder,maxLength:e.maxLength,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function _k({field:e,value:t,onChange:n}){return(0,l.jsx)(fk,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder,maxLength:e.maxLength,showCount:!!e.maxLength})}function vk({field:e,options:t,value:n,onChange:r}){let i=hk(t);return(0,l.jsx)(s.Select,{showSearch:!0,value:n,onChange:r,options:i,placeholder:e.placeholder,className:`dynamic-popup__field-select`,optionFilterProp:`label`,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function yk({field:e,options:t,value:n,onChange:r}){let i=hk(t);return(0,l.jsx)(s.Select,{mode:`multiple`,showSearch:!0,value:n,onChange:r,options:i,placeholder:e.placeholder,className:`dynamic-popup__field-select`,optionFilterProp:`label`,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function bk({field:e,options:t,onSearch:n,value:r,onChange:i,popupContext:a}){let o=hk(t),u=e.optionLayout,d=new Map(o.map(e=>[String(e?.value??``),e]));async function f(t,n){if(e.multiple){i?.(Array.isArray(t)?t:[]);return}let r=n??d.get(String(t??``));(typeof e.onSelectGuard!=`function`||await e.onSelectGuard({value:t,option:r,field:e,popupContext:a,confirm:s.Modal.confirm})!==!1)&&i?.(t)}return(0,l.jsx)(s.Select,{mode:e.multiple?`multiple`:void 0,showSearch:!0,filterOption:!1,notFoundContent:e.notFoundContent??null,value:r,onChange:f,options:o,placeholder:e.placeholder,onSearch:n,className:`dynamic-popup__field-select${u?` dynamic-popup__field-select--rich`:``}`,popupClassName:u?`dynamic-popup__option-dropdown`:void 0,listHeight:u?340:void 0,optionLabelProp:`label`,optionRender:u?e=>(0,l.jsx)(uk,{option:e?.data??e,layout:u}):void 0,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function xk({field:e,mentionOpts:t,onMentionSearch:n,value:r,onChange:i}){let a=Number(e.maxLength)>0?Number(e.maxLength):void 0,o=String(r??``).length;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Mentions,{value:r,onChange:i,rows:e.rows??5,placeholder:e.placeholder,prefix:`@`,options:t,onSearch:n,maxLength:a,className:`dynamic-popup__mention-textarea`}),a?(0,l.jsxs)(`div`,{className:`dynamic-popup__char-count`,style:{textAlign:`right`,fontSize:12,marginTop:4,color:o>a*.9?`#b45309`:`#8c8c8c`},children:[o,` / `,a]}):null]})}function Sk({field:e={},value:t={},onChange:n}){let r=t.period??`Hourly`,i=t.isRange??!1;function a(e){n?.({...t,...e})}(0,o.useEffect)(()=>{let e={};t.currency??(e.currency=`$`),t.period??(e.period=`Hourly`),Object.keys(e).length&&n?.({...t,...e})},[]);let c=Number(i?t.maxAmount:t.amount),u=i&&t.minAmount!=null&&t.maxAmount!=null&&Number(t.maxAmount)<=Number(t.minAmount),d=e.rateCeiling!=null&&Number.isFinite(c)&&c>Number(e.rateCeiling);return(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(s.Space.Compact,{style:{width:`100%`},children:[i?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.InputNumber,{controls:!1,placeholder:`From`,value:t.minAmount,onChange:e=>a({minAmount:e}),style:{flex:1}}),(0,l.jsx)(s.InputNumber,{controls:!1,placeholder:`To`,value:t.maxAmount,onChange:e=>a({maxAmount:e}),style:{flex:1}})]}):(0,l.jsx)(s.InputNumber,{controls:!1,placeholder:`0`,value:t.amount,onChange:e=>a({amount:e}),style:{flex:2}}),(0,l.jsx)(s.Select,{value:t.currency??`$`,options:pk,onChange:e=>a({currency:e}),style:{width:80}}),(0,l.jsx)(s.Select,{value:r,options:mk,onChange:e=>a({period:e}),style:{width:110}})]}),(u||d)&&(0,l.jsxs)(`div`,{style:{marginTop:4},children:[u&&(0,l.jsx)(dk,{type:`danger`,style:{fontSize:12,display:`block`},children:`To rate must be greater than From rate.`}),d&&(0,l.jsxs)(dk,{type:`danger`,style:{fontSize:12,display:`block`},children:[`Rate must not exceed the client rate (`,e.rateCeiling,`).`]})]}),(0,l.jsxs)(s.Space,{size:`small`,style:{marginTop:8},children:[(0,l.jsx)(s.Switch,{checked:i,onChange:e=>a({isRange:e})}),(0,l.jsx)(`span`,{children:`Range`})]})]})}function Ck({field:e,value:t,onChange:n}){return(0,l.jsx)(s.DatePicker,{value:t,onChange:n,placeholder:e.placeholder??`Select date`,style:{width:`100%`},format:`YYYY-MM-DD`})}function wk({field:e,checked:t,onChange:n}){return(0,l.jsx)(s.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function Tk({field:e,value:t,onChange:n}){return(0,l.jsx)(s.InputNumber,{value:t,onChange:n,min:e.min,max:e.max,placeholder:e.placeholder,style:{width:`100%`}})}function Ek({options:e,value:t,onChange:n}){return(0,l.jsx)(s.Radio.Group,{value:t,onChange:n,options:e})}var Dk={input:gk,text:gk,textarea:_k,select:vk,"multi-select":yk,"search-select":bk,"mention-textarea":xk,"candidate-rate":Sk,"priority-checkbox":wk,"date-picker":Ck,number:Tk,radio:Ek};function Ok(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}var kk=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function Ak({form:e,fields:t,initialValues:r,dynamicOptions:i,popupContext:a,extraData:o,removedIds:c,setRemovedIds:u,showAlreadyAssigned:d,onValuesChange:f,getSearchHandler:p,getMentionSearchHandler:m,mentionOptions:h}){let g=(o?.recruitersData??[]).filter(e=>{let t=String(e?.user_id??e?.id??e?.userId??``);return t&&!c.includes(t)}),_=d&&o,v=new Set(d?g.map(e=>String(e?.user_id??e?.id??e?.userId??``).trim()).filter(Boolean):[]),y=e=>v.size===0||!Array.isArray(e)?e:e.filter(e=>!v.has(String((e&&typeof e==`object`?e.value??e.id:e)??``).trim()));return!t.length&&!_?null:(0,l.jsxs)(l.Fragment,{children:[_&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`dynamic-popup__already-assigned`,children:[(0,l.jsx)(n.kn,{variant:`caption`,color:`secondary`,children:`Already Assigned People`}),(0,l.jsx)(`div`,{style:{marginTop:6,display:`flex`,flexWrap:`wrap`,gap:6},children:g.length===0?(0,l.jsx)(n.kn,{variant:`caption`,color:`secondary`,children:`No one is currently assigned to this job.`}):g.map(e=>{let t=String(e?.user_id??e?.id??e?.userId??``),n=e?.name??e?.user_name??e?.userName??e?.email??`Assigned user`;return(0,l.jsx)(s.Tag,{closable:!0,onClose:()=>{t&&u(e=>Array.from(new Set([...e,t])))},children:n},t||n)})})]}),(0,l.jsx)(s.Divider,{style:{margin:`12px 0`}})]}),t.length>0&&(0,l.jsx)(s.Form,{form:e,layout:`vertical`,initialValues:r,onValuesChange:(e,t)=>f(t),children:jk(t).map(e=>Mk(e,e=>{let t=y(i[e.name]??tk(e,a)),r=p(e),o=m(e),c=h[e.name]??[],u=Ok(e.type),d=Dk[e.type],f=[];return e.required&&f.push({required:!0,message:`${e.label||`This field`} is required`}),typeof e.validator==`function`&&f.push({validator:(t,n)=>{let r=e.validator(n,a);return r?Promise.reject(Error(r)):Promise.resolve()}}),kk.has(e.type)&&f.push(n.cn({label:e.label,field:e.name,type:e.type,maxLength:e.maxLength})),(0,l.jsx)(s.Form.Item,{name:e.name,label:e.label,rules:f,...u,children:d?(0,l.jsx)(d,{field:e,options:t,onSearch:r,mentionOpts:c,onMentionSearch:o,popupContext:a}):null},e.name)}))})]})}function jk(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 Mk(e,t){return e.length===1?t(e[0]):(0,l.jsx)(`div`,{style:{display:`flex`,gap:8,alignItems:`flex-start`},children:e.map((e,n)=>(0,l.jsx)(`div`,{style:{flex:n===0?2:1,minWidth:0},children:t(e)},e.name))},`row-${e.map(e=>e.name).join(`-`)}`)}function Nk(e){return[`select`,`multi-select`,`search-select`,`radio`].includes(e?.type)&&e?.dataSource===`master`&&e?.masterName}function Pk(e){let t=e?.data??e;return Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.items)?t.items:Array.isArray(t?.rows)?t.rows:Array.isArray(t?.records)?t.records:[]}function Fk(e){let t=String(e?.masterName??``).trim().toLowerCase();return t===`clientsubmissions`||t===`clientsubmissionstatus`}function Ik(e){if(e==null)return null;if(typeof e==`string`){let t=e.trim();return t?{label:t,value:t,_raw:{name:t}}:null}let t=String(e?.name??e?.clientSubmissionStatusText??e?.label??e?.text??``).trim();if(!t)return null;let n=Number(e?.id??e?.uniqueId??e?.clientSubmissionStatusId??e?.value??0)||0;return{label:t,value:t,_raw:{...e,...n>0?{id:n,uniqueId:n}:{},name:t,type:String(e?.type??e?.clientSubmissionStatusType??``).trim(),isInitialStatus:e?.isInitialStatus===!0,isTerminalStatus:e?.isTerminalStatus===!0,allowedNextStatusIds:Array.isArray(e?.allowedNextStatusIds)?e.allowedNextStatusIds.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}}}function Lk(e,t){return Fk(t)?Ik(e):ek(e,t)}function Rk(e){let t=e?.clientSubmissionStatus,n=Number((t&&typeof t==`object`?t?.clientSubmissionStatusId??t?.id??t?.uniqueId:void 0)??e?.clientSubmissionStatusId??e?.clientStatusId??e?.[`clientSubmissionStatus.clientSubmissionStatusId`]??0)||0,r=t&&typeof t==`object`?t?.clientSubmissionStatusText??t?.name??t?.text??t?.label:t;return{id:n,text:String(r??e?.clientSubmissionStatusText??e?.clientStatus??e?.clientStatusText??e?.[`clientSubmissionStatus.clientSubmissionStatusText`]??``).trim()}}function zk(e){let t=Number(e?.id??0)||0,n=String(e?.text??``).trim();return n&&n.toLowerCase()===`not submitted`?!0:t<=0&&!n}function Bk(e){return Number(e?._raw?.id??e?._raw?.uniqueId??0)||0}function Vk(e){let t=e?._raw?.allowedNextStatusIds;return Array.isArray(t)?t.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}function Hk(e){let t=e?.data??e;return t?Array.isArray(t)?t[0]??null:t?.record&&typeof t.record==`object`?t.record:t?.data&&typeof t.data==`object`&&!Array.isArray(t.data)?t.data:typeof t==`object`?t:null:null}function Uk(e){return(Array.isArray(e?.selectedRecords)?e.selectedRecords.filter(Boolean):[]).some(e=>!zk(Rk(e)))?!0:!zk(Rk(e??{}))}async function Wk(e,n){if(Uk(e))return e;let r=e?.selectedIds?.[0]??e?.selectedRecords?.[0]?._id??e?.selectedRecords?.[0]?.id;if(!r)return e;let i=String(e?.moduleName??`submissions`).trim()||`submissions`,a=new URLSearchParams({module:i,id:String(r)});n&&a.set(`app_id`,n);try{let r=Hk(await t.o(t.x,`/module-data-detail?${a.toString()}`,{headers:n?{"X-App-Id":n}:void 0}));if(!r)return e;let i=Array.isArray(e?.selectedRecords)?e.selectedRecords:[];return{...e,selectedRecords:i.length?i.map((e,t)=>t===0?{...e,...r}:e):[r]}}catch(t){return console.warn(`[DynamicPopup] Could not load selected submission detail for client status transition:`,t),e}}function Gk(e,t){if(!Array.isArray(e)||!e.length)return[];if(!e.some(e=>e?._raw?.isInitialStatus===!0||e?._raw?.isTerminalStatus===!0||Array.isArray(e?._raw?.allowedNextStatusIds)))return e;let n=Array.isArray(t?.selectedRecords)?t.selectedRecords.filter(Boolean):[],r={clientSubmissionStatus:t?.clientSubmissionStatus,clientSubmissionStatusId:t?.clientSubmissionStatusId,clientSubmissionStatusText:t?.clientSubmissionStatusText,clientStatus:t?.clientStatus,clientStatusId:t?.clientStatusId,clientStatusText:t?.clientStatusText,"clientSubmissionStatus.clientSubmissionStatusId":t?.[`clientSubmissionStatus.clientSubmissionStatusId`],"clientSubmissionStatus.clientSubmissionStatusText":t?.[`clientSubmissionStatus.clientSubmissionStatusText`]},i=n.length?n:[r];return e.filter(t=>i.every(n=>{let i=Rk(n);if(zk(i)){let e=Rk(r);zk(e)||(i=e)}if(zk(i))return t?._raw?.isInitialStatus===!0;let a=e.find(e=>{let t=Bk(e),n=String(e?.label??``).trim();return i.id>0&&t===i.id||i.text&&n.toLowerCase()===i.text.toLowerCase()});return!a||a?._raw?.isTerminalStatus===!0?!1:Vk(a).includes(Bk(t))}))}function Kk({open:e,config:n,api:r,fields:i,popupContext:a,formValues:s}){let[c,l]=(0,o.useState)({}),[u,d]=(0,o.useState)(null);return(0,o.useEffect)(()=>{e||(l({}),d(null))},[e]),(0,o.useEffect)(()=>{if(!e||!n||!r.getOptions)return;let t=new AbortController;return i.forEach(e=>{!e.fetchOptionsKey||e.fetchOptionsParamKey||Promise.resolve(r.getOptions(e,void 0,a)).then(n=>{t.signal.aborted||l(t=>({...t,[e.name]:n}))}).catch(n=>{t.signal.aborted||console.error(`[DynamicPopup] Failed to load options for field "${e.name}":`,n)})}),()=>t.abort()},[e,r,n,i,a]),(0,o.useEffect)(()=>{if(!e||!n)return;let r=i.filter(Nk);if(!r.length)return;let o=new AbortController;return r.forEach(e=>{let n=new URLSearchParams({masterName:e.masterName,offset:`0`,limit:String(e.limit??50)}),r=String(t.b??``).trim();r&&n.set(`app_id`,r),t.o(t.x,`/masters/dropdown?${n.toString()}`,{headers:r?{"X-App-Id":r}:void 0}).then(async t=>{if(o.signal.aborted)return;let n=Pk(t).map(t=>Lk(t,e)).filter(Boolean),i=a;if(Fk(e)&&(i=await Wk(a,r)),o.signal.aborted)return;let s=Fk(e)?Gk(n,i):n;l(t=>({...t,[e.name]:s}))}).catch(t=>{o.signal.aborted||console.error(`[DynamicPopup] Failed to load master options for field "${e.name}":`,t)})}),()=>o.abort()},[e,n,i,a]),(0,o.useEffect)(()=>{if(!e||!n||!r.getOptions)return;let t=i.filter(e=>e.fetchOptionsKey&&e.fetchOptionsParamKey);if(!t.length)return;let o=new AbortController;return t.forEach(e=>{let t=s[e.fetchOptionsParamKey]??a[e.fetchOptionsParamKey],n={[e.fetchOptionsParamKey]:t};Promise.resolve(r.getOptions(e,n,a)).then(t=>{o.signal.aborted||l(n=>({...n,[e.name]:t}))}).catch(t=>{o.signal.aborted||console.error(`[DynamicPopup] Failed to load param-dependent options for "${e.name}":`,t)})}),()=>o.abort()},[e,r,n,i,s,a]),(0,o.useEffect)(()=>{if(!e||!n||!r.loadExtraData)return;let t=new AbortController;return Promise.resolve(r.loadExtraData(a)).then(e=>{t.signal.aborted||d(e)}).catch(e=>{t.signal.aborted||(console.error(`[DynamicPopup] Failed to load extra data:`,e),d(null))}),()=>t.abort()},[e,r,n,a]),{dynamicOptions:c,setDynamicOptions:l,extraData:u}}var qk=500,Jk=3;function Yk({api:e,open:t,fields:n=[],popupContext:r,setDynamicOptions:i}){let[a,s]=(0,o.useState)({}),c=(0,o.useRef)({}),l=(0,o.useRef)({}),u=(0,o.useRef)({}),d=(0,o.useCallback)((t,n)=>{let a=e.searchOptions??e.searchFetcher;if(typeof a!=`function`)return;l.current[t.name]?.abort();let o=new AbortController;return l.current[t.name]=o,Promise.resolve(a(t,n,r)).then(e=>{if(o.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];i(e=>({...e,[t.name]:n.map(e=>ek(e,t))}))}).catch(e=>{o.signal.aborted||console.error(`[DynamicPopup] Search failed for field "${t.name}":`,e)}),o},[e,r,i]),f=n.filter(e=>(e.searchFetchKey||e.searchFetcher)&&e.preloadOptions!==!1),p=f.map(e=>e.name).join(`|`),m=(0,o.useRef)({runSearch:d,preloadFields:f});(0,o.useEffect)(()=>{m.current={runSearch:d,preloadFields:f}}),(0,o.useEffect)(()=>{if(!t||!p)return;let{runSearch:e,preloadFields:n}=m.current,r=n.map(t=>e(t,``)).filter(Boolean);return()=>r.forEach(e=>e.abort())},[t,p]);function h(t){if(!t.searchFetchKey&&!t.searchFetcher||typeof(e.searchOptions??e.searchFetcher)!=`function`)return;let n=t.searchMinLength??Jk;return e=>{clearTimeout(c.current[t.name]);let r=e.length<n?``:e;c.current[t.name]=setTimeout(()=>{d(t,r)},qk)}}function g(t){let n=e.getMentionOptions??e.mentionFetcher;if(typeof n==`function`)return e=>{u.current[t.name]?.abort();let i=new AbortController;u.current[t.name]=i,Promise.resolve(n(t,e,r)).then(e=>{if(i.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];s(e=>({...e,[t.name]:n.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 "${t.name}":`,e)})}}return{mentionOptions:a,getSearchHandler:h,getMentionSearchHandler:g}}function Xk({form:e,config:t,api:n,popupContext:r,resolvedIds:i,dynamicOptions:a,extraData:c,removedIds:l,removalOnlySubmit:u=!1,fields:d,onClose:f,onSubmit:p}){let[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(null);async function v(e){let t={resolvedIds:i,dynamicOptions:a,extraData:c,removedIds:l};if(typeof n.submit==`function`)return n.submit(e,r,t);if(typeof p==`function`)return p(e,r,t)}function y(){if(t){if(!d.length){if(t.mode===`delete`&&typeof n.deleteItems==`function`){h(!0),_(null),Promise.resolve(n.deleteItems(i,r)).then(()=>{s.message.success(t.successMessage||`Deleted successfully`),f({success:!0})}).catch(e=>{let t=e?.message||`Delete failed. Please try again.`;_(t),h(!1),s.message.error(t)});return}if(typeof n.onOk==`function`){h(!0),Promise.resolve(n.onOk(r)).then(()=>f({success:!0})).catch(e=>{let t=e?.message||`Failed. Please try again.`;s.message.error(t),h(!1)});return}if(typeof n.submit==`function`){h(!0),Promise.resolve(v({})).then(e=>{e?.cancelled||e?.navigated||(s.message.success(t.successMessage||`Saved successfully`),f({success:!0}))}).catch(e=>{s.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>h(!1));return}f();return}if(u){h(!0),Promise.resolve(v(e.getFieldsValue())).then(e=>{e?.cancelled||e?.navigated||(s.message.success(t.successMessage||`Saved successfully`),f({success:!0}))}).catch(e=>{s.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>h(!1));return}e.validateFields().then(async e=>{h(!0);try{let n=await v(e);if(n?.cancelled||n?.navigated)return;s.message.success(t.successMessage||`Saved successfully`),f({success:!0})}catch(e){s.message.error(e?.message||`Failed. Please try again.`)}finally{h(!1)}}).catch(()=>{})}}function b(){h(!1),_(null)}return{handleOk:y,confirming:m,deleteError:g,resetSubmitState:b}}function Zk({open:e=!0,config:t,context:n={},onClose:r,onSubmit:i,api:a={}}){let[c]=s.Form.useForm(),[d,f]=(0,o.useState)({}),[p,m]=(0,o.useState)([]),h=s.Form.useWatch([],c,{preserve:!0})??{},g=(0,o.useMemo)(()=>nk(n),[n]),{selectedIds:_=[],selectedRecords:v=[],moduleName:y=``}=g,b=(0,o.useMemo)(()=>_.map((e,t)=>{let n=v[t];return n?.id??n?._id??e}),[_,v]),x=(0,o.useMemo)(()=>t?typeof t.getFields==`function`?t.getFields(g):t.fields??[]:[],[t,g]),S=(0,o.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,u.default)(n):n)}),e},[x,g]),{dynamicOptions:C,setDynamicOptions:w,extraData:T}=Kk({open:e,config:t,api:a,fields:x,popupContext:g,formValues:d}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=Yk({api:a,open:e,fields:x,popupContext:g,setDynamicOptions:w});function k(e){typeof r==`function`&&r(e)}let A=x.filter(e=>e.required),j=A.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)}),M=(g.removedIds??[]).length,N=p.length>M,P=A.some(e=>{let t=h[e.name];return!(t==null||t===``||Array.isArray(t)&&t.length===0)}),{handleOk:F,confirming:I,deleteError:L,resetSubmitState:R}=Xk({form:c,config:t,api:a,popupContext:g,resolvedIds:b,dynamicOptions:C,extraData:T,removedIds:p,removalOnlySubmit:!!t?.allowRemovalOnlySubmit&&N&&!P,fields:x,onClose:k,onSubmit:i});(0,o.useEffect)(()=>{e&&(c.resetFields(),f(S??{}),m(g.removedIds??[]),R())},[e,S]);let z=!!t?.autoSubmitWhenNoFields&&x.length===0;(0,o.useEffect)(()=>{!e||!z||F()},[e,z]);let B=_.length,V=String(y).replace(/s$/i,``),H=B===1?V:y,ee=v[0]??{},U=t?.getTitleText?t.getTitleText(B,H,ee,g):t?.title,te=B===1?ee.jobTitle??ee.title??ee.name??ee.fullName??ee.candidateName??null:null,ne=t?.getBodyText?t.getBodyText(B,V,H,te,g):t?.bodyText??null,re=typeof t?.getNote==`function`?t.getNote(g):t?.note,ie=t?.disabledUntilFilled&&!j&&!N;if(!t||!e||z)return null;let ae=t.component;return ae?(0,l.jsx)(s.Modal,{open:e,title:t.title||t.getTitleText?(0,l.jsx)(GO,{titleText:U,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,l.jsx)(ae,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:k})}):(0,l.jsxs)(s.Modal,{open:e,title:(0,l.jsx)(GO,{titleText:U,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:F,onCancel:()=>k(),okButtonProps:{danger:t.okButtonDanger,disabled:ie,loading:I},cancelButtonProps:{disabled:I},closable:!I,maskClosable:!1,width:t.width??480,centered:!0,className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:[(0,l.jsx)(KO,{note:re,description:t.description,showSelectedCount:t.showSelectedCount,count:B,itemLabel:H,bodyText:ne,deleteError:L}),(0,l.jsx)(qO,{footerNote:t.footerNote}),(0,l.jsx)(Ak,{form:c,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 Qk={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:[]},$k={deleteItems:async(e,t)=>{await re(t.moduleName,e)}},eA=new Map;async function tA(e){return e?(eA.has(e)||eA.set(e,a.r({module:e}).catch(t=>(eA.delete(e),console.warn(`[in-progress gate] could not read ${e} form groups:`,t),[]))),eA.get(e)):[]}function nA(e=[],t){return e.some(e=>{let r=n.C(e,t);return r&&r.severity!==`allow`})}async function rA({targetModule:e,sourceModule:t,recordId:r,region:i}={}){let o={severity:`allow`,message:``,group:null};if(!e||!t||!r)return o;let s=i??n.Un().region;try{let i=await tA(e);if(!nA(i,s))return o;let c=await a.r({module:t,id:r}),l={};for(let e of c){let t=e?.payloadKey||e?.name;t&&Array.isArray(e?.rows)&&(l[t]=e.rows)}return n.D(i,s,l)}catch(e){return console.warn(`[in-progress gate] check skipped:`,e),o}}var iA=`Already submitted`,aA=`submissions`,oA=`candidates`,sA=864e5,cA=90,lA=`This candidate was created or last updated more than 90 days ago. Only candidates created or updated within the last 90 days can be selected. Please update this candidate first.`,uA=[`createdAt`,`createdDate`,`dateCreated`,`created_on`,`createdOn`],dA=[`updatedAt`,`updatedDate`,`lastUpdatedAt`,`lastUpdatedDate`,`modifiedAt`,`modifiedDate`];function fA(e,t){for(let n of t){let t=e?.[n];if(!t)continue;let r=new Date(t);if(!Number.isNaN(r.getTime()))return r}return null}function pA(e){return fA(e,uA)}function mA(e){return fA(e,dA)}function hA(e){if(!(e instanceof Date)||Number.isNaN(e.getTime()))return null;let t=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();return Math.max(0,Math.floor((t(new Date)-t(e))/sA))}function gA(e){return e===null?``:e<=14?`green`:e<=89?`yellow`:`red`}function _A(e,t=cA){if(!e)return!1;let n=Date.now()-t*sA,r=pA(e),i=mA(e),a=r&&r.getTime()>=n,o=i&&i.getTime()>=n;return!a&&!o}function vA(e){let t=pA(e);if(!t)return{createdAgo:``,createdAgoTone:``};let n=ZO(t);return n?{createdAgo:n,createdAgoTone:gA(hA(t))}:{createdAgo:``,createdAgoTone:``}}function yA(e){return{...e,...vA(e),isStaleCandidate:_A(e)}}function bA(e){return String(e?.applicantId??e?._id??e?.id??``)}var xA=null;async function SA(){return xA||=n.Rr(oA).then(e=>e?.strategies?.duplicateCheck?.editRoute??``).catch(()=>``),xA}async function CA(e){let t=bA(e);if(!t)return``;let n=await SA();return n?n.replace(/:(_?id)\b/g,encodeURIComponent(t)):``}async function wA({option:e,popupContext:t,confirm:n}){let r=e?._raw??e??{},i=bA(r);if(i){let e=await rA({targetModule:aA,sourceModule:oA,recordId:i});if(e.severity===`block`)return new Promise(t=>{n({title:`This candidate cannot be submitted`,content:e.message,okText:`Pick someone else`,cancelText:`Close`,onOk:()=>t(!1),onCancel:()=>t(!1)})})}if(!_A(r))return!0;let a=t?.navigate;return!a||!i?!1:new Promise(e=>{n({title:`Candidate update required`,content:lA,okText:`OK`,cancelText:`Cancel`,onOk:async()=>{let t=await CA(r);t&&a(t),e(!1)},onCancel:()=>e(!1)})})}function TA(e,t,n){return{...e,label:`${e.label} - ${iA}`,disabled:!0,title:`${iA}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}var EA={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 Ce({searchQuery:t,candidateId:r})}catch{a=!1;let e=await Ln({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?.isSubmitted||e._raw?.alreadySubmitted)return TA(e,e._raw?.jobSubmissionId||``,e._raw?.submittedAt||``);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 Te({applicantId:r,jobIds:o.map(e=>e.value)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e.value));return t?TA(e,t.submissionId,t.submittedAt):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 we({search:t,jobId:r})}catch{let e=await is({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await Te({jobId:r,applicantIds:i.map(bA)}).catch(()=>new Map)}return i.map(e=>yA(e)).map(e=>{let t=a.get(bA(e));if(!(t||e?.isSubmitted===!0||e?.alreadySubmitted===!0))return e;let n=t?.submissionId||e?.jobSubmissionId||``,r=t?.submittedAt||e?.submittedAt||``;return{...e,disabled:!0,optionNote:iA,isSubmitted:!0,alreadySubmitted:!0,existingSubmissionId:n,...r?{submittedAt:r}:{}}})}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=>bA(e?._raw)===String(l)),d=n?.dynamicOptions?.jobId?.find(e=>String(e?.value)===String(c)),f=u?._raw?.isSubmitted||u?._raw?.alreadySubmitted||d?.alreadySubmitted||d?._raw?.isSubmitted||d?._raw?.alreadySubmitted;if(!c||!l)throw Error(`Select both a job and a candidate to quick submit.`);if(_A(u?._raw))throw Error(lA);let p=await rA({targetModule:aA,sourceModule:oA,recordId:l});if(p.severity===`block`)throw Error(p.message);let m=f,h=u?._raw?.existingSubmissionId||u?._raw?.jobSubmissionId||d?.existingSubmissionId||d?._raw?.jobSubmissionId||``;try{let e=await Se({jobId:c,applicantId:l});m||=!!e?.exists,h=e?.submissionId||h}catch(e){throw Error(`Could not verify existing submissions (${e?.message??`request failed`}). Please try again.`,{cause:e})}if(m)throw Error(`This candidate is already submitted for this job${h?` (submission ${h})`:``}.`);let g=new URLSearchParams;l&&g.set(`candidateId`,l);let _=u?.priorSubmissionId||u?._raw?.submissionId||d?.priorSubmissionId||d?._raw?.submissionId||``;_?(g.set(`submissionId`,String(_)),g.set(`isFromSubmission`,`true`)):g.set(`isFromSubmission`,`false`);let v=ts(rs({jobId:c,applicantId:l}).catch(()=>[]));return r(`/submission-create/${c}?${g.toString()}`,{state:{relevantSkillsToken:v}}),{navigated:!0}}},DA={title:`Submit`,okText:`Submit`,width:640,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 - or pick a recent job`,searchFetchKey:`quickSubmitJobList`,optionLayout:{id:`{jobReferenceId}`,title:`{jobTitle}`,subtitle:`{clientJobReferenceId}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]}}]:[{name:`candidate`,label:`Candidate`,type:`search-select`,required:!0,placeholder:`Search candidate name / email - or pick a recent candidate`,optionsKey:`candidateOptions`,searchFetchKey:`quickSubmitCandidates`,labelTemplate:`{applicantRefrenceId} - {firstName} {lastName} - {createdAgo}`,valueKey:`applicantId`,optionLayout:{id:`{applicantRefrenceId}`,title:`{firstName} {lastName}`,titleAccent:{key:`createdAgo`,toneKey:`createdAgoTone`,prefix:` - `},subtitle:`{designation} - {email}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]},onSelectGuard:wA}]},OA={title:`Add Notes & Share`,okText:`Save & Share`,width:480,fields:[{name:`notes`,label:`Notes`,type:`mention-textarea`,required:!0,rows:5,maxLength:2e3,placeholder:`Add your notes on the job. Use '@' to mention someone.`,mentionFetchKey:`mentionUsers`}]},kA=e=>e?.data??e;async function AA({relatedId:e,notes:n,title:r,notesFor:i}){return kA(await yn(t.x,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var jA={getMentionOptions:async(e,t)=>ae(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 AA({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},MA={name:`jobId`,label:`Job Title / ID`,type:`search-select`,multiple:!0,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle}`},NA={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},PA={title:`Tag to Job`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[NA]:[MA,NA]},FA=e=>e?.data??e;function IA(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 LA(e){return e?Array.isArray(e.data)?e.data.map(IA):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(IA):Array.isArray(e)?e.map(IA):[]:[]}async function RA(e=1,n=10){let r=await t.o(t.x,`/workflow/list/all?page=${e}&limit=${n}`),i=FA(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 zA(e,n){let r=FA(await t.o(t.x,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function BA(e,n){if(!e||!n)return null;try{let r=new URLSearchParams({module:e,limit:`1`,offset:`0`,scope:`allJobs`,filters:JSON.stringify([{field:`_id`,op:`in`,values:[String(n)],operator:`and`}])}),i=FA(await t.o(t.x,`/module-data-list?${r}`));if(Array.isArray(i))return i[0]??null;if(i?.data&&Array.isArray(i.data))return i.data[0]??null;let a=i?.rows??i?.records??i?.items??i?.list;return Array.isArray(a)?a[0]??null:i??null}catch(t){return console.error(`[getModuleRecordById] failed: ${e}/${n}`,t),null}}async function VA(e){return FA(await t.o(t.C,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var HA={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`},UA=`Already submitted`;function WA(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 GA(e){let t=String(e??``).trim();return t?HA[t.toLowerCase()]??t:``}function KA(e,t=``){return String(WA(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t??``)}function qA(e){return String(WA(e,`_id`,`id`,`candidateId`,`candidate_id`,`applicantId`,`applicantID`)??``)}function JA(e,t,n){let r=String(e.jobTitle??``).trim();return{...e,jobTitle:r?`${r} (${UA})`:`(${UA})`,disabled:!0,title:UA,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}function YA(e,t){let n=String(t??``).trim();return n?/already submitted/i.test(n)?`${e} (${UA})`:/fulfilled/i.test(n)?`${e} (Fullfilled)`:`${e} (${n})`:e}function XA(e){let t=String(e.jobReferenceId??e.clientJobReferenceId??``).trim(),n=String(e.jobTitle??``).trim();return{...e,jobReferenceId:t,jobTitle:n}}function ZA(e){return $A(e).map(e=>e.id)}function QA(e,t=``){return(WA(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[WA(e,`firstName`,`first_name`),WA(e,`lastName`,`last_name`)].filter(Boolean).join(` `)??t)||`Unknown candidate`}function $A(e){let t=Array.isArray(e?.selectedIds)?e.selectedIds:[],n=Array.isArray(e?.selectedRecords)?e.selectedRecords:[],r=[],i=new Set,a=Math.max(t.length,n.length);for(let e=0;e<a;e+=1){let a=n[e]??{},o=t[e]?String(t[e]):``,s=KA(a,o);!s||i.has(s)||(i.add(s),r.push({id:s,name:QA(a,o),record:a,selectedId:o||s}))}return r}function ej(e,t){return Array.isArray(e?.jobId)?e.jobId.map(String).filter(Boolean):e?.jobId?[String(e.jobId)]:Array.isArray(t?.jobId)?t.jobId.map(String).filter(Boolean):t?.jobId?[String(t.jobId)]:[]}function tj(e,t=``){let n=String(e?.jobTitle??e?._raw?.jobTitle??``).trim();if(n)return n;let r=String(e?.label??e?._raw?.label??``).trim();return r.includes(` - `)?r.split(` - `).slice(1).join(` - `).trim():r||String(t??``)}function nj(e,t=``){return tj(e,t)}function rj(e,t,n){let r=[...new Set(ej(e,t))],i=Array.isArray(n?.dynamicOptions?.jobId)?n.dynamicOptions.jobId:[],a=new Map(i.map(e=>[String(e?._id??e?.value??``),e]));return r.map(e=>{let t=a.get(String(e))??{};return{id:String(e),label:nj(t,e),record:t}})}function ij(e){return e.filter(e=>e.blockedCandidates.length>0).map(e=>`${e.job.label} - ${e.blockedCandidates.map(e=>e.name).join(`, `)}`).join(` | `)}function aj(e){return e.filter(e=>e.allowedCandidates.length>0).map(e=>`${e.job.label} - ${e.allowedCandidates.map(e=>e.name).join(`, `)}`).join(` | `)}function oj(e,t){let n=qA(e);if(!n)return null;let r=QA(e,t)||void 0,i={candidateId:String(n),candidateName:r,phone:WA(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:WA(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:WA(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:WA(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:WA(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:WA(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:WA(e,`screeningScore`,`screening.score`,`score`),assignedDate:WA(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var sj={searchOptions:async(e,t,n)=>{if(e.searchFetchKey===`tagToJobJobList`){let e=ZA(n),r=e.length===1?e[0]:``,i,a=!1;if(r)try{i=await Ce({searchQuery:t,candidateId:r}),a=!0}catch{a=!1}Array.isArray(i)||(i=await ie(t));let o=i.map(XA);if(a)return o.map(e=>{if(e?.isSubmitted||e?.alreadySubmitted)return JA(e,e?.jobSubmissionId||e?.submissionId||``,e?.submittedAt||``);if(e?.disable){let t=String(e?.message??``).trim();return{...e,jobTitle:e.jobTitle?YA(e.jobTitle,t):`(${t})`,disabled:!0,optionNote:t,title:t}}return e});if(!r)return o;let s=await Te({applicantId:r,jobIds:o.map(e=>e._id).filter(Boolean)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e._id));return t?JA(e,t.submissionId,t.submittedAt):e})}return[]},submit:async(e,t,r)=>{let i=GA(e.hiringStage??t.hiringStage),a=$A(t),o=rj(e,t,r);if(!o.length||!a.length)return{cancelled:!0};let s=[];for(let e of o){let t=await Te({jobId:e.id,applicantIds:a.map(e=>e.id)}).catch(()=>new Map);s.push({job:e,blockedCandidates:a.filter(e=>t.has(String(e.id))),allowedCandidates:a.filter(e=>!t.has(String(e.id)))})}let c=ij(s),l=aj(s),u=s.filter(e=>e.allowedCandidates.length>0);if(!u.length)return await n.Wt({tone:`duplicate`,title:`Selected candidates are already submitted`,body:`Every selected candidate is already submitted to the selected jobs. Choose different jobs to continue.`,facts:[{label:`Blocked combinations`,value:c}],okText:`Close`}),{cancelled:!0};if(s.some(e=>e.blockedCandidates.length>0)&&!await n.Ut({tone:`duplicate`,title:`Some candidate-job combinations are already submitted`,body:`Those combinations will be skipped. Continue tagging the remaining valid combinations?`,facts:[{label:`Will be skipped`,value:c},{label:`Will be tagged`,value:l}],okText:`Tag remaining`,cancelText:`Cancel`,footnote:`Already submitted combinations will be left unchanged.`}))return{cancelled:!0};for(let e of u){for(let t of e.allowedCandidates){let n=oj(t.record??{},t.selectedId);await VA({jobId:e.job.id,module:`jobs`,currentStage:i,...n?{candidateDetails:n}:{}})}await ce({jobId:e.job.id,candidateIds:e.allowedCandidates.map(e=>e.selectedId||e.id),hiringStage:i})}}},cj={title:`Change Status`,okText:`Apply`,width:420,showSelectedCount:!0,fields:[{name:`status`,label:`New Status`,type:`select`,required:!0,placeholder:`Select a status`,dataSource:`master`,masterName:`clientSubmissions`,labelKey:`name`,valueKey:`name`,initialValueKey:`currentStatus`,defaultOptions:[{label:`Active`,value:`active`},{label:`Inactive`,value:`inactive`},{label:`Pending`,value:`pending`},{label:`Closed`,value:`closed`}]}]};function lj(e,t){let n=String(e??``).trim().toLowerCase();return(Array.isArray(t?.status)?t.status:[]).find(e=>String(e?.value??``).trim().toLowerCase()===n||String(e?.label??``).trim().toLowerCase()===n||String(e?._raw?.name??``).trim().toLowerCase()===n)??null}var uj={submit:async(e,t,n)=>{let r=lj(e.status,n?.dynamicOptions),i=r?._raw??{},a={clientSubmissionStatusText:String(i.name??r?.label??e.status??``).trim(),clientSubmissionStatusId:Number(i.id??i.uniqueId??0)||0,clientSubmissionStatusType:String(i.type??``).trim()};await ne(t.moduleName,t.selectedIds,a)}},dj={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:[]},fj={onOk:async e=>{await Ee({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},pj={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`}]},mj={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?le():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await ue({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},hj=[{title:`Name`,key:`name`,render:(e,t)=>t.name||`${t.first_name??``} ${t.last_name??``}`.trim()||t.user_name||`Assigned user`},{title:`Role`,dataIndex:`role_name`,key:`role`,render:e=>e||`-`},{title:`Reporting`,dataIndex:`reporting_name`,key:`reporting`,render:e=>e||`-`}];function gj({selectedIds:e,onClose:t}){let n=e?.[0],[r,i]=(0,o.useState)(!0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)({assignedUsers:[],totalSubmissions:0,message:``}),[p,m]=(0,o.useState)([]);(0,o.useEffect)(()=>{let e=!1;return i(!0),Promise.all([G(n).catch(t=>(e||s.message.error(t?.message??`Failed to load self-assign details`),{assignedUsers:[],totalSubmissions:0,message:``})),me(n).catch(()=>({recruitersData:[]}))]).then(([t,n])=>{e||(f(t),m(Array.isArray(n?.recruitersData)?n.recruitersData:[]))}).finally(()=>{e||i(!1)}),()=>{e=!0}},[n]);let h=async()=>{u(!0);try{await de({jobIds:[n]}),s.message.success(`Job assigned successfully`),t?.({success:!0})}catch(e){s.message.error(e?.message??`Failed to assign job`)}finally{u(!1)}};if(r)return(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})});let g=p.map(e=>({user_id:e.recruiterId??e.id??e.user_id,name:e.name??``,role_name:e.role_name??e.roleName??``,reporting_name:e.reporting_name??e.reportingName??``})),_=new Map(g.map(e=>[String(e.user_id??``),e])),v=(d.assignedUsers?.length??0)>0?d.assignedUsers.map(e=>{let t=e.user_id??e.userId??e.recruiterId??e.id,n=_.get(String(t??``))??{};return{...e,user_id:t,name:n.name||e.name||``,role_name:n.role_name||e.role_name||e.roleName||``,reporting_name:n.reporting_name||e.reporting_name||e.reportingName||``}}):g,y=v.length>0;return(0,l.jsxs)(`div`,{className:`self-assign-popup-body`,children:[y?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{style:{fontWeight:700,marginBottom:8},children:`Team Members Allocated`}),(0,l.jsx)(s.Table,{columns:hj,dataSource:v,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,l.jsxs)(`div`,{className:`warning-card`,style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,l.jsx)(c.ExclamationCircleFilled,{style:{color:`#faad14`,fontSize:18}}),(0,l.jsx)(`div`,{style:{fontSize:13},children:`These users are already assigned to this job. Do you still want to assign yourself as well?`})]})]}):(0,l.jsx)(`div`,{style:{padding:`8px 0`},children:d.message||`No one is currently assigned to this job. Do you want to assign yourself?`}),(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:12,marginTop:24},children:[(0,l.jsx)(s.Button,{size:`small`,onClick:()=>t?.(),disabled:a,children:`No`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,onClick:h,loading:a,children:`Yes`})]})]})}gj.propTypes={selectedIds:f.default.array,onClose:f.default.func};var _j={title:`Self Assign`,width:480,className:`self-assign-modal`,component:gj},vj={submit:async()=>{}};function yj(e={}){let t=Array.isArray(e.jobPayDetails)?e.jobPayDetails[e.jobPayDetails.length-1]:e.jobPayDetails??e.clientBudget??{},n=Number(t.clientBudgetEnd),r=Number(t.clientBudgetStart);return Number.isFinite(n)&&n>0?n:Number.isFinite(r)&&r>0?r:null}var bj={getTitleText:(e,t,n)=>{let r=n?.jobTitle||n?.title||``;return r?`Assign - ${r}`:`Assign`},okText:`Assign`,width:520,disabledUntilFilled:!0,showAlreadyAssigned:!0,allowRemovalOnlySubmit:!0,getFields:e=>(yj(e?.selectedRecords?.[0]??{}),[{name:`assignToUserId`,label:`Assign to`,type:`multi-select`,required:!0,placeholder:`Select recruiter(s)`,fetchOptionsKey:`assignToUsers`}])},xj={getOptions:async e=>e.fetchOptionsKey===`assignToUsers`?pe():[],loadExtraData:async e=>me(e.selectedIds[0]),submit:async(e,t,{removedIds:n,extraData:r})=>{await ve({jobIds:t.selectedIds,userId:e.assignToUserId,removedIds:n,existingRecruiters:r?.recruitersData})}},Sj={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`}]},Cj={getMentionOptions:async(e,t)=>ae(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await oe(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await W({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},wj={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`,successNavigate:`/onboarding`,fields:[{name:`sendOnboardingEmail`,type:`priority-checkbox`,checkboxLabel:`Send Onboarding Email`}]},Tj={submit:async(e,t)=>{await ye({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function Ej(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var Dj={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function Oj(e,t,n){let r=Ej(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function kj(e){let t=e.selectedRecords?.[0]??{},n=Oj(t,`candidateRate`,`candidateAcceptedRate`)??Oj(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=Oj(t,`candidateRate`,`candidateAcceptedCurrency`)??Oj(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:Oj(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??Oj(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??Dj[String(r??``).toUpperCase()]??(r||`$`),unit:Oj(t,`candidateRate`,`candidateAcceptedPayUnit`)??Oj(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var Aj={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=kj(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=kj(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`}]}]},jj={submit:async(e,t)=>{let n=t.selectedIds[0];if(await be(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await xe(n)}catch{s.message.warning(`Approved. VMS notification could not be sent — use Send Mail to notify the client.`)}else s.message.info(`Approved — use Send Mail to notify the client.`)}};async function Mj(e,n={}){let r=t.u();if(!r){let e=Error(`Authentication required`);throw e.status=401,e}let i=await fetch(`${t.T}${e}`,{...n,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${r}`,...n.headers}});if(i.status===401&&t.h(),!i.ok){let e=Error(`API ${i.status}: ${i.statusText}`);throw e.status=i.status,e}return i.json()}async function Nj(e){let t=await Mj(`/mail-form?${new URLSearchParams({submissionId:e,submissionType:`manager`}).toString()}`);return t.data??t}function Pj(e){return Array.isArray(e)?e[e.length-1]:e}function Fj(e={}){let t=Pj(e?.proposedRate)?.candidateProposedRate??e?.candidateProposedRate??e?.proposedRateValue,n=Number(t);return Number.isFinite(n)?n:0}function Ij(e,t={}){let n=Pj((e?.record?.job??e?.job??t?.job??{})?.jobPayDetails)??{},r=e?.record?.submission??t??{},i=Pj(r?.clientBudget)??r?.clientBudget??{},a=n?.clientBudgetEnd??n?.clientBudgetStart??i?.clientBudgetEnd??i?.clientBudgetStart,o=Number(a);return Number.isFinite(o)?o:0}function Lj(e={}){let t=String(e?.currencyRaw??``).trim().toUpperCase(),n=String(e?.currency??``).trim();return n&&!/^[A-Z]{3}$/i.test(n)?n:t===`USD`||n.toUpperCase()===`USD`?`$`:t===`INR`||n.toUpperCase()===`INR`?`₹`:t===`EUR`||n.toUpperCase()===`EUR`?`€`:t===`GBP`||n.toUpperCase()===`GBP`?`£`:n||t}function Rj(e={}){return String(e?.rateUnit??`hr`).trim().replace(/^\/+/,``)||`hr`}function zj(e,t={}){let n=Number(e);return Number.isFinite(n)?`${Lj(t)}${n}/${Rj(t)}`:``}function Bj(e,t,n){if(n==null||n===``)return String(e??``);let r=String(e??``),i=String(n),a=!1,o=RegExp(`(<(?:td|th)[^>]*>[\\s\\S]*?${t}[\\s\\S]*?</(?:td|th)>\\s*<(?:td|th)[^>]*>)([\\s\\S]*?)(</(?:td|th)>)`,`gi`);r=r.replace(o,(e,t,n,r)=>(a=!0,`${t}${i}${r}`));let s=RegExp(`(<(?:strong|b)[^>]*>\\s*${t}\\s*:?\\s*</(?:strong|b)>\\s*)([\\s\\S]*?)(?=</(?:li|p|div)>)`,`gi`);if(r=r.replace(s,(e,t)=>(a=!0,`${t}${i}`)),!a){let e=RegExp(`(${t}\\s*:?[ \\t]*)([^<\\r\\n]*)`,`gi`);r=r.replace(e,(e,t)=>`${t}${i}`)}return r}function Vj(e,t,n,r,i){let a=Number(n?.proposedRate),o=Number.isFinite(a)?a:Fj(t),s=Number(n?.clientJobRate),c=Number.isFinite(s)&&s>0?s:Ij(r,i),l={proposedRate:o,jobBillRate:c},u=String(e??``).replace(/{{\.?((?:proposedRate)|(?:jobBillRate))}}/g,(e,t)=>{let n=l[t];return n==null?e:String(n)});return u=Bj(u,`(?:Proposed\\s*Rate|Pay\\s*Rate)`,zj(o,n)),u=Bj(u,`(?:Job\\s*)?Bill\\s*Rate`,zj(c,n)),u}function Hj(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var Uj=(e,t)=>!!e&&e.toLowerCase()===Hj(t).toLowerCase();function Wj(e,t,n){let r=Hj(t.submittedBy);return Hj(Uj(r,n)||Uj(r,e.submitSource)||Uj(r,e.supplierName)||Uj(r,e.source)||Uj(r,e.candidateSource)?``:r,e.signatureEmail)}function Gj(e,t={}){let n=t.employerName??e.supplierName??e.submitSource;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:n,submittedBy:Wj(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function Kj(e){let t=e?.$oid??e?._id?.$oid??e?._id??e?.id?.$oid??e?.id??e;if(t==null||typeof t==`object`)return``;let n=String(t).trim();return/^[a-f\d]{24}$/i.test(n)?n:``}function qj(...e){for(let t of e){let e=[t?.jobId,t?.JobId,t?.job_id,t?.jobDetails?._id,t?.jobDetails?.id,t?.job?._id,t?.job?.id,t?.submission?.jobId,t?.submission?.JobId,t?.submission?.job_id,t?.submission?.jobDetails?._id,t?.submission?.jobDetails?.id,t?.submission?.job?._id,t?.submission?.job?.id,t?.recordMeta?.jobId,t?.recordMeta?.JobId,t?.recordMeta?.job_id,t?.submission?.recordMeta?.jobId,t?.submission?.recordMeta?.JobId,t?.submission?.recordMeta?.job_id].map(Kj).find(Boolean);if(e)return e}return``}function Jj(e){if(!e?.referralId)return{};let t=Number(e.referralRate??e.referalRate??0)||0,n=String(e.referralType??e.referalType??`RECURRING`).trim()||`RECURRING`,r=e.referralId??e.referalId;return{referralId:r,referalId:r,referralRate:t,referalRate:t,referralType:n,referalType:n,referralEnabled:!0,referalEnabled:!0,isReferralApplicable:!0,referralDetails:{referralId:r,referalId:r,referralRate:t,referalRate:t,referralType:n,referalType:n,referralEnabled:!0,referalEnabled:!0,isReferralApplicable:!0}}}function Yj(e=``){return String(e??``).replace(/map\[[^\]]*(?:resume|document|attachment|file)[^\]]*\]/gi,``).replace(/<p>\s*<\/p>/gi,``).replace(/(?:<br\s*\/?>\s*){3,}/gi,`<br><br>`).trim()}function Xj(...e){for(let t of e){let e=[t?.candidateId,t?.applicantId,t?.candidate?._id,t?.candidate?.id,t?.submission?.candidateId,t?.submission?.applicantId,t?.recordMeta?.candidateId,t?.recordMeta?.applicantId].map(Kj).find(Boolean);if(e)return e}return``}async function Zj(e){let t=e?.fileUrl??e?.downloadUrl??e?.url;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load ${e?.fileName||`resume`}`);let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.originalName??e?.uniqueName??`resume`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function Qj(e,r,i){let a=[],o=await n.yn(`submissions`,e,`resume`).catch(()=>({data:[]}));a.push(...o?.data??[]);let s=Xj(r?.record?.submission,i,r?.record);if(!s){let n=await t.o(t.x,`/module/list?module=submissions&id=${encodeURIComponent(e)}`).catch(()=>({})),r=n?.data??n??{};s=Xj((Array.isArray(r?.data)?r.data:Array.isArray(r)?r:[])[0])}if(s){let e=await n.yn(`candidates`,s,`resume`).catch(()=>({data:[]}));a.push(...e?.data??[])}let c=(await Promise.all(a.map(Zj))).filter(Boolean),l=new Set;return c.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!l.has(t)&&(l.add(t),!0)})}function $j(e={}){return{to:(e.to??e.To??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),cc:(e.cc??e.Cc??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),bcc:(e.bcc??e.Bcc??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),subject:e.subject??e.Subject??``,contents:Yj(e.content?.value??e.Content?.Value??e.contents??e.body??``)}}function eM({context:e,selectedIds:t,selectedRecords:n,moduleName:r,onClose:i}){let a=n?.[0]??{},c=t?.[0]??xv(a),[u,d]=(0,o.useState)(null),[f,p]=(0,o.useState)(!0),[m,h]=(0,o.useState)([]),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(`vms`),[b,x]=(0,o.useState)(null),[S,C]=(0,o.useState)(null),[w,T]=(0,o.useState)(!1),[E,D]=(0,o.useState)(!1),[O,k]=(0,o.useState)(!1),[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)({to:``,cc:``,bcc:``,subject:``,contents:``,attachments:[],showCc:!1,showBcc:!1});(0,o.useEffect)(()=>{let e=!1;return cy(c,a).then(t=>{e||d(t)}).catch(t=>{e||(s.message.error(t?.message??`Unable to load finance details`),d({record:{submission:a},lookups:{},display:{}}))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[c]),(0,o.useEffect)(()=>{let e=!1;return _y().then(t=>{e||h(t)}).catch(()=>{}),()=>{e=!0}},[]);let P=async()=>{if(b){if(v===`mail`){_(!1),D(!0),k(!0);try{let[e,t]=await Promise.all([Nj(c).then($j),Qj(c,u,a).catch(e=>(console.warn(`Unable to resolve resume attachment:`,e),[]))]),n=u?.record?.submission??a;N({to:Vj(e.to,n,b,u,a),cc:Vj(e.cc,n,b,u,a),bcc:Vj(e.bcc,n,b,u,a),subject:Vj(e.subject,n,b,u,a),contents:Vj(e.contents,n,b,u,a),attachments:t,showCc:!!e.cc,showBcc:!!e.bcc})}catch(e){s.message.error(e?.message??`Unable to prepare approval mail`)}finally{k(!1)}return}T(!0);try{await be(c,{candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit,submitVia:`VMS`,...Jj(S)}),s.message.success(`Submission approved`),_(!1),x(null),C(null),i?.({success:!0})}catch(e){s.message.error(e?.message??`Unable to approve submission`)}finally{T(!1)}}},F=!O&&jD(M.to).length>0&&MD(M.to)&&MD(M.cc)&&MD(M.bcc)&&M.subject.trim()&&M.contents.trim(),I=async()=>{if(!b||!F||A)return;j(!0);let e={candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit};try{await be(c,{...e,submitVia:`VMS`,...Jj(S)});let t=qj(u?.record,a);if(!t)s.message.warning(`Submission approved, but job details were not available to send mail`);else try{await pn({jobId:t,toMail:jD(M.to),ccMail:jD(M.cc),bccMail:jD(M.bcc),subject:M.subject,contents:M.contents,attachments:M.attachments??[]}),s.message.success(`Approval mail sent and submission approved`)}catch(e){s.message.warning(e?.message?`Submission approved, but mail was not sent: ${e.message}`:`Submission approved, but mail was not sent`)}D(!1),x(null),C(null),i?.({success:!0})}catch(e){s.message.error(e?.message??`Unable to send approval mail`)}finally{j(!1)}},L=(0,o.useMemo)(()=>({submissionApprove:async({computed:e,referral:t})=>{x(e),C(t??null),y(`vms`),_(!0)},submissionReject:async()=>{e?.navigate?.(`/popup/reject`,{replace:!0,state:{background:e?.background??null,selectedIds:t,selectedRecords:n,moduleName:r}})}}),[e,t,n,r]);return f||!u?(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(Zv,{type:Y_,record:u.record,lookups:u.lookups,identity:Gj(a,u.display),referralOptions:m,onAddReferral:()=>e?.navigate?.(`/referrals-create`),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:L,onClose:()=>i?.(),variant:`popup`}),(0,l.jsx)(s.Modal,{title:`Choose approval method`,open:g,okText:`Approve`,confirmLoading:w,onOk:P,onCancel:()=>{w||(_(!1),x(null),C(null))},children:(0,l.jsxs)(s.Radio.Group,{value:v,onChange:e=>y(e.target.value),style:{display:`grid`,gap:12},children:[(0,l.jsx)(s.Radio,{value:`vms`,children:`Via VMS`}),(0,l.jsx)(s.Radio,{value:`mail`,children:`Via Mail`})]})}),(0,l.jsx)(s.Drawer,{open:E,placement:`right`,onClose:()=>{A||D(!1)},closable:!1,rootClassName:`mail-popup`,width:620,maskClosable:!1,footer:(0,l.jsxs)(`div`,{className:`mail-popup__footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>D(!1),disabled:A,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:A,disabled:!F,onClick:I,children:`Send`})]}),children:O?(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})}):(0,l.jsx)(GD,{value:M,onChange:N,moduleName:`submissions`,ready:!O,title:`Submit Via Mail`,contextRecords:[u.record?.submission??a]})})]})}eM.propTypes={context:f.default.object,selectedIds:f.default.array,selectedRecords:f.default.array,moduleName:f.default.string,onClose:f.default.func};var tM={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:eM},nM={submit:async()=>{}};function rM(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var iM=(e,t)=>!!e&&e.toLowerCase()===rM(t).toLowerCase();function aM(e,t,n){let r=rM(t.submittedBy);return rM(iM(r,n)||iM(r,e.submitSource)||iM(r,e.supplierName)||iM(r,e.source)||iM(r,e.candidateSource)?``:r,e.signatureEmail)}function oM(e,t={}){let n=t.employerName??e.supplierName??e.submitSource;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:n,submittedBy:aM(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function sM(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 cM(e){return String(e??``).toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}function lM({selectedIds:e,selectedRecords:t,onClose:r}){let i=t?.[0]??{},a=e?.[0]??xv(i),[c,u]=(0,o.useState)(null),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(!0);(0,o.useEffect)(()=>{let e=!1;return m(!0),Promise.all([cy(a,i),n.pn(`submission`,a).catch(()=>[])]).then(([t,n])=>{if(e)return;let r=sM(n);f(xv(t?.meta?.workforceEngagementId??i?.onboarding?.workforceEngagementId??i?.workforceEngagementId));let a=t?.meta?.rejectReasonComments||r?.activityComments||``;u({...t,record:{...t.record,submission:{...t.record.submission,cfoRejectionReason:a?cM(a):``,cfoRejectedAt:t?.meta?.rejectedAt??r?.activityTime??null}}})}).catch(t=>{e||(s.message.error(t?.message??`Unable to load finance details`),u({record:{submission:i},lookups:{},display:{}}))}).finally(()=>{e||m(!1)}),()=>{e=!0}},[a]);let h=(0,o.useMemo)(()=>({submissionReapproveSend:async({computed:e})=>{await K(d,{submissionId:a,billRate:e.proposedRate,payRate:e.employerRate,currency:e.currencyRaw??e.currency,rateUnit:e.rateUnit,vmsPercent:e.clientVmsPercent}),await be(a,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currencyRaw??e.currency,candidateProposedRateUnit:e.rateUnit,submitVia:`Mail`,context:`resend`}),s.message.success(`Re-approved and sent for CFO approval`),r?.({success:!0})}}),[a,d,r]);return p||!c?(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})}):(0,l.jsx)(Zv,{type:$_,record:c.record,lookups:c.lookups,identity:oM(i,c.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:h,onClose:()=>r?.(),variant:`popup`})}lM.propTypes={selectedIds:f.default.array,selectedRecords:f.default.array,onClose:f.default.func};var uM={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:lM},dM={submit:async()=>{}},fM=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],pM={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:fM.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},mM={submit:async(e,t)=>{let n=fM.find(t=>String(t.id)===String(e.rejectReason));await q({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},hM={title:`Request Document Edit`,okText:`Submit Request`,cancelText:`Cancel`,width:480,successMessage:`Edit request submitted successfully.`,fields:[{name:`reason`,label:`Reason for Edit`,type:`textarea`,required:!0,rows:4,maxLength:1e3,placeholder:`Enter the reason for requesting changes to this document`}]},gM=`documents`,_M={submit:async(e,t)=>{let n=await ke({module:t.moduleName||gM,documentIds:t.selectedIds??[],reason:String(e.reason??``).trim()}),r=Number(n?.failedCount)||0;if(r>0){let e=Number(n?.createdCount)||0,t=n?.failures?.find(e=>e?.error)?.error;s.message.warning(`${e} of ${e+r} edit requests raised${t?` — ${t}`:``}.`)}}},vM={title:`Reject Edit Request`,okText:`Reject`,cancelText:`Cancel`,okButtonDanger:!0,width:480,successMessage:`Edit request rejected successfully.`,fields:[{name:`rejectionReason`,label:`Rejection Reason`,type:`textarea`,required:!0,rows:4,maxLength:1e3,placeholder:`Explain why this edit request is being rejected`}]},yM={submit:async(e,t)=>{let n=t.selectedIds??[],r=await Ae({ids:n,rejectionReason:String(e.rejectionReason??``).trim()}),i=Number(r?.rejectedCount)||0,a=Number(r?.failedCount)||0;if(i===0)throw Error(n.length>1?`None of the selected requests could be rejected — they are no longer pending or are outside your review scope.`:`This request could not be rejected — it is no longer pending or is outside your review scope.`);a>0&&s.message.warning(`${i} of ${i+a} edit requests rejected — the rest are no longer pending or are outside your review scope.`)}},bM={delete:Qk,"quick-submit":DA,"add-notes":OA,"tag-to-job":PA,"change-status":cj,"remove-from-shortlist":dj,"add-to-groups":pj,"self-assign":_j,"others-assign":bj,"sticky-notes":Sj,"move-to-onboarding":wj,"approve-rate":Aj,"manager-approve":tM,"manager-reapprove":uM,reject:pM,"document-edit-request":hM,"document-edit-reject":vM},xM={delete:$k,"quick-submit":EA,"add-notes":jA,"tag-to-job":sj,"change-status":uj,"remove-from-shortlist":fj,"add-to-groups":mj,"self-assign":vj,"others-assign":xj,"sticky-notes":Cj,"move-to-onboarding":Tj,"approve-rate":jj,"manager-approve":nM,"manager-reapprove":dM,reject:mM,"document-edit-request":_M,"document-edit-reject":yM};function SM(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function CM(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 wM(e){let t=String(CM(e,`isDeleted`,`deleted`)).toLowerCase(),n=String(CM(e,`assignmentStatus`,`status`)).toLowerCase();return t!==`true`&&t!==`1`&&![`removed`,`inactive`,`deleted`].includes(n)}function TM(e){let t=CM(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[CM(e,`firstName`,`first_name`),CM(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function EM(e){return String(CM(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function DM(e){return String(CM(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function OM(e){return String(CM(e,`batchName`,`name`,`title`,`batch_name`))}function kM({open:e=!0,context:r={},onClose:i}){let[a,c]=(0,o.useState)([]),[u,d]=(0,o.useState)([]),[f,p]=(0,o.useState)(``),[m,h]=(0,o.useState)(!0),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(``),[b,x]=(0,o.useState)(new Map),S=String(r.selectedIds?.[0]??r.selectedRecords?.[0]?._id??r.selectedRecords?.[0]?.id??r.batchId??``);(0,o.useEffect)(()=>{if(!e)return;let t=!1;return Promise.resolve().then(()=>(t||h(!0),Promise.all([n.Sn(`onboarding`,200,0),n.Sn(`batchCandidates`,1e3,0).catch(()=>[])]))).then(([e,n])=>{t||(c(SM(e)),x(new Map(SM(n).filter(wM).map(e=>[String(CM(e,`candidateId`,`candidate_id`)),e]).filter(([e])=>e))))}).catch(e=>{t||y(e.message||`Unable to load onboarding candidates`)}).finally(()=>{t||h(!1)}),()=>{t=!0}},[e]);let C=(0,o.useMemo)(()=>{let e=f.trim().toLowerCase();return e?a.filter(t=>[TM(t),CM(t,`email`,`candidateEmail`,`candidate_email`),CM(t,`status`,`onboardingStatus`,`onboarding_status`)].some(t=>String(t).toLowerCase().includes(e))):a},[a,f]);async function w(){if(!S){y(`Select a batch before adding candidates`);return}let e=a.filter(e=>u.includes(DM(e)));if(!e.length)return;let o=e.map(e=>({record:e,assignment:b.get(EM(e))})).filter(e=>e.assignment);if(o.length){let e=o.map(({record:e})=>TM(e)).join(`, `);y(`${e} ${o.length===1?`is`:`are`} already added to a batch. Each candidate can be added to only one batch.`);return}_(!0),y(``);try{let{userId:a}=t.s(),o=OM(r.selectedRecords?.[0])||OM(r);await Promise.all(e.map(e=>n.er(`batchCandidates`,{schemaVersion:1,batchId:S,batchName:o,candidateId:EM(e),workforceEngagementId:DM(e),source:`ONBOARDING`,assignmentStatus:`ASSIGNED`,assignedAt:new Date().toISOString(),assignedBy:a??0,isDeleted:!1}))),s.message.success(`${e.length} candidate${e.length===1?``:`s`} added to the batch`),i?.({refresh:!0})}catch(e){y(e.message||`Unable to add candidates to the batch`)}finally{_(!1)}}return(0,l.jsxs)(s.Modal,{open:e,title:`Add Candidate to Batch`,okText:`Add`,onOk:w,onCancel:()=>i?.(),okButtonProps:{disabled:u.length===0||!S,loading:g},cancelButtonProps:{disabled:g},closable:!g,maskClosable:!1,width:760,centered:!0,children:[v&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:v,style:{marginBottom:12}}),(0,l.jsx)(s.Input.Search,{allowClear:!0,placeholder:`Search onboarding candidates`,value:f,onChange:e=>p(e.target.value),style:{marginBottom:12}}),(0,l.jsx)(s.Table,{rowKey:e=>DM(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>TM(t)},{title:`Email`,key:`email`,render:(e,t)=>CM(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>CM(t,`status`,`onboardingStatus`,`onboarding_status`)||`—`}],dataSource:C,loading:m,size:`small`,pagination:{pageSize:10,showSizeChanger:!1},rowSelection:{selectedRowKeys:u,onChange:d,getCheckboxProps:e=>{let t=b.get(EM(e));return{disabled:!EM(e)||!DM(e)||!!t,title:t?`Candidate is already added to a batch`:void 0}}},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var AM={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function jM(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:AM[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}))}))),n=MM(e.successNavigate);return{title:e.label,fields:t,...n?{successNavigate:n}:{}}}function MM(e){let t=String(e??``).trim();return!t||!t.startsWith(`/`)||t.startsWith(`//`)||/^[a-z][a-z0-9+.-]*:/i.test(t)?null:t}function NM(e,t=[]){if(!e||!Array.isArray(t)||!t.length)return e;let n=new Map(t.filter(e=>e?.name).map(e=>[String(e.name),e]));return n.size?{...e,fields:(e.fields??[]).map(r=>{let i=n.get(String(r.name))??n.get(String(r.label))??(n.size===1&&(e.fields??[]).length===1?t[0]:null);if(!i)return r;let{name:a,...o}=i;return{...r,...o}})}:e}function PM({apiMap:e={},extraConfigs:r={}}){let i=(0,o.useMemo)(()=>({...xM,...e}),[e]),a=(0,o.useMemo)(()=>{let e={...bM};return Object.entries(r).forEach(([t,n])=>{e[t]={...e[t]??{},...n}}),e},[r]),{popupKey:s}=(0,d.useParams)(),c=(0,d.useNavigate)(),{state:u={}}=(0,d.useLocation)(),[f,p]=(0,o.useState)({key:``,config:null});(0,o.useEffect)(()=>{let e=!1;if(!s||!u.moduleName)return;let t=`${u.moduleName}:${s}`;return n.Er(u.moduleName,`popup`,s).then(n=>{e||p({key:t,config:jM(n[0])})}).catch(()=>{e||p({key:t,config:null})}),()=>{e=!0}},[s,u.moduleName]);let m=(0,o.useMemo)(()=>{let e=a[s],t=`${u.moduleName}:${s}`,n=f.key===t?f.config:null;return NM(n?{...e,...n}:e,u.popupAction?.popupFieldOverrides)},[f,a,s,u.moduleName,u.popupAction?.popupFieldOverrides]),h=(0,o.useMemo)(()=>({selectedIds:u.selectedIds??[],selectedRecords:u.selectedRecords??[],moduleName:u.moduleName??``,navigate:c,background:u.background??null,...u.popupContext??{}}),[c,u.selectedIds,u.selectedRecords,u.moduleName,u.popupContext,u.background]),g=(0,o.useMemo)(()=>{let e=u.popupAction;return e?.apiPath?{submit:(n,r)=>{let i=String(e.apiMethod||`POST`).toUpperCase();return t.o(t.x,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})})}}:{}},[u.popupAction]),_=e=>{let t=u.background;if(e?.success&&m?.successNavigate){c(m.successNavigate,{replace:!0,state:{refreshTimestamp:Date.now()}});return}if(e?.success&&t?.pathname){c(`${t.pathname}${t.search??``}`,{replace:!0,state:{...t.state??{},refreshTimestamp:Date.now()}});return}c(-1)};return s===`add-batch-candidate`?(0,l.jsx)(kM,{open:!0,context:h,onClose:_}):(0,l.jsx)(Zk,{open:!0,config:m,context:h,onClose:_,api:{...i[s]??{},...g}})}var FM={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`}]},IM={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>un({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>dn(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>pn({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},LM=FM.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function RM(){let e=(0,d.useNavigate)(),t=(0,d.useLocation)(),{selectedIds:n=[],selectedRecords:r=[],recipients:i=[],subject:a=``,onSend:u,moduleName:f=``,popupAction:p={}}=t.state??{},m=n[0]??r[0]?._id??r[0]?.id,[h,g]=(0,o.useState)({to:i.join(`, `),cc:``,bcc:``,subject:a,contents:``,showCc:!1,showBcc:!1}),[_,v]=(0,o.useState)(!m),[y,b]=(0,o.useState)(FM.defaultTab),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)([]),[T,E]=(0,o.useState)(0),[D,O]=(0,o.useState)(0),[k,A]=(0,o.useState)(0),[j,M]=(0,o.useState)(1),[N,P]=(0,o.useState)(FM.defaultPageSize),[F,I]=(0,o.useState)(!1),[L,R]=(0,o.useState)([]);(0,o.useEffect)(()=>{if(!m)return;let e=!1;I(!0);let t=x?100:N,n=x?0:(j-1)*N;return IM.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,o.useEffect)(()=>{m&&IM.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,o.useMemo)(()=>L.map(e=>C.find(t=>t.vendorId===e)?.vendorEmail??``).filter(Boolean),[L,C]),B=(0,o.useMemo)(()=>({...h,bcc:[...new Set([...jD(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function V(e){let t=new Set(z);g({...e,bcc:jD(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let H=(jD(B.to).length||jD(B.bcc).length)&&MD(B.to)&&MD(B.cc)&&MD(B.bcc)&&B.subject.trim(),ee=e=>e===`myVendor`?T:D;function U(){e(-1)}function te(){H&&IM.submit({jobId:m,toMail:jD(B.to),ccMail:jD(B.cc),bccMail:jD(B.bcc),subject:B.subject,contents:B.contents}).then(t=>{t?.status===!0?(s.message.success(t?.data||`Mail sent successfully.`),typeof u==`function`&&u({...B,message:B.contents,selectedIds:n}),e(-1)):s.message.error(t?.message||t?.data||`Failed to send mail. Please try again.`)}).catch(e=>{s.message.error(e?.message||`Failed to send mail. Please try again.`)})}let ne=(0,o.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,l.jsx)(s.Drawer,{open:!0,placement:`right`,onClose:U,closable:!1,rootClassName:`vendor-share`,width:`95%`,footer:(0,l.jsxs)(`div`,{className:`vendor-share__footer`,children:[(0,l.jsx)(s.Button,{onClick:U,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,disabled:!H,onClick:te,children:`Send`})]}),children:(0,l.jsxs)(`div`,{className:`vendor-share__body`,children:[(0,l.jsxs)(`div`,{className:`vendor-share__left`,children:[(0,l.jsxs)(`div`,{className:`vendor-share__vendor-header`,children:[(0,l.jsxs)(`div`,{className:`vendor-share__vendor-header-row`,children:[(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.CloseOutlined,{}),onClick:U,size:`small`,style:{marginRight:8}}),(0,l.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,l.jsx)(c.TeamOutlined,{})}),(0,l.jsx)(`span`,{className:`dynamic-popup__header-label`,children:`Vendor List`}),(0,l.jsxs)(`div`,{className:`vendor-share__vendor-search`,children:[(0,l.jsx)(c.SearchOutlined,{className:`vendor-share__search-icon`}),(0,l.jsx)(s.Input,{variant:`borderless`,placeholder:`Search vendor`,value:x,onChange:e=>{S(e.target.value),M(1)},className:`vendor-share__search-input`})]})]}),(0,l.jsx)(`div`,{className:`vendor-share__vendor-tabs`,children:FM.vendorTabs.map(e=>(0,l.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,` (`,ee(e.key),`)`]},e.key))})]}),(0,l.jsx)(`div`,{className:`vendor-share__vendor-table-wrapper`,children:(0,l.jsx)(s.Table,{rowKey:e=>e.vendorId,columns:LM,dataSource:ne,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>FM.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,l.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,l.jsx)(Be,{current:j,pageSize:N,total:k,onChange:e=>M(e),onPageSizeChange:e=>P(e)})})]}),(0,l.jsx)(`div`,{className:`vendor-share__right`,children:(0,l.jsx)(GD,{value:B,onChange:V,moduleName:f,defaultTemplateId:p.defaultTemplateId??t.state?.defaultTemplateId??``,ready:_,contextRecords:r,title:`Share`,hint:`Select vendors or add email addresses`,bccHint:`Vendor emails are added automatically`,afterBcc:L.length>0?(0,l.jsxs)(`div`,{className:`vendor-share__selected-count`,children:[L.length,` / `,FM.maxVendorSelect,` Vendors selected`]}):null})})]})})}function zM(e){return e?.data??e}async function BM(e){let n=String(e??``).trim();if(!n)throw Error(`Invoice id is required`);return zM(await t.o(t.x,`/payments/invoice/${encodeURIComponent(n)}`))}function VM(...e){for(let t of e){let e=String(t??``).trim();if(e&&e!==`undefined`&&e!==`null`)return e}return``}async function HM(e,t,n){if(!e)return null;let r=await fetch(e);if(!r.ok)throw Error(`Unable to load invoice attachment`);let i=await r.blob();return new File([i],t||`payment-invoice.html`,{type:n||i.type||`text/html`})}function UM(e){let t=VM(e?.courseName,`your course`),n=VM(e?.invoiceNumber,e?.invoiceFileName,e?.transactionId);return{subject:`Payment invoice - ${t}`,contents:`<p>Hello ${VM(e?.recipientName,`Student`)},</p><p>Please find attached the invoice for your successful payment${n?` (${n})`:``}.</p><p>Thank you.</p>`}}function WM(){let e=(0,d.useNavigate)(),{id:t}=(0,d.useParams)(),[r,i]=(0,o.useState)(null),[a,u]=(0,o.useState)(``),[f,p]=(0,o.useState)(!0),[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)({to:``,cc:``,bcc:``,subject:``,contents:``,attachments:[],showCc:!1,showBcc:!1}),b=(0,o.useMemo)(()=>r?.invoiceUrl?[{id:r.invoiceS3Key||r.invoiceUrl,name:r.invoiceFileName||`payment-invoice.html`,url:r.invoiceUrl,type:r.invoiceContentType||`html`}]:[],[r]);(0,o.useEffect)(()=>{let e=!1;async function n(){p(!0);try{let n=await BM(t);if(e)return;i(n);let r=UM(n),a=await HM(n?.invoiceUrl,n?.invoiceFileName,n?.invoiceContentType).catch(()=>null),o={to:VM(n?.recipientEmail),cc:``,bcc:``,subject:r.subject,contents:r.contents,attachments:a?[a]:[],showCc:!1,showBcc:!1},s=(await Xw({module:`payments`,action:`invoice`}).catch(()=>[]))[0];if(!s?._id){y(o);return}u(String(s._id));let c=await Zw(s._id).catch(()=>null);if(!c){y(o);return}y({...o,to:VM(o.to,...(c.toMail??[]).map(e=>WD(e,c.placeholders,n))),cc:(c.ccMail??[]).map(e=>WD(e,c.placeholders,n)).filter(Boolean).join(`, `),bcc:(c.bccMail??[]).map(e=>WD(e,c.placeholders,n)).filter(Boolean).join(`, `),subject:VM(WD(c.subject,c.placeholders,n),o.subject),contents:VM(WD(c.body,c.placeholders,n),o.contents),showCc:!!c.ccMail?.length,showBcc:!!c.bccMail?.length})}catch(t){e||s.message.error(t?.message||`Unable to load invoice`)}finally{e||p(!1)}}return n(),()=>{e=!0}},[t]);let x=jD(v.to).length>0&&MD(v.to)&&MD(v.cc)&&MD(v.bcc)&&v.subject.trim()&&v.contents.trim();async function S(){if(!(!x||g)){_(!0);try{await pn({jobId:``,toMail:jD(v.to),ccMail:jD(v.cc),bccMail:jD(v.bcc),subject:v.subject,contents:v.contents,attachments:v.attachments}),s.message.success(`Invoice mail sent successfully`),h(!1)}catch(e){s.message.error(e?.message||`Failed to send invoice mail`)}finally{_(!1)}}}return(0,l.jsxs)(s.Drawer,{open:!0,placement:`right`,onClose:()=>e(-1),width:`min(1040px, 96vw)`,title:`Payment Invoice`,extra:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.MailOutlined,{}),onClick:()=>h(!0),disabled:!r,children:`Send Mail`}),destroyOnClose:!0,children:[(0,l.jsx)(s.Spin,{spinning:f,tip:`Loading invoice...`,children:!f&&!b.length?(0,l.jsx)(s.Alert,{type:`warning`,message:`Invoice document is not available for this payment.`,showIcon:!0}):(0,l.jsx)(`div`,{style:{height:`calc(100vh - 140px)`},children:(0,l.jsx)(n.En,{documents:b,inline:!0})})}),(0,l.jsx)(s.Drawer,{open:m,placement:`right`,onClose:()=>h(!1),width:620,rootClassName:`mail-popup`,destroyOnClose:!0,footer:(0,l.jsxs)(`div`,{className:`mail-popup__footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>h(!1),children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:g,disabled:!x,onClick:S,children:`Send`})]}),children:(0,l.jsx)(GD,{value:v,onChange:y,moduleName:`payments`,defaultTemplateId:a,contextRecords:r?[r]:[],title:`Invoice Mail`,hint:`Customer email and invoice attachment are prefilled.`})})]})}var GM={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].*$/},KM={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},qM={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 ${KM.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.`},JM={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},YM={REMARKS_MIN:10,REMARKS_MAX:250},XM={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)}`}},ZM={required:(e=`Field`)=>({required:!0,message:qM.REQUIRED(e)}),email:()=>({pattern:GM.EMAIL,message:qM.INVALID_EMAIL}),phone:()=>({pattern:GM.PHONE,message:qM.INVALID_PHONE}),password:()=>({pattern:GM.PASSWORD,message:qM.INVALID_PASSWORD}),alphabets:()=>({pattern:GM.ALPHABETS,message:qM.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:GM.ALPHANUMERIC,message:qM.INVALID_ALPHANUMERIC}),number:()=>({pattern:GM.NUMBER,message:qM.INVALID_NUMBER}),url:()=>({pattern:GM.URL,message:qM.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:GM.CANDIDATE_ID,message:qM.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:GM.REMARKS,message:qM.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${YM.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${YM.REMARKS_MAX} characters.`}),designation:()=>({pattern:GM.DESIGNATION,message:qM.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!GM.DOB.test(n))return Promise.reject(Error(qM.INVALID_DOB));let r=(0,u.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(qM.INVALID_DOB));let i=(0,u.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:GM.LINKEDIN,message:qM.INVALID_LINKEDIN}),companyName:()=>({pattern:GM.COMPANY_NAME,message:qM.INVALID_COMPANY_NAME}),firstName:()=>({pattern:GM.FIRST_NAME,message:qM.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${JM.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${JM.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:JM.FIRST_NAME_MIN,message:qM.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:JM.FIRST_NAME_MAX,message:qM.FIRST_NAME_MAX}),remarksMinLength:()=>({min:YM.REMARKS_MIN,message:qM.REMARKS_MIN}),remarksMaxLength:()=>({max:YM.REMARKS_MAX,message:qM.REMARKS_MAX}),fullName:()=>({pattern:GM.FULL_NAME,message:qM.INVALID_FULL_NAME}),noSpaces:()=>({pattern:GM.NO_SPACES,message:qM.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:GM.STARTS_WITH_CAPITAL,message:qM.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<=KM.MAX_FILE_SIZE))return s.message.error(qM.INVALID_FILE_SIZE),Promise.reject(Error(qM.INVALID_FILE_SIZE));if(!KM.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(qM.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>KM.SINGLE_FILE_COUNT)return Promise.reject(Error(qM.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<KM.MAX_FILE_SIZE?KM.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(qM.INVALID_FILE_TYPE)):Promise.reject(Error(qM.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>KM.MULTI_FILE_COUNT)return Promise.reject(Error(qM.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<KM.MAX_FILE_SIZE))return Promise.reject(Error(qM.INVALID_FILE_SIZE));if(!KM.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(qM.INVALID_FILE_TYPE))}return Promise.resolve()}})},QM={beforeUpload:e=>[`image/jpeg`,`image/png`,`application/pdf`].includes(e.type)?e.size/1024/1024<=2?!1:(s.message.error(`File upload must be 2 MB below.`),s.Upload.LIST_IGNORE):(s.message.error(`Only JPG, PNG and PDF files are allowed.`),s.Upload.LIST_IGNORE)},$M=()=>{let[e]=s.Form.useForm();return(0,l.jsx)(`div`,{style:{padding:24},children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,onFinish:e=>{console.log(`Form Values:`,e)},autoComplete:`off`,children:[(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Email`,name:`email`,rules:[ZM.required(`Email`),ZM.email()],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Phone Number`,name:`phone`,rules:[ZM.required(`Phone Number`),ZM.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,l.jsx)(s.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:XM.phoneFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Password`,name:`password`,rules:[ZM.required(`Password`),ZM.password()],children:(0,l.jsx)(s.Input.Password,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Full Name`,name:`fullName`,rules:[ZM.required(`Full Name`),ZM.alphabets(),ZM.firstNameMinLength(),ZM.firstNameMaxLength()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({fullName:XM.firstNameFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Username`,name:`username`,rules:[ZM.required(`Username`),ZM.alphanumeric()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({username:XM.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Website URL`,name:`website`,rules:[ZM.required(`Website URL`),ZM.url()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({website:XM.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`MSP Req ID`,name:`mspreqID`,rules:[ZM.required(`MSP Req ID`),ZM.candidateId(`MSP Req ID`)],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({mspreqID:XM.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[ZM.required(`Candidate ID`),ZM.candidateId(`Candidate ID`)],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({candidateId:XM.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:24,children:(0,l.jsx)(s.Form.Item,{label:`Remarks`,name:`remarks`,rules:[ZM.required(`Remarks`),ZM.remarks(),ZM.remarksMinLength(),ZM.remarksMaxLength()],children:(0,l.jsx)(s.Input.TextArea,{rows:4})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Designation`,name:`designation`,rules:[ZM.required(`Designation`),ZM.designation()],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Date of Birth`,name:`dob`,rules:[ZM.dob()],children:(0,l.jsx)(s.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:XM.dobFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Company Name`,name:`companyName`,rules:[ZM.required(`Company Name`),ZM.companyName()],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{name:`contractType`,label:`Contract Type`,children:(0,l.jsxs)(s.Select,{showSearch:!0,allowClear:!0,filterOption:(e,t)=>(t?.label??``).toLowerCase().includes(e.toLowerCase()),children:[(0,l.jsx)(s.Select.Option,{value:`C2C`,label:`C2C`,children:`C2C`}),(0,l.jsx)(s.Select.Option,{value:`W2-Contract`,label:`W2-Contract`,children:`W2-Contract`}),(0,l.jsx)(s.Select.Option,{value:`W2-Fulltime`,label:`W2-Fulltime`,children:`W2-Fulltime`}),(0,l.jsx)(s.Select.Option,{value:`1099`,label:`1099`,children:`1099`})]})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{name:`candidateProposedRateCurrency`,label:`Currency`,children:(0,l.jsxs)(s.Select,{showSearch:!0,allowClear:!0,children:[(0,l.jsx)(s.Select.Option,{value:`$`,children:`$`}),(0,l.jsx)(s.Select.Option,{value:`₹`,children:`₹`}),(0,l.jsx)(s.Select.Option,{value:`€`,children:`€`}),(0,l.jsx)(s.Select.Option,{value:`zł`,children:`zł`}),(0,l.jsx)(s.Select.Option,{value:`£`,children:`£`}),(0,l.jsx)(s.Select.Option,{value:`kr`,children:`kr`}),(0,l.jsx)(s.Select.Option,{value:`Fr`,children:`Fr`}),(0,l.jsx)(s.Select.Option,{value:`kr`,children:`kr`})]})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Resume new`,name:`resume`,children:(0,l.jsx)(s.Upload,{beforeUpload:QM.beforeUpload,maxCount:1,children:(0,l.jsx)(s.Button,{children:`Upload Resume`})})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Documents`,name:`documents`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[ZM.multiFileUpload()],children:(0,l.jsx)(s.Upload,{multiple:!0,beforeUpload:QM.beforeUpload,children:(0,l.jsx)(s.Button,{children:`Upload Documents`})})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Upload File`,name:`file`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[ZM.fileUpload()],children:(0,l.jsx)(s.Upload,{beforeUpload:QM.beforeUpload,maxCount:1,children:(0,l.jsx)(s.Button,{children:`Upload`})})})})]}),(0,l.jsx)(s.Row,{children:(0,l.jsx)(s.Form.List,{name:`users`,children:(e,{add:t,remove:n})=>(0,l.jsxs)(l.Fragment,{children:[e.map(({key:e,name:t,...r})=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{required:!0,...r,rules:[{required:!0,message:`First name is requried`}],name:[t,`first`],children:(0,l.jsx)(s.Input,{placeholder:`First Name`})})}),(0,l.jsx)(s.Col,{span:11,children:(0,l.jsx)(s.Form.Item,{...r,required:!0,name:[t,`last`],children:(0,l.jsx)(s.Input,{placeholder:`Last Name`})})}),(0,l.jsx)(s.Col,{span:1,children:(0,l.jsx)(c.MinusCircleOutlined,{onClick:()=>n(t)})})]})),(0,l.jsx)(s.Form.Item,{children:(0,l.jsx)(s.Button,{type:`dashed`,onClick:()=>t(),block:!0,icon:(0,l.jsx)(c.PlusOutlined,{}),children:`Add field`})})]})})}),(0,l.jsxs)(s.Form.Item,{children:[(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,children:`Submit`}),(0,l.jsx)(s.Button,{style:{marginLeft:10},onClick:()=>e.resetFields(),children:`Reset`})]})]})})};function eN(e){return(0,l.jsx)(Pb,{children:(0,l.jsx)(ED,{...e})})}var{Text:tN}=s.Typography,nN=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],rN={fileText:(0,l.jsx)(c.FileTextOutlined,{}),checkCircle:(0,l.jsx)(c.CheckCircleOutlined,{}),user:(0,l.jsx)(c.UserOutlined,{}),filter:(0,l.jsx)(c.FilterOutlined,{})};function iN({stats:e=nN}){return(0,l.jsx)(s.Card,{children:(0,l.jsx)(s.Row,{gutter:[12,12],children:e.map(e=>(0,l.jsx)(s.Col,{xs:24,sm:24,md:8,lg:8,xl:8,children:(0,l.jsxs)(s.Card,{className:`stats-inner-card`,children:[(0,l.jsxs)(s.Space,{align:`center`,children:[rN[e.icon]??rN.fileText,(0,l.jsx)(tN,{children:e.label})]}),(0,l.jsx)(s.Statistic,{value:e.value})]})},e.label))})})}var{Text:aN}=s.Typography;function oN(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 sN(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:oN(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function cN(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(1),[p,m]=(0,o.useState)(10),[h,g]=(0,o.useState)(``),_=(0,o.useCallback)(async({offset:e,limit:r,searchQuery:a}={})=>{u(!0);try{let o=await n.yr({offset:e,limit:r,searchQuery:a??``}),s=(o.users??[]).map(sN);t(s),i(o.total??s.length)}catch{s.message.error(`Failed to load users`)}finally{u(!1)}},[]);return(0,o.useEffect)(()=>{queueMicrotask(()=>{_({offset:(d-1)*p,limit:p,searchQuery:h})})},[_,d,p,h]),(0,l.jsx)(Z,{icon:(0,l.jsx)(c.TeamOutlined,{}),title:`Users`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,l.jsx)($m,{listName:`Users`,dataSource:e,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(aN,{strong:!0,style:{fontSize:13},children:e}),t._email&&(0,l.jsx)(`div`,{style:{fontSize:11,color:`var(--color-text-muted)`},children:t._email})]})},{label:`Role`,value:`_role`,width:180}],loading:a,total:r,current:d,pageSize:p,onPageChange:e=>f(e),onPageSizeChange:e=>{m(e),f(1)},onSearch:e=>{g(e),f(1)}})})}var{Text:lN}=s.Typography,uN=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],dN=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function fN({field:e,index:t,onToggle:n,onReorder:r}){let i=(0,o.useRef)(null),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(!1);function p(e){i.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),i.current!==null&&i.current!==t&&r(i.current,t),i.current=null}return(0,l.jsxs)(`div`,{draggable:!0,onDragStart:p,onDragEnd:m,onDragOver:h,onDragLeave:g,onDrop:_,className:`uss-field-row with-edit${a?` drag-over`:``}${d?` dragging`:``}`,children:[(0,l.jsx)(`span`,{className:`uss-drag-handle`,children:(0,l.jsx)(c.HolderOutlined,{})}),(0,l.jsxs)(`span`,{className:`uss-field-name`,children:[e.fieldName,(0,l.jsx)(`span`,{className:`uss-field-key`,children:e.fieldKey})]}),(0,l.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,l.jsx)(s.Switch,{size:`small`,checked:e.isVisible,onChange:e=>n(t,`isVisible`,e)})}),(0,l.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,l.jsx)(s.Switch,{size:`small`,checked:!!e.isEditable,onChange:e=>n(t,`isEditable`,e)})}),(0,l.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,l.jsx)(s.Switch,{size:`small`,checked:!!e.ismandatory,onChange:e=>n(t,`ismandatory`,e)})})]})}function pN({team:e,configType:t}){let[r,i]=(0,o.useState)({}),[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)({}),[f,p]=(0,o.useState)(`job`);(0,o.useEffect)(()=>{e&&(c(!0),n.Zr(e,t).then(i).catch(()=>s.message.error(`Failed to load field config`)).finally(()=>c(!1)))},[e,t]);let m=r[f]??[];function h(e,t){i(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 n.Ci(e,r,m,t),s.message.success(`Saved`)}catch{s.message.error(`Save failed`)}finally{d(e=>({...e,[r]:!1}))}}return(0,l.jsxs)(s.Spin,{spinning:a,children:[(0,l.jsx)(s.Tabs,{size:`small`,activeKey:f,onChange:p,items:uN.map(e=>({key:e.key,label:e.label}))}),(0,l.jsxs)(`div`,{className:`uss-field-header with-edit`,children:[(0,l.jsx)(`span`,{}),(0,l.jsx)(`span`,{children:`Field`}),(0,l.jsx)(`span`,{style:{textAlign:`center`},children:`Visible`}),(0,l.jsx)(`span`,{style:{textAlign:`center`},children:`Editable`}),(0,l.jsx)(`span`,{style:{textAlign:`center`},children:`Mandatory`})]}),(0,l.jsxs)(`div`,{className:`uss-field-list`,children:[m.length===0&&!a&&(0,l.jsx)(`div`,{className:`uss-empty`,children:`No fields found.`}),m.map((e,t)=>(0,l.jsx)(fN,{field:e,index:t,onToggle:g,onReorder:_},e.fieldKey??t))]}),(0,l.jsx)(`div`,{className:`uss-modal-footer`,children:(0,l.jsxs)(s.Button,{type:`primary`,size:`small`,loading:u[f],onClick:v,children:[`Save `,uN.find(e=>e.key===f)?.label]})})]})}function mN(){let[e,t]=(0,o.useState)(null),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(`listView`),[p,m]=(0,o.useState)([]),[h,g]=(0,o.useState)(0),[_,v]=(0,o.useState)(!1),[y,b]=(0,o.useState)(``),[x,S]=(0,o.useState)(!1),C=(0,o.useCallback)(async()=>{v(!0);try{let e=await n.vr();m(e.teams),g(e.total)}catch{s.message.error(`Failed to load teams`)}finally{v(!1)}},[]);(0,o.useEffect)(()=>{C()},[C]);function w(e){t(e),f(`listView`),i(!0)}function T(e){t(e),b(e.teamName??``),u(!0)}async function E(){if(!y.trim()){s.message.warning(`Team name is required`);return}S(!0);try{await n.Si(e,{teamName:y.trim(),managerId:e.managerId,memberIds:e.memberIds}),s.message.success(`Team updated`),u(!1),C()}catch{s.message.error(`Failed to update team`)}finally{S(!1)}}return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(Z,{icon:(0,l.jsx)(c.TeamOutlined,{}),title:`Teams`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,l.jsx)($m,{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,l.jsxs)(`div`,{style:{display:`flex`,gap:4},children:[(0,l.jsx)(s.Button,{size:`small`,type:`link`,onClick:()=>T(t),children:`Edit`}),(0,l.jsx)(s.Button,{size:`small`,type:`link`,onClick:()=>w(t),children:`Configure`})]})}],loading:_,total:h})}),(0,l.jsx)(s.Modal,{open:a,onCancel:()=>u(!1),title:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.TeamOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),`Edit Team`]}),width:420,footer:null,destroyOnClose:!0,children:(0,l.jsxs)(`div`,{className:`uss-edit-team-body`,style:{paddingTop:12},children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`uss-edit-team-label`,children:`Team Name`}),(0,l.jsx)(s.Input,{value:y,onChange:e=>b(e.target.value),onPressEnter:E,placeholder:`Enter team name`})]}),(0,l.jsxs)(`div`,{className:`uss-modal-footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>u(!1),children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:x,onClick:E,children:`Save`})]})]})}),(0,l.jsxs)(s.Modal,{className:`uss-modal`,open:r,onCancel:()=>i(!1),title:(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(c.TeamOutlined,{style:{color:`var(--color-brand)`}}),(0,l.jsxs)(`span`,{children:[`Configure: `,e?.teamName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,l.jsx)(`div`,{style:{marginBottom:12},children:(0,l.jsx)(`div`,{className:`uss-config-toggle`,children:dN.map(e=>(0,l.jsx)(`button`,{className:`uss-config-btn${d===e.key?` active`:``}`,onClick:()=>f(e.key),children:e.label},e.key))})}),e&&(0,l.jsx)(pN,{team:e,configType:d},`${e?.teamId}-${d}`)]})]})}var hN=[`view`,`add`,`edit`,`delete`],gN={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`,po_msa:`PO MSA`,reApprove:`ReApprove`,sendApprove:`Send Approve`};function _N(e){return gN[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function vN(e){let t=hN.filter(t=>e.includes(t)),n=e.filter(e=>!hN.includes(e)).sort();return[...t,...n]}function yN(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),vN([...t])}function bN(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{Kx(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function xN(e={}){if(!e||typeof e!=`object`)return e;let t=Object.keys(e).find(e=>String(e).trim().toLowerCase()===`onboarding`);if(!t)return e;let n=e[t]??{},r={...n.permissions??{}};for(let e of[`sendApprove`,`reApprove`])Object.keys(r).some(t=>t.toLowerCase()===e.toLowerCase())||(r[e]={id:0,value:`0`});return{...e,[t]:{...n,permissions:r}}}function SN({value:e,onSave:t,className:n}){let[r,i]=(0,o.useState)(!1),[a,s]=(0,o.useState)(e);(0,o.useEffect)(()=>{s(e)},[e]);function u(){i(!1);let n=a.trim();n&&n!==e?t(n):s(e)}return r?(0,l.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input${n?` ${n}`:``}`,value:a,style:{width:Math.max(48,a.length*8)},onChange:e=>s(e.target.value),onBlur:u,onKeyDown:t=>{t.key===`Enter`&&u(),t.key===`Escape`&&(i(!1),s(e)),t.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,l.jsxs)(`span`,{className:`perm-editable-name${n?` ${n}`:``}`,onDoubleClick:e=>{e.stopPropagation(),i(!0)},children:[e,(0,l.jsx)(c.EditOutlined,{className:`perm-name-edit-icon`})]})}function CN({entry:e,label:t,onToggle:n,onLabelSave:r}){let[i,a]=(0,o.useState)(!1),[u,d]=(0,o.useState)(t),f=e?.value===`1`,p=!!e;(0,o.useEffect)(()=>{d(t)},[t]);function m(){a(!1);let e=u.trim();e&&e!==t?r(e):d(t)}return(0,l.jsx)(s.Tooltip,{title:p?f?`Click to disable`:`Click to enable`:`Not applicable for this module`,children:(0,l.jsxs)(`div`,{className:`perm-action-pill${f?` on`:``}${p?``:` na`}`,onClick:()=>{!i&&p&&n()},children:[(0,l.jsx)(`span`,{className:`perm-action-pill-dot${f?` on`:``}`}),i?(0,l.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`&&(a(!1),d(t)),e.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,l.jsx)(`span`,{className:`perm-action-pill-label`,onDoubleClick:e=>{e.stopPropagation(),a(!0)},children:t}),f&&!i&&(0,l.jsx)(c.CheckOutlined,{className:`perm-action-pill-check`})]})})}function wN({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:o,onActionLabelSave:s}){let c=t?.permissions??{},u=n.filter(t=>Kx(e,t)),d=u.filter(e=>c[e]?.value===`1`).length,f=u.filter(e=>c[e]).length,p=f>0&&d===f;return(0,l.jsxs)(`div`,{className:`perm-module-card${p?` all-on`:d>0&&!p?` some-on`:``}`,children:[(0,l.jsxs)(`div`,{className:`perm-module-card-header`,children:[(0,l.jsx)(SN,{value:i,onSave:t=>o(e,t),className:`perm-module-card-name`}),f>0&&(0,l.jsxs)(`span`,{className:`perm-module-card-badge${d>0?` active`:``}`,children:[d,`/`,f]})]}),(0,l.jsx)(`div`,{className:`perm-module-card-body`,children:u.map(t=>(0,l.jsx)(CN,{entry:c[t],label:a[t]??_N(t),onToggle:()=>r(e,t),onLabelSave:e=>s(t,e)},t))})]})}function TN({role:e,moduleLabels:t={},actionLabels:r={},onModuleLabelSave:i=()=>{},onActionLabelSave:a=()=>{}}){let[u,d]=(0,o.useState)({}),[f,p]=(0,o.useState)({}),[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(!1),b=n.Kr(e);(0,o.useEffect)(()=>{b&&(h(!0),y(!1),n.Yr(b).then(e=>{let t=xN(e);d(t),p(t)}).catch(()=>s.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 n.bi(b,f),d(f),y(!1),s.message.success(`Permissions saved`)}catch(e){s.message.error(e?.message||`Save failed`)}finally{_(!1)}}let C=(0,o.useMemo)(()=>Object.keys(f).sort(),[f]),w=(0,o.useMemo)(()=>yN(f),[f]),{enabled:T,total:E}=(0,o.useMemo)(()=>bN(f),[f]);return(0,l.jsxs)(s.Spin,{spinning:m,children:[(0,l.jsxs)(`div`,{className:`perm-panel-header`,children:[(0,l.jsxs)(`div`,{className:`perm-panel-title`,children:[(0,l.jsx)(c.LockOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),(0,l.jsx)(`span`,{children:e?.roleName}),!m&&E>0&&(0,l.jsxs)(s.Tag,{color:`blue`,style:{marginLeft:8,fontSize:11},children:[T,`/`,E,` enabled`]})]}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.UnlockOutlined,{}),loading:g,disabled:!v,onClick:S,children:`Save Changes`})]}),(0,l.jsxs)(`div`,{className:`perm-hint`,children:[(0,l.jsx)(c.InfoCircleOutlined,{className:`perm-hint-icon`}),(0,l.jsxs)(`span`,{children:[`Click a pill to toggle. `,(0,l.jsx)(`strong`,{children:`Double-click`}),` a module name or action label to rename it — labels are saved locally.`]})]}),C.length===0&&!m?(0,l.jsx)(`div`,{className:`perm-empty`,children:`No permission entries found for this role.`}):(0,l.jsx)(`div`,{className:`perm-cards-grid`,children:C.map(e=>(0,l.jsx)(wN,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:t[e]??e,actionLabels:r,onModuleLabelSave:i,onActionLabelSave:a},e))})]})}var{Text:EN}=s.Typography,DN=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function ON(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function kN(e){return String(e||``).trim().toLowerCase()}function AN(e){return e?.key||e?.collectionName||e?.value||``}function jN(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=AN(e);if(!t)return;let o=kN(e.key||t),s=kN(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||ON(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=kN(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:ON(t),value:t,disabled:!1}))}),n}function MN(){let[e,t]=(0,o.useState)(null),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(`listView`),[d,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(0),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)([]),[x,S]=(0,o.useState)(!1),[C,w]=(0,o.useState)(!1),T=(0,o.useMemo)(()=>_.filter(e=>!e.disabled),[_]),E=!x&&T.length===0,D=(0,o.useCallback)(async()=>{g(!0);try{let e=await n._r();f(e.roles),m(e.total)}catch{s.message.error(`Failed to load roles`)}finally{g(!1)}},[]),O=(0,o.useCallback)(async()=>{S(!0);try{let[e,t]=await Promise.all([n.kr(),n.xr()]),r=jN(e.modules,t),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));v(r),b(e=>e.filter(e=>i.has(e)))}catch{s.message.error(`Failed to load seed status`)}finally{S(!1)}},[]);(0,o.useEffect)(()=>{D()},[D]),(0,o.useEffect)(()=>{O()},[O]);async function k(){if(y.length===0){s.message.warning(E?`All modules already seeded.`:`Select at least one module to seed.`);return}w(!0);try{await n.di(y),s.message.success(`Role field config seeded`),b([]),await O()}catch(e){s.message.error(e?.message||`Seed failed`)}finally{w(!1)}}function A(e,n=`listView`){t(e),u(n),i(!0)}return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,l.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,l.jsx)(s.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,l.jsx)(s.Button,{type:`primary`,loading:C,disabled:x||y.length===0,onClick:k,children:`Seed Field Config`})]}),(0,l.jsx)(EN,{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,l.jsx)(Z,{icon:(0,l.jsx)(c.SafetyOutlined,{}),title:`Roles`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,l.jsx)($m,{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,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Button,{size:`small`,type:`link`,onClick:()=>A(t),children:`Configure`}),(0,l.jsx)(s.Button,{size:`small`,type:`link`,icon:(0,l.jsx)(c.LockOutlined,{}),onClick:()=>A(t,`permissions`),children:`Permissions`})]})}],loading:h,total:p})}),(0,l.jsxs)(s.Modal,{className:`uss-modal`,open:r,onCancel:()=>i(!1),title:(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(c.SafetyOutlined,{style:{color:`var(--color-brand)`}}),(0,l.jsxs)(`span`,{children:[`Configure: `,e?.roleName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,l.jsx)(`div`,{style:{marginBottom:12},children:(0,l.jsx)(`div`,{className:`uss-config-toggle`,children:DN.map(e=>(0,l.jsx)(`button`,{className:`uss-config-btn${a===e.key?` active`:``}`,onClick:()=>u(e.key),children:e.label},e.key))})}),e&&(a===`permissions`?(0,l.jsx)(TN,{role:e},e?.roleId):(0,l.jsx)(lS,{role:e,configType:a},`${e?.roleId}-${a}`))]})]})}var NN=`perm-module-labels`,PN=`perm-action-labels`;function FN(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function IN(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function LN({label:e,onSave:t,onDelete:n,loading:r}){let[i,a]=(0,o.useState)(!1),[u,d]=(0,o.useState)(e);function f(){a(!1);let n=u.trim();n&&n!==e?t(n):d(e)}return(0,l.jsxs)(`div`,{className:`perm-manage-row`,children:[i?(0,l.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`&&(a(!1),d(e))}}):(0,l.jsx)(`span`,{className:`perm-manage-row-label`,children:e}),(0,l.jsxs)(`div`,{className:`perm-manage-row-actions`,children:[(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{d(e),a(!0)},loading:r}),(0,l.jsx)(s.Popconfirm,{title:`Delete this item?`,onConfirm:n,okText:`Delete`,cancelText:`Cancel`,okType:`danger`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.DeleteOutlined,{}),danger:!0})})]})]})}function RN({open:e,onClose:t}){let[r,i]=(0,o.useState)(`modules`),[a,u]=(0,o.useState)([]),[d,f]=(0,o.useState)(!1),[p,m]=(0,o.useState)(``),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)(``),[T,E]=(0,o.useState)(!1);(0,o.useEffect)(()=>{e&&(D(),O())},[e]);async function D(){f(!0);try{u(await n.Ir())}catch{s.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await n.Fr())}catch{s.message.error(`Failed to load actions`)}finally{b(!1)}}async function k(){let e=p.trim();if(!e){s.message.warning(`Enter a module name`);return}g(!0);try{let t=await n.Qn({menuName:e});u(e=>[...e,t]),m(``),s.message.success(`Module added`)}catch{s.message.error(`Failed to add module`)}finally{g(!1)}}async function A(e,t){try{await n.gi(e,{menuName:t}),u(n=>n.map(n=>n.MENUID===e?{...n,MENUNAME:t}:n))}catch{s.message.error(`Failed to update module`)}}async function j(e){try{await n.sr(e),u(t=>t.filter(t=>t.MENUID!==e)),s.message.success(`Module deleted`)}catch{s.message.error(`Failed to delete module`)}}async function M(){let e=x.trim(),t=C.trim().toLowerCase().replace(/\s+/g,`_`);if(!e||!t){s.message.warning(`Enter both name and key`);return}E(!0);try{let r=await n.Zn({permissionName:e,permissionKey:t});v(e=>[...e,r]),S(``),w(``),s.message.success(`Action added`)}catch(e){s.message.error(e?.message?.includes(`409`)||e?.status===409?`Permission key already exists`:`Failed to add action`)}finally{E(!1)}}async function N(e,t){try{await n.hi(e,{permissionName:t}),v(n=>n.map(n=>n.permissionId===e?{...n,permissionName:t}:n))}catch{s.message.error(`Failed to update action`)}}async function P(e){try{await n.or(e),v(t=>t.filter(t=>t.permissionId!==e)),s.message.success(`Action deleted`)}catch{s.message.error(`Failed to delete action`)}}let F=[{key:`modules`,label:`Modules`,children:(0,l.jsxs)(s.Spin,{spinning:d,children:[(0,l.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,l.jsx)(s.Input,{placeholder:`Module name`,value:p,onChange:e=>m(e.target.value),onPressEnter:k,style:{flex:1},size:`small`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.PlusOutlined,{}),loading:h,onClick:k,children:`Add`})]}),(0,l.jsxs)(`div`,{className:`perm-manage-list`,children:[a.length===0&&!d&&(0,l.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No modules found`}),a.map(e=>(0,l.jsx)(LN,{label:e.MENUNAME,onSave:t=>A(e.MENUID,t),onDelete:()=>j(e.MENUID)},e.MENUID))]})]})},{key:`actions`,label:`Actions`,children:(0,l.jsxs)(s.Spin,{spinning:y,children:[(0,l.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,l.jsx)(s.Input,{placeholder:`Action name (e.g. Approve)`,value:x,onChange:e=>S(e.target.value),style:{flex:1},size:`small`}),(0,l.jsx)(s.Input,{placeholder:`Key (e.g. approve)`,value:C,onChange:e=>w(e.target.value),onPressEnter:M,style:{width:140},size:`small`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.PlusOutlined,{}),loading:T,onClick:M,children:`Add`})]}),(0,l.jsxs)(`div`,{className:`perm-manage-list`,children:[_.length===0&&!y&&(0,l.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No actions found`}),_.map(e=>(0,l.jsx)(LN,{label:`${e.permissionName} (${e.permissionKey})`,onSave:t=>N(e.permissionId,t),onDelete:()=>P(e.permissionId)},e.permissionId))]})]})}];return(0,l.jsx)(s.Modal,{open:e,onCancel:t,title:(0,l.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(c.SettingOutlined,{style:{color:`var(--color-brand)`}}),`Manage Modules & Actions`]}),width:520,footer:null,destroyOnClose:!0,children:(0,l.jsx)(s.Tabs,{activeKey:r,onChange:i,size:`small`,items:F})})}function zN(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(null),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(()=>FN(NN)),[_,v]=(0,o.useState)(()=>FN(PN)),y=(0,o.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return IN(NN,r),r})},[]),b=(0,o.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return IN(PN,r),r})},[]);function x(){g({}),v({}),IN(NN,{}),IN(PN,{}),s.message.success(`Labels reset to defaults`)}let S=(0,o.useCallback)(async()=>{i(!0);try{let{roles:e}=await n._r();t(e),e.length>0&&u(e[0])}catch{s.message.error(`Failed to load roles`)}finally{i(!1)}},[]);(0,o.useEffect)(()=>{S()},[S]);let C=(0,o.useMemo)(()=>{let t=d.trim().toLowerCase();return t?e.filter(e=>e.roleName.toLowerCase().includes(t)):e},[e,d]),w=Object.keys(h).length>0||Object.keys(_).length>0;return(0,l.jsxs)(`div`,{className:`perm-page`,children:[(0,l.jsxs)(Z,{className:`perm-left-card`,icon:(0,l.jsx)(c.SafetyOutlined,{}),title:`Roles`,bodyStyle:{padding:0},children:[(0,l.jsx)(`div`,{className:`perm-role-search`,children:(0,l.jsx)(s.Input,{prefix:(0,l.jsx)(c.SearchOutlined,{}),placeholder:`Search roles…`,allowClear:!0,size:`small`,value:d,onChange:e=>f(e.target.value)})}),(0,l.jsx)(s.Spin,{spinning:r,children:(0,l.jsxs)(`div`,{className:`perm-role-list`,children:[C.length===0&&!r&&(0,l.jsx)(`div`,{className:`perm-role-empty`,children:`No roles found`}),C.map(e=>{let t=a?.roleId===e.roleId,n=e.description&&e.description!==`N/A`?e.description:e.roleType===0?`Default role`:`Custom role`;return(0,l.jsxs)(`div`,{className:`perm-role-item${t?` active`:``}`,onClick:()=>u(e),children:[(0,l.jsx)(`div`,{className:`perm-role-item-name`,children:e.roleName}),(0,l.jsx)(`div`,{className:`perm-role-item-desc`,children:n})]},e.roleId)})]})})]}),(0,l.jsx)(Z,{className:`perm-right-card`,icon:(0,l.jsx)(c.LockOutlined,{}),title:`Module Permissions`,extra:(0,l.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[w&&(0,l.jsx)(`button`,{className:`perm-reset-btn`,onClick:x,children:`Reset labels`}),(0,l.jsx)(s.Button,{size:`small`,icon:(0,l.jsx)(c.SettingOutlined,{}),onClick:()=>m(!0),children:`Manage`})]}),bodyStyle:{padding:`12px 16px`},children:a?(0,l.jsx)(TN,{role:a,moduleLabels:h,actionLabels:_,onModuleLabelSave:y,onActionLabelSave:b},a.roleId):(0,l.jsx)(`div`,{className:`perm-empty`,children:`Select a role from the left to manage its permissions.`})}),(0,l.jsx)(RN,{open:p,onClose:()=>m(!1)})]})}var{Title:BN,Text:VN}=s.Typography,HN=[{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 UN({items:e=HN}){return(0,l.jsx)(s.Card,{className:`onboarding-card`,title:(0,l.jsx)(BN,{level:5,children:`Onboarding`}),extra:(0,l.jsx)(s.Button,{type:`link`,children:`View all`}),children:(0,l.jsx)(s.Row,{gutter:[12,12],children:e.map(e=>(0,l.jsx)(s.Col,{xs:12,sm:6,md:6,lg:12,xl:12,children:(0,l.jsxs)(`div`,{className:`onboarding-item ${e.color}`,children:[(0,l.jsx)(VN,{className:`onboarding-item-label`,children:e.label}),(0,l.jsx)(s.Statistic,{value:e.value,className:`onboarding-stat`}),(0,l.jsx)(`div`,{className:`onboarding-item-footer`,children:(0,l.jsx)(VN,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:WN,Title:GN}=s.Typography,KN=[{group:`Dashboard`,items:[{id:`dashboard`,label:`Admin Dashboard`,icon:(0,l.jsx)(c.DashboardOutlined,{})}]},{group:`Settings`,items:[{id:`org`,label:`Organization`,icon:(0,l.jsx)(c.BankOutlined,{}),heading:`Organization Settings`,desc:`Manage your company profile and location details`,cards:[{label:`Company Information`,icon:(0,l.jsx)(c.BankOutlined,{}),desc:`Manage company profile, address and business details.`},{label:`Location`,icon:(0,l.jsx)(c.BuildOutlined,{}),desc:`Manage office locations, branches and regions.`}]},{id:`users`,label:`Users`,icon:(0,l.jsx)(c.UserOutlined,{}),heading:`Users`,desc:`Manage platform users and configure their field views.`,component:`users`},{id:`teams`,label:`Teams`,icon:(0,l.jsx)(c.TeamOutlined,{}),heading:`Teams`,desc:`Organize users into teams and configure field visibility per team.`,component:`teams`},{id:`roles`,label:`Roles`,icon:(0,l.jsx)(c.SafetyOutlined,{}),heading:`Roles`,desc:`Control permissions and configure field visibility per role.`,component:`roles`},{id:`permissions`,label:`Permissions`,icon:(0,l.jsx)(c.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,l.jsx)(c.FileTextOutlined,{}),heading:`Templates`,desc:`Email and signature templates for communications`,component:`templates`},{id:`ai-services`,label:`AI Services`,icon:(0,l.jsx)(c.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,l.jsx)(c.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,l.jsx)(c.BankOutlined,{}),heading:`Clients`,desc:`Manage client accounts and settings`,cards:[{label:`Clients`,icon:(0,l.jsx)(c.BankOutlined,{}),desc:`Manage client companies and account details.`}]}]},{group:`Forms`,items:[{id:`form-groups`,label:`Form Groups`,icon:(0,l.jsx)(c.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,l.jsx)(c.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,l.jsx)(c.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,l.jsx)(c.AppstoreOutlined,{}),heading:`Jobs Master`,desc:`Configure job sources and status types`,cards:[{label:`Sources`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),desc:`Manage job source master values.`},{label:`Job Status`,icon:(0,l.jsx)(c.CheckCircleOutlined,{}),desc:`Configure job workflow status.`}]},{id:`candidates`,label:`Candidates`,icon:(0,l.jsx)(c.UserOutlined,{}),heading:`Candidates Master`,desc:`Skills, sources and work authorization settings`,cards:[{label:`Sources`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),desc:`Manage candidate source values.`},{label:`Skills`,icon:(0,l.jsx)(c.SettingOutlined,{}),desc:`Manage skill master data.`},{label:`Work Authorization`,icon:(0,l.jsx)(c.SafetyOutlined,{}),desc:`Manage visa and authorization types.`}]},{id:`submissions`,label:`Submissions`,icon:(0,l.jsx)(c.FileTextOutlined,{}),heading:`Submissions Master`,desc:`Rejection reasons and submission status configuration`,cards:[{label:`Rejection Reasons`,icon:(0,l.jsx)(c.FileTextOutlined,{}),desc:`Manage common rejection reasons.`},{label:`Client Submission Status`,icon:(0,l.jsx)(c.CheckCircleOutlined,{}),desc:`Manage client submission statuses.`}]},{id:`clientmaster`,label:`Client Master`,icon:(0,l.jsx)(c.BankOutlined,{}),heading:`Client Master`,desc:`Payment terms, client types and contact types`,cards:[{label:`Payment Terms`,icon:(0,l.jsx)(c.FileTextOutlined,{}),desc:`Manage billing and payment terms.`},{label:`Client Type`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),desc:`Classify client business types.`},{label:`Client Contact Type`,icon:(0,l.jsx)(c.TeamOutlined,{}),desc:`Manage client contact categories.`}]}]}],qN=[{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}],JN=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],YN=[{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 XN(){return(0,l.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.DashboardOutlined,{}),title:`Admin Dashboard`,children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(GN,{level:5,children:`Admin Dashboard`}),(0,l.jsx)(WN,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,l.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,l.jsx)(iN,{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,l.jsxs)(`div`,{className:`admin-dashboard-mid-row`,children:[(0,l.jsx)(UN,{}),(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,l.jsx)(WN,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,l.jsx)(`div`,{className:`admin-pipeline-bar`,children:qN.map(e=>(0,l.jsx)(`div`,{className:`admin-pipeline-seg`,style:{width:`${e.pct}%`,background:e.color}},e.label))}),(0,l.jsx)(`div`,{className:`admin-pipeline-legend`,children:qN.map(e=>(0,l.jsxs)(`div`,{className:`admin-pipeline-legend-item`,children:[(0,l.jsx)(`span`,{className:`admin-pipeline-dot`,style:{background:e.color}}),e.label,` `,e.count]},e.label))}),(0,l.jsx)(`div`,{className:`admin-divider`}),(0,l.jsx)(WN,{strong:!0,style:{fontSize:12},children:`Submission status`}),(0,l.jsxs)(`div`,{className:`admin-sub-status-list`,style:{marginTop:6},children:[(0,l.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,l.jsx)(WN,{style:{fontSize:13},children:`Pending client review`}),(0,l.jsx)(`span`,{className:`admin-badge warn`,children:`312`})]}),(0,l.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,l.jsx)(WN,{style:{fontSize:13},children:`Client approved`}),(0,l.jsx)(`span`,{className:`admin-badge success`,children:`248`})]}),(0,l.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,l.jsx)(WN,{style:{fontSize:13},children:`Rejected`}),(0,l.jsx)(`span`,{className:`admin-badge danger`,children:`89`})]})]})]})]}),(0,l.jsxs)(`div`,{className:`admin-dashboard-bottom-row`,children:[(0,l.jsx)(Z,{icon:(0,l.jsx)(c.BankOutlined,{}),title:`Top Clients`,extra:(0,l.jsx)(s.Button,{type:`link`,size:`small`,children:`View all`}),children:JN.map(e=>(0,l.jsxs)(`div`,{className:`admin-client-row`,children:[(0,l.jsxs)(`div`,{className:`admin-client-left`,children:[(0,l.jsx)(`div`,{className:`admin-client-icon`,children:(0,l.jsx)(c.BankOutlined,{})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`admin-client-name`,children:e.name}),(0,l.jsxs)(`div`,{className:`admin-client-sub`,children:[e.jobs,` open jobs`]})]})]}),(0,l.jsxs)(`div`,{className:`admin-client-right`,children:[(0,l.jsx)(`div`,{className:`admin-client-val`,children:e.candidates}),(0,l.jsx)(`div`,{className:`admin-client-sub`,children:`candidates`})]})]},e.name))}),(0,l.jsx)(Z,{icon:(0,l.jsx)(c.BellOutlined,{}),title:`Recent Activity`,children:YN.map((e,t)=>(0,l.jsxs)(`div`,{className:`admin-activity-row`,children:[(0,l.jsx)(`div`,{className:`admin-activity-dot`,style:{background:e.color}}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`admin-activity-text`,children:e.text}),(0,l.jsx)(`div`,{className:`admin-activity-time`,children:e.time})]})]},t))})]}),(0,l.jsx)(Z,{icon:(0,l.jsx)(c.SettingOutlined,{}),title:`Admin Configuration Overview`,extra:(0,l.jsx)(s.Button,{type:`link`,size:`small`,children:`Manage`}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsxs)(s.Col,{span:8,children:[(0,l.jsx)(WN,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Settings`}),[[`Organization`,2],[`User Settings`,4],[`Templates`,2]].map(([e,t])=>(0,l.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,l.jsx)(WN,{style:{fontSize:12},children:e}),(0,l.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,l.jsxs)(s.Col,{span:8,children:[(0,l.jsx)(WN,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Master`}),[[`Jobs`,2],[`Candidates`,3],[`Submissions`,2]].map(([e,t])=>(0,l.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,l.jsx)(WN,{style:{fontSize:12},children:e}),(0,l.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,l.jsxs)(s.Col,{span:8,children:[(0,l.jsx)(WN,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`System`}),[[`Total Groups`,4],[`Total Modules`,9],[`Config Items`,19]].map(([e,t])=>(0,l.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,l.jsx)(WN,{style:{fontSize:12},children:e}),(0,l.jsx)(WN,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function ZN({activeSection:e,activeGroup:t,filteredCards:n,searchText:r,setSearchText:i,allItems:a,handleNav:o}){return(0,l.jsxs)(s.Row,{gutter:[16,16],children:[(0,l.jsx)(s.Col,{span:24,children:(0,l.jsxs)(Z,{icon:e?.icon,title:e?.heading,extra:(0,l.jsx)(s.Input,{className:`admin-search`,prefix:(0,l.jsx)(c.SearchOutlined,{}),placeholder:`Search settings…`,allowClear:!0,value:r,onChange:e=>i(e.target.value)}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(GN,{level:5,children:e?.heading}),(0,l.jsx)(WN,{type:`secondary`,children:e?.desc})]})}),(0,l.jsx)(s.Col,{xs:24,xl:16,style:{alignSelf:`flex-start`},children:(0,l.jsx)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Configuration Items`,extra:(0,l.jsxs)(WN,{type:`secondary`,children:[n.length,` item`,n.length===1?``:`s`]}),children:(0,l.jsx)(s.Row,{gutter:[14,14],children:n.length>0?n.map(e=>(0,l.jsx)(s.Col,{xs:24,sm:12,xl:8,children:(0,l.jsxs)(`div`,{className:`admin-config-item`,children:[(0,l.jsx)(`div`,{className:`admin-config-top-bar`}),(0,l.jsxs)(`div`,{className:`admin-config-body`,children:[(0,l.jsx)(`div`,{className:`admin-config-icon`,children:e.icon}),(0,l.jsxs)(`div`,{className:`admin-config-text`,children:[(0,l.jsx)(`span`,{className:`admin-config-label`,children:e.label}),(0,l.jsx)(`span`,{className:`admin-config-desc`,children:e.desc})]})]}),(0,l.jsx)(`div`,{className:`admin-config-divider`}),(0,l.jsx)(s.Button,{type:`link`,size:`small`,className:`admin-config-manage`,icon:(0,l.jsx)(c.RightOutlined,{}),iconPosition:`end`,children:`Manage`})]})},e.label)):(0,l.jsx)(s.Col,{span:24,children:(0,l.jsx)(`div`,{className:`admin-config-empty`,children:(0,l.jsx)(s.Empty,{description:`No settings found`,image:s.Empty.PRESENTED_IMAGE_SIMPLE})})})})})}),(0,l.jsx)(s.Col,{xs:24,xl:8,style:{alignSelf:`flex-start`},children:(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`Section Overview`,children:[(0,l.jsx)(`div`,{className:`admin-overview-list`,children:KN.filter(e=>e.group!==`Dashboard`).map(e=>{let n=e.group===t?.group;return(0,l.jsxs)(`div`,{className:`admin-overview-item${n?` active`:``}`,onClick:()=>{let t=e.items[0];t&&o(t.id)},children:[(0,l.jsxs)(`div`,{className:`admin-overview-left`,children:[(0,l.jsx)(`div`,{className:`admin-overview-icon`,children:e.items[0]?.icon}),(0,l.jsxs)(`div`,{className:`admin-overview-text`,children:[(0,l.jsx)(`span`,{className:`admin-overview-name`,children:e.group}),(0,l.jsxs)(`span`,{className:`admin-overview-sub`,children:[e.items.length,` module`,e.items.length===1?``:`s`]})]})]}),(0,l.jsx)(`span`,{className:`admin-overview-count${n?` active`:``}`,children:e.items.length})]},e.group)})}),(0,l.jsxs)(`div`,{className:`admin-overview-footer`,children:[(0,l.jsx)(`span`,{className:`admin-overview-footer-label`,children:`Total configuration items`}),(0,l.jsx)(`span`,{className:`admin-overview-footer-value`,children:a.filter(e=>e.cards).reduce((e,t)=>e+t.cards.length,0)})]})]})})]})}function QN(){let[e,t]=(0,o.useState)(`dashboard`),[n,r]=(0,o.useState)(``),i=(0,o.useMemo)(()=>KN.flatMap(e=>e.items),[]),a=(0,o.useMemo)(()=>i.find(t=>t.id===e),[i,e]),u=(0,o.useMemo)(()=>KN.find(t=>t.items.some(t=>t.id===e)),[e]),d=(0,o.useMemo)(()=>{if(!a?.cards)return[];let e=n.trim().toLowerCase();return e?a.cards.filter(t=>t.label.toLowerCase().includes(e)||t.desc.toLowerCase().includes(e)):a.cards},[a,n]),f=(0,o.useMemo)(()=>KN.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),r(``)};return e===`dashboard`||a?.heading,(0,l.jsxs)(`main`,{className:`admin-page`,children:[(0,l.jsx)(`div`,{className:`admin-breadcrumb`,children:(0,l.jsx)(s.Breadcrumb,{items:[{title:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.HomeOutlined,{}),` Home`]})},{title:`Admin`}]})}),(0,l.jsxs)(s.Row,{gutter:[16,16],className:`admin-wrapper`,children:[(0,l.jsx)(s.Col,{xs:24,lg:6,xl:5,children:(0,l.jsxs)(Z,{title:`Admin Console`,icon:(0,l.jsx)(c.SettingOutlined,{}),children:[(0,l.jsxs)(`div`,{className:`admin-sidebar-banner`,children:[(0,l.jsx)(`span`,{className:`admin-sidebar-banner-title`,children:`Admin Panel`}),(0,l.jsx)(`span`,{className:`admin-sidebar-banner-sub`,children:`Configuration Center`}),(0,l.jsxs)(s.Row,{gutter:[8,0],children:[(0,l.jsx)(s.Col,{span:12,children:(0,l.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,l.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Groups`}),(0,l.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:KN.length})]})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,l.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Modules`}),(0,l.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:i.length})]})})]})]}),(0,l.jsx)(s.Menu,{mode:`inline`,selectedKeys:[e],items:f,onClick:({key:e})=>p(e),className:`admin-sidebar-menu`})]})}),(0,l.jsx)(s.Col,{xs:24,lg:18,xl:19,children:e===`dashboard`?(0,l.jsx)(XN,{}):a?.component===`form-groups`?(0,l.jsx)(ow,{}):a?.component===`detail-groups`?(0,l.jsx)(Vw,{}):a?.component===`row-actions`?(0,l.jsx)(AT,{}):a?.component===`users`?(0,l.jsx)(cN,{}):a?.component===`teams`?(0,l.jsx)(mN,{}):a?.component===`roles`?(0,l.jsx)(MN,{}):a?.component===`permissions`?(0,l.jsx)(zN,{}):a?.component===`templates`?(0,l.jsx)(HT,{}):a?.component===`ai-services`?(0,l.jsx)(KT,{}):a?.component===`bgc-integration`?(0,l.jsx)(QT,{}):(0,l.jsx)(ZN,{activeSection:a,activeGroup:u,filteredCards:d,searchText:n,setSearchText:r,allItems:i,handleNav:p})})]})]})}var{Title:$N}=s.Typography;function eP(){let e=(0,d.useNavigate)(),{state:t}=(0,d.useLocation)(),n=t?.moduleName||`stickyNotes`,r=t?.title||`Sticky Notes`,i={...t?.request,params:{...t?.request?.params,limit:200,offset:0}};return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.ArrowLeftOutlined,{}),onClick:()=>e(-1),style:{marginBottom:12},children:`Back`}),(0,l.jsx)(Rt,{moduleName:n,title:r,columns:4,request:i,viewAll:!1})]})}var{Text:tP,Title:nP}=s.Typography,rP=10485760,iP=`/templates/test_cases_flow_template.base64.txt`,aP=`test_cases_flow_template.xlsx`,oP=`module | subModule | step_order | description | actions | key | value | expected | scenario`,sP={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},cP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function lP(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 uP(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function dP(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function fP({errors:e}){return(0,l.jsx)(`div`,{className:`bulk-tooltip-errors`,children:(e??[]).map((e,t)=>(0,l.jsx)(`div`,{children:e.message},`${e.field}-${t}`))})}function pP({errors:e,expanded:t,onToggle:n,onSummaryClick:r}){return e.length===0?null:(0,l.jsxs)(`div`,{className:`bulk-error-banner`,children:[(0,l.jsxs)(`div`,{className:`bulk-error-summary`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`bulk-error-summary-main`,onClick:r,"aria-label":`Scroll to first invalid row`,children:[(0,l.jsx)(c.ExclamationCircleOutlined,{className:`bulk-error-icon`}),(0,l.jsxs)(`span`,{children:[e.length,` validation error(s) found`]})]}),(0,l.jsx)(s.Button,{type:`link`,onClick:n,"aria-expanded":t,children:t?`Hide Errors`:`View Errors`})]}),t&&(0,l.jsx)(`div`,{className:`bulk-error-list`,role:`region`,"aria-label":`Validation error details`,children:e.map((e,t)=>(0,l.jsxs)(`div`,{className:`bulk-error-line`,children:[(0,l.jsxs)(`span`,{className:`bulk-row-chip`,children:[`Row `,e.id]}),(0,l.jsx)(`span`,{children:e.message})]},`${e.id}-${e.field}-${t}`))})]})}function mP({rows:e,view:t,onViewChange:n,onConfirm:r,onReset:i,saving:a,firstInvalidRowId:o,firstInvalidRowRef:u}){let d=e.filter(e=>e.row_status===`invalid`),f=t===`errors`?d:e,p=d.length>0||a;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(s.Row,{justify:`space-between`,align:`middle`,gutter:[16,16],className:`bulk-table-toolbar`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space.Compact,{children:[(0,l.jsx)(s.Button,{type:t===`all`?`primary`:`default`,onClick:()=>n(`all`),children:`All rows`}),(0,l.jsx)(s.Button,{type:t===`errors`?`primary`:`default`,onClick:()=>n(`errors`),children:`Errors only`})]})}),(0,l.jsx)(s.Col,{children:(0,l.jsxs)(tP,{type:`secondary`,children:[e.length,` row(s)`]})})]}),(0,l.jsx)(`div`,{className:`bulk-table-wrap`,children:(0,l.jsxs)(`table`,{className:`bulk-preview-table`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:`bulk-col-row`,children:`Row`}),(0,l.jsx)(`th`,{className:`bulk-col-flow`,children:`Submodule`}),(0,l.jsx)(`th`,{className:`bulk-col-description`,children:`Description`}),(0,l.jsx)(`th`,{className:`bulk-col-keyword`,children:`Action`}),(0,l.jsx)(`th`,{className:`bulk-col-target`,children:`Key`}),(0,l.jsx)(`th`,{className:`bulk-col-status`,children:`Status`}),(0,l.jsx)(`th`,{className:`bulk-col-error`,children:`Error`})]})}),(0,l.jsx)(`tbody`,{children:f.map(e=>{let t=e.errors??[],n=e.row_status===`invalid`;return(0,l.jsxs)(`tr`,{ref:n&&e.id===o?u:null,className:n?`bulk-row-invalid`:``,children:[(0,l.jsx)(`td`,{children:e.id}),(0,l.jsx)(`td`,{title:e.submodule,children:e.submodule}),(0,l.jsx)(`td`,{title:e.description,children:e.description?e.description:(0,l.jsx)(`span`,{className:`bulk-empty-text`,children:`-empty-`})}),(0,l.jsx)(`td`,{children:(0,l.jsx)(`code`,{className:`bulk-code-chip`,children:e.actions})}),(0,l.jsx)(`td`,{title:e.key,children:e.key}),(0,l.jsx)(`td`,{children:n?(0,l.jsx)(s.Tag,{color:`red`,children:`Error`}):(0,l.jsx)(s.Tag,{color:`green`,children:`Valid`})}),(0,l.jsx)(`td`,{children:n?(0,l.jsx)(s.Tooltip,{title:(0,l.jsx)(fP,{errors:t}),placement:`left`,children:(0,l.jsxs)(`button`,{type:`button`,className:`bulk-error-info`,"aria-label":`View ${t.length} error(s) for row ${e.id}`,children:[(0,l.jsx)(c.InfoCircleOutlined,{}),(0,l.jsx)(s.Badge,{count:t.length,size:`small`})]})}):(0,l.jsx)(`span`,{className:`bulk-error-none`,children:`-`})})]},`${e.id}-${e.step_order}`)})})]})}),(0,l.jsxs)(s.Space,{className:`bulk-actions`,children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:i,children:`Reset`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:a,disabled:p,onClick:r,children:d.length>0?`Fix ${d.length} error(s) to proceed`:`Save to database`})]})]})}function hP(){let e=(0,d.useNavigate)(),r=(0,o.useMemo)(()=>t.l(),[]),i=(0,o.useRef)(null),a=(0,o.useRef)(null),[u,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(``),[h,g]=(0,o.useState)(`idle`),[_,v]=(0,o.useState)(!1),[y,b]=(0,o.useState)(null),[x,S]=(0,o.useState)([]),[C,w]=(0,o.useState)(`all`),[T,E]=(0,o.useState)(null),[D,O]=(0,o.useState)(null),[k,A]=(0,o.useState)(!1),j=u.map(e=>({value:e.modulename,label:e.modulename})),M=dP(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=sP[h]??0,I=x.find(e=>e.row_status===`invalid`)?.id,L=(0,o.useCallback)(()=>{m(``),g(`idle`),v(!1),b(null),S([]),w(`all`),E(null),O(null),i.current&&(i.current.value=``)},[]);(0,o.useEffect)(()=>{async function e(){try{let e=await Zb({project:r?.name??``,activeOnly:!0});f(e?.items??[])}catch(e){console.error(e),s.message.error(`Unable to load modules.`)}}e()},[r?.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>rP){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 lP(e);g(`validating`);let i=await Kb({filename:e.name,project:r?.name??``,module:p,file_base64:n,file_type:t});S(i?.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(iP);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 i=new Blob([r],{type:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=aP,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),s.message.success(`Sample template downloaded.`)}catch(e){console.error(e),s.message.error(`Unable to download sample template.`)}},V=async()=>{g(`inserting`),E(null);try{let t=await qb({project:r?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:uP(x)});O(t),g(`done`),s.message.success(`Bulk upload saved. Redirecting to view test cases...`),window.setTimeout(()=>e(`/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,o.useCallback)(()=>{a.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[]),ee=[`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,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:cP})}),r?.name&&(0,l.jsx)(s.Col,{children:(0,l.jsx)(tP,{strong:!0,children:r.name})})]}),(0,l.jsxs)(`div`,{className:`zt-page zt-page-wide bulk-page`,children:[(0,l.jsxs)(`div`,{className:`bulk-header`,children:[(0,l.jsx)(nP,{level:3,children:`Bulk upload test cases`}),(0,l.jsxs)(s.Space,{direction:`vertical`,size:4,children:[(0,l.jsx)(tP,{type:`secondary`,children:oP}),(0,l.jsx)(tP,{type:`secondary`,children:`Use the sample template for the required columns. Uploaded rows are saved as Active by default.`})]})]}),(0,l.jsx)(`div`,{className:`bulk-stepbar`,children:[`Select`,`Upload`,`Validate`,`Save`].map((e,t)=>(0,l.jsxs)(`span`,{className:t<F?`bulk-step-active`:``,children:[t+1,` `,e]},e))}),(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:`1. Module selector`,children:(0,l.jsx)(s.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,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:`2. File upload`,extra:(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.DownloadOutlined,{}),onClick:B,children:`Download Sample Template`}),children:[(0,l.jsx)(s.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,l.jsxs)(`button`,{type:`button`,className:ee,disabled:!P,onClick:()=>i.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,l.jsx)(c.CloudUploadOutlined,{className:`bulk-upload-icon`}),y?(0,l.jsxs)(`span`,{className:`bulk-file-chip`,children:[y.name,` - `,Math.ceil(y.size/1024),` KB`]}):(0,l.jsx)(`span`,{children:`Drag & drop here, or click to browse`})]}),(0,l.jsx)(`input`,{ref:i,hidden:!0,type:`file`,accept:`.xlsx,.csv`,onChange:e=>z(e.target.files?.[0])}),N&&(0,l.jsx)(s.Progress,{percent:h===`encoding`?45:82,showInfo:!1,size:`small`}),T&&h!==`preview`&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`})]}),x.length>0&&(0,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:`3. Validation result`,children:[(0,l.jsx)(pP,{errors:M,expanded:k,onToggle:()=>A(e=>!e),onSummaryClick:H}),T&&h===`preview`&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`}),(0,l.jsx)(mP,{rows:x,view:C,onViewChange:w,onConfirm:V,onReset:L,saving:h===`inserting`,firstInvalidRowId:I,firstInvalidRowRef:a})]}),D&&h===`done`&&(0,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:`4. Upload complete`,children:[(0,l.jsxs)(s.Row,{gutter:[16,16],className:`bulk-metrics`,children:[(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(tP,{children:`Total`}),(0,l.jsx)(`strong`,{children:x.length})]})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(tP,{children:`Inserted`}),(0,l.jsx)(`strong`,{children:D.inserted??0})]})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(tP,{children:`Failed`}),(0,l.jsx)(`strong`,{children:D.failed??0})]})})]}),(0,l.jsx)(s.Alert,{type:`success`,showIcon:!0,icon:(0,l.jsx)(c.CheckCircleOutlined,{}),message:`${D.inserted??0} test cases saved to database - module: ${p}`,className:`bulk-inline-alert`}),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:L,children:`Upload another file`})]})]})]})}var gP=[{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:_P}=s.Typography,vP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],yP={tags:`regression`,active:1},bP={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function xP(e=[]){return e.map(e=>({value:e,label:e}))}function SP(e=``){return String(e??``).trim()}function CP(e=``){return SP(e).toLowerCase()}function wP(e=[]){let t=new Map;return e.forEach(e=>{let n=SP(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function TP(e=[],t,n){let r=SP(t).toLowerCase(),i=SP(n).toLowerCase();return e.reduce((e,t)=>{let n=SP(t?.module).toLowerCase(),a=SP(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 EP({icon:e,title:t}){return(0,l.jsxs)(s.Space,{size:10,align:`center`,children:[(0,l.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,l.jsx)(_P,{strong:!0,className:`v1-section-label`,children:t})]})}function DP(){let[e]=s.Form.useForm(),[t]=s.Form.useForm(),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)([]),[f,p]=(0,o.useState)([]),[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)({open:!1,typeKey:`module`}),[b,x]=(0,o.useState)(!1),[S,C]=(0,o.useState)(!1),[w,T]=(0,o.useState)(!1),E=(0,d.useNavigate)(),D=bP[v.typeKey],O=(0,o.useMemo)(()=>xP(r),[r]),k=s.Form.useWatch(`module`,e),A=s.Form.useWatch(`flow`,e),j=!!SP(k),M=!!SP(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&i(t)},I=async()=>{h(!0);try{let e=await Vb(bP.module.dbName);i(e?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),s.message.error(`Unable to load testing options.`)}finally{h(!1)}},L=(0,o.useCallback)(async t=>{let n=SP(t);if(u([]),p([]),e.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await Gb({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];u(t),p(wP(t))}catch(e){console.error(`Unable to load flows:`,e),s.message.error(`Unable to load flows.`)}finally{_(!1)}}},[e]),R=(0,o.useCallback)(async(t,n,r)=>{let i=SP(t),a=SP(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}C(!0);try{e.setFieldsValue({step_order:TP(r,i,a)})}catch(e){console.error(`Unable to load step order:`,e),s.message.error(`Unable to load step order.`)}finally{C(!1)}},[e]);(0,o.useEffect)(()=>{Promise.resolve().then(I)},[]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>L(k))},[L,k]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>R(k,A,a))},[a,R,A,k]);let z=async t=>{let n={module:SP(t.module),flow:SP(t.flow),step_order:Number(t.step_order),description:SP(t.description),keyword:CP(t.keyword),target:SP(t.target),value:SP(t.value),expected:SP(t.expected),tags:t.tags?SP(t.tags):yP.tags,active:Number(t.active)};T(!0);try{await Wb(n),s.message.success(`Test case details saved successfully.`),e.resetFields(),u([]),p([])}catch(e){console.error(`Unable to save test case:`,e),s.message.error(`Unable to save test case.`)}finally{T(!1)}},B=(t,n)=>{e.setFieldsValue({[t]:SP(n)})},V=t=>{e.setFieldsValue({module:SP(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:yP.tags,value:void 0,expected:void 0})},H=t=>{e.setFieldsValue({flow:SP(t),step_order:void 0})},ee=e=>{let n=bP[e];y({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},U=()=>{y(e=>({...e,open:!1})),t.resetFields()},te=async()=>{try{let n=SP((await t.validateFields()).name),r=await Hb({name:n,type:D.dbName});F(v.typeKey,r?.items??[]),e.setFieldsValue({[D.formField]:n}),s.message.success(`${D.label} added successfully.`),U()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),s.message.error(`Unable to add ${D.label.toLowerCase()}.`)}finally{x(!1)}};return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:vP})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>E(`/zinnext-home`),children:`View Table`})})]}),(0,l.jsx)(`div`,{className:`v1-page`,children:(0,l.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,l.jsx)(`div`,{className:`v1-page-header`,children:(0,l.jsxs)(s.Space,{align:`center`,size:10,children:[(0,l.jsx)(c.ProfileOutlined,{className:`v1-outer-icon`}),(0,l.jsx)(`div`,{children:(0,l.jsx)(_P,{strong:!0,style:{fontSize:16},children:`Add Test Case`})})]})}),(0,l.jsx)(Z,{children:(0,l.jsxs)(s.Form,{form:e,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:yP,onFinish:z,autoComplete:`off`,children:[(0,l.jsx)(s.Card,{className:`v1-card`,title:(0,l.jsx)(EP,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,l.jsx)(_P,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsxs)(s.Space.Compact,{style:{width:`100%`},children:[(0,l.jsx)(s.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,loading:m,optionFilterProp:`label`,placeholder:`Select module`,options:O,onChange:V})}),(0,l.jsx)(s.Button,{"aria-label":`Add module`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:30},onClick:()=>ee(`module`)})]})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Flow`,name:`flow`,children:(0,l.jsx)(s.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,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,l.jsx)(s.Input,{maxLength:10,disabled:!0,placeholder:S?`Loading step order`:`Step order`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Action`,name:`keyword`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,disabled:P,optionFilterProp:`label`,placeholder:`Select action`,options:gP,onChange:t=>e.setFieldsValue({keyword:CP(t)})})})}),(0,l.jsx)(s.Col,{xs:24,children:(0,l.jsx)(s.Form.Item,{label:`Description`,name:`description`,children:(0,l.jsx)(s.Input.TextArea,{rows:3,maxLength:255,disabled:P,placeholder:`Enter description`,showCount:!0,onBlur:e=>B(`description`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Key`,name:`target`,children:(0,l.jsx)(s.Input,{maxLength:255,disabled:P,placeholder:`Enter target`,onBlur:e=>B(`target`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Tags`,name:`tags`,children:(0,l.jsx)(s.Input,{maxLength:200,disabled:P,placeholder:`Enter tags`,prefix:(0,l.jsx)(c.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>B(`tags`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Value`,name:`value`,children:(0,l.jsx)(s.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter value`,onBlur:e=>B(`value`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Expected`,name:`expected`,children:(0,l.jsx)(s.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter expected result`,onBlur:e=>B(`expected`,e.target.value)})})})]})}),(0,l.jsx)(`div`,{className:`v1-form-actions`,children:(0,l.jsx)(s.Form.Item,{children:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,loading:w,disabled:P,children:`Submit`}),(0,l.jsx)(s.Button,{onClick:()=>{e.resetFields(),u([]),p([])},children:`Reset`})]})})})]})}),(0,l.jsx)(s.Modal,{title:`Add ${D.label}`,open:v.open,confirmLoading:b,okText:`Add`,onCancel:U,onOk:()=>{x(!0),te()},destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:t,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,l.jsx)(s.Form.Item,{label:`Name`,name:`name`,children:(0,l.jsx)(s.Input,{maxLength:100,placeholder:`Enter ${D.label.toLowerCase()} name`,onBlur:e=>{t.setFieldsValue({name:SP(e.target.value)})}})}),(0,l.jsx)(s.Form.Item,{label:`Type`,name:`type`,children:(0,l.jsx)(s.Input,{disabled:!0})})]})})]})})]})}var{Text:OP}=s.Typography,kP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function AP(e=``){return String(e??``).trim()}function jP(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var MP=[{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,l.jsx)(s.Tag,{color:`green`,children:`Positive`}):(0,l.jsx)(s.Tag,{color:`red`,children:`Negative`})}],NP={key:!1,value:!1,expected:!1};function PP(e,t){return t?e[t]??NP:NP}function FP(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function IP(){let[e]=s.Form.useForm(),r=(0,d.useNavigate)(),[i]=(0,d.useSearchParams)(),a=i.get(`edit`),u=!!a,f=(0,o.useMemo)(()=>t.l(),[]),[p,m]=(0,o.useState)([]),[h,g]=(0,o.useState)([]),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)(gP),[x,S]=(0,o.useState)({}),[C,w]=(0,o.useState)(!1),[T,E]=(0,o.useState)(!1),[D,O]=(0,o.useState)(!1),[k,A]=(0,o.useState)(!1),[j,M]=(0,o.useState)(!1),N=s.Form.useWatch(`module`,e),P=s.Form.useWatch(`submodule`,e),F=s.Form.useWatch(`actions`,e),I=!!N,L=!!P,R=(0,o.useMemo)(()=>PP(x,F),[x,F]),z=(0,o.useMemo)(()=>jP(p,`modulename`),[p]),B=(0,o.useMemo)(()=>jP(h,`submodulename`),[h]),V=(0,o.useMemo)(()=>p.find(e=>e.id===N)?.modulename??``,[p,N]),H=(0,o.useMemo)(()=>h.find(e=>e.id===P)?.submodulename??``,[P,h]),ee=(0,o.useCallback)(async()=>{try{let e=await Ub();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),s.message.error(`Unable to load action validation rules.`)}},[]),U=(0,o.useCallback)(async e=>{if(!e){m([]);return}w(!0);try{let t=await Zb({project:e,activeOnly:!0});m(t?.items??[])}catch(e){console.error(`Unable to load modules:`,e),s.message.error(`Unable to load modules.`)}finally{w(!1)}},[]),te=(0,o.useCallback)(async(e,t)=>{if(!e||!t){g([]);return}E(!0);try{let n=await ex({project:e,module:t,activeOnly:!0});g(n?.items??[])}catch(e){console.error(`Unable to load submodules:`,e),s.message.error(`Unable to load submodules.`)}finally{E(!1)}},[]),ne=(0,o.useCallback)(async(t,n,r,i=``)=>{if(!t||!n||!r){v([]),e.setFieldsValue({step_order:void 0});return}O(!0);try{let[a,o]=await Promise.all([rx({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r,actions:i,limit:1e3}),ox({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r})]);v(a?.items??[]),e.setFieldsValue({step_order:o?.step_order??1})}catch(e){console.error(`Unable to load flows:`,e),s.message.error(`Unable to load flows.`)}finally{O(!1)}},[e]),re=(0,o.useCallback)(async(e=``)=>{if(!(!f?.id||!N||!P)){O(!0);try{let t=await rx({product_parent_ID:f.id,module_parent_ID:N,submodule_parent_ID:P,actions:e,limit:1e3});v(t?.items??[])}catch(e){console.error(`Unable to load action flows:`,e),s.message.error(`Unable to load action steps.`)}finally{O(!1)}}},[f?.id,N,P]),ie=(0,o.useCallback)(async()=>{if(!(!a||!f?.name)){M(!0);try{let t=await ax(a);await te(f.name,t.module);let n=await rx({product_parent_ID:t.product_parent_ID,module_parent_ID:t.module_parent_ID,submodule_parent_ID:t.submodule_parent_ID,limit:1e3});v(n?.items??[]),e.setFieldsValue({module:t.module_parent_ID,submodule:t.submodule_parent_ID,step_order:t.step_order,actions:t.actions,key:t.key,value:t.value,expected:t.expected,description:t.description,scenario:t.scenario===1,active:Number(t.active)!==0})}catch(e){console.error(`Unable to load test flow:`,e),s.message.error(`Unable to load test flow for edit.`),r(`/viewTestCase`)}finally{M(!1)}}},[a,e,te,r,f?.name]);return(0,o.useEffect)(()=>{if(!f){r(`/select-project`,{replace:!0});return}Promise.resolve().then(async()=>{await ee(),await U(f.name),a&&await ie()})},[f,r,ee,U,a,ie]),f?(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:kP})}),(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.ProjectOutlined,{}),(0,l.jsx)(OP,{strong:!0,children:f.name})]})})]}),(0,l.jsx)(`div`,{className:`zt-page`,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,colon:!1,className:`v1-form`,initialValues:{scenario:!0,active:!0},onFinish:async t=>{let n={product_parent_ID:Number(f?.id),module_parent_ID:Number(t.module),submodule_parent_ID:Number(t.submodule),description:AP(t.description),actions:AP(t.actions),key:AP(t.key),value:AP(t.value),expected:AP(t.expected),scenario:+!!t.scenario,active:+!!t.active};A(!0);try{if(u){await sx(a,{...n,step_order:Number(t.step_order)}),s.message.success(`Test case updated successfully.`),r(`/viewTestCase`);return}await ix(n),s.message.success(`Step saved (#${t.step_order}).`),e.setFieldsValue({actions:void 0,key:void 0,value:void 0,expected:void 0,description:void 0}),await ne(n.product_parent_ID,n.module_parent_ID,n.submodule_parent_ID)}catch(e){console.error(`Unable to save test case:`,e),s.message.error(u?`Unable to update test case.`:`Unable to save step.`)}finally{A(!1)}},autoComplete:`off`,disabled:j,children:[(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:8,className:`zt-section-title`,children:[(0,l.jsx)(`span`,{className:`zt-step-tag`,children:`1`}),(0,l.jsx)(`span`,{children:`Module & Submodule`})]}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],align:`bottom`,children:[(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Module`,name:`module`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,loading:C,placeholder:`Select module`,options:z,onChange:t=>{let n=p.find(e=>e.id===t)?.modulename??``;e.setFieldsValue({module:t,submodule:void 0,step_order:void 0,actions:void 0,key:void 0,value:void 0,expected:void 0}),FP(e,[`actions`,`key`,`value`,`expected`]),g([]),v([]),te(f?.name,n)}})})}),(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Submodule`,name:`submodule`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,disabled:!I,loading:T,placeholder:I?`Select submodule`:`Select module first`,options:B,onChange:t=>{e.setFieldsValue({submodule:t,actions:void 0,key:void 0,value:void 0,expected:void 0}),FP(e,[`actions`,`key`,`value`,`expected`]),ne(f?.id,N,t)}})})}),(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Scenario`,name:`scenario`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{disabled:!L,checkedChildren:`Positive`,unCheckedChildren:`Negative`})})}),(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Active`,name:`active`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{checkedChildren:`Active`,unCheckedChildren:`Inactive`})})})]})}),L&&(0,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:8,className:`zt-section-title`,children:[(0,l.jsx)(`span`,{className:`zt-step-tag`,children:`2`}),(0,l.jsx)(c.FileTextOutlined,{}),(0,l.jsx)(`span`,{children:`Step Details`})]}),extra:(0,l.jsxs)(OP,{type:`secondary`,children:[V,` / `,H]}),children:[(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Step Order`,name:`step_order`,children:(0,l.jsx)(s.Input,{disabled:!0,placeholder:D?`Loading…`:`Auto`})})}),(0,l.jsx)(s.Col,{xs:24,md:18,children:(0,l.jsx)(s.Form.Item,{label:`Action`,name:`actions`,rules:[{required:!0,message:`Mandatory Field`}],children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,placeholder:`Select action`,options:y,onChange:t=>{let n=PP(x,t);e.setFieldsValue({actions:t,key:n.key?e.getFieldValue(`key`):void 0,value:n.value?e.getFieldValue(`value`):void 0,expected:n.expected?e.getFieldValue(`expected`):void 0}),FP(e,[`key`,`value`,`expected`]),re(t||``)}})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Key`,name:`key`,rules:[{required:R.key,message:`Key is required for this action`}],children:(0,l.jsx)(s.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,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Value`,name:`value`,rules:[{required:R.value,message:`Value is required for this action`}],children:(0,l.jsx)(s.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,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:R.expected,message:`Expected result is required for this action`}],children:(0,l.jsx)(s.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,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Description`,name:`description`,children:(0,l.jsx)(s.Input.TextArea,{rows:2,maxLength:255,showCount:!0,placeholder:`Enter description`})})})]}),(0,l.jsxs)(s.Space,{className:`zt-actions`,children:[(0,l.jsx)(s.Button,{onClick:()=>{if(u){r(`/viewTestCase`);return}e.resetFields(),g([]),v([]),E(!1),O(!1)},children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,loading:k||j,children:u?`Update Test Case`:`Save & Continue`})]})]},`${N}-${P}`),L&&(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.TableOutlined,{}),(0,l.jsx)(`span`,{children:`Added Steps`})]}),extra:(0,l.jsx)(s.Tag,{children:F?`${_.length} ${F} step(s)`:`${_.length} step(s)`}),children:(0,l.jsx)($m,{listName:`Added Steps`,loading:D,fields:MP,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:LP}=s.Typography,RP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function zP(){let e=(0,d.useNavigate)(),r=(0,o.useMemo)(()=>t.l(),[]),[i,a]=(0,o.useState)([]),[u,f]=(0,o.useState)({}),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)(``),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(1),[C,w]=(0,o.useState)(10),T=(0,o.useCallback)(async e=>{if(!e){a([]);return}m(!0);try{let[t,n]=await Promise.all([Zb({project:e}),ex({project:e})]);a(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),s.message.error(`Unable to load modules.`)}finally{m(!1)}},[]);(0,o.useEffect)(()=>{if(!r){e(`/select-project`,{replace:!0});return}Promise.resolve().then(()=>T(r.name))},[r,e,T]);let E=async(e,t)=>{try{await $b(e.id,+!!t),a(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),s.message.success(`Module ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),s.message.error(`Unable to update module status.`)}},D=async()=>{let e=_.trim();if(!e){s.message.warning(`Enter a module name.`);return}b(!0);try{await Qb({project:r.name,modulename:e}),s.message.success(`Module added.`),g(!1),v(``),S(1),T(r.name)}catch(e){console.error(e),s.message.error(`Unable to add module (maybe it already exists).`)}finally{b(!1)}},O=t=>{e(`/test-cases/zinnext/submodules?module=${encodeURIComponent(t.modulename)}`)};return r?(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:RP})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>e(`/addTestCase`),children:`Back to Form`})})]}),(0,l.jsxs)(`div`,{className:`zt-page`,children:[(0,l.jsx)(s.Card,{className:`v1-card zt-bar`,children:(0,l.jsxs)(s.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.ProjectOutlined,{}),(0,l.jsx)(`span`,{children:`Project:`}),(0,l.jsx)(LP,{strong:!0,children:r.name})]})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Module`})})]})}),(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.AppstoreOutlined,{}),(0,l.jsx)(`span`,{children:`Modules`})]}),children:(0,l.jsx)($m,{listName:`Modules`,loading:p,fields:[{label:`Module`,value:`modulename`},{label:`Submodules`,value:`submoduleCount`,width:140,render:(e,t)=>(0,l.jsxs)(s.Button,{type:`link`,className:`zt-count-link`,onClick:()=>O(t),children:[u[t.modulename]??0,` submodule(s)`]})},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,l.jsx)(s.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:i,current:x,pageSize:C,total:i.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,l.jsx)(s.Modal,{title:`Add Module`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,l.jsxs)(s.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,l.jsxs)(LP,{type:`secondary`,children:[`Project: `,(0,l.jsx)(`b`,{children:r.name})]}),(0,l.jsx)(s.Input,{placeholder:`Enter module name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]}):null}var{Text:BP}=s.Typography,VP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function HP(){let e=(0,d.useNavigate)(),[r]=(0,d.useSearchParams)(),i=(0,o.useMemo)(()=>t.l(),[]),a=r.get(`module`)??``,[u,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)(``),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(1),[C,w]=(0,o.useState)(10),T=(0,o.useCallback)(async(e,t)=>{if(!e||!t){f([]);return}m(!0);try{let n=await ex({project:e,module:t});f(n?.items??[])}catch(e){console.error(e),s.message.error(`Unable to load submodules.`)}finally{m(!1)}},[]);(0,o.useEffect)(()=>{if(!i){e(`/select-project`,{replace:!0});return}if(!a){e(`/manageModules`,{replace:!0});return}Promise.resolve().then(()=>T(i.name,a))},[i,a,e,T]);let E=async(e,t)=>{try{await nx(e.id,+!!t),f(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),s.message.success(`Submodule ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),s.message.error(`Unable to update submodule status.`)}},D=async()=>{let e=_.trim();if(!e){s.message.warning(`Enter a submodule name.`);return}b(!0);try{await tx({project:i.name,modulename:a,submodulename:e}),s.message.success(`Submodule added.`),g(!1),v(``),S(1),T(i.name,a)}catch(e){console.error(e),s.message.error(`Unable to add submodule (maybe it already exists).`)}finally{b(!1)}};return!i||!a?null:(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:VP})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>e(`/manageModules`),children:`Back to Modules`})})]}),(0,l.jsxs)(`div`,{className:`zt-page`,children:[(0,l.jsx)(s.Card,{className:`v1-card zt-bar`,children:(0,l.jsxs)(s.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space,{size:16,wrap:!0,className:`zt-section-title`,children:[(0,l.jsxs)(s.Space,{size:6,children:[(0,l.jsx)(c.ProjectOutlined,{}),(0,l.jsx)(`span`,{children:`Project:`}),(0,l.jsx)(BP,{strong:!0,children:i.name})]}),(0,l.jsxs)(s.Space,{size:6,children:[(0,l.jsx)(c.AppstoreOutlined,{}),(0,l.jsx)(`span`,{children:`Module:`}),(0,l.jsx)(BP,{strong:!0,children:a})]})]})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Submodule`})})]})}),(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.AppstoreOutlined,{}),(0,l.jsx)(`span`,{children:`Submodules`})]}),children:(0,l.jsx)($m,{listName:`Submodules`,loading:p,fields:[{label:`Submodule`,value:`submodulename`},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,l.jsx)(s.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:u,current:x,pageSize:C,total:u.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,l.jsx)(s.Modal,{title:`Add Submodule`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,l.jsxs)(s.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,l.jsxs)(BP,{type:`secondary`,children:[`Project: `,(0,l.jsx)(`b`,{children:i.name}),` \xA0|\xA0 Module: `,(0,l.jsx)(`b`,{children:a})]}),(0,l.jsx)(s.Input,{placeholder:`Enter submodule name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]})}var{Text:UP}=s.Typography,WP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function GP(){let e=(0,d.useNavigate)(),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)(0),[f,p]=(0,o.useState)(!1),m=(0,o.useMemo)(()=>t.l(),[]),[h,g]=(0,o.useState)(``),[_,v]=(0,o.useState)(1),[y,b]=(0,o.useState)(20),[x,S]=(0,o.useState)(null),C=(0,o.useCallback)(async(e={})=>{p(!0);try{let t=await rx({product_parent_ID:e.project??m?.id??``,search:e.search??h??``,limit:e.pageSize??y,offset:((e.page??_)-1)*(e.pageSize??y)});i(t?.items??[]),u(t?.total??0)}catch(e){console.error(e),s.message.error(`Unable to load test flows.`)}finally{p(!1)}},[m?.id,h,_,y]),w=e=>{s.Modal.confirm({title:`Delete Test Case`,icon:(0,l.jsx)(c.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 cx(e.id),s.message.success(`Test case deleted successfully.`);let t=r.length===1&&_>1?_-1:_;v(t),await C({page:t})}catch(e){throw console.error(`Unable to delete test flow:`,e),s.message.error(`Unable to delete test case.`),e}finally{S(null)}}})};return(0,o.useEffect)(()=>{Promise.resolve().then(()=>{if(!m?.id){e(`/select-project`,{replace:!0});return}C({page:1})})},[]),(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:WP})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>e(`/addTestCase`),children:`Back to Form`})})]}),(0,l.jsx)(`div`,{className:`zt-page zt-page-wide`,children:(0,l.jsxs)(s.Card,{className:`v1-card`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.TableOutlined,{}),(0,l.jsx)(`span`,{children:`Test Flows`})]}),extra:(0,l.jsxs)(UP,{type:`secondary`,children:[a,` row(s)`]}),children:[(0,l.jsxs)(s.Space,{wrap:!0,className:`zt-toolbar`,children:[(0,l.jsx)(s.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,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:()=>C(),children:`Refresh`})]}),(0,l.jsx)($m,{listName:`Test Flows`,loading:f,fields:[{label:`Actions`,value:`rowActions`,width:112,fixed:`left`,sorter:!1,render:(t,n)=>(0,l.jsxs)(s.Space,{size:4,className:`zt-row-actions`,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>e(`/addTestCase?edit=${n.id}`)})}),(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{danger:!0,type:`text`,size:`small`,icon:(0,l.jsx)(c.DeleteOutlined,{}),loading:x===n.id,onClick:()=>w(n)})})]})},{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,l.jsx)(s.Tag,{color:`green`,children:`Positive`}):(0,l.jsx)(s.Tag,{color:`red`,children:`Negative`})},{label:`Active`,value:`active`,width:90,render:e=>e===1?(0,l.jsx)(s.Tag,{color:`blue`,children:`Active`}):(0,l.jsx)(s.Tag,{children:`Inactive`})}],dataSource:r,current:_,pageSize:y,total:a,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 KP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function qP(){return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsx)(n.t,{items:KP}),(0,l.jsx)(Qo,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:JP}=s.Typography,YP=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],XP={tags:`regression`,active:1},ZP={module:{dbName:`Modules`,formField:`module`,label:`Module`}},QP={key:!1,value:!1,expected:!1};function $P(e,t){return t?e[t]??QP:QP}function eF(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function tF(e=[]){return e.map(e=>({value:e,label:e}))}function nF(e=``){return String(e??``).trim()}function rF(e=[]){let t=new Map;return e.forEach(e=>{let n=nF(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function iF(e=[],t,n){let r=nF(t).toLowerCase(),i=nF(n).toLowerCase();return e.reduce((e,t)=>{let n=nF(t?.module).toLowerCase(),a=nF(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 aF({icon:e,title:t}){return(0,l.jsxs)(s.Space,{size:10,align:`center`,children:[(0,l.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,l.jsx)(JP,{strong:!0,className:`v1-section-label`,children:t})]})}function oF(){let[e]=s.Form.useForm(),[t]=s.Form.useForm(),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)([]),[f,p]=(0,o.useState)([]),[m,h]=(0,o.useState)(gP),[g,_]=(0,o.useState)({}),[v,y]=(0,o.useState)(!1),[b,x]=(0,o.useState)(!1),[S,C]=(0,o.useState)({open:!1,typeKey:`module`}),[w,T]=(0,o.useState)(!1),[E,D]=(0,o.useState)(!1),[O,k]=(0,o.useState)(!1),A=(0,d.useNavigate)(),j=ZP[S.typeKey],M=(0,o.useMemo)(()=>tF(r),[r]),N=s.Form.useWatch(`module`,e),P=s.Form.useWatch(`flow`,e),F=s.Form.useWatch(`keyword`,e),I=!!nF(N),L=!!nF(P),R=!I,z=!I||!L,B=(0,o.useMemo)(()=>$P(g,F),[g,F]),V=(e,t=[])=>{e===`module`&&i(t)},H=async()=>{y(!0);try{let e=await Vb(ZP.module.dbName);i(e?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),s.message.error(`Unable to load testing options.`)}finally{y(!1)}},ee=async()=>{try{let e=await Ub();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),s.message.error(`Unable to load action validation rules.`)}},U=(0,o.useCallback)(async t=>{let n=nF(t);if(u([]),p([]),e.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await Yb({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];u(t),p(rF(t))}catch(e){console.error(`Unable to load flows:`,e),s.message.error(`Unable to load flows.`)}finally{x(!1)}}},[e]),te=(0,o.useCallback)(async(t,n,r)=>{let i=nF(t),a=nF(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}D(!0);try{e.setFieldsValue({step_order:iF(r,i,a)})}catch(e){console.error(`Unable to load step order:`,e),s.message.error(`Unable to load step order.`)}finally{D(!1)}},[e]);(0,o.useEffect)(()=>{Promise.resolve().then(async()=>{await Promise.all([H(),ee()])})},[]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>U(N))},[U,N]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>te(N,P,a))},[a,te,P,N]);let ne=async t=>{let n={module:nF(t.module),flow:nF(t.flow),step_order:Number(t.step_order),description:nF(t.description),keyword:nF(t.keyword),target:nF(t.target),value:nF(t.value),expected:nF(t.expected),tags:t.tags?nF(t.tags):XP.tags,active:Number(t.active)};k(!0);try{await Jb(n),s.message.success(`LMS case details saved successfully.`),e.resetFields(),u([]),p([])}catch(e){console.error(`Unable to save LMS case:`,e),s.message.error(`Unable to save LMS case.`)}finally{k(!1)}},re=(t,n)=>{e.setFieldsValue({[t]:nF(n)})},ie=t=>{e.setFieldsValue({module:nF(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:XP.tags,value:void 0,expected:void 0}),eF(e,[`keyword`,`target`,`value`,`expected`])},ae=t=>{e.setFieldsValue({flow:nF(t),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),eF(e,[`keyword`,`target`,`value`,`expected`])},W=t=>{let n=$P(g,t);e.setFieldsValue({keyword:nF(t),target:n.key?e.getFieldValue(`target`):void 0,value:n.value?e.getFieldValue(`value`):void 0,expected:n.expected?e.getFieldValue(`expected`):void 0}),eF(e,[`target`,`value`,`expected`])},oe=e=>{let n=ZP[e];C({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},se=()=>{C(e=>({...e,open:!1})),t.resetFields()},ce=async()=>{try{let n=nF((await t.validateFields()).name),r=await Hb({name:n,type:j.dbName});V(S.typeKey,r?.items??[]),e.setFieldsValue({[j.formField]:n}),s.message.success(`${j.label} added successfully.`),se()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),s.message.error(`Unable to add ${j.label.toLowerCase()}.`)}finally{T(!1)}};return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:YP})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>A(`/lms-home`),children:`View Table`})})]}),(0,l.jsx)(`div`,{className:`v1-page`,children:(0,l.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,l.jsx)(`div`,{className:`v1-page-header`,children:(0,l.jsxs)(s.Space,{align:`center`,size:10,children:[(0,l.jsx)(c.ProfileOutlined,{className:`v1-outer-icon`}),(0,l.jsx)(`div`,{children:(0,l.jsx)(JP,{strong:!0,style:{fontSize:16},children:`Add LMS Case`})})]})}),(0,l.jsx)(Z,{children:(0,l.jsxs)(s.Form,{form:e,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:XP,onFinish:ne,autoComplete:`off`,children:[(0,l.jsx)(s.Card,{className:`v1-card`,title:(0,l.jsx)(aF,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,l.jsx)(JP,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsxs)(s.Space.Compact,{style:{width:`100%`},children:[(0,l.jsx)(s.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,loading:v,optionFilterProp:`label`,placeholder:`Select module`,options:M,onChange:ie})}),(0,l.jsx)(s.Button,{"aria-label":`Add module`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:30},onClick:()=>oe(`module`)})]})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Flow`,name:`flow`,children:(0,l.jsx)(s.AutoComplete,{maxLength:100,allowClear:!0,disabled:R,options:f,placeholder:b?`Loading flows`:`Enter flow`,onChange:ae,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,l.jsx)(s.Input,{maxLength:10,disabled:!0,placeholder:E?`Loading step order`:`Step order`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Action`,name:`keyword`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,disabled:z,optionFilterProp:`label`,placeholder:`Select action`,options:m,onChange:W})})}),(0,l.jsx)(s.Col,{xs:24,children:(0,l.jsx)(s.Form.Item,{label:`Description`,name:`description`,children:(0,l.jsx)(s.Input.TextArea,{rows:3,maxLength:255,disabled:z,placeholder:`Enter description`,showCount:!0,onBlur:e=>re(`description`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Key`,name:`target`,rules:[{required:B.key,message:`Key is required for this action`}],children:(0,l.jsx)(s.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=>re(`target`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Tags`,name:`tags`,children:(0,l.jsx)(s.Input,{maxLength:200,disabled:z,placeholder:`Enter tags`,prefix:(0,l.jsx)(c.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>re(`tags`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Value`,name:`value`,rules:[{required:B.value,message:`Value is required for this action`}],children:(0,l.jsx)(s.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=>re(`value`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:B.expected,message:`Expected result is required for this action`}],children:(0,l.jsx)(s.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=>re(`expected`,e.target.value)})})})]})}),(0,l.jsx)(`div`,{className:`v1-form-actions`,children:(0,l.jsx)(s.Form.Item,{children:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,loading:O,disabled:z,children:`Submit`}),(0,l.jsx)(s.Button,{onClick:()=>{e.resetFields(),u([]),p([])},children:`Reset`})]})})})]})}),(0,l.jsx)(s.Modal,{title:`Add ${j.label}`,open:S.open,confirmLoading:w,okText:`Add`,onCancel:se,onOk:()=>{T(!0),ce()},destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:t,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,l.jsx)(s.Form.Item,{label:`Name`,name:`name`,children:(0,l.jsx)(s.Input,{maxLength:100,placeholder:`Enter ${j.label.toLowerCase()} name`,onBlur:e=>{t.setFieldsValue({name:nF(e.target.value)})}})}),(0,l.jsx)(s.Form.Item,{label:`Type`,name:`type`,children:(0,l.jsx)(s.Input,{disabled:!0})})]})})]})})]})}var sF=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function cF(){return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsx)(n.t,{items:sF}),(0,l.jsx)(Qo,{moduleName:`lms-flows`,rowKey:`id`})]})}var lF=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function uF(e=lF){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 dF(e,t=lF){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 fF=uF();function pF(e){return typeof e==`function`?e:typeof e==`string`?uF([e]):Array.isArray(e)?uF(e):fF}function mF(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:e?.id??t?.id??n}}function hF(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var gF=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function _F(e){let t=e?.data??e,n={};for(let r of gF){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var vF=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function yF(e,t,n){let r=(Array.isArray(n)?n:[n]).map(vF).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(vF(e?.value))||r.includes(vF(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 bF=(e,t)=>_i(e,t).rows,xF=(e,t)=>{let{rows:n,total:r}=_i(e,t);return{rows:n,total:r}};function SF(e,t){return function(n,r,i,a={}){return e(t??n,r,i,a)}}function CF(e){return!e||typeof e!=`object`||typeof(e.fetchByKeys??e.fetch??e.function)!=`function`?null:{...e,fetchByKeys:typeof e.fetchByKeys==`function`?e.fetchByKeys:null,fetch:typeof e.fetch==`function`?e.fetch:null,function:typeof e.function==`function`?e.function:null,extractRows:typeof e.extractRows==`function`?e.extractRows:bF,mergeRow:typeof e.mergeRow==`function`?e.mergeRow:mF,fetchById:typeof e.fetchById==`function`?e.fetchById:null}}function wF({fetchSecondaryByKeys:e,fetchSecondary:t,extractSecondaryRows:n,fetchSecondaryById:r,secondaryKey:i,mergeRow:a,secondaryFetchLimit:o}){return!e&&!t&&!r?[]:[CF({key:i,fetchByKeys:e?(t,n,r)=>e(t,n,r):null,function:t?({moduleName:e,options:n})=>t(e,o,0,n):null,extractRows:n,fetchById:r,mergeRow:a})].filter(Boolean)}function TF(e){if(typeof e==`function`)return t=>{let n=e(t);return n==null||n===``?[]:[String(n)]};let t=typeof e==`string`?[e]:Array.isArray(e)&&e.length?e:lF;return e=>dF(e,t)}function EF(e,t){let n=new Map;return e.forEach(e=>{for(let r of t(e))n.has(r)||n.set(r,e)}),n}function DF({moduleName:e,limit:t,offset:n,options:r,keys:i,primaryResponse:a,primaryRows:o,pageRows:s,total:c,source:l}){return{moduleName:e,limit:t,offset:n,options:r,keys:i,primaryResponse:a,primaryRows:o,pageRows:s,total:c,source:l}}async function OF(e,t){if(typeof e.args==`function`){let n=e.args(t);return(e.fetch??e.function??e.fetchByKeys)(...Array.isArray(n)?n:[n])}if(Array.isArray(e.args))return(e.fetch??e.function??e.fetchByKeys)(...e.args);if(e.fetchByKeys&&Array.isArray(t.keys))return e.fetchByKeys(t.moduleName,t.keys,t.options,t);let n=e.fetch??e.function;return typeof n==`function`?n(t):null}function kF({fetchPrimaryPage:e,extractPrimaryPage:t=xF,fetchSecondaryByKeys:n,joinSources:r=[],fetchPrimary:i,extractPrimaryRows:a=bF,fetchSecondary:o,extractSecondaryRows:s=bF,fetchSecondaryById:c,primaryKey:l,secondaryKey:u,mergeRow:d=mF,secondaryFetchLimit:f=200,extraFields:p=[],extraFieldsAfter:m}){let h=Array.isArray(r)&&r.length?r.map(CF).filter(Boolean):wF({fetchSecondaryByKeys:n,fetchSecondary:o,extractSecondaryRows:s,fetchSecondaryById:c,secondaryKey:u,mergeRow:d,secondaryFetchLimit:f}),g=0;async function _(e,t,n,r){if(!e.fetchById||!r)return null;try{let i=await e.fetchById(n,r);return i&&t(i).includes(String(r))?i:null}catch(e){return console.error(`[mergedListApi] per-id join lookup failed for "${r}"`,e),null}}async function v(e,t,n,r,i){if(!n)return e;let a=t.extractRows(n,r)??[],o=pF(t.primaryKey??l),s=TF(t.key),c=EF(a,s);return Promise.all(e.map(async e=>{let n=o(e),a=c.get(n)??(i()?null:await _(t,s,r,n));return t.mergeRow(e,a,n)}))}async function y(e,t,n,r){let i=e;for(let e of t)i=await v(i,e.source,e.response,n,r);return i}function b(e,t,n){let r={};for(let e of n){if(!e)continue;let t=_F(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return p.length&&(r.fields=yF(r.fields??[],p,m)),hF(e,t,r)}async function x({moduleName:e,limit:t,offset:n,options:r,primaryResponse:i,primaryRows:a,pageRows:o,total:s}){return Promise.all(h.map(async c=>{try{let u=pF(c.primaryKey??l),d=[...new Set(o.map(u).filter(Boolean))];return c.fetchByKeys&&d.length===0?{source:c,response:null}:{source:c,response:await OF(c,DF({moduleName:e,limit:t,offset:n,options:r,keys:d,primaryResponse:i,primaryRows:a,pageRows:o,total:s,source:c}))}}catch(e){return console.error(`[mergedListApi] join fetch failed — rendering page without that join`,e),{source:c,response:null}}}))}async function S(n,r,i,a,o){let s=await e(n,r,i,a),c=t(s,n)??{},l=Array.isArray(c.rows)?c.rows:[],u=Number.isFinite(Number(c.total))?Number(c.total):l.length,d=await x({moduleName:n,limit:r,offset:i,options:a,primaryResponse:s,primaryRows:l,pageRows:l,total:u});return b(await y(l,d,n,o),u,[s,...d.map(e=>e.response)])}async function C(e,t,n,r,o){let s=await i(e,t,n,r),c=a(s,e)??[],l=c.length,u=c.slice(n,n+t),d=await x({moduleName:e,limit:t,offset:n,options:r,primaryResponse:s,primaryRows:c,pageRows:u,total:l});return b(await y(u,d,e,o),l,[s,...d.map(e=>e.response)])}return async function(t,n=10,r=0,i={}){let a=++g,o=()=>a!==g;return e?S(t,n,r,i,o):C(t,n,r,i,o)}}function AF(e,t,n={}){return kF({fetchPrimary:()=>zA(e,t),extractPrimaryRows:LA,fetchSecondary:Dn,fetchSecondaryById:BA,secondaryFetchLimit:n.moduleFetchLimit??200})}function jF(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 MF(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=jF(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var NF=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function PF({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=mF(n,r,i),o=NF(a);return o!=null&&(a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function FF(e={}){let t=PF();return kF({primaryKey:`_id`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:Dn,joinSources:[{key:`entityId`,fetchByKeys:(e,t,n,r)=>{let i=Math.max(1,Number(r?.limit)||10);return RA(Math.floor((Number(r?.offset)||0)/i)+1,i)},extractRows:e=>(e?.items??[]).map(MF),mergeRow:(e,n,r)=>{let i=t(e,n,r);return n?._id&&(i.workflowId=n._id),i}}]})}async function IF(e,t=10,n=0,r={},i={}){return _i(await FF(i)(e,t,n,r),e)}async function LF(e,t,n,r=10,i=0,a={}){return _i(await AF(e,t)(n,r,i,a),n)}typeof window<`u`&&(window.__CORE_THEME_BUILD__=`2026-10-22T10:33:29.288Z`);var RF=eN,zF=dx(QN),BF=dx(eP),VF=dx(hP),HF=dx(DP),UF=dx(IP),WF=dx(zP),GF=dx(HP),KF=dx(GP),qF=dx(qP),JF=dx(oF),YF=dx(cF);exports.ADMIN_API_URL=t.v,exports.ADMIN_APP_ID=t.y,exports.APP_ID=t.b,exports.AUTH_URL=t.x,exports.ActivityNotesCard=qc,exports.ActivityTab=Hc,exports.AddBatchCandidatePopup=kM,exports.AddFormV1=Tc,exports.AdminDashboard=eN,exports.AdminDashboardContent=ED,exports.AdminPage=RF,exports.AppAlert=Ec,exports.AppButton=n.ft,exports.AppShell=Pb,exports.ApprovalActionBar=U_,exports.AssigneeAvatars=Jc,exports.AuthGuard=Db,exports.BILLING_STATUS_FLOW=wf,exports.BOOLEAN_API_KEYS=kg,exports.BOOLEAN_PARSEABLE_API_KEYS=mh,exports.BULK_UPLOAD_DEFAULT_ACCEPT=Yc,exports.BULK_UPLOAD_DEFAULT_MAX_SIZE_MB=Xc,exports.Breadcrumb=n.t,exports.BulkUploadPage=VF,exports.BulkUploadPanel=il,exports.CANDIDATES_URL=t.S,exports.CONTRACT_C2C=pv,exports.CONTRACT_W2=fv,exports.CURRENCY_SYMBOLS=Du,exports.CalendarCard=A,exports.CoreThemeAdminApp=AD,exports.CoreThemeAdminRoutes=kD,exports.CustomPagination=Be,exports.DEFAULT_HOURS_POLICY=d_,exports.DEFAULT_RESULTS_VIEW=Tg,exports.DayLogModal=F_,exports.DescriptionBlock=_l,exports.DetailHeaderCard=Ep,exports.DetailViewPage=Np,exports.DetailViewV1=Sd,exports.DocumentViewer=n.En,exports.DynamicCards=Rt,exports.DynamicPopup=Zk,exports.DynamicPopupRoute=PM,exports.DynamicTabs=P,exports.EditFormV1=jm,exports.FIELD_TYPE_REGISTRY=Yh,exports.FINANCE_APPROVAL_CONFIG=iv,exports.FINANCE_TYPE_CFO=Z_,exports.FINANCE_TYPE_ONBOARDING_MANAGER=X_,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=ev,exports.FINANCE_TYPE_ONLY_FINANCE=Q_,exports.FINANCE_TYPE_SUBMISSION_MANAGER=Y_,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=$_,exports.FileListCard=vy,exports.FinanceApprovalPanel=Zv,exports.FinanceAvatar=ap,exports.FinanceBadge=lp,exports.FinanceDayCell=G_,exports.FinanceDivider=Zf,exports.FinanceEmployeeCell=op,exports.FinanceEmptyState=Jf,exports.FinanceEquation=Qf,exports.FinanceHistoryTimeline=np,exports.FinanceHoursGrid=qf,exports.FinanceKpiRow=Kf,exports.FinanceLine=Xf,exports.FinanceListToolbar=u_,exports.FinanceMarginBadge=up,exports.FinanceMoneyCell=cp,exports.FinanceRecordsTable=pp,exports.FinanceRowChevron=dp,exports.FinanceSection=Yf,exports.FinanceStatusPill=Gf,exports.FinanceTextCell=sp,exports.FinanceTimesheetAnalysis=q_,exports.FinanceWorkflowSteps=$f,exports.HOURS_MESSAGES=f_,exports.Header=qy,exports.HierarchyUserFilter=Ut,exports.JOBS_URL=t.C,exports.LegacyAdminPage=zF,exports.ListView=Qo,exports.LmsHomePage=YF,exports.LmsTestForm=JF,exports.Login=Fb,exports.MailPopup=sO,exports.ManageModules=WF,exports.ManageSubmodules=GF,exports.ModuleRowActions=Bm,exports.NotesPanel=H_,exports.NotesTab=Kc,exports.OPEN_AS_OPTIONS=gg,exports.PAYROLL_STATUS_FLOW=Tf,exports.POPUP_CONFIGS=bM,exports.ParamCardView=qm,exports.ParamListView=$m,exports.PaymentInvoicePopup=WM,exports.PeriodBadgeTag=w_,exports.PreviewPopup=RO,exports.ProjectSelect=ux,exports.ProofUploadPreview=V_,exports.QuickLogBar=R_,exports.QuickLogSelectionBar=I_,exports.RESULTS_VIEW_OPTIONS=wg,exports.RejectionReasonModal=L_,exports.SUBMISSIONS_URL=t.T,exports.SearchBuilderV1=t_,exports.Sidebar=Cb,exports.StatusBadge=r_,exports.StatusBadgeTag=C_,exports.StickyNotesFullPage=BF,exports.StylishDynamicTabs=a_,exports.TemplateEditor=s_,exports.TestForm=HF,exports.TestingHomePage=qF,exports.TimelineGroups=Pc,exports.TimesheetDayCell=M_,exports.TipTapEditor=n.On,exports.UserForm=$M,exports.VendorShareDrawer=RM,exports.ViewSummaryWidget=Ui,exports.WizardPopup=WO,exports.ZinnextTableView=KF,exports.ZinnextTestForm=UF,exports.appNow=n.Mn,exports.applyIntegrationStatus=n.Jn,exports.approveSubmission=be,exports.buildAcceptAttr=tl,exports.buildBooleanRequest=Pg,exports.buildCsv=zf,exports.buildDailyRows=Nf,exports.buildDayGradient=A_,exports.buildRateHistoryEntries=Rv,exports.buildWeeklyRollup=If,exports.clearSelectedProject=t.i,exports.colors=n.jn,exports.computeFinance=Av,exports.computeHoursPolicy=v_,exports.computeMarginBand=Lf,exports.conditionMatches=n.i,exports.configureCoreTheme=t.E,exports.configuredFieldLabel=n.a,exports.createAllWorkflowsListFetcher=FF,exports.createMergedListFetcher=kF,exports.createModuleListFetchAdapter=SF,exports.createWorkflowStageListFetcher=AF,exports.currencySymbol=Ou,exports.defaultMergeRow=mF,exports.deleteIntegrationConfig=n.ar,exports.deriveDayStats=Mf,exports.describeCapacity=b_,exports.downloadCsv=Uf,exports.evaluateShowIfWith=n.o,exports.findEmployerRow=wv,exports.flattenGroups=Sv,exports.formatAmount=Pu,exports.formatApp=n.Nn,exports.formatAppDateTime=n.Pn,exports.formatFileSize=el,exports.formatFinanceMoney=zv,exports.formatHours=hf,exports.formatMoney=Fu,exports.formatPercent=_f,exports.formatRate=Iu,exports.getActivity=n.pn,exports.getAllWorkflowsModuleList=IF,exports.getAppTimeZone=n.Fn,exports.getApprovalDate=xf,exports.getBgcIntegrationConfig=n.Cr,exports.getBgcIntegrationSummary=n.wr,exports.getBillingActionStates=Ef,exports.getBooleanEligibleTypes=tg,exports.getCurrentRoleName=t.c,exports.getFieldLabel=Vf,exports.getFieldType=Zh,exports.getFileExtension=$c,exports.getFinanceApprovalConfig=lv,exports.getFormGroupsRaw=sy,exports.getIntegrationConfig=n.Ar,exports.getIntegrationConfigs=n.jr,exports.getIntegrationSummary=n.Mr,exports.getModuleConfig=Le,exports.getModuleDataDetail=n.hn,exports.getPayrollActionStates=Df,exports.getPeriodBadgeConfig=ze,exports.getSearchPopup=pg,exports.getSelectedProject=t.l,exports.getStoredToken=t.u,exports.getStoredUser=t.d,exports.getUserRoles=t.f,exports.getVMSApprove=xe,exports.getValueStyle=Hf,exports.getWorkflowStageModuleList=LF,exports.getWorkflowSteps=Of,exports.humanizeEvent=bf,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Cs}}),exports.indexFieldConfig=Bf,exports.initialsOf=vf,exports.insertTokenAtCursor=vh,exports.isBooleanEligible=Qh,exports.isBooleanParsable=gh,exports.isTester=t.p,exports.logout=t.h,exports.marginIncludesReferral=dv,exports.matchLocationTax=kv,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Vp}}),exports.normalizeContract=Ev,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return al}}),exports.rateUnitLabel=Au,exports.rateUnitShort=Mu,exports.readActionButtons=bg,exports.reconcileHours=y_,exports.registerFieldType=Xh,exports.registerSearchPopup=fg,exports.rejectSubmission=q,exports.resolveActivityMeta=zc,exports.resolveAndCompute=jv,exports.resolveDayKind=g_,exports.resolveFinanceInputs=Ov,exports.resolveMergeKey=fF,exports.resolveMergedListKey=fF,exports.resolveOpenAs=vg,exports.resolveRejectionReason=uv,exports.resolveResultsSearchPlaceholder=Og,exports.resolveResultsView=Dg,exports.resolveSubmissionFinance=cy,exports.saveBgcIntegrationConfig=n.ni,exports.saveIntegrationConfig=n.ai,exports.setSelectedProject=t._,exports.showIfConditions=n.c,exports.stageCountKey=jF,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Ib}}),exports.testIntegrationConnection=n.fi,exports.toApp=n.Ln,exports.toNumber=Nu,exports.tzLabel=n.Rn,exports.tzShortLabel=n.zn,exports.unregisterSearchPopup=mg,exports.useDropdownFields=Un,exports.useDropdownValues=Wi,exports.useEditForm=yy,exports.useFieldConfig=Wn,exports.useFilterFields=Gn,exports.useMenuPermission=sr,exports.useModuleActions=Nm,exports.useRecordRefresh=Ap,exports.validateBooleanQuery=_h,exports.validateBulkFile=nl,exports.withAdminAppId=t.D,exports.withAppId=t.O,exports.withAuthGuard=dx;
20
+ `).trim()}function PO(e){return e.replace(/•/g,`
21
+ `).split(/\n+/).map(e=>e.trim().replace(/^[-–—•]\s*/,``).trim()).filter(Boolean)}function FO(e){return PO(e.replace(/(?:^|\s)[-–—]\s+/g,`
22
+ `))}function IO(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:jO(n),value:r}}function LO(e){let t=e.toLowerCase().replace(/[\s:.\-–—]+$/,``).trim();return DO.has(t)?OO.test(t)?`education`:kO.test(t)?`keySkills`:`overview`:null}function RO(e){let t=[],n={overview:[],keySkills:[],education:[]},r=`overview`;return e.forEach(e=>{let i=LO(e);if(i){r=i;return}if(r===`overview`){let n=IO(e);if(n){t.push(n);return}}n[r].push(e)}),{meta:t,overview:MO(n.overview),keySkills:MO(n.keySkills),education:MO(n.education)}}function zO(e){let t=[...EO].sort((e,t)=>t.length-e.length),n=RegExp(`\\b(${t.map(AO).join(`|`)})\\b\\s*:?`,`gi`),r=[...e.matchAll(n)];if(!r.length)return{meta:[],overview:MO(FO(e)),keySkills:[],education:[]};let i={overview:[],keySkills:[],education:[]},a=e.slice(0,r[0].index).trim();return a&&i.overview.push(...FO(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=FO(e.slice(o,s).trim());if(!c.length)return;let l=OO.test(a)?`education`:kO.test(a)?`keySkills`:`overview`;i[l].push(...c)}),{meta:[],overview:MO(i.overview),keySkills:MO(i.keySkills),education:MO(i.education)}}function BO(e){let t=NO(e);if(!t)return{meta:[],overview:[],keySkills:[],education:[]};let n=PO(t);return n.length>=4?RO(n):zO(t)}function VO({items:e}){return(0,l.jsx)(`ul`,{className:`jdv-ats-bullets`,children:e.map((e,t)=>(0,l.jsx)(`li`,{className:`jdv-ats-bullet-item`,children:e},t))})}function HO({raw:e=``,meta:t=[]}){let[n,r]=(0,o.useState)(!1),i=(0,o.useMemo)(()=>BO(e),[e]),a=t.length?t:i.meta,s=[];if(i.overview.length&&s.push({key:`overview`,title:`Overview`,items:i.overview}),i.keySkills.length&&s.push({key:`keySkills`,title:`Key Skills`,items:i.keySkills,card:!0,icon:`🛠️`}),i.education.length&&s.push({key:`education`,title:`Education`,items:i.education,card:!0,icon:`🎓`}),!a.length&&!s.length)return(0,l.jsx)(wO,{type:`secondary`,children:`No description available.`});let c=n?s:s.slice(0,TO),u=s.length-TO;return(0,l.jsxs)(`div`,{className:`jdv-ats-desc`,children:[a.length>0&&(0,l.jsx)(`div`,{className:`jdv-ats-meta-grid`,children:a.map(({fieldKey:e,fieldLabel:t,value:n})=>(0,l.jsxs)(`div`,{className:`jdv-ats-meta-row`,children:[(0,l.jsx)(`span`,{className:`jdv-ats-meta-key`,children:t}),(0,l.jsx)(`span`,{className:`jdv-ats-meta-val`,children:n})]},e??t))}),(0,l.jsx)(`div`,{className:`jdv-ats-sections`,children:c.map(e=>e.card?(0,l.jsxs)(`div`,{className:`education-block`,children:[(0,l.jsxs)(`div`,{className:`education-header`,children:[(0,l.jsx)(`span`,{children:e.icon}),(0,l.jsx)(`span`,{children:e.title})]}),(0,l.jsx)(`ul`,{className:`education-list`,children:e.items.map((e,t)=>(0,l.jsx)(`li`,{className:`education-list-item`,children:e},t))})]},e.key):(0,l.jsxs)(`div`,{className:`jdv-ats-section`,children:[(0,l.jsx)(`div`,{className:`jdv-ats-section-hd`,children:(0,l.jsx)(`span`,{children:e.title})}),(0,l.jsx)(VO,{items:e.items})]},e.key))}),u>0&&(0,l.jsx)(`span`,{className:`jdv-desc-toggle`,onClick:()=>r(e=>!e),children:n?`Show less`:`Show more (${u} more section${u>1?`s`:``})`})]})}var{Text:UO}=s.Typography;function WO(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function GO(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 KO(e){return e?e.email??e.emailId??e.emailAddress??``:``}function qO(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function JO(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 YO=[`jobDescription`,`description`,`rawDescription`,`jobDescriptionText`];function XO(e){return String(e??``).toLowerCase()===`job`}function ZO(e){let t=YO.includes(e.field),n=/description/i.test(e.label??``);return t||n}function QO({record:e}){let t=GO(e),n=KO(e),r=qO(e);return!t&&!n?null:(0,l.jsxs)(`div`,{className:`preview-profile-card`,children:[(0,l.jsxs)(`div`,{className:`preview-profile-card__info`,children:[(0,l.jsx)(s.Avatar,{className:`preview-profile-card__avatar`,children:WO(t)}),(0,l.jsxs)(`div`,{className:`preview-profile-card__text`,children:[t&&(0,l.jsx)(`span`,{className:`preview-profile-card__name`,children:t}),n&&(0,l.jsx)(`span`,{className:`preview-profile-card__email`,children:n})]})]}),r&&(0,l.jsx)(s.Tag,{className:`preview-profile-card__status`,children:r})]})}function $O({fields:e,moduleName:t,centralDocuments:r=[]}){let[i,a]=(0,o.useState)([]),[s,c]=(0,o.useState)(0),[u,d]=(0,o.useState)(!1);if(!e?.length)return null;function f(e){let t=String(e?.type??``).trim().toLowerCase(),n=`${e?.field??``} ${e?.label??``}`;return[`file`,`document`,`upload`].includes(t)||/resume|cv|document|attachment/i.test(n)}function p(e,t){a(e),c(t),d(!0)}return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`preview-field-grid`,children:e.map(e=>{let i=e.value,a=Array.isArray(i)&&i.length>0,o=XO(t)&&ZO(e)&&typeof i==`string`&&i.trim(),s=f(e)?r.filter(t=>{let n=String(t?.fieldName??t?.field??t?.formField??t?.key??``).trim().toLowerCase(),r=String(e?.field??``).trim().toLowerCase();if(n&&r&&n===r)return!0;let i=`${e?.field??``} ${e?.label??``}`;return/resume|cv/i.test(i)?/resume|cv/i.test(`${n} ${t?.fileName??``} ${t?.name??``}`):!1}).map(t=>({name:t?.fileName||t?.name||t?.uploadedFileName||t?.originalName||e?.label||`Document`,url:t?.fileUrl||t?.downloadUrl||t?.signedUrl||t?.url||``,type:t?.mimeType||t?.contentType||t?.type})).filter(e=>e.url):[],c=f(e)?s.length?s:n.Bt(i).filter(e=>e.url):[];return c.length?(0,l.jsxs)(`div`,{className:`preview-field-card preview-field-card--documents`,children:[(0,l.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,l.jsx)(`div`,{className:`preview-document-list`,children:c.map((e,t)=>(0,l.jsxs)(`button`,{type:`button`,className:`preview-document-link`,onClick:()=>p(c,t),title:`Preview ${e.name||`document`}`,children:[(0,l.jsx)(`span`,{className:`preview-document-link__icon`,"aria-hidden":`true`,children:`▣`}),(0,l.jsx)(`span`,{className:`preview-document-link__name`,children:e.name||`Document ${t+1}`}),(0,l.jsx)(`span`,{className:`preview-document-link__action`,children:`Preview`})]},`${e.url}-${t}`))})]},e.field??e.label):a?i.map((t,n)=>(0,l.jsxs)(`div`,{className:`preview-field-card`,children:[(0,l.jsxs)(`span`,{className:`preview-field-card__label`,children:[e.label,i.length>1?` (${n+1})`:``]}),(0,l.jsx)(`span`,{className:`preview-field-card__value`,children:JO(t)})]},`${e.field??e.label}-${n}`)):o?(0,l.jsxs)(`div`,{className:`preview-field-card preview-field-card--description`,children:[(0,l.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,l.jsx)(`div`,{className:`preview-field-card__description`,children:(0,l.jsx)(HO,{raw:i})})]},e.field??e.label):(0,l.jsxs)(`div`,{className:`preview-field-card`,children:[(0,l.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,l.jsx)(`span`,{className:`preview-field-card__value`,children:JO(i)})]},e.field??e.label)})}),(0,l.jsx)(n.En,{documents:i,open:u,onClose:()=>d(!1),initialIndex:s})]})}function ek(){let e=(0,d.useNavigate)(),{moduleName:t=``,record:r=null}=(0,d.useLocation)().state??{},i=r?.id??r?._id,[c,u]=(0,o.useState)([]),[f,p]=(0,o.useState)(!!(t&&i)),[m,h]=(0,o.useState)(null),[g,_]=(0,o.useState)([]),[v,y]=(0,o.useState)(0),b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)([]),C=(0,o.useRef)([]);(0,o.useEffect)(()=>{if(!t||!i)return;let e=!1;return Promise.all([a.r({module:t,id:i}),n.yn(t,i).catch(()=>({data:[]}))]).then(([t,n])=>{e||(u(Array.isArray(t)?t:[]),_(Array.isArray(n)?n:n?.data??[]),p(!1))}).catch(t=>{e||(h(t.message||`Failed to load preview`),_([]),p(!1))}),()=>{e=!0}},[t,i]);function w(){e(-1)}function T(e,t){return e?.label??e?.name??`Section ${t+1}`}function E(e){let t=b.current,n=C.current[e];if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=(t.querySelector(`.preview-stepper-wrap`)?.offsetHeight??0)+12,o=t.scrollTop+i.top-r.top-a;y(e),t.scrollTo({top:Math.max(0,o),behavior:`smooth`})}function D(){let e=b.current;if(!e||!C.current.length)return;let t=e.getBoundingClientRect().top+(e.querySelector(`.preview-stepper-wrap`)?.offsetHeight??0)+24,n=0;C.current.forEach((e,r)=>{e&&e.getBoundingClientRect().top<=t&&(n=r)}),y(e=>e===n?e:n)}(0,o.useEffect)(()=>{let e=x.current,t=S.current[v];if(!e||!t)return;let n=t.offsetLeft-(e.clientWidth-t.offsetWidth)/2,r=Math.max(0,e.scrollWidth-e.clientWidth);e.scrollTo({left:Math.min(Math.max(0,n),r),behavior:`smooth`})},[v,c.length]);function O(){return c.length?(0,l.jsx)(`div`,{ref:x,className:`preview-stepper-wrap`,"aria-label":`Preview sections`,children:(0,l.jsx)(`div`,{className:`preview-stepper`,children:c.map((e,t)=>(0,l.jsxs)(`div`,{className:`preview-stepper__segment`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`preview-stepper__item`,ref:e=>{S.current[t]=e},onClick:()=>E(t),"aria-current":v===t?`step`:void 0,title:`Go to ${T(e,t)}`,children:[(0,l.jsx)(`span`,{className:[`preview-stepper__circle`,t<v?`preview-stepper__circle--done`:``,t===v?`preview-stepper__circle--active`:``].filter(Boolean).join(` `),children:t+1}),(0,l.jsx)(`span`,{className:[`preview-stepper__label`,t===v?`preview-stepper__label--active`:``].filter(Boolean).join(` `),children:T(e,t)})]}),t<c.length-1&&(0,l.jsx)(`span`,{className:[`preview-stepper__line`,t<v?`preview-stepper__line--done`:``].filter(Boolean).join(` `),"aria-hidden":`true`})]},e.name??e.id??t))})}):null}let k=(0,l.jsxs)(`div`,{className:`preview-modal-header`,children:[(0,l.jsx)(`span`,{className:`preview-modal-module`,children:t.toUpperCase()}),(0,l.jsx)(`span`,{className:`preview-modal-title`,children:t?` Details`:`Preview`})]}),A=(0,l.jsx)(`div`,{className:`wizard-footer preview-scroll-footer`,children:(0,l.jsx)(`div`,{className:`wizard-footer-nav`,children:(0,l.jsx)(s.Button,{onClick:w,children:`Close`})})});function j(){return!t||!i?(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`Preview id is missing.`}):f?(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:(0,l.jsx)(s.Spin,{size:`small`})}):m?(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status job-preview-error`,children:m}):c.length?(0,l.jsx)(`div`,{className:`preview-section-list`,children:c.map((e,n)=>(0,l.jsxs)(`section`,{ref:e=>{C.current[n]=e},className:`preview-section-card`,"data-section-index":n,children:[(0,l.jsxs)(`div`,{className:`preview-section-card__header`,children:[(0,l.jsx)(`span`,{className:`preview-section-card__number`,children:n+1}),(0,l.jsx)(`span`,{className:`preview-section-card__title`,children:T(e,n)})]}),(0,l.jsx)(`div`,{className:`preview-section-card__body`,children:e.fields?.length>0?(0,l.jsx)($O,{fields:e.fields,moduleName:t,centralDocuments:g}):(0,l.jsx)(UO,{type:`secondary`,children:`No fields in this group.`})})]},e.name??e.id??n))}):(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`No form groups found.`})}return(0,l.jsx)(s.Modal,{centered:!0,className:`wizard-modal preview-modal preview-scroll-modal`,footer:A,open:!0,title:k,width:`min(900px, calc(100vw - 32px))`,onCancel:w,maskClosable:!1,children:(0,l.jsxs)(`div`,{ref:b,className:`wizard-body preview-scroll-body`,onScroll:D,children:[!f&&!m&&c.length>0&&O(),r&&(0,l.jsx)(QO,{record:r}),j()]})})}var{Text:tk}=s.Typography,{TextArea:nk}=s.Input,rk=[{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 ik(e){switch(e.type){case`select`:return(0,l.jsx)(s.Select,{placeholder:e.placeholder,options:e.options,style:{width:`100%`}});case`textarea`:return(0,l.jsx)(nk,{rows:3,placeholder:e.placeholder});case`number`:return(0,l.jsx)(s.InputNumber,{placeholder:e.placeholder,style:{width:`100%`}});default:return(0,l.jsx)(s.Input,{type:e.inputType||`text`,placeholder:e.placeholder})}}function ak({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,l.jsxs)(`div`,{className:`wizard-review-content`,children:[r.map(e=>(0,l.jsxs)(`div`,{className:`wizard-review-section`,children:[(0,l.jsx)(tk,{className:`wizard-review-section-title`,children:e.title}),(0,l.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,l.jsxs)(`div`,{className:`wizard-review-row`,children:[(0,l.jsx)(`span`,{className:`wizard-review-label`,children:e.label}),(0,l.jsx)(`span`,{className:`wizard-review-separator`,children:`:`}),(0,l.jsx)(`span`,{className:`wizard-review-value`,children:r})]},e.name)})})]},e.key)),(0,l.jsxs)(`div`,{className:`wizard-review-confirm-note`,children:[(0,l.jsx)(c.CheckCircleOutlined,{className:`wizard-review-confirm-icon`}),(0,l.jsx)(tk,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,l.jsx)(`div`,{className:`wizard-review-empty`,children:(0,l.jsx)(tk,{type:`secondary`,children:`No data entered yet.`})})}function ok(){let[e]=s.Form.useForm(),t=(0,d.useNavigate)(),{title:n=`Wizard`,moduleName:r=``,steps:i=rk,onSubmit:a}=(0,d.useLocation)().state??{},[c,u]=(0,o.useState)(0),f=i[c],p=c===i.length-1,m=c===0;function h(){t(-1)}function g(){let t=(f.fields||[]).map(e=>e.name);e.validateFields(t.length>0?t:void 0).then(()=>{u(e=>e+1)})}function _(){u(e=>e-1)}function v(){let n=e.getFieldsValue();typeof a==`function`&&a(n),t(-1)}let y=i.map((e,t)=>({title:e.title,description:e.description,status:t<c?`finish`:t===c?`process`:`wait`})),b=r?`${n} — ${r}`:n;return(0,l.jsxs)(s.Modal,{open:!0,title:b,footer:(0,l.jsxs)(`div`,{className:`wizard-footer`,children:[(0,l.jsx)(s.Button,{onClick:h,children:`Cancel`}),(0,l.jsxs)(`div`,{className:`wizard-footer-nav`,children:[!m&&(0,l.jsx)(s.Button,{onClick:_,children:`Back`}),p?(0,l.jsx)(s.Button,{type:`primary`,onClick:v,children:`Submit`}):(0,l.jsx)(s.Button,{type:`primary`,onClick:g,children:`Next`})]})]}),onCancel:h,width:`min(680px, calc(100vw - 32px))`,centered:!0,className:`wizard-modal`,children:[(0,l.jsx)(`div`,{className:`wizard-steps-container`,children:(0,l.jsx)(s.Steps,{current:c,items:y,size:`small`,className:`wizard-steps`})}),(0,l.jsx)(`div`,{className:`wizard-body`,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,children:[i.filter(e=>!e.isReview).map((e,t)=>(0,l.jsx)(`div`,{style:{display:t===c?`block`:`none`},children:(0,l.jsx)(s.Row,{gutter:16,children:(e.fields||[]).map(e=>(0,l.jsx)(s.Col,{span:e.span||24,children:(0,l.jsx)(s.Form.Item,{name:e.name,label:e.label,rules:[...e.required?[{required:!0,message:`${e.label} is required`}]:[],...e.rules||[]],children:ik(e)})},e.name))})},e.key)),f.isReview&&(0,l.jsx)(ak,{steps:i,form:e})]})})]})}function sk({titleText:e,titleIcon:t}){let n=t===`delete`;return(0,l.jsxs)(`span`,{className:`dynamic-popup__header`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__header-icon-box${n?` dynamic-popup__header-icon-box--danger`:``}`,children:n?(0,l.jsx)(c.DeleteOutlined,{}):(0,l.jsx)(c.AppstoreOutlined,{})}),(0,l.jsx)(`span`,{className:`dynamic-popup__header-label`,children:e})]})}function ck({note:e,description:t,showSelectedCount:r,count:i,itemLabel:a,bodyText:o,deleteError:s}){return(0,l.jsxs)(l.Fragment,{children:[e&&(0,l.jsx)(n.kn,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:e}),t&&(0,l.jsx)(n.kn,{variant:`body`,className:`dynamic-popup__description`,children:t}),r&&i>0&&(0,l.jsxs)(n.kn,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,l.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),o&&(0,l.jsx)(n.kn,{variant:`body`,children:o}),s&&(0,l.jsx)(n.kn,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:s})]})}function lk({footerNote:e}){return e?(0,l.jsx)(n.kn,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:e}):null}function uk(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function dk(e){return String(e).replace(/\(\s*\)/g,``).replace(/\s+/g,` `).replace(/(^|\s)([-–—·|])(?=\s*\2)/g,``).replace(/^[\s\-–—·|]+/,``).replace(/[\s\-–—·|]+$/,``).trim()}function fk(e){if(!e)return!1;let t=new Date(e).getTime();return Number.isNaN(t)||t<=0?!1:t<=Date.now()+864e5}function pk(e){if(!fk(e))return``;let t=new Date(e),n=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date,i=Math.round((n(r)-n(t))/864e5);if(i<=0)return`Today`;if(i===1)return`Yesterday`;if(i<=30)return`${i} days ago`;let a=(r.getFullYear()-t.getFullYear())*12+(r.getMonth()-t.getMonth());if(r.getDate()<t.getDate()&&--a,a=Math.max(1,a),a<12)return`${a} month${a===1?``:`s`} ago`;let o=Math.floor(a/12);return`${o} year${o===1?``:`s`} ago`}function mk(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 hk(e){let t=Array.isArray(e?.submissionHistory)?e.submissionHistory:[],n=[e?.lastSubmittedAt,e?.submittedAt,...t.map(e=>e?.submittedAt)].filter(Boolean);return n.length?n.reduce((e,t)=>new Date(t)>new Date(e)?t:e):null}function gk(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:pk(mk(e))}:e,o=(i?dk(uk(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};if(c&&(u.disabled=!0),l&&(u.title=l),e?.isSubmitted===!0||e?.alreadySubmitted===!0){u.alreadySubmitted=!0,u.existingSubmissionId=String(e?.existingSubmissionId??e?.jobSubmissionId??e?.submissionId??``);let t=e?.submittedAt||hk(e);t&&(u.submittedAt=t)}if(e?.isFromSubmission===!0&&e?.submissionId){u.isFromSubmission=!0,u.priorSubmissionId=String(e.submissionId);let t=e?.lastSubmittedAt||hk(e);t&&(u.priorSubmittedAt=t)}return u}function _k(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>gk(t,e))}function vk(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var yk=`DD MMM YYYY`,bk=`DD MMM YYYY, h:mm A`;function xk(e,t){if(e==null||e===``)return``;let n=(0,u.default)(e);return n.isValid()?t===`relative`?pk(e)||(fk(e)?n.format(yk):`Not updated`):fk(e)?n.format(yk):``:String(e)}function Sk(e,t){return e?String(e).includes(`{`)?dk(uk(e,t)):String(t?.[e]??e).trim():``}function Ck(e){if(e?.alreadySubmitted){let t=e?.submittedAt?(0,u.default)(e.submittedAt):null;return{tone:`blocked`,tooltip:t?.isValid()?`Already submitted to this job on ${t.format(bk)}`:`Already submitted to this job — a candidate can only be submitted once per job`}}if(e?.isFromSubmission){let t=e?.priorSubmittedAt?(0,u.default)(e.priorSubmittedAt):null;return{tone:`history`,tooltip:t?.isValid()?`Previously submitted on ${t.format(bk)} — this form will prefill from it`:`Submitted to another job before — this form will prefill from it`}}return null}function wk(e,t){return e?.alreadySubmitted||!e?.disabled?``:String(t?.message??e?.title??``).trim()}function Tk({meta:e}){return(0,l.jsx)(`div`,{className:`dynamic-popup__option-dates`,children:e.map(e=>(0,l.jsxs)(o.Fragment,{children:[(0,l.jsx)(`span`,{className:`dynamic-popup__option-date-label`,children:e.label}),(0,l.jsx)(`span`,{className:`dynamic-popup__option-date-value`,children:e.text})]},e.label))})}function Ek({option:e,layout:t}){let n=e?._raw??e??{},r=Sk(t.id,n),i=Sk(t.title,n)||String(e?.label??``),a=Sk(t.subtitle,n),o=Sk(t.titleAccent?.key,n),u=Sk(t.titleAccent?.toneKey,n),d=t.titleAccent?.prefix??``,f=(t.meta??[]).map(e=>({label:e.label,text:xk(n?.[e.key],e.type)})).filter(e=>e.text),p=wk(e,n),m=Ck(e);return(0,l.jsxs)(`div`,{className:`dynamic-popup__option`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__option-tick${m?` dynamic-popup__option-tick--${m.tone}`:``}`,children:m&&(0,l.jsx)(s.Tooltip,{title:m.tooltip,placement:`topLeft`,children:(0,l.jsx)(c.CheckCircleFilled,{"aria-label":m.tooltip})})}),(0,l.jsxs)(`div`,{className:`dynamic-popup__option-main`,children:[(0,l.jsxs)(`div`,{className:`dynamic-popup__option-head`,children:[r&&(0,l.jsx)(`span`,{className:`dynamic-popup__option-id`,children:r}),(0,l.jsxs)(`span`,{className:`dynamic-popup__option-title`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__option-title-text`,children:i}),o&&(0,l.jsx)(`span`,{className:`dynamic-popup__option-title-accent${u?` dynamic-popup__option-title-accent--${u}`:``}`,children:`${d}${o}`})]}),p&&(0,l.jsx)(`span`,{className:`dynamic-popup__option-flag`,children:p})]}),a&&(0,l.jsx)(`div`,{className:`dynamic-popup__option-sub`,children:a})]}),e?.alreadySubmitted?(0,l.jsx)(`span`,{className:`dynamic-popup__option-onjob`,children:`On this job`}):f.length>0&&(0,l.jsx)(Tk,{meta:f})]})}var{Text:Dk}=s.Typography,{TextArea:Ok}=s.Input,kk=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],Ak=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function jk(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 Mk({field:e,value:t,onChange:n}){return(0,l.jsx)(s.Input,{value:t,onChange:n,placeholder:e.placeholder,maxLength:e.maxLength,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function Nk({field:e,value:t,onChange:n}){return(0,l.jsx)(Ok,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder,maxLength:e.maxLength,showCount:!!e.maxLength})}function Pk({field:e,options:t,value:n,onChange:r}){let i=jk(t);return(0,l.jsx)(s.Select,{showSearch:!0,value:n,onChange:r,options:i,placeholder:e.placeholder,className:`dynamic-popup__field-select`,optionFilterProp:`label`,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function Fk({field:e,options:t,value:n,onChange:r}){let i=jk(t);return(0,l.jsx)(s.Select,{mode:`multiple`,showSearch:!0,value:n,onChange:r,options:i,placeholder:e.placeholder,className:`dynamic-popup__field-select`,optionFilterProp:`label`,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function Ik({field:e,options:t,onSearch:n,value:r,onChange:i,popupContext:a}){let o=jk(t),u=e.optionLayout,d=new Map(o.map(e=>[String(e?.value??``),e]));async function f(t,n){if(e.multiple){i?.(Array.isArray(t)?t:[]);return}let r=n??d.get(String(t??``));(typeof e.onSelectGuard!=`function`||await e.onSelectGuard({value:t,option:r,field:e,popupContext:a,confirm:s.Modal.confirm})!==!1)&&i?.(t)}return(0,l.jsx)(s.Select,{mode:e.multiple?`multiple`:void 0,showSearch:!0,filterOption:!1,notFoundContent:e.notFoundContent??null,value:r,onChange:f,options:o,placeholder:e.placeholder,onSearch:n,className:`dynamic-popup__field-select${u?` dynamic-popup__field-select--rich`:``}`,popupClassName:u?`dynamic-popup__option-dropdown`:void 0,listHeight:u?340:void 0,optionLabelProp:`label`,optionRender:u?e=>(0,l.jsx)(Ek,{option:e?.data??e,layout:u}):void 0,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function Lk({field:e,mentionOpts:t,onMentionSearch:n,value:r,onChange:i}){let a=Number(e.maxLength)>0?Number(e.maxLength):void 0,o=String(r??``).length;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Mentions,{value:r,onChange:i,rows:e.rows??5,placeholder:e.placeholder,prefix:`@`,options:t,onSearch:n,maxLength:a,className:`dynamic-popup__mention-textarea`}),a?(0,l.jsxs)(`div`,{className:`dynamic-popup__char-count`,style:{textAlign:`right`,fontSize:12,marginTop:4,color:o>a*.9?`#b45309`:`#8c8c8c`},children:[o,` / `,a]}):null]})}function Rk({field:e={},value:t={},onChange:n}){let r=t.period??`Hourly`,i=t.isRange??!1;function a(e){n?.({...t,...e})}(0,o.useEffect)(()=>{let e={};t.currency??(e.currency=`$`),t.period??(e.period=`Hourly`),Object.keys(e).length&&n?.({...t,...e})},[]);let c=Number(i?t.maxAmount:t.amount),u=i&&t.minAmount!=null&&t.maxAmount!=null&&Number(t.maxAmount)<=Number(t.minAmount),d=e.rateCeiling!=null&&Number.isFinite(c)&&c>Number(e.rateCeiling);return(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(s.Space.Compact,{style:{width:`100%`},children:[i?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.InputNumber,{controls:!1,placeholder:`From`,value:t.minAmount,onChange:e=>a({minAmount:e}),style:{flex:1}}),(0,l.jsx)(s.InputNumber,{controls:!1,placeholder:`To`,value:t.maxAmount,onChange:e=>a({maxAmount:e}),style:{flex:1}})]}):(0,l.jsx)(s.InputNumber,{controls:!1,placeholder:`0`,value:t.amount,onChange:e=>a({amount:e}),style:{flex:2}}),(0,l.jsx)(s.Select,{value:t.currency??`$`,options:kk,onChange:e=>a({currency:e}),style:{width:80}}),(0,l.jsx)(s.Select,{value:r,options:Ak,onChange:e=>a({period:e}),style:{width:110}})]}),(u||d)&&(0,l.jsxs)(`div`,{style:{marginTop:4},children:[u&&(0,l.jsx)(Dk,{type:`danger`,style:{fontSize:12,display:`block`},children:`To rate must be greater than From rate.`}),d&&(0,l.jsxs)(Dk,{type:`danger`,style:{fontSize:12,display:`block`},children:[`Rate must not exceed the client rate (`,e.rateCeiling,`).`]})]}),(0,l.jsxs)(s.Space,{size:`small`,style:{marginTop:8},children:[(0,l.jsx)(s.Switch,{checked:i,onChange:e=>a({isRange:e})}),(0,l.jsx)(`span`,{children:`Range`})]})]})}function zk({field:e,value:t,onChange:n}){return(0,l.jsx)(s.DatePicker,{value:t,onChange:n,placeholder:e.placeholder??`Select date`,style:{width:`100%`},format:`YYYY-MM-DD`})}function Bk({field:e,checked:t,onChange:n}){return(0,l.jsx)(s.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function Vk({field:e,value:t,onChange:n}){return(0,l.jsx)(s.InputNumber,{value:t,onChange:n,min:e.min,max:e.max,placeholder:e.placeholder,style:{width:`100%`}})}function Hk({options:e,value:t,onChange:n}){return(0,l.jsx)(s.Radio.Group,{value:t,onChange:n,options:e})}var Uk={input:Mk,text:Mk,textarea:Nk,select:Pk,"multi-select":Fk,"search-select":Ik,"mention-textarea":Lk,"candidate-rate":Rk,"priority-checkbox":Bk,"date-picker":zk,number:Vk,radio:Hk};function Wk(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}var Gk=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function Kk({form:e,fields:t,initialValues:r,dynamicOptions:i,popupContext:a,extraData:o,removedIds:c,setRemovedIds:u,showAlreadyAssigned:d,onValuesChange:f,getSearchHandler:p,getMentionSearchHandler:m,mentionOptions:h}){let g=(o?.recruitersData??[]).filter(e=>{let t=String(e?.user_id??e?.id??e?.userId??``);return t&&!c.includes(t)}),_=d&&o,v=new Set(d?g.map(e=>String(e?.user_id??e?.id??e?.userId??``).trim()).filter(Boolean):[]),y=e=>v.size===0||!Array.isArray(e)?e:e.filter(e=>!v.has(String((e&&typeof e==`object`?e.value??e.id:e)??``).trim()));return!t.length&&!_?null:(0,l.jsxs)(l.Fragment,{children:[_&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`dynamic-popup__already-assigned`,children:[(0,l.jsx)(n.kn,{variant:`caption`,color:`secondary`,children:`Already Assigned People`}),(0,l.jsx)(`div`,{style:{marginTop:6,display:`flex`,flexWrap:`wrap`,gap:6},children:g.length===0?(0,l.jsx)(n.kn,{variant:`caption`,color:`secondary`,children:`No one is currently assigned to this job.`}):g.map(e=>{let t=String(e?.user_id??e?.id??e?.userId??``),n=e?.name??e?.user_name??e?.userName??e?.email??`Assigned user`;return(0,l.jsx)(s.Tag,{closable:!0,onClose:()=>{t&&u(e=>Array.from(new Set([...e,t])))},children:n},t||n)})})]}),(0,l.jsx)(s.Divider,{style:{margin:`12px 0`}})]}),t.length>0&&(0,l.jsx)(s.Form,{form:e,layout:`vertical`,initialValues:r,onValuesChange:(e,t)=>f(t),children:qk(t).map(e=>Jk(e,e=>{let t=y(i[e.name]??_k(e,a)),r=p(e),o=m(e),c=h[e.name]??[],u=Wk(e.type),d=Uk[e.type],f=[];return e.required&&f.push({required:!0,message:`${e.label||`This field`} is required`}),typeof e.validator==`function`&&f.push({validator:(t,n)=>{let r=e.validator(n,a);return r?Promise.reject(Error(r)):Promise.resolve()}}),Gk.has(e.type)&&f.push(n.cn({label:e.label,field:e.name,type:e.type,maxLength:e.maxLength})),(0,l.jsx)(s.Form.Item,{name:e.name,label:e.label,rules:f,...u,children:d?(0,l.jsx)(d,{field:e,options:t,onSearch:r,mentionOpts:c,onMentionSearch:o,popupContext:a}):null},e.name)}))})]})}function qk(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 Jk(e,t){return e.length===1?t(e[0]):(0,l.jsx)(`div`,{style:{display:`flex`,gap:8,alignItems:`flex-start`},children:e.map((e,n)=>(0,l.jsx)(`div`,{style:{flex:n===0?2:1,minWidth:0},children:t(e)},e.name))},`row-${e.map(e=>e.name).join(`-`)}`)}function Yk(e){return[`select`,`multi-select`,`search-select`,`radio`].includes(e?.type)&&e?.dataSource===`master`&&e?.masterName}function Xk(e){let t=e?.data??e;return Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.items)?t.items:Array.isArray(t?.rows)?t.rows:Array.isArray(t?.records)?t.records:[]}function Zk(e){let t=String(e?.masterName??``).trim().toLowerCase();return t===`clientsubmissions`||t===`clientsubmissionstatus`}function Qk(e){if(e==null)return null;if(typeof e==`string`){let t=e.trim();return t?{label:t,value:t,_raw:{name:t}}:null}let t=String(e?.name??e?.clientSubmissionStatusText??e?.label??e?.text??``).trim();if(!t)return null;let n=Number(e?.id??e?.uniqueId??e?.clientSubmissionStatusId??e?.value??0)||0;return{label:t,value:t,_raw:{...e,...n>0?{id:n,uniqueId:n}:{},name:t,type:String(e?.type??e?.clientSubmissionStatusType??``).trim(),isInitialStatus:e?.isInitialStatus===!0,isTerminalStatus:e?.isTerminalStatus===!0,allowedNextStatusIds:Array.isArray(e?.allowedNextStatusIds)?e.allowedNextStatusIds.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}}}function $k(e,t){return Zk(t)?Qk(e):gk(e,t)}function eA(e){let t=e?.clientSubmissionStatus,n=Number((t&&typeof t==`object`?t?.clientSubmissionStatusId??t?.id??t?.uniqueId:void 0)??e?.clientSubmissionStatusId??e?.clientStatusId??e?.[`clientSubmissionStatus.clientSubmissionStatusId`]??0)||0,r=t&&typeof t==`object`?t?.clientSubmissionStatusText??t?.name??t?.text??t?.label:t;return{id:n,text:String(r??e?.clientSubmissionStatusText??e?.clientStatus??e?.clientStatusText??e?.[`clientSubmissionStatus.clientSubmissionStatusText`]??``).trim()}}function tA(e){let t=Number(e?.id??0)||0,n=String(e?.text??``).trim();return n&&n.toLowerCase()===`not submitted`?!0:t<=0&&!n}function nA(e){return Number(e?._raw?.id??e?._raw?.uniqueId??0)||0}function rA(e){let t=e?._raw?.allowedNextStatusIds;return Array.isArray(t)?t.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}function iA(e){let t=e?.data??e;return t?Array.isArray(t)?t[0]??null:t?.record&&typeof t.record==`object`?t.record:t?.data&&typeof t.data==`object`&&!Array.isArray(t.data)?t.data:typeof t==`object`?t:null:null}function aA(e){return(Array.isArray(e?.selectedRecords)?e.selectedRecords.filter(Boolean):[]).some(e=>!tA(eA(e)))?!0:!tA(eA(e??{}))}async function oA(e,n){if(aA(e))return e;let r=e?.selectedIds?.[0]??e?.selectedRecords?.[0]?._id??e?.selectedRecords?.[0]?.id;if(!r)return e;let i=String(e?.moduleName??`submissions`).trim()||`submissions`,a=new URLSearchParams({module:i,id:String(r)});n&&a.set(`app_id`,n);try{let r=iA(await t.o(t.x,`/module-data-detail?${a.toString()}`,{headers:n?{"X-App-Id":n}:void 0}));if(!r)return e;let i=Array.isArray(e?.selectedRecords)?e.selectedRecords:[];return{...e,selectedRecords:i.length?i.map((e,t)=>t===0?{...e,...r}:e):[r]}}catch(t){return console.warn(`[DynamicPopup] Could not load selected submission detail for client status transition:`,t),e}}function sA(e,t){if(!Array.isArray(e)||!e.length)return[];if(!e.some(e=>e?._raw?.isInitialStatus===!0||e?._raw?.isTerminalStatus===!0||Array.isArray(e?._raw?.allowedNextStatusIds)))return e;let n=Array.isArray(t?.selectedRecords)?t.selectedRecords.filter(Boolean):[],r={clientSubmissionStatus:t?.clientSubmissionStatus,clientSubmissionStatusId:t?.clientSubmissionStatusId,clientSubmissionStatusText:t?.clientSubmissionStatusText,clientStatus:t?.clientStatus,clientStatusId:t?.clientStatusId,clientStatusText:t?.clientStatusText,"clientSubmissionStatus.clientSubmissionStatusId":t?.[`clientSubmissionStatus.clientSubmissionStatusId`],"clientSubmissionStatus.clientSubmissionStatusText":t?.[`clientSubmissionStatus.clientSubmissionStatusText`]},i=n.length?n:[r];return e.filter(t=>i.every(n=>{let i=eA(n);if(tA(i)){let e=eA(r);tA(e)||(i=e)}if(tA(i))return t?._raw?.isInitialStatus===!0;let a=e.find(e=>{let t=nA(e),n=String(e?.label??``).trim();return i.id>0&&t===i.id||i.text&&n.toLowerCase()===i.text.toLowerCase()});return!a||a?._raw?.isTerminalStatus===!0?!1:rA(a).includes(nA(t))}))}function cA({open:e,config:n,api:r,fields:i,popupContext:a,formValues:s}){let[c,l]=(0,o.useState)({}),[u,d]=(0,o.useState)(null);return(0,o.useEffect)(()=>{e||(l({}),d(null))},[e]),(0,o.useEffect)(()=>{if(!e||!n||!r.getOptions)return;let t=new AbortController;return i.forEach(e=>{!e.fetchOptionsKey||e.fetchOptionsParamKey||Promise.resolve(r.getOptions(e,void 0,a)).then(n=>{t.signal.aborted||l(t=>({...t,[e.name]:n}))}).catch(n=>{t.signal.aborted||console.error(`[DynamicPopup] Failed to load options for field "${e.name}":`,n)})}),()=>t.abort()},[e,r,n,i,a]),(0,o.useEffect)(()=>{if(!e||!n)return;let r=i.filter(Yk);if(!r.length)return;let o=new AbortController;return r.forEach(e=>{let n=new URLSearchParams({masterName:e.masterName,offset:`0`,limit:String(e.limit??50)}),r=String(t.b??``).trim();r&&n.set(`app_id`,r),t.o(t.x,`/masters/dropdown?${n.toString()}`,{headers:r?{"X-App-Id":r}:void 0}).then(async t=>{if(o.signal.aborted)return;let n=Xk(t).map(t=>$k(t,e)).filter(Boolean),i=a;if(Zk(e)&&(i=await oA(a,r)),o.signal.aborted)return;let s=Zk(e)?sA(n,i):n;l(t=>({...t,[e.name]:s}))}).catch(t=>{o.signal.aborted||console.error(`[DynamicPopup] Failed to load master options for field "${e.name}":`,t)})}),()=>o.abort()},[e,n,i,a]),(0,o.useEffect)(()=>{if(!e||!n||!r.getOptions)return;let t=i.filter(e=>e.fetchOptionsKey&&e.fetchOptionsParamKey);if(!t.length)return;let o=new AbortController;return t.forEach(e=>{let t=s[e.fetchOptionsParamKey]??a[e.fetchOptionsParamKey],n={[e.fetchOptionsParamKey]:t};Promise.resolve(r.getOptions(e,n,a)).then(t=>{o.signal.aborted||l(n=>({...n,[e.name]:t}))}).catch(t=>{o.signal.aborted||console.error(`[DynamicPopup] Failed to load param-dependent options for "${e.name}":`,t)})}),()=>o.abort()},[e,r,n,i,s,a]),(0,o.useEffect)(()=>{if(!e||!n||!r.loadExtraData)return;let t=new AbortController;return Promise.resolve(r.loadExtraData(a)).then(e=>{t.signal.aborted||d(e)}).catch(e=>{t.signal.aborted||(console.error(`[DynamicPopup] Failed to load extra data:`,e),d(null))}),()=>t.abort()},[e,r,n,a]),{dynamicOptions:c,setDynamicOptions:l,extraData:u}}var lA=500,uA=3;function dA({api:e,open:t,fields:n=[],popupContext:r,setDynamicOptions:i}){let[a,s]=(0,o.useState)({}),c=(0,o.useRef)({}),l=(0,o.useRef)({}),u=(0,o.useRef)({}),d=(0,o.useCallback)((t,n)=>{let a=e.searchOptions??e.searchFetcher;if(typeof a!=`function`)return;l.current[t.name]?.abort();let o=new AbortController;return l.current[t.name]=o,Promise.resolve(a(t,n,r)).then(e=>{if(o.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];i(e=>({...e,[t.name]:n.map(e=>gk(e,t))}))}).catch(e=>{o.signal.aborted||console.error(`[DynamicPopup] Search failed for field "${t.name}":`,e)}),o},[e,r,i]),f=n.filter(e=>(e.searchFetchKey||e.searchFetcher)&&e.preloadOptions!==!1),p=f.map(e=>e.name).join(`|`),m=(0,o.useRef)({runSearch:d,preloadFields:f});(0,o.useEffect)(()=>{m.current={runSearch:d,preloadFields:f}}),(0,o.useEffect)(()=>{if(!t||!p)return;let{runSearch:e,preloadFields:n}=m.current,r=n.map(t=>e(t,``)).filter(Boolean);return()=>r.forEach(e=>e.abort())},[t,p]);function h(t){if(!t.searchFetchKey&&!t.searchFetcher||typeof(e.searchOptions??e.searchFetcher)!=`function`)return;let n=t.searchMinLength??uA;return e=>{clearTimeout(c.current[t.name]);let r=e.length<n?``:e;c.current[t.name]=setTimeout(()=>{d(t,r)},lA)}}function g(t){let n=e.getMentionOptions??e.mentionFetcher;if(typeof n==`function`)return e=>{u.current[t.name]?.abort();let i=new AbortController;u.current[t.name]=i,Promise.resolve(n(t,e,r)).then(e=>{if(i.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];s(e=>({...e,[t.name]:n.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 "${t.name}":`,e)})}}return{mentionOptions:a,getSearchHandler:h,getMentionSearchHandler:g}}function fA({form:e,config:t,api:n,popupContext:r,resolvedIds:i,dynamicOptions:a,extraData:c,removedIds:l,removalOnlySubmit:u=!1,fields:d,onClose:f,onSubmit:p}){let[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(null);async function v(e){let t={resolvedIds:i,dynamicOptions:a,extraData:c,removedIds:l};if(typeof n.submit==`function`)return n.submit(e,r,t);if(typeof p==`function`)return p(e,r,t)}function y(){if(t){if(!d.length){if(t.mode===`delete`&&typeof n.deleteItems==`function`){h(!0),_(null),Promise.resolve(n.deleteItems(i,r)).then(()=>{s.message.success(t.successMessage||`Deleted successfully`),f({success:!0})}).catch(e=>{let t=e?.message||`Delete failed. Please try again.`;_(t),h(!1),s.message.error(t)});return}if(typeof n.onOk==`function`){h(!0),Promise.resolve(n.onOk(r)).then(()=>f({success:!0})).catch(e=>{let t=e?.message||`Failed. Please try again.`;s.message.error(t),h(!1)});return}if(typeof n.submit==`function`){h(!0),Promise.resolve(v({})).then(e=>{e?.cancelled||e?.navigated||(s.message.success(t.successMessage||`Saved successfully`),f({success:!0}))}).catch(e=>{s.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>h(!1));return}f();return}if(u){h(!0),Promise.resolve(v(e.getFieldsValue())).then(e=>{e?.cancelled||e?.navigated||(s.message.success(t.successMessage||`Saved successfully`),f({success:!0}))}).catch(e=>{s.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>h(!1));return}e.validateFields().then(async e=>{h(!0);try{let n=await v(e);if(n?.cancelled||n?.navigated)return;s.message.success(t.successMessage||`Saved successfully`),f({success:!0})}catch(e){s.message.error(e?.message||`Failed. Please try again.`)}finally{h(!1)}}).catch(()=>{})}}function b(){h(!1),_(null)}return{handleOk:y,confirming:m,deleteError:g,resetSubmitState:b}}function pA({open:e=!0,config:t,context:n={},onClose:r,onSubmit:i,api:a={}}){let[c]=s.Form.useForm(),[d,f]=(0,o.useState)({}),[p,m]=(0,o.useState)([]),h=s.Form.useWatch([],c,{preserve:!0})??{},g=(0,o.useMemo)(()=>vk(n),[n]),{selectedIds:_=[],selectedRecords:v=[],moduleName:y=``}=g,b=(0,o.useMemo)(()=>_.map((e,t)=>{let n=v[t];return n?.id??n?._id??e}),[_,v]),x=(0,o.useMemo)(()=>t?typeof t.getFields==`function`?t.getFields(g):t.fields??[]:[],[t,g]),S=(0,o.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,u.default)(n):n)}),e},[x,g]),{dynamicOptions:C,setDynamicOptions:w,extraData:T}=cA({open:e,config:t,api:a,fields:x,popupContext:g,formValues:d}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=dA({api:a,open:e,fields:x,popupContext:g,setDynamicOptions:w});function k(e){typeof r==`function`&&r(e)}let A=x.filter(e=>e.required),j=A.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)}),M=(g.removedIds??[]).length,N=p.length>M,P=A.some(e=>{let t=h[e.name];return!(t==null||t===``||Array.isArray(t)&&t.length===0)}),{handleOk:F,confirming:I,deleteError:L,resetSubmitState:R}=fA({form:c,config:t,api:a,popupContext:g,resolvedIds:b,dynamicOptions:C,extraData:T,removedIds:p,removalOnlySubmit:!!t?.allowRemovalOnlySubmit&&N&&!P,fields:x,onClose:k,onSubmit:i});(0,o.useEffect)(()=>{e&&(c.resetFields(),f(S??{}),m(g.removedIds??[]),R())},[e,S]);let z=!!t?.autoSubmitWhenNoFields&&x.length===0;(0,o.useEffect)(()=>{!e||!z||F()},[e,z]);let B=_.length,V=String(y).replace(/s$/i,``),H=B===1?V:y,ee=v[0]??{},U=t?.getTitleText?t.getTitleText(B,H,ee,g):t?.title,te=B===1?ee.jobTitle??ee.title??ee.name??ee.fullName??ee.candidateName??null:null,ne=t?.getBodyText?t.getBodyText(B,V,H,te,g):t?.bodyText??null,re=typeof t?.getNote==`function`?t.getNote(g):t?.note,ie=t?.disabledUntilFilled&&!j&&!N;if(!t||!e||z)return null;let ae=t.component;return ae?(0,l.jsx)(s.Modal,{open:e,title:t.title||t.getTitleText?(0,l.jsx)(sk,{titleText:U,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,l.jsx)(ae,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:k})}):(0,l.jsxs)(s.Modal,{open:e,title:(0,l.jsx)(sk,{titleText:U,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:F,onCancel:()=>k(),okButtonProps:{danger:t.okButtonDanger,disabled:ie,loading:I},cancelButtonProps:{disabled:I},closable:!I,maskClosable:!1,width:t.width??480,centered:!0,className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:[(0,l.jsx)(ck,{note:re,description:t.description,showSelectedCount:t.showSelectedCount,count:B,itemLabel:H,bodyText:ne,deleteError:L}),(0,l.jsx)(lk,{footerNote:t.footerNote}),(0,l.jsx)(Kk,{form:c,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 mA={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:[]},hA={deleteItems:async(e,t)=>{await re(t.moduleName,e)}},gA=new Map;async function _A(e){return e?(gA.has(e)||gA.set(e,a.r({module:e}).catch(t=>(gA.delete(e),console.warn(`[in-progress gate] could not read ${e} form groups:`,t),[]))),gA.get(e)):[]}function vA(e=[],t){return e.some(e=>{let r=n.C(e,t);return r&&r.severity!==`allow`})}async function yA({targetModule:e,sourceModule:t,recordId:r,region:i}={}){let o={severity:`allow`,message:``,group:null};if(!e||!t||!r)return o;let s=i??n.Un().region;try{let i=await _A(e);if(!vA(i,s))return o;let c=await a.r({module:t,id:r}),l={};for(let e of c){let t=e?.payloadKey||e?.name;t&&Array.isArray(e?.rows)&&(l[t]=e.rows)}return n.D(i,s,l)}catch(e){return console.warn(`[in-progress gate] check skipped:`,e),o}}var bA=`Already submitted`,xA=`submissions`,SA=`candidates`,CA=864e5,wA=90,TA=`This candidate was created or last updated more than 90 days ago. Only candidates created or updated within the last 90 days can be selected. Please update this candidate first.`,EA=[`createdAt`,`createdDate`,`dateCreated`,`created_on`,`createdOn`],DA=[`updatedAt`,`updatedDate`,`lastUpdatedAt`,`lastUpdatedDate`,`modifiedAt`,`modifiedDate`];function OA(e,t){for(let n of t){let t=e?.[n];if(!t)continue;let r=new Date(t);if(!Number.isNaN(r.getTime()))return r}return null}function kA(e){return OA(e,EA)}function AA(e){return OA(e,DA)}function jA(e){if(!(e instanceof Date)||Number.isNaN(e.getTime()))return null;let t=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();return Math.max(0,Math.floor((t(new Date)-t(e))/CA))}function MA(e){return e===null?``:e<=14?`green`:e<=89?`yellow`:`red`}function NA(e,t=wA){if(!e)return!1;let n=Date.now()-t*CA,r=kA(e),i=AA(e),a=r&&r.getTime()>=n,o=i&&i.getTime()>=n;return!a&&!o}function PA(e){let t=kA(e);if(!t)return{createdAgo:``,createdAgoTone:``};let n=pk(t);return n?{createdAgo:n,createdAgoTone:MA(jA(t))}:{createdAgo:``,createdAgoTone:``}}function FA(e){return{...e,...PA(e),isStaleCandidate:NA(e)}}function IA(e){return String(e?.applicantId??e?._id??e?.id??``)}var LA=null;async function RA(){return LA||=n.Rr(SA).then(e=>e?.strategies?.duplicateCheck?.editRoute??``).catch(()=>``),LA}async function zA(e){let t=IA(e);if(!t)return``;let n=await RA();return n?n.replace(/:(_?id)\b/g,encodeURIComponent(t)):``}async function BA({option:e,popupContext:t,confirm:n}){let r=e?._raw??e??{},i=IA(r);if(i){let e=await yA({targetModule:xA,sourceModule:SA,recordId:i});if(e.severity===`block`)return new Promise(t=>{n({title:`This candidate cannot be submitted`,content:e.message,okText:`Pick someone else`,cancelText:`Close`,onOk:()=>t(!1),onCancel:()=>t(!1)})})}if(!NA(r))return!0;let a=t?.navigate;return!a||!i?!1:new Promise(e=>{n({title:`Candidate update required`,content:TA,okText:`OK`,cancelText:`Cancel`,onOk:async()=>{let t=await zA(r);t&&a(t),e(!1)},onCancel:()=>e(!1)})})}function VA(e,t,n){return{...e,label:`${e.label} - ${bA}`,disabled:!0,title:`${bA}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}var HA={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 Ce({searchQuery:t,candidateId:r})}catch{a=!1;let e=await Ln({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?.isSubmitted||e._raw?.alreadySubmitted)return VA(e,e._raw?.jobSubmissionId||``,e._raw?.submittedAt||``);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 Te({applicantId:r,jobIds:o.map(e=>e.value)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e.value));return t?VA(e,t.submissionId,t.submittedAt):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 we({search:t,jobId:r})}catch{let e=await is({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await Te({jobId:r,applicantIds:i.map(IA)}).catch(()=>new Map)}return i.map(e=>FA(e)).map(e=>{let t=a.get(IA(e));if(!(t||e?.isSubmitted===!0||e?.alreadySubmitted===!0))return e;let n=t?.submissionId||e?.jobSubmissionId||``,r=t?.submittedAt||e?.submittedAt||``;return{...e,disabled:!0,optionNote:bA,isSubmitted:!0,alreadySubmitted:!0,existingSubmissionId:n,...r?{submittedAt:r}:{}}})}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=>IA(e?._raw)===String(l)),d=n?.dynamicOptions?.jobId?.find(e=>String(e?.value)===String(c)),f=u?._raw?.isSubmitted||u?._raw?.alreadySubmitted||d?.alreadySubmitted||d?._raw?.isSubmitted||d?._raw?.alreadySubmitted;if(!c||!l)throw Error(`Select both a job and a candidate to quick submit.`);if(NA(u?._raw))throw Error(TA);let p=await yA({targetModule:xA,sourceModule:SA,recordId:l});if(p.severity===`block`)throw Error(p.message);let m=f,h=u?._raw?.existingSubmissionId||u?._raw?.jobSubmissionId||d?.existingSubmissionId||d?._raw?.jobSubmissionId||``;try{let e=await Se({jobId:c,applicantId:l});m||=!!e?.exists,h=e?.submissionId||h}catch(e){throw Error(`Could not verify existing submissions (${e?.message??`request failed`}). Please try again.`,{cause:e})}if(m)throw Error(`This candidate is already submitted for this job${h?` (submission ${h})`:``}.`);let g=new URLSearchParams;l&&g.set(`candidateId`,l);let _=u?.priorSubmissionId||u?._raw?.submissionId||d?.priorSubmissionId||d?._raw?.submissionId||``;_?(g.set(`submissionId`,String(_)),g.set(`isFromSubmission`,`true`)):g.set(`isFromSubmission`,`false`);let v=ts(rs({jobId:c,applicantId:l}).catch(()=>[]));return r(`/submission-create/${c}?${g.toString()}`,{state:{relevantSkillsToken:v}}),{navigated:!0}}},UA={title:`Submit`,okText:`Submit`,width:640,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 - or pick a recent job`,searchFetchKey:`quickSubmitJobList`,optionLayout:{id:`{jobReferenceId}`,title:`{jobTitle}`,subtitle:`{clientJobReferenceId}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]}}]:[{name:`candidate`,label:`Candidate`,type:`search-select`,required:!0,placeholder:`Search candidate name / email - or pick a recent candidate`,optionsKey:`candidateOptions`,searchFetchKey:`quickSubmitCandidates`,labelTemplate:`{applicantRefrenceId} - {firstName} {lastName} - {createdAgo}`,valueKey:`applicantId`,optionLayout:{id:`{applicantRefrenceId}`,title:`{firstName} {lastName}`,titleAccent:{key:`createdAgo`,toneKey:`createdAgoTone`,prefix:` - `},subtitle:`{designation} - {email}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]},onSelectGuard:BA}]},WA={title:`Add Notes & Share`,okText:`Save & Share`,width:480,fields:[{name:`notes`,label:`Notes`,type:`mention-textarea`,required:!0,rows:5,maxLength:2e3,placeholder:`Add your notes on the job. Use '@' to mention someone.`,mentionFetchKey:`mentionUsers`}]},GA=e=>e?.data??e;async function KA({relatedId:e,notes:n,title:r,notesFor:i}){return GA(await yn(t.x,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var qA={getMentionOptions:async(e,t)=>ae(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 KA({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},JA={name:`jobId`,label:`Job Title / ID`,type:`search-select`,multiple:!0,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle}`},YA={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},XA={title:`Tag to Job`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[YA]:[JA,YA]},ZA=e=>e?.data??e;function QA(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 $A(e){return e?Array.isArray(e.data)?e.data.map(QA):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(QA):Array.isArray(e)?e.map(QA):[]:[]}async function ej(e=1,n=10){let r=await t.o(t.x,`/workflow/list/all?page=${e}&limit=${n}`),i=ZA(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 tj(e,n){let r=ZA(await t.o(t.x,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function nj(e,n){if(!e||!n)return null;try{let r=new URLSearchParams({module:e,limit:`1`,offset:`0`,scope:`allJobs`,filters:JSON.stringify([{field:`_id`,op:`in`,values:[String(n)],operator:`and`}])}),i=ZA(await t.o(t.x,`/module-data-list?${r}`));if(Array.isArray(i))return i[0]??null;if(i?.data&&Array.isArray(i.data))return i.data[0]??null;let a=i?.rows??i?.records??i?.items??i?.list;return Array.isArray(a)?a[0]??null:i??null}catch(t){return console.error(`[getModuleRecordById] failed: ${e}/${n}`,t),null}}async function rj(e){return ZA(await t.o(t.C,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var ij={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`},aj=`Already submitted`;function oj(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 sj(e){let t=String(e??``).trim();return t?ij[t.toLowerCase()]??t:``}function cj(e,t=``){return String(oj(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t??``)}function lj(e){return String(oj(e,`_id`,`id`,`candidateId`,`candidate_id`,`applicantId`,`applicantID`)??``)}function uj(e,t,n){let r=String(e.jobTitle??``).trim();return{...e,jobTitle:r?`${r} (${aj})`:`(${aj})`,disabled:!0,title:aj,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}function dj(e,t){let n=String(t??``).trim();return n?/already submitted/i.test(n)?`${e} (${aj})`:/fulfilled/i.test(n)?`${e} (Fullfilled)`:`${e} (${n})`:e}function fj(e){let t=String(e.jobReferenceId??e.clientJobReferenceId??``).trim(),n=String(e.jobTitle??``).trim();return{...e,jobReferenceId:t,jobTitle:n}}function pj(e){return hj(e).map(e=>e.id)}function mj(e,t=``){return(oj(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[oj(e,`firstName`,`first_name`),oj(e,`lastName`,`last_name`)].filter(Boolean).join(` `)??t)||`Unknown candidate`}function hj(e){let t=Array.isArray(e?.selectedIds)?e.selectedIds:[],n=Array.isArray(e?.selectedRecords)?e.selectedRecords:[],r=[],i=new Set,a=Math.max(t.length,n.length);for(let e=0;e<a;e+=1){let a=n[e]??{},o=t[e]?String(t[e]):``,s=cj(a,o);!s||i.has(s)||(i.add(s),r.push({id:s,name:mj(a,o),record:a,selectedId:o||s}))}return r}function gj(e,t){return Array.isArray(e?.jobId)?e.jobId.map(String).filter(Boolean):e?.jobId?[String(e.jobId)]:Array.isArray(t?.jobId)?t.jobId.map(String).filter(Boolean):t?.jobId?[String(t.jobId)]:[]}function _j(e,t=``){let n=String(e?.jobTitle??e?._raw?.jobTitle??``).trim();if(n)return n;let r=String(e?.label??e?._raw?.label??``).trim();return r.includes(` - `)?r.split(` - `).slice(1).join(` - `).trim():r||String(t??``)}function vj(e,t=``){return _j(e,t)}function yj(e,t,n){let r=[...new Set(gj(e,t))],i=Array.isArray(n?.dynamicOptions?.jobId)?n.dynamicOptions.jobId:[],a=new Map(i.map(e=>[String(e?._id??e?.value??``),e]));return r.map(e=>{let t=a.get(String(e))??{};return{id:String(e),label:vj(t,e),record:t}})}function bj(e){return e.filter(e=>e.blockedCandidates.length>0).map(e=>`${e.job.label} - ${e.blockedCandidates.map(e=>e.name).join(`, `)}`).join(` | `)}function xj(e){return e.filter(e=>e.allowedCandidates.length>0).map(e=>`${e.job.label} - ${e.allowedCandidates.map(e=>e.name).join(`, `)}`).join(` | `)}function Sj(e,t){let n=lj(e);if(!n)return null;let r=mj(e,t)||void 0,i={candidateId:String(n),candidateName:r,phone:oj(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:oj(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:oj(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:oj(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:oj(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:oj(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:oj(e,`screeningScore`,`screening.score`,`score`),assignedDate:oj(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var Cj={searchOptions:async(e,t,n)=>{if(e.searchFetchKey===`tagToJobJobList`){let e=pj(n),r=e.length===1?e[0]:``,i,a=!1;if(r)try{i=await Ce({searchQuery:t,candidateId:r}),a=!0}catch{a=!1}Array.isArray(i)||(i=await ie(t));let o=i.map(fj);if(a)return o.map(e=>{if(e?.isSubmitted||e?.alreadySubmitted)return uj(e,e?.jobSubmissionId||e?.submissionId||``,e?.submittedAt||``);if(e?.disable){let t=String(e?.message??``).trim();return{...e,jobTitle:e.jobTitle?dj(e.jobTitle,t):`(${t})`,disabled:!0,optionNote:t,title:t}}return e});if(!r)return o;let s=await Te({applicantId:r,jobIds:o.map(e=>e._id).filter(Boolean)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e._id));return t?uj(e,t.submissionId,t.submittedAt):e})}return[]},submit:async(e,t,r)=>{let i=sj(e.hiringStage??t.hiringStage),a=hj(t),o=yj(e,t,r);if(!o.length||!a.length)return{cancelled:!0};let s=[];for(let e of o){let t=await Te({jobId:e.id,applicantIds:a.map(e=>e.id)}).catch(()=>new Map);s.push({job:e,blockedCandidates:a.filter(e=>t.has(String(e.id))),allowedCandidates:a.filter(e=>!t.has(String(e.id)))})}let c=bj(s),l=xj(s),u=s.filter(e=>e.allowedCandidates.length>0);if(!u.length)return await n.Wt({tone:`duplicate`,title:`Selected candidates are already submitted`,body:`Every selected candidate is already submitted to the selected jobs. Choose different jobs to continue.`,facts:[{label:`Blocked combinations`,value:c}],okText:`Close`}),{cancelled:!0};if(s.some(e=>e.blockedCandidates.length>0)&&!await n.Ut({tone:`duplicate`,title:`Some candidate-job combinations are already submitted`,body:`Those combinations will be skipped. Continue tagging the remaining valid combinations?`,facts:[{label:`Will be skipped`,value:c},{label:`Will be tagged`,value:l}],okText:`Tag remaining`,cancelText:`Cancel`,footnote:`Already submitted combinations will be left unchanged.`}))return{cancelled:!0};for(let e of u){for(let t of e.allowedCandidates){let n=Sj(t.record??{},t.selectedId);await rj({jobId:e.job.id,module:`jobs`,currentStage:i,...n?{candidateDetails:n}:{}})}await ce({jobId:e.job.id,candidateIds:e.allowedCandidates.map(e=>e.selectedId||e.id),hiringStage:i})}}},wj={title:`Change Status`,okText:`Apply`,width:420,showSelectedCount:!0,fields:[{name:`status`,label:`New Status`,type:`select`,required:!0,placeholder:`Select a status`,dataSource:`master`,masterName:`clientSubmissions`,labelKey:`name`,valueKey:`name`,initialValueKey:`currentStatus`,defaultOptions:[{label:`Active`,value:`active`},{label:`Inactive`,value:`inactive`},{label:`Pending`,value:`pending`},{label:`Closed`,value:`closed`}]}]};function Tj(e,t){let n=String(e??``).trim().toLowerCase();return(Array.isArray(t?.status)?t.status:[]).find(e=>String(e?.value??``).trim().toLowerCase()===n||String(e?.label??``).trim().toLowerCase()===n||String(e?._raw?.name??``).trim().toLowerCase()===n)??null}var Ej={submit:async(e,t,n)=>{let r=Tj(e.status,n?.dynamicOptions),i=r?._raw??{},a={clientSubmissionStatusText:String(i.name??r?.label??e.status??``).trim(),clientSubmissionStatusId:Number(i.id??i.uniqueId??0)||0,clientSubmissionStatusType:String(i.type??``).trim()};await ne(t.moduleName,t.selectedIds,a)}},Dj={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:[]},Oj={onOk:async e=>{await Ee({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},kj={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`}]},Aj={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?le():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await ue({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},jj=[{title:`Name`,key:`name`,render:(e,t)=>t.name||`${t.first_name??``} ${t.last_name??``}`.trim()||t.user_name||`Assigned user`},{title:`Role`,dataIndex:`role_name`,key:`role`,render:e=>e||`-`},{title:`Reporting`,dataIndex:`reporting_name`,key:`reporting`,render:e=>e||`-`}];function Mj({selectedIds:e,onClose:t}){let n=e?.[0],[r,i]=(0,o.useState)(!0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)({assignedUsers:[],totalSubmissions:0,message:``}),[p,m]=(0,o.useState)([]);(0,o.useEffect)(()=>{let e=!1;return i(!0),Promise.all([G(n).catch(t=>(e||s.message.error(t?.message??`Failed to load self-assign details`),{assignedUsers:[],totalSubmissions:0,message:``})),me(n).catch(()=>({recruitersData:[]}))]).then(([t,n])=>{e||(f(t),m(Array.isArray(n?.recruitersData)?n.recruitersData:[]))}).finally(()=>{e||i(!1)}),()=>{e=!0}},[n]);let h=async()=>{u(!0);try{await de({jobIds:[n]}),s.message.success(`Job assigned successfully`),t?.({success:!0})}catch(e){s.message.error(e?.message??`Failed to assign job`)}finally{u(!1)}};if(r)return(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})});let g=p.map(e=>({user_id:e.recruiterId??e.id??e.user_id,name:e.name??``,role_name:e.role_name??e.roleName??``,reporting_name:e.reporting_name??e.reportingName??``})),_=new Map(g.map(e=>[String(e.user_id??``),e])),v=(d.assignedUsers?.length??0)>0?d.assignedUsers.map(e=>{let t=e.user_id??e.userId??e.recruiterId??e.id,n=_.get(String(t??``))??{};return{...e,user_id:t,name:n.name||e.name||``,role_name:n.role_name||e.role_name||e.roleName||``,reporting_name:n.reporting_name||e.reporting_name||e.reportingName||``}}):g,y=v.length>0;return(0,l.jsxs)(`div`,{className:`self-assign-popup-body`,children:[y?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{style:{fontWeight:700,marginBottom:8},children:`Team Members Allocated`}),(0,l.jsx)(s.Table,{columns:jj,dataSource:v,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,l.jsxs)(`div`,{className:`warning-card`,style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,l.jsx)(c.ExclamationCircleFilled,{style:{color:`#faad14`,fontSize:18}}),(0,l.jsx)(`div`,{style:{fontSize:13},children:`These users are already assigned to this job. Do you still want to assign yourself as well?`})]})]}):(0,l.jsx)(`div`,{style:{padding:`8px 0`},children:d.message||`No one is currently assigned to this job. Do you want to assign yourself?`}),(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:12,marginTop:24},children:[(0,l.jsx)(s.Button,{size:`small`,onClick:()=>t?.(),disabled:a,children:`No`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,onClick:h,loading:a,children:`Yes`})]})]})}Mj.propTypes={selectedIds:f.default.array,onClose:f.default.func};var Nj={title:`Self Assign`,width:480,className:`self-assign-modal`,component:Mj},Pj={submit:async()=>{}};function Fj(e={}){let t=Array.isArray(e.jobPayDetails)?e.jobPayDetails[e.jobPayDetails.length-1]:e.jobPayDetails??e.clientBudget??{},n=Number(t.clientBudgetEnd),r=Number(t.clientBudgetStart);return Number.isFinite(n)&&n>0?n:Number.isFinite(r)&&r>0?r:null}var Ij={getTitleText:(e,t,n)=>{let r=n?.jobTitle||n?.title||``;return r?`Assign - ${r}`:`Assign`},okText:`Assign`,width:520,disabledUntilFilled:!0,showAlreadyAssigned:!0,allowRemovalOnlySubmit:!0,getFields:e=>(Fj(e?.selectedRecords?.[0]??{}),[{name:`assignToUserId`,label:`Assign to`,type:`multi-select`,required:!0,placeholder:`Select recruiter(s)`,fetchOptionsKey:`assignToUsers`}])},Lj={getOptions:async e=>e.fetchOptionsKey===`assignToUsers`?pe():[],loadExtraData:async e=>me(e.selectedIds[0]),submit:async(e,t,{removedIds:n,extraData:r})=>{await ve({jobIds:t.selectedIds,userId:e.assignToUserId,removedIds:n,existingRecruiters:r?.recruitersData})}},Rj={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`}]},zj={getMentionOptions:async(e,t)=>ae(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await oe(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await W({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},Bj={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`,successNavigate:`/onboarding`,fields:[{name:`sendOnboardingEmail`,type:`priority-checkbox`,checkboxLabel:`Send Onboarding Email`}]},Vj={submit:async(e,t)=>{await ye({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function Hj(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var Uj={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function Wj(e,t,n){let r=Hj(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function Gj(e){let t=e.selectedRecords?.[0]??{},n=Wj(t,`candidateRate`,`candidateAcceptedRate`)??Wj(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=Wj(t,`candidateRate`,`candidateAcceptedCurrency`)??Wj(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:Wj(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??Wj(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??Uj[String(r??``).toUpperCase()]??(r||`$`),unit:Wj(t,`candidateRate`,`candidateAcceptedPayUnit`)??Wj(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var Kj={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=Gj(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=Gj(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`}]}]},qj={submit:async(e,t)=>{let n=t.selectedIds[0];if(await be(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await xe(n)}catch{s.message.warning(`Approved. VMS notification could not be sent — use Send Mail to notify the client.`)}else s.message.info(`Approved — use Send Mail to notify the client.`)}};async function Jj(e,n={}){let r=t.u();if(!r){let e=Error(`Authentication required`);throw e.status=401,e}let i=await fetch(`${t.T}${e}`,{...n,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${r}`,...n.headers}});if(i.status===401&&t.h(),!i.ok){let e=Error(`API ${i.status}: ${i.statusText}`);throw e.status=i.status,e}return i.json()}async function Yj(e){let t=await Jj(`/mail-form?${new URLSearchParams({submissionId:e,submissionType:`manager`}).toString()}`);return t.data??t}function Xj(e){return Array.isArray(e)?e[e.length-1]:e}function Zj(e={}){let t=Xj(e?.proposedRate)?.candidateProposedRate??e?.candidateProposedRate??e?.proposedRateValue,n=Number(t);return Number.isFinite(n)?n:0}function Qj(e,t={}){let n=Xj((e?.record?.job??e?.job??t?.job??{})?.jobPayDetails)??{},r=e?.record?.submission??t??{},i=Xj(r?.clientBudget)??r?.clientBudget??{},a=n?.clientBudgetEnd??n?.clientBudgetStart??i?.clientBudgetEnd??i?.clientBudgetStart,o=Number(a);return Number.isFinite(o)?o:0}function $j(e={}){let t=String(e?.currencyRaw??``).trim().toUpperCase(),n=String(e?.currency??``).trim();return n&&!/^[A-Z]{3}$/i.test(n)?n:t===`USD`||n.toUpperCase()===`USD`?`$`:t===`INR`||n.toUpperCase()===`INR`?`₹`:t===`EUR`||n.toUpperCase()===`EUR`?`€`:t===`GBP`||n.toUpperCase()===`GBP`?`£`:n||t}function eM(e={}){return String(e?.rateUnit??`hr`).trim().replace(/^\/+/,``)||`hr`}function tM(e,t={}){let n=Number(e);return Number.isFinite(n)?`${$j(t)}${n}/${eM(t)}`:``}function nM(e,t,n){if(n==null||n===``)return String(e??``);let r=String(e??``),i=String(n),a=!1,o=RegExp(`(<(?:td|th)[^>]*>[\\s\\S]*?${t}[\\s\\S]*?</(?:td|th)>\\s*<(?:td|th)[^>]*>)([\\s\\S]*?)(</(?:td|th)>)`,`gi`);r=r.replace(o,(e,t,n,r)=>(a=!0,`${t}${i}${r}`));let s=RegExp(`(<(?:strong|b)[^>]*>\\s*${t}\\s*:?\\s*</(?:strong|b)>\\s*)([\\s\\S]*?)(?=</(?:li|p|div)>)`,`gi`);if(r=r.replace(s,(e,t)=>(a=!0,`${t}${i}`)),!a){let e=RegExp(`(${t}\\s*:?[ \\t]*)([^<\\r\\n]*)`,`gi`);r=r.replace(e,(e,t)=>`${t}${i}`)}return r}function rM(e,t,n,r,i){let a=Number(n?.proposedRate),o=Number.isFinite(a)?a:Zj(t),s=Number(n?.clientJobRate),c=Number.isFinite(s)&&s>0?s:Qj(r,i),l={proposedRate:o,jobBillRate:c},u=String(e??``).replace(/{{\.?((?:proposedRate)|(?:jobBillRate))}}/g,(e,t)=>{let n=l[t];return n==null?e:String(n)});return u=nM(u,`(?:Proposed\\s*Rate|Pay\\s*Rate)`,tM(o,n)),u=nM(u,`(?:Job\\s*)?Bill\\s*Rate`,tM(c,n)),u}function iM(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var aM=(e,t)=>!!e&&e.toLowerCase()===iM(t).toLowerCase();function oM(e,t,n){let r=iM(t.submittedBy);return iM(aM(r,n)||aM(r,e.submitSource)||aM(r,e.supplierName)||aM(r,e.source)||aM(r,e.candidateSource)?``:r,e.signatureEmail)}function sM(e,t={}){let n=t.employerName??e.supplierName??e.submitSource;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:n,submittedBy:oM(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function cM(e){let t=e?.$oid??e?._id?.$oid??e?._id??e?.id?.$oid??e?.id??e;if(t==null||typeof t==`object`)return``;let n=String(t).trim();return/^[a-f\d]{24}$/i.test(n)?n:``}function lM(...e){for(let t of e){let e=[t?.jobId,t?.JobId,t?.job_id,t?.jobDetails?._id,t?.jobDetails?.id,t?.job?._id,t?.job?.id,t?.submission?.jobId,t?.submission?.JobId,t?.submission?.job_id,t?.submission?.jobDetails?._id,t?.submission?.jobDetails?.id,t?.submission?.job?._id,t?.submission?.job?.id,t?.recordMeta?.jobId,t?.recordMeta?.JobId,t?.recordMeta?.job_id,t?.submission?.recordMeta?.jobId,t?.submission?.recordMeta?.JobId,t?.submission?.recordMeta?.job_id].map(cM).find(Boolean);if(e)return e}return``}function uM(e){if(!e?.referralId)return{};let t=Number(e.referralRate??e.referalRate??0)||0,n=String(e.referralType??e.referalType??`RECURRING`).trim()||`RECURRING`,r=e.referralId??e.referalId;return{referralId:r,referalId:r,referralRate:t,referalRate:t,referralType:n,referalType:n,referralEnabled:!0,referalEnabled:!0,isReferralApplicable:!0,referralDetails:{referralId:r,referalId:r,referralRate:t,referalRate:t,referralType:n,referalType:n,referralEnabled:!0,referalEnabled:!0,isReferralApplicable:!0}}}function dM(e=``){return String(e??``).replace(/map\[[^\]]*(?:resume|document|attachment|file)[^\]]*\]/gi,``).replace(/<p>\s*<\/p>/gi,``).replace(/(?:<br\s*\/?>\s*){3,}/gi,`<br><br>`).trim()}function fM(...e){for(let t of e){let e=[t?.candidateId,t?.applicantId,t?.candidate?._id,t?.candidate?.id,t?.submission?.candidateId,t?.submission?.applicantId,t?.recordMeta?.candidateId,t?.recordMeta?.applicantId].map(cM).find(Boolean);if(e)return e}return``}async function pM(e){let t=e?.fileUrl??e?.downloadUrl??e?.url;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load ${e?.fileName||`resume`}`);let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.originalName??e?.uniqueName??`resume`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function mM(e,r,i){let a=[],o=await n.yn(`submissions`,e,`resume`).catch(()=>({data:[]}));a.push(...o?.data??[]);let s=fM(r?.record?.submission,i,r?.record);if(!s){let n=await t.o(t.x,`/module/list?module=submissions&id=${encodeURIComponent(e)}`).catch(()=>({})),r=n?.data??n??{};s=fM((Array.isArray(r?.data)?r.data:Array.isArray(r)?r:[])[0])}if(s){let e=await n.yn(`candidates`,s,`resume`).catch(()=>({data:[]}));a.push(...e?.data??[])}let c=(await Promise.all(a.map(pM))).filter(Boolean),l=new Set;return c.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!l.has(t)&&(l.add(t),!0)})}function hM(e={}){return{to:(e.to??e.To??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),cc:(e.cc??e.Cc??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),bcc:(e.bcc??e.Bcc??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),subject:e.subject??e.Subject??``,contents:dM(e.content?.value??e.Content?.Value??e.contents??e.body??``)}}function gM({context:e,selectedIds:t,selectedRecords:n,moduleName:r,onClose:i}){let a=n?.[0]??{},c=t?.[0]??xv(a),[u,d]=(0,o.useState)(null),[f,p]=(0,o.useState)(!0),[m,h]=(0,o.useState)([]),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(`vms`),[b,x]=(0,o.useState)(null),[S,C]=(0,o.useState)(null),[w,T]=(0,o.useState)(!1),[E,D]=(0,o.useState)(!1),[O,k]=(0,o.useState)(!1),[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)({to:``,cc:``,bcc:``,subject:``,contents:``,attachments:[],showCc:!1,showBcc:!1});(0,o.useEffect)(()=>{let e=!1;return cy(c,a).then(t=>{e||d(t)}).catch(t=>{e||(s.message.error(t?.message??`Unable to load finance details`),d({record:{submission:a},lookups:{},display:{}}))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[c]),(0,o.useEffect)(()=>{let e=!1;return _y().then(t=>{e||h(t)}).catch(()=>{}),()=>{e=!0}},[]);let P=async()=>{if(b){if(v===`mail`){_(!1),D(!0),k(!0);try{let[e,t]=await Promise.all([Yj(c).then(hM),mM(c,u,a).catch(e=>(console.warn(`Unable to resolve resume attachment:`,e),[]))]),n=u?.record?.submission??a;N({to:rM(e.to,n,b,u,a),cc:rM(e.cc,n,b,u,a),bcc:rM(e.bcc,n,b,u,a),subject:rM(e.subject,n,b,u,a),contents:rM(e.contents,n,b,u,a),attachments:t,showCc:!!e.cc,showBcc:!!e.bcc})}catch(e){s.message.error(e?.message??`Unable to prepare approval mail`)}finally{k(!1)}return}T(!0);try{await be(c,{candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit,submitVia:`VMS`,...uM(S)}),s.message.success(`Submission approved`),_(!1),x(null),C(null),i?.({success:!0})}catch(e){s.message.error(e?.message??`Unable to approve submission`)}finally{T(!1)}}},F=!O&&qD(M.to).length>0&&JD(M.to)&&JD(M.cc)&&JD(M.bcc)&&M.subject.trim()&&M.contents.trim(),I=async()=>{if(!b||!F||A)return;j(!0);let e={candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit};try{await be(c,{...e,submitVia:`VMS`,...uM(S)});let t=lM(u?.record,a);if(!t)s.message.warning(`Submission approved, but job details were not available to send mail`);else try{await pn({jobId:t,toMail:qD(M.to),ccMail:qD(M.cc),bccMail:qD(M.bcc),subject:M.subject,contents:M.contents,attachments:M.attachments??[]}),s.message.success(`Approval mail sent and submission approved`)}catch(e){s.message.warning(e?.message?`Submission approved, but mail was not sent: ${e.message}`:`Submission approved, but mail was not sent`)}D(!1),x(null),C(null),i?.({success:!0})}catch(e){s.message.error(e?.message??`Unable to send approval mail`)}finally{j(!1)}},L=(0,o.useMemo)(()=>({submissionApprove:async({computed:e,referral:t})=>{x(e),C(t??null),y(`vms`),_(!0)},submissionReject:async()=>{e?.navigate?.(`/popup/reject`,{replace:!0,state:{background:e?.background??null,selectedIds:t,selectedRecords:n,moduleName:r}})}}),[e,t,n,r]);return f||!u?(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(Zv,{type:Y_,record:u.record,lookups:u.lookups,identity:sM(a,u.display),referralOptions:m,onAddReferral:()=>e?.navigate?.(`/referrals-create`),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:L,onClose:()=>i?.(),variant:`popup`}),(0,l.jsx)(s.Modal,{title:`Choose approval method`,open:g,okText:`Approve`,confirmLoading:w,onOk:P,onCancel:()=>{w||(_(!1),x(null),C(null))},children:(0,l.jsxs)(s.Radio.Group,{value:v,onChange:e=>y(e.target.value),style:{display:`grid`,gap:12},children:[(0,l.jsx)(s.Radio,{value:`vms`,children:`Via VMS`}),(0,l.jsx)(s.Radio,{value:`mail`,children:`Via Mail`})]})}),(0,l.jsx)(s.Drawer,{open:E,placement:`right`,onClose:()=>{A||D(!1)},closable:!1,rootClassName:`mail-popup`,width:620,maskClosable:!1,footer:(0,l.jsxs)(`div`,{className:`mail-popup__footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>D(!1),disabled:A,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:A,disabled:!F,onClick:I,children:`Send`})]}),children:O?(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})}):(0,l.jsx)(sO,{value:M,onChange:N,moduleName:`submissions`,ready:!O,title:`Submit Via Mail`,contextRecords:[u.record?.submission??a]})})]})}gM.propTypes={context:f.default.object,selectedIds:f.default.array,selectedRecords:f.default.array,moduleName:f.default.string,onClose:f.default.func};var _M={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:gM},vM={submit:async()=>{}};function yM(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var bM=(e,t)=>!!e&&e.toLowerCase()===yM(t).toLowerCase();function xM(e,t,n){let r=yM(t.submittedBy);return yM(bM(r,n)||bM(r,e.submitSource)||bM(r,e.supplierName)||bM(r,e.source)||bM(r,e.candidateSource)?``:r,e.signatureEmail)}function SM(e,t={}){let n=t.employerName??e.supplierName??e.submitSource;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:n,submittedBy:xM(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function CM(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 wM(e){return String(e??``).toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}function TM({selectedIds:e,selectedRecords:t,onClose:r}){let i=t?.[0]??{},a=e?.[0]??xv(i),[c,u]=(0,o.useState)(null),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(!0);(0,o.useEffect)(()=>{let e=!1;return m(!0),Promise.all([cy(a,i),n.pn(`submission`,a).catch(()=>[])]).then(([t,n])=>{if(e)return;let r=CM(n);f(xv(t?.meta?.workforceEngagementId??i?.onboarding?.workforceEngagementId??i?.workforceEngagementId));let a=t?.meta?.rejectReasonComments||r?.activityComments||``;u({...t,record:{...t.record,submission:{...t.record.submission,cfoRejectionReason:a?wM(a):``,cfoRejectedAt:t?.meta?.rejectedAt??r?.activityTime??null}}})}).catch(t=>{e||(s.message.error(t?.message??`Unable to load finance details`),u({record:{submission:i},lookups:{},display:{}}))}).finally(()=>{e||m(!1)}),()=>{e=!0}},[a]);let h=(0,o.useMemo)(()=>({submissionReapproveSend:async({computed:e})=>{await K(d,{submissionId:a,billRate:e.proposedRate,payRate:e.employerRate,currency:e.currencyRaw??e.currency,rateUnit:e.rateUnit,vmsPercent:e.clientVmsPercent}),await be(a,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currencyRaw??e.currency,candidateProposedRateUnit:e.rateUnit,submitVia:`Mail`,context:`resend`}),s.message.success(`Re-approved and sent for CFO approval`),r?.({success:!0})}}),[a,d,r]);return p||!c?(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})}):(0,l.jsx)(Zv,{type:$_,record:c.record,lookups:c.lookups,identity:SM(i,c.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:h,onClose:()=>r?.(),variant:`popup`})}TM.propTypes={selectedIds:f.default.array,selectedRecords:f.default.array,onClose:f.default.func};var EM={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:TM},DM={submit:async()=>{}},OM=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],kM={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:OM.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},AM={submit:async(e,t)=>{let n=OM.find(t=>String(t.id)===String(e.rejectReason));await q({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},jM={title:`Request Document Edit`,okText:`Submit Request`,cancelText:`Cancel`,width:480,successMessage:`Edit request submitted successfully.`,fields:[{name:`reason`,label:`Reason for Edit`,type:`textarea`,required:!0,rows:4,maxLength:1e3,placeholder:`Enter the reason for requesting changes to this document`}]},MM=`documents`,NM={submit:async(e,t)=>{let n=await ke({module:t.moduleName||MM,documentIds:t.selectedIds??[],reason:String(e.reason??``).trim()}),r=Number(n?.failedCount)||0;if(r>0){let e=Number(n?.createdCount)||0,t=n?.failures?.find(e=>e?.error)?.error;s.message.warning(`${e} of ${e+r} edit requests raised${t?` — ${t}`:``}.`)}}},PM={title:`Reject Edit Request`,okText:`Reject`,cancelText:`Cancel`,okButtonDanger:!0,width:480,successMessage:`Edit request rejected successfully.`,fields:[{name:`rejectionReason`,label:`Rejection Reason`,type:`textarea`,required:!0,rows:4,maxLength:1e3,placeholder:`Explain why this edit request is being rejected`}]},FM={submit:async(e,t)=>{let n=t.selectedIds??[],r=await Ae({ids:n,rejectionReason:String(e.rejectionReason??``).trim()}),i=Number(r?.rejectedCount)||0,a=Number(r?.failedCount)||0;if(i===0)throw Error(n.length>1?`None of the selected requests could be rejected — they are no longer pending or are outside your review scope.`:`This request could not be rejected — it is no longer pending or is outside your review scope.`);a>0&&s.message.warning(`${i} of ${i+a} edit requests rejected — the rest are no longer pending or are outside your review scope.`)}},IM={delete:mA,"quick-submit":UA,"add-notes":WA,"tag-to-job":XA,"change-status":wj,"remove-from-shortlist":Dj,"add-to-groups":kj,"self-assign":Nj,"others-assign":Ij,"sticky-notes":Rj,"move-to-onboarding":Bj,"approve-rate":Kj,"manager-approve":_M,"manager-reapprove":EM,reject:kM,"document-edit-request":jM,"document-edit-reject":PM},LM={delete:hA,"quick-submit":HA,"add-notes":qA,"tag-to-job":Cj,"change-status":Ej,"remove-from-shortlist":Oj,"add-to-groups":Aj,"self-assign":Pj,"others-assign":Lj,"sticky-notes":zj,"move-to-onboarding":Vj,"approve-rate":qj,"manager-approve":vM,"manager-reapprove":DM,reject:AM,"document-edit-request":NM,"document-edit-reject":FM};function RM(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function zM(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 BM(e){let t=String(zM(e,`isDeleted`,`deleted`)).toLowerCase(),n=String(zM(e,`assignmentStatus`,`status`)).toLowerCase();return t!==`true`&&t!==`1`&&![`removed`,`inactive`,`deleted`].includes(n)}function VM(e){let t=zM(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[zM(e,`firstName`,`first_name`),zM(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function HM(e){return String(zM(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function UM(e){return String(zM(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function WM(e){return String(zM(e,`batchName`,`name`,`title`,`batch_name`))}function GM({open:e=!0,context:r={},onClose:i}){let[a,c]=(0,o.useState)([]),[u,d]=(0,o.useState)([]),[f,p]=(0,o.useState)(``),[m,h]=(0,o.useState)(!0),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(``),[b,x]=(0,o.useState)(new Map),S=String(r.selectedIds?.[0]??r.selectedRecords?.[0]?._id??r.selectedRecords?.[0]?.id??r.batchId??``);(0,o.useEffect)(()=>{if(!e)return;let t=!1;return Promise.resolve().then(()=>(t||h(!0),Promise.all([n.Sn(`onboarding`,200,0),n.Sn(`batchCandidates`,1e3,0).catch(()=>[])]))).then(([e,n])=>{t||(c(RM(e)),x(new Map(RM(n).filter(BM).map(e=>[String(zM(e,`candidateId`,`candidate_id`)),e]).filter(([e])=>e))))}).catch(e=>{t||y(e.message||`Unable to load onboarding candidates`)}).finally(()=>{t||h(!1)}),()=>{t=!0}},[e]);let C=(0,o.useMemo)(()=>{let e=f.trim().toLowerCase();return e?a.filter(t=>[VM(t),zM(t,`email`,`candidateEmail`,`candidate_email`),zM(t,`status`,`onboardingStatus`,`onboarding_status`)].some(t=>String(t).toLowerCase().includes(e))):a},[a,f]);async function w(){if(!S){y(`Select a batch before adding candidates`);return}let e=a.filter(e=>u.includes(UM(e)));if(!e.length)return;let o=e.map(e=>({record:e,assignment:b.get(HM(e))})).filter(e=>e.assignment);if(o.length){let e=o.map(({record:e})=>VM(e)).join(`, `);y(`${e} ${o.length===1?`is`:`are`} already added to a batch. Each candidate can be added to only one batch.`);return}_(!0),y(``);try{let{userId:a}=t.s(),o=WM(r.selectedRecords?.[0])||WM(r);await Promise.all(e.map(e=>n.er(`batchCandidates`,{schemaVersion:1,batchId:S,batchName:o,candidateId:HM(e),workforceEngagementId:UM(e),source:`ONBOARDING`,assignmentStatus:`ASSIGNED`,assignedAt:new Date().toISOString(),assignedBy:a??0,isDeleted:!1}))),s.message.success(`${e.length} candidate${e.length===1?``:`s`} added to the batch`),i?.({refresh:!0})}catch(e){y(e.message||`Unable to add candidates to the batch`)}finally{_(!1)}}return(0,l.jsxs)(s.Modal,{open:e,title:`Add Candidate to Batch`,okText:`Add`,onOk:w,onCancel:()=>i?.(),okButtonProps:{disabled:u.length===0||!S,loading:g},cancelButtonProps:{disabled:g},closable:!g,maskClosable:!1,width:760,centered:!0,children:[v&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:v,style:{marginBottom:12}}),(0,l.jsx)(s.Input.Search,{allowClear:!0,placeholder:`Search onboarding candidates`,value:f,onChange:e=>p(e.target.value),style:{marginBottom:12}}),(0,l.jsx)(s.Table,{rowKey:e=>UM(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>VM(t)},{title:`Email`,key:`email`,render:(e,t)=>zM(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>zM(t,`status`,`onboardingStatus`,`onboarding_status`)||`—`}],dataSource:C,loading:m,size:`small`,pagination:{pageSize:10,showSizeChanger:!1},rowSelection:{selectedRowKeys:u,onChange:d,getCheckboxProps:e=>{let t=b.get(HM(e));return{disabled:!HM(e)||!UM(e)||!!t,title:t?`Candidate is already added to a batch`:void 0}}},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var KM={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function qM(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:KM[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}))}))),n=JM(e.successNavigate);return{title:e.label,fields:t,...n?{successNavigate:n}:{}}}function JM(e){let t=String(e??``).trim();return!t||!t.startsWith(`/`)||t.startsWith(`//`)||/^[a-z][a-z0-9+.-]*:/i.test(t)?null:t}function YM(e,t=[]){if(!e||!Array.isArray(t)||!t.length)return e;let n=new Map(t.filter(e=>e?.name).map(e=>[String(e.name),e]));return n.size?{...e,fields:(e.fields??[]).map(r=>{let i=n.get(String(r.name))??n.get(String(r.label))??(n.size===1&&(e.fields??[]).length===1?t[0]:null);if(!i)return r;let{name:a,...o}=i;return{...r,...o}})}:e}function XM({apiMap:e={},extraConfigs:r={}}){let i=(0,o.useMemo)(()=>({...LM,...e}),[e]),a=(0,o.useMemo)(()=>{let e={...IM};return Object.entries(r).forEach(([t,n])=>{e[t]={...e[t]??{},...n}}),e},[r]),{popupKey:s}=(0,d.useParams)(),c=(0,d.useNavigate)(),{state:u={}}=(0,d.useLocation)(),[f,p]=(0,o.useState)({key:``,config:null});(0,o.useEffect)(()=>{let e=!1;if(!s||!u.moduleName)return;let t=`${u.moduleName}:${s}`;return n.Er(u.moduleName,`popup`,s).then(n=>{e||p({key:t,config:qM(n[0])})}).catch(()=>{e||p({key:t,config:null})}),()=>{e=!0}},[s,u.moduleName]);let m=(0,o.useMemo)(()=>{let e=a[s],t=`${u.moduleName}:${s}`,n=f.key===t?f.config:null;return YM(n?{...e,...n}:e,u.popupAction?.popupFieldOverrides)},[f,a,s,u.moduleName,u.popupAction?.popupFieldOverrides]),h=(0,o.useMemo)(()=>({selectedIds:u.selectedIds??[],selectedRecords:u.selectedRecords??[],moduleName:u.moduleName??``,navigate:c,background:u.background??null,...u.popupContext??{}}),[c,u.selectedIds,u.selectedRecords,u.moduleName,u.popupContext,u.background]),g=(0,o.useMemo)(()=>{let e=u.popupAction;return e?.apiPath?{submit:(n,r)=>{let i=String(e.apiMethod||`POST`).toUpperCase();return t.o(t.x,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})})}}:{}},[u.popupAction]),_=e=>{let t=u.background;if(e?.success&&m?.successNavigate){c(m.successNavigate,{replace:!0,state:{refreshTimestamp:Date.now()}});return}if(e?.success&&t?.pathname){c(`${t.pathname}${t.search??``}`,{replace:!0,state:{...t.state??{},refreshTimestamp:Date.now()}});return}c(-1)};return s===`add-batch-candidate`?(0,l.jsx)(GM,{open:!0,context:h,onClose:_}):(0,l.jsx)(pA,{open:!0,config:m,context:h,onClose:_,api:{...i[s]??{},...g}})}var ZM={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`}]},QM={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>un({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>dn(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>pn({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},$M=ZM.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function eN(){let e=(0,d.useNavigate)(),t=(0,d.useLocation)(),{selectedIds:n=[],selectedRecords:r=[],recipients:i=[],subject:a=``,onSend:u,moduleName:f=``,popupAction:p={}}=t.state??{},m=n[0]??r[0]?._id??r[0]?.id,[h,g]=(0,o.useState)({to:i.join(`, `),cc:``,bcc:``,subject:a,contents:``,showCc:!1,showBcc:!1}),[_,v]=(0,o.useState)(!m),[y,b]=(0,o.useState)(ZM.defaultTab),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)([]),[T,E]=(0,o.useState)(0),[D,O]=(0,o.useState)(0),[k,A]=(0,o.useState)(0),[j,M]=(0,o.useState)(1),[N,P]=(0,o.useState)(ZM.defaultPageSize),[F,I]=(0,o.useState)(!1),[L,R]=(0,o.useState)([]);(0,o.useEffect)(()=>{if(!m)return;let e=!1;I(!0);let t=x?100:N,n=x?0:(j-1)*N;return QM.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,o.useEffect)(()=>{m&&QM.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,o.useMemo)(()=>L.map(e=>C.find(t=>t.vendorId===e)?.vendorEmail??``).filter(Boolean),[L,C]),B=(0,o.useMemo)(()=>({...h,bcc:[...new Set([...qD(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function V(e){let t=new Set(z);g({...e,bcc:qD(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let H=(qD(B.to).length||qD(B.bcc).length)&&JD(B.to)&&JD(B.cc)&&JD(B.bcc)&&B.subject.trim(),ee=e=>e===`myVendor`?T:D;function U(){e(-1)}function te(){H&&QM.submit({jobId:m,toMail:qD(B.to),ccMail:qD(B.cc),bccMail:qD(B.bcc),subject:B.subject,contents:B.contents}).then(t=>{t?.status===!0?(s.message.success(t?.data||`Mail sent successfully.`),typeof u==`function`&&u({...B,message:B.contents,selectedIds:n}),e(-1)):s.message.error(t?.message||t?.data||`Failed to send mail. Please try again.`)}).catch(e=>{s.message.error(e?.message||`Failed to send mail. Please try again.`)})}let ne=(0,o.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,l.jsx)(s.Drawer,{open:!0,placement:`right`,onClose:U,closable:!1,rootClassName:`vendor-share`,width:`95%`,footer:(0,l.jsxs)(`div`,{className:`vendor-share__footer`,children:[(0,l.jsx)(s.Button,{onClick:U,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,disabled:!H,onClick:te,children:`Send`})]}),children:(0,l.jsxs)(`div`,{className:`vendor-share__body`,children:[(0,l.jsxs)(`div`,{className:`vendor-share__left`,children:[(0,l.jsxs)(`div`,{className:`vendor-share__vendor-header`,children:[(0,l.jsxs)(`div`,{className:`vendor-share__vendor-header-row`,children:[(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.CloseOutlined,{}),onClick:U,size:`small`,style:{marginRight:8}}),(0,l.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,l.jsx)(c.TeamOutlined,{})}),(0,l.jsx)(`span`,{className:`dynamic-popup__header-label`,children:`Vendor List`}),(0,l.jsxs)(`div`,{className:`vendor-share__vendor-search`,children:[(0,l.jsx)(c.SearchOutlined,{className:`vendor-share__search-icon`}),(0,l.jsx)(s.Input,{variant:`borderless`,placeholder:`Search vendor`,value:x,onChange:e=>{S(e.target.value),M(1)},className:`vendor-share__search-input`})]})]}),(0,l.jsx)(`div`,{className:`vendor-share__vendor-tabs`,children:ZM.vendorTabs.map(e=>(0,l.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,` (`,ee(e.key),`)`]},e.key))})]}),(0,l.jsx)(`div`,{className:`vendor-share__vendor-table-wrapper`,children:(0,l.jsx)(s.Table,{rowKey:e=>e.vendorId,columns:$M,dataSource:ne,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>ZM.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,l.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,l.jsx)(Be,{current:j,pageSize:N,total:k,onChange:e=>M(e),onPageSizeChange:e=>P(e)})})]}),(0,l.jsx)(`div`,{className:`vendor-share__right`,children:(0,l.jsx)(sO,{value:B,onChange:V,moduleName:f,defaultTemplateId:p.defaultTemplateId??t.state?.defaultTemplateId??``,ready:_,contextRecords:r,title:`Share`,hint:`Select vendors or add email addresses`,bccHint:`Vendor emails are added automatically`,afterBcc:L.length>0?(0,l.jsxs)(`div`,{className:`vendor-share__selected-count`,children:[L.length,` / `,ZM.maxVendorSelect,` Vendors selected`]}):null})})]})})}function tN(e){return e?.data??e}async function nN(e){let n=String(e??``).trim();if(!n)throw Error(`Invoice id is required`);return tN(await t.o(t.x,`/payments/invoice/${encodeURIComponent(n)}`))}function rN(...e){for(let t of e){let e=String(t??``).trim();if(e&&e!==`undefined`&&e!==`null`)return e}return``}async function iN(e,t,n){if(!e)return null;let r=await fetch(e);if(!r.ok)throw Error(`Unable to load invoice attachment`);let i=await r.blob();return new File([i],t||`payment-invoice.html`,{type:n||i.type||`text/html`})}function aN(e){let t=rN(e?.courseName,`your course`),n=rN(e?.invoiceNumber,e?.invoiceFileName,e?.transactionId);return{subject:`Payment invoice - ${t}`,contents:`<p>Hello ${rN(e?.recipientName,`Student`)},</p><p>Please find attached the invoice for your successful payment${n?` (${n})`:``}.</p><p>Thank you.</p>`}}function oN(){let e=(0,d.useNavigate)(),{id:t}=(0,d.useParams)(),[r,i]=(0,o.useState)(null),[a,u]=(0,o.useState)(``),[f,p]=(0,o.useState)(!0),[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)({to:``,cc:``,bcc:``,subject:``,contents:``,attachments:[],showCc:!1,showBcc:!1}),b=(0,o.useMemo)(()=>r?.invoiceUrl?[{id:r.invoiceS3Key||r.invoiceUrl,name:r.invoiceFileName||`payment-invoice.html`,url:r.invoiceUrl,type:r.invoiceContentType||`html`}]:[],[r]);(0,o.useEffect)(()=>{let e=!1;async function n(){p(!0);try{let n=await nN(t);if(e)return;i(n);let r=aN(n),a=await iN(n?.invoiceUrl,n?.invoiceFileName,n?.invoiceContentType).catch(()=>null),o={to:rN(n?.recipientEmail),cc:``,bcc:``,subject:r.subject,contents:r.contents,attachments:a?[a]:[],showCc:!1,showBcc:!1},s=(await Xw({module:`payments`,action:`invoice`}).catch(()=>[]))[0];if(!s?._id){y(o);return}u(String(s._id));let c=await Zw(s._id).catch(()=>null);if(!c){y(o);return}y({...o,to:rN(o.to,...(c.toMail??[]).map(e=>oO(e,c.placeholders,n))),cc:(c.ccMail??[]).map(e=>oO(e,c.placeholders,n)).filter(Boolean).join(`, `),bcc:(c.bccMail??[]).map(e=>oO(e,c.placeholders,n)).filter(Boolean).join(`, `),subject:rN(oO(c.subject,c.placeholders,n),o.subject),contents:rN(oO(c.body,c.placeholders,n),o.contents),showCc:!!c.ccMail?.length,showBcc:!!c.bccMail?.length})}catch(t){e||s.message.error(t?.message||`Unable to load invoice`)}finally{e||p(!1)}}return n(),()=>{e=!0}},[t]);let x=qD(v.to).length>0&&JD(v.to)&&JD(v.cc)&&JD(v.bcc)&&v.subject.trim()&&v.contents.trim();async function S(){if(!(!x||g)){_(!0);try{await pn({jobId:``,toMail:qD(v.to),ccMail:qD(v.cc),bccMail:qD(v.bcc),subject:v.subject,contents:v.contents,attachments:v.attachments}),s.message.success(`Invoice mail sent successfully`),h(!1)}catch(e){s.message.error(e?.message||`Failed to send invoice mail`)}finally{_(!1)}}}return(0,l.jsxs)(s.Drawer,{open:!0,placement:`right`,onClose:()=>e(-1),width:`min(1040px, 96vw)`,title:`Payment Invoice`,extra:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.MailOutlined,{}),onClick:()=>h(!0),disabled:!r,children:`Send Mail`}),destroyOnClose:!0,children:[(0,l.jsx)(s.Spin,{spinning:f,tip:`Loading invoice...`,children:!f&&!b.length?(0,l.jsx)(s.Alert,{type:`warning`,message:`Invoice document is not available for this payment.`,showIcon:!0}):(0,l.jsx)(`div`,{style:{height:`calc(100vh - 140px)`},children:(0,l.jsx)(n.En,{documents:b,inline:!0})})}),(0,l.jsx)(s.Drawer,{open:m,placement:`right`,onClose:()=>h(!1),width:620,rootClassName:`mail-popup`,destroyOnClose:!0,footer:(0,l.jsxs)(`div`,{className:`mail-popup__footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>h(!1),children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:g,disabled:!x,onClick:S,children:`Send`})]}),children:(0,l.jsx)(sO,{value:v,onChange:y,moduleName:`payments`,defaultTemplateId:a,contextRecords:r?[r]:[],title:`Invoice Mail`,hint:`Customer email and invoice attachment are prefilled.`})})]})}var sN={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].*$/},cN={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},lN={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 ${cN.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.`},uN={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},dN={REMARKS_MIN:10,REMARKS_MAX:250},fN={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)}`}},pN={required:(e=`Field`)=>({required:!0,message:lN.REQUIRED(e)}),email:()=>({pattern:sN.EMAIL,message:lN.INVALID_EMAIL}),phone:()=>({pattern:sN.PHONE,message:lN.INVALID_PHONE}),password:()=>({pattern:sN.PASSWORD,message:lN.INVALID_PASSWORD}),alphabets:()=>({pattern:sN.ALPHABETS,message:lN.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:sN.ALPHANUMERIC,message:lN.INVALID_ALPHANUMERIC}),number:()=>({pattern:sN.NUMBER,message:lN.INVALID_NUMBER}),url:()=>({pattern:sN.URL,message:lN.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:sN.CANDIDATE_ID,message:lN.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:sN.REMARKS,message:lN.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${dN.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${dN.REMARKS_MAX} characters.`}),designation:()=>({pattern:sN.DESIGNATION,message:lN.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!sN.DOB.test(n))return Promise.reject(Error(lN.INVALID_DOB));let r=(0,u.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(lN.INVALID_DOB));let i=(0,u.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:sN.LINKEDIN,message:lN.INVALID_LINKEDIN}),companyName:()=>({pattern:sN.COMPANY_NAME,message:lN.INVALID_COMPANY_NAME}),firstName:()=>({pattern:sN.FIRST_NAME,message:lN.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${uN.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${uN.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:uN.FIRST_NAME_MIN,message:lN.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:uN.FIRST_NAME_MAX,message:lN.FIRST_NAME_MAX}),remarksMinLength:()=>({min:dN.REMARKS_MIN,message:lN.REMARKS_MIN}),remarksMaxLength:()=>({max:dN.REMARKS_MAX,message:lN.REMARKS_MAX}),fullName:()=>({pattern:sN.FULL_NAME,message:lN.INVALID_FULL_NAME}),noSpaces:()=>({pattern:sN.NO_SPACES,message:lN.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:sN.STARTS_WITH_CAPITAL,message:lN.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<=cN.MAX_FILE_SIZE))return s.message.error(lN.INVALID_FILE_SIZE),Promise.reject(Error(lN.INVALID_FILE_SIZE));if(!cN.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(lN.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>cN.SINGLE_FILE_COUNT)return Promise.reject(Error(lN.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<cN.MAX_FILE_SIZE?cN.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(lN.INVALID_FILE_TYPE)):Promise.reject(Error(lN.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>cN.MULTI_FILE_COUNT)return Promise.reject(Error(lN.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<cN.MAX_FILE_SIZE))return Promise.reject(Error(lN.INVALID_FILE_SIZE));if(!cN.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(lN.INVALID_FILE_TYPE))}return Promise.resolve()}})},mN={beforeUpload:e=>[`image/jpeg`,`image/png`,`application/pdf`].includes(e.type)?e.size/1024/1024<=2?!1:(s.message.error(`File upload must be 2 MB below.`),s.Upload.LIST_IGNORE):(s.message.error(`Only JPG, PNG and PDF files are allowed.`),s.Upload.LIST_IGNORE)},hN=()=>{let[e]=s.Form.useForm();return(0,l.jsx)(`div`,{style:{padding:24},children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,onFinish:e=>{console.log(`Form Values:`,e)},autoComplete:`off`,children:[(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Email`,name:`email`,rules:[pN.required(`Email`),pN.email()],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Phone Number`,name:`phone`,rules:[pN.required(`Phone Number`),pN.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,l.jsx)(s.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:fN.phoneFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Password`,name:`password`,rules:[pN.required(`Password`),pN.password()],children:(0,l.jsx)(s.Input.Password,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Full Name`,name:`fullName`,rules:[pN.required(`Full Name`),pN.alphabets(),pN.firstNameMinLength(),pN.firstNameMaxLength()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({fullName:fN.firstNameFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Username`,name:`username`,rules:[pN.required(`Username`),pN.alphanumeric()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({username:fN.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Website URL`,name:`website`,rules:[pN.required(`Website URL`),pN.url()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({website:fN.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`MSP Req ID`,name:`mspreqID`,rules:[pN.required(`MSP Req ID`),pN.candidateId(`MSP Req ID`)],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({mspreqID:fN.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[pN.required(`Candidate ID`),pN.candidateId(`Candidate ID`)],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({candidateId:fN.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:24,children:(0,l.jsx)(s.Form.Item,{label:`Remarks`,name:`remarks`,rules:[pN.required(`Remarks`),pN.remarks(),pN.remarksMinLength(),pN.remarksMaxLength()],children:(0,l.jsx)(s.Input.TextArea,{rows:4})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Designation`,name:`designation`,rules:[pN.required(`Designation`),pN.designation()],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Date of Birth`,name:`dob`,rules:[pN.dob()],children:(0,l.jsx)(s.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:fN.dobFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Company Name`,name:`companyName`,rules:[pN.required(`Company Name`),pN.companyName()],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{name:`contractType`,label:`Contract Type`,children:(0,l.jsxs)(s.Select,{showSearch:!0,allowClear:!0,filterOption:(e,t)=>(t?.label??``).toLowerCase().includes(e.toLowerCase()),children:[(0,l.jsx)(s.Select.Option,{value:`C2C`,label:`C2C`,children:`C2C`}),(0,l.jsx)(s.Select.Option,{value:`W2-Contract`,label:`W2-Contract`,children:`W2-Contract`}),(0,l.jsx)(s.Select.Option,{value:`W2-Fulltime`,label:`W2-Fulltime`,children:`W2-Fulltime`}),(0,l.jsx)(s.Select.Option,{value:`1099`,label:`1099`,children:`1099`})]})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{name:`candidateProposedRateCurrency`,label:`Currency`,children:(0,l.jsxs)(s.Select,{showSearch:!0,allowClear:!0,children:[(0,l.jsx)(s.Select.Option,{value:`$`,children:`$`}),(0,l.jsx)(s.Select.Option,{value:`₹`,children:`₹`}),(0,l.jsx)(s.Select.Option,{value:`€`,children:`€`}),(0,l.jsx)(s.Select.Option,{value:`zł`,children:`zł`}),(0,l.jsx)(s.Select.Option,{value:`£`,children:`£`}),(0,l.jsx)(s.Select.Option,{value:`kr`,children:`kr`}),(0,l.jsx)(s.Select.Option,{value:`Fr`,children:`Fr`}),(0,l.jsx)(s.Select.Option,{value:`kr`,children:`kr`})]})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Resume new`,name:`resume`,children:(0,l.jsx)(s.Upload,{beforeUpload:mN.beforeUpload,maxCount:1,children:(0,l.jsx)(s.Button,{children:`Upload Resume`})})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Documents`,name:`documents`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[pN.multiFileUpload()],children:(0,l.jsx)(s.Upload,{multiple:!0,beforeUpload:mN.beforeUpload,children:(0,l.jsx)(s.Button,{children:`Upload Documents`})})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Upload File`,name:`file`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[pN.fileUpload()],children:(0,l.jsx)(s.Upload,{beforeUpload:mN.beforeUpload,maxCount:1,children:(0,l.jsx)(s.Button,{children:`Upload`})})})})]}),(0,l.jsx)(s.Row,{children:(0,l.jsx)(s.Form.List,{name:`users`,children:(e,{add:t,remove:n})=>(0,l.jsxs)(l.Fragment,{children:[e.map(({key:e,name:t,...r})=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{required:!0,...r,rules:[{required:!0,message:`First name is requried`}],name:[t,`first`],children:(0,l.jsx)(s.Input,{placeholder:`First Name`})})}),(0,l.jsx)(s.Col,{span:11,children:(0,l.jsx)(s.Form.Item,{...r,required:!0,name:[t,`last`],children:(0,l.jsx)(s.Input,{placeholder:`Last Name`})})}),(0,l.jsx)(s.Col,{span:1,children:(0,l.jsx)(c.MinusCircleOutlined,{onClick:()=>n(t)})})]})),(0,l.jsx)(s.Form.Item,{children:(0,l.jsx)(s.Button,{type:`dashed`,onClick:()=>t(),block:!0,icon:(0,l.jsx)(c.PlusOutlined,{}),children:`Add field`})})]})})}),(0,l.jsxs)(s.Form.Item,{children:[(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,children:`Submit`}),(0,l.jsx)(s.Button,{style:{marginLeft:10},onClick:()=>e.resetFields(),children:`Reset`})]})]})})};function gN(e){return(0,l.jsx)(Pb,{children:(0,l.jsx)(HD,{...e})})}var{Text:_N}=s.Typography,vN=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],yN={fileText:(0,l.jsx)(c.FileTextOutlined,{}),checkCircle:(0,l.jsx)(c.CheckCircleOutlined,{}),user:(0,l.jsx)(c.UserOutlined,{}),filter:(0,l.jsx)(c.FilterOutlined,{})};function bN({stats:e=vN}){return(0,l.jsx)(s.Card,{children:(0,l.jsx)(s.Row,{gutter:[12,12],children:e.map(e=>(0,l.jsx)(s.Col,{xs:24,sm:24,md:8,lg:8,xl:8,children:(0,l.jsxs)(s.Card,{className:`stats-inner-card`,children:[(0,l.jsxs)(s.Space,{align:`center`,children:[yN[e.icon]??yN.fileText,(0,l.jsx)(_N,{children:e.label})]}),(0,l.jsx)(s.Statistic,{value:e.value})]})},e.label))})})}var{Text:xN}=s.Typography;function SN(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 CN(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:SN(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function wN(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(1),[p,m]=(0,o.useState)(10),[h,g]=(0,o.useState)(``),_=(0,o.useCallback)(async({offset:e,limit:r,searchQuery:a}={})=>{u(!0);try{let o=await n.yr({offset:e,limit:r,searchQuery:a??``}),s=(o.users??[]).map(CN);t(s),i(o.total??s.length)}catch{s.message.error(`Failed to load users`)}finally{u(!1)}},[]);return(0,o.useEffect)(()=>{queueMicrotask(()=>{_({offset:(d-1)*p,limit:p,searchQuery:h})})},[_,d,p,h]),(0,l.jsx)(Z,{icon:(0,l.jsx)(c.TeamOutlined,{}),title:`Users`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,l.jsx)($m,{listName:`Users`,dataSource:e,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(xN,{strong:!0,style:{fontSize:13},children:e}),t._email&&(0,l.jsx)(`div`,{style:{fontSize:11,color:`var(--color-text-muted)`},children:t._email})]})},{label:`Role`,value:`_role`,width:180}],loading:a,total:r,current:d,pageSize:p,onPageChange:e=>f(e),onPageSizeChange:e=>{m(e),f(1)},onSearch:e=>{g(e),f(1)}})})}var{Text:TN}=s.Typography,EN=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],DN=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function ON({field:e,index:t,onToggle:n,onReorder:r}){let i=(0,o.useRef)(null),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(!1);function p(e){i.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),i.current!==null&&i.current!==t&&r(i.current,t),i.current=null}return(0,l.jsxs)(`div`,{draggable:!0,onDragStart:p,onDragEnd:m,onDragOver:h,onDragLeave:g,onDrop:_,className:`uss-field-row with-edit${a?` drag-over`:``}${d?` dragging`:``}`,children:[(0,l.jsx)(`span`,{className:`uss-drag-handle`,children:(0,l.jsx)(c.HolderOutlined,{})}),(0,l.jsxs)(`span`,{className:`uss-field-name`,children:[e.fieldName,(0,l.jsx)(`span`,{className:`uss-field-key`,children:e.fieldKey})]}),(0,l.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,l.jsx)(s.Switch,{size:`small`,checked:e.isVisible,onChange:e=>n(t,`isVisible`,e)})}),(0,l.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,l.jsx)(s.Switch,{size:`small`,checked:!!e.isEditable,onChange:e=>n(t,`isEditable`,e)})}),(0,l.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,l.jsx)(s.Switch,{size:`small`,checked:!!e.ismandatory,onChange:e=>n(t,`ismandatory`,e)})})]})}function kN({team:e,configType:t}){let[r,i]=(0,o.useState)({}),[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)({}),[f,p]=(0,o.useState)(`job`);(0,o.useEffect)(()=>{e&&(c(!0),n.Zr(e,t).then(i).catch(()=>s.message.error(`Failed to load field config`)).finally(()=>c(!1)))},[e,t]);let m=r[f]??[];function h(e,t){i(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 n.Ci(e,r,m,t),s.message.success(`Saved`)}catch{s.message.error(`Save failed`)}finally{d(e=>({...e,[r]:!1}))}}return(0,l.jsxs)(s.Spin,{spinning:a,children:[(0,l.jsx)(s.Tabs,{size:`small`,activeKey:f,onChange:p,items:EN.map(e=>({key:e.key,label:e.label}))}),(0,l.jsxs)(`div`,{className:`uss-field-header with-edit`,children:[(0,l.jsx)(`span`,{}),(0,l.jsx)(`span`,{children:`Field`}),(0,l.jsx)(`span`,{style:{textAlign:`center`},children:`Visible`}),(0,l.jsx)(`span`,{style:{textAlign:`center`},children:`Editable`}),(0,l.jsx)(`span`,{style:{textAlign:`center`},children:`Mandatory`})]}),(0,l.jsxs)(`div`,{className:`uss-field-list`,children:[m.length===0&&!a&&(0,l.jsx)(`div`,{className:`uss-empty`,children:`No fields found.`}),m.map((e,t)=>(0,l.jsx)(ON,{field:e,index:t,onToggle:g,onReorder:_},e.fieldKey??t))]}),(0,l.jsx)(`div`,{className:`uss-modal-footer`,children:(0,l.jsxs)(s.Button,{type:`primary`,size:`small`,loading:u[f],onClick:v,children:[`Save `,EN.find(e=>e.key===f)?.label]})})]})}function AN(){let[e,t]=(0,o.useState)(null),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(`listView`),[p,m]=(0,o.useState)([]),[h,g]=(0,o.useState)(0),[_,v]=(0,o.useState)(!1),[y,b]=(0,o.useState)(``),[x,S]=(0,o.useState)(!1),C=(0,o.useCallback)(async()=>{v(!0);try{let e=await n.vr();m(e.teams),g(e.total)}catch{s.message.error(`Failed to load teams`)}finally{v(!1)}},[]);(0,o.useEffect)(()=>{C()},[C]);function w(e){t(e),f(`listView`),i(!0)}function T(e){t(e),b(e.teamName??``),u(!0)}async function E(){if(!y.trim()){s.message.warning(`Team name is required`);return}S(!0);try{await n.Si(e,{teamName:y.trim(),managerId:e.managerId,memberIds:e.memberIds}),s.message.success(`Team updated`),u(!1),C()}catch{s.message.error(`Failed to update team`)}finally{S(!1)}}return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(Z,{icon:(0,l.jsx)(c.TeamOutlined,{}),title:`Teams`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,l.jsx)($m,{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,l.jsxs)(`div`,{style:{display:`flex`,gap:4},children:[(0,l.jsx)(s.Button,{size:`small`,type:`link`,onClick:()=>T(t),children:`Edit`}),(0,l.jsx)(s.Button,{size:`small`,type:`link`,onClick:()=>w(t),children:`Configure`})]})}],loading:_,total:h})}),(0,l.jsx)(s.Modal,{open:a,onCancel:()=>u(!1),title:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.TeamOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),`Edit Team`]}),width:420,footer:null,destroyOnClose:!0,children:(0,l.jsxs)(`div`,{className:`uss-edit-team-body`,style:{paddingTop:12},children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`uss-edit-team-label`,children:`Team Name`}),(0,l.jsx)(s.Input,{value:y,onChange:e=>b(e.target.value),onPressEnter:E,placeholder:`Enter team name`})]}),(0,l.jsxs)(`div`,{className:`uss-modal-footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>u(!1),children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:x,onClick:E,children:`Save`})]})]})}),(0,l.jsxs)(s.Modal,{className:`uss-modal`,open:r,onCancel:()=>i(!1),title:(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(c.TeamOutlined,{style:{color:`var(--color-brand)`}}),(0,l.jsxs)(`span`,{children:[`Configure: `,e?.teamName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,l.jsx)(`div`,{style:{marginBottom:12},children:(0,l.jsx)(`div`,{className:`uss-config-toggle`,children:DN.map(e=>(0,l.jsx)(`button`,{className:`uss-config-btn${d===e.key?` active`:``}`,onClick:()=>f(e.key),children:e.label},e.key))})}),e&&(0,l.jsx)(kN,{team:e,configType:d},`${e?.teamId}-${d}`)]})]})}var jN=[`view`,`add`,`edit`,`delete`],MN={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`,po_msa:`PO MSA`,reApprove:`ReApprove`,sendApprove:`Send Approve`};function NN(e){return MN[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function PN(e){let t=jN.filter(t=>e.includes(t)),n=e.filter(e=>!jN.includes(e)).sort();return[...t,...n]}function FN(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),PN([...t])}function IN(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{Kx(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function LN(e={}){if(!e||typeof e!=`object`)return e;let t=Object.keys(e).find(e=>String(e).trim().toLowerCase()===`onboarding`);if(!t)return e;let n=e[t]??{},r={...n.permissions??{}};for(let e of[`sendApprove`,`reApprove`])Object.keys(r).some(t=>t.toLowerCase()===e.toLowerCase())||(r[e]={id:0,value:`0`});return{...e,[t]:{...n,permissions:r}}}function RN({value:e,onSave:t,className:n}){let[r,i]=(0,o.useState)(!1),[a,s]=(0,o.useState)(e);(0,o.useEffect)(()=>{s(e)},[e]);function u(){i(!1);let n=a.trim();n&&n!==e?t(n):s(e)}return r?(0,l.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input${n?` ${n}`:``}`,value:a,style:{width:Math.max(48,a.length*8)},onChange:e=>s(e.target.value),onBlur:u,onKeyDown:t=>{t.key===`Enter`&&u(),t.key===`Escape`&&(i(!1),s(e)),t.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,l.jsxs)(`span`,{className:`perm-editable-name${n?` ${n}`:``}`,onDoubleClick:e=>{e.stopPropagation(),i(!0)},children:[e,(0,l.jsx)(c.EditOutlined,{className:`perm-name-edit-icon`})]})}function zN({entry:e,label:t,onToggle:n,onLabelSave:r}){let[i,a]=(0,o.useState)(!1),[u,d]=(0,o.useState)(t),f=e?.value===`1`,p=!!e;(0,o.useEffect)(()=>{d(t)},[t]);function m(){a(!1);let e=u.trim();e&&e!==t?r(e):d(t)}return(0,l.jsx)(s.Tooltip,{title:p?f?`Click to disable`:`Click to enable`:`Not applicable for this module`,children:(0,l.jsxs)(`div`,{className:`perm-action-pill${f?` on`:``}${p?``:` na`}`,onClick:()=>{!i&&p&&n()},children:[(0,l.jsx)(`span`,{className:`perm-action-pill-dot${f?` on`:``}`}),i?(0,l.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`&&(a(!1),d(t)),e.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,l.jsx)(`span`,{className:`perm-action-pill-label`,onDoubleClick:e=>{e.stopPropagation(),a(!0)},children:t}),f&&!i&&(0,l.jsx)(c.CheckOutlined,{className:`perm-action-pill-check`})]})})}function BN({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:o,onActionLabelSave:s}){let c=t?.permissions??{},u=n.filter(t=>Kx(e,t)),d=u.filter(e=>c[e]?.value===`1`).length,f=u.filter(e=>c[e]).length,p=f>0&&d===f;return(0,l.jsxs)(`div`,{className:`perm-module-card${p?` all-on`:d>0&&!p?` some-on`:``}`,children:[(0,l.jsxs)(`div`,{className:`perm-module-card-header`,children:[(0,l.jsx)(RN,{value:i,onSave:t=>o(e,t),className:`perm-module-card-name`}),f>0&&(0,l.jsxs)(`span`,{className:`perm-module-card-badge${d>0?` active`:``}`,children:[d,`/`,f]})]}),(0,l.jsx)(`div`,{className:`perm-module-card-body`,children:u.map(t=>(0,l.jsx)(zN,{entry:c[t],label:a[t]??NN(t),onToggle:()=>r(e,t),onLabelSave:e=>s(t,e)},t))})]})}function VN({role:e,moduleLabels:t={},actionLabels:r={},onModuleLabelSave:i=()=>{},onActionLabelSave:a=()=>{}}){let[u,d]=(0,o.useState)({}),[f,p]=(0,o.useState)({}),[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(!1),b=n.Kr(e);(0,o.useEffect)(()=>{b&&(h(!0),y(!1),n.Yr(b).then(e=>{let t=LN(e);d(t),p(t)}).catch(()=>s.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 n.bi(b,f),d(f),y(!1),s.message.success(`Permissions saved`)}catch(e){s.message.error(e?.message||`Save failed`)}finally{_(!1)}}let C=(0,o.useMemo)(()=>Object.keys(f).sort(),[f]),w=(0,o.useMemo)(()=>FN(f),[f]),{enabled:T,total:E}=(0,o.useMemo)(()=>IN(f),[f]);return(0,l.jsxs)(s.Spin,{spinning:m,children:[(0,l.jsxs)(`div`,{className:`perm-panel-header`,children:[(0,l.jsxs)(`div`,{className:`perm-panel-title`,children:[(0,l.jsx)(c.LockOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),(0,l.jsx)(`span`,{children:e?.roleName}),!m&&E>0&&(0,l.jsxs)(s.Tag,{color:`blue`,style:{marginLeft:8,fontSize:11},children:[T,`/`,E,` enabled`]})]}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.UnlockOutlined,{}),loading:g,disabled:!v,onClick:S,children:`Save Changes`})]}),(0,l.jsxs)(`div`,{className:`perm-hint`,children:[(0,l.jsx)(c.InfoCircleOutlined,{className:`perm-hint-icon`}),(0,l.jsxs)(`span`,{children:[`Click a pill to toggle. `,(0,l.jsx)(`strong`,{children:`Double-click`}),` a module name or action label to rename it — labels are saved locally.`]})]}),C.length===0&&!m?(0,l.jsx)(`div`,{className:`perm-empty`,children:`No permission entries found for this role.`}):(0,l.jsx)(`div`,{className:`perm-cards-grid`,children:C.map(e=>(0,l.jsx)(BN,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:t[e]??e,actionLabels:r,onModuleLabelSave:i,onActionLabelSave:a},e))})]})}var{Text:HN}=s.Typography,UN=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function WN(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function GN(e){return String(e||``).trim().toLowerCase()}function KN(e){return e?.key||e?.collectionName||e?.value||``}function qN(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=KN(e);if(!t)return;let o=GN(e.key||t),s=GN(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||WN(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=GN(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:WN(t),value:t,disabled:!1}))}),n}function JN(){let[e,t]=(0,o.useState)(null),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(`listView`),[d,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(0),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)([]),[x,S]=(0,o.useState)(!1),[C,w]=(0,o.useState)(!1),T=(0,o.useMemo)(()=>_.filter(e=>!e.disabled),[_]),E=!x&&T.length===0,D=(0,o.useCallback)(async()=>{g(!0);try{let e=await n._r();f(e.roles),m(e.total)}catch{s.message.error(`Failed to load roles`)}finally{g(!1)}},[]),O=(0,o.useCallback)(async()=>{S(!0);try{let[e,t]=await Promise.all([n.kr(),n.xr()]),r=qN(e.modules,t),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));v(r),b(e=>e.filter(e=>i.has(e)))}catch{s.message.error(`Failed to load seed status`)}finally{S(!1)}},[]);(0,o.useEffect)(()=>{D()},[D]),(0,o.useEffect)(()=>{O()},[O]);async function k(){if(y.length===0){s.message.warning(E?`All modules already seeded.`:`Select at least one module to seed.`);return}w(!0);try{await n.di(y),s.message.success(`Role field config seeded`),b([]),await O()}catch(e){s.message.error(e?.message||`Seed failed`)}finally{w(!1)}}function A(e,n=`listView`){t(e),u(n),i(!0)}return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,l.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,l.jsx)(s.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,l.jsx)(s.Button,{type:`primary`,loading:C,disabled:x||y.length===0,onClick:k,children:`Seed Field Config`})]}),(0,l.jsx)(HN,{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,l.jsx)(Z,{icon:(0,l.jsx)(c.SafetyOutlined,{}),title:`Roles`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,l.jsx)($m,{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,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Button,{size:`small`,type:`link`,onClick:()=>A(t),children:`Configure`}),(0,l.jsx)(s.Button,{size:`small`,type:`link`,icon:(0,l.jsx)(c.LockOutlined,{}),onClick:()=>A(t,`permissions`),children:`Permissions`})]})}],loading:h,total:p})}),(0,l.jsxs)(s.Modal,{className:`uss-modal`,open:r,onCancel:()=>i(!1),title:(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(c.SafetyOutlined,{style:{color:`var(--color-brand)`}}),(0,l.jsxs)(`span`,{children:[`Configure: `,e?.roleName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,l.jsx)(`div`,{style:{marginBottom:12},children:(0,l.jsx)(`div`,{className:`uss-config-toggle`,children:UN.map(e=>(0,l.jsx)(`button`,{className:`uss-config-btn${a===e.key?` active`:``}`,onClick:()=>u(e.key),children:e.label},e.key))})}),e&&(a===`permissions`?(0,l.jsx)(VN,{role:e},e?.roleId):(0,l.jsx)(lS,{role:e,configType:a},`${e?.roleId}-${a}`))]})]})}var YN=`perm-module-labels`,XN=`perm-action-labels`;function ZN(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function QN(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function $N({label:e,onSave:t,onDelete:n,loading:r}){let[i,a]=(0,o.useState)(!1),[u,d]=(0,o.useState)(e);function f(){a(!1);let n=u.trim();n&&n!==e?t(n):d(e)}return(0,l.jsxs)(`div`,{className:`perm-manage-row`,children:[i?(0,l.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`&&(a(!1),d(e))}}):(0,l.jsx)(`span`,{className:`perm-manage-row-label`,children:e}),(0,l.jsxs)(`div`,{className:`perm-manage-row-actions`,children:[(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{d(e),a(!0)},loading:r}),(0,l.jsx)(s.Popconfirm,{title:`Delete this item?`,onConfirm:n,okText:`Delete`,cancelText:`Cancel`,okType:`danger`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.DeleteOutlined,{}),danger:!0})})]})]})}function eP({open:e,onClose:t}){let[r,i]=(0,o.useState)(`modules`),[a,u]=(0,o.useState)([]),[d,f]=(0,o.useState)(!1),[p,m]=(0,o.useState)(``),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)(``),[T,E]=(0,o.useState)(!1);(0,o.useEffect)(()=>{e&&(D(),O())},[e]);async function D(){f(!0);try{u(await n.Ir())}catch{s.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await n.Fr())}catch{s.message.error(`Failed to load actions`)}finally{b(!1)}}async function k(){let e=p.trim();if(!e){s.message.warning(`Enter a module name`);return}g(!0);try{let t=await n.Qn({menuName:e});u(e=>[...e,t]),m(``),s.message.success(`Module added`)}catch{s.message.error(`Failed to add module`)}finally{g(!1)}}async function A(e,t){try{await n.gi(e,{menuName:t}),u(n=>n.map(n=>n.MENUID===e?{...n,MENUNAME:t}:n))}catch{s.message.error(`Failed to update module`)}}async function j(e){try{await n.sr(e),u(t=>t.filter(t=>t.MENUID!==e)),s.message.success(`Module deleted`)}catch{s.message.error(`Failed to delete module`)}}async function M(){let e=x.trim(),t=C.trim().toLowerCase().replace(/\s+/g,`_`);if(!e||!t){s.message.warning(`Enter both name and key`);return}E(!0);try{let r=await n.Zn({permissionName:e,permissionKey:t});v(e=>[...e,r]),S(``),w(``),s.message.success(`Action added`)}catch(e){s.message.error(e?.message?.includes(`409`)||e?.status===409?`Permission key already exists`:`Failed to add action`)}finally{E(!1)}}async function N(e,t){try{await n.hi(e,{permissionName:t}),v(n=>n.map(n=>n.permissionId===e?{...n,permissionName:t}:n))}catch{s.message.error(`Failed to update action`)}}async function P(e){try{await n.or(e),v(t=>t.filter(t=>t.permissionId!==e)),s.message.success(`Action deleted`)}catch{s.message.error(`Failed to delete action`)}}let F=[{key:`modules`,label:`Modules`,children:(0,l.jsxs)(s.Spin,{spinning:d,children:[(0,l.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,l.jsx)(s.Input,{placeholder:`Module name`,value:p,onChange:e=>m(e.target.value),onPressEnter:k,style:{flex:1},size:`small`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.PlusOutlined,{}),loading:h,onClick:k,children:`Add`})]}),(0,l.jsxs)(`div`,{className:`perm-manage-list`,children:[a.length===0&&!d&&(0,l.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No modules found`}),a.map(e=>(0,l.jsx)($N,{label:e.MENUNAME,onSave:t=>A(e.MENUID,t),onDelete:()=>j(e.MENUID)},e.MENUID))]})]})},{key:`actions`,label:`Actions`,children:(0,l.jsxs)(s.Spin,{spinning:y,children:[(0,l.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,l.jsx)(s.Input,{placeholder:`Action name (e.g. Approve)`,value:x,onChange:e=>S(e.target.value),style:{flex:1},size:`small`}),(0,l.jsx)(s.Input,{placeholder:`Key (e.g. approve)`,value:C,onChange:e=>w(e.target.value),onPressEnter:M,style:{width:140},size:`small`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.PlusOutlined,{}),loading:T,onClick:M,children:`Add`})]}),(0,l.jsxs)(`div`,{className:`perm-manage-list`,children:[_.length===0&&!y&&(0,l.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No actions found`}),_.map(e=>(0,l.jsx)($N,{label:`${e.permissionName} (${e.permissionKey})`,onSave:t=>N(e.permissionId,t),onDelete:()=>P(e.permissionId)},e.permissionId))]})]})}];return(0,l.jsx)(s.Modal,{open:e,onCancel:t,title:(0,l.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(c.SettingOutlined,{style:{color:`var(--color-brand)`}}),`Manage Modules & Actions`]}),width:520,footer:null,destroyOnClose:!0,children:(0,l.jsx)(s.Tabs,{activeKey:r,onChange:i,size:`small`,items:F})})}function tP(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(null),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(()=>ZN(YN)),[_,v]=(0,o.useState)(()=>ZN(XN)),y=(0,o.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return QN(YN,r),r})},[]),b=(0,o.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return QN(XN,r),r})},[]);function x(){g({}),v({}),QN(YN,{}),QN(XN,{}),s.message.success(`Labels reset to defaults`)}let S=(0,o.useCallback)(async()=>{i(!0);try{let{roles:e}=await n._r();t(e),e.length>0&&u(e[0])}catch{s.message.error(`Failed to load roles`)}finally{i(!1)}},[]);(0,o.useEffect)(()=>{S()},[S]);let C=(0,o.useMemo)(()=>{let t=d.trim().toLowerCase();return t?e.filter(e=>e.roleName.toLowerCase().includes(t)):e},[e,d]),w=Object.keys(h).length>0||Object.keys(_).length>0;return(0,l.jsxs)(`div`,{className:`perm-page`,children:[(0,l.jsxs)(Z,{className:`perm-left-card`,icon:(0,l.jsx)(c.SafetyOutlined,{}),title:`Roles`,bodyStyle:{padding:0},children:[(0,l.jsx)(`div`,{className:`perm-role-search`,children:(0,l.jsx)(s.Input,{prefix:(0,l.jsx)(c.SearchOutlined,{}),placeholder:`Search roles…`,allowClear:!0,size:`small`,value:d,onChange:e=>f(e.target.value)})}),(0,l.jsx)(s.Spin,{spinning:r,children:(0,l.jsxs)(`div`,{className:`perm-role-list`,children:[C.length===0&&!r&&(0,l.jsx)(`div`,{className:`perm-role-empty`,children:`No roles found`}),C.map(e=>{let t=a?.roleId===e.roleId,n=e.description&&e.description!==`N/A`?e.description:e.roleType===0?`Default role`:`Custom role`;return(0,l.jsxs)(`div`,{className:`perm-role-item${t?` active`:``}`,onClick:()=>u(e),children:[(0,l.jsx)(`div`,{className:`perm-role-item-name`,children:e.roleName}),(0,l.jsx)(`div`,{className:`perm-role-item-desc`,children:n})]},e.roleId)})]})})]}),(0,l.jsx)(Z,{className:`perm-right-card`,icon:(0,l.jsx)(c.LockOutlined,{}),title:`Module Permissions`,extra:(0,l.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[w&&(0,l.jsx)(`button`,{className:`perm-reset-btn`,onClick:x,children:`Reset labels`}),(0,l.jsx)(s.Button,{size:`small`,icon:(0,l.jsx)(c.SettingOutlined,{}),onClick:()=>m(!0),children:`Manage`})]}),bodyStyle:{padding:`12px 16px`},children:a?(0,l.jsx)(VN,{role:a,moduleLabels:h,actionLabels:_,onModuleLabelSave:y,onActionLabelSave:b},a.roleId):(0,l.jsx)(`div`,{className:`perm-empty`,children:`Select a role from the left to manage its permissions.`})}),(0,l.jsx)(eP,{open:p,onClose:()=>m(!1)})]})}var{Title:nP,Text:rP}=s.Typography,iP=[{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 aP({items:e=iP}){return(0,l.jsx)(s.Card,{className:`onboarding-card`,title:(0,l.jsx)(nP,{level:5,children:`Onboarding`}),extra:(0,l.jsx)(s.Button,{type:`link`,children:`View all`}),children:(0,l.jsx)(s.Row,{gutter:[12,12],children:e.map(e=>(0,l.jsx)(s.Col,{xs:12,sm:6,md:6,lg:12,xl:12,children:(0,l.jsxs)(`div`,{className:`onboarding-item ${e.color}`,children:[(0,l.jsx)(rP,{className:`onboarding-item-label`,children:e.label}),(0,l.jsx)(s.Statistic,{value:e.value,className:`onboarding-stat`}),(0,l.jsx)(`div`,{className:`onboarding-item-footer`,children:(0,l.jsx)(rP,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:oP,Title:sP}=s.Typography,cP=[{group:`Dashboard`,items:[{id:`dashboard`,label:`Admin Dashboard`,icon:(0,l.jsx)(c.DashboardOutlined,{})}]},{group:`Settings`,items:[{id:`org`,label:`Organization`,icon:(0,l.jsx)(c.BankOutlined,{}),heading:`Organization Settings`,desc:`Manage your company profile and location details`,cards:[{label:`Company Information`,icon:(0,l.jsx)(c.BankOutlined,{}),desc:`Manage company profile, address and business details.`},{label:`Location`,icon:(0,l.jsx)(c.BuildOutlined,{}),desc:`Manage office locations, branches and regions.`}]},{id:`users`,label:`Users`,icon:(0,l.jsx)(c.UserOutlined,{}),heading:`Users`,desc:`Manage platform users and configure their field views.`,component:`users`},{id:`teams`,label:`Teams`,icon:(0,l.jsx)(c.TeamOutlined,{}),heading:`Teams`,desc:`Organize users into teams and configure field visibility per team.`,component:`teams`},{id:`roles`,label:`Roles`,icon:(0,l.jsx)(c.SafetyOutlined,{}),heading:`Roles`,desc:`Control permissions and configure field visibility per role.`,component:`roles`},{id:`permissions`,label:`Permissions`,icon:(0,l.jsx)(c.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,l.jsx)(c.FileTextOutlined,{}),heading:`Templates`,desc:`Email and signature templates for communications`,component:`templates`},{id:`ai-services`,label:`AI Services`,icon:(0,l.jsx)(c.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,l.jsx)(c.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,l.jsx)(c.BankOutlined,{}),heading:`Clients`,desc:`Manage client accounts and settings`,cards:[{label:`Clients`,icon:(0,l.jsx)(c.BankOutlined,{}),desc:`Manage client companies and account details.`}]}]},{group:`Forms`,items:[{id:`form-groups`,label:`Form Groups`,icon:(0,l.jsx)(c.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,l.jsx)(c.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,l.jsx)(c.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,l.jsx)(c.AppstoreOutlined,{}),heading:`Jobs Master`,desc:`Configure job sources and status types`,cards:[{label:`Sources`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),desc:`Manage job source master values.`},{label:`Job Status`,icon:(0,l.jsx)(c.CheckCircleOutlined,{}),desc:`Configure job workflow status.`}]},{id:`candidates`,label:`Candidates`,icon:(0,l.jsx)(c.UserOutlined,{}),heading:`Candidates Master`,desc:`Skills, sources and work authorization settings`,cards:[{label:`Sources`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),desc:`Manage candidate source values.`},{label:`Skills`,icon:(0,l.jsx)(c.SettingOutlined,{}),desc:`Manage skill master data.`},{label:`Work Authorization`,icon:(0,l.jsx)(c.SafetyOutlined,{}),desc:`Manage visa and authorization types.`}]},{id:`submissions`,label:`Submissions`,icon:(0,l.jsx)(c.FileTextOutlined,{}),heading:`Submissions Master`,desc:`Rejection reasons and submission status configuration`,cards:[{label:`Rejection Reasons`,icon:(0,l.jsx)(c.FileTextOutlined,{}),desc:`Manage common rejection reasons.`},{label:`Client Submission Status`,icon:(0,l.jsx)(c.CheckCircleOutlined,{}),desc:`Manage client submission statuses.`}]},{id:`clientmaster`,label:`Client Master`,icon:(0,l.jsx)(c.BankOutlined,{}),heading:`Client Master`,desc:`Payment terms, client types and contact types`,cards:[{label:`Payment Terms`,icon:(0,l.jsx)(c.FileTextOutlined,{}),desc:`Manage billing and payment terms.`},{label:`Client Type`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),desc:`Classify client business types.`},{label:`Client Contact Type`,icon:(0,l.jsx)(c.TeamOutlined,{}),desc:`Manage client contact categories.`}]}]}],lP=[{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}],uP=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],dP=[{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 fP(){return(0,l.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.DashboardOutlined,{}),title:`Admin Dashboard`,children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(sP,{level:5,children:`Admin Dashboard`}),(0,l.jsx)(oP,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,l.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,l.jsx)(bN,{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,l.jsxs)(`div`,{className:`admin-dashboard-mid-row`,children:[(0,l.jsx)(aP,{}),(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,l.jsx)(oP,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,l.jsx)(`div`,{className:`admin-pipeline-bar`,children:lP.map(e=>(0,l.jsx)(`div`,{className:`admin-pipeline-seg`,style:{width:`${e.pct}%`,background:e.color}},e.label))}),(0,l.jsx)(`div`,{className:`admin-pipeline-legend`,children:lP.map(e=>(0,l.jsxs)(`div`,{className:`admin-pipeline-legend-item`,children:[(0,l.jsx)(`span`,{className:`admin-pipeline-dot`,style:{background:e.color}}),e.label,` `,e.count]},e.label))}),(0,l.jsx)(`div`,{className:`admin-divider`}),(0,l.jsx)(oP,{strong:!0,style:{fontSize:12},children:`Submission status`}),(0,l.jsxs)(`div`,{className:`admin-sub-status-list`,style:{marginTop:6},children:[(0,l.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,l.jsx)(oP,{style:{fontSize:13},children:`Pending client review`}),(0,l.jsx)(`span`,{className:`admin-badge warn`,children:`312`})]}),(0,l.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,l.jsx)(oP,{style:{fontSize:13},children:`Client approved`}),(0,l.jsx)(`span`,{className:`admin-badge success`,children:`248`})]}),(0,l.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,l.jsx)(oP,{style:{fontSize:13},children:`Rejected`}),(0,l.jsx)(`span`,{className:`admin-badge danger`,children:`89`})]})]})]})]}),(0,l.jsxs)(`div`,{className:`admin-dashboard-bottom-row`,children:[(0,l.jsx)(Z,{icon:(0,l.jsx)(c.BankOutlined,{}),title:`Top Clients`,extra:(0,l.jsx)(s.Button,{type:`link`,size:`small`,children:`View all`}),children:uP.map(e=>(0,l.jsxs)(`div`,{className:`admin-client-row`,children:[(0,l.jsxs)(`div`,{className:`admin-client-left`,children:[(0,l.jsx)(`div`,{className:`admin-client-icon`,children:(0,l.jsx)(c.BankOutlined,{})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`admin-client-name`,children:e.name}),(0,l.jsxs)(`div`,{className:`admin-client-sub`,children:[e.jobs,` open jobs`]})]})]}),(0,l.jsxs)(`div`,{className:`admin-client-right`,children:[(0,l.jsx)(`div`,{className:`admin-client-val`,children:e.candidates}),(0,l.jsx)(`div`,{className:`admin-client-sub`,children:`candidates`})]})]},e.name))}),(0,l.jsx)(Z,{icon:(0,l.jsx)(c.BellOutlined,{}),title:`Recent Activity`,children:dP.map((e,t)=>(0,l.jsxs)(`div`,{className:`admin-activity-row`,children:[(0,l.jsx)(`div`,{className:`admin-activity-dot`,style:{background:e.color}}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`admin-activity-text`,children:e.text}),(0,l.jsx)(`div`,{className:`admin-activity-time`,children:e.time})]})]},t))})]}),(0,l.jsx)(Z,{icon:(0,l.jsx)(c.SettingOutlined,{}),title:`Admin Configuration Overview`,extra:(0,l.jsx)(s.Button,{type:`link`,size:`small`,children:`Manage`}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsxs)(s.Col,{span:8,children:[(0,l.jsx)(oP,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Settings`}),[[`Organization`,2],[`User Settings`,4],[`Templates`,2]].map(([e,t])=>(0,l.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,l.jsx)(oP,{style:{fontSize:12},children:e}),(0,l.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,l.jsxs)(s.Col,{span:8,children:[(0,l.jsx)(oP,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Master`}),[[`Jobs`,2],[`Candidates`,3],[`Submissions`,2]].map(([e,t])=>(0,l.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,l.jsx)(oP,{style:{fontSize:12},children:e}),(0,l.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,l.jsxs)(s.Col,{span:8,children:[(0,l.jsx)(oP,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`System`}),[[`Total Groups`,4],[`Total Modules`,9],[`Config Items`,19]].map(([e,t])=>(0,l.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,l.jsx)(oP,{style:{fontSize:12},children:e}),(0,l.jsx)(oP,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function pP({activeSection:e,activeGroup:t,filteredCards:n,searchText:r,setSearchText:i,allItems:a,handleNav:o}){return(0,l.jsxs)(s.Row,{gutter:[16,16],children:[(0,l.jsx)(s.Col,{span:24,children:(0,l.jsxs)(Z,{icon:e?.icon,title:e?.heading,extra:(0,l.jsx)(s.Input,{className:`admin-search`,prefix:(0,l.jsx)(c.SearchOutlined,{}),placeholder:`Search settings…`,allowClear:!0,value:r,onChange:e=>i(e.target.value)}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(sP,{level:5,children:e?.heading}),(0,l.jsx)(oP,{type:`secondary`,children:e?.desc})]})}),(0,l.jsx)(s.Col,{xs:24,xl:16,style:{alignSelf:`flex-start`},children:(0,l.jsx)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Configuration Items`,extra:(0,l.jsxs)(oP,{type:`secondary`,children:[n.length,` item`,n.length===1?``:`s`]}),children:(0,l.jsx)(s.Row,{gutter:[14,14],children:n.length>0?n.map(e=>(0,l.jsx)(s.Col,{xs:24,sm:12,xl:8,children:(0,l.jsxs)(`div`,{className:`admin-config-item`,children:[(0,l.jsx)(`div`,{className:`admin-config-top-bar`}),(0,l.jsxs)(`div`,{className:`admin-config-body`,children:[(0,l.jsx)(`div`,{className:`admin-config-icon`,children:e.icon}),(0,l.jsxs)(`div`,{className:`admin-config-text`,children:[(0,l.jsx)(`span`,{className:`admin-config-label`,children:e.label}),(0,l.jsx)(`span`,{className:`admin-config-desc`,children:e.desc})]})]}),(0,l.jsx)(`div`,{className:`admin-config-divider`}),(0,l.jsx)(s.Button,{type:`link`,size:`small`,className:`admin-config-manage`,icon:(0,l.jsx)(c.RightOutlined,{}),iconPosition:`end`,children:`Manage`})]})},e.label)):(0,l.jsx)(s.Col,{span:24,children:(0,l.jsx)(`div`,{className:`admin-config-empty`,children:(0,l.jsx)(s.Empty,{description:`No settings found`,image:s.Empty.PRESENTED_IMAGE_SIMPLE})})})})})}),(0,l.jsx)(s.Col,{xs:24,xl:8,style:{alignSelf:`flex-start`},children:(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`Section Overview`,children:[(0,l.jsx)(`div`,{className:`admin-overview-list`,children:cP.filter(e=>e.group!==`Dashboard`).map(e=>{let n=e.group===t?.group;return(0,l.jsxs)(`div`,{className:`admin-overview-item${n?` active`:``}`,onClick:()=>{let t=e.items[0];t&&o(t.id)},children:[(0,l.jsxs)(`div`,{className:`admin-overview-left`,children:[(0,l.jsx)(`div`,{className:`admin-overview-icon`,children:e.items[0]?.icon}),(0,l.jsxs)(`div`,{className:`admin-overview-text`,children:[(0,l.jsx)(`span`,{className:`admin-overview-name`,children:e.group}),(0,l.jsxs)(`span`,{className:`admin-overview-sub`,children:[e.items.length,` module`,e.items.length===1?``:`s`]})]})]}),(0,l.jsx)(`span`,{className:`admin-overview-count${n?` active`:``}`,children:e.items.length})]},e.group)})}),(0,l.jsxs)(`div`,{className:`admin-overview-footer`,children:[(0,l.jsx)(`span`,{className:`admin-overview-footer-label`,children:`Total configuration items`}),(0,l.jsx)(`span`,{className:`admin-overview-footer-value`,children:a.filter(e=>e.cards).reduce((e,t)=>e+t.cards.length,0)})]})]})})]})}function mP(){let[e,t]=(0,o.useState)(`dashboard`),[n,r]=(0,o.useState)(``),i=(0,o.useMemo)(()=>cP.flatMap(e=>e.items),[]),a=(0,o.useMemo)(()=>i.find(t=>t.id===e),[i,e]),u=(0,o.useMemo)(()=>cP.find(t=>t.items.some(t=>t.id===e)),[e]),d=(0,o.useMemo)(()=>{if(!a?.cards)return[];let e=n.trim().toLowerCase();return e?a.cards.filter(t=>t.label.toLowerCase().includes(e)||t.desc.toLowerCase().includes(e)):a.cards},[a,n]),f=(0,o.useMemo)(()=>cP.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),r(``)};return e===`dashboard`||a?.heading,(0,l.jsxs)(`main`,{className:`admin-page`,children:[(0,l.jsx)(`div`,{className:`admin-breadcrumb`,children:(0,l.jsx)(s.Breadcrumb,{items:[{title:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.HomeOutlined,{}),` Home`]})},{title:`Admin`}]})}),(0,l.jsxs)(s.Row,{gutter:[16,16],className:`admin-wrapper`,children:[(0,l.jsx)(s.Col,{xs:24,lg:6,xl:5,children:(0,l.jsxs)(Z,{title:`Admin Console`,icon:(0,l.jsx)(c.SettingOutlined,{}),children:[(0,l.jsxs)(`div`,{className:`admin-sidebar-banner`,children:[(0,l.jsx)(`span`,{className:`admin-sidebar-banner-title`,children:`Admin Panel`}),(0,l.jsx)(`span`,{className:`admin-sidebar-banner-sub`,children:`Configuration Center`}),(0,l.jsxs)(s.Row,{gutter:[8,0],children:[(0,l.jsx)(s.Col,{span:12,children:(0,l.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,l.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Groups`}),(0,l.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:cP.length})]})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,l.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Modules`}),(0,l.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:i.length})]})})]})]}),(0,l.jsx)(s.Menu,{mode:`inline`,selectedKeys:[e],items:f,onClick:({key:e})=>p(e),className:`admin-sidebar-menu`})]})}),(0,l.jsx)(s.Col,{xs:24,lg:18,xl:19,children:e===`dashboard`?(0,l.jsx)(fP,{}):a?.component===`form-groups`?(0,l.jsx)(ow,{}):a?.component===`detail-groups`?(0,l.jsx)(Vw,{}):a?.component===`row-actions`?(0,l.jsx)(AT,{}):a?.component===`users`?(0,l.jsx)(wN,{}):a?.component===`teams`?(0,l.jsx)(AN,{}):a?.component===`roles`?(0,l.jsx)(JN,{}):a?.component===`permissions`?(0,l.jsx)(tP,{}):a?.component===`templates`?(0,l.jsx)(HT,{}):a?.component===`ai-services`?(0,l.jsx)(KT,{}):a?.component===`bgc-integration`?(0,l.jsx)(QT,{}):(0,l.jsx)(pP,{activeSection:a,activeGroup:u,filteredCards:d,searchText:n,setSearchText:r,allItems:i,handleNav:p})})]})]})}var{Title:hP}=s.Typography;function gP(){let e=(0,d.useNavigate)(),{state:t}=(0,d.useLocation)(),n=t?.moduleName||`stickyNotes`,r=t?.title||`Sticky Notes`,i={...t?.request,params:{...t?.request?.params,limit:200,offset:0}};return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.ArrowLeftOutlined,{}),onClick:()=>e(-1),style:{marginBottom:12},children:`Back`}),(0,l.jsx)(Rt,{moduleName:n,title:r,columns:4,request:i,viewAll:!1})]})}var{Text:_P,Title:vP}=s.Typography,yP=10485760,bP=`/templates/test_cases_flow_template.base64.txt`,xP=`test_cases_flow_template.xlsx`,SP=`module | subModule | step_order | description | actions | key | value | expected | scenario`,CP={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},wP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function TP(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 EP(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function DP(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function OP({errors:e}){return(0,l.jsx)(`div`,{className:`bulk-tooltip-errors`,children:(e??[]).map((e,t)=>(0,l.jsx)(`div`,{children:e.message},`${e.field}-${t}`))})}function kP({errors:e,expanded:t,onToggle:n,onSummaryClick:r}){return e.length===0?null:(0,l.jsxs)(`div`,{className:`bulk-error-banner`,children:[(0,l.jsxs)(`div`,{className:`bulk-error-summary`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`bulk-error-summary-main`,onClick:r,"aria-label":`Scroll to first invalid row`,children:[(0,l.jsx)(c.ExclamationCircleOutlined,{className:`bulk-error-icon`}),(0,l.jsxs)(`span`,{children:[e.length,` validation error(s) found`]})]}),(0,l.jsx)(s.Button,{type:`link`,onClick:n,"aria-expanded":t,children:t?`Hide Errors`:`View Errors`})]}),t&&(0,l.jsx)(`div`,{className:`bulk-error-list`,role:`region`,"aria-label":`Validation error details`,children:e.map((e,t)=>(0,l.jsxs)(`div`,{className:`bulk-error-line`,children:[(0,l.jsxs)(`span`,{className:`bulk-row-chip`,children:[`Row `,e.id]}),(0,l.jsx)(`span`,{children:e.message})]},`${e.id}-${e.field}-${t}`))})]})}function AP({rows:e,view:t,onViewChange:n,onConfirm:r,onReset:i,saving:a,firstInvalidRowId:o,firstInvalidRowRef:u}){let d=e.filter(e=>e.row_status===`invalid`),f=t===`errors`?d:e,p=d.length>0||a;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(s.Row,{justify:`space-between`,align:`middle`,gutter:[16,16],className:`bulk-table-toolbar`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space.Compact,{children:[(0,l.jsx)(s.Button,{type:t===`all`?`primary`:`default`,onClick:()=>n(`all`),children:`All rows`}),(0,l.jsx)(s.Button,{type:t===`errors`?`primary`:`default`,onClick:()=>n(`errors`),children:`Errors only`})]})}),(0,l.jsx)(s.Col,{children:(0,l.jsxs)(_P,{type:`secondary`,children:[e.length,` row(s)`]})})]}),(0,l.jsx)(`div`,{className:`bulk-table-wrap`,children:(0,l.jsxs)(`table`,{className:`bulk-preview-table`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:`bulk-col-row`,children:`Row`}),(0,l.jsx)(`th`,{className:`bulk-col-flow`,children:`Submodule`}),(0,l.jsx)(`th`,{className:`bulk-col-description`,children:`Description`}),(0,l.jsx)(`th`,{className:`bulk-col-keyword`,children:`Action`}),(0,l.jsx)(`th`,{className:`bulk-col-target`,children:`Key`}),(0,l.jsx)(`th`,{className:`bulk-col-status`,children:`Status`}),(0,l.jsx)(`th`,{className:`bulk-col-error`,children:`Error`})]})}),(0,l.jsx)(`tbody`,{children:f.map(e=>{let t=e.errors??[],n=e.row_status===`invalid`;return(0,l.jsxs)(`tr`,{ref:n&&e.id===o?u:null,className:n?`bulk-row-invalid`:``,children:[(0,l.jsx)(`td`,{children:e.id}),(0,l.jsx)(`td`,{title:e.submodule,children:e.submodule}),(0,l.jsx)(`td`,{title:e.description,children:e.description?e.description:(0,l.jsx)(`span`,{className:`bulk-empty-text`,children:`-empty-`})}),(0,l.jsx)(`td`,{children:(0,l.jsx)(`code`,{className:`bulk-code-chip`,children:e.actions})}),(0,l.jsx)(`td`,{title:e.key,children:e.key}),(0,l.jsx)(`td`,{children:n?(0,l.jsx)(s.Tag,{color:`red`,children:`Error`}):(0,l.jsx)(s.Tag,{color:`green`,children:`Valid`})}),(0,l.jsx)(`td`,{children:n?(0,l.jsx)(s.Tooltip,{title:(0,l.jsx)(OP,{errors:t}),placement:`left`,children:(0,l.jsxs)(`button`,{type:`button`,className:`bulk-error-info`,"aria-label":`View ${t.length} error(s) for row ${e.id}`,children:[(0,l.jsx)(c.InfoCircleOutlined,{}),(0,l.jsx)(s.Badge,{count:t.length,size:`small`})]})}):(0,l.jsx)(`span`,{className:`bulk-error-none`,children:`-`})})]},`${e.id}-${e.step_order}`)})})]})}),(0,l.jsxs)(s.Space,{className:`bulk-actions`,children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:i,children:`Reset`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:a,disabled:p,onClick:r,children:d.length>0?`Fix ${d.length} error(s) to proceed`:`Save to database`})]})]})}function jP(){let e=(0,d.useNavigate)(),r=(0,o.useMemo)(()=>t.l(),[]),i=(0,o.useRef)(null),a=(0,o.useRef)(null),[u,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(``),[h,g]=(0,o.useState)(`idle`),[_,v]=(0,o.useState)(!1),[y,b]=(0,o.useState)(null),[x,S]=(0,o.useState)([]),[C,w]=(0,o.useState)(`all`),[T,E]=(0,o.useState)(null),[D,O]=(0,o.useState)(null),[k,A]=(0,o.useState)(!1),j=u.map(e=>({value:e.modulename,label:e.modulename})),M=DP(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=CP[h]??0,I=x.find(e=>e.row_status===`invalid`)?.id,L=(0,o.useCallback)(()=>{m(``),g(`idle`),v(!1),b(null),S([]),w(`all`),E(null),O(null),i.current&&(i.current.value=``)},[]);(0,o.useEffect)(()=>{async function e(){try{let e=await Zb({project:r?.name??``,activeOnly:!0});f(e?.items??[])}catch(e){console.error(e),s.message.error(`Unable to load modules.`)}}e()},[r?.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>yP){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 TP(e);g(`validating`);let i=await Kb({filename:e.name,project:r?.name??``,module:p,file_base64:n,file_type:t});S(i?.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(bP);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 i=new Blob([r],{type:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=xP,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),s.message.success(`Sample template downloaded.`)}catch(e){console.error(e),s.message.error(`Unable to download sample template.`)}},V=async()=>{g(`inserting`),E(null);try{let t=await qb({project:r?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:EP(x)});O(t),g(`done`),s.message.success(`Bulk upload saved. Redirecting to view test cases...`),window.setTimeout(()=>e(`/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,o.useCallback)(()=>{a.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[]),ee=[`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,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:wP})}),r?.name&&(0,l.jsx)(s.Col,{children:(0,l.jsx)(_P,{strong:!0,children:r.name})})]}),(0,l.jsxs)(`div`,{className:`zt-page zt-page-wide bulk-page`,children:[(0,l.jsxs)(`div`,{className:`bulk-header`,children:[(0,l.jsx)(vP,{level:3,children:`Bulk upload test cases`}),(0,l.jsxs)(s.Space,{direction:`vertical`,size:4,children:[(0,l.jsx)(_P,{type:`secondary`,children:SP}),(0,l.jsx)(_P,{type:`secondary`,children:`Use the sample template for the required columns. Uploaded rows are saved as Active by default.`})]})]}),(0,l.jsx)(`div`,{className:`bulk-stepbar`,children:[`Select`,`Upload`,`Validate`,`Save`].map((e,t)=>(0,l.jsxs)(`span`,{className:t<F?`bulk-step-active`:``,children:[t+1,` `,e]},e))}),(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:`1. Module selector`,children:(0,l.jsx)(s.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,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:`2. File upload`,extra:(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.DownloadOutlined,{}),onClick:B,children:`Download Sample Template`}),children:[(0,l.jsx)(s.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,l.jsxs)(`button`,{type:`button`,className:ee,disabled:!P,onClick:()=>i.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,l.jsx)(c.CloudUploadOutlined,{className:`bulk-upload-icon`}),y?(0,l.jsxs)(`span`,{className:`bulk-file-chip`,children:[y.name,` - `,Math.ceil(y.size/1024),` KB`]}):(0,l.jsx)(`span`,{children:`Drag & drop here, or click to browse`})]}),(0,l.jsx)(`input`,{ref:i,hidden:!0,type:`file`,accept:`.xlsx,.csv`,onChange:e=>z(e.target.files?.[0])}),N&&(0,l.jsx)(s.Progress,{percent:h===`encoding`?45:82,showInfo:!1,size:`small`}),T&&h!==`preview`&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`})]}),x.length>0&&(0,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:`3. Validation result`,children:[(0,l.jsx)(kP,{errors:M,expanded:k,onToggle:()=>A(e=>!e),onSummaryClick:H}),T&&h===`preview`&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`}),(0,l.jsx)(AP,{rows:x,view:C,onViewChange:w,onConfirm:V,onReset:L,saving:h===`inserting`,firstInvalidRowId:I,firstInvalidRowRef:a})]}),D&&h===`done`&&(0,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:`4. Upload complete`,children:[(0,l.jsxs)(s.Row,{gutter:[16,16],className:`bulk-metrics`,children:[(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(_P,{children:`Total`}),(0,l.jsx)(`strong`,{children:x.length})]})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(_P,{children:`Inserted`}),(0,l.jsx)(`strong`,{children:D.inserted??0})]})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(_P,{children:`Failed`}),(0,l.jsx)(`strong`,{children:D.failed??0})]})})]}),(0,l.jsx)(s.Alert,{type:`success`,showIcon:!0,icon:(0,l.jsx)(c.CheckCircleOutlined,{}),message:`${D.inserted??0} test cases saved to database - module: ${p}`,className:`bulk-inline-alert`}),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:L,children:`Upload another file`})]})]})]})}var MP=[{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:NP}=s.Typography,PP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],FP={tags:`regression`,active:1},IP={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function LP(e=[]){return e.map(e=>({value:e,label:e}))}function RP(e=``){return String(e??``).trim()}function zP(e=``){return RP(e).toLowerCase()}function BP(e=[]){let t=new Map;return e.forEach(e=>{let n=RP(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function VP(e=[],t,n){let r=RP(t).toLowerCase(),i=RP(n).toLowerCase();return e.reduce((e,t)=>{let n=RP(t?.module).toLowerCase(),a=RP(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 HP({icon:e,title:t}){return(0,l.jsxs)(s.Space,{size:10,align:`center`,children:[(0,l.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,l.jsx)(NP,{strong:!0,className:`v1-section-label`,children:t})]})}function UP(){let[e]=s.Form.useForm(),[t]=s.Form.useForm(),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)([]),[f,p]=(0,o.useState)([]),[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)({open:!1,typeKey:`module`}),[b,x]=(0,o.useState)(!1),[S,C]=(0,o.useState)(!1),[w,T]=(0,o.useState)(!1),E=(0,d.useNavigate)(),D=IP[v.typeKey],O=(0,o.useMemo)(()=>LP(r),[r]),k=s.Form.useWatch(`module`,e),A=s.Form.useWatch(`flow`,e),j=!!RP(k),M=!!RP(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&i(t)},I=async()=>{h(!0);try{let e=await Vb(IP.module.dbName);i(e?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),s.message.error(`Unable to load testing options.`)}finally{h(!1)}},L=(0,o.useCallback)(async t=>{let n=RP(t);if(u([]),p([]),e.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await Gb({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];u(t),p(BP(t))}catch(e){console.error(`Unable to load flows:`,e),s.message.error(`Unable to load flows.`)}finally{_(!1)}}},[e]),R=(0,o.useCallback)(async(t,n,r)=>{let i=RP(t),a=RP(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}C(!0);try{e.setFieldsValue({step_order:VP(r,i,a)})}catch(e){console.error(`Unable to load step order:`,e),s.message.error(`Unable to load step order.`)}finally{C(!1)}},[e]);(0,o.useEffect)(()=>{Promise.resolve().then(I)},[]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>L(k))},[L,k]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>R(k,A,a))},[a,R,A,k]);let z=async t=>{let n={module:RP(t.module),flow:RP(t.flow),step_order:Number(t.step_order),description:RP(t.description),keyword:zP(t.keyword),target:RP(t.target),value:RP(t.value),expected:RP(t.expected),tags:t.tags?RP(t.tags):FP.tags,active:Number(t.active)};T(!0);try{await Wb(n),s.message.success(`Test case details saved successfully.`),e.resetFields(),u([]),p([])}catch(e){console.error(`Unable to save test case:`,e),s.message.error(`Unable to save test case.`)}finally{T(!1)}},B=(t,n)=>{e.setFieldsValue({[t]:RP(n)})},V=t=>{e.setFieldsValue({module:RP(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:FP.tags,value:void 0,expected:void 0})},H=t=>{e.setFieldsValue({flow:RP(t),step_order:void 0})},ee=e=>{let n=IP[e];y({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},U=()=>{y(e=>({...e,open:!1})),t.resetFields()},te=async()=>{try{let n=RP((await t.validateFields()).name),r=await Hb({name:n,type:D.dbName});F(v.typeKey,r?.items??[]),e.setFieldsValue({[D.formField]:n}),s.message.success(`${D.label} added successfully.`),U()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),s.message.error(`Unable to add ${D.label.toLowerCase()}.`)}finally{x(!1)}};return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:PP})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>E(`/zinnext-home`),children:`View Table`})})]}),(0,l.jsx)(`div`,{className:`v1-page`,children:(0,l.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,l.jsx)(`div`,{className:`v1-page-header`,children:(0,l.jsxs)(s.Space,{align:`center`,size:10,children:[(0,l.jsx)(c.ProfileOutlined,{className:`v1-outer-icon`}),(0,l.jsx)(`div`,{children:(0,l.jsx)(NP,{strong:!0,style:{fontSize:16},children:`Add Test Case`})})]})}),(0,l.jsx)(Z,{children:(0,l.jsxs)(s.Form,{form:e,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:FP,onFinish:z,autoComplete:`off`,children:[(0,l.jsx)(s.Card,{className:`v1-card`,title:(0,l.jsx)(HP,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,l.jsx)(NP,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsxs)(s.Space.Compact,{style:{width:`100%`},children:[(0,l.jsx)(s.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,loading:m,optionFilterProp:`label`,placeholder:`Select module`,options:O,onChange:V})}),(0,l.jsx)(s.Button,{"aria-label":`Add module`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:30},onClick:()=>ee(`module`)})]})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Flow`,name:`flow`,children:(0,l.jsx)(s.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,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,l.jsx)(s.Input,{maxLength:10,disabled:!0,placeholder:S?`Loading step order`:`Step order`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Action`,name:`keyword`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,disabled:P,optionFilterProp:`label`,placeholder:`Select action`,options:MP,onChange:t=>e.setFieldsValue({keyword:zP(t)})})})}),(0,l.jsx)(s.Col,{xs:24,children:(0,l.jsx)(s.Form.Item,{label:`Description`,name:`description`,children:(0,l.jsx)(s.Input.TextArea,{rows:3,maxLength:255,disabled:P,placeholder:`Enter description`,showCount:!0,onBlur:e=>B(`description`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Key`,name:`target`,children:(0,l.jsx)(s.Input,{maxLength:255,disabled:P,placeholder:`Enter target`,onBlur:e=>B(`target`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Tags`,name:`tags`,children:(0,l.jsx)(s.Input,{maxLength:200,disabled:P,placeholder:`Enter tags`,prefix:(0,l.jsx)(c.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>B(`tags`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Value`,name:`value`,children:(0,l.jsx)(s.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter value`,onBlur:e=>B(`value`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Expected`,name:`expected`,children:(0,l.jsx)(s.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter expected result`,onBlur:e=>B(`expected`,e.target.value)})})})]})}),(0,l.jsx)(`div`,{className:`v1-form-actions`,children:(0,l.jsx)(s.Form.Item,{children:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,loading:w,disabled:P,children:`Submit`}),(0,l.jsx)(s.Button,{onClick:()=>{e.resetFields(),u([]),p([])},children:`Reset`})]})})})]})}),(0,l.jsx)(s.Modal,{title:`Add ${D.label}`,open:v.open,confirmLoading:b,okText:`Add`,onCancel:U,onOk:()=>{x(!0),te()},destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:t,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,l.jsx)(s.Form.Item,{label:`Name`,name:`name`,children:(0,l.jsx)(s.Input,{maxLength:100,placeholder:`Enter ${D.label.toLowerCase()} name`,onBlur:e=>{t.setFieldsValue({name:RP(e.target.value)})}})}),(0,l.jsx)(s.Form.Item,{label:`Type`,name:`type`,children:(0,l.jsx)(s.Input,{disabled:!0})})]})})]})})]})}var{Text:WP}=s.Typography,GP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function KP(e=``){return String(e??``).trim()}function qP(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var JP=[{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,l.jsx)(s.Tag,{color:`green`,children:`Positive`}):(0,l.jsx)(s.Tag,{color:`red`,children:`Negative`})}],YP={key:!1,value:!1,expected:!1};function XP(e,t){return t?e[t]??YP:YP}function ZP(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function QP(){let[e]=s.Form.useForm(),r=(0,d.useNavigate)(),[i]=(0,d.useSearchParams)(),a=i.get(`edit`),u=!!a,f=(0,o.useMemo)(()=>t.l(),[]),[p,m]=(0,o.useState)([]),[h,g]=(0,o.useState)([]),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)(MP),[x,S]=(0,o.useState)({}),[C,w]=(0,o.useState)(!1),[T,E]=(0,o.useState)(!1),[D,O]=(0,o.useState)(!1),[k,A]=(0,o.useState)(!1),[j,M]=(0,o.useState)(!1),N=s.Form.useWatch(`module`,e),P=s.Form.useWatch(`submodule`,e),F=s.Form.useWatch(`actions`,e),I=!!N,L=!!P,R=(0,o.useMemo)(()=>XP(x,F),[x,F]),z=(0,o.useMemo)(()=>qP(p,`modulename`),[p]),B=(0,o.useMemo)(()=>qP(h,`submodulename`),[h]),V=(0,o.useMemo)(()=>p.find(e=>e.id===N)?.modulename??``,[p,N]),H=(0,o.useMemo)(()=>h.find(e=>e.id===P)?.submodulename??``,[P,h]),ee=(0,o.useCallback)(async()=>{try{let e=await Ub();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),s.message.error(`Unable to load action validation rules.`)}},[]),U=(0,o.useCallback)(async e=>{if(!e){m([]);return}w(!0);try{let t=await Zb({project:e,activeOnly:!0});m(t?.items??[])}catch(e){console.error(`Unable to load modules:`,e),s.message.error(`Unable to load modules.`)}finally{w(!1)}},[]),te=(0,o.useCallback)(async(e,t)=>{if(!e||!t){g([]);return}E(!0);try{let n=await ex({project:e,module:t,activeOnly:!0});g(n?.items??[])}catch(e){console.error(`Unable to load submodules:`,e),s.message.error(`Unable to load submodules.`)}finally{E(!1)}},[]),ne=(0,o.useCallback)(async(t,n,r,i=``)=>{if(!t||!n||!r){v([]),e.setFieldsValue({step_order:void 0});return}O(!0);try{let[a,o]=await Promise.all([rx({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r,actions:i,limit:1e3}),ox({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r})]);v(a?.items??[]),e.setFieldsValue({step_order:o?.step_order??1})}catch(e){console.error(`Unable to load flows:`,e),s.message.error(`Unable to load flows.`)}finally{O(!1)}},[e]),re=(0,o.useCallback)(async(e=``)=>{if(!(!f?.id||!N||!P)){O(!0);try{let t=await rx({product_parent_ID:f.id,module_parent_ID:N,submodule_parent_ID:P,actions:e,limit:1e3});v(t?.items??[])}catch(e){console.error(`Unable to load action flows:`,e),s.message.error(`Unable to load action steps.`)}finally{O(!1)}}},[f?.id,N,P]),ie=(0,o.useCallback)(async()=>{if(!(!a||!f?.name)){M(!0);try{let t=await ax(a);await te(f.name,t.module);let n=await rx({product_parent_ID:t.product_parent_ID,module_parent_ID:t.module_parent_ID,submodule_parent_ID:t.submodule_parent_ID,limit:1e3});v(n?.items??[]),e.setFieldsValue({module:t.module_parent_ID,submodule:t.submodule_parent_ID,step_order:t.step_order,actions:t.actions,key:t.key,value:t.value,expected:t.expected,description:t.description,scenario:t.scenario===1,active:Number(t.active)!==0})}catch(e){console.error(`Unable to load test flow:`,e),s.message.error(`Unable to load test flow for edit.`),r(`/viewTestCase`)}finally{M(!1)}}},[a,e,te,r,f?.name]);return(0,o.useEffect)(()=>{if(!f){r(`/select-project`,{replace:!0});return}Promise.resolve().then(async()=>{await ee(),await U(f.name),a&&await ie()})},[f,r,ee,U,a,ie]),f?(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:GP})}),(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.ProjectOutlined,{}),(0,l.jsx)(WP,{strong:!0,children:f.name})]})})]}),(0,l.jsx)(`div`,{className:`zt-page`,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,colon:!1,className:`v1-form`,initialValues:{scenario:!0,active:!0},onFinish:async t=>{let n={product_parent_ID:Number(f?.id),module_parent_ID:Number(t.module),submodule_parent_ID:Number(t.submodule),description:KP(t.description),actions:KP(t.actions),key:KP(t.key),value:KP(t.value),expected:KP(t.expected),scenario:+!!t.scenario,active:+!!t.active};A(!0);try{if(u){await sx(a,{...n,step_order:Number(t.step_order)}),s.message.success(`Test case updated successfully.`),r(`/viewTestCase`);return}await ix(n),s.message.success(`Step saved (#${t.step_order}).`),e.setFieldsValue({actions:void 0,key:void 0,value:void 0,expected:void 0,description:void 0}),await ne(n.product_parent_ID,n.module_parent_ID,n.submodule_parent_ID)}catch(e){console.error(`Unable to save test case:`,e),s.message.error(u?`Unable to update test case.`:`Unable to save step.`)}finally{A(!1)}},autoComplete:`off`,disabled:j,children:[(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:8,className:`zt-section-title`,children:[(0,l.jsx)(`span`,{className:`zt-step-tag`,children:`1`}),(0,l.jsx)(`span`,{children:`Module & Submodule`})]}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],align:`bottom`,children:[(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Module`,name:`module`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,loading:C,placeholder:`Select module`,options:z,onChange:t=>{let n=p.find(e=>e.id===t)?.modulename??``;e.setFieldsValue({module:t,submodule:void 0,step_order:void 0,actions:void 0,key:void 0,value:void 0,expected:void 0}),ZP(e,[`actions`,`key`,`value`,`expected`]),g([]),v([]),te(f?.name,n)}})})}),(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Submodule`,name:`submodule`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,disabled:!I,loading:T,placeholder:I?`Select submodule`:`Select module first`,options:B,onChange:t=>{e.setFieldsValue({submodule:t,actions:void 0,key:void 0,value:void 0,expected:void 0}),ZP(e,[`actions`,`key`,`value`,`expected`]),ne(f?.id,N,t)}})})}),(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Scenario`,name:`scenario`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{disabled:!L,checkedChildren:`Positive`,unCheckedChildren:`Negative`})})}),(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Active`,name:`active`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{checkedChildren:`Active`,unCheckedChildren:`Inactive`})})})]})}),L&&(0,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:8,className:`zt-section-title`,children:[(0,l.jsx)(`span`,{className:`zt-step-tag`,children:`2`}),(0,l.jsx)(c.FileTextOutlined,{}),(0,l.jsx)(`span`,{children:`Step Details`})]}),extra:(0,l.jsxs)(WP,{type:`secondary`,children:[V,` / `,H]}),children:[(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Step Order`,name:`step_order`,children:(0,l.jsx)(s.Input,{disabled:!0,placeholder:D?`Loading…`:`Auto`})})}),(0,l.jsx)(s.Col,{xs:24,md:18,children:(0,l.jsx)(s.Form.Item,{label:`Action`,name:`actions`,rules:[{required:!0,message:`Mandatory Field`}],children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,placeholder:`Select action`,options:y,onChange:t=>{let n=XP(x,t);e.setFieldsValue({actions:t,key:n.key?e.getFieldValue(`key`):void 0,value:n.value?e.getFieldValue(`value`):void 0,expected:n.expected?e.getFieldValue(`expected`):void 0}),ZP(e,[`key`,`value`,`expected`]),re(t||``)}})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Key`,name:`key`,rules:[{required:R.key,message:`Key is required for this action`}],children:(0,l.jsx)(s.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,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Value`,name:`value`,rules:[{required:R.value,message:`Value is required for this action`}],children:(0,l.jsx)(s.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,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:R.expected,message:`Expected result is required for this action`}],children:(0,l.jsx)(s.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,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Description`,name:`description`,children:(0,l.jsx)(s.Input.TextArea,{rows:2,maxLength:255,showCount:!0,placeholder:`Enter description`})})})]}),(0,l.jsxs)(s.Space,{className:`zt-actions`,children:[(0,l.jsx)(s.Button,{onClick:()=>{if(u){r(`/viewTestCase`);return}e.resetFields(),g([]),v([]),E(!1),O(!1)},children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,loading:k||j,children:u?`Update Test Case`:`Save & Continue`})]})]},`${N}-${P}`),L&&(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.TableOutlined,{}),(0,l.jsx)(`span`,{children:`Added Steps`})]}),extra:(0,l.jsx)(s.Tag,{children:F?`${_.length} ${F} step(s)`:`${_.length} step(s)`}),children:(0,l.jsx)($m,{listName:`Added Steps`,loading:D,fields:JP,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:$P}=s.Typography,eF=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function tF(){let e=(0,d.useNavigate)(),r=(0,o.useMemo)(()=>t.l(),[]),[i,a]=(0,o.useState)([]),[u,f]=(0,o.useState)({}),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)(``),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(1),[C,w]=(0,o.useState)(10),T=(0,o.useCallback)(async e=>{if(!e){a([]);return}m(!0);try{let[t,n]=await Promise.all([Zb({project:e}),ex({project:e})]);a(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),s.message.error(`Unable to load modules.`)}finally{m(!1)}},[]);(0,o.useEffect)(()=>{if(!r){e(`/select-project`,{replace:!0});return}Promise.resolve().then(()=>T(r.name))},[r,e,T]);let E=async(e,t)=>{try{await $b(e.id,+!!t),a(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),s.message.success(`Module ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),s.message.error(`Unable to update module status.`)}},D=async()=>{let e=_.trim();if(!e){s.message.warning(`Enter a module name.`);return}b(!0);try{await Qb({project:r.name,modulename:e}),s.message.success(`Module added.`),g(!1),v(``),S(1),T(r.name)}catch(e){console.error(e),s.message.error(`Unable to add module (maybe it already exists).`)}finally{b(!1)}},O=t=>{e(`/test-cases/zinnext/submodules?module=${encodeURIComponent(t.modulename)}`)};return r?(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:eF})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>e(`/addTestCase`),children:`Back to Form`})})]}),(0,l.jsxs)(`div`,{className:`zt-page`,children:[(0,l.jsx)(s.Card,{className:`v1-card zt-bar`,children:(0,l.jsxs)(s.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.ProjectOutlined,{}),(0,l.jsx)(`span`,{children:`Project:`}),(0,l.jsx)($P,{strong:!0,children:r.name})]})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Module`})})]})}),(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.AppstoreOutlined,{}),(0,l.jsx)(`span`,{children:`Modules`})]}),children:(0,l.jsx)($m,{listName:`Modules`,loading:p,fields:[{label:`Module`,value:`modulename`},{label:`Submodules`,value:`submoduleCount`,width:140,render:(e,t)=>(0,l.jsxs)(s.Button,{type:`link`,className:`zt-count-link`,onClick:()=>O(t),children:[u[t.modulename]??0,` submodule(s)`]})},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,l.jsx)(s.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:i,current:x,pageSize:C,total:i.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,l.jsx)(s.Modal,{title:`Add Module`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,l.jsxs)(s.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,l.jsxs)($P,{type:`secondary`,children:[`Project: `,(0,l.jsx)(`b`,{children:r.name})]}),(0,l.jsx)(s.Input,{placeholder:`Enter module name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]}):null}var{Text:nF}=s.Typography,rF=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function iF(){let e=(0,d.useNavigate)(),[r]=(0,d.useSearchParams)(),i=(0,o.useMemo)(()=>t.l(),[]),a=r.get(`module`)??``,[u,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)(``),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(1),[C,w]=(0,o.useState)(10),T=(0,o.useCallback)(async(e,t)=>{if(!e||!t){f([]);return}m(!0);try{let n=await ex({project:e,module:t});f(n?.items??[])}catch(e){console.error(e),s.message.error(`Unable to load submodules.`)}finally{m(!1)}},[]);(0,o.useEffect)(()=>{if(!i){e(`/select-project`,{replace:!0});return}if(!a){e(`/manageModules`,{replace:!0});return}Promise.resolve().then(()=>T(i.name,a))},[i,a,e,T]);let E=async(e,t)=>{try{await nx(e.id,+!!t),f(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),s.message.success(`Submodule ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),s.message.error(`Unable to update submodule status.`)}},D=async()=>{let e=_.trim();if(!e){s.message.warning(`Enter a submodule name.`);return}b(!0);try{await tx({project:i.name,modulename:a,submodulename:e}),s.message.success(`Submodule added.`),g(!1),v(``),S(1),T(i.name,a)}catch(e){console.error(e),s.message.error(`Unable to add submodule (maybe it already exists).`)}finally{b(!1)}};return!i||!a?null:(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:rF})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>e(`/manageModules`),children:`Back to Modules`})})]}),(0,l.jsxs)(`div`,{className:`zt-page`,children:[(0,l.jsx)(s.Card,{className:`v1-card zt-bar`,children:(0,l.jsxs)(s.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space,{size:16,wrap:!0,className:`zt-section-title`,children:[(0,l.jsxs)(s.Space,{size:6,children:[(0,l.jsx)(c.ProjectOutlined,{}),(0,l.jsx)(`span`,{children:`Project:`}),(0,l.jsx)(nF,{strong:!0,children:i.name})]}),(0,l.jsxs)(s.Space,{size:6,children:[(0,l.jsx)(c.AppstoreOutlined,{}),(0,l.jsx)(`span`,{children:`Module:`}),(0,l.jsx)(nF,{strong:!0,children:a})]})]})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Submodule`})})]})}),(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.AppstoreOutlined,{}),(0,l.jsx)(`span`,{children:`Submodules`})]}),children:(0,l.jsx)($m,{listName:`Submodules`,loading:p,fields:[{label:`Submodule`,value:`submodulename`},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,l.jsx)(s.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:u,current:x,pageSize:C,total:u.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,l.jsx)(s.Modal,{title:`Add Submodule`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,l.jsxs)(s.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,l.jsxs)(nF,{type:`secondary`,children:[`Project: `,(0,l.jsx)(`b`,{children:i.name}),` \xA0|\xA0 Module: `,(0,l.jsx)(`b`,{children:a})]}),(0,l.jsx)(s.Input,{placeholder:`Enter submodule name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]})}var{Text:aF}=s.Typography,oF=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function sF(){let e=(0,d.useNavigate)(),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)(0),[f,p]=(0,o.useState)(!1),m=(0,o.useMemo)(()=>t.l(),[]),[h,g]=(0,o.useState)(``),[_,v]=(0,o.useState)(1),[y,b]=(0,o.useState)(20),[x,S]=(0,o.useState)(null),C=(0,o.useCallback)(async(e={})=>{p(!0);try{let t=await rx({product_parent_ID:e.project??m?.id??``,search:e.search??h??``,limit:e.pageSize??y,offset:((e.page??_)-1)*(e.pageSize??y)});i(t?.items??[]),u(t?.total??0)}catch(e){console.error(e),s.message.error(`Unable to load test flows.`)}finally{p(!1)}},[m?.id,h,_,y]),w=e=>{s.Modal.confirm({title:`Delete Test Case`,icon:(0,l.jsx)(c.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 cx(e.id),s.message.success(`Test case deleted successfully.`);let t=r.length===1&&_>1?_-1:_;v(t),await C({page:t})}catch(e){throw console.error(`Unable to delete test flow:`,e),s.message.error(`Unable to delete test case.`),e}finally{S(null)}}})};return(0,o.useEffect)(()=>{Promise.resolve().then(()=>{if(!m?.id){e(`/select-project`,{replace:!0});return}C({page:1})})},[]),(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:oF})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>e(`/addTestCase`),children:`Back to Form`})})]}),(0,l.jsx)(`div`,{className:`zt-page zt-page-wide`,children:(0,l.jsxs)(s.Card,{className:`v1-card`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.TableOutlined,{}),(0,l.jsx)(`span`,{children:`Test Flows`})]}),extra:(0,l.jsxs)(aF,{type:`secondary`,children:[a,` row(s)`]}),children:[(0,l.jsxs)(s.Space,{wrap:!0,className:`zt-toolbar`,children:[(0,l.jsx)(s.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,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:()=>C(),children:`Refresh`})]}),(0,l.jsx)($m,{listName:`Test Flows`,loading:f,fields:[{label:`Actions`,value:`rowActions`,width:112,fixed:`left`,sorter:!1,render:(t,n)=>(0,l.jsxs)(s.Space,{size:4,className:`zt-row-actions`,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>e(`/addTestCase?edit=${n.id}`)})}),(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{danger:!0,type:`text`,size:`small`,icon:(0,l.jsx)(c.DeleteOutlined,{}),loading:x===n.id,onClick:()=>w(n)})})]})},{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,l.jsx)(s.Tag,{color:`green`,children:`Positive`}):(0,l.jsx)(s.Tag,{color:`red`,children:`Negative`})},{label:`Active`,value:`active`,width:90,render:e=>e===1?(0,l.jsx)(s.Tag,{color:`blue`,children:`Active`}):(0,l.jsx)(s.Tag,{children:`Inactive`})}],dataSource:r,current:_,pageSize:y,total:a,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 cF=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function lF(){return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsx)(n.t,{items:cF}),(0,l.jsx)(Qo,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:uF}=s.Typography,dF=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],fF={tags:`regression`,active:1},pF={module:{dbName:`Modules`,formField:`module`,label:`Module`}},mF={key:!1,value:!1,expected:!1};function hF(e,t){return t?e[t]??mF:mF}function gF(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function _F(e=[]){return e.map(e=>({value:e,label:e}))}function vF(e=``){return String(e??``).trim()}function yF(e=[]){let t=new Map;return e.forEach(e=>{let n=vF(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function bF(e=[],t,n){let r=vF(t).toLowerCase(),i=vF(n).toLowerCase();return e.reduce((e,t)=>{let n=vF(t?.module).toLowerCase(),a=vF(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 xF({icon:e,title:t}){return(0,l.jsxs)(s.Space,{size:10,align:`center`,children:[(0,l.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,l.jsx)(uF,{strong:!0,className:`v1-section-label`,children:t})]})}function SF(){let[e]=s.Form.useForm(),[t]=s.Form.useForm(),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)([]),[f,p]=(0,o.useState)([]),[m,h]=(0,o.useState)(MP),[g,_]=(0,o.useState)({}),[v,y]=(0,o.useState)(!1),[b,x]=(0,o.useState)(!1),[S,C]=(0,o.useState)({open:!1,typeKey:`module`}),[w,T]=(0,o.useState)(!1),[E,D]=(0,o.useState)(!1),[O,k]=(0,o.useState)(!1),A=(0,d.useNavigate)(),j=pF[S.typeKey],M=(0,o.useMemo)(()=>_F(r),[r]),N=s.Form.useWatch(`module`,e),P=s.Form.useWatch(`flow`,e),F=s.Form.useWatch(`keyword`,e),I=!!vF(N),L=!!vF(P),R=!I,z=!I||!L,B=(0,o.useMemo)(()=>hF(g,F),[g,F]),V=(e,t=[])=>{e===`module`&&i(t)},H=async()=>{y(!0);try{let e=await Vb(pF.module.dbName);i(e?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),s.message.error(`Unable to load testing options.`)}finally{y(!1)}},ee=async()=>{try{let e=await Ub();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),s.message.error(`Unable to load action validation rules.`)}},U=(0,o.useCallback)(async t=>{let n=vF(t);if(u([]),p([]),e.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await Yb({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];u(t),p(yF(t))}catch(e){console.error(`Unable to load flows:`,e),s.message.error(`Unable to load flows.`)}finally{x(!1)}}},[e]),te=(0,o.useCallback)(async(t,n,r)=>{let i=vF(t),a=vF(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}D(!0);try{e.setFieldsValue({step_order:bF(r,i,a)})}catch(e){console.error(`Unable to load step order:`,e),s.message.error(`Unable to load step order.`)}finally{D(!1)}},[e]);(0,o.useEffect)(()=>{Promise.resolve().then(async()=>{await Promise.all([H(),ee()])})},[]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>U(N))},[U,N]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>te(N,P,a))},[a,te,P,N]);let ne=async t=>{let n={module:vF(t.module),flow:vF(t.flow),step_order:Number(t.step_order),description:vF(t.description),keyword:vF(t.keyword),target:vF(t.target),value:vF(t.value),expected:vF(t.expected),tags:t.tags?vF(t.tags):fF.tags,active:Number(t.active)};k(!0);try{await Jb(n),s.message.success(`LMS case details saved successfully.`),e.resetFields(),u([]),p([])}catch(e){console.error(`Unable to save LMS case:`,e),s.message.error(`Unable to save LMS case.`)}finally{k(!1)}},re=(t,n)=>{e.setFieldsValue({[t]:vF(n)})},ie=t=>{e.setFieldsValue({module:vF(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:fF.tags,value:void 0,expected:void 0}),gF(e,[`keyword`,`target`,`value`,`expected`])},ae=t=>{e.setFieldsValue({flow:vF(t),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),gF(e,[`keyword`,`target`,`value`,`expected`])},W=t=>{let n=hF(g,t);e.setFieldsValue({keyword:vF(t),target:n.key?e.getFieldValue(`target`):void 0,value:n.value?e.getFieldValue(`value`):void 0,expected:n.expected?e.getFieldValue(`expected`):void 0}),gF(e,[`target`,`value`,`expected`])},oe=e=>{let n=pF[e];C({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},se=()=>{C(e=>({...e,open:!1})),t.resetFields()},ce=async()=>{try{let n=vF((await t.validateFields()).name),r=await Hb({name:n,type:j.dbName});V(S.typeKey,r?.items??[]),e.setFieldsValue({[j.formField]:n}),s.message.success(`${j.label} added successfully.`),se()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),s.message.error(`Unable to add ${j.label.toLowerCase()}.`)}finally{T(!1)}};return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:dF})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>A(`/lms-home`),children:`View Table`})})]}),(0,l.jsx)(`div`,{className:`v1-page`,children:(0,l.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,l.jsx)(`div`,{className:`v1-page-header`,children:(0,l.jsxs)(s.Space,{align:`center`,size:10,children:[(0,l.jsx)(c.ProfileOutlined,{className:`v1-outer-icon`}),(0,l.jsx)(`div`,{children:(0,l.jsx)(uF,{strong:!0,style:{fontSize:16},children:`Add LMS Case`})})]})}),(0,l.jsx)(Z,{children:(0,l.jsxs)(s.Form,{form:e,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:fF,onFinish:ne,autoComplete:`off`,children:[(0,l.jsx)(s.Card,{className:`v1-card`,title:(0,l.jsx)(xF,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,l.jsx)(uF,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsxs)(s.Space.Compact,{style:{width:`100%`},children:[(0,l.jsx)(s.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,loading:v,optionFilterProp:`label`,placeholder:`Select module`,options:M,onChange:ie})}),(0,l.jsx)(s.Button,{"aria-label":`Add module`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:30},onClick:()=>oe(`module`)})]})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Flow`,name:`flow`,children:(0,l.jsx)(s.AutoComplete,{maxLength:100,allowClear:!0,disabled:R,options:f,placeholder:b?`Loading flows`:`Enter flow`,onChange:ae,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,l.jsx)(s.Input,{maxLength:10,disabled:!0,placeholder:E?`Loading step order`:`Step order`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Action`,name:`keyword`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,disabled:z,optionFilterProp:`label`,placeholder:`Select action`,options:m,onChange:W})})}),(0,l.jsx)(s.Col,{xs:24,children:(0,l.jsx)(s.Form.Item,{label:`Description`,name:`description`,children:(0,l.jsx)(s.Input.TextArea,{rows:3,maxLength:255,disabled:z,placeholder:`Enter description`,showCount:!0,onBlur:e=>re(`description`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Key`,name:`target`,rules:[{required:B.key,message:`Key is required for this action`}],children:(0,l.jsx)(s.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=>re(`target`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Tags`,name:`tags`,children:(0,l.jsx)(s.Input,{maxLength:200,disabled:z,placeholder:`Enter tags`,prefix:(0,l.jsx)(c.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>re(`tags`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Value`,name:`value`,rules:[{required:B.value,message:`Value is required for this action`}],children:(0,l.jsx)(s.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=>re(`value`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:B.expected,message:`Expected result is required for this action`}],children:(0,l.jsx)(s.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=>re(`expected`,e.target.value)})})})]})}),(0,l.jsx)(`div`,{className:`v1-form-actions`,children:(0,l.jsx)(s.Form.Item,{children:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,loading:O,disabled:z,children:`Submit`}),(0,l.jsx)(s.Button,{onClick:()=>{e.resetFields(),u([]),p([])},children:`Reset`})]})})})]})}),(0,l.jsx)(s.Modal,{title:`Add ${j.label}`,open:S.open,confirmLoading:w,okText:`Add`,onCancel:se,onOk:()=>{T(!0),ce()},destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:t,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,l.jsx)(s.Form.Item,{label:`Name`,name:`name`,children:(0,l.jsx)(s.Input,{maxLength:100,placeholder:`Enter ${j.label.toLowerCase()} name`,onBlur:e=>{t.setFieldsValue({name:vF(e.target.value)})}})}),(0,l.jsx)(s.Form.Item,{label:`Type`,name:`type`,children:(0,l.jsx)(s.Input,{disabled:!0})})]})})]})})]})}var CF=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function wF(){return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsx)(n.t,{items:CF}),(0,l.jsx)(Qo,{moduleName:`lms-flows`,rowKey:`id`})]})}var TF=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function EF(e=TF){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 DF(e,t=TF){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 OF=EF();function kF(e){return typeof e==`function`?e:typeof e==`string`?EF([e]):Array.isArray(e)?EF(e):OF}function AF(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:e?.id??t?.id??n}}function jF(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var MF=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function NF(e){let t=e?.data??e,n={};for(let r of MF){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var PF=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function FF(e,t,n){let r=(Array.isArray(n)?n:[n]).map(PF).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(PF(e?.value))||r.includes(PF(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 IF=(e,t)=>_i(e,t).rows,LF=(e,t)=>{let{rows:n,total:r}=_i(e,t);return{rows:n,total:r}};function RF(e,t){return function(n,r,i,a={}){return e(t??n,r,i,a)}}function zF(e){return!e||typeof e!=`object`||typeof(e.fetchByKeys??e.fetch??e.function)!=`function`?null:{...e,fetchByKeys:typeof e.fetchByKeys==`function`?e.fetchByKeys:null,fetch:typeof e.fetch==`function`?e.fetch:null,function:typeof e.function==`function`?e.function:null,extractRows:typeof e.extractRows==`function`?e.extractRows:IF,mergeRow:typeof e.mergeRow==`function`?e.mergeRow:AF,fetchById:typeof e.fetchById==`function`?e.fetchById:null}}function BF({fetchSecondaryByKeys:e,fetchSecondary:t,extractSecondaryRows:n,fetchSecondaryById:r,secondaryKey:i,mergeRow:a,secondaryFetchLimit:o}){return!e&&!t&&!r?[]:[zF({key:i,fetchByKeys:e?(t,n,r)=>e(t,n,r):null,function:t?({moduleName:e,options:n})=>t(e,o,0,n):null,extractRows:n,fetchById:r,mergeRow:a})].filter(Boolean)}function VF(e){if(typeof e==`function`)return t=>{let n=e(t);return n==null||n===``?[]:[String(n)]};let t=typeof e==`string`?[e]:Array.isArray(e)&&e.length?e:TF;return e=>DF(e,t)}function HF(e,t){let n=new Map;return e.forEach(e=>{for(let r of t(e))n.has(r)||n.set(r,e)}),n}function UF({moduleName:e,limit:t,offset:n,options:r,keys:i,primaryResponse:a,primaryRows:o,pageRows:s,total:c,source:l}){return{moduleName:e,limit:t,offset:n,options:r,keys:i,primaryResponse:a,primaryRows:o,pageRows:s,total:c,source:l}}async function WF(e,t){if(typeof e.args==`function`){let n=e.args(t);return(e.fetch??e.function??e.fetchByKeys)(...Array.isArray(n)?n:[n])}if(Array.isArray(e.args))return(e.fetch??e.function??e.fetchByKeys)(...e.args);if(e.fetchByKeys&&Array.isArray(t.keys))return e.fetchByKeys(t.moduleName,t.keys,t.options,t);let n=e.fetch??e.function;return typeof n==`function`?n(t):null}function GF({fetchPrimaryPage:e,extractPrimaryPage:t=LF,fetchSecondaryByKeys:n,joinSources:r=[],fetchPrimary:i,extractPrimaryRows:a=IF,fetchSecondary:o,extractSecondaryRows:s=IF,fetchSecondaryById:c,primaryKey:l,secondaryKey:u,mergeRow:d=AF,secondaryFetchLimit:f=200,extraFields:p=[],extraFieldsAfter:m}){let h=Array.isArray(r)&&r.length?r.map(zF).filter(Boolean):BF({fetchSecondaryByKeys:n,fetchSecondary:o,extractSecondaryRows:s,fetchSecondaryById:c,secondaryKey:u,mergeRow:d,secondaryFetchLimit:f}),g=0;async function _(e,t,n,r){if(!e.fetchById||!r)return null;try{let i=await e.fetchById(n,r);return i&&t(i).includes(String(r))?i:null}catch(e){return console.error(`[mergedListApi] per-id join lookup failed for "${r}"`,e),null}}async function v(e,t,n,r,i){if(!n)return e;let a=t.extractRows(n,r)??[],o=kF(t.primaryKey??l),s=VF(t.key),c=HF(a,s);return Promise.all(e.map(async e=>{let n=o(e),a=c.get(n)??(i()?null:await _(t,s,r,n));return t.mergeRow(e,a,n)}))}async function y(e,t,n,r){let i=e;for(let e of t)i=await v(i,e.source,e.response,n,r);return i}function b(e,t,n){let r={};for(let e of n){if(!e)continue;let t=NF(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return p.length&&(r.fields=FF(r.fields??[],p,m)),jF(e,t,r)}async function x({moduleName:e,limit:t,offset:n,options:r,primaryResponse:i,primaryRows:a,pageRows:o,total:s}){return Promise.all(h.map(async c=>{try{let u=kF(c.primaryKey??l),d=[...new Set(o.map(u).filter(Boolean))];return c.fetchByKeys&&d.length===0?{source:c,response:null}:{source:c,response:await WF(c,UF({moduleName:e,limit:t,offset:n,options:r,keys:d,primaryResponse:i,primaryRows:a,pageRows:o,total:s,source:c}))}}catch(e){return console.error(`[mergedListApi] join fetch failed — rendering page without that join`,e),{source:c,response:null}}}))}async function S(n,r,i,a,o){let s=await e(n,r,i,a),c=t(s,n)??{},l=Array.isArray(c.rows)?c.rows:[],u=Number.isFinite(Number(c.total))?Number(c.total):l.length,d=await x({moduleName:n,limit:r,offset:i,options:a,primaryResponse:s,primaryRows:l,pageRows:l,total:u});return b(await y(l,d,n,o),u,[s,...d.map(e=>e.response)])}async function C(e,t,n,r,o){let s=await i(e,t,n,r),c=a(s,e)??[],l=c.length,u=c.slice(n,n+t),d=await x({moduleName:e,limit:t,offset:n,options:r,primaryResponse:s,primaryRows:c,pageRows:u,total:l});return b(await y(u,d,e,o),l,[s,...d.map(e=>e.response)])}return async function(t,n=10,r=0,i={}){let a=++g,o=()=>a!==g;return e?S(t,n,r,i,o):C(t,n,r,i,o)}}function KF(e,t,n={}){return GF({fetchPrimary:()=>tj(e,t),extractPrimaryRows:$A,fetchSecondary:Dn,fetchSecondaryById:nj,secondaryFetchLimit:n.moduleFetchLimit??200})}function qF(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 JF(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=qF(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var YF=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function XF({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=AF(n,r,i),o=YF(a);return o!=null&&(a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function ZF(e={}){let t=XF();return GF({primaryKey:`_id`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:Dn,joinSources:[{key:`entityId`,fetchByKeys:(e,t,n,r)=>{let i=Math.max(1,Number(r?.limit)||10);return ej(Math.floor((Number(r?.offset)||0)/i)+1,i)},extractRows:e=>(e?.items??[]).map(JF),mergeRow:(e,n,r)=>{let i=t(e,n,r);return n?._id&&(i.workflowId=n._id),i}}]})}async function QF(e,t=10,n=0,r={},i={}){return _i(await ZF(i)(e,t,n,r),e)}async function $F(e,t,n,r=10,i=0,a={}){return _i(await KF(e,t)(n,r,i,a),n)}typeof window<`u`&&(window.__CORE_THEME_BUILD__=`2026-10-29T14:24:21.085Z`);var eI=gN,tI=dx(mP),nI=dx(gP),rI=dx(jP),iI=dx(UP),aI=dx(QP),oI=dx(tF),sI=dx(iF),cI=dx(sF),lI=dx(lF),uI=dx(SF),dI=dx(wF);exports.ADMIN_API_URL=t.v,exports.ADMIN_APP_ID=t.y,exports.APP_ID=t.b,exports.AUTH_URL=t.x,exports.ActivityNotesCard=qc,exports.ActivityTab=Hc,exports.AddBatchCandidatePopup=GM,exports.AddFormV1=Tc,exports.AdminDashboard=gN,exports.AdminDashboardContent=HD,exports.AdminPage=eI,exports.AppAlert=Ec,exports.AppButton=n.ft,exports.AppShell=Pb,exports.ApprovalActionBar=U_,exports.AssigneeAvatars=Jc,exports.AuthGuard=Db,exports.BILLING_STATUS_FLOW=wf,exports.BOOLEAN_API_KEYS=kg,exports.BOOLEAN_PARSEABLE_API_KEYS=mh,exports.BULK_UPLOAD_DEFAULT_ACCEPT=Yc,exports.BULK_UPLOAD_DEFAULT_MAX_SIZE_MB=Xc,exports.Breadcrumb=n.t,exports.BulkUploadPage=rI,exports.BulkUploadPanel=il,exports.CANDIDATES_URL=t.S,exports.CONTRACT_C2C=pv,exports.CONTRACT_W2=fv,exports.CURRENCY_SYMBOLS=Du,exports.CalendarCard=A,exports.CoreThemeAdminApp=KD,exports.CoreThemeAdminRoutes=GD,exports.CustomPagination=Be,exports.DEFAULT_HOURS_POLICY=d_,exports.DEFAULT_RESULTS_VIEW=Tg,exports.DayLogModal=F_,exports.DescriptionBlock=_l,exports.DetailHeaderCard=Ep,exports.DetailViewPage=Np,exports.DetailViewV1=Sd,exports.DocumentViewer=n.En,exports.DynamicCards=Rt,exports.DynamicPopup=pA,exports.DynamicPopupRoute=XM,exports.DynamicTabs=P,exports.EditFormV1=jm,exports.FIELD_TYPE_REGISTRY=Yh,exports.FINANCE_APPROVAL_CONFIG=iv,exports.FINANCE_TYPE_CFO=Z_,exports.FINANCE_TYPE_ONBOARDING_MANAGER=X_,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=ev,exports.FINANCE_TYPE_ONLY_FINANCE=Q_,exports.FINANCE_TYPE_SUBMISSION_MANAGER=Y_,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=$_,exports.FileListCard=vy,exports.FinanceApprovalPanel=Zv,exports.FinanceAvatar=ap,exports.FinanceBadge=lp,exports.FinanceDayCell=G_,exports.FinanceDivider=Zf,exports.FinanceEmployeeCell=op,exports.FinanceEmptyState=Jf,exports.FinanceEquation=Qf,exports.FinanceHistoryTimeline=np,exports.FinanceHoursGrid=qf,exports.FinanceKpiRow=Kf,exports.FinanceLine=Xf,exports.FinanceListToolbar=u_,exports.FinanceMarginBadge=up,exports.FinanceMoneyCell=cp,exports.FinanceRecordsTable=pp,exports.FinanceRowChevron=dp,exports.FinanceSection=Yf,exports.FinanceStatusPill=Gf,exports.FinanceTextCell=sp,exports.FinanceTimesheetAnalysis=q_,exports.FinanceWorkflowSteps=$f,exports.HOURS_MESSAGES=f_,exports.Header=qy,exports.HierarchyUserFilter=Ut,exports.JOBS_URL=t.C,exports.LegacyAdminPage=tI,exports.ListView=Qo,exports.LmsHomePage=dI,exports.LmsTestForm=uI,exports.Login=Fb,exports.MailPopup=CO,exports.ManageModules=oI,exports.ManageSubmodules=sI,exports.ModuleRowActions=Bm,exports.NotesPanel=H_,exports.NotesTab=Kc,exports.OPEN_AS_OPTIONS=gg,exports.PAYROLL_STATUS_FLOW=Tf,exports.POPUP_CONFIGS=IM,exports.ParamCardView=qm,exports.ParamListView=$m,exports.PaymentInvoicePopup=oN,exports.PeriodBadgeTag=w_,exports.PreviewPopup=ek,exports.ProjectSelect=ux,exports.ProofUploadPreview=V_,exports.QuickLogBar=R_,exports.QuickLogSelectionBar=I_,exports.RESULTS_VIEW_OPTIONS=wg,exports.RejectionReasonModal=L_,exports.SUBMISSIONS_URL=t.T,exports.SearchBuilderV1=t_,exports.Sidebar=Cb,exports.StatusBadge=r_,exports.StatusBadgeTag=C_,exports.StickyNotesFullPage=nI,exports.StylishDynamicTabs=a_,exports.TemplateEditor=s_,exports.TestForm=iI,exports.TestingHomePage=lI,exports.TimelineGroups=Pc,exports.TimesheetDayCell=M_,exports.TipTapEditor=n.On,exports.UserForm=hN,exports.VendorShareDrawer=eN,exports.ViewSummaryWidget=Ui,exports.WizardPopup=ok,exports.ZinnextTableView=cI,exports.ZinnextTestForm=aI,exports.appNow=n.Mn,exports.applyIntegrationStatus=n.Jn,exports.approveSubmission=be,exports.buildAcceptAttr=tl,exports.buildBooleanRequest=Pg,exports.buildCsv=zf,exports.buildDailyRows=Nf,exports.buildDayGradient=A_,exports.buildRateHistoryEntries=Rv,exports.buildWeeklyRollup=If,exports.clearSelectedProject=t.i,exports.colors=n.jn,exports.computeFinance=Av,exports.computeHoursPolicy=v_,exports.computeMarginBand=Lf,exports.conditionMatches=n.i,exports.configureCoreTheme=t.E,exports.configuredFieldLabel=n.a,exports.createAllWorkflowsListFetcher=ZF,exports.createMergedListFetcher=GF,exports.createModuleListFetchAdapter=RF,exports.createWorkflowStageListFetcher=KF,exports.currencySymbol=Ou,exports.defaultMergeRow=AF,exports.deleteIntegrationConfig=n.ar,exports.deriveDayStats=Mf,exports.describeCapacity=b_,exports.downloadCsv=Uf,exports.evaluateShowIfWith=n.o,exports.findEmployerRow=wv,exports.flattenGroups=Sv,exports.formatAmount=Pu,exports.formatApp=n.Nn,exports.formatAppDateTime=n.Pn,exports.formatFileSize=el,exports.formatFinanceMoney=zv,exports.formatHours=hf,exports.formatMoney=Fu,exports.formatPercent=_f,exports.formatRate=Iu,exports.getActivity=n.pn,exports.getAllWorkflowsModuleList=QF,exports.getAppTimeZone=n.Fn,exports.getApprovalDate=xf,exports.getBgcIntegrationConfig=n.Cr,exports.getBgcIntegrationSummary=n.wr,exports.getBillingActionStates=Ef,exports.getBooleanEligibleTypes=tg,exports.getCurrentRoleName=t.c,exports.getFieldLabel=Vf,exports.getFieldType=Zh,exports.getFileExtension=$c,exports.getFinanceApprovalConfig=lv,exports.getFormGroupsRaw=sy,exports.getIntegrationConfig=n.Ar,exports.getIntegrationConfigs=n.jr,exports.getIntegrationSummary=n.Mr,exports.getModuleConfig=Le,exports.getModuleDataDetail=n.hn,exports.getPayrollActionStates=Df,exports.getPeriodBadgeConfig=ze,exports.getSearchPopup=pg,exports.getSelectedProject=t.l,exports.getStoredToken=t.u,exports.getStoredUser=t.d,exports.getUserRoles=t.f,exports.getVMSApprove=xe,exports.getValueStyle=Hf,exports.getWorkflowStageModuleList=$F,exports.getWorkflowSteps=Of,exports.humanizeEvent=bf,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Cs}}),exports.indexFieldConfig=Bf,exports.initialsOf=vf,exports.insertTokenAtCursor=vh,exports.isBooleanEligible=Qh,exports.isBooleanParsable=gh,exports.isTester=t.p,exports.logout=t.h,exports.marginIncludesReferral=dv,exports.matchLocationTax=kv,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Vp}}),exports.normalizeContract=Ev,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return al}}),exports.rateUnitLabel=Au,exports.rateUnitShort=Mu,exports.readActionButtons=bg,exports.reconcileHours=y_,exports.registerFieldType=Xh,exports.registerSearchPopup=fg,exports.rejectSubmission=q,exports.resolveActivityMeta=zc,exports.resolveAndCompute=jv,exports.resolveDayKind=g_,exports.resolveFinanceInputs=Ov,exports.resolveMergeKey=OF,exports.resolveMergedListKey=OF,exports.resolveOpenAs=vg,exports.resolveRejectionReason=uv,exports.resolveResultsSearchPlaceholder=Og,exports.resolveResultsView=Dg,exports.resolveSubmissionFinance=cy,exports.saveBgcIntegrationConfig=n.ni,exports.saveIntegrationConfig=n.ai,exports.setSelectedProject=t._,exports.showIfConditions=n.c,exports.stageCountKey=qF,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Ib}}),exports.testIntegrationConnection=n.fi,exports.toApp=n.Ln,exports.toNumber=Nu,exports.tzLabel=n.Rn,exports.tzShortLabel=n.zn,exports.unregisterSearchPopup=mg,exports.useDropdownFields=Un,exports.useDropdownValues=Wi,exports.useEditForm=yy,exports.useFieldConfig=Wn,exports.useFilterFields=Gn,exports.useMenuPermission=sr,exports.useModuleActions=Nm,exports.useRecordRefresh=Ap,exports.validateBooleanQuery=_h,exports.validateBulkFile=nl,exports.withAdminAppId=t.D,exports.withAppId=t.O,exports.withAuthGuard=dx;
23
23
  //# sourceMappingURL=index.cjs.map