@erpsquad/common 1.10.8-test → 1.10.9-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{ai-summary-D9QajB4_.js → ai-summary-4NVNEHfi.js} +2 -2
- package/dist/chunks/{ai-summary-D9QajB4_.js.map → ai-summary-4NVNEHfi.js.map} +1 -1
- package/dist/chunks/{ai-summary-FqAUpafL.esm.js → ai-summary-f8clWLbW.esm.js} +65 -44
- package/dist/chunks/{ai-summary-FqAUpafL.esm.js.map → ai-summary-f8clWLbW.esm.js.map} +1 -1
- package/dist/chunks/{android-12-switch-BVabRCje.esm.js → android-12-switch-BUbQYnRQ.esm.js} +53 -35
- package/dist/chunks/{android-12-switch-BVabRCje.esm.js.map → android-12-switch-BUbQYnRQ.esm.js.map} +1 -1
- package/dist/chunks/android-12-switch-CphTHRb8.js +2 -0
- package/dist/chunks/{android-12-switch-DMaoWQwq.js.map → android-12-switch-CphTHRb8.js.map} +1 -1
- package/dist/chunks/{appbar-6Ucw59ku.js → appbar-C6Es9HGk.js} +2 -2
- package/dist/chunks/{appbar-6Ucw59ku.js.map → appbar-C6Es9HGk.js.map} +1 -1
- package/dist/chunks/{appbar-mDf1LZ0u.esm.js → appbar-CKrHdx9n.esm.js} +2 -2
- package/dist/chunks/{appbar-mDf1LZ0u.esm.js.map → appbar-CKrHdx9n.esm.js.map} +1 -1
- package/dist/chunks/{default-data-CwLgBvlI.esm.js → default-data-BsZWgQGR.esm.js} +3 -3
- package/dist/chunks/{default-data-CwLgBvlI.esm.js.map → default-data-BsZWgQGR.esm.js.map} +1 -1
- package/dist/chunks/{default-data-D2cqOmp4.js → default-data-Dsjlvwev.js} +2 -2
- package/dist/chunks/{default-data-D2cqOmp4.js.map → default-data-Dsjlvwev.js.map} +1 -1
- package/dist/chunks/{fullScreen-VlXxoepU.js → fullScreen-BBpaDn-A.js} +2 -2
- package/dist/chunks/{fullScreen-VlXxoepU.js.map → fullScreen-BBpaDn-A.js.map} +1 -1
- package/dist/chunks/{fullScreen-B9d2_kak.esm.js → fullScreen-Dn-3Tkwm.esm.js} +2 -2
- package/dist/chunks/{fullScreen-B9d2_kak.esm.js.map → fullScreen-Dn-3Tkwm.esm.js.map} +1 -1
- package/dist/chunks/index-B9CFxEZ9.js +2 -0
- package/dist/chunks/index-B9CFxEZ9.js.map +1 -0
- package/dist/chunks/{index-iPYNYnNP.esm.js → index-wf5q5BST.esm.js} +73 -66
- package/dist/chunks/{index-iPYNYnNP.esm.js.map → index-wf5q5BST.esm.js.map} +1 -1
- package/dist/chunks/{migration-utils-TYitNMC7.js → migration-utils-9IXhe_fj.js} +2 -2
- package/dist/chunks/{migration-utils-TYitNMC7.js.map → migration-utils-9IXhe_fj.js.map} +1 -1
- package/dist/chunks/{migration-utils-BRjncD-b.esm.js → migration-utils-DGoEzQUj.esm.js} +2 -2
- package/dist/chunks/{migration-utils-BRjncD-b.esm.js.map → migration-utils-DGoEzQUj.esm.js.map} +1 -1
- package/dist/chunks/{sidebar-DJREtRnK.js → sidebar-B3SExDRU.js} +2 -2
- package/dist/chunks/{sidebar-DJREtRnK.js.map → sidebar-B3SExDRU.js.map} +1 -1
- package/dist/chunks/{sidebar-D_3INLNa.esm.js → sidebar-n9Y25HU-.esm.js} +2 -2
- package/dist/chunks/{sidebar-D_3INLNa.esm.js.map → sidebar-n9Y25HU-.esm.js.map} +1 -1
- package/dist/chunks/{sidebarScreen-CUf5Onkp.js → sidebarScreen-Dxb_e58p.js} +2 -2
- package/dist/chunks/{sidebarScreen-CUf5Onkp.js.map → sidebarScreen-Dxb_e58p.js.map} +1 -1
- package/dist/chunks/{sidebarScreen-CLjYZOzQ.esm.js → sidebarScreen-_Zt2pSOx.esm.js} +3 -3
- package/dist/chunks/{sidebarScreen-CLjYZOzQ.esm.js.map → sidebarScreen-_Zt2pSOx.esm.js.map} +1 -1
- package/dist/components/index.esm.js +121 -103
- package/dist/components/index.js +1 -1
- package/dist/index.esm.js +218 -200
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/layout/index.esm.js +2 -2
- package/dist/layout/index.js +1 -1
- package/dist/src/components/index.d.ts +18 -1
- package/dist/utils/index.esm.js +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/views/index.esm.js +5 -5
- package/dist/views/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/android-12-switch-DMaoWQwq.js +0 -2
- package/dist/chunks/index-BQ2NBHDS.js +0 -2
- package/dist/chunks/index-BQ2NBHDS.js.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),l=require("./index-BQ2NBHDS.js"),t=require("./appbar-6Ucw59ku.js"),o=require("@mui/icons-material/Close"),a=require("@mui/material"),r=require("react-dnd");;/* empty css */const n=require("./images-DrJQoSCu.js"),i=require("./useAuth-C1y8BBuX.js"),s=require("react"),d=require("@mui/icons-material/Add"),c=require("react-hook-form");;/* empty css */const u=require("@mui/material/Tab"),m=require("@mui/lab/TabContext"),p=require("@mui/lab/TabList"),h=require("@mui/lab/TabPanel"),y=require("react-i18next"),g=require("./form-builder-deconversion-BbeAseMU.js"),x=require("yup"),v=require("dayjs"),f=require("./common-wRWMk0Fs.js"),b=require("lodash"),j=require("@mui/material/styles"),_=require("@mui/x-date-pickers/AdapterDayjs"),C=require("@mui/x-date-pickers/LocalizationProvider"),T=require("@mui/x-date-pickers/TimePicker"),w=require("@mui/icons-material"),S=require("@mui/icons-material/KeyboardArrowDownOutlined"),A=require("./useAccountSetting-DZvJOGz7.js"),P=require("./action-bar-BmEN5Ob9.js");require("react-querybuilder/dist/query-builder.scss");const k=require("react-querybuilder"),N=require("@react-querybuilder/material"),M=require("./useLangauge-p2qKwusp.js"),I=require("./trash-lbX6jsCI.js"),D=require("./api-DG3x2G1d.js"),B=require("./api-config-CkfRrKRY.js"),q=require("notistack"),F=require("./route-page-map-CDdU1EAs.js"),E=require("react-router-dom"),R=require("@mui/material/ButtonGroup"),z=require("@mui/material/ClickAwayListener"),$=require("@mui/material/Grow"),V=require("@mui/material/Paper"),L=require("@mui/material/Popper"),O=require("@mui/material/MenuItem"),G=require("@mui/material/MenuList"),W=require("./hooks-BdfwliGF.js"),U=require("@mui/material/Box"),K=require("react-dropzone"),H=require("@mui/icons-material/Remove"),Y=require("./page-context-qa1FKO9A.js"),J=require("./tick-ChY3vEPD.js"),Q=require("@mui/icons-material/ColorLens"),Z=require("@mui/icons-material/ChevronLeft"),X=require("@mui/icons-material/ChevronRight"),ee=require("@mui/icons-material/Menu"),le=require("@mui/icons-material/KeyboardArrowDown"),te=require("@mui/icons-material/AddCircleOutlineRounded"),oe=require("@mui/icons-material/KeyboardArrowRight"),ae=require("react-redux"),re=require("./reducer-BfnLOnkL.js"),ne=require("@mui/icons-material/ExpandMore"),ie=require("@mui/material/Switch"),se=require("@mui/material/Stack"),de=require("react-phone-input-2");require("react-phone-input-2/lib/material.css");const ce=require("material-react-table"),ue=require("@mui/x-date-pickers/DatePicker"),me=require("@mui/x-date-pickers/DateTimePicker"),pe=require("./document-BNdWzYrf.js"),he=require("./modules-BiUx1fbP.js"),ye=require("./pathname.rental-Br768eN2.js"),ge=require("./pathname.hrms-DGxdM-k7.js"),xe=require("libphonenumber-js"),ve=require("./actionCreator-C14XakVb.js"),fe=require("@mui/material/CardMedia");function be(e){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const t in e)if("default"!==t){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(l,t,o.get?o:{enumerable:!0,get:()=>e[t]})}return l.default=e,Object.freeze(l)}const je=be(s),_e=be(x),Ce=s.memo(l=>{const{title:t,children:o,accordionProps:r}=l;return e.jsxs(Te,{...r,children:[e.jsx(a.AccordionSummary,{expandIcon:e.jsx(ne,{}),"aria-controls":"panel1-content",id:"panel1-header",children:t}),e.jsx(a.AccordionDetails,{children:o})]})}),Te=a.styled(a.Accordion)(({theme:{palette:e}})=>{var l,t;return{color:null==(l=e.theme)?void 0:l.secondary[1e3],fontSize:" 0.875rem",boxShadow:"none",".MuiAccordionSummary-root":{padding:"0.625rem 1.5rem",minHeight:"0px !important",borderBottomWidth:"2px",borderBottomStyle:"solid",borderBottomColor:null==(t=e.theme)?void 0:t.secondary[200]},".MuiAccordionSummary-content":{margin:"0","&.Mui-expanded":{margin:"0rem"},"&.MuiButtonBase-root":{margin:"0","&.MuiAccordionSummary-content.Mui-expanded":{margin:"0"}}},".MuiAccordionDetails-root":{padding:"0"}}}),we=l=>{const{data:r,setData:c,setActive:u,disabledViews:m=[]}=l,[p,h]=s.useState(!1),[y,g]=s.useState("Table"),[x,v]=s.useState(!1),f=a.useTheme(),b=a.useMediaQuery(f.breakpoints.up("lg")),j=[{label:"Table",icon:e.jsx(n.images.TableIcon,{}),desc:"Easily manage, update, and organize your tasks with Table view.",image:e.jsx("img",{src:n.images.table})},{label:"Grid",icon:e.jsx(n.images.GridIcon,{}),desc:"Grid of cards, use for mood boards, index cards, and recipes",image:e.jsx("img",{src:n.images.grid})}];return e.jsxs("div",{className:"view-modal",children:[e.jsxs("div",{className:"view-modal--Header",children:["|",e.jsx(t.Button,{variant:"text",startIcon:e.jsx(d,{}),sx:b?{}:{pr:0},onClick:()=>{h(!0),v(Boolean(r.find(e=>e.label.toLowerCase()===y.toLowerCase())))},children:b?"View":""})]}),e.jsxs(t.Modal,{open:p,onClose:()=>h(!1),className:"view-modal",children:[e.jsxs(a.DialogTitle,{className:"view-modal--Head",children:[e.jsx(i.Typography,{type:"s3",weight:"medium",color:"#000",children:"Add View"}),e.jsx(a.IconButton,{onClick:()=>h(!1),children:e.jsx(o,{fontSize:"small"})})]}),e.jsxs("div",{className:"view-modal--TabsContent",children:[e.jsx(a.Tabs,{orientation:"vertical",value:y,onChange:(e,l)=>{g(l),v(Boolean(r.find(e=>e.label.toLowerCase()===l.toLowerCase())))},className:"view-modal--Tab",children:j&&(null==j?void 0:j.map(l=>e.jsx(a.Tab,{label:`${null==l?void 0:l.label} View`,iconPosition:"start",icon:null==l?void 0:l.icon,value:l.label,className:"view-modal--Tabs",disabled:Boolean(null==m?void 0:m.includes(l.label))},l.label)))}),j.map(l=>e.jsxs("div",{hidden:y!==l.label,className:"view-modal--TabData",children:[l.image,e.jsxs("div",{className:"view-modal--Desc",children:[e.jsxs(i.Typography,{type:"s1",color:"theme.secondary.1000",children:[null==l?void 0:l.label," Views"]}),e.jsx(i.Typography,{type:"s4",color:"theme.secondary.800",children:l.desc}),((null==l?void 0:l.label)===P.viewTypes.KANBAN||(null==l?void 0:l.label)===P.viewTypes.CALENDAR)&&e.jsxs("div",{className:"view-modal--BoardContainer",children:[e.jsx(i.Typography,{type:"s4",color:"theme.secondary.900",children:"Group Board by"}),e.jsxs(t.Select,{placeholder:"Status",size:"small",defaultValue:1,className:"view-modal--Select",variant:"outlined",children:[e.jsx(a.MenuItem,{value:1,children:"option 1"}),e.jsx(a.MenuItem,{value:2,children:"option 2"})]})]})]})]},l.label))]}),e.jsxs(a.DialogActions,{className:"view-modal--Actions",sx:{backgroundColor:"theme.secondary.200"},children:[e.jsx(t.Button,{variant:"text",onClick:()=>h(!1),children:"Cancel"}),e.jsxs(t.Button,{variant:"contained",onClick:()=>{const e=j.find(e=>e.label.toLowerCase()===y.toLowerCase());(null==e?void 0:e.label)&&(r.some(e=>e.label.toLowerCase()===y.toLowerCase())||(c([...r,{label:e.label,position:r.length}]),u(null==e?void 0:e.label),h(!1)))},disabled:x,children:["Add ",y," View"]})]})]})]})},Se=l=>{const{title:t,active:o,onClick:r,key:s,...d}=l,c=a.useTheme(),u=a.useMediaQuery(c.breakpoints.up("lg"));return e.jsxs("div",{className:o&&t.includes(o)?"header-card header-card--Active":"header-card",onClick:r,...d,children:[t&&t===P.viewTypes.TABLE?e.jsx(n.images.TableIcon,{}):t===P.viewTypes.GRID?e.jsx(n.images.GridIcon,{}):t===P.viewTypes.GANTT?e.jsx(n.images.GanttIcon,{}):t===P.viewTypes.CALENDAR?e.jsx(n.images.CalenderIcon,{}):t===P.viewTypes.KANBAN?e.jsx(n.images.KanbanIcon,{}):t===P.viewTypes.CHART?e.jsx(n.images.ChartIcon,{}):"",u&&e.jsxs(i.Typography,{type:"s3",color:"inherit",children:[t," View"]})]},s)},Ae=j.styled(a.Box)(({theme:{palette:e}})=>({"& input:checked + .slider":{backgroundColor:e.theme.primary[700]},"& .slider":{backgroundColor:e.theme.secondary[200],":hover":{backgroundColor:e.theme.secondary[300]}},"& input":{display:"none"}})),Pe=l=>e.jsx(Ae,{children:e.jsxs("label",{className:"switch",children:[e.jsx("input",{type:"checkbox",...l}),e.jsx("span",{className:"slider round"})]})}),ke=l=>{var o,r;const{handleOnChange:n,value:s,options:d,...c}=l,u=1===(null==(o=l.path)?void 0:o[0])||1===(null==(r=l.path)?void 0:r[1]);return e.jsx(e.Fragment,{children:u?e.jsx(t.Select,{value:s,onChange:e=>n(e.target.value),...c,className:"combinator-list",children:null==d?void 0:d.map(({name:l,label:t})=>e.jsx(a.MenuItem,{value:l,children:e.jsx(i.Typography,{type:"s4",color:"theme.secondary.1000",children:t})},l))}):e.jsx(i.Typography,{type:"s4",color:"theme.secondary.1000",className:"combinator-value",children:s})})},Ne=l=>{const{isRtl:t}=M.useLanguage(),o={...t?{marginRight:-1.5}:{}};return e.jsx(a.Box,{children:e.jsx(a.IconButton,{sx:o,size:"small",onClick:l.handleOnClick,disableRipple:!0,children:e.jsx(I.Trash,{sx:{fontSize:"1.35rem",color:"theme.grey.600","&:hover":{color:"theme.error.600"}}})})})},Me=l=>{const{t:o}=y.useTranslation(),{handleOnChange:r,value:n,options:d,...c}=l,[u,m]=s.useState();return s.useEffect(()=>{m((null==d?void 0:d.filter(e=>{var l;return Boolean(null==(l=e.label)?void 0:l.trim())}))||[])},[null==d?void 0:d.length]),e.jsx(a.Box,{width:"100%",children:e.jsxs(t.Select,{fullWidth:!0,value:n,onChange:e=>r(e.target.value),...c,className:"select-drps",variant:"outlined",renderValue:e=>{var l,t,a;return f.formatText((null==(a=null==(t=o(null==(l=null==u?void 0:u.find(l=>l.name===e))?void 0:l.label))?void 0:t.replace("_id",""))?void 0:a.replaceAll("_"," "))||"Select Default")},onClose:()=>m((null==d?void 0:d.filter(e=>{var l;return Boolean(null==(l=e.label)?void 0:l.trim())}))||[]),children:[e.jsx("div",{className:"searchbar-box-list new-searchbar",children:e.jsx(t.SearchBar,{placeholder:"Search Attributes",handleSearch:e=>(e=>{const l=((null==d?void 0:d.filter(e=>{var l;return Boolean(null==(l=e.label)?void 0:l.trim())}))||[]).filter(l=>l.name.toLowerCase().includes(e.toLowerCase()));m(l)})(e)})}),null==u?void 0:u.map(l=>{var t,r;return e.jsx(a.MenuItem,{value:l.name,children:e.jsx(i.Typography,{type:"s4",color:"theme.secondary.1000",children:f.formatText(null==(r=null==(t=o(l.label))?void 0:t.replace("_id",""))?void 0:r.replaceAll("_"," "))})},l.name)})]})})},Ie=j.styled(t.Button)(({theme:{palette:e}})=>{var l,t;return{":hover":{backgroundColor:null==(l=e.theme)?void 0:l.secondary[100]},"&.MuiButton-text":{":hover":{color:null==(t=e.theme)?void 0:t.secondary[1e3]}}}}),De=l=>{const{handleOnClick:t,...o}=l;return e.jsx(Ie,{onClick:t,...o,className:"add-filter",variant:"text",startIcon:e.jsx(w.Add,{}),children:"Add Filter"})},Be=j.styled(t.Button)(({theme:{palette:e}})=>{var l,t;return{":hover":{backgroundColor:null==(l=e.theme)?void 0:l.secondary[100]},"&.MuiButton-text":{":hover":{color:null==(t=e.theme)?void 0:t.secondary[1e3]}}}}),qe=l=>{const{handleOnClick:t,...o}=l;return e.jsx(Be,{onClick:t,...o,className:"add-group",variant:"text",startIcon:e.jsx(w.Add,{}),children:"Add Group"})},Fe=j.styled(ue.DatePicker)(({theme:{palette:e}})=>{var l,t,o,a,r,n,i,s,d,c;return{"& .MuiOutlinedInput-root":{padding:"0",color:null==(l=e.theme)?void 0:l.secondary[800],"& fieldset":{borderColor:null==(t=e.theme)?void 0:t.secondary[400]},"&:hover fieldset":{borderColor:null==(o=e.theme)?void 0:o.secondary[500]},"&.Mui-focused fieldset":{borderWidth:"0.0625rem",borderStyle:"solid",borderColor:null==(a=e.theme)?void 0:a.primary[700]},"&.Mui-error fieldset":{borderColor:null==(r=e.theme)?void 0:r.error[600]},"&.Mui-disabled":{background:null==(n=e.theme)?void 0:n.secondary[200],color:null==(i=e.theme)?void 0:i.secondary[800]},"& .MuiInputBase-input::placeholder":{color:null==(s=e.theme)?void 0:s.secondary[800],opacity:1}},"& .MuiFormHelperText-root":{marginLeft:0,color:null==(d=e.theme)?void 0:d.secondary[800],"&.Mui-error":{color:null==(c=e.theme)?void 0:c.error[600]}},"& .MuiIconButton-root":{marginRight:0},"& .MuiPickersCalendarHeader-labelContainer":{fontWeight:600}}}),Ee=s.memo(l=>{const{label:t,disabled:o,error:a,helperText:r,dataName:s,dataPosition:d,disableFutureDates:c=!1,placeholder:u,required:m=!1,disablePastDates:p=!1,defaultValue:h,textFieldProps:y,format:g,...x}=l;return e.jsxs(C.LocalizationProvider,{dateAdapter:_.AdapterDayjs,children:[t&&e.jsxs(i.Typography,{type:"s5",weight:"medium",mb:.5,color:a?"theme.error.600":"theme.secondary.800","data-position":d,"data-name":s,children:[t," ",m&&e.jsx("span",{className:"requiredStar",children:"*"})]}),e.jsx(Fe,{disabled:o,disableFuture:c,disablePast:p,slotProps:{textField:{helperText:r,error:a,placeholder:u||"MM/DD/YYYY",...y},desktopPaper:{sx:{"& .MuiButtonBase-root.Mui-selected":{color:"theme.primary.900",bgcolor:"#B6E9D6 !important"},"& .MuiButtonBase-root:hover":{color:"theme.primary.900",bgcolor:"#B6E9D6 !important"}}}},format:g||"DD-MM-YYYY",slots:{openPickerIcon:n.images.CalenderIcon},...x,defaultValue:h?v(h):void 0,className:"datePicker"})]})}),Re=a.styled(a.Checkbox)(({theme:{palette:e}})=>{var l,t,o,a;return{padding:"0rem",color:null==(l=e.theme)?void 0:l.secondary[300],borderRadius:".625rem","&.Mui-checked":{color:null==(t=e.theme)?void 0:t.primary[600],"&:hover":{color:null==(o=e.theme)?void 0:o.primary[500]}},"&.Mui-disabled":{color:null==(a=e.theme)?void 0:a.secondary[400]}}}),ze=s.memo(l=>e.jsx(Re,{icon:e.jsx(I.RecgtangleIcon,{fontSize:(null==l?void 0:l.size)||"small"}),checkedIcon:e.jsx(I.CheckBoxIcon,{fontSize:(null==l?void 0:l.size)||"small"}),disableRipple:!0,...l})),$e=({data:l,placeholder:t,onDelete:o,chipProps:a,disabled:r,selectedLabel:n="Item"})=>e.jsx(e.Fragment,{children:l.length?e.jsx(g.Chip,{type:"normal",label:e.jsxs(i.Typography,{color:"theme.secondary.1000",type:"s5",children:[l.length," ",n," Selected"]}),onDelete:o,onMouseDown:e=>e.stopPropagation(),disabled:Boolean(r),...a,sx:{...null==a?void 0:a.sx,"& .MuiChip-deleteIcon":{color:"theme.primary.800",fontSize:"1rem","&:hover":{color:"theme.primary.900"}}}}):e.jsx(i.Typography,{color:"inherit",type:"s3",children:t})}),Ve=s.memo(l=>{const{color:t,...o}=l;return e.jsx(e.Fragment,{children:e.jsx(a.Radio,{disableRipple:!0,sx:{"&, &.Mui-checked":{color:t||"theme.primary.700"}},icon:e.jsx(I.BlankCircle,{color:"theme.secondary.300",fontSize:"large"}),checkedIcon:e.jsx(I.FilledCircle,{fontSize:"large"}),...o})})}),Le=j.styled(a.Box,{shouldForwardProp:e=>"bordered"!==e&&"isSelected"!==e})(({theme:e,bordered:l})=>({display:"flex",alignItems:"center",padding:0,margin:0,...l&&{border:`1px solid ${e.palette.divider}`,borderRadius:e.shape.borderRadius,margin:e.spacing(0,3,0,0),padding:e.spacing(0,5,0,1),height:"36px",alignContent:"left","&:hover":{backgroundColor:e.palette.action.hover}}})),Oe=s.memo(({formControl:l,fieldArrayName:t,name:o,options:r,display:n,label:s,position:d,disabled:u,title:m,titlePosition:p,bordered:h=!1,defaultValue:y=""})=>e.jsxs(e.Fragment,{children:[e.jsx(i.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800","data-position":d,sx:{mb:.5},children:s}),e.jsx(c.Controller,{control:l,name:`${t}.${o}`,defaultValue:y,render:({field:l,fieldState:{error:t}})=>e.jsxs(e.Fragment,{children:[e.jsxs(a.RadioGroup,{value:l.value??y,onChange:e=>l.onChange(e.target.value),row:"row"===n,sx:{alignItems:"center",gap:1},children:[m&&"start"===p&&e.jsx(i.Typography,{type:"s4",color:"theme.secondary.800",weight:"medium",children:m}),r.map(t=>e.jsx(Le,{bordered:h,isSelected:l.value==t.value,children:e.jsx(a.FormControlLabel,{sx:{margin:0,opacity:u?.5:1},value:t.value,control:e.jsx(Ve,{checked:l.value==t.value}),label:e.jsx(i.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:t.label}),disabled:u})},t.value)),m&&"end"===p&&e.jsx(i.Typography,{type:"s4",color:"theme.secondary.800",weight:"medium",children:m})]}),t&&e.jsx(i.Typography,{type:"s5",color:"theme.error.600",children:t.message})]})})]})),Ge="parties",We="account_type",Ue="first_name",Ke="last_name",He="company_name",Ye="vat_number",Je="crn",Qe="companies",Ze="currencies",Xe="contact_no",el="email_ids",ll="responsible_person",tl="addresses",ol="contacts",al="account_id",rl="default_tax_template",nl=[{label:"Individual",value:"Individual"},{label:"Company",value:"Company"}],il={parties_id:null,address_type:null,contact_name:null,street_1:null,street_2:null,city:null,zip_code:null,state:null,country:null,email:null,mobile:null,phone:null,street_3:null,summary:null,default_shipping_address:0,default_billing_address:0,country_code:null},sl={parties_id:null,name:null,country_code:null,contact_no:null,email:null},dl=[{header:"common.party.table.addressType_header",accessorKey:"address_type",visible:!0,type:"string",editVariant:"select",editProperties:{placeholder:"Select Address Type",field_name:"address_type",validations:[{type:"required",value:!0,msg_en:"Address Type is required",msg_ar:"Address Type is required"}]},editSelectOptions:[{label:"Delivery",value:"Delivery"},{label:"Shipping",value:"Shipping"},{label:"Office",value:"Office"}]},{header:"common.party.table.addressee_header",accessorKey:"contact_name",visible:!0,type:"custom_link",editProperties:{placeholder:"Enter Addressee",field_name:"contact_name",validations:[{type:"required",value:!1,msg_en:"Contact name is required",msg_ar:"Contact name is required"}]}},{header:"common.party.table.defaultShippingAddress_header",accessorKey:"default_shipping_address",visible:!0,type:"custom_link",editVariant:"checkbox",editProperties:{field_name:"default_shipping_address"}},{header:"common.party.table.defaultBillingAddress_header",accessorKey:"default_billing_address",visible:!0,type:"custom_link",editVariant:"checkbox",editProperties:{field_name:"default_billing_address"}},{header:"common.party.table.countryCode_header",accessorKey:"country_code",visible:!0,type:"custom_link",enableEditing:!1},{header:"common.party.table.contactNumber_header",accessorKey:"phone",visible:!0,type:"custom_link",editVariant:"phone",editProperties:{field_name:"phone"}},{header:"common.party.table.addrressOne_header",accessorKey:"street_1",visible:!0,type:"string",editProperties:{placeholder:"Enter Address",field_name:"street_1",validations:[{type:"required",value:!1,msg_en:"Address is required",msg_ar:"Address is required"}]}},{header:"common.party.table.addressTwo_header",accessorKey:"street_2",visible:!0,type:"string",editProperties:{placeholder:"Enter Address",field_name:"street_2"}},{header:"common.party.table.addressThree_header",accessorKey:"street_3",visible:!0,type:"string",editProperties:{placeholder:"Enter Address",field_name:"street_3"}},{header:"common.party.table.zipCode_header",accessorKey:"zip_code",visible:!0,type:"string",editProperties:{field_name:"zip_code",placeholder:"Enter Zip Code"}},{header:"common.party.table.country_header",accessorKey:"country_name",visible:!0,type:"string",editVariant:"select",editProperties:{field_name:"country",placeholder:"Select country",valueKey:"country_id",apiType:"countries",validations:[{type:"required",value:!0,msg_en:"Country is required",msg_ar:"Country is required"}]}},{header:"common.party.table.state_header",accessorKey:"state_name",visible:!0,type:"string",editVariant:"select",editProperties:{field_name:"state",placeholder:"Select state",valueKey:"state_id",apiType:"states",validations:[{type:"required",value:!0,msg_en:"State is required",msg_ar:"State is required"}],customeFilter:(e,l)=>(null==l?void 0:l.country_name)?{"&country_id.eq":null==l?void 0:l.country_name}:null}},{header:"common.party.table.city_header",accessorKey:"city",visible:!0,type:"string",editProperties:{placeholder:"Enter City",field_name:"city",validations:[{type:"required",value:!0,msg_en:"City is required",msg_ar:"City is required"}]}},{header:"common.party.table.summary_header",accessorKey:"summary",visible:!0,type:"string",enableEditing:!1}],cl=[{header:"common.party.table.name_header",accessorKey:"name",visible:!0,type:"string",editProperties:{placeholder:"Enter Name",field_name:"name",validations:[{type:"required",value:!0,msg_en:"Name is required",msg_ar:"Name is required"}]}},{header:"common.party.table.email_header",accessorKey:"email",visible:!0,type:"string",editProperties:{placeholder:"Enter Email",field_name:"email",validations:[{type:"required",value:!0,msg_en:"Email is required",msg_ar:"Email is required"},{type:"email",value:!0,msg_en:"Invalid Email",msg_ar:"Invalid Email"}]}},{header:"common.party.table.countryCode_header",accessorKey:"country_code",visible:!0,type:"custom_link",enableEditing:!1},{header:"common.party.table.contactNumber_header",accessorKey:"contact_no",visible:!0,type:"custom_link",editVariant:"phone",editProperties:{field_name:"contact_no"}}],ul=["id","state_id","country_id","country_name","state_name","parties_id","state_data","country_data","summary"],ml=["id","summary"],pl=e=>{const{addresses:l=[],contacts:t=[],...o}=e||{};return{...o,addresses:l.map(e=>b.omit(e,...ul)),contacts:t.map(e=>b.omit(e,...ml))}},hl=e=>{if(e)return e;try{const e=window.localStorage.getItem(B.auth.storageUserKeyName);return e?JSON.parse(e):null}catch{return null}},yl=e=>{var l;return{value:null==e?void 0:e.company_id,options:[{label:(null==(l=null==e?void 0:e.company_data)?void 0:l.name)??(null==e?void 0:e.company_id),value:null==e?void 0:e.company_id}]}},gl={company:{callBack:yl},company_id:{callBack:yl}},xl=({options:l,multiple:t,placeholder:o,with_checkboxes:r,values:n,disabledIds:s,onChange:d,handleChange:c,hasParent:u,t:m})=>{const p=e=>null==s?void 0:s.includes(e),h=[];t||h.push(e.jsx(a.MenuItem,{disabled:!0,value:"",sx:{opacity:"0 !important",height:"0 !important",p:"0 !important",m:"0 !important"},children:e.jsx(i.Typography,{type:"s3",color:"theme.secondary.1000",children:e.jsx("em",{children:m(o)})})},"placeholder"));const y=Array.isArray(n)&&(null==n?void 0:n.length)>0?null==n?void 0:n.filter(e=>e):n,g=(e,l)=>{const t=l.map(e=>e.value),o=Array.isArray(y)?y:[y];return t.every(e=>o.includes(e))},x=e=>{const l=e.map(e=>e.value),t=Array.isArray(y)?y:[y];return l.some(e=>t.includes(e))};return Array.isArray(l)&&l.length>0&&l.forEach(l=>{h.push(e.jsx(a.MenuItem,{value:l.value,disabled:Boolean(l.disabled)||p(l.id||l.value),className:l.isGroup?"select--MenuItemHeader":"",children:e.jsxs(a.Box,{sx:{display:"flex",gap:1},children:[t&&r&&e.jsx(ze,{checked:u?g(l.value,l.options||[]):Boolean(Array.isArray(y)?y.includes(l.value):y==l.value),indeterminate:u&&x(l.options||[]),onChange:()=>u?((e,l)=>{const t=l.map(e=>e.value),o=Array.isArray(y)?y:[y],a=o.includes(e)?o.filter(l=>l!==e&&!t.includes(l)):[...new Set([...o,e,...t])];d(a),null==c||c(a)})(l.value,l.options||[]):null==c?void 0:c(l.value)}),e.jsx(i.Typography,{type:"s3",color:"theme.secondary.1000",onClick:()=>null==c?void 0:c(l.value),children:l.label})]})},l.value)),l.isGroup&&Array.isArray(l.options)&&l.options.forEach(o=>{h.push(e.jsx(a.MenuItem,{value:o.value,disabled:Boolean(o.disabled)||p(o.id||o.value),sx:{pl:5},children:e.jsxs(a.Box,{sx:{display:"flex",gap:1},children:[t&&r&&e.jsx(ze,{checked:Boolean(Array.isArray(n)&&n.includes(o.value))}),e.jsx(i.Typography,{type:"s3",color:"theme.secondary.1000",onClick:()=>null==c?void 0:c(String(o.value)),children:"Payment Entries"==o.label?"Payment and Collection Entries":o.label||o.value})]})},`${l.value}-${o.value}`))})}),h.length&&(1!=h.length||t)||h.push(e.jsx(a.MenuItem,{disabled:!0,children:"No data available"},"no-data")),h},vl=({data:l,options:t})=>{const o=l.map(e=>{var l;return(null==(l=null==t?void 0:t.find(l=>l.value==e))?void 0:l.label)||""}).filter(Boolean);return e.jsxs(i.Typography,{type:"s4",color:"inherit",sx:{display:"flex",gap:1,alignItems:"center",mt:.5},children:[o.slice(0,4).join(", "),l.length>4&&e.jsx(g.Chip,{variant:"outlined",type:"normal",label:e.jsx(I.MoreIcon,{})})]})},fl=()=>e.jsx(i.Typography,{fontStyle:"italic",color:"inherit",type:"s3",children:"Loading..."}),bl=s.memo(l=>{var o;const r=c.useWatch({control:l.formControl,name:`${l.fieldArrayName}.${l.name}`}),n=c.useFormContext(),{setValue:d}=n||{},u=s.useCallback((e,t)=>{var o,a;const r=l.formControl;if(!r)return;const n=e.split(".");let i=r._formValues;for(let l=0;l<n.length-1;l++)i[n[l]]||(i[n[l]]={}),i=i[n[l]];i[n[n.length-1]]=t,null==(a=null==(o=r._subjects)?void 0:o.state)||a.next({name:e,values:{...r._formValues}})},[l.formControl]),m=d??u,{t:p}=y.useTranslation(),{isRtl:h}=M.useLanguage(),{user:g}=i.useAuth();s.useMemo(()=>{if(g)return g;try{const e=window.localStorage.getItem(B.auth.storageUserKeyName);return e?JSON.parse(e):null}catch{return null}},[g]);const x=s.useRef(null),[v,j]=s.useState([]),[_,C]=s.useState(null),[T,S]=s.useState([]),[A,P]=s.useState(!1),[k,N]=s.useState(!1),[I,D]=s.useState(!1),[q,F]=s.useState(null),[E,R]=s.useState(!1),[z,$]=s.useState(""),[V,L]=s.useState(!1),[O,G]=s.useState(null),[W,U]=s.useState(!1),[K,H]=s.useState(!1),[Y,J]=s.useState({page:1,hasMore:!0,isLoadingMore:!1,total:0}),{handleOptions:Q,isInternal:Z=!1,disabledIds:X=[],getSelectedData:ee,attributes:le=[],filterKey:te="id",customeFilter:oe={},refresh:ae,handleChange:re,hasParent:ne=!1,sortOrder:ie="id:-1",apiType:se,addType:de,showCancelButton:ce=!0,customFetchApi:ue,isMergeOptions:me=!1}=l,pe=l.showItemTooltip??"salesItems"===se,he=25,ye=s.useMemo(()=>{var e;return!(me&&(se||ue)||(se||ue)&&(!Z||(se||ue)&&0==(null==(e=l.options)?void 0:e.length)))},[Z,se,ue,null==(o=l.options)?void 0:o.length,me]),ge=s.useMemo(()=>oe,[JSON.stringify(oe)]),{defaultOptions:xe=[]}=(({props:e,setValue:l,isInternalOptions:t})=>{const{user:o}=i.useAuth(),a=hl(o),[r,n]=s.useState([]);return s.useEffect(()=>{const o=hl(a),{value:r,options:i}=((e,l)=>{const{apiType:t,name:o}=e,a=gl[t||o];return a?a.callBack(l):{value:null,options:[]}})(e,o);null!=r&&("function"==typeof l&&l(`${e.fieldArrayName}.${e.name}`,(null==e?void 0:e.is_multiselect)?[r]:r),t||n(i))},[null==e?void 0:e.name,null==e?void 0:e.apiType,a,l,t]),{defaultOptions:r}})({props:l,setValue:m,isInternalOptions:ye}),ve=s.useCallback((e,t)=>{const o=l.options&&l.options.length>0?l.options:xe||[];if(!e)return o;const a=e.toLowerCase(),r=ne?(null==o?void 0:o.reduce((e,l)=>{var t;const o=null==(t=l.options)?void 0:t.filter(e=>{const l=s.isValidElement(e.label)?e.searchLabel:String(e.label);return null==l?void 0:l.toLowerCase().includes(a)});return(null==o?void 0:o.length)&&e.push({...l,options:o}),e},[]))||[]:(null==o?void 0:o.filter(e=>{const l=s.isValidElement(e.label)?e.searchLabel:String(e.label);return null==l?void 0:l.toLowerCase().includes(a)}))||[];return be(r,t)},[l.options,ne,xe]),fe=s.useCallback(e=>[...new Map(null==e?void 0:e.map(e=>[e.value,e])).values()],[]),be=s.useCallback((e,l)=>{let t=Array.isArray(l)?l:[l];return t=t.map(e=>Number(e)),b.sortBy(e,e=>{const l=t.indexOf(e.id||e.value);return-1==l?1/0:l})},[]),je=s.useMemo(()=>{if(ye)return ve(z,r);const e=be(fe([...v,...T]),r);if(me){const l=ve(z,r);return fe([...l,...e])}return e},[v,T,ye,l.options,r,z,ve,be,fe,me]),_e=s.useMemo(()=>r&&je.length&&je.find(e=>e.id===r||e.value===r)||null,[r,je]),Ce=s.useCallback(async(e="",l=ge,t=1,o=!1)=>{if(!se&&!ue)return[];P(!0),t>1&&J(e=>({...e,isLoadingMore:!0}));try{let a=[],r={};if(ue){const o=await ue({search:e,filters:l,limit:he,skip:(t-1)*he,select:null==le?void 0:le.join(","),order:ie});a=(null==o?void 0:o.data)||[],r=(null==o?void 0:o.pagination)||{}}else{const o=await f.fetchApi({apiKey:se,filters:{limit:he,skip:(t-1)*he,search:e,filters:l,select:le,order:ie}});a=(null==o?void 0:o.data)||[],r=(null==o?void 0:o.pagination)||{}}if(a&&Array.isArray(a)){const e=o?[...v,...a]:a;we(e,o),Se(a),J(e=>({...e,page:t,hasMore:((null==r?void 0:r.totalCount)||0)>t*he,total:(null==r?void 0:r.totalCount)||0,isLoadingMore:!1}))}return a||[]}catch(a){return console.error("Error fetching options:",a),J(e=>({...e,isLoadingMore:!1})),[]}finally{P(!1)}},[se,ue,v,le,ie,he,ge]),Te=s.useCallback(e=>{const{scrollTop:l,scrollHeight:t,clientHeight:o}=e.currentTarget;if(t-l<=o+10&&Y.hasMore&&!Y.isLoadingMore&&!ye){const e=Y.page+1;Ce(z,ge,e,!0)}},[Y.hasMore,Y.isLoadingMore,Y.page,ye,z,ge,Ce]),we=s.useCallback((e,l=!1)=>{const t=fe([...l?v:T,...e]);j(t)},[v,T,fe]),Se=s.useCallback(async e=>{if(!r)return;let t=l.is_multiselect?r:[r];t=Array.isArray(t)?null==t?void 0:t.filter(e=>e):[],t=Array.isArray(t)?null==t?void 0:t.map(e=>Number(e)):[];const o=null==e?void 0:e.filter(e=>Array.isArray(t)?t.includes(e.id||e.value):(e[te]||e.value||e.id)==t);return!!(Array.isArray(o)&&o.length>0)&&(null==ee||ee(l.is_multiselect?o:o[0],l.name),!0)},[l.is_multiselect,l.name,r,te,ee,je]),Ae=s.useCallback(async()=>{k||await Se(je)||(l.is_multiselect?Array.isArray(r)&&r.length>0:Boolean(r))&&(R(!0),await Ce("",{...ge,"&id.in":r},1,!1),R(!1))},[k,r,JSON.stringify(ge)]),Pe=s.useCallback(async()=>{JSON.stringify(ge)!==JSON.stringify(q)&&(F(ge),j([]),D(!1),J({page:1,hasMore:!0,isLoadingMore:!1,total:0})),ye||I||(await Ce(z,ge,1,!1),D(!0))},[ge,ye,I]),ke=s.useMemo(()=>b.debounce(async e=>{A||(e||ye||!V||(J({page:1,hasMore:!0,isLoadingMore:!1,total:0}),await Ce("",ge,1,!1)),e.length>1&&!ye&&(J({page:1,hasMore:!0,isLoadingMore:!1,total:0}),await Ce(e,ge,1,!1)))},700),[ye,V,ge]),Ne=s.useCallback(e=>{e.onChange(l.is_multiselect?[]:null),ee&&ee(null,l.name)},[l.is_multiselect,l.name,ee]),Me=s.useCallback(()=>{N(!1),z.length>0&&D(!1),L(!1),$("")},[z]),Ie=s.useCallback(()=>{U(!0)},[]),De=s.useCallback(async e=>{if(O&&O.api){H(!0);try{const t=await O.api(e);if(H(!1),U(!1),ye||(J({page:1,hasMore:!0,isLoadingMore:!1,total:0}),D(!1),await Ce("",ge,1,!1)),t&&t.data){const e=l.is_multiselect?[...r||[],t.data.id]:t.data.id;m&&m(`${l.fieldArrayName}.${l.name}`,e)}}catch(t){console.log("error",t),H(!1)}}else console.error("Add configuration is not properly set")},[O,ye,Ce,ge,l.is_multiselect,l.fieldArrayName,l.name,r,m]);s.useEffect(()=>{Q&&Q(_)},[Q,_]),s.useEffect(()=>{k&&Pe()},[k,Pe]),s.useEffect(()=>{Ae()},[Ae]),s.useEffect(()=>{ae&&(J({page:1,hasMore:!0,isLoadingMore:!1,total:0}),Ce("",ge,1,!1))},[ae,Ce,ge]),s.useEffect(()=>(k&&ke(z),()=>ke.cancel()),[z,k,ke]),s.useEffect(()=>{if(r&&!k){const e=null==v?void 0:v.filter(e=>l.is_multiselect?Array.isArray(r)&&r.includes(e.id||e.value):(e.id||e.value)==r);S(e||[])}},[r,v,l.is_multiselect]);const Be=s.useCallback(e=>Array.isArray(e)?e.filter(Boolean):[],[]);return s.useEffect(()=>{const e=Kt(de);G(e)},[de]),e.jsx(c.Controller,{control:l.formControl,name:`${l.fieldArrayName}.${l.name}`,render:({field:o,fieldState:r})=>{var n,d,c,u,m,y,g,v,f,b;return e.jsxs(e.Fragment,{children:["Select Currency"==l.placeholder&&C(o.value),pe?e.jsx(a.Tooltip,{title:(null==_e?void 0:_e.label)?String(_e.label):"",placement:"top",arrow:!0,slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,-25]}}]},tooltip:{sx:{maxWidth:500}}},children:e.jsx("span",{children:e.jsxs(t.Select,{...o,ref:x,open:k,onOpen:()=>{N(!0),setTimeout(()=>{const e=document.querySelector(`input[placeholder="Search ${l.label}"]`);console.log("Active Search input:",e),null==e||e.focus()},150)},onClose:Me,fullWidth:!0,dataPosition:l.position,dataName:`${l.fieldArrayName}.${l.name}`,placeholder:l.placeholder,label:l.label,defaultValue:l.defaultValue||(l.is_multiselect?[]:""),searchValue:z,required:"builder"!=l.formType&&l.required,size:l.size||"small",multiple:l.is_multiselect||!1,disabled:l.disabled,sx:l.is_multiselect&&(null==(n=null==o?void 0:o.value)?void 0:n.length)?{"& .MuiSelect-select":{padding:"5.5px !important"}}:{},variant:"outlined",value:E?l.is_multiselect?[]:"":(null==(d=o.value)?void 0:d.id)||o.value||(l.is_multiselect?[]:""),className:l.is_multiselect&&(null==(c=Be(o.value))?void 0:c.length)?"MultiSelect filter-select":"",MenuProps:{PaperProps:{onScroll:Te,style:{maxHeight:300}}},renderValue:t=>{if(Array.isArray(t))return e.jsx($e,{selectedLabel:l.selectedLabel,data:Be(t),placeholder:A||l.is_loading?e.jsx(fl,{}):`${p("common.search")} ${l.label}`,onDelete:l.onChipRemove,disabled:l.disabled,chipProps:{sx:{background:"#ebf9f2",border:0,"& .MuiTypography-body1":{color:"#289b64",fontWeight:"500"}}}});{const o=je.find(e=>{var l;return((null==(l=e.value)?void 0:l.id)||e.value)==t});return A||l.is_loading?e.jsx(fl,{}):(null==o?void 0:o.label)||("string"==typeof l.label?`${p("common.search")} ${l.label}`:l.placeholder)}},searchPlaceholder:`${p("common.search")} ${l.label}`,handleSearch:e=>{$(e),L(!0)},error:Boolean(null==(u=r.error)?void 0:u.message),helperText:(null==(m=r.error)?void 0:m.message)||"",onBlur:o.onBlur,input:e.jsx(a.OutlinedInput,{label:"",endAdornment:e.jsx(a.InputAdornment,{position:"end",children:A||l.is_loading?e.jsx(a.CircularProgress,{size:20,sx:{mr:3,color:"#4AC08C"}}):!l.disabled&&(l.is_multiselect?Array.isArray(o.value)&&o.value.length>0:Boolean(o.value))&&ce&&e.jsx(a.IconButton,{"aria-label":"clear selection",onClick:()=>Ne(o),edge:"end",sx:h?{ml:2.5}:{mr:1.5},size:"small",children:e.jsx(w.Close,{sx:{fontSize:"1rem"}})})})}),children:[xl({options:je,multiple:Boolean(l.is_multiselect),placeholder:l.placeholder,values:o.value,with_checkboxes:!0,disabledIds:X,onChange:o.onChange,handleChange:re,hasParent:ne,t:p}),(null==l?void 0:l.enable_footer)&&e.jsxs(a.Box,{sx:{position:"sticky",bottom:0,background:"#fff",zIndex:1},children:[e.jsx(a.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),e.jsxs(a.MenuItem,{sx:{gap:1},onClick:()=>{(null==l?void 0:l.onFooterClick)?null==l||l.onFooterClick():Ie()},children:[e.jsx(w.Add,{fontSize:"small"}),e.jsxs(i.Typography,{type:"s4",color:"theme.secondary.1000",children:["Create New ",l.label]})]})]},"footer"),Y.isLoadingMore&&e.jsx(a.MenuItem,{disabled:!0,children:e.jsx(a.Box,{sx:{display:"flex",justifyContent:"center",width:"100%"},children:e.jsx(a.CircularProgress,{size:20})})})]})})}):e.jsxs(t.Select,{...o,ref:x,open:k,onOpen:()=>{N(!0),setTimeout(()=>{const e=document.querySelector(`input[placeholder="Search ${l.label}"]`);console.log("Active Search input:",e),null==e||e.focus()},150)},onClose:Me,fullWidth:!0,dataPosition:l.position,dataName:`${l.fieldArrayName}.${l.name}`,placeholder:l.placeholder,label:l.label,defaultValue:l.defaultValue||(l.is_multiselect?[]:""),searchValue:z,required:"builder"!=l.formType&&l.required,size:l.size||"small",multiple:l.is_multiselect||!1,disabled:l.disabled,sx:l.is_multiselect&&(null==(y=null==o?void 0:o.value)?void 0:y.length)?{"& .MuiSelect-select":{padding:"5.5px !important"}}:{},variant:"outlined",value:E?l.is_multiselect?[]:"":(null==(g=o.value)?void 0:g.id)||o.value||(l.is_multiselect?[]:""),className:l.is_multiselect&&(null==(v=Be(o.value))?void 0:v.length)?"MultiSelect filter-select":"",MenuProps:{PaperProps:{onScroll:Te,style:{maxHeight:300}}},renderValue:t=>{if(Array.isArray(t))return e.jsx($e,{selectedLabel:l.selectedLabel,data:Be(t),placeholder:A||l.is_loading?e.jsx(fl,{}):`${p("common.search")} ${l.label}`,onDelete:l.onChipRemove,disabled:l.disabled,chipProps:{sx:{background:"#ebf9f2",border:0,"& .MuiTypography-body1":{color:"#289b64",fontWeight:"500"}}}});{const o=je.find(e=>{var l;return((null==(l=e.value)?void 0:l.id)||e.value)==t});return A||l.is_loading?e.jsx(fl,{}):(null==o?void 0:o.label)||("string"==typeof l.label?`${p("common.search")} ${l.label}`:l.placeholder)}},searchPlaceholder:`${p("common.search")} ${l.label}`,handleSearch:e=>{$(e),L(!0)},error:Boolean(null==(f=r.error)?void 0:f.message),helperText:(null==(b=r.error)?void 0:b.message)||"",onBlur:o.onBlur,input:e.jsx(a.OutlinedInput,{label:"",endAdornment:e.jsx(a.InputAdornment,{position:"end",children:A||l.is_loading?e.jsx(a.CircularProgress,{size:20,sx:{mr:3,color:"#4AC08C"}}):!l.disabled&&(l.is_multiselect?Array.isArray(o.value)&&o.value.length>0:Boolean(o.value))&&ce&&e.jsx(a.IconButton,{"aria-label":"clear selection",onClick:()=>Ne(o),edge:"end",sx:h?{ml:2.5}:{mr:1.5},size:"small",children:e.jsx(w.Close,{sx:{fontSize:"1rem"}})})})}),children:[xl({options:je,multiple:Boolean(l.is_multiselect),placeholder:l.placeholder,values:o.value,with_checkboxes:!0,disabledIds:X,onChange:o.onChange,handleChange:re,hasParent:ne,t:p}),(null==l?void 0:l.enable_footer)&&e.jsxs(a.Box,{sx:{position:"sticky",bottom:0,background:"#fff",zIndex:1},children:[e.jsx(a.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),e.jsxs(a.MenuItem,{sx:{gap:1},onClick:()=>{(null==l?void 0:l.onFooterClick)?null==l||l.onFooterClick():Ie()},children:[e.jsx(w.Add,{fontSize:"small"}),e.jsxs(i.Typography,{type:"s4",color:"theme.secondary.1000",children:["Create New ",l.label]})]})]},"footer"),Y.isLoadingMore&&e.jsx(a.MenuItem,{disabled:!0,children:e.jsx(a.Box,{sx:{display:"flex",justifyContent:"center",width:"100%"},children:e.jsx(a.CircularProgress,{size:20})})})]}),O&&O.component&&e.jsx(e.Fragment,{children:s.createElement(O.component,{isOpen:W,setIsOpen:U,isLoading:K,onSave:De,modalProps:{maxWidth:"md",fullWidth:!0},...null==l?void 0:l.modalComponentProps})}),l.is_multiselect&&Array.isArray(o.value)&&e.jsx(vl,{data:o.value,options:je})]})}})});bl.propTypes={name:l.PropTypes.string.isRequired,placeholder:l.PropTypes.string.isRequired,label:l.PropTypes.string.isRequired,size:l.PropTypes.string,options:l.PropTypes.arrayOf(l.PropTypes.shape({label:l.PropTypes.oneOfType([l.PropTypes.string,l.PropTypes.node]),value:l.PropTypes.any})).isRequired,formControl:l.PropTypes.object.isRequired,defaultValue:l.PropTypes.any,fieldArrayName:l.PropTypes.string.isRequired,id:l.PropTypes.string,required:l.PropTypes.bool,is_multiselect:l.PropTypes.bool,position:l.PropTypes.number,formType:l.PropTypes.string,typeOfField:l.PropTypes.string,disabled:l.PropTypes.bool,onChipRemove:l.PropTypes.func,enable_footer:l.PropTypes.bool,footer_action:l.PropTypes.string,onFooterClick:l.PropTypes.func,is_loading:l.PropTypes.bool,selectedLabel:l.PropTypes.string,isInternal:l.PropTypes.bool,disabledIds:l.PropTypes.array,getSelectedData:l.PropTypes.func,attributes:l.PropTypes.array,handleChange:l.PropTypes.func,hasParent:l.PropTypes.bool,sortOrder:l.PropTypes.string,apiType:l.PropTypes.string,handleOptions:l.PropTypes.func,filterKey:l.PropTypes.string,customeFilter:l.PropTypes.object,refresh:l.PropTypes.bool,addType:l.PropTypes.string,modalComponentProps:l.PropTypes.object,showCancelButton:l.PropTypes.bool,customFetchApi:l.PropTypes.func};const jl=j.styled(de)(({theme:{palette:e},isRtl:l})=>{var t,o,a,r,i,s,d,c,u,m,p;return{"&:hover":{border:"none"},"&.react-tel-input":{".form-control":{borderRadius:"0.25rem",padding:"8px 8px 8px 55px",border:`1px solid ${null==(t=e.theme)?void 0:t.secondary[300]}`,fontSize:"0.875rem",width:"100%",maxHeight:"36.13px",direction:"ltr",textAlign:"left",":hover":{border:`1px solid ${null==(o=e.theme)?void 0:o.secondary[400]}`},":focus":{border:`1px solid ${null==(a=e.theme)?void 0:a.primary[600]}`,boxShadow:"none"},":disabled":{background:null==(r=e.theme)?void 0:r.secondary[200],color:null==(i=e.theme)?void 0:i.secondary[800]},"&.invalid-number":{border:`1px solid ${null==(s=e.theme)?void 0:s.error[600]}`,":focus":{boxShadow:"none"}}},".flag-dropdown":{left:"0",right:"auto",borderRadius:"0.25rem 0 0 0.25rem",".selected-flag":{borderRadius:"0.25rem 0 0 0.25rem","&:hover":{backgroundColor:null==(d=e.theme)?void 0:d.secondary[100]}}},".country-list":{left:l?"auto":"0",right:l?"0":"auto",".search":{padding:"0.5rem 0.5rem 0.5rem 0.75rem",borderBottom:"1px solid #F3F2F2",display:"flex",alignItems:"center",direction:l?"rtl":"ltr",".search-emoji":{position:"absolute",left:l?"auto":"1.25rem",right:l?"1.25rem":"auto",":first-child":{display:"block",color:"transparent",background:`url(${n.images.search})`,backgroundRepeat:"no-repeat",backgroundPosition:"center"}},".search-box":{width:"100%",marginLeft:"0rem",border:`1px solid ${null==(c=e.theme)?void 0:c.secondary[200]}`,backgroundColor:null==(u=e.theme)?void 0:u.secondary[100],borderRadius:"0.5rem",padding:"0.4rem",paddingLeft:l?"0.4rem":"2rem",paddingRight:l?"2rem":"0.4rem",fontSize:"0.8125rem",direction:l?"rtl":"ltr",textAlign:l?"right":"left",":hover":{border:`1px solid ${null==(m=e.theme)?void 0:m.secondary[300]}`},":focus":{border:`1px solid ${null==(p=e.theme)?void 0:p.primary[600]}`}}},".country":{fontSize:"0.8125rem",direction:l?"rtl":"ltr",textAlign:l?"right":"left",".dial-code":{fontSize:"0.75rem",position:"absolute",right:l?"auto":"0.5rem",left:l?"0.5rem":"auto"}}}}}}),_l=j.styled("div")(()=>({marginTop:"0.4rem"})),Cl=s.memo(({name:l,error:t=!1,dataName:o,dataPosition:a,label:r,required:n=!1,placeholder:d,default_value:c,onChange:u,disabled:m,setCountryCodeField:p,helperText:h,isInlineEditing:y=!1,...g})=>{const{isRtl:x}=M.useLanguage();return s.useEffect(()=>{y&&function(){let e,l;const t=()=>{if(!e||!l)return;const t=l.getBoundingClientRect();e.style.position="fixed",e.style.top=t.bottom+"px",e.style.left=t.left+"px",e.style.zIndex="2000"};document.addEventListener("click",()=>{e=document.querySelector(".react-tel-input .country-list"),l=document.querySelector(".react-tel-input input"),e&&l&&!document.body.contains(e)&&document.body.appendChild(e),t()}),window.addEventListener("scroll",t,!0),window.addEventListener("resize",t)}()},[y]),s.useEffect(()=>{"function"==typeof p&&(null==p||p({dialCode:"971"}))},[]),e.jsxs(e.Fragment,{children:[e.jsxs(i.Typography,{type:"s5",weight:"medium",mb:.5,color:t?"theme.error.600":"theme.secondary.800","data-position":a,"data-name":o,children:[r," ",n&&e.jsx("span",{className:"requiredStar",children:"*"})]}),e.jsx(jl,{dropdownContainer:document.body,isRtl:x,specialLabel:"",enableSearch:!0,searchPlaceholder:"Search Country",isValid:!t,country:"ae",searchNotFound:"Not Found!",inputProps:{name:l,required:n},placeholder:d,value:c||(null==g?void 0:g.value),onChange:(e,l)=>{null==p||p(l),null==u||u(e)},disabled:m}),h&&e.jsx(_l,{children:e.jsx(i.Typography,{type:"s5",color:t?"theme.error.600":"theme.secondary.600",children:h})})]})}),Tl=s.memo(l=>e.jsx(c.Controller,{control:l.formControl,name:`${l.fieldArrayName}.${l.name}`,render:({field:t,fieldState:o})=>{var a,r;return e.jsx(Cl,{...t,dataPosition:l.position,dataName:`${l.fieldArrayName}.${l.name}`,label:l.label,required:"builder"!==l.formType&&l.required,placeholder:l.placeholder,default_value:l.default_value,onChange:e=>t.onChange(e),error:Boolean(null==(a=o.error)?void 0:a.message),disabled:l.disabled,helperText:(null==(r=o.error)?void 0:r.message)||"",setCountryCodeField:l.setCountryCodeField})}}));Tl.propTypes={formControl:l.PropTypes.shape({register:l.PropTypes.func.isRequired,setValue:l.PropTypes.func}).isRequired,name:l.PropTypes.string.isRequired,label:l.PropTypes.string.isRequired,fieldArrayName:l.PropTypes.string,required:l.PropTypes.bool,position:l.PropTypes.number,formType:l.PropTypes.string,placeholder:l.PropTypes.string,default_value:l.PropTypes.string,type:l.PropTypes.string,typeOfField:l.PropTypes.string,disabled:l.PropTypes.bool,setCountryCodeField:l.PropTypes.func};const wl=j.styled(me.DateTimePicker)(({theme:{palette:e}})=>{var l,t,o,a,r,n,i,s,d,c;return{"& .MuiOutlinedInput-root":{padding:"0",color:null==(l=e.theme)?void 0:l.secondary[800],"& fieldset":{borderColor:null==(t=e.theme)?void 0:t.secondary[400]},"&:hover fieldset":{borderColor:null==(o=e.theme)?void 0:o.secondary[500]},"&.Mui-focused fieldset":{borderWidth:"0.0625rem",borderStyle:"solid",borderColor:null==(a=e.theme)?void 0:a.primary[700]},"&.Mui-error fieldset":{borderColor:null==(r=e.theme)?void 0:r.error[600]},"&.Mui-disabled":{background:null==(n=e.theme)?void 0:n.secondary[200],color:null==(i=e.theme)?void 0:i.secondary[800]},"& .MuiInputBase-input::placeholder":{color:null==(s=e.theme)?void 0:s.secondary[800],opacity:1}},"& .MuiFormHelperText-root":{marginLeft:0,color:null==(d=e.theme)?void 0:d.secondary[800],"&.Mui-error":{color:null==(c=e.theme)?void 0:c.error[600]}},"& .MuiIconButton-root":{marginRight:0},"& .MuiPickersCalendarHeader-labelContainer":{fontWeight:600}}}),Sl=l=>{const{label:t,disabled:o,error:a,helperText:r,dataName:s,dataPosition:d,disableFutureDates:c=!1,placeholder:u,required:m=!1,disablePastDates:p=!1,defaultValue:h,textFieldProps:y,format:g,...x}=l;return e.jsxs(C.LocalizationProvider,{dateAdapter:_.AdapterDayjs,children:[t&&e.jsxs(i.Typography,{type:"s5",weight:"medium",mb:.5,color:a?"theme.error.600":"theme.secondary.800","data-position":d,"data-name":s,children:[t," ",m&&e.jsx("span",{className:"requiredStar",children:"*"})]}),e.jsx(wl,{disabled:o,disableFuture:c,disablePast:p,slotProps:{textField:{helperText:r,error:a,placeholder:u||"MM/DD/YYYY HH:mm:ss",...y}},format:g||"MM/DD/YYYY HH:mm:ss",slots:{openPickerIcon:n.images.CalenderIcon},...x,defaultValue:h?v(h):void 0,className:"datePicker"})]})},Al=s.memo(l=>{const{type:o,label:r,disabled:s,error:d,dataName:c,dataPosition:u,required:m,max_size:p=20,onChange:h,name:y,value:g,multiple:x,...v}=l,f=a.styled("input")({clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:1,overflow:"hidden",position:"absolute",bottom:0,left:0,whiteSpace:"nowrap",width:1}),b=a.styled(t.Button)(({theme:{palette:e}})=>{var l,t,o,a;return{marginBottom:8,"&.MuiButton-outlined":{color:null==(l=e.theme)?void 0:l.primary[1e3]},"&.Mui-disabled":{background:null==(t=e.theme)?void 0:t.secondary[200],color:null==(o=e.theme)?void 0:o.secondary[800],borderWidth:"0.0625rem",borderStyle:"solid",borderColor:null==(a=e.theme)?void 0:a.secondary[400]}}}),j=["image/jpeg","image/png","image/gif","image/bmp","image/webp","image/svg+xml","image/tiff","image/x-icon","image/heic","image/heif"],_=["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-powerpoint","application/vnd.oasis.opendocument.text","text/csv","text/plain","application/rtf","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","image/jpeg","image/png","image/gif","image/bmp","image/webp","image/svg+xml","image/tiff","image/x-icon","image/heic","image/heif"],C=e=>{if(!e)return"";if(e instanceof File)return e.name;if("string"==typeof e){const l=null==e?void 0:e.split("/");return null==l?void 0:l[(null==l?void 0:l.length)-1]}return Array.isArray(e)&&(null==e?void 0:e.length)>0?e.map(e=>{const l=null==e?void 0:e.split("/");return null==l?void 0:l[(null==l?void 0:l.length)-1]}).join(", "):void 0};return e.jsxs(e.Fragment,{children:[e.jsxs(i.Typography,{type:"s5",weight:"medium",mb:.5,color:d?"theme.error.600":"theme.secondary.800","data-position":u,"data-name":c,children:[r," ",m&&" *"]}),e.jsx("div",{style:{display:"flex"},children:e.jsxs(b,{component:"label",startIcon:e.jsx("img",{src:"image"===o?n.images.uploadImage:n.images.uploadDocument}),variant:"outlined",disabled:s,children:[e.jsx(i.Typography,{type:"s5",weight:"medium",color:"theme.secondary.1000",children:"Upload"}),e.jsx(f,{type:"file",accept:"file"===o?_.join(","):"image"===o?j.join(","):void 0,onChange:e=>{var l;const t=null==(l=[...e.target.files].map(e=>{if(e&&e.size<=1024*p*1024)return(e=>"image"===o?j.includes(e.type):"file"===o?_.includes(e.type):void 0)(e)?e:(q.enqueueSnackbar(`Invalid file type for ${e.name}. Please upload a valid document.`,{variant:"error"}),null)}))?void 0:l.filter(Boolean);h(x?(null==g?void 0:g.length)?[...g,...t]:t:t[0])},name:y,multiple:x,...v})]})}),(l=>{if(l)return Array.isArray(l)?l.map(l=>e.jsxs(a.Box,{display:"flex",gap:1,mb:1,alignItems:"center",children:["file"===o&&e.jsx(pe.Document,{fontSize:"small"}),e.jsx(i.Typography,{type:"s5",weight:"medium",color:d?"theme.error.600":"theme.secondary.800","data-position":u,"data-name":c,noWrap:!0,children:C(l)})]})):e.jsxs(a.Box,{display:"flex",gap:1,alignItems:"center",children:["file"===o&&e.jsx(pe.Document,{fontSize:"small"}),e.jsx(i.Typography,{type:"s5",weight:"medium",color:d?"theme.error.600":"theme.secondary.800","data-position":u,"data-name":c,noWrap:!0,children:C(l)})]})})(g)]})}),Pl=({column:l,row:o,col:r,errors:n,validationSchema:d,setValidationErrors:c,onChangeRowField:u,getSelectedData:m})=>{var p,h,y,g,x,f,j,_;const[C,T]=s.useState(),[w,S]=s.useState(!1),A=s.useRef(null),P=o.getAllCells().map(e=>e.column.columnDef).filter(e=>void 0===(null==e?void 0:e.enableEditing)||!0===(null==e?void 0:e.enableEditing)),k=r.editVariant,N=(null==(p=l.columnDef)?void 0:p.editProperties)||{};let M=!1;(null==N?void 0:N.disable)&&(M="function"==typeof N.disable?Boolean(null==N?void 0:N.disable(o,o._valuesCache)):Boolean(N.disable));const I=s.useCallback(async(e,l)=>{try{if("function"==typeof N.customeFilter){const t=await N.customeFilter(e,l);return A.current=t,t}A.current=null==N?void 0:N.customeFilter}catch(t){return null}},[N,o,o._valuesCache]);s.useEffect(()=>{I(o,o._valuesCache)},[I,o,o._valuesCache]);const D=null==N?void 0:N.valueKey;let B="";B="select"===k&&(null==N?void 0:N.is_multiple)?D?b.get(o.original,D,[]):[]:D?b.get(o.original,D,o.original[l.id]):o.original[l.id];const q=async(e,t,a)=>{const i=a;let s;switch(t){case"date":case"file":case"image":case"phone":s=e;break;case"text":case"number":default:s=e.target.value;break;case"checkbox":s=e.target.checked}if(T({...C,[l.id]:s}),u){const l=await u(e,t,o,r,i);l&&(o._valuesCache={...o._valuesCache,...l},T({...C,...l}))}T({...C,[l.id]:s}),o._valuesCache={...o._valuesCache,[l.id]:s},await(async e=>{try{await d.validateAt(l.id,{[l.id]:e},{abortEarly:!1});const t={};for(const e in n)e!=l.id&&(t[e]=n[e]);c(t)}catch(t){if(t instanceof _e.ValidationError){const e={};t.inner.forEach(l=>{l.path&&(e[l.path]=l.message)});const l={...n,...e};c(l)}}})(s)};s.useEffect(()=>{T({...C,...o._valuesCache})},[o._valuesCache]),s.useEffect(()=>{if(!w){const e=Object.keys(o._valuesCache||{}),l={};o.getAllCells().forEach(t=>{var a,r,n;if(void 0===(null==(a=t.column.columnDef)?void 0:a.enableEditing)||!0===(null==(r=t.column.columnDef)?void 0:r.enableEditing)){const{is_multiple:a,valueKey:r}=(null==(n=t.column.columnDef)?void 0:n.editProperties)||{};if(e.includes(t.column.id)){const e=b.get(o.original,r);l[t.column.id]="select"===k&&a?e?Array.isArray(e)?e:[e]:[]:"date"===k||"date_time"===k?e?v(e).isValid()?v(e):void 0:v(o.original[t.column.id]).isValid()?v(o.original[t.column.id]):void 0:b.get(o.original,r,o.original[t.column.id])}}}),o._valuesCache=l,T(l),S(!0)}},[o,k,w]);const F=e=>"function"==typeof e?e(o):e;return e.jsxs(e.Fragment,{children:[(!k||"number"===k)&&e.jsx(t.TextField,{defaultValue:B,onChange:e=>q(e,k),value:null==C?void 0:C[l.id],autoFocus:(null==(h=null==P?void 0:P[0])?void 0:h.accessorKey)===l.id,type:k||"text",error:!!(null==n?void 0:n[l.id]),helperText:null==n?void 0:n[l.id],placeholder:(null==N?void 0:N.placeholder)||"",name:(null==N?void 0:N.field_name)||"",disabled:M}),"select"===k&&e.jsxs(a.Box,{display:"flex",flexDirection:"column",width:"100%",children:[e.jsx(Yt,{name:(null==N?void 0:N.field_name)||"",defaultValue:B,placeholder:(null==N?void 0:N.placeholder)||"",searchPlaceholder:`Search ${r.header}`,onChange:(e,l)=>q(e,"select",l),apiType:null==N?void 0:N.apiType,autoFocus:(null==(y=null==P?void 0:P[0])?void 0:y.accessorKey)===l.id,options:null==r?void 0:r.editSelectOptions,customeFilter:A.current,filterKey:null==N?void 0:N.filterKey,labelKey:null==N?void 0:N.labelKey,valueKey:null==N?void 0:N.bindingKey,attributes:N.attributes,isInternal:(null==N?void 0:N.isInternal)||!(null==N?void 0:N.apiType),multiple:null==N?void 0:N.is_multiple,value:(null==N?void 0:N.is_multiple)?Array.isArray(null==C?void 0:C[l.id])?null==C?void 0:C[l.id]:[]:null==C?void 0:C[l.id],getSelectedData:e=>m(null==N?void 0:N.field_name,e)}),(null==n?void 0:n[l.id])&&e.jsx(i.Typography,{color:"theme.error.600",type:"s5",children:null==n?void 0:n[l.id]})]}),"date"===k&&e.jsx(Ee,{name:(null==N?void 0:N.field_name)||"",defaultValue:B,onChange:e=>q(e,"date"),textFieldProps:{autoFocus:(null==(g=null==P?void 0:P[0])?void 0:g.accessorKey)===l.id},error:!!(null==n?void 0:n[l.id]),helperText:null==n?void 0:n[l.id],format:null==N?void 0:N.dateFormat,placeholder:(null==N?void 0:N.placeholder)||(null==N?void 0:N.dateFormat),value:v(o._valuesCache[l.id]).isValid()?v(o._valuesCache[l.id]):void 0,disabled:M,minDate:()=>F(null==N?void 0:N.min_date),maxDate:()=>F(null==N?void 0:N.min_date)}),"date_time"===k&&e.jsx(Sl,{name:(null==N?void 0:N.field_name)||"",defaultValue:B,onChange:e=>q(e,"date"),textFieldProps:{autoFocus:(null==(x=null==P?void 0:P[0])?void 0:x.accessorKey)===l.id},error:!!(null==n?void 0:n[l.id]),helperText:null==n?void 0:n[l.id],format:null==N?void 0:N.dateFormat,placeholder:(null==N?void 0:N.placeholder)||(null==N?void 0:N.dateFormat),value:v(o._valuesCache[l.id]).isValid()?v(o._valuesCache[l.id]):void 0,disabled:M}),("file"===k||"image"===k)&&e.jsxs(a.Box,{display:"flex",flexDirection:"column",children:[e.jsx(Al,{name:(null==N?void 0:N.field_name)||"table_file",dataPosition:0,dataName:"table_file",label:"",type:k,max_size:10,onChange:e=>q(e,"file"),error:!!(null==n?void 0:n[l.id]),multiple:Boolean(null==l?void 0:l.is_multiple),value:o._valuesCache[l.id]}),(null==n?void 0:n[l.id])&&e.jsx(i.Typography,{color:"theme.error.600",type:"s5",children:null==n?void 0:n[l.id]})]}),"phone"===k&&e.jsx(Cl,{name:(null==N?void 0:N.field_name)||"",default_value:B,onChange:e=>q(e,"phone"),textFieldProps:{autoFocus:(null==(f=null==P?void 0:P[0])?void 0:f.accessorKey)===l.id},error:!!(null==n?void 0:n[l.id]),helperText:null==n?void 0:n[l.id],format:null==N?void 0:N.dateFormat,placeholder:(null==N?void 0:N.placeholder)||(null==N?void 0:N.dateFormat),value:null==(j=o._valuesCache)?void 0:j[l.id],disabled:M,isInlineEditing:!0}),"checkbox"===k&&e.jsx(ze,{name:(null==N?void 0:N.field_name)||"",defaultChecked:Boolean(B),onChange:e=>q(e,"checkbox"),error:!!(null==n?void 0:n[l.id]),helperText:null==n?void 0:n[l.id],format:null==N?void 0:N.dateFormat,placeholder:(null==N?void 0:N.placeholder)||(null==N?void 0:N.dateFormat),value:null==(_=o._valuesCache)?void 0:_[l.id],disabled:M})]})},kl=a.styled(a.Box,{shouldForwardProp:e=>"disableMaxHeight"!==e})(({theme:{palette:e},disableMaxHeight:l})=>{var t,o,a,r;return{".MuiTableCell-root":{border:"1px solid #efefef",borderBottom:0,borderLeft:0,padding:"0 0.5rem",lineHeight:"19px",fontSize:"14px",minHeight:32},".MuiTableCell-head":{backgroundColor:null==(t=e.theme)?void 0:t.secondary[100]},".MuiTableContainer-root":{...!l&&{maxHeight:"clamp(350px, 100vh - 200px, 9999px) !important"}},".MuiPaper-root":{boxShadow:"none"},".MuiPaginationItem-root":{"&.Mui-selected":{backgroundColor:null==(o=null==e?void 0:e.theme)?void 0:o.primary[700],color:"white"}},".MuiTableRow-root":{"&.Mui-selected":{backgroundColor:`${null==(a=null==e?void 0:e.theme)?void 0:a.primary[100]} !important`,color:"white"}},".MuiCheckbox-indeterminate":{color:`${null==(r=null==e?void 0:e.theme)?void 0:r.primary[700]} !important`,"& svg":{height:"20px !important",width:"20px !important"}}}}),Nl=s.memo(({enablePagination:l=!1,rows:o,columns:r,totalPages:c,paginationModel:u,columnOrder:m=["mrt-row-select"],updateData:p,handleColumnOrdering:h,enableEditing:x,enableColumnDragging:f,states:b,rowActionMenu:j,destructiveActionMenu:_,disableDefaultActionColumn:C,enableRowSelection:T,defaultActionColumnItems:w=[],enableBottomToolbar:S,SetSelectedRowId:P,isResetRow:k,onCreateRow:N,onEditRow:M,onDeleteRow:D,editDisplayMode:B,enableRowCreate:F,onChangeRowField:R,onSelectRow:z,enableColumnResizing:$=!0,selectedRowIds:V=[],onColumnVisibility:L,onSortingChange:O,getSelectedData:G,disabledDefaultActionColumnIcon:W=!1,enableAddCustomField:U=!0,enableRowDragging:K=!1,handleColumnResizing:H=()=>{},columnSizes:Y={},disableMaxHeight:J=!1,showPreview:Q=!1,handlePreview:ee=()=>{},...le})=>{const{t:te}=y.useTranslation(),{formData:oe=null,updatePageInfo:ae,activePage:re}=A.usePages(),ne=A.useDeepMemo(re),{pageNo:ie}=u,[se,de]=s.useState({}),[ue,me]=s.useState(r),[pe,xe]=s.useState(null),[ve,fe]=s.useState(!1),[be,je]=s.useState(null),Ce=ue.filter(e=>e.visible),Te=ue.filter(e=>!e.visible),[we,Se]=s.useState(Te),[Ae,Pe]=s.useState(null),[ke,Ne]=s.useState({}),[Me,Ie]=s.useState([]),[De,Be]=s.useState(!1),[qe,Fe]=s.useState(!1),[Ee,Re]=s.useState(!1),[ze,$e]=s.useState(null),[Ve,Le]=s.useState({}),[Oe,Ge]=s.useState(!1),[We,Ue]=s.useState([]),[Ke,He]=s.useState(!1),[Ye,Je]=s.useState(ne.column_sizes),[Qe,Ze]=s.useState({columnSizingStart:[],deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,startOffset:null,startSize:null}),Xe=E.useNavigate(),el=location.pathname.split("/")[2];let ll="";switch(el){case"accounting":ll=ye.PathnameAccounting.CUSTOM_FORM;break;case"inventory":ll=ye.PathnameInventory.CUSTOM_FORM;break;case"manufacturing":ll=ye.PathnameManufacturing.CUSTOM_FORM;break;case"procurement":ll=ye.PathnamePurchase.CUSTOM_FORM;break;case"crm":ll=ye.PathnameCrm.CUSTOM_FORM;break;case"user":ll=ge.PathnameUsers.CUSTOM_FORM;break;case"rental":ll=ye.PathnameRental.CUSTOM_FORM;break;case"drive":ll=he.PathnameDocument.ADD_CUSTOM_FIELDS}const tl=`/dashboard/${el}${ll}`,ol=(e,l,t)=>{var o;let a=e;switch(l.type){case"required":a=l.value?e.required(l.msg_en).typeError(l.msg_en):(null==(o=null==t?void 0:t.editProperties)?void 0:o.is_multiple)?e.min(1,l.msg_en):e;break;case"min":a=e.min(l.value,l.msg_en);break;case"email":a=e.email(l.value,l.msg_en);break;case"max":a=e.max(l.value,l.msg_en);break;case"positive":a=!0===l.value?e.test("is-positive-number","Value must be a positive number",e=>!e||e>=0):e;break;case"when":return e.when(l.relation,{is:e=>e===l.values,then:()=>{var o;return(null==(o=null==l?void 0:l.thenValidations)?void 0:o.reduce((e,l)=>ol(e,l,t),e))||e},otherwise:()=>{var o;return(null==(o=null==l?void 0:l.otherWiseValidations)?void 0:o.reduce((e,l)=>ol(e,l,t),e))||e}});default:a=e}return"required"!=l.type||!l.value||(null==t?void 0:t.editVariant)&&"text"!=(null==t?void 0:t.editVariant)||(a=e.test("no-blank-spaces","Blank space is not allowed",e=>{var l;return e&&(null==(l=e.trim())?void 0:l.length)>0})),a};s.useEffect(()=>{me(r);const e=(e=>{const l={};return e.forEach(e=>{var t,o,a;if(null==(o=null==(t=null==e?void 0:e.editProperties)?void 0:t.validations)?void 0:o.length){const t=null==(a=null==e?void 0:e.editProperties)?void 0:a.validations.reduce((l,t)=>ol(l,t,e),(e=>{var l;switch(e.editVariant){case"select":return(null==(l=null==e?void 0:e.editProperties)?void 0:l.is_multiple)?_e.array():_e.string();case"number":return _e.number().nullable().transform((e,l)=>""===l?null:e);case"url":return _e.string().matches(/^(https?:\/\/)?((([a-zA-Z0-9_-]+\.)+[a-zA-Z]{2,})|localhost)(:\d{2,5})?(\/[a-zA-Z0-9#_-]+\/?)*(\?[a-zA-Z0-9&=_-]+)?(#\S+)?$/,{excludeEmptyString:!0,message:"Please enter valid URL."});default:return _e.string()}})(e));l[e.accessorKey]=t}}),l})(r);Ie(_e.object().shape(e))},[r]),s.useEffect(()=>{(null==Qe?void 0:Qe.isResizingColumn)||(ae({column_sizes:{...ne.column_sizes,...Ye}}),null==H||H(Ye))},[null==Qe?void 0:Qe.isResizingColumn,Ye]);const al=e=>{xe(e.currentTarget)},rl=(e,l)=>{const t={};return Object.keys(e).forEach(o=>{const a=e[o];t[o]=a;const r=l.find(e=>e.accessorKey==o);a&&(a instanceof File&&(t[o]=a.name),r&&"date"==(null==r?void 0:r.editVariant)&&(t[o]=v(a).format((null==r?void 0:r.dateFormat)||"DD-MM-YYYY")))}),t},nl=s.useCallback(e=>{var l;return null==(l=null==e?void 0:e.validations)?void 0:l.some(e=>"required"===e.type)},[]);s.useEffect(()=>{const e={};!Oe&&V.length&&(o.forEach(l=>{V.includes(l.id)&&(e[l.id]=!0)}),Le(e),Ge(!0))},[o,V]),s.useEffect(()=>{if(O instanceof Function){const e=Array.isArray(We)?We:[];O(e[0]||null)}},[We]);const il=()=>{Le({}),He(!1)},sl=e=>{const l=document.createElement("canvas").getContext("2d");return l?l.measureText(e).width+5:50},dl=ce.useMaterialReactTable({defaultColumn:{minSize:0,size:void 0},columns:[...Ce.map(l=>(sl(l.header||""),Math.max(...o.map(e=>sl(String(e[l.accessorKey]??"")))),{...l,..."row"===B?{Edit:({cell:t,row:o,table:a,column:r})=>e.jsx(Pl,{cell:t,column:r,col:l,row:o,table:a,callback:e=>console.log("Save",e),errors:ke,validationSchema:Me,setValidationErrors:Ne,onChangeRowField:R,getSelectedData:(e,l)=>null==G?void 0:G(e,l)})}:{},Header:e.jsxs(a.Box,{display:"flex",alignItems:"center",children:[l.header,(null==l?void 0:l.required)||nl(null==l?void 0:l.editProperties)&&e.jsx(i.Typography,{type:"s5",color:"theme.error.600",children:"*"})]}),enableColumnDragging:"actions"!==l.id,size:void 0,maxSize:800})),...Q?[{id:"preview",enableEditing:!1,size:70,header:e.jsx(a.IconButton,{size:"small",sx:{ml:"20px","&:hover":{backgroundColor:"transparent"}},children:e.jsx("img",{src:n.images.common.eyeIcon,alt:"Eye Icon"})}),enableColumnDragging:!1,visible:!0,muiTableHeadCellProps:{className:"pinned-column"},muiTableBodyCellProps:{className:"pinned-column",sx:{whiteSpace:"pre-wrap"}},Cell:l=>e.jsx(t.Button,{size:"small",variant:"outlined",onClick:()=>{return e=l.row.original,void(null==ee||ee(e));var e},children:"Preview"})}]:[],...C?[]:[{id:"actions",enableEditing:!1,size:(null==w?void 0:w.length)>1?80:50,header:e.jsx(a.IconButton,{size:"small",sx:{p:.5,"&:hover":{backgroundColor:"transparent"}},onClick:al,children:e.jsx("img",{src:n.images.common.arrowIcon,alt:"Arrow Icon"})}),enableColumnDragging:!1,visible:!0,muiTableHeadCellProps:{className:"pinned-column"},muiTableBodyCellProps:{className:"pinned-column"},Cell:l=>(null==w?void 0:w.length)?w.map(e=>{const t={...e.props,onClick:()=>e.props.onClick(l)};return s.cloneElement(e,t)}):!W&&e.jsx(a.IconButton,{onClick:e=>{return t=e,o=l.row.original,de(o),void je(t.currentTarget);var t,o},disabled:!(null==j?void 0:j.length)&&!(null==_?void 0:_.length),children:e.jsx("img",{src:n.images.more,alt:"More Icon"})})}]],data:o,muiTableContainerProps:{sx:{...J&&{maxHeight:"none !important"}}},muiTablePaperProps:{sx:{tableLayout:"auto"}},columnResizeMode:"onChange",onEditingRowSave:async e=>{try{await Me.validate(e.values,{abortEarly:!1}),Ne({}),Fe(!0),He(!1);const l=e.row.getAllCells().map(e=>e.column.columnDef);e.row._valuesCache=rl(e.values,l),M&&await M(e,"edit"),Fe(!1),e.table.setEditingRow(null)}catch(l){if(Fe(!1),l instanceof _e.ValidationError){const e={};l.inner.forEach(l=>{l.path&&(e[l.path]=l.message)}),Ne(e)}else l instanceof Error?q.enqueueSnackbar(l.message,{variant:"error"}):q.enqueueSnackbar("Something went wrong",{variant:"error"})}},onCreatingRowSave:async e=>{try{await Me.validate(e.values,{abortEarly:!1}),Ne({}),Be(!0),He(!1);const l=e.row.getAllCells().map(e=>e.column.columnDef);e.row._valuesCache=rl(e.values,l),N&&await N(e),Be(!1),e.table.setCreatingRow(null)}catch(l){if(Be(!1),l instanceof _e.ValidationError){const e={};l.inner.forEach(l=>{l.path&&(e[l.path]=l.message)}),Ne(e)}else l instanceof Error?q.enqueueSnackbar(l.message,{variant:"error"}):q.enqueueSnackbar("Something went wrong",{variant:"error"})}},onCreatingRowCancel:()=>il(),onEditingRowCancel:()=>il(),onSortingChange:(null==b?void 0:b.sorting)?O:Ue,displayColumnDefOptions:{"mrt-row-actions":{Header:e.jsx(a.IconButton,{onClick:al,size:"small",children:e.jsx("img",{src:n.images.common.arrowIcon,alt:"Arrow Icon"})}),muiTableBodyCellProps:{sx:{"& .MuiBox-root":{gap:0},backgroundColor:"#fff"},onKeyUp:e=>console.log(e)}},"mrt-row-expand":{size:70},"mrt-row-select":{size:50}},renderRowActions:({row:l,table:o})=>e.jsx(e.Fragment,{children:(null==le?void 0:le.enableExpanding)?e.jsx(e.Fragment,{children:(null==l?void 0:l.parentId)&&e.jsxs(a.Box,{sx:{display:"flex",gap:0},children:[e.jsx(t.Tooltip,{title:"Edit",children:e.jsx(a.IconButton,{disabled:Ke,onClick:()=>{o.setEditingRow(l),He(!0)},size:"small",children:e.jsx(I.Edit,{fontSize:"small",sx:{color:"theme.secondary.1000"}})})}),D&&e.jsx(t.Tooltip,{title:"Delete",children:e.jsx(a.IconButton,{disabled:Ke,onClick:()=>$e(l),size:"small",children:e.jsx(I.Trash,{fontSize:"small",sx:{color:"theme.secondary.1000"}})})})]})}):e.jsxs(a.Box,{sx:{display:"flex",gap:0},children:[e.jsx(t.Tooltip,{title:"Edit",children:e.jsx(a.IconButton,{disabled:Ke,onClick:()=>{o.setEditingRow(l),He(!0)},children:e.jsx(I.Edit,{fontSize:"small",sx:{color:"theme.secondary.1000"}})})}),D&&e.jsx(t.Tooltip,{title:"Delete",children:e.jsx(a.IconButton,{onClick:()=>$e(l),children:e.jsx(I.Trash,{fontSize:"small",sx:{color:"theme.secondary.1000"}})})})]})}),...Boolean(F)&&{renderBottomToolbarCustomActions:({table:l})=>e.jsx(t.Button,{variant:"outlined",startIcon:e.jsx(d,{}),className:"add-row-btn",disabled:Ke,onClick:()=>{l.setCreatingRow(!0),He(!0)},children:te("common.add")})},onRowSelectionChange:Le,enableColumnOrdering:!0,enableRowSelection:T??!0,enableEditing:x instanceof Function?x():x??!0,editDisplayMode:B??"cell",createDisplayMode:"row",enableColumnResizing:$,enableRowDragging:K,enableTopToolbar:!1,enableColumnActions:!1,enableSorting:!0,enableGrouping:!0,enableBottomToolbar:S??!1,enableColumnDragging:f??!0,enableStickyHeader:!0,enableSortingRemoval:!1,state:{columnOrder:m,columnPinning:{left:["actions","mrt-row-actions"]},isSaving:De||qe,showProgressBars:!1,rowSelection:Ve,...b,sorting:Array.isArray(null==b?void 0:b.sorting)?null==b?void 0:b.sorting:Array.isArray(We)?We:[],columnSizing:Ye},getRowId:e=>null==e?void 0:e.id,muiTableBodyRowProps:({row:e})=>{var l,t,o,a,r;const n=(null==(t=null==(l=dl.getState())?void 0:l.editingRow)?void 0:t.id)||(null==(a=null==(o=dl.getState())?void 0:o.creatingRow)?void 0:a.id)||null,i=Boolean(null==(r=null==e?void 0:e.original)?void 0:r.has_error);return{onClick:()=>{return l=e.id,void Pe(l);var l},sx:{cursor:"pointer",backgroundColor:n?"inherit":i?"theme.error.100":"inherit","&:hover":{backgroundColor:n?"transparent":i?"theme.error.200":"#e8e8e8"},"&:hover td:after":{backgroundColor:"transparent"}}}},onColumnOrderChange:e=>{h&&h(e)},onColumnSizingChange:Je,onColumnSizingInfoChange:Ze,renderEmptyRowsFallback:()=>e.jsxs(a.Box,{className:"no-data",children:[e.jsx("img",{src:n.images.common.tableNoData}),e.jsx(i.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:te("common.noData")})]}),enablePagination:l,paginationDisplayMode:"pages",muiPaginationProps:{shape:"rounded",page:ie,count:c,showRowsPerPage:!1,boundaryCount:3},muiEditTextFieldProps:({row:e,column:l})=>({InputProps:{disableUnderline:!0},onBlur:t=>{p(t.target.value,l,e.id)},variant:"outlined",sx:({palette:e})=>{var l;return{"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:`${null==(l=e.theme)?void 0:l.primary[700]} !important`}}}}}),muiCircularProgressProps:{sx:{color:"#289B64"}},muiTableHeadCellProps:{sx:{lineHeight:"140%",letterSpacing:"-0.28px",fontWeight:"500",fontSize:"0.875rem","& .Mui-TableHeadCell-Content":{height:"100%"},"& .Mui-TableHeadCell-Content-Labels":{width:"100%",justifyContent:"space-between"},"&.pinned-column":{backgroundColor:"#fff"},"& .Mui-TableHeadCell-ResizeHandle-Wrapper":{padding:0,margin:0,right:"-5px",opacity:0}}},muiTableBodyProps:{sx:{zIndex:500}},muiTableHeadProps:{sx:{zIndex:600}},muiTableBodyCellProps:()=>({sx:{lineHeight:"140%",letterSpacing:"-0.26px",fontWeight:"400",fontSize:"0.8125rem","&.pinned-column":{backgroundColor:"#fff"},"&:hover":{backgroundColor:"transparent"}}}),muiSelectCheckboxProps:{sx:{color:"theme.secondary.300","&.Mui-checked":{color:"theme.primary.600","&:hover":{color:"theme.primary.500"}},"&.Mui-disabled":{color:"theme.secondary.200"}},icon:e.jsx(I.RecgtangleIcon,{sx:{width:20,height:20}}),checkedIcon:e.jsx(I.CheckBoxIcon,{sx:{width:20,height:20}})},muiSelectAllCheckboxProps:{sx:{color:"theme.secondary.300","&.Mui-checked":{color:"theme.primary.600","&:hover":{color:"theme.primary.500"}},"&.Mui-disabled":{color:"theme.secondary.600"}},icon:e.jsx(I.RecgtangleIcon,{sx:{width:20,height:20}}),checkedIcon:e.jsx(I.CheckBoxIcon,{sx:{width:20,height:20}})},muiBottomToolbarProps:{sx:{boxShadow:"none","& .MuiBox-root":{paddingLeft:0}}},layoutMode:"grid",icons:{ArrowDownwardIcon:l=>e.jsx(I.ArrowUpDown,{fontSize:"medium",...l}),SortIcon:l=>e.jsx(I.ArrowUpDown,{fontSize:"medium",...l}),SyncAltIcon:()=>e.jsx(I.ArrowUpDown,{fontSize:"medium"}),CancelIcon:l=>e.jsx(I.Close,{fontSize:"small",...l,sx:{color:"theme.secondary.1000"}}),SaveIcon:l=>e.jsx(I.Save,{...l,fontSize:"small",sx:{color:"theme.secondary.1000"}})},...le});return s.useEffect(()=>{var e,l;T&&(null==(e=null==dl?void 0:dl.getSelectedRowModel())?void 0:e.rows)&&(null==P||P(null==(l=null==dl?void 0:dl.getSelectedRowModel())?void 0:l.rows))},[T]),s.useEffect(()=>{if(z)if(null==le?void 0:le.enableExpanding){const e=[],l=dl.getState().rowSelection,t=(o,a="")=>{o.forEach((o,r)=>{var n;const i=a?`${a}.${r}`:`${o.id}`;l[i]&&e.push(o),(null==(n=o.subRows)?void 0:n.length)&&t(o.subRows,i)})};t(dl.getRowModel().rows),z(e,Ve)}else z(dl.getSelectedRowModel().rows,Ve)},[Ve,dl]),s.useEffect(()=>{k&&(null==dl||dl.resetRowSelection())},[k,dl]),e.jsxs(kl,{className:"MRT-TableWrapper custom-table",disableMaxHeight:J,children:[e.jsx(ce.MaterialReactTable,{table:dl}),e.jsx(g.Menu,{anchorEl:pe,open:Boolean(pe),onClose:()=>{xe(null)},className:"add-role-drp",children:ve?e.jsxs("div",{children:[e.jsxs(a.MenuItem,{onClick:()=>{fe(!1)},className:"role-drp-list add-column-title",children:[e.jsx(a.ListItemIcon,{className:"add-icon",children:e.jsx(Z,{})}),e.jsx(a.ListItemText,{className:"title",children:te("common.addColumn_label")})]}),e.jsx(a.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),e.jsx("div",{className:"searchbar-box-list",children:e.jsx(t.SearchBar,{placeholder:"Search User",handleSearch:e=>(e=>{const l=Te.filter(l=>l.header.toLowerCase().includes(e.toLowerCase()));Se(l)})(e)})}),e.jsx("div",{className:"all-attribute-title",children:e.jsx(i.Typography,{variant:"body2",color:"text.secondary",children:te("common.allAttributes_label")})}),we.map(l=>e.jsx(a.MenuItem,{onClick:()=>(e=>{const l=ue.map(l=>({...l,visible:l.accessorKey===e.accessorKey||l.visible}));null==L||L(JSON.parse(JSON.stringify(l))),me(l);const t=we.filter(l=>l.accessorKey!==e.accessorKey);Se(t),xe(null),fe(!1)})(l),children:e.jsx(i.Typography,{color:"theme.secondary.1000",type:"s3",children:l.header})},l.accessorKey)),e.jsx(a.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),U&&e.jsxs(a.MenuItem,{onClick:()=>{Xe(tl,{state:oe}),xe(null),fe(!1)},className:"role-drp-list",children:[e.jsx(a.ListItemIcon,{className:"add-icon",children:e.jsx("img",{src:n.images.common.addIcon,alt:"Add Icon"})}),e.jsx(a.ListItemText,{className:"title",children:te("common.addCustomField_label")})]})]}):e.jsxs(e.Fragment,{children:[Ce.map(l=>e.jsxs(a.MenuItem,{onClick:()=>(e=>{const l=ue.map(l=>({...l,visible:l.accessorKey!==e.accessorKey&&l.visible}));me(l),null==L||L(JSON.parse(JSON.stringify(l))),Se([...we,e]),xe(null)})(l),className:"role-drp-list",children:[e.jsx(a.ListItemIcon,{className:"add-icon",children:e.jsx("img",{src:n.images.common.dotsIcon,alt:"Add Icon"})}),e.jsx(a.ListItemText,{className:"title",children:l.header}),e.jsx(a.ListItemIcon,{className:"eye-icon",children:e.jsx("img",{src:n.images.common.eyeIcon,alt:"Eye Icon"})})]},l.accessorKey)),e.jsx(a.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),e.jsxs(a.MenuItem,{onClick:()=>{fe(!0)},className:"role-drp-list",children:[e.jsx(a.ListItemIcon,{className:"add-icon",children:e.jsx("img",{src:n.images.common.addIcon,alt:"Add Icon"})}),e.jsx(a.ListItemText,{className:"title",children:te("common.addColumn_label")}),e.jsx(i.Typography,{variant:"body2",color:"text.secondary",className:"eye-icon",children:e.jsx(X,{sx:{fontSize:"1.25rem !important"}})})]})]})}),e.jsxs(g.Menu,{anchorEl:be,open:Boolean(be),onClose:()=>{je(null)},children:[null==j?void 0:j.map(l=>e.jsxs(a.MenuItem,{onClick:async()=>{await l.handleAction(se),je(null)},disabled:"function"==typeof l.disabled?l.disabled(se):Boolean(l.disabled),sx:{alignItems:"center",gap:.5},children:[null==l?void 0:l.icon,e.jsx(i.Typography,{type:"s4",color:"inherit",children:"function"==typeof l.label?l.label(se):l.label})]})),(null==_?void 0:_.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx(a.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),e.jsx("div",{className:"dropdown-inner--DestructiveHeader",children:null==_?void 0:_.map(l=>e.jsx(a.MenuItem,{onClick:()=>{l.handleAction(se),je(null)},className:"dropdown-inner--DestructiveActions",disabled:"function"==typeof l.disabled?l.disabled(se):Boolean(l.disabled),children:e.jsx(i.Typography,{type:"s4",color:"inherit",children:"function"==typeof l.label?l.label(se):l.label})}))})]})]}),e.jsx(t.ConfirmPopUp,{open:Boolean(ze),onClose:()=>$e(null),onConfirm:()=>(async()=>{Re(!0),ze&&(await(null==D?void 0:D(ze)),$e(null)),Re(!1)})(),title:"Delete Item",description:"Are you sure you want to delete entry ?",loading:Ee})]})}),Ml=j.styled(a.CircularProgress)(({theme:e})=>{var l;return{color:null==(l=e.palette)?void 0:l.theme.primary[500]}}),Il=j.styled(a.Box)(()=>({position:"absolute",display:"flex",width:"100%",height:"100%",justifyContent:"center",alignItems:"center",backgroundColor:"#ffffff96",zIndex:3,left:0,top:0})),Dl=l=>e.jsx(Il,{children:e.jsx(Ml,{size:50,...l})}),Bl={state:"",country:""};function ql({isOpen:l,handleModalClose:o,modalProps:r,type:n,partyCreated:d,isLoading:u,onSave:m,setIsOpen:p}){const{t:h}=y.useTranslation(),x=ae.useDispatch(),{user:v}=i.useAuth(),j=s.useRef(Bl),[_,C]=s.useState([]),[T,S]=s.useState([]),[P,k]=s.useState(!1);s.useState([]);const{control:N,formState:{errors:M},trigger:I,getValues:D,handleSubmit:B,setValue:F,resetField:E,reset:R,watch:z,getFieldState:$}=c.useForm({defaultValues:{status:!0,parties:{account_type:"Company"}},mode:"all",resolver:t.o(_e.object().shape({[Ge]:_e.object().shape({[We]:_e.string().required("Customer type is required"),[Ue]:_e.string().when("account_type",{is:e=>"Individual"===e,then:()=>_e.string().required("First name is required"),otherwise:()=>_e.string().optional().nullable()}),[Ke]:_e.string().when("account_type",{is:e=>"Individual"===e,then:()=>_e.string().required("Last name is required"),otherwise:()=>_e.string().optional().nullable()}),[He]:_e.string().when("account_type",{is:e=>"Company"===e,then:()=>_e.string().required("Company is required"),otherwise:()=>_e.string().optional().nullable()}),[Ye]:_e.string().optional().nullable(),[Je]:_e.string().optional().nullable(),[Qe]:_e.mixed().required("Company is required"),[Ze]:_e.array().required("Currency is required"),[ll]:_e.string().required("Responsible Person is required"),[tl]:_e.array().nullable().notRequired(),[ol]:_e.array().required("Please add atleast one Contact").min(1,"Please add atleast one Contact"),[al]:_e.number().required("Receivable account is required"),[rl]:_e.number().required("Tax template is required")})}))}),V={[al]:"receivable_account",[rl]:"default_tax"};A.useAccountingSetting({fieldToUpdate:V,companyField:Qe,fieldArrayName:Ge,formMethods:{control:N,setValue:F,watch:z,getFieldState:$},isUpdateAccount:!0});const L=c.useWatch({control:N,name:"parties.account_type"}),O=c.useWatch({control:N,name:`${Ge}.${ll}`}),G=c.useWatch({control:N,name:`${Ge}.${Xe}`}),W=c.useWatch({control:N,name:`${Ge}.${el}`}),U=s.useCallback((l,t)=>{const o=new Map;return g.transformTableColumns({columns:l,currencySymbol:void 0,translationFn:h,enableFooter:!1,redirectionLink:void 0,redirectionLinkState:void 0,rows:t,statusClasses:void 0,customizeValue:(l,t,r)=>{var n,i;switch(t){case"default_shipping_address":case"default_billing_address":return e.jsx(a.Box,{sx:{display:"flex",gap:1},children:e.jsx(ze,{checked:Boolean(r),sx:{pointerEvents:"none"}})});case"phone":case"contact_no":{if(!r)return"";const e=`phone-${r}`;if(!o.has(e)){const l=xe(`+${r}`);o.set(e,(null==l?void 0:l.nationalNumber)||"")}return o.get(e)}case"country_code":{const e=(null==(n=null==l?void 0:l.original)?void 0:n.phone)||(null==(i=null==l?void 0:l.original)?void 0:i.contact_no);if(!e)return"";const t=`country-${e}`;if(!o.has(t)){const l=xe(`+${e}`);o.set(t,(null==l?void 0:l.countryCallingCode)?`+${l.countryCallingCode}`:"")}return o.get(t)}default:return r}}})},[h]),K=async(e,l,t,o)=>{var a,r,n,i,s,d,c,u;try{const{values:m,row:p}=e,h=p.index>=0,y=o?il:sl,g={};for(const e in y)b.has(m,e)&&(g[e]=(null==m?void 0:m[e])?m[e]:null);if(o){const e={c:null==(a=j.current)?void 0:a.country,s:null==(r=j.current)?void 0:r.state},o={...await H(g,l,p.index),country_name:null==(n=e.c)?void 0:n.name,country:null==(i=e.c)?void 0:i.id,state_name:null==(s=e.s)?void 0:s.name,state:null==(d=e.s)?void 0:d.id,country_data:e.c,state_data:e.s,country_id:null==(c=e.c)?void 0:c.id,state_id:null==(u=e.s)?void 0:u.id};return t(h?l.map((e,l)=>l===p.index?{...e,...o}:e):[...l,o])}return t(h?l.map((e,l)=>l===p.index?{...e,...g}:e):[...l,g])}catch(m){return Promise.reject(m)}},H=async(e,l,t)=>{let o={...e};const a=a=>{const r=[...l],n="shipping"===a?"default_shipping_address":"default_billing_address";t>=0&&r.splice(t,1);const i=r.some(e=>null==e?void 0:e[n]);if(i&&(null==e?void 0:e[n]))throw new Error(`Another address is already marked as the default ${a} address. Please uncheck that before selecting this one`);i||(o={...o,[n]:(null==e?void 0:e[n])||0==(null==l?void 0:l.length)?1:0})};return await a("shipping"),await a("billing"),o},Y=async(e,l,t)=>{const o=t.index;return l(e.filter((e,l)=>l!==o)),Promise.resolve()},J=async(e,l,t,o,a)=>{var r,n;const i=null==(r=null==e?void 0:e.target)?void 0:r.name;let s=null;if((null==(n=null==o?void 0:o.editProperties)?void 0:n.field_name)&&(j.current={...j.current,[o.editProperties.field_name]:a}),"country"===i)s={...t._valuesCache,country:a.id,country_id:a.id,state:null,state_id:null,state_name:null};else if("state"===i)s={...t._valuesCache,state:a.id,state_id:a.id};else if("phone"===i){const l=xe(`+${e}`);s={...t._valuesCache,country_code:(null==l?void 0:l.countryCallingCode)?`+${l.countryCallingCode}`:""}}const d=["contact_name","street_1","street_2","street_3","zip_code","city","state","country"];if(t._valuesCache){const l=d.map(l=>{var o,a,r,n,s,d;return"country"===l?(null==(a=null==(o=j.current)?void 0:o.country)?void 0:a.name)||"":"state"===l?(null==(n=null==(r=j.current)?void 0:r.state)?void 0:n.name)||"":l===i?(null==(s=e.target)?void 0:s.value)||"":(null==(d=t._valuesCache)?void 0:d[l])||""}).reduce((e,l,t)=>l?e?(l=(null==l?void 0:l.name)||l,e=(null==e?void 0:e.name)||e,[2,3].includes(t)?`${e} ${l}`:`${e}, \n${l}`):l:e,"");t._valuesCache.summary=l}return s&&t.getAllCells().forEach(e=>{b.has(s,e.column.id)&&(t._valuesCache[e.column.id]=s[e.column.id])}),t._valuesCache},Q=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,Z=async()=>{var e,l,t,o;if(!(await I()))return;const a=D(),r=null==a?void 0:a[Ge];let i=[];(null==r?void 0:r.email_ids)&&(i=null==(e=null==r?void 0:r.email_ids)?void 0:e.split(/\s*,\s*/).map(e=>{var l;return null==(l=null==e?void 0:e.replaceAll(",",""))?void 0:l.trim()}).filter(e=>e.match(Q)));const s={party:{...pl(r),email_ids:i,account_type:L,status:1,type:n,company_id:(null==r?void 0:r[Qe])||null}};if("function"!=typeof m){k(!0);try{const e=await x(ve.createParties(s));if("fulfilled"===(null==(l=null==e?void 0:e.meta)?void 0:l.requestStatus))q.enqueueSnackbar(`${n} ${h("common.party.msg.success")}`),X(),d();else if("rejected"===(null==(t=null==e?void 0:e.meta)?void 0:t.requestStatus)){const l=f.getErrorMessage(null==(o=null==e?void 0:e.error)?void 0:o.message);q.enqueueSnackbar(l,{variant:"error"})}}finally{k(!1)}}else null==m||m(s)},X=()=>{ee(),C([]),S([]),null==o||o(),null==p||p(!1)},ee=()=>{R()};s.useEffect(()=>{const e=_.map(e=>b.omit(e,ul));F(`${Ge}.${tl}`,e)},[_,F]),s.useEffect(()=>{const e=T.map(e=>b.omit(e,ml));F(`${Ge}.${ol}`,e)},[T,F]),s.useEffect(()=>{k(u)},[u]),s.useEffect(()=>{"Individual"===L&&(E("parties.company_name"),E("parties.vat_number"),E("parties.crn")),"Company"===L&&(E("parties.first_name"),E("parties.last_name"))},[L,E]),s.useEffect(()=>{var e,t;if(l&&(null==v?void 0:v.company_data)){const l=(null==v?void 0:v.entity_priority)||(null==(e=null==v?void 0:v.company_data)?void 0:e.id)||Array.isArray(null==v?void 0:v.company_data)&&(null==(t=null==v?void 0:v.company_data[0])?void 0:t.id)||null;l&&(F("quotation.company_id",l),F(`${Ge}.${Qe}`,l))}},[l,null==v?void 0:v.company_data,F]),s.useEffect(()=>{if(l&&(null==v?void 0:v.company_currencies)){const e=Object.values(v.company_currencies);e.length>0&&F(`${Ge}.${Ze}`,[e[0].id])}},[l,null==v?void 0:v.company_currencies,F]),s.useEffect(()=>{var e;const l=T[0],t=G?`+${(null==(e=xe(`+${G}`))?void 0:e.countryCallingCode)||""}`:"",o=W&&W.split(/\s*,\s*/).map(e=>e.trim()).filter(e=>Q.test(e))[0]||"",a={name:O||"",contact_no:G||"",email:o,country_code:t};if(l){if(Object.keys(a).some(e=>l[e]!==a[e])){const e=[...T];e[0]={...e[0],...a},S(e)}}else S([a,...T])},[O,G,W]),s.useEffect(()=>{var e;const l=_[0],t=(null==l?void 0:l.address_type)||(null==l?void 0:l.street_1)||(null==l?void 0:l.city);if(O&&G){const o=G?`+${(null==(e=xe(`+${G}`))?void 0:e.countryCallingCode)||""}`:"";if(!l)return void C([{...il,contact_name:O,phone:G,country_code:o}]);if(!t){const e=(null==l?void 0:l.contact_name)!==O,t=(null==l?void 0:l.phone)!==G;(e||t)&&C(e=>e.map((e,l)=>0===l?{...e,contact_name:O,phone:G,country_code:o}:e))}}},[O,G]);const le=s.useMemo(()=>e.jsx(Ce,{title:e.jsx(i.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:h("common.party.sections.basic_details")}),accordionProps:{defaultExpanded:!0,className:"form--Accordion"},children:e.jsxs(a.Grid,{container:!0,spacing:2,children:[e.jsx(a.Grid,{item:!0,xs:12,sm:12,children:e.jsx(Oe,{label:"",name:We,fieldArrayName:Ge,formControl:N,options:nl,display:"row",title:h(h("common.party.fields.type")),titlePosition:"start",position:2})}),"Individual"===L&&e.jsxs(e.Fragment,{children:[e.jsx(a.Grid,{item:!0,xs:12,sm:6,children:e.jsx(t.DynamicInput,{label:h("common.party.fields.firstName_label"),name:Ue,placeholder:h("common.party.fields.firstName_placeholder"),fieldArrayName:Ge,formControl:N,required:!0})}),e.jsx(a.Grid,{item:!0,xs:12,sm:6,children:e.jsx(t.DynamicInput,{label:h("common.party.fields.lastName_label"),name:Ke,placeholder:h("common.party.fields.lastName_placeholder"),fieldArrayName:Ge,formControl:N,required:!0})})]}),"Company"===L&&e.jsxs(e.Fragment,{children:[e.jsx(a.Grid,{item:!0,xs:12,sm:6,children:e.jsx(t.DynamicInput,{label:h("common.party.fields.company_name_label"),name:He,placeholder:h("common.party.fields.company_name_placeholder"),fieldArrayName:Ge,formControl:N,required:!0})}),e.jsx(a.Grid,{item:!0,xs:12,sm:6,children:e.jsx(t.DynamicInput,{label:h("common.party.fields.vat_number_label"),name:Ye,placeholder:h("common.party.fields.vat_number_placeholder"),fieldArrayName:Ge,formControl:N})}),e.jsx(a.Grid,{item:!0,xs:12,sm:6,children:e.jsx(t.DynamicInput,{label:h("common.party.fields.crn_label"),name:"crn",placeholder:h("common.party.fields.crn_placeholder"),fieldArrayName:Ge,formControl:N})})]}),e.jsx(a.Grid,{item:!0,xs:12,sm:6,children:e.jsx(Tl,{type:"text",label:h("common.party.fields.contact_label"),name:Xe,placeholder:h("common.party.fields.contact_placeholder"),fieldArrayName:Ge,formControl:N,required:!0})}),e.jsx(a.Grid,{item:!0,xs:12,sm:6,children:e.jsx(t.DynamicInput,{label:h("common.party.fields.email_label"),name:el,placeholder:h("common.party.fields.email_placeholder"),fieldArrayName:Ge,formControl:N,required:!0})}),e.jsx(a.Grid,{item:!0,xs:12,sm:6,children:e.jsx(bl,{label:h("common.party.fields.company_label"),apiType:"company",selectedLabel:"Companies",name:Qe,placeholder:h("common.party.fields.company_placeholder"),fieldArrayName:Ge,formControl:N,required:!0})}),e.jsx(a.Grid,{item:!0,xs:12,sm:6,children:e.jsx(bl,{label:h("common.party.fields.currency_label"),apiType:"currency",selectedLabel:"Currency",name:Ze,placeholder:h("common.party.fields.currency_placeholder"),fieldArrayName:Ge,formControl:N,required:!0,is_multiselect:!0})}),e.jsx(a.Grid,{item:!0,xs:12,sm:6,children:e.jsx(t.DynamicInput,{label:h("common.party.fields.responsible_person_label"),name:ll,placeholder:h("common.party.fields.responsible_person_placeholder"),fieldArrayName:Ge,formControl:N,required:!0})})]})}),[h,N,L]),te=s.useMemo(()=>e.jsx(Ce,{title:e.jsx(i.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:h("common.party.sections.accounting")}),accordionProps:{defaultExpanded:!0,className:"form--Accordion"},children:e.jsxs(a.Grid,{container:!0,spacing:2,children:[e.jsx(a.Grid,{item:!0,xs:12,sm:6,children:e.jsx(bl,{label:h("common.party.fields.receivable_account_label"),apiType:"accounts",selectedLabel:"Account",name:al,placeholder:h("common.party.fields.receivable_account_placeholder"),fieldArrayName:Ge,formControl:N,required:!0,customeFilter:{"&account_type.eq":"Receivable"},options:[]})}),e.jsx(a.Grid,{item:!0,xs:12,sm:6,children:e.jsx(bl,{label:h("common.party.fields.tax_template_label"),apiType:"taxTemplate",selectedLabel:"Tax Template",name:rl,placeholder:h("common.party.fields.tax_template_placeholder"),fieldArrayName:Ge,formControl:N,required:!0,options:[]})})]})}),[h,N]),oe=s.useMemo(()=>{var l,t,o;return e.jsx(Ce,{title:e.jsxs(i.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[h("common.party.sections.address"),e.jsx("span",{className:"errorIndicator",children:"*"}),(null==(l=null==M?void 0:M[Ge])?void 0:l[tl])&&e.jsx("span",{className:"error",children:null==(o=null==(t=null==M?void 0:M[Ge])?void 0:t[tl])?void 0:o.message})]}),accordionProps:{defaultExpanded:!0,className:"form--Accordion"},children:e.jsx(a.Grid,{spacing:4,children:e.jsx(a.Grid,{item:!0,xs:12,children:e.jsx(Nl,{rows:[..._],columns:U(dl),paginationModel:{pageNo:1,limit:10},totalPages:20,enableColumnDragging:!1,isResetRow:!1,columnOrder:["mrt-row-select"],enableRowSelection:!1,enableBottomToolbar:!0,disableDefaultActionColumn:!0,editDisplayMode:"row",enableRowCreate:!0,onCreateRow:e=>K(e,_,C,!0),onEditRow:e=>K(e,_,C,!0),onDeleteRow:e=>Y(_,C,e),onChangeRowField:J})})})})},[h,_,U,M]),re=s.useMemo(()=>{var l,t,o;return e.jsx(Ce,{title:e.jsxs(i.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[h("common.party.sections.contact"),e.jsx("span",{className:"errorIndicator",children:"*"}),(null==(l=null==M?void 0:M[Ge])?void 0:l[ol])&&e.jsx("span",{className:"error",children:null==(o=null==(t=null==M?void 0:M[Ge])?void 0:t[ol])?void 0:o.message})]}),accordionProps:{defaultExpanded:!0,className:"form--Accordion"},children:e.jsx(a.Grid,{spacing:4,children:e.jsx(a.Grid,{item:!0,xs:12,children:e.jsx(Nl,{rows:[...T],columns:U(cl),paginationModel:{pageNo:1,limit:10},totalPages:20,enableColumnDragging:!1,isResetRow:!1,columnOrder:["mrt-row-select"],enableRowSelection:!1,enableBottomToolbar:!0,disableDefaultActionColumn:!0,editDisplayMode:"row",enableRowCreate:!0,onCreateRow:e=>K(e,T,S,!1),onEditRow:e=>{K(e,T,S,!1),0===e.row.index&&(F(`${Ge}.${ll}`,e.values.name||""),F(`${Ge}.${Xe}`,e.values.contact_no||""),F(`${Ge}.${el}`,e.values.email||""))},onDeleteRow:e=>0===e.index?(q.enqueueSnackbar(h("common.party.errors.cannotDeleteResponsiblePerson"),{variant:"error"}),Promise.resolve()):Y(T,S,e),onChangeRowField:J})})})})},[h,T,U,M]);return e.jsxs(t.Modal,{open:l,onClose:X,maxWidth:"lg",fullWidth:!0,sx:{overflowY:"hidden"},...r,children:[P&&e.jsx(Dl,{}),e.jsxs("form",{onSubmit:B(Z),className:"scroll-container",style:{position:"relative",overflow:"auto"},children:[e.jsxs(a.DialogTitle,{className:"itemEntryModal--DialogTitle",children:[e.jsx(i.Typography,{type:"s3",color:"inherit",weight:"medium",children:`Add ${n}`}),e.jsx(a.IconButton,{onClick:X,children:e.jsx(w.Close,{fontSize:"small"})})]}),e.jsxs(a.DialogContent,{children:[le,e.jsx(a.Divider,{className:"form--SectionDivider"}),oe,e.jsx(a.Divider,{className:"form--SectionDivider"}),re,e.jsx(a.Divider,{className:"form--SectionDivider"}),te]}),e.jsx(a.DialogActions,{className:"itemEntryModal--DialogAction",sx:{position:"sticky",bottom:0,backgroundColor:"white",zIndex:1,padding:"8px 24px",justifyContent:"end"},children:e.jsxs(a.Box,{display:"flex",gap:1.5,children:[e.jsx(t.Button,{className:"itemEntryModal--DialogAction--WhiteBtn",onClick:X,children:h("common.cancel")}),e.jsx(t.Button,{variant:"contained",onClick:B(Z),children:h("common.save")})]})})]})]})}const Fl=({options:l,multiple:t,placeholder:o,with_checkboxes:r,values:n,field:s})=>{const d=[];return t||d.push(e.jsx(a.MenuItem,{disabled:!0,value:"",sx:{opacity:"0 !important",height:"0 !important",p:"0 !important",m:"0 !important"},children:e.jsx(i.Typography,{type:"s3",color:"theme.secondary.1000",children:e.jsx("em",{children:o})})})),null==l||l.forEach((l,o)=>{d.push(e.jsx(a.MenuItem,{value:l.value,disabled:Boolean(l.disabled),className:(null==l?void 0:l.isGroup)?"select--MenuItemHeader":"",children:e.jsxs(a.Box,{sx:{display:"flex",gap:1},children:[t&&r&&e.jsx(ze,{checked:Boolean(n&&(null==n?void 0:n.indexOf(l.value))>-1)}),e.jsx(i.Typography,{type:"s3",color:"theme.secondary.1000",children:l.label})]})},o)),(null==l?void 0:l.isGroup)&&Array.isArray(null==l?void 0:l.options)&&l.options.forEach(o=>{d.push(e.jsx(a.MenuItem,{value:o.value,disabled:Boolean(o.disabled),sx:{pl:5},children:e.jsxs(a.Box,{sx:{display:"flex",gap:1},children:[t&&r&&e.jsx(ze,{checked:Boolean(n&&(null==n?void 0:n.indexOf(o.value))>-1)}),e.jsx(i.Typography,{type:"s3",color:"theme.secondary.1000",children:o.label})]})},`${l.value}-${o.value}`))})}),s.enable_footer&&d.push(e.jsxs(a.Box,{children:[e.jsx(a.Divider,{flexItem:!0}),e.jsxs(a.MenuItem,{sx:{gap:1},onClick:s.onFooterClick,children:[e.jsx(w.Add,{fontSize:"small"}),e.jsxs(i.Typography,{type:"s4",color:"theme.secondary.1000",children:["Create New ",s.label]})]})]})),d},El=({data:l,options:t})=>{const o=l.map(e=>{var l;return(null==(l=null==t?void 0:t.find(l=>l.value===e))?void 0:l.label)||e}).filter(Boolean);return e.jsxs(i.Typography,{type:"s4",color:"inherit",sx:{display:"flex",gap:1,alignItems:"center",mt:.5},children:[o.slice(.4).join(", "),l.length>4&&e.jsx(g.Chip,{variant:"outlined",type:"normal",label:e.jsx(I.MoreIcon,{})})]})},Rl=s.memo(l=>{const[o,r]=s.useState([]),[n,i]=s.useState(null),{handleOptions:d}=l;s.useEffect(()=>{d&&d(n)},[d,n]);const u=e=>{var t;if((null==(t=l.options)?void 0:t.length)&&e){const t=l.options.filter(l=>{var t,o;return s.isValidElement(l.label)?null==(o=null==(t=null==l?void 0:l.searchLabel)?void 0:t.toLowerCase())?void 0:o.includes(e.toLowerCase()):l.label.toLowerCase().includes(e.toLowerCase())});r(t)}else r(l.options)},m=e=>null==e?void 0:e.filter(e=>e),p=s.useCallback(()=>{r(l.options)},[l.options]);s.useEffect(()=>{p()},[p]);const{t:h}=y.useTranslation();return e.jsx(c.Controller,{control:l.formControl,name:`${l.fieldArrayName}.${l.name}`,render:({field:r,fieldState:n})=>{var s,d,c,p,y;return e.jsxs(e.Fragment,{children:["Select Currency"===l.placeholder?i(r.value):i(null),e.jsx(t.Select,{...r,fullWidth:!0,dataPosition:l.position,dataName:`${l.fieldArrayName}.${l.name}`,placeholder:l.placeholder,label:l.label,value:(null==(s=r.value)?void 0:s.id)||(null==(d=r.value)?void 0:d.label)||r.value||(l.is_multiselect?[]:""),defaultValue:l.defaultValue||(l.is_multiselect?[]:""),required:"builder"!==l.formType&&l.required,size:l.size||"small",multiple:l.is_multiselect||!1,disabled:l.disabled,variant:"outlined",className:l.is_multiselect&&(null==(c=m(r.value))?void 0:c.length)?"MultiSelect":"",renderValue:t=>{var a;return e.jsx(e.Fragment,{children:Array.isArray(t)?e.jsx($e,{selectedLabel:l.selectedLabel,data:m(t),placeholder:l.placeholder,onDelete:null==l?void 0:l.onChipRemove,disabled:l.disabled}):(null==(a=null==o?void 0:o.find(e=>{var l;return((null==(l=e.value)?void 0:l.id)||e.value)===t}))?void 0:a.label)||t||l.placeholder})},searchPlaceholder:`${h("common.search")} ${l.label}`,handleSearch:u,error:Boolean(null==(p=n.error)?void 0:p.message),helperText:(null==(y=n.error)?void 0:y.message)||"",onBlur:r.onBlur,input:(null==l?void 0:l.is_multiselect)||l.disabled||!(null==r?void 0:r.value)?void 0:e.jsx(a.OutlinedInput,{label:"",endAdornment:e.jsx(a.InputAdornment,{position:"end",children:r.value&&e.jsx(a.IconButton,{"aria-label":"clear selection",onClick:()=>r.onChange(null),edge:"end",sx:{mr:1.5},size:"small",children:e.jsx(w.Close,{sx:{fontSize:"1rem"}})})})}),loading:null==l?void 0:l.is_loading,children:Fl({options:o,multiple:Boolean(l.is_multiselect),placeholder:l.placeholder,values:r.value,with_checkboxes:!0,field:l})}),l.is_multiselect&&Array.isArray(null==r?void 0:r.value)&&e.jsx(El,{data:r.value,options:o})]})}})});Rl.propTypes={name:l.PropTypes.string.isRequired,placeholder:l.PropTypes.string.isRequired,label:l.PropTypes.string.isRequired,size:l.PropTypes.string,options:l.PropTypes.arrayOf(l.PropTypes.shape({label:l.PropTypes.string,value:l.PropTypes.string})).isRequired,formControl:l.PropTypes.shape({register:l.PropTypes.func.isRequired,setValue:l.PropTypes.func}).isRequired,defaultValue:l.PropTypes.string,fieldArrayName:l.PropTypes.string,id:l.PropTypes.string,required:l.PropTypes.bool,is_multiselect:l.PropTypes.bool,position:l.PropTypes.number,formType:l.PropTypes.string,typeOfField:l.PropTypes.string,disabled:l.PropTypes.bool,onChipRemove:l.PropTypes.func,enable_footer:l.PropTypes.bool,footer_action:l.PropTypes.string,onFooterClick:l.PropTypes.any,is_loading:l.PropTypes.bool,selectedLabel:l.PropTypes.string};const zl=l=>{const{type:o,onClick:a,className:r,disable:n,...i}=l;return e.jsx(t.Button,{type:o,onClick:a,className:r,...i,disabled:n,children:l.text})};zl.propTypes={text:l.PropTypes.string.isRequired,onClick:l.PropTypes.func,type:l.PropTypes.string,style:l.PropTypes.object,variant:l.PropTypes.string,className:l.PropTypes.string,disable:l.PropTypes.bool,startIcon:l.PropTypes.node};const $l=({formControl:l,fieldArrayName:t,name:o,label:r,position:n,disabled:s,titlePosition:d="end",title:u,titleColor:m="theme.secondary.800",checkboxProps:p,stackProps:h})=>{const{isRtl:y}=M.useLanguage();return e.jsx(c.Controller,{control:l,name:`${t}.${o}`,render:({field:l})=>e.jsxs(e.Fragment,{children:[r&&e.jsx(i.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800","data-position":n,sx:{mb:.5},children:r}),e.jsxs(a.Stack,{direction:"row",spacing:y?"":.25,alignItems:"center",...h,children:["start"===d&&e.jsxs(i.Typography,{type:"s4",weight:"medium",color:m,children:[" ",u]}),e.jsx(ze,{checked:Boolean(l.value),onChange:l.onChange,disabled:s,size:"small",sx:{m:1},...p}),"end"===d&&e.jsxs(i.Typography,{type:"s4",weight:"medium",color:m,children:[" ",u]})]})]})})},Vl=s.memo(l=>{const t=s.useMemo(()=>`${l.fieldArrayName}.${l.name}`,[l.fieldArrayName,l.name]),{minDate:o,maxDate:a}=s.useMemo(()=>({minDate:v(l.min_date||null).isValid()?v(l.min_date):null,maxDate:v(l.max_date||null).isValid()?v(l.max_date):null}),[l.min_date,l.max_date]),r=s.useMemo(()=>"builder"!==l.formType&&l.required,[l.formType,l.required]);return e.jsx(c.Controller,{control:l.formControl,name:t,render:({field:n,fieldState:i})=>{var s;return e.jsx(Ee,{...n,dataPosition:l.position,dataName:t,label:l.label,placeholder:l.placeholder,required:r,defaultValue:l.defaultValue,disableFutureDates:l.is_future_dates_allowed,disablePastDates:l.is_past_dates_allowed,helperText:null==(s=i.error)?void 0:s.message,error:Boolean(i.error),disabled:l.disabled,minDate:o,maxDate:a,...(null==l?void 0:l.views)&&{views:null==l?void 0:l.views}})}})});Vl.displayName="DynamicDate",Vl.propTypes={formControl:l.PropTypes.shape({register:l.PropTypes.func.isRequired,setValue:l.PropTypes.func}).isRequired,name:l.PropTypes.string.isRequired,label:l.PropTypes.string.isRequired,fieldArrayName:l.PropTypes.string,required:l.PropTypes.bool,position:l.PropTypes.number,formType:l.PropTypes.string,placeholder:l.PropTypes.string,defaultValue:l.PropTypes.any,is_future_dates_allowed:l.PropTypes.bool,is_past_dates_allowed:l.PropTypes.bool,typeOfField:l.PropTypes.string,disabled:l.PropTypes.bool,min_date:l.PropTypes.any,max_date:l.PropTypes.any};const Ll=l=>e.jsx(c.Controller,{control:l.formControl,name:`${l.fieldArrayName}.${l.name}`,render:({field:o,fieldState:r})=>{var n,i;return e.jsx(t.TextField,{...o,name:`${l.fieldArrayName}.${l.name}`,fullWidth:!0,label:l.label,defaultValue:l.default_value.replace(/[^0-9]/g,""),placeholder:l.placeholder,multiline:l.is_multiline||!1,disabled:l.disabled,required:l.is_required,inputProps:{step:(null==l?void 0:l.float_step)||"0",min:l.min_length||0,max:l.max_length||1e3,inputMode:"numeric",pattern:`${l.is_negative}`?"-?[0-9]*":"[0-9]*"},InputProps:{startAdornment:e.jsx(a.InputAdornment,{position:"start",sx:{display:"flex",alignItems:"center",justifyContent:"center",borderRight:"1px solid rgba(0, 0, 0, 0.23)",width:50,height:"100%",borderBottomLeftRadius:4,borderTopLeftRadius:4},children:null!==l.currencyType?l.currencyType:"-"})},error:Boolean(null==(n=r.error)?void 0:n.message),helperText:(null==(i=r.error)?void 0:i.message)||"",onBlur:o.onBlur,onChange:e=>{const l=e.target.value.replace(/[^0-9]/g,"");o.onChange(l)}})}});Ll.propTypes={formControl:l.PropTypes.shape({register:l.PropTypes.func.isRequired,setValue:l.PropTypes.func,_formState:l.PropTypes.object.isRequired}).isRequired,defaultValue:l.PropTypes.string,name:l.PropTypes.string.isRequired,label:l.PropTypes.node.isRequired,fieldArrayName:l.PropTypes.string,required:l.PropTypes.bool,is_multiline:l.PropTypes.bool,min:l.PropTypes.number,max:l.PropTypes.number,min_length:l.PropTypes.number,max_length:l.PropTypes.number,float_step:l.PropTypes.string,position:l.PropTypes.number,formType:l.PropTypes.string,disabled:l.PropTypes.bool,InputProps:l.PropTypes.object,placeholder:l.PropTypes.string,currencyType:l.PropTypes.string};const Ol=l=>{var t,i,s,d;const[,c]=r.useDrag({type:"element",item:{index:l.index}}),[,u]=r.useDrop({accept:"element",hover:e=>{const t=e.index,o=l.index;o!==t&&l.swap(t,o)},drop:()=>{l.elementSwap()}}),m=l.activeIndex?"form-element-wrapper--Active":"form-element-wrapper--Element",p="custom"===(null==(i=null==(t=null==l?void 0:l.children)?void 0:t.props)?void 0:i.typeOfField)?"":"form-element-wrapper--Default";return e.jsxs(a.Grid,{item:!0,xs:(null==l||l.element,12),className:`${m} ${p}`,ref:e=>u(c(e)),children:[e.jsx(a.Box,{sx:{width:"100%"},onClick:l.onClick,children:l.children}),e.jsxs("div",{className:"form-element-wrapper--Actions",children:[e.jsx("img",{src:n.images.duplicate,onClick:()=>l.handleDuplicate(l.index)}),"custom"===(null==(d=null==(s=null==l?void 0:l.children)?void 0:s.props)?void 0:d.typeOfField)&&e.jsx(o,{style:{fontSize:"1rem",color:"#656669"},onClick:()=>{l.removeElement(l.index),l.setElementHoc()}})]})]})};Ol.propTypes={removeElement:l.PropTypes.func.isRequired,index:l.PropTypes.number.isRequired,onClick:l.PropTypes.func,children:l.PropTypes.node.isRequired,swap:l.PropTypes.func,elementSwap:l.PropTypes.func,activeIndex:l.PropTypes.bool,handleDuplicate:l.PropTypes.func,setElementHoc:l.PropTypes.func,element:l.PropTypes.string,elementPerRow:l.PropTypes.number};const Gl=l=>{const[o,r]=s.useState(l.options[0].value),n=e=>{r(e.target.value)};return e.jsx(c.Controller,{control:l.formControl,name:`${l.fieldArrayName}.${l.name}`,render:({field:r,fieldState:i})=>{var s,d,c;return e.jsx(t.TextField,{...r,name:`${l.fieldArrayName}.${l.name}`,fullWidth:!0,label:l.label,placeholder:l.placeholder,multiline:l.is_multiline||!1,disabled:l.disabled,required:l.is_required,inputProps:{step:(null==l?void 0:l.float_step)||"0",min:l.min_length||0,max:l.max_length||1e3,inputMode:"string"},InputProps:{endAdornment:e.jsx(a.InputAdornment,{position:"start",sx:{display:"flex",alignItems:"center",justifyContent:"center",borderLeft:"1px solid rgba(0, 0, 0, 0.23)",padding:1,height:"100%",borderBottomLeftRadius:4,borderTopLeftRadius:4,backgroundColor:"rgba(245 , 245 , 245 )",margin:0,boxSizing:"border-box",borderRadius:0},children:e.jsx(a.Select,{value:o,onChange:n,sx:{height:"100%","&:focus":{backgroundColor:"rgba(245 , 245 , 245 )"},"&:hover":{backgroundColor:"rgba(245 , 245 , 245 )"},"&:active":{backgroundColor:"rgba(245 , 245 , 245)"},"&.Mui-focused":{backgroundColor:"#fff"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#fff"}},variant:"standard",disableUnderline:!0,IconComponent:S,children:null==(s=l.options)?void 0:s.map((l,t)=>e.jsx(a.MenuItem,{value:l.value,sx:{"&:hover":{backgroundColor:"rgba(245 , 245 , 245 )"},"&.Mui-selected":{backgroundColor:"rgba(245 , 245 , 245)"},"&.Mui-selected:hover":{backgroundColor:"rgba(245 , 245 , 245)"}},children:l.label},t))})})},error:Boolean(null==(d=i.error)?void 0:d.message),helperText:(null==(c=i.error)?void 0:c.message)||"",onBlur:r.onBlur,onChange:e=>{r.onChange(e.target.value)}})}})};Gl.propTypes={formControl:l.PropTypes.shape({register:l.PropTypes.func.isRequired,setValue:l.PropTypes.func,_formState:l.PropTypes.object.isRequired}).isRequired,defaultValue:l.PropTypes.string,name:l.PropTypes.string.isRequired,label:l.PropTypes.node.isRequired,fieldArrayName:l.PropTypes.string,required:l.PropTypes.bool,is_multiline:l.PropTypes.bool,min:l.PropTypes.number,max:l.PropTypes.number,min_length:l.PropTypes.number,max_length:l.PropTypes.number,float_step:l.PropTypes.string,position:l.PropTypes.number,formType:l.PropTypes.string,disabled:l.PropTypes.bool,InputProps:l.PropTypes.object,placeholder:l.PropTypes.string};const Wl=({formControl:l,name:o,fieldArrayName:r="",label:n})=>{const[d,u]=s.useState("");return e.jsx(c.Controller,{control:l,name:`${r}.${o}`,render:({field:{value:l="",onChange:o}})=>{const r=l?l.split(",").map(e=>e.trim()):[],s=e=>{if("Tab"===e.key){const l=d.trim();if(l&&!r.includes(l)){e.preventDefault();const t=[...r,l].join(", ");o(t),u("")}}};return e.jsx(a.Autocomplete,{clearIcon:!1,options:[],freeSolo:!0,multiple:!0,fullWidth:!0,value:r,onChange:(e,l)=>{const t=(null==l?void 0:l.join(", "))||"";o(t)},renderTags:(l,t)=>l.map((l,o)=>e.jsx(g.Chip,{type:"normal",label:e.jsx(i.Typography,{color:"theme.secondary.1000",type:"s4",children:l}),...t({index:o})},o)),renderInput:l=>e.jsx(t.TextField,{label:n,type:"text",...l,value:d,onChange:e=>u(e.target.value),onKeyDown:s})})}})};Wl.propTypes={formControl:l.PropTypes.shape({register:l.PropTypes.func.isRequired,setValue:l.PropTypes.func,_formState:l.PropTypes.object.isRequired}).isRequired,name:l.PropTypes.string.isRequired,label:l.PropTypes.node.isRequired,fieldArrayName:l.PropTypes.string};const Ul=l=>{const{label:t,dataPosition:o,dataName:a,value:r}=l;return e.jsxs(e.Fragment,{children:[e.jsxs(i.Typography,{type:"s5",weight:"medium",mb:.5,color:"theme.secondary.800","data-position":o,"data-name":a,className:"infoCard",children:[t,e.jsx("img",{src:n.images.info})]}),e.jsx(i.Typography,{color:"theme.secondary.1000",children:r??"Info"})]})},Kl=l=>e.jsx(c.Controller,{control:l.formControl,name:`${l.fieldArrayName}.${l.name}`,render:({field:t})=>e.jsx(Ul,{...t,dataPosition:l.position,dataName:`${l.fieldArrayName}.${l.name}`,label:l.label,value:l.defaultValue||"Info"})});Kl.propTypes={formControl:l.PropTypes.shape({register:l.PropTypes.func.isRequired,setValue:l.PropTypes.func}).isRequired,name:l.PropTypes.string.isRequired,label:l.PropTypes.string.isRequired,fieldArrayName:l.PropTypes.string,position:l.PropTypes.number,formType:l.PropTypes.string,defaultValue:l.PropTypes.string,typeOfField:l.PropTypes.string,disabled:l.PropTypes.bool};const Hl=s.memo(l=>e.jsx(c.Controller,{control:l.formControl,name:`${l.fieldArrayName}.${l.name}`,render:({field:t,fieldState:{error:o}})=>e.jsxs(e.Fragment,{children:[e.jsx(Al,{dataPosition:l.position,dataName:`${l.fieldArrayName}.${l.name}`,label:l.label,required:"builder"!==l.formType&&l.required,type:l.field_type,max_size:null==l?void 0:l.max_size,disabled:null==l?void 0:l.disabled,onChange:null==t?void 0:t.onChange,name:l.name,value:(null==t?void 0:t.value)||(null==l?void 0:l.value),multiple:Boolean(null==l?void 0:l.is_multiple)}),o&&e.jsx(i.Typography,{color:"theme.error.600",type:"s5",children:o.message})]})}));Hl.propTypes={formControl:l.PropTypes.shape({register:l.PropTypes.func.isRequired,setValue:l.PropTypes.func}).isRequired,name:l.PropTypes.string.isRequired,label:l.PropTypes.string.isRequired,fieldArrayName:l.PropTypes.string,required:l.PropTypes.bool,is_multiple:l.PropTypes.bool,position:l.PropTypes.number,formType:l.PropTypes.string,placeholder:l.PropTypes.string,default_value:l.PropTypes.string,type:l.PropTypes.string,field_type:l.PropTypes.string,max_size:l.PropTypes.number,typeOfField:l.PropTypes.string,disabled:l.PropTypes.bool};const Yl=l=>{var o;const[r,c]=s.useState(null);return e.jsxs(a.Grid,{className:l.className?`formBuilder ${l.className}`:"formBuilder",children:[e.jsxs("div",{className:"formBuilder--Header",children:[e.jsx(i.Typography,{type:"s4",fontWeight:"medium",mb:.5,color:"theme.secondary.800",sx:{cursor:"pointer",...(null==(o=l.label)?void 0:o.trim())?{}:{fontStyle:"italic"}},onClick:l.onClick,"data-position":l.position,"data-name":`${l.fieldArrayName}.${l.name}`,children:l.label||"(Unnamed Section)"}),e.jsxs("div",{children:[e.jsx(a.IconButton,{color:"inherit",size:"small",onClick:e=>{c(e.currentTarget)},children:e.jsx("img",{src:n.images.more,alt:"more icon"})}),e.jsxs(a.Menu,{open:Boolean(r),anchorEl:r,onClose:()=>c(null),children:[e.jsx(a.MenuItem,{onClick:()=>{l.handleAccordion(),c(null)},children:"Make this section accordion"}),!l.remove_section&&e.jsx(a.MenuItem,{sx:{color:"#F86060"},onClick:()=>{l.removeSection(),c(null)},children:"Remove Section"})]})]})]}),e.jsxs("div",{className:l.activeIndex?"formBuilder--Active":"formBuilder--Section",children:[e.jsx(a.Grid,{container:!0,sx:{mb:2},children:l.children}),l.isFormSwitcher?null:e.jsx(t.Button,{variant:"outlined",style:{color:"#292D32",marginBottom:"0.375rem"},startIcon:e.jsx(d,{}),"data-position":l.position,"data-name":`${l.fieldArrayName}.${l.name}`,onClick:l.handleAddButton,children:"Add"})]})]})};Yl.propTypes={index:l.PropTypes.number.isRequired,onClick:l.PropTypes.func,children:l.PropTypes.node.isRequired,label:l.PropTypes.string,position:l.PropTypes.number,fieldArrayName:l.PropTypes.string,className:l.PropTypes.string,removeSection:l.PropTypes.func.isRequired,handleAccordion:l.PropTypes.func,activeIndex:l.PropTypes.bool,handleAddButton:l.PropTypes.func,remove_section:l.PropTypes.bool,isFormSwitcher:l.PropTypes.bool};const{parse:Jl,stringify:Ql}=JSON,{keys:Zl}=Object,Xl=String,et="string",lt={},tt="object",ot=(e,l)=>l,at=e=>e instanceof Xl?Xl(e):e,rt=(e,l)=>typeof l===et?new Xl(l):l,nt=(e,l,t)=>{const o=Xl(l.push(t)-1);return e.set(t,o),o},it=(e,l)=>{const t=Jl(e,rt).map(at),o=l||ot;let a=t[0];if(typeof a===tt&&a){const e=[],l=((e,l,t,o)=>a=>{for(let r=Zl(a),{length:n}=r,i=0;i<n;i++){const n=r[i],s=a[n];if(s instanceof Xl){const r=e[+s];typeof r!==tt||t.has(r)?a[n]=o.call(a,n,r):(t.add(r),a[n]=lt,l.push({o:a,k:n,r:r}))}else a[n]!==lt&&(a[n]=o.call(a,n,s))}return a})(t,e,new Set,o);a=l(a);let r=0;for(;r<e.length;){const{o:t,k:a,r:n}=e[r++];t[a]=o.call(t,a,l(n))}}return o.call({"":a},"",a)},st=(e,l,t)=>{const o=ot,a=new Map,r=[],n=[];let i=+nt(a,r,o.call({"":e},"",e)),s=!i;for(;i<r.length;)s=!0,n[i]=Ql(r[i++],d,t);return"["+n.join(",")+"]";function d(e,l){if(s)return s=!s,l;const t=o.call(this,e,l);switch(typeof t){case tt:if(null===t)return t;case et:return a.get(t)||nt(a,r,t)}return t}},dt=s.memo(({columns:l,position:o,label:r,rows:n=[],onAddClick:d,name:c,is_button:u=!0,disableTableAddButton:m,otherButtons:p,defaultActionColumnItems:h,onTableCellChange:x,currencySymbol:v="",...j})=>{var _,C,T;const{t:S}=y.useTranslation(),{user:A}=i.useAuth(),P=v||(null==(_=null==A?void 0:A.currency_data)?void 0:_.symbol)||"",k=(null==(C=null==A?void 0:A.currency_data)?void 0:C.number_format)||"",N=(null==(T=null==A?void 0:A.currency_data)?void 0:T.position)||"before",M=s.useCallback((e,l)=>{switch(e){case"Percentage":return`${l}%`;case"Fixed Amount":return`${P}${l}`;default:return l}},[P]),I=x instanceof Function,D=s.useCallback(l=>l.map(l=>({...l,header:S(l.header),Cell:({renderedCellValue:t,row:o})=>{var r,i,s,d;let u=t;if("number"==typeof u&&u&&(null==(r=String(u))?void 0:r.includes(".")))return f.toFixedWithNumbers(u);switch(l.type){case"formattedString":u=f.formatLabel(t)||"-";break;case"date":u=f.formatDate(t,(null==(i=l.editProperties)?void 0:i.dateFormat)||"DD-MM-YYYY")||"-";break;case"currency":u=t?`${f.formatAmount(t,k,N,P)}`:"-";break;case"stringOrArray":{const l=null==(d=null==(s=o.original)?void 0:s.promotion_map_data)?void 0:d.type;u=Array.isArray(t)?t.map(t=>t?e.jsx(g.Chip,{label:M(l,t)}):null):M(l,t);break}case"checkbox":u=e.jsx(ze,{checked:Boolean(t),onClick:I?e=>x({value:e.target.checked,data:o.original,col:l,row:o,name:c,uRows:n}):void 0});break;case"array":u=Array.isArray(t)&&t.length?e.jsx(a.Box,{sx:{display:"flex",gap:.5,alignItems:"center",flexWrap:"wrap"},children:t.map(t=>e.jsx(g.Chip,{type:"normal",label:b.get(t,null==l?void 0:l.valueGet,""),active:!0}))}):"-";break;case"file":u=f.getFileName(t)||"-"}return u}})),[P,M,v,n]);return e.jsxs(a.Box,{"data-position":o,children:[e.jsx(i.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800","data-position":o,sx:{mb:.5},children:S(r)}),e.jsxs(a.Box,{children:[e.jsx(Nl,{columnOrder:["mrt-row-select"],rows:n,columns:D(it(st(l))),totalPages:20,paginationModel:{pageNo:1,limit:10},enableEditing:!1,enableColumnDragging:!1,enableBottomToolbar:!1,defaultActionColumnItems:h,...j}),u&&!m&&e.jsxs(a.Box,{sx:{display:"flex",width:"100%",justifyContent:"space-between",mt:1},children:[e.jsx(t.Button,{variant:"outlined",onClick:()=>null==d?void 0:d(c),startIcon:e.jsx(w.Add,{}),className:"table--AddButton",children:"Add"}),Boolean(null==p?void 0:p.length)&&p]})]})]})}),ct=j.styled(T.TimePicker)(({theme:{palette:e}})=>{var l,t,o,a,r,n,i,s,d,c;return{"& .MuiOutlinedInput-root":{padding:"0",color:null==(l=e.theme)?void 0:l.secondary[800],"& fieldset":{borderColor:null==(t=e.theme)?void 0:t.secondary[400]},"&:hover fieldset":{borderColor:null==(o=e.theme)?void 0:o.secondary[500]},"&.Mui-focused fieldset":{borderWidth:"0.0625rem",borderStyle:"solid",borderColor:null==(a=e.theme)?void 0:a.primary[700]},"&.Mui-error fieldset":{borderColor:null==(r=e.theme)?void 0:r.error[600]},"&.Mui-disabled":{background:null==(n=e.theme)?void 0:n.secondary[200],color:null==(i=e.theme)?void 0:i.secondary[800]},"& .MuiInputBase-input::placeholder":{color:null==(s=e.theme)?void 0:s.secondary[800],opacity:1}},"& .MuiFormHelperText-root":{marginLeft:0,color:null==(d=e.theme)?void 0:d.secondary[800],"&.Mui-error":{color:null==(c=e.theme)?void 0:c.error[600]}},"& .MuiIconButton-root":{marginRight:0},"& .MuiPickersCalendarHeader-labelContainer":{fontWeight:600}}}),ut=s.memo(l=>{const{label:t,disabled:o,error:a,helperText:r,dataName:n,dataPosition:s,is24hrFormat:d=!1,placeholder:c,required:u=!1,...m}=l;return e.jsx("div",{children:e.jsxs(C.LocalizationProvider,{dateAdapter:_.AdapterDayjs,children:[t&&e.jsxs(i.Typography,{type:"s4",fontWeight:"medium",mb:.5,color:a?"theme.error.600":"theme.secondary.800","data-position":s,"data-name":n,children:[t," ",u&&e.jsx("span",{className:"requiredStar",children:"*"})]}),e.jsx(ct,{...m,disabled:o,slotProps:{textField:{helperText:r,error:a,placeholder:c||"HH:mm A"}},format:d?"HH:MM":"hh:mm a",className:"timePicker"})]})})}),mt=s.memo(l=>e.jsx(c.Controller,{control:l.formControl,name:`${l.fieldArrayName}.${l.name}`,render:({field:t,fieldState:o})=>{var a;return e.jsx(ut,{...t,onChange:e=>{t.onChange(e),null==l||l.onChange(e)},dataPosition:l.position,dataName:`${l.fieldArrayName}.${l.name}`,label:l.label,placeholder:l.placeholder,required:"builder"!==l.formType&&l.required,is24hrFormat:"24hr"===l.options,disabled:l.disabled,helperText:null==(a=o.error)?void 0:a.message,error:Boolean(o.error),...(null==l?void 0:l.rest)||{}})}}));mt.propTypes={formControl:l.PropTypes.shape({register:l.PropTypes.func.isRequired,setValue:l.PropTypes.func}).isRequired,name:l.PropTypes.string.isRequired,label:l.PropTypes.string.isRequired,fieldArrayName:l.PropTypes.string,required:l.PropTypes.bool,position:l.PropTypes.number,formType:l.PropTypes.string,option:l.PropTypes.string,placeholder:l.PropTypes.string,typeOfField:l.PropTypes.string,disabled:l.PropTypes.bool,onChange:l.PropTypes.func,rest:l.PropTypes.object};const pt=j.styled(l=>e.jsx(ie,{focusVisibleClassName:".Mui-focusVisible",disableRipple:!0,...l}))(({theme:e,size:l,checked:t})=>{var o,a,r;return{width:24,height:16,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"medium"===l?2:1,transitionDuration:"300ms","&.Mui-checked":{transform:"medium"===l?"translateX(16px)":"translateX(8px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"dark"===e.palette.mode?"#2ECA45":"#65C466",opacity:1,border:0},"&.Mui-disabled + .MuiSwitch-track":{opacity:.5}},"&.Mui-focusVisible .MuiSwitch-thumb":{color:"#33cf4d",border:"6px solid #fff"},"&.Mui-disabled .MuiSwitch-thumb":{color:"light"===e.palette.mode?e.palette.grey[100]:e.palette.grey[600]},"&.Mui-disabled + .MuiSwitch-track":{opacity:"light"===e.palette.mode?.7:.3}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:14,height:14,border:t?0:`1px solid ${null==(o=e.palette.theme)?void 0:o.secondary[300]}`},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:null==(a=e.palette.theme)?void 0:a.secondary[200],opacity:1,transition:e.transitions.create(["background-color"],{duration:500})},..."medium"===l&&{width:42,height:26,"& .MuiSwitch-thumb":{boxSizing:"border-box",width:22,height:22,border:t?0:`1px solid ${null==(r=e.palette.theme)?void 0:r.secondary[300]}`}}}}),ht=s.memo(({label:l,labelPosition:t="end",typographyProps:o,...a})=>{const{isRtl:r}=M.useLanguage();return e.jsxs(se,{direction:"row",spacing:r?"":.5,alignItems:"center",children:["start"===t&&e.jsx(i.Typography,{type:"s3",color:"theme.secondary.1000",...o,children:l}),e.jsx(pt,{sx:{m:1},...a}),"end"===t&&e.jsx(i.Typography,{type:"s3",color:"theme.secondary.1000",...o,children:l})]})}),yt=s.memo(({formControl:l,fieldArrayName:t,name:o,label:a,position:r,disabled:n,titlePosition:s,title:d,toggleSwitchProps:u})=>e.jsx(c.Controller,{control:l,name:`${t}.${o}`,render:({field:l})=>e.jsxs(e.Fragment,{children:[e.jsx(i.Typography,{type:"s5",color:"theme.secondary.800",weight:"medium","data-position":r,sx:{mb:.5},children:a}),e.jsx(ht,{...u,name:o,checked:l.value,onChange:l.onChange,label:d,disabled:Boolean(n),labelPosition:s})]})})),gt=l=>{const{t:r}=y.useTranslation(),{tabs:n,onEditTabTitle:d,activeValue:c,setActiveValue:g,handleTabChange:x,handleRemoveTab:v,containerProps:f}=l,[b,j]=s.useState(c||0),[_,C]=s.useState(null);return s.useEffect(()=>{c&&j(c)},[c]),e.jsx(a.Box,{mb:2,...f,children:e.jsxs(m,{value:c??b,children:[e.jsx(a.Box,{children:e.jsx(p,{className:"account-payble-tabs-wrap",onChange:(e,l)=>{j(l),g&&g(l),x&&x()},variant:"scrollable",scrollButtons:"auto","aria-label":"scrollable tabs",sx:{overflowX:"auto",maxWidth:"100%"},children:n.map((l,n)=>e.jsx(u,{className:"account-payble-tab-items",label:e.jsx(a.Box,{display:"flex",alignItems:"center",children:d&&_===l.tab_order?e.jsx(t.TextField,{value:l.title,autoFocus:!0,onBlur:()=>C(null),onChange:e=>{return t=e,o=l.tab_order,void(d&&d(o,t.target.value));var t,o}}):v?e.jsxs("div",{className:"Tabs--Title",children:[e.jsx(i.Typography,{color:"theme.secondary.1000",type:"s3",children:r(l.title)}),!l.remove_tab&&e.jsx(a.IconButton,{size:"small",onClick:e=>{e.preventDefault(),e.stopPropagation(),v(l.tab_order)},children:e.jsx(o,{style:{fontSize:"15px",cursor:"pointer"}})})]}):e.jsx(i.Typography,{color:"theme.secondary.1000",type:"s3",children:r(l.title)})}),wrapped:!0,onDoubleClick:()=>{return e=l.tab_order,void C(e);var e}},l.tab_order))})}),n.map((l,t)=>l.content&&e.jsx(h,{value:t.toString(),children:b===t&&l.content},l.tab_order))]})})},xt=a.styled(a.Alert)(({theme:{palette:e}})=>{var l,t,o,a,r,n,i;return{"&.MuiAlert-root":{fontSize:"0.75rem",fontWeight:"500",letterSpacing:"-0.24px",padding:"0rem 0.75rem"},"&.MuiAlert-standardInfo":{color:null==(l=e.theme)?void 0:l.secondary[900],backgroundColor:null==(t=e.theme)?void 0:t.secondary[200]},"&.MuiAlert-standardSuccess":{color:null==(o=e.theme)?void 0:o.primary[900],backgroundColor:null==(a=e.theme)?void 0:a.primary[100]},"&.MuiAlert-standardError":{color:null==(r=e.theme)?void 0:r.tertiary6[900],backgroundColor:null==(n=e.theme)?void 0:n.tertiary6[100],"& .MuiAlert-icon":{color:null==(i=e.theme)?void 0:i.tertiary6[900]}},".MuiAlert-action":{svg:{fontSize:"1rem"}}}}),vt=l=>{const{children:t,icon:o=!1,...a}=l;return e.jsx(xt,{icon:o,...a,children:t})},ft=a.styled(a.Box)(({theme:e})=>({display:"flex",flexWrap:"wrap",alignItems:"center",gap:e.spacing(.5),minHeight:"1.4375em",border:"1px solid #D3D3D4",borderRadius:"0.25rem",cursor:"text",fontSize:"0.875rem","&.focused":{borderColor:"#54CC96",borderWidth:"1px"},"&.error":{borderColor:e.palette.error.main},"&.disabled":{backgroundColor:e.palette.action.disabledBackground,cursor:"default"},paddingLeft:3})),bt=a.styled("input")(({theme:e})=>({border:"none",outline:"none",backgroundColor:"transparent",flexGrow:1,minWidth:"120px",padding:"0.5rem",fontSize:"0.875rem",fontFamily:e.typography.fontFamily,"&::placeholder":{color:e.palette.text.secondary,opacity:1},"&:disabled":{cursor:"default"}})),jt=a.styled(a.Chip)(({theme:{palette:e}})=>({height:"24px",fontSize:"0.875rem",borderColor:" #54CC96",backgroundColor:e.theme.primary[50],color:"#2EB273",margin:"1px","& .MuiChip-deleteIcon":{fontSize:"16px",color:"#2EB273","&:hover":{color:"#2EB273"}}})),_t=s.memo(({name:l,control:t,label:o,placeholder:r="Type and press space to add",required:n=!1,disabled:d=!1,validation:u,maxChips:m,allowDuplicates:p=!1,fieldArrayName:h,endIcon:y,helperText:g,error:x,onChipAdd:v,onChipRemove:f,customChipProps:b={},allowMultipleAdd:j=!0,delimiters:_=[",",";","\n","\t"],dataType:C="string",separator:T=","})=>{const[w,S]=s.useState(""),[A,P]=s.useState(""),[k,N]=s.useState(!1),M=s.useRef(null),I=s.useRef(null),D=(e,l)=>{if(!l)return{isValid:!0,error:""};const t=e.trim();if(!t)return{isValid:!1,error:"Empty values are not allowed"};switch(l.type){case"email":{const e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);return{isValid:e,error:e?"":l.message||"Please enter a valid email address"}}case"phone":{const e=/^[+]?[1-9][\d]{0,15}$/.test(t.replace(/[\s()-]/g,""));return{isValid:e,error:e?"":l.message||"Please enter a valid phone number"}}case"custom":if(l.pattern){const e=l.pattern.test(t);return{isValid:e,error:e?"":l.message}}if(l.validator){const e=l.validator(t);return{isValid:e,error:e?"":l.message}}return{isValid:!0,error:""};default:return{isValid:!0,error:""}}},B=e=>e&&"string"==typeof e?e.split(T).map(e=>e.trim()).filter(Boolean):[],q=e=>e.join(T+" "),F=(e,l,t)=>{const o=t.filter((e,t)=>t!==l);return null==f||f(e,l),P(""),o},E=(e,l,t)=>{const o=Array.isArray(t)?t:B(t),{newChips:a,errors:r}=((e,l)=>{const t=(e=>{if(!j)return[e.trim()].filter(Boolean);const l=_.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),t=new RegExp(`[${l}]`);return e.split(t).map(e=>e.trim()).filter(Boolean)})(e);if(0===t.length)return{newChips:l,errors:[],addedCount:0};const o=[...l],a=[];let r=0;for(const n of t){if(m&&o.length>=m){a.push(`Maximum ${m} items allowed`);break}if((null==u?void 0:u.length)>0){const e=u.map(e=>D(n,e)).filter(e=>!e.isValid).map(e=>e.error);if(e.length>0){a.push(`"${n}": ${e.join(", ")}`);continue}}p||!o.includes(n)?(o.push(n),r++,null==v||v(n)):a.push(`"${n}": Duplicate values are not allowed`)}return{newChips:o,errors:a,addedCount:r}})(e,o);r.length>0?P(r.join("; ")):P(""),a.length!==o.length&&(l("string"===C?q(a):a),S(""))},R=()=>{!d&&M.current&&M.current.focus()},z=h?`${h}.${l}`:l;return e.jsx(c.Controller,{name:z,control:t,defaultValue:"string"===C?"":[],render:({field:{onChange:l,value:t,...s},fieldState:{error:c}})=>{const u=Array.isArray(t)?t:B(t||""),p=!!c||!!A||x;return e.jsxs(a.FormControl,{fullWidth:!0,error:p,children:[o&&e.jsxs(i.Typography,{type:"s5",weight:"medium",mb:.5,color:c?"theme.error.600":"theme.secondary.800",children:[o," ",n&&e.jsx("span",{className:"requiredStar",children:"*"})]}),e.jsxs(ft,{ref:I,className:`${k?"focused":""} ${p?"error":""} ${d?"disabled":""}`,onClick:R,children:[u.map((t,o)=>e.jsx(jt,{label:t,onDelete:d?void 0:e=>{e.stopPropagation();const a=F(t,o,u),r="string"===C?q(a):a;l(r)},size:"small",...b},`${t}-${o}`)),e.jsx(bt,{...s,ref:M,value:w,onChange:e=>S(e.target.value),onKeyDown:e=>((e,l,t)=>{if(" "===e.key||"Enter"===e.key)e.preventDefault(),w.trim()&&E(w,l,t);else if("Backspace"===e.key&&!w){const e=Array.isArray(t)?t:B(t);if(e.length>0){const t=e.length-1,o=F(e[t],t,e);l("string"===C?q(o):o)}}})(e,l,t),onFocus:()=>N(!0),onBlur:()=>((e,l)=>{N(!1),w.trim()&&E(w,e,l)})(l,t),onPaste:e=>((e,l,t)=>{if(j){e.preventDefault();const o=e.clipboardData.getData("text");E(w+o,l,t)}})(e,l,t),placeholder:0===u.length?r:"",disabled:d,style:{width:w?`${Math.max(8*w.length,120)}px`:"120px"}}),y&&e.jsx(a.InputAdornment,{position:"end",sx:{ml:1},children:y})]}),(g||(null==c?void 0:c.message)||A)&&e.jsx(a.FormHelperText,{children:(null==c?void 0:c.message)||A||g}),m&&e.jsxs(a.FormHelperText,{children:[u.length," / ",m," items"]})]})}})}),Ct=s.memo(({selectedCompany:l,control:t,setValue:o,fieldArrayName:a,locationFieldName:r="location_id",label:n,placeholder:i,resetValue:d,filterKey:u="&company_id.in",filterField:m="company_id",...p})=>{var h;const g=c.useFormContext(),{control:x,watch:v,setValue:f,getFieldState:j}=g||{},_=t||x,C=o||f,T=j||(()=>({})),w=(v||(()=>{}))(`${a}.${m}`),S=null==(h=T(`${a}.${m}`))?void 0:h.isDirty,P=s.useRef(),{t:k}=y.useTranslation(),N=s.useMemo(()=>!(!w||!P.current||b.isEqual(P.current,w)),[w]);s.useEffect(()=>{w&&(P.current=w)},[w]);const M=A.useLocationFilter({selectedCompany:w||l,setValue:C,fieldArrayName:a,locationFieldName:r,resetValue:d,filterKey:u,isDirty:N||S});return _?e.jsx(bl,{label:k(n)||k("crm.salesOrder.fields.location_label"),apiType:"location",addType:"location",enable_footer:!0,name:r,placeholder:k(i)||k("crm.salesOrder.fields.location_placeholder"),fieldArrayName:a,formControl:_,customeFilter:M,...p}):(console.warn("LocationSearchSelect: No form control available."),e.jsx("div",{children:"Location Search Select"}))});Ct.defaultProps={locationFieldName:"location_id",resetValue:void 0,filterKey:"&company_id.in"};const Tt=s.memo(({children:l,isFormSwitcher:t,control:o,fieldArrayName:r,formSwitcherName:n,label:s,resetForm:d})=>t?e.jsx(c.Controller,{control:o,name:`${r}.${n}`,render:({field:t})=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"24px"},children:[s?e.jsx(i.Typography,{type:"s5",style:{fontWeight:500},color:"theme.secondary.900",children:s}):null,e.jsx(a.RadioGroup,{value:t.value,onChange:e=>{d(e.target.value),t.onChange(e.target.value)},row:!0,children:l})]})}):null),wt=s.memo(({field:l,fieldName:o,sectionLabel:r,index:n,...i})=>{const d=s.useMemo(()=>l.is_fullwidth?12:l.custom_width??6,[l.is_fullwidth,l.custom_width]),c=s.useMemo(()=>`${r}-${o}-${n}`,[r,o,n]),u=s.useMemo(()=>({...l,key:c,name:o,position:n,formControl:i.control,fieldArrayName:i.fieldArrayName,required:l.is_required,label:i.t(l.label),placeholder:i.t(l.placeholder),defaultValue:l.value||l.default_value,disabled:l.disabled}),[l,o,n,c,i.control,i.fieldArrayName,i.t]),m=s.useCallback(e=>{i.onBlur&&"function"==typeof i.onBlur&&i.onBlur(e,o)},[i.onBlur,o]),p=s.useMemo(()=>{const t={email:i.images.sms,url:i.images.url,currency:i.images.dollar,geoLocation:i.images.location}[l.field_type];return t?e.jsx("img",{src:t,alt:l.field_type}):null},[l.field_type,i.images]),h=s.useMemo(()=>"relation"===l.field_type?e.jsxs("span",{className:"formSection--Relation",children:[i.t(l.label),e.jsx("img",{src:i.images.relation,alt:"relation"})]}):i.t(l.label),[l.field_type,l.label,i.t,i.images.relation]),y=()=>{var a,r,n,d,c,y,g,x,v,f,b;switch(l.field_type){case"text":case"email":case"url":case"currency":case"number":case"geoLocation":case"relation":return s.createElement(t.DynamicInput,{...u,key:u.key,label:h,onBlur:m,type:l.field_type,endIcon:p,disabled:l.disabled||"relation"===l.field_type});case"date":return s.createElement(Vl,{...u,key:u.key});case"time":return s.createElement(mt,{...u,key:u.key});case"phone":return s.createElement(Tl,{...u,key:u.key,setCountryCodeField:e=>i.handleSetCountryCodeField(e,l,i.fieldArrayName,i.values)});case"select":return s.createElement(bl,{...u,key:u.key,apiType:null==(a=l.field_properties)?void 0:a.apiType,customeFilter:null==(r=l.field_properties)?void 0:r.customeFilter,attributes:null==(n=l.field_properties)?void 0:n.attributes,disabledIds:null==(d=l.field_properties)?void 0:d.disabledIds,onChipRemove:()=>i.setValue(`${i.fieldArrayName}.${o}`,[]),...(null==l?void 0:l.addType)&&(null==(c=null==l?void 0:l.field_properties)?void 0:c.addType)?{}:{onFooterClick:()=>{var e;return null==(e=i.onSelectFooterClick)?void 0:e.call(i,l)}},handleOptions:i.setCurrencyOptions,getSelectedData:i.getSelectedData,refresh:i.refreshOptions,sortOrder:null==(y=l.field_properties)?void 0:y.sortOrder,showCancelButton:null==(g=l.field_properties)?void 0:g.showCancelButton,addType:(null==l?void 0:l.addType)||(null==(x=null==l?void 0:l.field_properties)?void 0:x.addType),modalComponentProps:null==(v=null==l?void 0:l.field_properties)?void 0:v.modalComponentProps});case"file":case"image":return s.createElement(Hl,{...u,key:u.key});case"info":return s.createElement(Kl,{...u,key:u.key});case"toggleButton":return s.createElement(yt,{...u,key:u.key,titlePosition:l.title_position,title:i.t(l.title)});case"checkbox":return s.createElement($l,{...u,key:u.key,titlePosition:l.title_position,title:i.t(l.title)});case"table":return s.createElement(dt,{...u,key:u.key,columns:l.table_columns,rows:l.table_rows,onAddClick:()=>i.handleTableAddClick(l),disableTableAddButton:Boolean(l.disableTableAddButton),is_button:i.isButton,onTableCellChange:i.onTableCellChange});case"radioButton":return s.createElement(Oe,{...u,key:u.key,titlePosition:l.title_position,title:i.t(l.title)});case"customComponent":return l.component;case"tagsInput":return s.createElement(Wl,{...u,key:u.key,label:h,type:l.field_type,endIcon:p});case"currency_with_amount":return s.createElement(Ll,{...u,key:u.key,currencyType:i.currencyOption});case"select_with_input":return e.jsx(Gl,{...u,currencyType:i.currencyOption});case"chipInput":return s.createElement(_t,{...u,key:u.key,maxChips:null==(f=l.field_properties)?void 0:f.maxChips,allowDuplicates:null==(b=l.field_properties)?void 0:b.allowDuplicates,validation:l.validation,endIcon:p,onChipAdd:e=>console.log("Chip added:",e),onChipRemove:(e,l)=>console.log("Chip removed:",e,"at index:",l)});case"location_select":return e.jsx(Ct,{fieldArrayName:i.fieldArrayName,filterField:l.filterField,getSelectedData:e=>i.getSelectedData(e),locationFieldName:l.name,addType:"location",enable_footer:!0});default:return null}};return"table"===l.field_type||"customComponent"===l.field_type?e.jsx(a.Grid,{item:!0,xs:12,children:y()}):e.jsx(a.Grid,{item:!0,xs:d,children:y()})});wt.displayName="MemoizedField";const St=s.memo(({section:l,switchForms:t,isFormSwitcher:o,control:r,fieldArrayName:n,formSwitcherName:i,handleFieldCleanUp:d,t:c})=>{const u=s.useCallback(()=>{d(t||[])},[d,t]);return o&&(null==t?void 0:t.length)?e.jsx(Tt,{...l,isFormSwitcher:o,control:r,fieldArrayName:n,formSwitcherName:i,label:c(l.form_switcher_label||""),resetForm:u,children:t.map(t=>e.jsx(a.FormControlLabel,{value:t.value||t.name,control:e.jsx(a.Radio,{}),slotProps:{typography:{variant:"body2"}},label:c(t.name),disabled:Boolean(l.disabled)},t.id))}):null});St.displayName="MemoizedFormSwitcher";const At=s.memo(({section:l,index:t,members:o,switchForms:r,isFormSwitcher:n,control:d,fieldArrayName:c,formSwitcherName:u,displayAvtar:m,isButton:p,currencyOption:h,values:y,onBlur:g,setValue:x,onSelectFooterClick:v,getSelectedData:f,setCurrencyOptions:b,refreshOptions:j,handleFieldCleanUp:_,handleSetCountryCodeField:C,handleTableAddClick:T,onTableCellChange:w,setDetailsData:S,t:A,images:P})=>{const k=s.useMemo(()=>(null==o?void 0:o.filter(e=>!e.is_hidden))||[],[o]),N=s.useMemo(()=>k.map(e=>({...e,fieldName:e.name||e.label.toLowerCase().split(" ").join("_")})),[k]),M=s.useMemo(()=>l.label?e.jsxs("div",{style:{minHeight:"16px"},children:[0!==t&&e.jsx(a.Divider,{className:"formParser--Section--SectionDivider"}),e.jsx(i.Typography,{type:"s3",weight:"medium",mb:2,mt:4,color:"theme.secondary.1000",className:"formParser--Section--SectionTitle",children:A(l.label)})]}):null,[l.label,t,A]),I=s.useMemo(()=>m?e.jsx("div",{className:"avtarDisplay",children:"ERP"}):null,[m]),D=s.useMemo(()=>({control:d,fieldArrayName:c,isButton:p,currencyOption:h,values:y,onBlur:g,setValue:x,onSelectFooterClick:v,getSelectedData:f,setCurrencyOptions:b,refreshOptions:j,handleSetCountryCodeField:C,handleTableAddClick:T,onTableCellChange:w,setDetailsData:S,t:A,images:P}),[d,c,p,h,y,g,x,v,f,b,j,C,T,w,S,A,P]);return l.is_accordion?e.jsx("section",{className:"formParser--Section",children:e.jsx("div",{style:{marginTop:"20px"},children:e.jsx(Ce,{title:A(l.label||""),children:e.jsxs("div",{className:"formParser--Grid formParser--Accordion",children:[e.jsx(St,{section:l,switchForms:r,isFormSwitcher:n,control:d,fieldArrayName:c,formSwitcherName:u,handleFieldCleanUp:_,t:A}),N.map((t,o)=>e.jsx(wt,{field:t,fieldName:t.fieldName,sectionLabel:l.label,index:o,...D},`${l.label}-${t.fieldName}-${o}`))]})})})},t):e.jsxs("section",{className:"formParser--Section",children:[M,e.jsx(St,{section:l,switchForms:r,isFormSwitcher:n,control:d,fieldArrayName:c,formSwitcherName:u,handleFieldCleanUp:_,t:A}),e.jsxs(a.Grid,{container:!0,spacing:2,children:[I,N.map((t,o)=>e.jsx(wt,{field:t,fieldName:t.fieldName,sectionLabel:l.label,index:o,...D},`${l.label}-${t.fieldName}-${o}`))]})]},t)});At.displayName="FormSection";const Pt=(e,l,t,o)=>{var a;switch(l.type){case"required":return(null==(a=t.field_properties)?void 0:a.is_multiselect)?e.required(o(l.msg_en)).min(1,o(l.msg_en)):l.value?e.required(o(l.msg_en)).test("not-empty",o(l.msg_en),e=>{var l;return"string"!=typeof e||e&&(null==(l=null==e?void 0:e.trim())?void 0:l.length)>0}):e.nullable();case"min_length":case"min_val":return e.min(l.value,o(l.msg_en));case"max_length":case"max_val":return e.max(l.value,o(l.msg_en));case"postive_number":return e.test("is-positive-number",o(l.msg_en),e=>e>=0);case"email":return e.email(l.msg_en);case"no_special_char":return e.test("no-special-char",o(l.msg_en),e=>"string"!=typeof e||/^[^.\-\W_]+$/u.test(e));case"when":return e.when(l.relation,{is:e=>e===l.values,then:()=>{var a;return(null==(a=null==l?void 0:l.thenValidations)?void 0:a.reduce((e,l)=>Pt(e,l,t,o),e))||e},otherwise:()=>{var a;return(null==(a=null==l?void 0:l.otherWiseValidations)?void 0:a.reduce((e,l)=>Pt(e,l,t,o),e))||e}});default:return e}},kt=_e.object().shape({team:_e.object().shape({name:_e.string().required("Team Name is required"),department_id:_e.string().nullable(),team_lead_id:_e.string().nullable().required("Team Lead is required"),member_ids:_e.array().nullable(),description:_e.string()})}),Nt={team:{name:"",department_id:null,team_lead_id:null,member_ids:null,description:""}},Mt=_e.object().shape({department:_e.object().shape({company_id:_e.string().nullable().required("Company is required"),department_code:_e.string().required("Department Code is required"),name:_e.string().required("Department Name is required"),parent_department_id:_e.string().nullable(),department_head_id:_e.string().nullable(),cost_code:_e.string(),status:_e.boolean(),description:_e.string()})}),It=_e.object().shape({location_data:_e.object().shape({name:_e.string().required("Name is required")})}),Dt=_e.object().shape({designation:_e.object().shape({company_id:_e.string().nullable().required("Company is required"),designation_code:_e.string(),name:_e.string().required("Designation Name is required"),reports_to:_e.string().nullable(),level:_e.number().nullable().typeError("Level must be a number"),status:_e.boolean(),description:_e.string()})}),Bt=[{label:"FIFO",value:"FIFO"},{label:"LIFO",value:"LIFO"},{label:"Weighted Average Cost",value:"Weighted Average Cost"}],qt=[{label:"Straight line",value:"Straight line"},{label:"Declining",value:"Declining"}],Ft=[{label:"Constant periods",value:"Constant periods"},{label:"Based on days per period",value:"Based on days per period"}],Et=_e.object().shape({inventory_fixed_asset_item:_e.object().shape({name:_e.string().required("Name is required"),sku:_e.string().required("SKU is required"),category:_e.mixed().required("Category is required"),base_unit:_e.mixed().required("Base Unit is required"),company:_e.array().min(1,"At least one company is required").required("Company is required"),unit_of_measurement:_e.mixed().required("Unit of Measurement is required"),stock_unit:_e.mixed().nullable(),purchase_unit:_e.mixed().nullable(),sales_unit:_e.mixed().nullable(),costing_method:_e.string().required("Costing Method is required"),depreciation_method:_e.string().required("Depreciation Method is required"),computation_method:_e.string().required("Computation Method is required"),default_tax_id:_e.mixed().required("Default Tax is required"),income_account_id:_e.mixed().required("Income Account is required"),asset_account_id:_e.mixed().required("Asset Account is required"),cogs_account_id:_e.mixed().required("COGS Account is required"),fixed_asset_account_id:_e.mixed().required("Fixed Asset Account is required"),depreciation_account_id:_e.mixed().required("Depreciation Account is required"),declining_factor:_e.number().nullable().when("depreciation_method",{is:"Declining",then:e=>e.required("Declining Factor is required").min(0,"Must be positive"),otherwise:e=>e.nullable()})})}),Rt=_e.object().shape({brand_data:_e.object().shape({name:_e.string().required("Name is required")})}),zt=_e.object().shape({category_data:_e.object().shape({category_name:_e.string().required("Category Name is required")})}),$t=_e.object().shape({source_type:_e.object().shape({name:_e.string().trim().required("common.source_type.source_type_name_required").max(255,"common.source_type.source_type_name_max"),description:_e.string().nullable().max(1e3,"common.source_type.description_max")})}),Vt={source_type:{name:"",description:""}},Lt=({isOpen:l,setIsOpen:r,isLoading:n=!1,onSave:d,modalProps:u})=>{const{t:m}=y.useTranslation(),[p,h]=s.useState(!1),{control:g,handleSubmit:x,reset:v}=c.useForm({mode:"all",resolver:t.o($t),defaultValues:Vt}),f=()=>{v(Vt),r(!1)},b=async e=>{var l;h(!0);try{await d({...e.source_type,description:(null==(l=e.source_type.description)?void 0:l.trim())||null}),f()}catch(t){console.error(m("common.source_type.error_creating_source_type"),t)}finally{h(!1)}};return e.jsx(t.Modal,{open:l,onClose:f,maxWidth:(null==u?void 0:u.maxWidth)||"sm",fullWidth:(null==u?void 0:u.fullWidth)??!0,...u,children:e.jsxs("form",{onSubmit:e=>{e.stopPropagation(),e.preventDefault(),x(b)(e)},children:[(p||n)&&e.jsx(Dl,{}),e.jsxs(a.DialogTitle,{className:"brandAddModal--DialogTitle",children:[e.jsx(i.Typography,{type:"s3",color:"inherit",weight:"medium",children:m("common.source_type.create_new_source_type")}),e.jsx(a.IconButton,{onClick:e=>{e.stopPropagation(),f()},children:e.jsx(o,{fontSize:"small"})})]}),e.jsx(a.DialogContent,{dividers:!0,children:e.jsxs(a.Grid,{container:!0,spacing:2,children:[e.jsx(a.Grid,{item:!0,xs:12,children:e.jsx(t.DynamicInput,{label:m("common.source_type.source_type_name"),name:"name",fieldArrayName:"source_type",placeholder:m("common.source_type.enter_source_type_name"),formControl:g,required:!0})}),e.jsx(a.Grid,{item:!0,xs:12,children:e.jsx(t.DynamicInput,{label:m("common.source_type.description"),name:"description",fieldArrayName:"source_type",placeholder:m("common.source_type.enter_description_optional"),formControl:g,is_multiline:!0})})]})}),e.jsx(a.DialogActions,{children:e.jsxs(a.Box,{display:"flex",gap:1.5,width:"100%",justifyContent:"flex-end",children:[e.jsx(t.Button,{variant:"outlined",onClick:e=>{e.stopPropagation(),f()},disabled:p||n,children:m("common.cancel")}),e.jsx(t.Button,{variant:"contained",type:"submit",onClick:e=>e.stopPropagation(),loading:p||n,children:m("common.source_type.create_source_type")})]})})]})})},Ot=_e.object().shape({journal_type_data:_e.object().shape({name:_e.string().required("Name is required").max(100,"Name must be at most 100 characters"),is_payment:_e.boolean()})}),Gt=({isOpen:l,setIsOpen:r,onSave:n,isLoading:s,modalProps:d})=>{const{t:u}=y.useTranslation(),{control:m,handleSubmit:p,reset:h,trigger:g}=c.useForm({mode:"all",resolver:t.o(Ot),defaultValues:{journal_type_data:{name:"",is_payment:!1}}}),x=()=>{h({journal_type_data:{name:"",is_payment:!1}}),r()},v=async e=>{await g()&&(await n(null==e?void 0:e.journal_type_data),x())};return e.jsx(t.Modal,{open:l,onClose:x,maxWidth:"sm",fullWidth:!0,...d,children:e.jsx(e.Fragment,{children:e.jsxs("form",{onSubmit:p(v),children:[s&&e.jsx(Dl,{}),e.jsxs(a.DialogTitle,{className:"journalTypeAddModal--DialogTitle",children:[e.jsx(i.Typography,{type:"s3",color:"inherit",weight:"medium",children:u("accounting.journalType.addModal.title","Create New Journal Type")}),e.jsx(a.IconButton,{onClick:x,children:e.jsx(o,{fontSize:"small"})})]}),e.jsx(a.DialogContent,{className:"journalTypeAddModal--DialogContents",children:e.jsxs(a.Grid,{container:!0,rowGap:1.5,columnSpacing:3,pt:3,children:[e.jsx(a.Grid,{item:!0,sm:12,children:e.jsx(t.DynamicInput,{type:"text",formControl:m,label:u("accounting.journalType.form.name_label","Name"),name:"name",fieldArrayName:"journal_type_data",placeholder:u("accounting.journalType.form.name_placeholder","Enter journal type name"),required:!0})}),e.jsx(a.Grid,{item:!0,sm:12,children:e.jsx($l,{formControl:m,label:u("accounting.journalType.form.is_payment_label","Is Payment"),name:"is_payment",fieldArrayName:"journal_type_data",title:u("accounting.journalType.form.is_payment_label","Is Payment")})})]})}),e.jsxs(a.DialogActions,{className:"journalTypeAddModal--DialogAction",children:[e.jsx("span",{}),e.jsxs(a.Box,{display:"flex",gap:1.5,children:[e.jsx(t.Button,{className:"journalTypeAddModal--DialogAction--WhiteBtn",onClick:x,children:u("common.cancel","Cancel")}),e.jsx(t.Button,{type:"button",onClick:p(v),children:u("common.save","Save")})]})]})]})})})},Wt=async(e,l)=>{try{return await e({...l,...f.getToken()})}catch(t){throw q.enqueueSnackbar(f.getErrorMessage(null==t?void 0:t.message),{variant:"error"}),t}},Ut={location:{api:e=>Wt(D.postV1WarehouseLocation,e),component:({isOpen:l,setIsOpen:r,modalProps:n,onSave:d,isLoading:u})=>{const{t:m}=y.useTranslation(),[p,h]=s.useState(null),{control:g,handleSubmit:x,reset:v}=c.useForm({mode:"all",resolver:t.o(It)}),f=()=>{v({location_data:void 0}),r()},b=async e=>{d(null==e?void 0:e.location_data)};return e.jsxs(t.Modal,{open:l,onClose:f,maxWidth:"sm",fullWidth:!0,...n,children:[e.jsx(e.Fragment,{children:e.jsxs("form",{onSubmit:x(b),children:[u&&e.jsx(Dl,{}),e.jsxs(a.DialogTitle,{className:"brandAddModal--DialogTitle",children:[e.jsx(i.Typography,{type:"s3",color:"inherit",weight:"medium",children:m("inventory.item.locationModal.title")}),e.jsx(a.IconButton,{onClick:f,children:e.jsx(o,{fontSize:"small"})})]}),e.jsx(a.DialogContent,{className:"brandAddModal--DialogContents",children:e.jsxs(a.Grid,{container:!0,rowGap:1.5,columnSpacing:3,pt:3,children:[e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(t.DynamicInput,{type:"text",formControl:g,label:m("inventory.item.locationModal.location_name_label"),name:"name",fieldArrayName:"location_data",placeholder:m("inventory.item.locationModal.location_name_placeholder"),required:!0})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(t.DynamicInput,{type:"text",formControl:g,label:m("inventory.item.locationModal.location_code_label"),name:"short_name",fieldArrayName:"location_data",placeholder:m("inventory.item.locationModal.location_code_placeholder"),required:!0})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("accounting.authorize_commission.fields.company_label"),name:"company_id",placeholder:m("accounting.authorize_commission.fields.company_placeholder"),fieldArrayName:"location_data",formControl:g,apiType:"company",getSelectedData:e=>console.log("data",e),required:!0})})]})}),e.jsxs(a.DialogActions,{className:"brandAddModal--DialogAction",children:[e.jsx("span",{}),e.jsxs(a.Box,{display:"flex",gap:1.5,children:[e.jsx(t.Button,{className:"brandAddModal--DialogAction--WhiteBtn",onClick:f,children:m("common.cancel")}),e.jsx(t.Button,{type:"button",onClick:x(b),children:m("common.save")})]})]})]})}),e.jsx(t.Toast,{open:Boolean(p),type:null==p?void 0:p.type,message:null==p?void 0:p.message,handleClose:()=>h(null),anchorOrigin:{horizontal:"right",vertical:"bottom"}})]})}},party:{api:e=>Wt(D.postV1Parties,e),component:ql},department:{api:e=>Wt(f.postV1Departments,e),component:({isOpen:l,setIsOpen:r,onSave:n,isLoading:s,modalProps:d})=>{const{t:u}=y.useTranslation(),{control:m,handleSubmit:p,reset:h,trigger:g,watch:x}=c.useForm({mode:"all",resolver:t.o(Mt),defaultValues:{department:{company_id:null,department_code:"",name:"",parent_department_id:null,department_head_id:null,cost_code:"",status:!0,description:""}}}),v=x("department.company_id"),f=()=>{h({department:{company_id:null,department_code:"",name:"",parent_department_id:null,department_head_id:null,cost_code:"",status:!0,description:""}}),r()},b=async e=>{await g()&&(await n(e),f())};return e.jsx(t.Modal,{open:l,onClose:f,maxWidth:"sm",fullWidth:!0,...d,children:e.jsx(e.Fragment,{children:e.jsxs("form",{onSubmit:p(b),children:[s&&e.jsx(Dl,{}),e.jsxs(a.DialogTitle,{className:"brandAddModal--DialogTitle",children:[e.jsx(i.Typography,{type:"s3",color:"inherit",weight:"medium",children:u("hrms.organization_structure.departmentModal.title","Add Department")}),e.jsx(a.IconButton,{onClick:f,children:e.jsx(o,{fontSize:"small"})})]}),e.jsx(a.DialogContent,{className:"brandAddModal--DialogContents",children:e.jsxs(a.Grid,{container:!0,rowGap:1.5,columnSpacing:3,pt:3,children:[e.jsx(a.Grid,{item:!0,sm:12,children:e.jsx(bl,{label:u("hrms.organization_structure.departmentModal.company_label","Company"),name:"company_id",placeholder:u("hrms.organization_structure.departmentModal.company_placeholder","Select Company"),fieldArrayName:"department",formControl:m,apiType:"company",required:!0,options:[]})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(t.DynamicInput,{type:"text",formControl:m,label:u("hrms.organization_structure.departmentModal.code_label","Department Code"),name:"department_code",fieldArrayName:"department",placeholder:u("hrms.organization_structure.departmentModal.code_placeholder","Enter Department Code"),required:!0})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(t.DynamicInput,{type:"text",formControl:m,label:u("hrms.organization_structure.departmentModal.name_label","Department Name"),name:"name",fieldArrayName:"department",placeholder:u("hrms.organization_structure.departmentModal.name_placeholder","Enter Department Name"),required:!0})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:u("hrms.organization_structure.departmentModal.parent_department_label","Parent Department"),name:"parent_department_id",placeholder:u("hrms.organization_structure.departmentModal.parent_department_placeholder","Select Parent Department"),fieldArrayName:"department",formControl:m,apiType:"department",required:!1,options:[],customeFilter:{"is_parent.eq":!0,"&company_id.eq":v||0}})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:u("hrms.organization_structure.departmentModal.department_head_label","Department Head"),name:"department_head_id",placeholder:u("hrms.organization_structure.departmentModal.department_head_placeholder","Select Department Head"),fieldArrayName:"department",formControl:m,apiType:"employees",required:!1,options:[],customeFilter:{"&company_id.eq":v||0}})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(t.DynamicInput,{type:"text",formControl:m,label:u("hrms.organization_structure.departmentModal.cost_code_label","Cost Code"),name:"cost_code",fieldArrayName:"department",placeholder:u("hrms.organization_structure.departmentModal.cost_code_placeholder","Enter Cost Code")})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(yt,{formControl:m,name:"status",fieldArrayName:"department",label:u("hrms.organization_structure.departmentModal.status_label","Status"),title:u("common.active","Active"),titlePosition:"end",position:3})}),e.jsx(a.Grid,{item:!0,sm:12,children:e.jsx(t.DynamicInput,{type:"textarea",formControl:m,label:u("hrms.organization_structure.departmentModal.description_label","Description"),name:"description",fieldArrayName:"department",placeholder:u("hrms.organization_structure.departmentModal.description_placeholder","Enter Description"),is_multiline:!0,rows:3})})]})}),e.jsxs(a.DialogActions,{className:"brandAddModal--DialogAction",children:[e.jsx("span",{}),e.jsxs(a.Box,{display:"flex",gap:1.5,children:[e.jsx(t.Button,{className:"brandAddModal--DialogAction--WhiteBtn",onClick:f,children:u("common.cancel")}),e.jsx(t.Button,{type:"button",onClick:p(b),children:u("common.save")})]})]})]})})})}},team:{api:e=>Wt(f.postV1DepartmentsTeams,e),component:({isOpen:l,setIsOpen:r,onSave:n,isLoading:d,modalProps:u})=>{const{t:m}=y.useTranslation(),{control:p,handleSubmit:h,reset:g,watch:x}=c.useForm({mode:"all",resolver:t.o(kt),defaultValues:Nt}),v=x("team.department_id"),f=x("team.team_lead_id"),b=()=>{g(Nt),r()},j=s.useMemo(()=>({"&department_id.eq":v||0}),[v]),_=s.useMemo(()=>({"&department_id.eq":v||0,...f?{"&id.ne":f}:{}}),[v,f]);return e.jsx(t.Modal,{open:l,onClose:b,maxWidth:"sm",fullWidth:!0,...u,children:e.jsxs("form",{onSubmit:h(async e=>{await n(e),b()}),children:[d&&e.jsx(Dl,{}),e.jsxs(a.DialogTitle,{className:"brandAddModal--DialogTitle",children:[e.jsx(i.Typography,{type:"s3",color:"inherit",weight:"medium",children:m("hrms.organization_structure.teamModal.title","Add Team")}),e.jsx(a.IconButton,{onClick:b,children:e.jsx(o,{fontSize:"small"})})]}),e.jsx(a.DialogContent,{className:"brandAddModal--DialogContents",children:e.jsxs(a.Grid,{container:!0,rowGap:1.5,columnSpacing:3,pt:3,children:[e.jsx(a.Grid,{item:!0,sm:12,children:e.jsx(t.DynamicInput,{type:"text",formControl:p,label:m("hrms.organization_structure.teamModal.name_label","Team Name"),name:"name",fieldArrayName:"team",placeholder:m("hrms.organization_structure.teamModal.name_placeholder","Enter Team Name"),required:!0})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("hrms.organization_structure.teamModal.department_label","Department"),name:"department_id",placeholder:m("hrms.organization_structure.teamModal.department_placeholder","Select Department"),fieldArrayName:"team",formControl:p,apiType:"department",required:!1,options:[]})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("hrms.organization_structure.teamModal.team_lead_label","Team Lead"),name:"team_lead_id",placeholder:m("hrms.organization_structure.teamModal.team_lead_placeholder","Select Team Lead"),fieldArrayName:"team",formControl:p,apiType:"employees",required:!0,options:[],customeFilter:j})}),e.jsx(a.Grid,{item:!0,sm:12,children:e.jsx(bl,{label:m("hrms.organization_structure.teamModal.members_label","Members"),name:"member_ids",placeholder:m("hrms.organization_structure.teamModal.members_placeholder","Select Members"),fieldArrayName:"team",formControl:p,apiType:"employees",required:!1,options:[],is_multiselect:!0,customeFilter:_})}),e.jsx(a.Grid,{item:!0,sm:12,children:e.jsx(t.DynamicInput,{type:"textarea",formControl:p,label:m("hrms.organization_structure.teamModal.description_label","Description"),name:"description",fieldArrayName:"team",placeholder:m("hrms.organization_structure.teamModal.description_placeholder","Enter Description"),is_multiline:!0,rows:3})})]})}),e.jsxs(a.DialogActions,{className:"brandAddModal--DialogAction",children:[e.jsx("span",{}),e.jsxs(a.Box,{display:"flex",gap:1.5,children:[e.jsx(t.Button,{className:"brandAddModal--DialogAction--WhiteBtn",onClick:b,children:m("common.cancel")}),e.jsx(t.Button,{type:"submit",children:m("common.save")})]})]})]})})}},designation:{api:e=>Wt(f.postV1Designation,e),component:({isOpen:l,setIsOpen:r,onSave:n,isLoading:s,modalProps:d})=>{const{t:u}=y.useTranslation(),{control:m,handleSubmit:p,reset:h,trigger:g,watch:x}=c.useForm({mode:"all",resolver:t.o(Dt),defaultValues:{designation:{company_id:null,designation_code:"",name:"",reports_to:null,level:null,status:!0,description:""}}}),v=x("designation.company_id"),f=()=>{h({designation:{company_id:null,designation_code:"",name:"",reports_to:null,level:null,status:!0,description:""}}),r()},b=async e=>{await g()&&(await n(e),f())};return e.jsx(t.Modal,{open:l,onClose:f,maxWidth:"sm",fullWidth:!0,...d,children:e.jsx(e.Fragment,{children:e.jsxs("form",{onSubmit:p(b),children:[s&&e.jsx(Dl,{}),e.jsxs(a.DialogTitle,{className:"brandAddModal--DialogTitle",children:[e.jsx(i.Typography,{type:"s3",color:"inherit",weight:"medium",children:u("hrms.organization_structure.designationModal.title","Add Designation")}),e.jsx(a.IconButton,{onClick:f,children:e.jsx(o,{fontSize:"small"})})]}),e.jsx(a.DialogContent,{className:"brandAddModal--DialogContents",children:e.jsxs(a.Grid,{container:!0,rowGap:1.5,columnSpacing:3,pt:3,children:[e.jsx(a.Grid,{item:!0,sm:12,children:e.jsx(bl,{label:u("hrms.organization_structure.designationModal.company_label","Company"),name:"company_id",placeholder:u("hrms.organization_structure.designationModal.company_placeholder","Select Company"),fieldArrayName:"designation",formControl:m,apiType:"company",required:!0,options:[]})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(t.DynamicInput,{type:"text",formControl:m,label:u("hrms.organization_structure.designationModal.code_label","Designation Code"),name:"designation_code",fieldArrayName:"designation",placeholder:u("hrms.organization_structure.designationModal.code_placeholder","Enter Designation Code")})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(t.DynamicInput,{type:"text",formControl:m,label:u("hrms.organization_structure.designationModal.name_label","Designation Name"),name:"name",fieldArrayName:"designation",placeholder:u("hrms.organization_structure.designationModal.name_placeholder","Enter Designation Name"),required:!0})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:u("hrms.organization_structure.designationModal.reports_to_label","Reports To"),name:"reports_to",placeholder:u("hrms.organization_structure.designationModal.reports_to_placeholder","Select Reports To"),fieldArrayName:"designation",formControl:m,apiType:"employees",required:!1,options:[],customeFilter:{"&company_id.eq":v||0}})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(t.DynamicInput,{type:"number",formControl:m,label:u("hrms.organization_structure.designationModal.level_label","Level"),name:"level",fieldArrayName:"designation",placeholder:u("hrms.organization_structure.designationModal.level_placeholder","Enter Level")})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(yt,{formControl:m,name:"status",fieldArrayName:"designation",label:u("hrms.organization_structure.designationModal.status_label","Status"),title:u("common.active","Active"),titlePosition:"end",position:3})}),e.jsx(a.Grid,{item:!0,sm:12,children:e.jsx(t.DynamicInput,{type:"textarea",formControl:m,label:u("hrms.organization_structure.designationModal.description_label","Description"),name:"description",fieldArrayName:"designation",placeholder:u("hrms.organization_structure.designationModal.description_placeholder","Enter Description"),is_multiline:!0,rows:3})})]})}),e.jsxs(a.DialogActions,{className:"brandAddModal--DialogAction",children:[e.jsx("span",{}),e.jsxs(a.Box,{display:"flex",gap:1.5,children:[e.jsx(t.Button,{className:"brandAddModal--DialogAction--WhiteBtn",onClick:f,children:u("common.cancel")}),e.jsx(t.Button,{type:"button",onClick:p(b),children:u("common.save")})]})]})]})})})}},fixedAssetItem:{api:e=>Wt(D.postV1InventoryFixedAssetItems,e),component:({isOpen:l,setIsOpen:r,modalProps:n,onSave:d,isLoading:u})=>{const{t:m}=y.useTranslation(),[p,h]=s.useState(null),[g,x]=s.useState(null),v=["stock_unit","purchase_unit","sales_unit","consumption_unit","base_unit"],b={inventory_fixed_asset_item:{name:"",sku:"",category:null,base_unit:null,company:[],unit_of_measurement:null,stock_unit:null,purchase_unit:null,sales_unit:null,costing_method:"",depreciation_method:"",computation_method:"",default_tax_id:null,income_account_id:null,asset_account_id:null,cogs_account_id:null,fixed_asset_account_id:null,depreciation_account_id:null,declining_factor:null,status:1}},j=c.useForm({mode:"all",resolver:t.o(Et),defaultValues:b}),{control:_,handleSubmit:C,reset:T,setValue:w,trigger:S}=j||{},[A,P,k,N]=c.useWatch({control:_,name:["inventory_fixed_asset_item.name","inventory_fixed_asset_item.category","inventory_fixed_asset_item.unit_of_measurement","inventory_fixed_asset_item.depreciation_method"]});s.useEffect(()=>{if(A&&(null==g?void 0:g.category_name)){const e=f.skuGenerator({name:A,category:g.category_name});w("inventory_fixed_asset_item.sku",e)}},[A,g,w]);const M=()=>{T(b),x(null),r()},I=async e=>{await S()&&(await d({...e.inventory_fixed_asset_item,type:"inventory-fixed-asset",status:1}),M())},D=s.useCallback(e=>{x(e)},[]),B=s.useCallback(async()=>{if(!k)return;const e={"&template_id.eq":k,"&is_base_unit.eq":1},l=await f.fetchOptions("uom",e,[],!1);v.forEach(e=>{w(`inventory_fixed_asset_item.${e}`,null==l?void 0:l.id)})},[k]);return s.useEffect(()=>{B()},[B]),e.jsxs(t.Modal,{open:l,onClose:M,maxWidth:"md",fullWidth:!0,...n,children:[e.jsx(e.Fragment,{children:e.jsx(c.FormProvider,{...j,children:e.jsxs("form",{onSubmit:C(I),children:[u&&e.jsx(Dl,{}),e.jsxs(a.DialogTitle,{className:"fixedAssetItemAddModal--DialogTitle",children:[e.jsx(i.Typography,{type:"s3",color:"inherit",weight:"medium",children:m("inventory.fixed_asset_items.modal.title","Add Fixed Asset Item")}),e.jsx(a.IconButton,{onClick:M,children:e.jsx(o,{fontSize:"small"})})]}),e.jsx(a.DialogContent,{className:"fixedAssetItemAddModal--DialogContents",children:e.jsxs(a.Grid,{container:!0,rowGap:1.5,columnSpacing:3,pt:3,children:[e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(t.DynamicInput,{type:"text",formControl:_,label:m("inventory.fixed_asset_items.modal.name_label","Name"),name:"name",fieldArrayName:"inventory_fixed_asset_item",placeholder:m("inventory.fixed_asset_items.modal.name_placeholder","Enter Name"),required:!0})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(t.DynamicInput,{type:"text",formControl:_,label:m("inventory.fixed_asset_items.modal.sku_label","SKU"),name:"sku",fieldArrayName:"inventory_fixed_asset_item",placeholder:m("inventory.fixed_asset_items.modal.sku_placeholder","Auto-generated"),required:!0,disabled:!0})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("inventory.fixed_asset_items.modal.category_label","Category"),name:"category",placeholder:m("inventory.fixed_asset_items.modal.category_placeholder","Select Category"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,apiType:"categoryItems",options:[],required:!0,getSelectedData:D})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("inventory.fixed_asset_items.modal.company_label","Company"),name:"company",placeholder:m("inventory.fixed_asset_items.modal.company_placeholder","Select Company"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,apiType:"company",options:[],is_multiselect:!0,required:!0})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(Rl,{label:m("inventory.fixed_asset_items.modal.costing_method_label","Costing Method"),name:"costing_method",placeholder:m("inventory.fixed_asset_items.modal.costing_method_placeholder","Select Costing Method"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,options:Bt,required:!0})}),e.jsx(a.Grid,{item:!0,xs:12,pt:2,children:e.jsx(i.Typography,{type:"s3",weight:"medium",color:"theme.neutral.900",children:m("inventory.fixed_asset_items.modal.uom_section","Unit of Measurement")})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("inventory.fixed_asset_items.modal.unit_of_measurement_label","UOM Template"),name:"unit_of_measurement",placeholder:m("inventory.fixed_asset_items.modal.unit_of_measurement_placeholder","Select UOM Template"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,apiType:"uom_templates",required:!0})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("inventory.fixed_asset_items.modal.stock_unit_label","Stock Unit"),name:"stock_unit",placeholder:m("inventory.fixed_asset_items.modal.stock_unit_placeholder","Select Stock Unit"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,apiType:"uom",customFilter:{"&template_id.eq":k||0}})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("inventory.fixed_asset_items.modal.purchase_unit_label","Purchase Unit"),name:"purchase_unit",placeholder:m("inventory.fixed_asset_items.modal.purchase_unit_placeholder","Select Purchase Unit"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,apiType:"uom",customFilter:{"&template_id.eq":k||0}})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("inventory.fixed_asset_items.modal.sales_unit_label","Consumption Unit"),name:"sales_unit",placeholder:m("inventory.fixed_asset_items.modal.sales_unit_placeholder","Select Sales Unit"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,apiType:"uom",customFilter:{"&template_id.eq":k||0}})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("inventory.fixed_asset_items.modal.sales_unit_label","Consumption Unit"),name:"consumption_unit",placeholder:m("inventory.fixed_asset_items.modal.sales_unit_placeholder","Select Sales Unit"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,apiType:"uom",customFilter:{"&template_id.eq":k||0}})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("inventory.fixed_asset_items.modal.base_unit_label","Base Unit"),name:"base_unit",placeholder:m("inventory.fixed_asset_items.modal.base_unit_placeholder","Select Base Unit"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,disabled:!0,apiType:"uom",customFilter:{"&template_id.eq":k||0,"&is_base_unit.eq":1}})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(Rl,{label:m("inventory.fixed_asset_items.modal.depreciation_method_label","Depreciation Method"),name:"depreciation_method",placeholder:m("inventory.fixed_asset_items.modal.depreciation_method_placeholder","Select Depreciation Method"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,options:qt,required:!0})}),"Declining"===N&&e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(t.DynamicInput,{type:"number",formControl:_,label:m("inventory.fixed_asset_items.modal.declining_factor_label","Declining Factor"),name:"declining_factor",fieldArrayName:"inventory_fixed_asset_item",placeholder:m("inventory.fixed_asset_items.modal.declining_factor_placeholder","Enter Declining Factor"),required:!0})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(Rl,{label:m("inventory.fixed_asset_items.modal.computation_method_label","Computation Method"),name:"computation_method",placeholder:m("inventory.fixed_asset_items.modal.computation_method_placeholder","Select Computation Method"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,options:Ft,required:!0})}),e.jsx(a.Grid,{item:!0,xs:12,pt:2,children:e.jsx(i.Typography,{type:"s3",weight:"medium",color:"theme.neutral.900",children:m("inventory.fixed_asset_items.modal.accounting_section","Accounting")})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("inventory.fixed_asset_items.modal.default_tax_label","Default Tax"),name:"default_tax_id",placeholder:m("inventory.fixed_asset_items.modal.default_tax_placeholder","Select Default Tax"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,apiType:"taxTemplate",options:[],required:!0})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("inventory.fixed_asset_items.modal.income_account_label","Income Account"),name:"income_account_id",placeholder:m("inventory.fixed_asset_items.modal.income_account_placeholder","Select Income Account"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,apiType:"accounts",options:[],required:!0,customeFilter:{"&account_parent_type.in":["Income","Assets"]}})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("inventory.fixed_asset_items.modal.asset_account_label","Asset Account"),name:"asset_account_id",placeholder:m("inventory.fixed_asset_items.modal.asset_account_placeholder","Select Asset Account"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,apiType:"accounts",options:[],required:!0,customeFilter:{"&account_parent_type.eq":"Assets"}})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("inventory.fixed_asset_items.modal.cogs_account_label","COGS Account"),name:"cogs_account_id",placeholder:m("inventory.fixed_asset_items.modal.cogs_account_placeholder","Select COGS Account"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,apiType:"accounts",options:[],required:!0})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("inventory.fixed_asset_items.modal.fixed_asset_account_label","Fixed Asset Account"),name:"fixed_asset_account_id",placeholder:m("inventory.fixed_asset_items.modal.fixed_asset_account_placeholder","Select Fixed Asset Account"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,apiType:"accounts",options:[],required:!0,customeFilter:{"&account_parent_type.eq":"Assets"}})}),e.jsx(a.Grid,{item:!0,sm:6,children:e.jsx(bl,{label:m("inventory.fixed_asset_items.modal.depreciation_account_label","Depreciation Account"),name:"depreciation_account_id",placeholder:m("inventory.fixed_asset_items.modal.depreciation_account_placeholder","Select Depreciation Account"),fieldArrayName:"inventory_fixed_asset_item",formControl:_,apiType:"accounts",options:[],required:!0,customeFilter:{"&account_parent_type.eq":"Assets"}})})]})}),e.jsxs(a.DialogActions,{className:"fixedAssetItemAddModal--DialogAction",children:[e.jsx("span",{}),e.jsxs(a.Box,{display:"flex",gap:1.5,children:[e.jsx(t.Button,{className:"fixedAssetItemAddModal--DialogAction--WhiteBtn",onClick:M,children:m("common.cancel")}),e.jsx(t.Button,{type:"button",onClick:C(I),children:m("common.save")})]})]})]})})}),e.jsx(t.Toast,{open:Boolean(p),type:null==p?void 0:p.type,message:null==p?void 0:p.message,handleClose:()=>h(null),anchorOrigin:{horizontal:"right",vertical:"bottom"}})]})}},brand:{api:e=>Wt(D.postV1Brand,e),component:({isOpen:l,setIsOpen:r,onSave:n,isLoading:s,modalProps:d})=>{const{t:u}=y.useTranslation(),{control:m,handleSubmit:p,reset:h,trigger:g}=c.useForm({mode:"all",resolver:t.o(Rt),defaultValues:{brand_data:{name:""}}}),x=()=>{h({brand_data:{name:""}}),r()},v=async e=>{await g()&&(await n(null==e?void 0:e.brand_data),x())};return e.jsx(t.Modal,{open:l,onClose:x,maxWidth:"sm",fullWidth:!0,...d,children:e.jsx(e.Fragment,{children:e.jsxs("form",{onSubmit:p(v),children:[s&&e.jsx(Dl,{}),e.jsxs(a.DialogTitle,{className:"brandAddModal--DialogTitle",children:[e.jsx(i.Typography,{type:"s3",color:"inherit",weight:"medium",children:u("inventory.item.brandModal.title")}),e.jsx(a.IconButton,{onClick:x,children:e.jsx(o,{fontSize:"small"})})]}),e.jsx(a.DialogContent,{className:"brandAddModal--DialogContents",children:e.jsx(a.Grid,{container:!0,rowGap:1.5,columnSpacing:3,pt:3,children:e.jsx(a.Grid,{item:!0,sm:12,children:e.jsx(t.DynamicInput,{type:"text",formControl:m,label:u("inventory.item.brandModal.brand_name_label"),name:"name",fieldArrayName:"brand_data",placeholder:u("inventory.item.brandModal.brand_name_placeholder"),required:!0})})})}),e.jsxs(a.DialogActions,{className:"brandAddModal--DialogAction",children:[e.jsx("span",{}),e.jsxs(a.Box,{display:"flex",gap:1.5,children:[e.jsx(t.Button,{className:"brandAddModal--DialogAction--WhiteBtn",onClick:x,children:u("common.cancel")}),e.jsx(t.Button,{type:"button",onClick:p(v),children:u("common.save")})]})]})]})})})}},category:{api:e=>Wt(D.postV1CategoryItems,e),component:({isOpen:l,setIsOpen:r,onSave:n,isLoading:s,modalProps:d})=>{const{t:u}=y.useTranslation(),{control:m,handleSubmit:p,reset:h,trigger:g}=c.useForm({mode:"all",resolver:t.o(zt),defaultValues:{category_data:{category_name:""}}}),x=()=>{h({category_data:{category_name:""}}),r()},v=async e=>{await g()&&(await n({category_data:{category_name:e.category_data.category_name,sku_prefix:e.category_data.sku_prefix,unique_items:e.category_data.unique_items,status:!0},attribute_data:[]}),x())};return e.jsx(t.Modal,{open:l,onClose:x,maxWidth:"sm",fullWidth:!0,...d,children:e.jsx(e.Fragment,{children:e.jsxs("form",{onSubmit:p(v),children:[s&&e.jsx(Dl,{}),e.jsxs(a.DialogTitle,{className:"categoryAddModal--DialogTitle",children:[e.jsx(i.Typography,{type:"s3",color:"inherit",weight:"medium",children:u("inventory.item.categoryModal.title")}),e.jsx(a.IconButton,{onClick:x,children:e.jsx(o,{fontSize:"small"})})]}),e.jsx(a.DialogContent,{className:"categoryAddModal--DialogContents",children:e.jsxs(a.Grid,{container:!0,rowGap:1.5,columnSpacing:3,pt:3,children:[e.jsx(a.Grid,{item:!0,sm:12,children:e.jsx(t.DynamicInput,{type:"text",formControl:m,label:u("inventory.item.categoryModal.category_name_label"),name:"category_name",fieldArrayName:"category_data",placeholder:u("inventory.item.categoryModal.category_name_placeholder"),required:!0})}),e.jsx(a.Grid,{item:!0,sm:12,children:e.jsx(t.DynamicInput,{type:"text",formControl:m,label:u("inventory.item.categoryModal.sku_prefix_label"),name:"sku_prefix",fieldArrayName:"category_data",placeholder:u("inventory.item.categoryModal.sku_prefix_placeholder")})}),e.jsx(a.Grid,{item:!0,sm:12,children:e.jsx(t.DynamicInput,{type:"text",formControl:m,label:u("inventory.item.categoryModal.unique_items_label"),name:"unique_items",fieldArrayName:"category_data",placeholder:u("inventory.item.categoryModal.unique_items_placeholder")})})]})}),e.jsxs(a.DialogActions,{className:"categoryAddModal--DialogAction",children:[e.jsx("span",{}),e.jsxs(a.Box,{display:"flex",gap:1.5,children:[e.jsx(t.Button,{className:"categoryAddModal--DialogAction--WhiteBtn",onClick:x,children:u("common.cancel")}),e.jsx(t.Button,{type:"button",onClick:p(v),children:u("common.save")})]})]})]})})})}},industry:{api:e=>Wt(D.postV1PartiesIndustry,e),component:({isOpen:l,setIsOpen:r,onSave:n,isLoading:s,modalProps:d})=>{const{t:u}=y.useTranslation(),m=_e.object().shape({industry:_e.object().shape({name:_e.string().required("Industry name is required").max(255,"Industry name must be at most 255 characters")})}),{control:p,handleSubmit:h,reset:g}=c.useForm({resolver:t.o(m),mode:"all",defaultValues:{industry:{name:""}}}),x=()=>{g({industry:{name:""}}),r(!1)},v=async e=>{try{await n(e.industry),x()}catch(l){console.error("❌ ~ Error saving industry:",l)}};return e.jsxs(t.Modal,{open:l,onClose:x,maxWidth:(null==d?void 0:d.maxWidth)||"sm",fullWidth:(null==d?void 0:d.fullWidth)||!0,className:"industry-add-modal",children:[e.jsxs(a.DialogTitle,{children:[e.jsx(i.Typography,{type:"h5",weight:"medium",color:"theme.secondary.1000",children:u("crm.leads.fields.create_industry_label","Create New Industry")}),e.jsx(a.IconButton,{onClick:x,children:e.jsx(o,{fontSize:"small"})})]}),e.jsxs("form",{onSubmit:e=>(null==e||e.preventDefault(),null==e||e.stopPropagation(),h(v)(e)),children:[e.jsx(a.DialogContent,{children:s?e.jsx(Dl,{}):e.jsx(a.Grid,{container:!0,spacing:3,children:e.jsx(a.Grid,{item:!0,xs:12,children:e.jsx(t.DynamicInput,{label:u("crm.leads.fields.industry_name_label","Industry Name"),name:"name",placeholder:u("crm.leads.fields.industry_name_placeholder","Enter Industry Name"),fieldArrayName:"industry",formControl:p,required:!0})})})}),e.jsxs(a.DialogActions,{children:[e.jsx(t.Button,{type:"button",variant:"outlined",onClick:x,disabled:s,children:u("common.cancel","Cancel")}),e.jsx(t.Button,{type:"submit",variant:"contained",disabled:s,children:u("common.save","Save")})]})]})]})}},sourceType:{api:e=>Wt(D.postV1SourceTypes,e),component:Lt},journalType:{api:e=>Wt(D.postV1JournalTypes,e),component:Gt},journal_type:{api:e=>Wt(D.postV1JournalTypes,e),component:Gt}},Kt=e=>{const l=Ut[e];return l?{...l}:(console.warn(`No configuration found for addType: ${e}`),null)},Ht=({options:l,multiple:t,placeholder:o,with_checkboxes:r,values:n,field:s,disabledIds:d,handleClear:c,handleChange:u,hasParent:m=!1})=>{const p=e=>null==d?void 0:d.includes(e),h=[];t||h.push(e.jsx(a.MenuItem,{disabled:!0,value:"",sx:{opacity:"0 !important",height:"0 !important",p:"0 !important",m:"0 !important"},children:e.jsx(i.Typography,{type:"s3",color:"theme.secondary.1000",children:e.jsx("em",{children:o})})},"placeholder"));const y=Array.isArray(n)?null==n?void 0:n.filter(e=>e):[],g=(e,l)=>{const t=l.map(e=>e.value),o=Array.isArray(y)?y:[y];return t.every(e=>o.includes(e))},x=e=>{const l=e.map(e=>e.value),t=Array.isArray(y)?y:[y];return l.some(e=>t.includes(e))};return Array.isArray(l)&&(null==l?void 0:l.length)>0&&(null==l||l.forEach((l,o)=>{h.push(e.jsx(a.MenuItem,{value:null==l?void 0:l.value,disabled:Boolean(null==l?void 0:l.disabled)||p(null==l?void 0:l.value)||m&&!t,className:(null==l?void 0:l.isGroup)?"select--MenuItemHeader":"",onClick:()=>{1==(null==n?void 0:n.length)&&c()},children:e.jsxs(a.Box,{sx:{display:"flex",gap:1},children:[t&&r&&e.jsx(ze,{checked:m?g(l.value,l.options||[]):Boolean(Array.isArray(n)&&(null==n?void 0:n.indexOf(null==l?void 0:l.value))>-1),indeterminate:m&&x(l.options||[]),onChange:()=>m?((e,l)=>{const t=l.map(e=>e.value),o=Array.isArray(y)?y:[y],a=o.includes(e)?o.filter(l=>l!==e&&!t.includes(l)):[...new Set([...o,e,...t])];null==u||u(a)})(l.value,l.options||[]):null==u?void 0:u(l.value)}),e.jsx(i.Typography,{type:"s3",color:"theme.secondary.1000",onClick:()=>null==u?void 0:u(l.value),children:null==l?void 0:l.label})]})},`${null==l?void 0:l.value}-${o}`)),(null==l?void 0:l.isGroup)&&Array.isArray(null==l?void 0:l.options)&&l.options.forEach((o,s)=>{h.push(e.jsx(a.MenuItem,{id:`${l.value}-${o.value} ${s}`,value:o.value,disabled:Boolean(o.disabled)||p(o.value),sx:{pl:5},onClick:()=>{1==(null==n?void 0:n.length)&&c()},children:e.jsxs(a.Box,{sx:{display:"flex",gap:1},children:[t&&r&&e.jsx(ze,{checked:Boolean(Array.isArray(n)&&(null==n?void 0:n.indexOf(o.value))>-1)}),e.jsx(i.Typography,{id:`${l.value}-${o.value} ${s}`,type:"s3",color:"theme.secondary.1000",onClick:()=>null==u?void 0:u(String(o.value)),children:"Payment Entries"==o.label?"Payment and Collection Entries":o.label||o.value})]})},`${l.value}-${o.value} ${s}`))})})),(s.enable_footer||s.addType)&&h.push(e.jsxs(a.Box,{sx:{position:"sticky",bottom:0,background:"#fff",zIndex:1},children:[e.jsx(a.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),e.jsxs(a.MenuItem,{sx:{gap:1},onClick:()=>{s.onFooterClick?s.onFooterClick():s.handleModalOpen&&s.handleModalOpen()},children:[e.jsx(w.Add,{fontSize:"small"}),e.jsxs(i.Typography,{type:"s4",color:"theme.secondary.1000",children:["Create New ",s.label]})]})]},"footer")),h.length&&(1!=h.length||t)||h.push(e.jsx(a.MenuItem,{disabled:!0,children:"No data available"},"no-data")),h},Yt=l=>{const{labelId:o,label:r,value:n,onChange:i,options:d,multiple:c=!1,size:u="small",searchPlaceholder:m,placeholder:p,name:h,defaultValue:g,apiType:x,isInternal:v=!1,autoFocus:j,error:_,disabled:C,customeFilter:T,attributes:w,getSelectedData:S,disabledIds:A,onChipRemove:P,selectedLabel:k,is_loading:N,customStyle:D={},CustomDropDownIcon:B,labelKey:q,valueKey:F,inputStyle:E,hasParent:R=!1,sortOrder:z="id:-1",handleChange:$,enable_footer:V=!1,onFooterClick:L,showCancelButton:O=!0,customFetchApi:G,addType:W,isMergeOptions:U=!1}=l,[K,H]=s.useState(""),[Y,J]=s.useState(!1),[Q,Z]=s.useState([]),[X,ee]=s.useState([]),[le,te]=s.useState(!1),[oe,ae]=s.useState(!1),[re,ne]=s.useState(!1),[ie,se]=s.useState(!1),[de,ce]=s.useState(null),[ue,me]=s.useState(null),[pe,he]=s.useState(!1),[ye,ge]=s.useState(!1),{t:xe}=y.useTranslation(),[ve,fe]=s.useState({page:1,hasMore:!0,isLoadingMore:!1,total:0}),{isRtl:be}=M.useLanguage(),je=25,_e=s.useMemo(()=>(!U||!x&&!G)&&(v||!x&&!G),[v,x,G,U]),Ce=s.useCallback((e,l)=>{const t=d&&d.length>0?d:[];if(!e)return t;const o=e.toLowerCase(),a=R?(null==d?void 0:d.reduce((e,l)=>{var t;const a=null==(t=l.options)?void 0:t.filter(e=>{const l=s.isValidElement(e.label)?e.searchLabel:String(e.label);return null==l?void 0:l.toLowerCase().includes(o)});return(null==a?void 0:a.length)&&e.push({...l,options:a}),e},[]))||[]:(null==d?void 0:d.filter(e=>{const l=s.isValidElement(e.label)?e.searchLabel:String(e.label);return null==l?void 0:l.toLowerCase().includes(o)}))||[];return Se(a,l)},[d,R]),Te=()=>{null==i||i({target:{value:c?[]:null}}),S&&"function"==typeof S&&S(null)},we=s.useCallback(e=>[...new Map(null==e?void 0:e.map(e=>[e.value,e])).values()],[]),Se=s.useCallback((e,l)=>{const t=Array.isArray(l)?l:[l];return b.sortBy(e,e=>{const l=t.indexOf(e.id||e.value);return-1===l?1/0:l})},[]),Ae=s.useMemo(()=>{if(_e)return Ce(K,n);const e=Se(we([...Q,...X]),n);if(U){const l=Ce(K,n);return we([...l,...e])}return e},[K,Q,d,n,_e,X,Ce,Se,we,U]),Pe=s.useCallback(e=>{const{scrollTop:l,scrollHeight:t,clientHeight:o}=e.currentTarget;if(t-l<=o+10&&ve.hasMore&&!ve.isLoadingMore&&!_e){const e=ve.page+1;Ne(K,T,e,!0)}},[ve.hasMore,ve.isLoadingMore,ve.page,_e,K,JSON.stringify(T)]),ke=s.useCallback((e,l=!1)=>{Z(t=>we([...l?t:X,...e]))},[X,we]),Ne=s.useCallback(async(e="",l=T,t=1,o=!1)=>{if(!x&&!G)return[];J(!0),t>1&&fe(e=>({...e,isLoadingMore:!0}));try{let a=[],r={};if(G){const o=await G({search:e,filters:l,limit:je,skip:(t-1)*je,select:w,order:z});a=(null==o?void 0:o.data)||[],r=(null==o?void 0:o.pagination)||{}}else{const o=await f.fetchApi({apiKey:x,filters:{limit:je,skip:(t-1)*je,search:e,filters:l,select:w,order:z},labelKey:q,valueKey:F});a=(null==o?void 0:o.data)||[],r=(null==o?void 0:o.pagination)||{}}return a&&Array.isArray(a)&&(ke(a,o),fe(e=>({...e,page:t,hasMore:((null==r?void 0:r.totalCount)||0)>t*je,total:(null==r?void 0:r.totalCount)||0,isLoadingMore:!1})),(null==a?void 0:a.length)>0&&De()),a||[]}catch(a){return console.error("Error fetching options:",a),fe(e=>({...e,isLoadingMore:!1})),[]}finally{J(!1)}},[x,G,w,z,je,ke,Q]),Me=s.useMemo(()=>b.debounce(async e=>{Y||(e||_e||!re||(fe({page:1,hasMore:!0,isLoadingMore:!1,total:0}),await Ne("",T,1,!1)),(null==e?void 0:e.length)>1&&!_e&&(fe({page:1,hasMore:!0,isLoadingMore:!1,total:0}),await Ne(e,T,1,!1)))},700),[_e,re,JSON.stringify(T)]),Ie=s.useCallback(async()=>{!(JSON.stringify(T)!==JSON.stringify(de))||_e||le||(ce(T),Z([]),te(!1),fe({page:1,hasMore:!0,isLoadingMore:!1,total:0})),_e||le||(await Ne(K,T,1,!1),te(!0))},[JSON.stringify(T),_e,le]),De=s.useCallback(()=>{let e=!1;const l=null==Ae?void 0:Ae.filter(e=>c?null==n?void 0:n.includes(null==e?void 0:e.value):(null==e?void 0:e.value)==n);return Array.isArray(l)&&(null==l?void 0:l.length)>0&&(null==S||S(c?l:l[0]),e=!0),e},[JSON.stringify(Ae),n,c]),Be=s.useCallback(async()=>{if(await De())return;if(ie)return;const e=c?n&&(null==n?void 0:n.filter(e=>Boolean(Number(e)))):n||null;(c?(null==e?void 0:e.length)>0:e)&&!_e&&(ae(!0),await Ne("",{...T,"&id.in":e},1,!1),ae(!1))},[ie,n,JSON.stringify(T)]),qe=c?Array.isArray(n)&&n.length>0:null!=n&&""!==n;s.useEffect(()=>(ie&&Me(K),()=>Me.cancel()),[K,JSON.stringify(T),ie,le,Me]),s.useEffect(()=>{De()},[De]),s.useEffect(()=>{Be()},[Be]),s.useEffect(()=>{ie&&Ie()},[ie,Ie]),s.useEffect(()=>{const e=JSON.stringify(T)!==JSON.stringify(de);T&&e&&te(!1)},[T,de]),s.useEffect(()=>{if(n&&!ie){const e=d&&d.length>0?d:[],l=(null==e?void 0:e.filter(e=>c?null==n?void 0:n.includes(null==e?void 0:e.value):(null==e?void 0:e.value)==n))||[];ee(l)}ee(null==Ae?void 0:Ae.filter(e=>c?null==n?void 0:n.includes(null==e?void 0:e.value):(null==e?void 0:e.value)==n))},[n,ie,d,c]);const Fe=s.useCallback(()=>{he(!0)},[]),Ee=s.useCallback(async e=>{if(ue&&ue.api){ge(!0);try{await ue.api(e),ge(!1),he(!1),_e||(fe({page:1,hasMore:!0,isLoadingMore:!1,total:0}),te(!1),await Ne("",T,1,!1))}catch(l){console.log("error",l),ge(!1)}}else console.error("Add configuration is not properly set")},[ue,_e,Ne,T,c,h,n]);s.useEffect(()=>{const e=Kt(W);me(e)},[W]);const Re=e=>{var l;if(!(null==e?void 0:e.length))return;const t=null==e?void 0:e.flatMap(e=>null==e?void 0:e.options);return null==(l=null==t?void 0:t.find(e=>(null==e?void 0:e.value)===n))?void 0:l.label};return e.jsxs(t.Select,{labelId:o,name:h,defaultValue:g||(c?[]:""),placeholder:xe(p),className:"filter-select",size:u,onOpen:()=>se(!0),onClose:()=>{se(!1),(null==K?void 0:K.length)>0&&te(!1),ne(!1),H("")},onChange:e=>{const{value:l}=e.target;if(c&&Array.isArray(l)&&0==(null==l?void 0:l.filter(e=>e).length)||!l)return;const t=null==Ae?void 0:Ae.filter(e=>c?null==l?void 0:l.includes(null==e?void 0:e.value):(null==e?void 0:e.value)===l);null==i||i(e,c?t:null==t?void 0:t[0]),null==S||S(c?t:null==t?void 0:t[0])},showCancelButton:O,multiple:c,label:xe(r),fullWidth:!0,displayEmpty:!0,autoFocus:j,error:Boolean(_),disabled:C,value:oe?c?[]:"":(null==n?void 0:n.id)||n||(c?[]:""),searchPlaceholder:m,CustomDropdownIcon:B,sx:c&&(null==n?void 0:n.length)?{...D,"& .MuiSelect-select":{padding:"5.5px !important"}}:D,MenuProps:{PaperProps:{onScroll:Pe,style:{maxHeight:295,maxWidth:250}}},input:C?void 0:e.jsx(a.OutlinedInput,{label:"",sx:E,endAdornment:e.jsx(a.InputAdornment,{position:"end",children:Y||N?e.jsx(a.CircularProgress,{size:20,sx:{mr:3,color:"#4AC08C"}}):O&&qe&&e.jsx(a.IconButton,{"aria-label":"clear selection",onClick:Te,edge:"end",sx:be?{ml:2.5}:{mr:1.5},size:"small",children:e.jsx(I.Close,{fontSize:"small",color:"theme.primary.800"})})})}),renderValue:l=>{var t,o;return e.jsx(e.Fragment,{children:Array.isArray(l)?e.jsx($e,{selectedLabel:k,data:(o=l,Array.isArray(o)&&(null==o?void 0:o.length)>0&&(null==o?void 0:o.filter(e=>e))),placeholder:p,onDelete:P,disabled:C,chipProps:{sx:{bgcolor:"theme.primary.100",border:0,"& .MuiTypography-body1":{color:"theme.primary.800",fontWeight:"500"}}}}):R?Re(Ae):Array.isArray(Ae)&&(null==Ae?void 0:Ae.length)>0&&(null==(t=null==Ae?void 0:Ae.find(e=>(null==e?void 0:e.value)==n))?void 0:t.label)||l||p})},handleSearch:e=>{H(e),ne(!0)},children:[Ht({options:Ae,multiple:Boolean(c),placeholder:p,values:n,with_checkboxes:!0,field:{...l,enable_footer:V,onFooterClick:L,label:r,handleModalOpen:Fe},disabledIds:A,handleClear:Te,handleChange:$,hasParent:R}),ve.isLoadingMore&&e.jsx(a.MenuItem,{disabled:!0,children:e.jsx(a.Box,{sx:{display:"flex",justifyContent:"center",width:"100%"},children:e.jsx(a.CircularProgress,{size:20})})}),ue&&ue.component&&e.jsx(e.Fragment,{children:s.createElement(ue.component,{isOpen:pe,setIsOpen:he,isLoading:ye,onSave:Ee,modalProps:{maxWidth:"md",fullWidth:!0},...null==l?void 0:l.modalComponentProps})})]})},Jt=l=>{let{values:o,value:r,handleOnChange:n,fieldData:i,rule:d,...c}=l;console.log("🚀 ~ ValueEditor ~ values:",o),r||"select"!=i.inputType?Array.isArray(r)||"select"!=i.inputType||(r=[]):r=null;const u=s.useMemo(()=>"null"===d.operator||"notNull"===d.operator,[d.operator]),m=s.useCallback(async e=>{const l=(null==e?void 0:e.search)||"",t=(null==e?void 0:e.limit)||25,a=(null==e?void 0:e.skip)||0;if(i.table){const e=await(async(e,l,t,o=0)=>{var a,r;try{const n=f.getToken(),i=await D.getV1FilterFilterTable({table:e,search:l,limit:t,offset:o,"x-token":n["x-token"],"x-timezone":String(n["x-timezone"])});if("data"in i&&i.data){const e=(null==(a=i.data)?void 0:a.result)??[],l=(null==(r=null==i?void 0:i.pagination)?void 0:r.totalCount)??e.length;return{items:e.map(e=>({label:e.name,value:e.id})),totalCount:l}}return{items:[],totalCount:0}}catch{return{items:[],totalCount:0}}})(i.table,l,t,a);return{data:e.items.map(e=>({id:e.value,value:e.value,label:e.label})),pagination:{totalCount:e.totalCount}}}{const e=null==o?void 0:o.map(e=>({...e,value:null==e?void 0:e.name,label:e.label?f.formatLabel(e.label):""}));return{data:e,pagination:{totalCount:e.length}}}},[i.table,o]);return e.jsx(a.Box,{width:"100%",children:(()=>{switch(i.inputType){case"select":return e.jsx(Yt,{label:"",name:"insurance_account",placeholder:"Select",onChange:(e,l)=>{console.log("🚀 ~ renderOptions ~ selected:",l);const t=null==l?void 0:l.map(e=>({...e,name:null==e?void 0:e.value}));n(t)},value:null==r?void 0:r.map(e=>null==e?void 0:e.value),multiple:!0,customFetchApi:m,disabled:u,onChipRemove:()=>n([])},i.name);case"date":return e.jsx(Ee,{onChange:e=>n(v(e).isValid()?v(e).format("YYYY-MM-DD"):""),value:r?v(r):null,disabled:u,slotProps:{textField:{placeholder:"YYYY-MM-DD",className:"select-drps"}},format:"YYYY-MM-DD"});default:return e.jsx(t.TextField,{value:r,onChange:e=>{n(e.target.value)},...c,inputProps:{style:{fontSize:"0.8125rem"}},className:"select-drps",type:i.inputType,disabled:u})}})()})},Qt=l=>{var o;const{handleOnChange:r,options:n,...s}=l;return e.jsx(a.Box,{width:"100%",children:e.jsx(t.Select,{fullWidth:!0,...s,onChange:e=>r(e.target.value),className:"select-drps",variant:"outlined",renderValue:e=>{var l;const t=null==(l=null==n?void 0:n.find(l=>l.name==e))?void 0:l.label;return t?f.formatText(t):e},children:null==(o=null==n?void 0:n.filter(e=>{var l;return Boolean(null==(l=e.label)?void 0:l.trim())}))?void 0:o.map(l=>e.jsx(a.MenuItem,{value:l.name,children:e.jsx(i.Typography,{type:"s4",color:"theme.secondary.1000",children:f.formatText(l.label)})},l.name))})})},Zt=l=>{const{handleOnClick:o}=l;return e.jsx(t.Button,{className:"filterGrp-remove-btn",variant:"outlined",onClick:o,sx:({palette:e})=>{var l;return{marginRight:"0px",marginLeft:"auto",color:`${null==(l=e.theme.error)?void 0:l[600]} !important`}},startIcon:e.jsx(I.Trash,{color:"theme.error.600",fontSize:"small"}),children:"Delete Group"})},Xt=({open:l,onClose:r,handleSubmit:n,oldName:d})=>{const[c,u]=s.useState("");return s.useEffect(()=>{void 0!==d&&u(d)},[d]),e.jsx(e.Fragment,{children:e.jsxs(t.Modal,{fullWidth:!0,onClose:r,open:l,children:[e.jsxs(a.DialogTitle,{children:[e.jsxs(a.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(I.FolderSave,{sx:{fontSize:"1.25rem"}}),e.jsx(i.Typography,{type:"s2",weight:"medium",color:"theme.secondary.1000",children:"Save active filters"})]}),e.jsx(a.IconButton,{edge:"end",onClick:r,size:"small",children:e.jsx(o,{fontSize:"inherit"})})]}),e.jsx(a.DialogContent,{dividers:!0,children:e.jsx(t.TextField,{label:"Name",fullWidth:!0,placeholder:"Name Filter",value:c,onChange:e=>u(e.target.value)})}),e.jsxs(a.DialogActions,{children:[e.jsx(t.Button,{variant:"outlined",onClick:r,style:{color:"black"},children:"Cancel"}),e.jsx(t.Button,{onClick:()=>(async e=>{e&&await n(e)&&(u(""),r())})(c),children:d?"Rename":"Save"})]})]})})},eo={combinator:"and",rules:[]},lo=({open:l,onClose:o,savedFilters:r,fetchSavedFilters:n,onSaveFilter:d,onSelectedFilter:c,applyFilter:u,fields:m=[],isUseFields:p=!1})=>{const h=E.useLocation(),y=localStorage.getItem(B.auth.storageTokenKeyName),{updatePageInfo:g,activePage:x,schemaFields:v,setActivePage:j}=A.usePages();m=p?f.generateFields(m):v.length?f.generateFields(v):m;const[_,C]=s.useState(eo),[T,S]=s.useState(r??[]),[P,R]=s.useState(null),[z,$]=s.useState(null),[V,L]=s.useState(null),{isRtl:O}=M.useLanguage(),G=s.useMemo(()=>F.routeToResourceMap[h.pathname]||null,[h.pathname]);s.useEffect(()=>{r&&S(r)},[r]);const W=s.useCallback((e=!1)=>{let l=_;if(H(l))L("Invalid filter");else if(e)l=eo,C(l);else{const e=l?f.generateQueryString(l):l;g({filters:l,filterQueryString:e}),o()}},[_,u,o]),U=e=>{e?(R(e),C(e.query),c&&c(e)):(R(null),C(eo),c&&c(null))},K=e=>{const l=null==r?void 0:r.filter(l=>l.name.toLowerCase().includes(e.toLowerCase()));l&&S(l)};s.useEffect(()=>{let e=eo;b.isEmpty(x.filters)||(e=x.filters),C(e);const l=null==r?void 0:r.find(e=>{var l;return e.name===(null==(l=null==x?void 0:x.filters)?void 0:l.name)});R(l||null)},[null==x?void 0:x.filters,r]);const H=e=>{var l,t;let o=[];return null==(l=null==e?void 0:e.rules)||l.forEach(l=>{if(o.includes(l.field)&&"and"==e.combinator)return!0;o.push(l.field)}),o.length!==(null==(t=null==e?void 0:e.rules)?void 0:t.length)},Y=e=>Array.isArray(e.rules)?e.rules.length?e.rules.some(Y):!e.rules.length:!e.field||b.isEmpty(e.value)&&!["null","notNull"].includes(e.operator),J=s.useMemo(()=>Y(_)||V,[_,V]);return e.jsx("div",{children:e.jsxs(a.Dialog,{open:l,onClose:o,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:2}},children:[e.jsxs(a.DialogTitle,{className:"filter-header",children:[e.jsx(i.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:"Filters"}),e.jsxs(a.Box,{gap:1,display:"flex",children:[e.jsxs(t.Select,{fullWidth:!0,size:"small",className:"filter-dropdown",value:P?P.name:"Saved Filters",onChange:e=>{const l=null==r?void 0:r.find(l=>l.name==e.target.value);U(l)},variant:"outlined",onClose:()=>{setTimeout(()=>{K("")},500)},input:P?e.jsx(a.OutlinedInput,{label:"",endAdornment:e.jsx(a.InputAdornment,{position:"end",children:e.jsx(a.IconButton,{"aria-label":"clear selection",onClick:()=>{U()},edge:"end",sx:{mr:1.5},size:"small",children:e.jsx(w.Close,{sx:{fontSize:"1rem"}})})})}):void 0,children:[e.jsx("div",{className:"searchbar-box-list",children:e.jsx(t.SearchBar,{placeholder:"Search Filters",handleSearch:e=>K(e)})}),null==T?void 0:T.map(l=>e.jsxs(a.MenuItem,{value:null==l?void 0:l.name,className:"menu-list",selected:(null==P?void 0:P.name)==(null==l?void 0:l.name),children:[e.jsx(i.Typography,{color:"theme.secondary.1000",type:"s3",children:null==l?void 0:l.name}),e.jsxs("div",{className:"icon-list",children:[e.jsx(a.IconButton,{size:"small",onClick:e=>{e.preventDefault(),e.stopPropagation(),$(l)},children:e.jsx(I.Edit,{fontSize:"small",color:(null==P?void 0:P.name)==(null==l?void 0:l.name)?"theme.primary.800":"inherit"})}),e.jsx(a.IconButton,{size:"small",onClick:e=>{e.preventDefault(),e.stopPropagation(),(async e=>{const l={"x-token":y,id:e};D.deleteV1FilterId(l).then(e=>{R(null),C(eo),n&&n()}).catch(e=>console.log("Error deleting saved filters:",e))})(l.id)},color:"error",children:e.jsx(I.Trash,{fontSize:"small",color:"theme.error.600"})})]})]},l.id))]}),e.jsx(Xt,{open:null!==z,onClose:()=>$(null),handleSubmit:e=>(e=>{if(z)return(async(e,l)=>{const t={"x-token":y,id:e,name:l,module:(null==G?void 0:G.fieldResource)||(null==G?void 0:G.pageResource)};try{await D.putV1FilterId(t),n&&n(),q.enqueueSnackbar("Filters renamed successfully.")}catch(o){let e="Something went wrong on saving filters";return o instanceof Error&&(e=f.getErrorMessage(o.message)),q.enqueueSnackbar(e,{variant:"error"}),!1}return!0})(z.id,e)})(e),oldName:null==z?void 0:z.name}),e.jsx(a.Box,{children:e.jsx(a.IconButton,{size:"small",onClick:o,children:e.jsx(w.Close,{fontSize:"small"})})})]})]}),e.jsxs(a.DialogContent,{className:"content",children:[V&&e.jsx(a.Alert,{severity:"error",sx:{px:1,pt:.5,mb:1},children:e.jsx(i.Typography,{color:"error",type:"s4",children:V})}),e.jsxs(N.QueryBuilderMaterial,{children:[e.jsx(k.QueryBuilder,{fields:m||[],query:_,onQueryChange:e=>{const l=e.rules.map((e,l)=>{var t,o;return{...e,value:e.field!==(null==(o=null==(t=_.rules)?void 0:t[l])?void 0:o.field)||["null","notNull"].includes(e.operator)?"":e.value}});C({...e,rules:l}),L(null),d&&d(e)},showCombinatorsBetweenRules:!0,controlClassnames:{header:"actions"},controlElements:{addRuleAction:De,addGroupAction:qe,combinatorSelector:ke,fieldSelector:Me,operatorSelector:Qt,removeRuleAction:Ne,valueEditor:Jt,removeGroupAction:Zt}}),e.jsx(t.Button,{variant:"text",className:O?"remove-filters_rtl":"remove-filters",onClick:()=>{W(!0)},disabled:J,children:"Clear all filters"})]})]}),e.jsx(a.DialogActions,{className:"filter-footer",children:e.jsxs(a.Box,{sx:{display:"flex",alignItems:"center",justifyContent:P?"space-between":"flex-end",width:"100%"},children:[P&&e.jsx(a.Box,{children:e.jsx(t.Button,{onClick:async()=>{if(P){const e={"x-token":y,id:P.id,data:_};D.putV1FilterId(e).then(e=>{n&&n(),j(e=>({...e,filters:{...e.filters,rules:_.rules,combinator:_.combinator,name:P.name}}))}).catch(e=>q.enqueueSnackbar("Error renaming saved filters:",{variant:"error"}))}},children:"Update Seleted filter"})}),e.jsxs(a.Box,{sx:{display:"flex",gap:1},children:[e.jsx(t.Button,{className:"cancel-filter-btn",onClick:o,children:"Cancel"}),e.jsx(t.Button,{disabled:J,onClick:()=>W(),children:"Apply"})]})]})})]})})},to=({children:l,options:o,isMenuThirdItemDisabled:r,isOnlyDropDownButton:n=!1,onlyDropDownButtonProps:s=null,buttonGroupProps:d=null,dropdownButtonProps:c=null,toggleCallback:u,loading:m=!1,...p})=>{const[h,y]=je.useState(!1),g=je.useRef(null),{isRtl:x}=M.useLanguage(),v=()=>{y(e=>!e)},f=e=>{g.current&&g.current.contains(e.target)||y(!1)};return je.useEffect(()=>{null==u||u(h)},[h]),e.jsxs(je.Fragment,{children:[e.jsx(R,{sx:m?{boxShadow:"none"}:x?{flexDirection:"row-reverse"}:{},...d,ref:g,disabled:m,children:n?e.jsx(t.Button,{...p,sx:{borderRightColor:"#ffffff20 !important",...null==s?void 0:s.style},onClick:v,children:l}):e.jsxs(e.Fragment,{children:[e.jsx(t.Button,{...p,sx:e=>{var l;return{borderRightColor:`${null==(l=e.palette.theme)?void 0:l.secondary[100]} !important`,borderRight:"1px solid",borderTopRightRadius:0,borderBottomRightRadius:0,..."function"==typeof(null==p?void 0:p.sx)?p.sx(e):(null==p?void 0:p.sx)||{}}},children:l}),e.jsx(t.Button,{size:"small","aria-controls":h?"split-button-menu":void 0,"aria-expanded":h?"true":void 0,"aria-label":"select merge strategy","aria-haspopup":"menu",...c,sx:e=>({p:1,minWidth:"unset !important",borderTopLeftRadius:0,borderBottomLeftRadius:0,..."function"==typeof(null==c?void 0:c.sx)?c.sx(e):(null==c?void 0:c.sx)||{}}),onClick:v,children:m?e.jsx(a.CircularProgress,{size:15,color:"inherit"}):e.jsx(I.ArrowDownTwo,{fontSize:"small"})})]})}),e.jsx(L,{sx:{zIndex:1},open:h,anchorEl:g.current,role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:l,placement:t})=>e.jsx($,{...l,style:{transformOrigin:"bottom"===t?"center top":"center bottom"},children:e.jsx(V,{elevation:0,sx:{border:"1px solid",borderColor:"grey.300",borderRadius:"8px",mt:.25},children:e.jsx(z,{onClickAway:f,children:e.jsx(G,{id:"split-button-menu",autoFocusItem:!0,children:o.map((l,t)=>e.jsx(O,{disabled:!r&&2===t,onClick:e=>{l.callback(e,t),(null==l?void 0:l.disableToggle)||v()},children:e.jsx(i.Typography,{type:"s4",color:l.color?l.color:"theme.secondary.1000",sx:{width:"100%"},children:l.label})},t))})})})})})]})},oo=({children:l,options:t,isMenuThirdItemDisabled:o,currentTitle:a=""})=>{const[r,n]=je.useState(!1),s=je.useRef(null),d=()=>{n(e=>!e)},c=e=>{s.current&&s.current.contains(e.target)||n(!1)};return e.jsxs(je.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-end",gap:"10px"},ref:s,children:[e.jsx(i.Typography,{type:"h3",weight:"medium",color:"theme.secondary.1000",children:l}),e.jsx("div",{"aria-controls":r?"split-button-menu":void 0,"aria-expanded":r?"true":void 0,"aria-label":"select merge strategy","aria-haspopup":"menu",style:{minWidth:"unset !important",cursor:"pointer"},onClick:d,children:e.jsx(I.ArrowDownTwo,{fontSize:"small"})})]}),e.jsx(L,{sx:{zIndex:1},open:r,anchorEl:s.current,role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:l,placement:r})=>e.jsx($,{...l,style:{transformOrigin:"bottom"===r?"center top":"center bottom"},children:e.jsx(V,{elevation:0,sx:{border:"1px solid",borderRadius:2,borderColor:"theme.grey.200"},children:e.jsx(z,{onClickAway:c,children:e.jsx(G,{autoFocusItem:!0,children:t.map((l,t)=>{var r;return e.jsx(O,{disabled:!o&&2===t,selected:(null==a?void 0:a.trim())===(null==(r=l.label)?void 0:r.trim()),onClick:e=>{l.callback(e,t),d()},children:e.jsx(i.Typography,{type:"s4",color:l.color?l.color:"theme.secondary.1000",children:l.label})},t)})})})})})})]})},ao=(e,l=2)=>{if(0===e)return"0 Bytes";const t=l<0?0:l,o=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,o)).toFixed(t))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][o]},ro=l=>{var o,r,d,c,u,m;const{open:p,title:h,onClose:y,onConfirm:g,onSubmit:x,accept:v="*",multiple:b=!1,importModuleName:j,handleSuccessImport:_}=l,[C,T]=s.useState([]),[S,A]=s.useState(!1),[P,k]=s.useState(!1),[N,M]=s.useState(!1),[D,B]=s.useState(null),[q,F]=s.useState(!1),{getRootProps:E,getInputProps:R,isDragActive:z}=K.useDropzone({onDropAccepted:e=>{T([...C,...e.map(e=>({file:e,isPrivate:!1,checkboxDisabled:!1,status:"pending",uploadProgress:0,fileSize:e.size,fileName:e.name,fileType:e.type,location:"",message:""}))]),M(!1)},onDragEnter:()=>{M(!0)},onDragLeave:()=>{M(!1)},noClick:!0,noKeyboard:!0,multiple:b,accept:v?(L=v,L.split(",").map(e=>e.trim()).reduce((e,l)=>(e[l]=[],e),{})):v}),$=()=>{y(),B(null)},V=s.useRef(null);var L;s.useEffect(()=>{const e=e=>{const l="Are you sure you want to leave? Your uploads are not complete.";return e.returnValue=l,l};return V.current&&(V.current.multiple=b),window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}},[b]);const O=l=>{switch(null==l?void 0:l.type.split("/")[0]){case"image":return e.jsx("div",{className:P?"document-icon-sm":"document-icon-lg",style:{backgroundColor:"#FFEBEB"},children:e.jsx(t.Avatar,{size:20,src:n.images.upload.documentPDF})});case"application":return e.jsxs("div",{className:P?"document-icon-sm":"document-icon-lg",style:{backgroundColor:"#FFEBEB"},children:[e.jsx(t.Avatar,{size:150,src:n.images.upload.documentPDF,alt:"PDF"}),e.jsx(i.Typography,{color:"theme.secondary.1000",weight:"bold",type:"s2",children:l.name}),e.jsx(i.Typography,{color:"theme.secondary.800",type:"s5",children:ao(l.size)})]});default:return e.jsx("div",{className:P?"document-icon-sm":"document-icon-lg",style:{backgroundColor:"#EBF9F2"},children:e.jsx(t.Avatar,{size:20,src:n.images.upload.docFile})})}},G=e=>{T(l=>l.filter((l,t)=>t!==e))};return s.useEffect(()=>{p&&T([])},[p]),e.jsxs(e.Fragment,{children:[e.jsxs(a.Dialog,{open:p,onClose:$,className:"upload",children:[e.jsx(a.DialogTitle,{className:"upload--head",children:e.jsx(U,{className:"upload--title",children:e.jsx(i.Typography,{type:"s3",ml:1,weight:"medium",color:"theme.secondary.1000",children:h})})}),e.jsx(a.Divider,{}),e.jsxs(a.DialogContent,{className:"upload--content",children:[q&&e.jsx(Dl,{}),0===C.length?e.jsx("div",{className:"upload--fileContent "+(z?"drag-active":""),children:e.jsx("div",{...E(),className:"drop-view",children:N?e.jsxs("div",{className:"after-drop",children:[e.jsx("img",{src:n.images.upload.documentUpload}),e.jsx(i.Typography,{type:"s3",children:"Drag & Drop your files here"})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{...R(),ref:V}),e.jsx("p",{className:"upload--text",children:"Drag and Drop files here or upload from"}),e.jsx("div",{className:"device-wrap",children:e.jsxs("div",{className:"select-button",onClick:()=>{V.current&&(l.multiple?V.current.setAttribute("multiple","true"):V.current.removeAttribute("multiple"),V.current.click())},children:[e.jsx("img",{src:n.images.upload.monitor}),e.jsx(i.Typography,{type:"s5",children:"My Device"}),e.jsx("input",{type:"file",...R({multiple:!0}),ref:V,style:{display:"none"},onChange:e=>{var l;const t=(null==(l=e.target.files)?void 0:l[0])||null,o={file:t,isPrivate:!1,checkboxDisabled:!1,status:"pending",uploadProgress:0,fileSize:t.size,fileName:t.name,fileType:t.type,location:"",message:""};T([...C,o])},accept:v})]})}),(null==(o=null==D?void 0:D.successful)?void 0:o.length)||(null==(r=null==D?void 0:D.failed)?void 0:r.length)?e.jsx("div",{className:"mt-2",children:0==(null==D?void 0:D.failed.length)?e.jsx(i.Typography,{type:"s3",children:"All data imported successfully."}):e.jsxs(i.Typography,{type:"s4","word-break":"break-word",color:"theme.error.600",weight:"medium",children:["Failed to import the following records with IDs: ",null==(d=D.failed)?void 0:d.map(e=>null==e?void 0:e.id).join(", ")]})}):""]})})}):e.jsx(a.Grow,{in:Boolean(null==C?void 0:C.length),timeout:500,children:e.jsxs(U,{children:[C.map((l,o)=>{var r,s,d;return e.jsxs(U,{display:"flex",width:"100%",justifyContent:"center",alignItems:"center",flexDirection:"column",children:[e.jsxs(U,{className:"icon-BG",children:[e.jsxs(a.IconButton,{onClick:()=>G(o),className:"remove-button",children:[e.jsx(I.Trash,{fontSize:"small"})," "]}),e.jsx(t.Avatar,{size:150,src:n.images.upload.docFile,alt:"PDF"})]}),e.jsx(i.Typography,{type:"s2",weight:"bold",color:"theme.secondary.1000",children:null==(r=null==l?void 0:l.file)?void 0:r.name}),e.jsx(i.Typography,{type:"s4",color:"theme.secondary.800",children:ao(null==(s=null==l?void 0:l.file)?void 0:s.size)})]},null==(d=null==l?void 0:l.file)?void 0:d.name)}),(null==(c=null==D?void 0:D.successful)?void 0:c.length)||(null==(u=null==D?void 0:D.failed)?void 0:u.length)?e.jsx("div",{className:"mt-2",children:0==(null==D?void 0:D.failed.length)?e.jsx(i.Typography,{type:"s3",children:"All data imported successfully."}):e.jsxs(i.Typography,{type:"s4","word-break":"break-word",color:"theme.error.600",weight:"medium",children:["Failed to import the following records with IDs: ",null==(m=null==D?void 0:D.failed)?void 0:m.map(e=>e.id).join(", ")]})}):""]})})]}),e.jsx(a.DialogActions,{className:"uploadActions",children:e.jsx(t.Button,{onClick:x?()=>{x(C)}:async()=>{var e,l;const t=C[0].file,o=new FormData;o.append("file",t),F(!0);try{const t=await f.postImportSheet(o,j);t&&(B(t.data),F(!1),0==(null==(l=null==(e=null==t?void 0:t.data)?void 0:e.failed)?void 0:l.length)&&($(),_(null==t?void 0:t.data)))}catch(a){F(!1)}},startIcon:e.jsx(w.Upload,{}),children:"Upload"})})]}),P&&e.jsxs("div",{className:"bottom-corner-box",children:[e.jsxs("div",{className:"top-section",children:[e.jsxs("div",{className:"top-text",children:["Uploading ",C.length," Item",1!==C.length?"s":""]}),e.jsxs("div",{className:"top-options",children:[e.jsx("div",{className:"btn",onClick:()=>{k(!P),P?g():y()},children:e.jsx(H,{})}),e.jsx("div",{className:"btn",onClick:()=>{A(e=>!e)},children:e.jsx("div",{className:"arrow-btn",children:S?e.jsx(w.KeyboardArrowUp,{}):e.jsx(w.KeyboardArrowDown,{})})})]})]}),e.jsx("div",{className:"box-list",children:!S&&C.map((l,o)=>{var r;return e.jsxs("div",{className:"bottom-section",children:[e.jsx("div",{className:"doc-icon",children:O(null==l?void 0:l.file)}),e.jsxs("div",{className:"file-detail",children:[e.jsx("div",{className:"file-name",children:e.jsxs("div",{className:"file-text",children:[null==(r=null==l?void 0:l.file)?void 0:r.name,o]})}),e.jsx("div",{className:"file-status",children:"canceled"!==(null==l?void 0:l.status)?e.jsxs(e.Fragment,{children:[0===l.uploadProgress&&e.jsxs("div",{className:"avatar-container",children:[e.jsx(t.Avatar,{size:20,className:"avatar",src:n.images.upload.empty}),e.jsx(t.Avatar,{size:20,onClick:()=>G(o),src:n.images.upload.close,className:"close-icon"})]}),(null==l?void 0:l.uploadProgress)>0&&(null==l?void 0:l.uploadProgress)<100&&e.jsx(a.CircularProgress,{color:"success",variant:"determinate",value:null==l?void 0:l.uploadProgress}),100===(null==l?void 0:l.uploadProgress)&&e.jsxs("div",{className:"avatar-container",children:[e.jsx(t.Avatar,{size:20,className:"avatar",src:n.images.upload.tick}),e.jsx(t.Avatar,{size:20,src:n.images.upload.folder,className:"close-icon"})]})]}):e.jsx(i.Typography,{type:"s4",className:"canceled-text",children:"Upload Canceled"})})]})]})})})]})]})},no=s.memo(l=>{var o;const r=localStorage.getItem(B.auth.storageTokenKeyName)||void 0,c=E.useLocation(),{title:u,data:m,setData:p,active:h,setActive:x,handleAddButton:v,handleSearch:b,button:j=!0,disabledViews:_,isDropdownMenuButton:C=!1,itemListingDropdownOptions:T=[],isTitleMenu:S=!1,titleMenus:P=[],type:k,fields:N=[],applyFilter:M,isToggleButton:R=!1,handleToggleButton:z,showSearch:$=!0,showFilter:V=!0,showView:L=!0,customButtons:O,pageName:G,actionBtn:U,importModuleName:K,selectedIds:H,searchText:Q,isUseFields:Z,handleSuccessImport:X}=l;W.useAppDispatch(),s.useState(!1);const[ee,le]=s.useState(!1),[te,oe]=s.useState(!1);s.useState("");const[ae,re]=s.useState(!1),[ne,ie]=s.useState(null),[se,de]=s.useState(!1),[ce,ue]=s.useState([]),[me,pe]=s.useState(""),{t:he}=y.useTranslation(),ye=a.useTheme(),ge=a.useMediaQuery(ye.breakpoints.up("xl")),{activePage:xe,updatePageInfo:ve,schemaFields:fe,setActivePage:be}=A.usePages(),{filters:je}=xe,_e=s.useMemo(()=>F.routeToResourceMap[c.pathname]||null,[c.pathname]);s.useEffect(()=>{Ce()},[]);const Ce=async()=>{(null==_e?void 0:_e.pageResource)||(null==_e?void 0:_e.fieldResource)?D.getV1FilterResource({...f.getToken(),resource:(null==_e?void 0:_e.pageResource)||(null==_e?void 0:_e.fieldResource)}).then(e=>{const l=e.data.result.map(e=>({id:e._id,name:e.name,query:e.data}));null==ue||ue(l)}).catch(e=>console.log("Error fetching saved filters:",e)):ue([])},Te=[];!G||K&&!H||Te.push({label:"Export Excel",handleAction:e=>(async(e,l,t,o)=>{const a=await f.getExcelExportTemplate({"x-token":r,activePage:xe,filterQueryString:l,selectedIds:t,title:o});if(a){const l=await a.blob(),t=document.createElement("a"),o=window.URL.createObjectURL(l);t.href=o,t.download=`${e}.xlsx`,document.body.appendChild(t),t.click(),document.body.removeChild(t),window.URL.revokeObjectURL(o)}})(e,xe.filterQueryString,H,u),icon:e.jsx(I.Export,{fontSize:"small"})}),!G||K&&!H||Te.push({label:"Export PDF",handleAction:e=>(async(e,l,t,o)=>{const a=xe.visible_columns.map(e=>({...e,header:he(e.header)})),n=await f.getPdfExportTemplate({"x-token":r,activePage:xe,filterQueryString:l,selectedIds:t,title:o,columns:a});if(n){const l=await n.blob(),t=document.createElement("a"),o=window.URL.createObjectURL(l);t.href=o,t.download=`${e}.pdf`,document.body.appendChild(t),t.click(),document.body.removeChild(t),window.URL.revokeObjectURL(o)}})(e,xe.filterQueryString,H,u),icon:e.jsx(I.Export,{fontSize:"small"})}),G&&K&&Te.push({label:"Download Template ",handleAction:e=>(async e=>{const l=await f.getExcelTemplateGenerateTemplate({"x-token":r,resource:e});if(l){const t=await l.blob(),o=document.createElement("a"),a=window.URL.createObjectURL(t);o.href=a,o.download=`${e}.xlsx`,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(a)}})(e),icon:e.jsx(I.DocumentDownload,{fontSize:"small"})},{label:"Import Template",handleAction:e=>{de(!0)},icon:e.jsx(I.Import,{fontSize:"small"})});const Ae=l=>{var t,o;l={...l,field:null==(t=l.field)?void 0:t.replace("__replaceKey","")};let r=(null==(o=fe.find(e=>e.key===l.field))?void 0:o.label)||l.field;r=f.formatLabel(null==r?void 0:r.replace("_id"," "));const n=f.getOperatorLabel(l,fe);let s=l.value;return Array.isArray(l.value)&&(l.value=l.value.map(e=>f.formatLabel("object"==typeof e?e.label:e)),s=l.value.join(", ")),e.jsxs(a.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(i.Typography,{type:"s5",color:"theme.secondary.800",weight:"medium",children:r}),e.jsx(a.Divider,{orientation:"vertical",flexItem:!0}),e.jsxs(i.Typography,{type:"s5",color:"theme.primary.800",weight:"medium",children:[f.formatText(n)," ",s]})]})},ke=(l,t)=>e.jsx(g.Chip,{label:Ae(l),variant:"outlined",active:!0,sx:({palette:e})=>({backgroundColor:"grey.200",borderColor:`${e.grey[300]} !important`,opacity:.8,"&:hover":{backgroundColor:`${e.grey[200]} !important`},flexDirection:"row-reverse",alignItems:"center",gap:.75,cursor:"unset"}),deleteIcon:e.jsx(w.Cancel,{sx:{fontSize:"1rem !important",color:"#919294 !important",marginRight:"auto !important",marginLeft:"0 !important","&:hover":{color:"inherit !important"}}}),onDelete:()=>Ne(t),clickable:!1}),Ne=e=>{const l=je.rules.filter((l,t)=>t!==e),t={...je,rules:l},o=f.generateQueryString(t);ve({filters:t,filterQueryString:o})},[Me,Ie]=s.useState(null);return s.useEffect(()=>{(null==xe?void 0:xe.search)&&pe(null==xe?void 0:xe.search)},[null==xe?void 0:xe.search]),s.useEffect(()=>{me&&(null==b||b(me),ve({search:me}))},[me]),e.jsxs("div",{children:[e.jsxs("div",{className:"action-bar",children:[e.jsxs("div",{className:"action-bar--LeftContent",children:[S?e.jsx("div",{style:{zIndex:999},children:e.jsx(oo,{onClick:v,options:P,isMenuThirdItemDisabled:!0,currentTitle:u,children:u})}):e.jsx(i.Typography,{type:"h3",weight:"medium",color:"theme.secondary.1000",children:u}),e.jsxs("div",{className:"action-bar--HeaderCard",children:[Boolean(m)&&m.map(e=>e).sort((e,l)=>e.position-l.position).map(l=>e.jsx(Se,{title:null==l?void 0:l.label,active:h,onClick:()=>{var e;x(null==(e=l)?void 0:e.label)}},null==l?void 0:l.position)),L&&e.jsx(we,{setData:p,data:m,setActive:x,disabledViews:_})]})]}),e.jsxs("div",{className:"action-bar--RightContent",style:{gap:ge?"1rem":"0.5rem"},children:[R&&e.jsxs("div",{className:"item--VariantDisplay",children:[e.jsx("div",{className:"item--VariantHeading",children:"Variant:"}),e.jsx("div",{className:"item--VariantToggal",children:e.jsx(Pe,{checked:ee,onChange:()=>{le(e=>!e),null==z||z()}})})]}),$&&e.jsx(e.Fragment,{children:ge?e.jsx(t.SearchBar,{placeholder:"Search",handleSearch:e=>{pe(e),null==b||b(e)},debounceTime:1e3,isDrivePage:!0,searchText:me}):e.jsxs(e.Fragment,{children:[e.jsxs(a.IconButton,{size:"small",onClick:e=>Ie(e.currentTarget),children:[e.jsx(J.Search,{fontSize:"small",color:"grey.1000"})," "]}),e.jsx(a.Menu,{anchorEl:Me,open:Boolean(Me),onClose:()=>Ie(null),anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},sx:{"& ul":{p:0},"& .MuiMenu-paper":{boxShadow:"0px 4px 6px rgba(0, 0, 0, 0.1), 0px 1px 3px rgba(0, 0, 0, 0.06);"}},children:e.jsx(t.SearchBar,{placeholder:"Search",handleSearch:e=>{pe(e),null==b||b(e)},debounceTime:1e3,isDrivePage:!0,searchText:Q||me})})]})}),V&&e.jsx(e.Fragment,{children:ge?e.jsx(t.Button,{variant:"text",startIcon:e.jsx(I.Filter,{fontSize:"small"}),onClick:()=>{oe(!0),Ce()},children:he("common.filter")}):e.jsx(a.IconButton,{onClick:()=>{oe(!0),Ce()},size:"small",children:e.jsx(I.Filter,{fontSize:"small",color:"grey.1000"})})}),O,U,j&&e.jsx(t.Button,{variant:"contained",startIcon:e.jsx(d,{}),onClick:v,children:he("common.add")}),C&&e.jsx("div",{style:{zIndex:999},children:e.jsx(to,{onClick:v,options:T,startIcon:e.jsx(d,{}),isMenuThirdItemDisabled:!0,children:he("common.add")})}),G?e.jsx(a.IconButton,{onClick:e=>{ie(e.currentTarget)},children:e.jsx("img",{src:n.images.more,alt:"More Icon"})}):"",e.jsx(a.Menu,{anchorEl:ne,open:Boolean(ne),onClose:()=>{ie(null)},children:null==Te?void 0:Te.map(l=>e.jsxs(a.MenuItem,{onClick:()=>{l.handleAction(G),ie(null)},sx:{alignItems:"center",gap:.5},disabled:"function"==typeof l.disabled?l.disabled():Boolean(l.disabled),children:[null==l?void 0:l.icon,e.jsx(i.Typography,{type:"s4",color:"inherit",children:l.label})]}))}),e.jsx(lo,{open:te,onClose:()=>{oe(!1)},activeView:h,savedFilters:ce,fetchSavedFilters:Ce,onSaveFilter:e=>{},type:k,isUseFields:Z,fields:N,onSelectedFilter:e=>setSelectedSavedFilter(e),applyFilter:M})]})]}),(De=je,Boolean(null==(Be=null==De?void 0:De.rules)?void 0:Be.length)&&e.jsxs(a.Box,{mb:1,sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(a.Box,{mb:1,sx:{display:"flex",alignItems:"center",gap:1,maxWidth:400},children:[e.jsxs(i.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[he("common.filters"),":"," "]}),null==(o=null==je?void 0:je.rules)?void 0:o.map((l,t)=>{var o,a;return e.jsx(e.Fragment,{children:(null==(o=null==l?void 0:l.rules)?void 0:o.length)?null==(a=null==l?void 0:l.rules)?void 0:a.map((l,t)=>e.jsx(e.Fragment,{children:ke(l,t)})):e.jsx(e.Fragment,{children:ke(l,t)})})})]}),e.jsxs(a.Box,{children:[e.jsx(t.Button,{variant:"text",className:"enable-filter-btn",startIcon:e.jsx(I.FolderSave,{fontSize:"small"}),onClick:()=>{(null==je?void 0:je.rules)&&re(!0)},children:e.jsxs("span",{children:[" ",he("common.saveFilter")]})}),e.jsx(t.Button,{variant:"text",startIcon:e.jsx(I.FilterRemove,{fontSize:"small"}),onClick:()=>ve({filters:Y.initialFilter,filterQueryString:""}),children:he("common.clearFilter")})]})]})),e.jsx(Xt,{open:ae,onClose:()=>re(!1),handleSubmit:e=>(async(e,l)=>{const t={"x-token":r,module:(null==_e?void 0:_e.pageResource)||(null==_e?void 0:_e.fieldResource)||"erp-common",name:e,is_applied:!0,data:l};try{await D.postV1Filter(t),q.enqueueSnackbar("Filters saved successfully."),be(t=>({...t,filters:{...t.filters,name:e,rules:l.rules},filterQueryString:f.generateQueryString(l)})),re(!1)}catch(o){let e="Something went wrong on saving filters";return o instanceof Error&&(e=f.getErrorMessage(o.message)),q.enqueueSnackbar(e,{variant:"error"}),!1}return!0})(e,je)}),e.jsx(ro,{open:se,showCameraButton:!1,onClose:()=>de(!1),onConfirm:()=>de(!0),title:"Upload",multiple:!1,importModuleName:K,pageName:K,handleSuccessImport:X,accept:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})]});var De,Be}),io=l=>{const{path:t}=l;return e.jsx(e.Fragment,{children:e.jsx(a.Breadcrumbs,{sx:{"& .MuiBreadcrumbs-separator":{color:"theme.secondary.600"}},children:null==t?void 0:t.map((l,o)=>e.jsx(a.Box,{children:o<(null==t?void 0:t.length)-1?e.jsx(i.Typography,{type:"s4",color:"theme.secondary.600",weight:"medium",component:(null==l?void 0:l.link)?E.Link:void 0,to:String(null==l?void 0:l.link)??void 0,state:null==l?void 0:l.linkState,onClick:null==l?void 0:l.onClick,style:{display:"block"},children:null==l?void 0:l.label}):e.jsx(i.Typography,{type:"s4",weight:"medium",color:"theme.secondary.1000",children:null==l?void 0:l.label})},o))})})},so=({paginationModel:l,totalPages:o,handlePaginationModel:r})=>{const{pageNo:n,limit:d}=l,c=d*(n-1),u=[10,20,50],{isRtl:m}=M.useLanguage(),{setIsChanged:p,setActivePage:h,activePage:y}=A.usePages();return s.useEffect(()=>{h({...y,skip:c,pageNo:n})},[n]),e.jsxs(a.Box,{className:"pagination",borderTop:"2px solid theme.secondary.200",children:[e.jsx(i.Typography,{color:"theme.secondary.800",type:"s4",children:"Items per page :"}),e.jsx(t.Select,{value:d,size:"small",className:"page-size-select page-size-select-pagination",onChange:e=>{var t;const o={...l,page:1,pageNo:1,limit:null==(t=null==e?void 0:e.target)?void 0:t.value};r(o)},variant:"outlined",MenuProps:{sx:{maxWidth:"unset"}},children:null==u?void 0:u.map(l=>e.jsx(a.MenuItem,{value:l,children:l},l))}),e.jsx(i.Typography,{color:"theme.secondary.800",type:"s4",children:"Go To :"}),e.jsx(a.TextField,{type:"number",className:"goto-box",id:"outlined-required",defaultValue:"",onKeyDown:e=>{if("Enter"===e.key){const t=e.target.value;if(parseInt(t)>0&&parseInt(t)<=o){const e={...l,pageNo:parseInt(t)};r(e),p(!0)}}}}),e.jsx(a.IconButton,{onClick:()=>{if(n>1){const e={...l,pageNo:parseInt(n)-1};r(e),p(!0)}},size:"small",disabled:1===l.pageNo,children:m?e.jsx(X,{}):e.jsx(Z,{})}),e.jsxs(i.Typography,{sx:{...m?{ml:.5}:{mr:.5}},type:"s4",weight:"normal",color:"theme.secondary.700",children:["Page"," "]}),e.jsxs(i.Typography,{type:"s4",weight:"medium",color:"theme.secondary.1000",children:[n," "]}),e.jsxs(i.Typography,{mx:.5,type:"s4",weight:"normal",color:"theme.secondary.700",children:["of"," "]}),e.jsx(i.Typography,{type:"s4",weight:"medium",color:"theme.secondary.1000",children:o||1}),e.jsx(a.IconButton,{onClick:()=>{if(n<o){const e={...l,pageNo:parseInt(n)+1};r(e),p(!0)}},size:"small",disabled:l.pageNo===o,children:m?e.jsx(Z,{}):e.jsx(X,{})})]})},co=({open:l,onClose:r,page:n,handleSubmit:d,pages:c})=>{const[u,m]=s.useState(),[p,h]=s.useState(""),y=s.useMemo(()=>null==c?void 0:c.map(e=>(null==e?void 0:e.name)||""),[c]);return s.useEffect(()=>{m(null==n?void 0:n.name)},[n]),s.useEffect(()=>{h("")},[]),e.jsx(e.Fragment,{children:e.jsxs(t.Modal,{fullWidth:!0,onClose:r,open:l,children:[e.jsxs(a.DialogTitle,{children:[e.jsxs(i.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[n?"Edit":"Add"," New View"]}),e.jsx(a.IconButton,{edge:"end",onClick:r,size:"small",children:e.jsx(o,{fontSize:"inherit"})})]}),e.jsx(a.DialogContent,{dividers:!0,children:e.jsx(t.TextField,{label:"View Name",fullWidth:!0,placeholder:"Enter view name",error:p,helperText:p,value:u,onChange:e=>{const l=e.target.value;m(l),(null==y?void 0:y.includes(l.trim()))?h("Page name already in use"):l.trim()?h(""):h("Page name can not be empty")}})}),e.jsxs(a.DialogActions,{children:[e.jsx(t.Button,{variant:"outlined",onClick:()=>{r(),m("")},style:{color:"black"},children:"Cancel"}),e.jsx(t.Button,{disabled:p||!u,onClick:()=>{let e={};n&&(e={...n}),e.name=u,d(e),m(""),r()},children:"Save"})]})]})})};function uo(l){var t;const{pageValue:o,pages:r,onChange:d}=l,[c,u]=s.useState((null==(t=r[o])?void 0:t.viewStyle)-1),m=e=>{switch(e){case 0:return 0===c?"Kanban View":"1";case 1:return 1===c?"Calendar View":"2";case 2:return 2===c?"List View":"3";case 3:return 3===c?"Timeline View":"4";case 4:return 4===c?"Grid":"5";default:return""}};return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"shared-img-wrap",children:[e.jsx(i.Typography,{children:(()=>{switch(c){case 0:return e.jsx("img",{className:"shared-img",src:n.images.sharedPage.kanbanView,alt:"Kanban View"});case 1:return e.jsx("img",{className:"shared-img",src:n.images.sharedPage.calendarView,alt:"Gantt View"});case 2:return e.jsx("img",{className:"shared-img",src:n.images.sharedPage.tableView,alt:"Grid View"});case 3:return e.jsx("img",{className:"shared-img",src:n.images.sharedPage.ganttView,alt:"Table View"});case 4:return e.jsx("img",{className:"shared-img",src:n.images.sharedPage.gridView,alt:"Calendar View"});default:return null}})()}),e.jsx("div",{className:"shared-img-tab",children:e.jsx(a.Box,{sx:{width:"100%"},children:e.jsxs(a.Tabs,{value:c,onChange:(e,l)=>{u(l),d(l+1)},centered:!0,children:[e.jsx(a.Tab,{label:m(0)},0),e.jsx(a.Tab,{label:m(1)},1),e.jsx(a.Tab,{label:m(2)},2),e.jsx(a.Tab,{label:m(3)},3),e.jsx(a.Tab,{label:m(4)},4)]})})})]})})}function mo(l){const{children:t,value:o,index:r,...n}=l;return e.jsx("div",{className:"shared-tab",role:"tabpanel",hidden:o!==r,id:`vertical-tabpanel-${r}`,"aria-labelledby":`vertical-tab-${r}`,...n,children:o===r&&e.jsx(a.Box,{sx:{p:3},children:e.jsx(i.Typography,{children:t})})})}function po(e){return{id:`vertical-tab-${e}`,"aria-controls":`vertical-tabpanel-${e}`}}const ho=({open:l,onClose:r,pages:n,handleSubmit:d})=>{const[c,u]=s.useState(0),[m,p]=s.useState(n),[h,y]=s.useState(""),g=ae.useDispatch();s.useEffect(()=>{g(re.setSharedPage(m))},[g,m]);const x=({page:l})=>{var t,o,a,r,n,i,s,d,c,u,m,p;let h="",y="";return h=1===(null==(o=null==(t=null==l?void 0:l.details)?void 0:t.views)?void 0:o.length)?"This page has 1 view, you can customize it":(null==(r=null==(a=null==l?void 0:l.details)?void 0:a.views)?void 0:r.length)?`This page has ${null==(i=null==(n=null==l?void 0:l.details)?void 0:n.views)?void 0:i.length} different views, you can customize them`:"In this page you can add different views and customize them",y=1===(null==(d=null==(s=null==l?void 0:l.details)?void 0:s.filters)?void 0:d.length)?", and it also have a saved filters to make things easier for you.":(null==(u=null==(c=null==l?void 0:l.details)?void 0:c.filters)?void 0:u.length)?`, and there are also ${null==(p=null==(m=null==l?void 0:l.details)?void 0:m.filters)?void 0:p.length} saved filters to make things easier for you.`:", and you can also add filters to make things easier for you",e.jsx("p",{children:h+y})},v=()=>{p(e=>e.map((e,l)=>l===c?{...e,isPinToDashboard:!e.isPinToDashboard}:e))},f=e=>{p(l=>l.map((l,t)=>t===c?{...l,viewStyle:e}:l))};return e.jsx(e.Fragment,{children:e.jsxs(t.Modal,{fullWidth:!0,onClose:r,open:l,className:"shared-pages-modal",children:[e.jsxs(a.DialogTitle,{children:[e.jsx(i.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:"Shared Views"}),e.jsx(a.IconButton,{edge:"end",onClick:r,size:"small",children:e.jsx(o,{fontSize:"inherit"})})]}),e.jsx(a.DialogContent,{dividers:!0,children:(null==m?void 0:m.length)?e.jsx(a.Box,{children:e.jsxs(a.Grid,{container:!0,spacing:2,children:[e.jsxs(a.Grid,{item:!0,xs:4,className:"tab-title-wrap",children:[e.jsx("div",{className:"tab-search-wrap",children:e.jsx(t.SearchBar,{placeholder:"Search User",handleSearch:e=>{y(e),u(0)}})}),e.jsx(a.Tabs,{orientation:"vertical",variant:"scrollable",value:c,onChange:(e,l)=>{u(l)},"aria-label":"Vertical tabs example",sx:{borderRight:1,borderColor:"divider"},children:m.filter(e=>e.name.toLowerCase().includes(h.toLowerCase())).map((l,t)=>e.jsx(a.Tab,{label:l.name,...po(t)},t))})]}),e.jsx(a.Grid,{className:"shared-grid-wrap",item:!0,xs:8,children:m.filter(e=>e.name.toLowerCase().includes(h.toLowerCase())).map((l,t)=>e.jsxs(mo,{value:c,index:t,children:[e.jsx("div",{className:"shared-pages-main",children:e.jsx(uo,{pageValue:t,pages:m,onChange:f})}),e.jsxs("div",{className:"tab-info-wrap",children:[e.jsxs("div",{className:"tab-inner-info",children:[e.jsx("div",{children:e.jsx("h1",{children:l.name})}),e.jsxs("div",{className:"tab-toggle",children:[e.jsx("div",{children:e.jsx(a.FormControlLabel,{control:e.jsx(Pe,{checked:l.isPinToDashboard,onChange:v}),label:"Pined to dashboard",labelPlacement:"start"})}),e.jsx("div",{className:"owner-name-wrap",children:e.jsxs("p",{children:[e.jsx("span",{children:"Owner:"})," ",l.owner]})})]})]}),e.jsx("div",{className:"tab-content",children:e.jsx(x,{page:l})})]})]},t))})]})}):e.jsx(a.Box,{display:"flex",width:"100%",height:"100%",alignItems:"center",justifyContent:"center",children:e.jsx(i.Typography,{type:"s1",color:"theme.secondary.800",children:"No Views has been shared with you"})})}),e.jsxs(a.DialogActions,{children:[e.jsx(t.Button,{variant:"outlined",onClick:r,style:{color:"black"},disabled:!(null==m?void 0:m.length),children:"Cancel"}),e.jsx(t.Button,{onClick:()=>{d(n[c])},disabled:!(null==m?void 0:m.length),children:"Duplicate"})]})]})})},yo=({sharedPages:l,handleAddPage:t,pages:o})=>{const[r,n]=s.useState(null),[d,c]=s.useState(!1),[u,m]=s.useState(!1),p=()=>n(null);return e.jsxs(e.Fragment,{children:[e.jsx(a.IconButton,{size:"small",sx:{ml:1},onClick:e=>{e.stopPropagation(),n(e.currentTarget)},children:e.jsx(te,{fontSize:"inherit"})}),e.jsxs(a.Menu,{open:Boolean(r),anchorEl:r,onClose:p,children:[e.jsx(a.MenuItem,{onClick:()=>{p(),c(!0)},children:e.jsx(i.Typography,{color:"theme.secondary.1000",type:"s4",children:"Create New View"})}),e.jsxs(a.MenuItem,{onClick:()=>{m(!0),n(null)},children:[e.jsx(i.Typography,{color:"theme.secondary.1000",type:"s4",children:"Shared Views"}),e.jsx(oe,{fontSize:"small"})]})]}),e.jsx(co,{pages:o,open:d,onClose:()=>c(!1),handleSubmit:t}),e.jsx(ho,{open:u,pages:l||[],onClose:()=>{m(!1)},handleSubmit:e=>{const l={...e.details,name:e.name};t(l),m(!1)}})]})},go=l=>{const{open:r,title:n,onClose:d,roles:c,toggleSwitch:u,onSubmit:m,value:p={},isPeopleAccessVisible:h=!1}=l,{share:y}=W.useAppSelector(e=>e),g=W.useAppDispatch(),[x,v]=s.useState(p.isPublic||!1),[f,j]=s.useState(p.selectedUsers||[]),[_,C]=s.useState([]),[T,w]=s.useState([]),[S,A]=s.useState({isRoleVisible:!1,selectedUsers:[]}),P=s.useMemo(()=>(null==S?void 0:S.isRoleVisible)?y.departments:y.users,[y,null==S?void 0:S.isRoleVisible]),[k,N]=s.useState([]);s.useEffect(()=>{const e=[],l=[];c&&c.map(t=>{const o={};"Owner"!==t.role&&(e.push(t.role),o.id=t.id,o.role=t.role,l.push(o)),w(e),C(l)})},[c]),s.useEffect(()=>{var e;(null==(e=null==p?void 0:p.selectedUsers)?void 0:e.length)||(null==p?void 0:p.role_id)?(S.isRoleVisible=p.is_role,A(S),j({...p,selectedUsers:p.is_role?null==p?void 0:p.role_id:null==p?void 0:p.selectedUsers})):M()},[null==p?void 0:p.selectedUsers,r]);const M=()=>{j({...p}),A(e=>({...e,selectedUsers:[]}))};return s.useEffect(()=>{r||M(),r&&g(re.getAllUserAndDepartmentDropdown())},[r]),e.jsx("div",{children:e.jsxs(a.Dialog,{open:r,onClose:d,className:"share",children:[e.jsxs(a.DialogTitle,{className:"share--head",children:[e.jsx(a.Box,{className:"share--title",children:e.jsx(i.Typography,{type:"s3",ml:1,className:"dialog-box-title",children:n})}),e.jsx(a.IconButton,{disableRipple:!0,onClick:d,children:e.jsx(o,{})})]}),e.jsx(a.Divider,{}),e.jsxs(a.DialogContent,{className:"share--content",children:[e.jsxs(a.Box,{m:1,display:"flex",alignItems:"center",justifyContent:"space-between",children:[e.jsx(i.Typography,{type:"s3",className:"input-label",children:"Add users"}),e.jsx(a.FormControlLabel,{control:e.jsx(a.Box,{mb:.5,mr:.5,children:e.jsx(Pe,{checked:null==S?void 0:S.isRoleVisible,onChange:()=>{A(e=>({...e,isRoleVisible:!e.isRoleVisible})),j([]),N(p.selectedUsers||[])}})}),label:e.jsx(i.Typography,{type:"s3",className:"input-label",children:"Show only Roles"})})]}),u&&e.jsx(e.Fragment,{children:e.jsx(a.Box,{mb:4,className:"d-flex",children:e.jsx(Yt,{options:P,multiple:!0,value:null==f?void 0:f.selectedUsers,onChange:e=>{return l=e.target.value,S.isRoleVisible&&j({...f,role_id:l}),void j({...f,selectedUsers:l});var l},placeholder:f&&f.length?"":"Add people and roles",getSelectedData:e=>N(e)})})}),h&&e.jsx("div",{className:"share--blurClass",children:e.jsxs(a.Accordion,{className:"people-access-accordion",children:[e.jsx(a.AccordionSummary,{expandIcon:e.jsx(ne,{}),children:e.jsx(i.Typography,{children:"People with access"})}),e.jsx(a.AccordionDetails,{className:"user-accordion-details",children:e.jsx(a.List,{className:"accordion-list",children:c&&c.map(l=>{const o=(null==_?void 0:_.length)>0&&(null==_?void 0:_.filter(e=>e.id===l.id));return e.jsxs(a.ListItem,{alignItems:"flex-start",children:[e.jsx(a.ListItemAvatar,{children:e.jsx(t.Avatar,{size:40,alt:"Person",icon:!0})}),e.jsx(a.ListItemText,{className:"primary-user-name",primary:l.name,secondary:e.jsx(i.Typography,{component:"span",variant:"body2",className:"secondary-email-text",children:l.email})}),"Owner"==l.role?e.jsx("p",{className:"owner-role-badge",children:l.role}):e.jsx("div",{children:e.jsx(t.Select,{className:"role-edit-select-box",value:(null==o?void 0:o.length)>0?o[0].role:"",onChange:e=>((e,l)=>{const t=_.map(t=>(t.id===l&&(t.role=e.target.value),t));C(t)})(e,l.id),variant:"outlined",children:T.map(l=>e.jsx(a.MenuItem,{className:"select-menu-items",value:l,children:l}))})})]})})})})]})}),e.jsxs("div",{className:"checkbox",children:[e.jsx(ze,{checked:x,onChange:()=>{v(!x)}}),e.jsx("div",{className:"checkbox-text",children:"Make it public"})]})]}),e.jsx(a.Divider,{}),e.jsxs(a.DialogActions,{className:"share--actions",children:[e.jsx(t.Button,{className:"cancel-btn",variant:"text",onClick:d,children:"Cancel"}),e.jsx(t.Button,{className:"success-btn",onClick:()=>{var e;if(!(null==k?void 0:k.length))return;const l=b.flatMap(k,"userIds").filter(e=>e);let t=k;Array.isArray(l)&&(null==l?void 0:l.length)&&(t=null==(e=y.users)?void 0:e.filter(e=>l.includes(e.id)));const o={is_private:!x,selectedUsers:[...new Set(t)],is_role:null==S?void 0:S.isRoleVisible,role_id:(null==S?void 0:S.isRoleVisible)?null==k?void 0:k.map(e=>null==e?void 0:e.id):[]};m(o)},children:"Save and Share"})]})]})})},xo=[{id:1,name:"Prasun Singh",email:"prasun@goldenflitch.com",role:"Owner"},{id:2,name:"Sidhant Chandel",email:"sidhant@goldenflitch.com",role:"Editor"},{id:3,name:"Amrit Sonar",email:"amrit@goldenflitch.com",role:"Viewer"}],vo=({open:l,onClose:o,page:r,pages:n,setCurrentPage:d,setPages:c,resource:u,handlePageDelete:m})=>{var p;const[h,y]=s.useState(!1),[x,v]=s.useState(!1),[b,j]=s.useState(!1),[_,C]=s.useState({}),[T,w]=s.useState({}),[S,P]=s.useState([]),k=ae.useSelector(e=>e),[N,M]=s.useState((null==(p=null==k?void 0:k.dashboard)?void 0:p.pinToDashboardList)||[]),I=W.useAppDispatch(),D=ae.useDispatch(),{setIsCreatePage:B}=A.usePages();s.useEffect(()=>{D(re.pinToDashboardList(N))},[D,S,N]),s.useEffect(()=>{r&&P([...S,{page:{...r,value:null==r?void 0:r._id},isPublic:!0,shareUsers:null==r?void 0:r.selectedUsers}])},[r]);const q=e=>{j(!0),C(e)},F=[{label:"Rename",func:()=>{o(),y(!0)},disabled:Boolean(null==r?void 0:r.isShared)},{label:"Duplicate",func:e=>{const l=e=>n.some(l=>l.name===e),{uniqueNumberId:t}=f.generateRandomId();let o=e.name;if(l(o)){let t=1;for(;l(`${e.name} ${t}`);)t++;o=`${e.name} ${t}`}const a=[...n,{...e,name:o,_id:t,data:e.data,isShared:!1}];c(a),B(!0)}},{label:"Share",func:e=>{var l;const t=S.find(l=>{var t;return(null==(t=l.page)?void 0:t.value)===(null==e?void 0:e.value)});w(t?{isPublic:t.isPublic,selectedUsers:t.shareUsers}:{isPublic:(null==(l=null==e?void 0:e.selectedUsers)?void 0:l.length)>0,...e}),v(!0),v(!0)},disabled:Boolean(null==r?void 0:r.isShared)},{label:"Pin to dashboard",func:()=>{const e=N.findIndex(e=>e.value===(null==r?void 0:r._id));M(-1!==e?l=>{const t=[...l];return t[e]={...t[e],label:null==r?void 0:r.name},t}:e=>[...e,r])},disabled:Boolean(null==r?void 0:r.isShared)},{label:"Move Right",func:e=>{const l=((e,l)=>{const t=[...e];if(t.length<=1)return;const o=t.findIndex(e=>e._id===l);if(o===t.length-1)return;const a=t.splice(o,1)[0];return t.splice(o+1,0,a),t})(n,null==e?void 0:e._id);l&&c(l)},disabled:(null==n?void 0:n.length)<=1||Boolean(null==r?void 0:r.isShared)},{label:"Move Left",func:e=>{const l=((e,l)=>{const t=[...e];if(t.length<=1)return;const o=t.findIndex(e=>e._id===l);if(0===o)return;const a=t.splice(o,1)[0];return t.splice(o-1,0,a),t})(n,null==e?void 0:e._id);l&&c(l)},disabled:(null==n?void 0:n.length)<=1||Boolean(null==r?void 0:r.isShared)}],E=e=>{e(r),o()};return e.jsxs(e.Fragment,{children:[e.jsxs(g.Menu,{open:Boolean(l),anchorEl:l,onClose:o,children:[null==F?void 0:F.map(l=>e.jsx(a.MenuItem,{onClick:()=>E(l.func),disabled:Boolean(null==l?void 0:l.disabled),children:e.jsx(i.Typography,{color:"theme.secondary.1000",type:"s4",children:null==l?void 0:l.label})},null==l?void 0:l.label)),e.jsx(a.Divider,{sx:{mt:"4px !important",mb:"4px !important"}}),e.jsx(a.MenuItem,{onClick:()=>E(q),disabled:Boolean(null==r?void 0:r.isShared),sx:{"&:hover":{backgroundColor:"theme.error.100"}},children:e.jsx(i.Typography,{color:"theme.error.500",type:"s4",children:"Delete"})})]}),e.jsx(co,{open:h,page:r,pages:n,onClose:()=>{y(!1)},handleSubmit:e=>{const l=n.map(l=>l._id===e._id?{...l,name:e.name}:l);c(l),B(!0)}}),e.jsx(t.ConfirmPopUp,{open:b,onClose:()=>j(!1),onConfirm:()=>{const e=((e,l)=>{const t=[...e];if(t.length<=1)return;const o=t.findIndex(e=>e._id===l);return t.splice(o,1),t})(n,null==_?void 0:_._id);(()=>{const e=N.filter(e=>e.value!==(null==r?void 0:r._id));M(e)})(),C({}),j(!1),e?(d(e[0]),c(e),m(e)):(m([]),c([]))},title:"Delete Confirmation?",description:"Are you sure you want to delete this page ?"}),e.jsx(go,{open:x,onClose:()=>v(!1),title:`Share page ${null==r?void 0:r.name}`,roles:xo,toggleSwitch:!0,value:T,onSubmit:e=>{let l=[];var t;l=S.find(e=>e.page.value===(null==r?void 0:r._id))?S.map(l=>l.page.value===(null==r?void 0:r._id)?{...l,isPublic:e.isPublic,shareUsers:e.selectedUsers}:l):[...S,{page:r,isPublic:e.isPublic,shareUsers:e.selectedUsers,viewStyle:1,owner:0}],P(l),(t={...e,page:r,resource:u}).pages=n,I(re.sharePage(t)).then(e=>{var l,t,o,a,r;(null==(o=null==(t=null==(l=null==e?void 0:e.payload)?void 0:l.data)?void 0:t.pages)?void 0:o.length)&&c(null==(r=null==(a=null==e?void 0:e.payload)?void 0:a.data)?void 0:r.pages),v(!1)})}})]})},fo=a.styled(a.Tabs)(()=>({minHeight:"fit-content",".MuiTabs-indicator":{height:"0px !important"},"& .MuiTabs-flexContainer":{gap:"4px"}})),bo=a.styled(a.Tab)(({theme:{palette:e}})=>{var l,t,o,a;return{minHeight:"2rem",textTransform:"none",padding:"0rem 1rem",minWidth:"fit-content",borderRadius:4,"&.Mui-selected":{background:null==(l=e.theme)?void 0:l.primary[100],color:null==(t=e.theme)?void 0:t.primary[700],borderTop:`2px solid ${null==(o=e.theme)?void 0:o.primary[700]}`},".MuiIconButton-root":{padding:"0rem"},"&:hover":{background:null==(a=e.theme)?void 0:a.primary[100]}}}),jo=({resource:l})=>{const{pages:o,setPages:r,setActivePage:n,activePage:d,savePages:c,setIsChanged:u,isSaving:m,generatedColumns:p,sharedPages:h,isChanged:y,deletePage:x,isCreatePage:v,setIsCreatePage:f,addOrDeletePage:j}=A.usePages(),[_,C]=s.useState(null),[T,S]=s.useState(),[P,k]=s.useState(null),N=()=>k(null),M=s.useCallback(async()=>{var e;if(v){const l=await j();200===l.status_code&&(r(null==(e=null==l?void 0:l.data)?void 0:e.pages),u(!1))}setTimeout(()=>{f(!1)},2e3)},[v]);return s.useEffect(()=>{M()},[M]),e.jsxs(a.Box,{display:"flex",gap:2,alignItems:"center",className:"page-navigator-container",children:[e.jsxs(a.Box,{display:"flex",className:"page-navigator",sx:{display:"flex",opacity:m?.5:1},children:[e.jsx(a.IconButton,{onClick:e=>{e.stopPropagation(),k(e.currentTarget)},disabled:m,children:e.jsx(ee,{fontSize:"small"})}),e.jsx(fo,{value:null==d?void 0:d._id,variant:"scrollable",onChange:(e,l)=>{const t=o.find(e=>(null==e?void 0:e._id)==l);n(t)},"aria-label":"basic tabs example",children:null==o?void 0:o.map(l=>{return e.jsx(bo,{iconPosition:"end",disableRipple:!0,icon:e.jsx(a.IconButton,{size:"small",edge:"end",onClick:e=>{return o=l,(t=e).stopPropagation(),S(o),void C(t.currentTarget);var t,o},disabled:m,children:e.jsx(le,{fontSize:"small",color:(null==d?void 0:d._id)===(null==l?void 0:l._id)?"primary":void 0})}),label:e.jsx(t.Tooltip,{title:`The '${l.name}' page has been ${(null==l?void 0:l.isShared)?(o=null==l?void 0:l.owner,`shared by ${o}`):"successfully created, complete with your saved filters, sorting options, and views."}`,placement:"top",arrow:!0,children:e.jsxs(a.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[(null==l?void 0:l.isShared)&&e.jsx(w.Share,{sx:{fontSize:"20px",color:"#4AC08C"}}),e.jsx("span",{children:l.name})]})},l._id),value:null==l?void 0:l._id},l);var o})}),e.jsx(a.Divider,{orientation:"vertical",variant:"middle",flexItem:!0,sx:{ml:2,borderWidth:"1px"}}),e.jsx(a.Box,{display:"flex",alignItems:"center",children:e.jsx(yo,{pages:o,handleAddPage:e=>{const l={...Y.defaultPageState,...e,name:e.name,visible_columns:p.columns,column_order:b.uniq(p.orderKeys),_id:o.length+1,active_view:"Table",views:[{label:"Table",position:0}]},t=[...o,l];n({...l}),r([...t]),f(!0)},sharedPages:h})}),e.jsx(vo,{open:_,onClose:()=>C(null),page:T,setPages:r,setCurrentPage:n,pages:o,resource:l,handlePageDelete:e=>{x(e)}}),e.jsx(g.Menu,{open:Boolean(P),anchorEl:P,onClose:N,children:null==o?void 0:o.map(l=>e.jsx(a.MenuItem,{selected:l._id===(null==d?void 0:d._id),onClick:()=>(n(l),void N()),children:e.jsx(i.Typography,{color:"theme.secondary.1000",type:"s4",children:l.name})},l._id))})]}),e.jsx(a.Box,{display:"flex",alignItems:"center",children:e.jsx(t.Button,{size:"small",variant:"contained",onClick:()=>c(),endIcon:m?e.jsx(a.CircularProgress,{size:15,color:"inherit"}):e.jsx(w.Save,{fontSize:"small"}),disabled:!y||m,children:"Save"})})]})},_o=s.memo(({pages:l,setPages:t,currentPage:o,setCurrentPage:r,total:n,paginationModel:i,handlePaginationModel:d,sharedPages:c,resource:u,savePageConfiguration:m,handlePageDelete:p,enablePages:h,isPaginationDisplayed:y=!0,isPageSaving:g=!1})=>{const[x,v]=s.useState("true"===window.localStorage.getItem("_is_drawer_open"));return s.useEffect(()=>{const e=()=>{v("true"===window.localStorage.getItem("_is_drawer_open"))};window.addEventListener("storage",e);const l=setInterval(e,10);return()=>{window.removeEventListener("storage",e),clearInterval(l)}},[]),e.jsxs(a.Box,{className:x?"footer--Container":"footer--drawerContainer",sx:{justifyContent:h?"space-between":"flex-end"},children:[Boolean(h)&&e.jsx(jo,{pages:l,setPages:t,currentPage:o,setCurrentPage:r,resource:u,sharedPages:c,handlePageDelete:p}),e.jsx(a.Box,{children:y&&e.jsx(so,{paginationModel:i,handlePaginationModel:d,totalPages:n})})]})}),Co=a.styled(a.Switch)(({theme:e})=>({padding:8,"& .MuiSwitch-track":{borderRadius:11,"&::before, &::after":{content:'""',position:"absolute",top:"50%",transform:"translateY(-50%)",width:16,height:16},"&::before":{backgroundImage:`url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 24 24"><path fill="${encodeURIComponent(e.palette.getContrastText(e.palette.primary.main))}" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg>')`,left:12},"&::after":{backgroundImage:`url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 24 24"><path fill="${encodeURIComponent(e.palette.getContrastText(e.palette.primary.main))}" d="M19,13H5V11H19V13Z" /></svg>')`,right:12}},"& .MuiSwitch-thumb":{boxShadow:"none",width:16,height:16,margin:2},"& .Mui-checked":{color:`${e.palette.theme.primary[800]} !important`},"& .Mui-checked+.MuiSwitch-track":{backgroundColor:`${e.palette.theme.primary[800]} !important`}}));exports.Accordion=Ce,exports.ActionBar=no,exports.AddFilterButton=De,exports.AddGroupButton=qe,exports.AddPage=yo,exports.AddPageModal=co,exports.Alert=vt,exports.Android12Switch=Co,exports.BreadCrumb=io,exports.Checkbox=ze,exports.ChipGenerator=_t,exports.ChipOrPlaceholder=$e,exports.ColorPickerInput=({value:l,onChange:o,label:r,...n})=>{const i=b.debounce(e=>{o(e)},500);return e.jsx(t.TextField,{label:r||"",variant:"outlined",type:"color",value:l,onChange:e=>{i(e.target.value)},size:"small",fullWidth:!0,InputProps:{startAdornment:e.jsx(a.InputAdornment,{position:"start",children:e.jsx(Q,{fontSize:"small"})})},...n})},exports.CombinatorSelect=ke,exports.CustomerVendorModal=ql,exports.DatePicker=Ee,exports.DateTimePicker=Sl,exports.DropdownButton=to,exports.DynamicButton=zl,exports.DynamicCheckBox=$l,exports.DynamicCurrency=Ll,exports.DynamicDate=Vl,exports.DynamicElementHOC=Ol,exports.DynamicInfo=Kl,exports.DynamicInputSelect=Gl,exports.DynamicMedia=Hl,exports.DynamicPhone=Tl,exports.DynamicRadioButton=Oe,exports.DynamicSearchSelect=bl,exports.DynamicSectionHOC=Yl,exports.DynamicSelect=Rl,exports.DynamicTable=dt,exports.DynamicTagsInput=Wl,exports.DynamicTime=mt,exports.DynamicToggleButton=yt,exports.Fallback=l=>{const{heading:t,subHeading:o,icon:r,children:n,...s}=l;return e.jsxs(a.Box,{className:"fallback",...s,children:[r,e.jsx(i.Typography,{type:"h5",weight:"medium",color:"theme.secondary.1000",className:"fallback--Text",children:t}),e.jsx(i.Typography,{type:"s3",weight:"medium",color:"theme.secondary.800",className:"fallback--Text",children:o}),e.jsx("div",{children:n})]})},exports.FieldSelect=Me,exports.Filter=lo,exports.Footer=_o,exports.FormHeader=l=>{const{breadCrumbPath:t,children:o,containerProps:a}=l;return e.jsxs("div",{className:"formHeader--Header",...a,children:[e.jsx(io,{path:t}),e.jsx("div",{children:o})]})},exports.FormParser=({data:l,defaultValues:o,handleFormSubmit:r,fieldArrayName:i,mode:d,displayAvtar:u=!1,onTableAddClick:m,handleFormValues:p,getFormMethods:h,setFields:x,onSelectFooterClick:j,setActiveTabValue:_,activeTab:C=0,recieveTabDataLenght:T,recieveIsValidForm:w,activeTabs:S,onTableCellChange:A,containerStyles:P,isButton:k=!0,getSelectedData:N,refreshOptions:M=!1,onBlur:I})=>{const{t:D}=y.useTranslation(),B=e=>{var l;switch(e.field_type){case"select":return(null==(l=e.field_properties)?void 0:l.is_multiselect)?_e.array():_e.string();case"number":case"currency":return _e.number().transform((e,l)=>""===l?void 0:e).typeError("Please enter valid number").nullable();case"currency_with_amount":return _e.number();case"url":return _e.string().matches(/^(https?:\/\/)?((([a-zA-Z0-9_-]+\.)+[a-zA-Z]{2,})|localhost)(:\d{2,5})?(\/[a-zA-Z0-9#_-]+\/?)*(\?[a-zA-Z0-9&=_-]+)?(#\S+)?$/,{excludeEmptyString:!0,message:"Please enter valid URL."});default:return _e.string()}},q=e=>{const l={};for(const t in e)"object"!=typeof e[t]||Object.hasOwn(e[t],"tests")?l[t]=e[t]:l[t]=_e.object().shape(q(e[t]));return l},{control:F,handleSubmit:E,formState:{errors:R},setValue:z,reset:$,getValues:V,watch:L,resetField:O,unregister:G,trigger:W,getFieldState:U,...K}=c.useForm({...o&&"object"==typeof o?{defaultValues:o}:{},resolver:t.o((e=>{const l={};let t={},o={};return e&&(null==e||e.forEach(e=>{var a;let r;e.validation&&e.validation.length>0&&((null==(a=e.name)?void 0:a.includes("."))?t=function(e,l,t={}){const o=e.split(".");let a=t;return o.forEach((e,t)=>{if(t===o.length-1)if(a[e]){if("object"!=typeof a[e]||Array.isArray(a[e]))throw new Error(`Conflict: The key "${e}" already exists and is not an object.`)}else{const t=l.validation.reduce((e,t)=>{var o;switch(t.type){case"required":return t.value?e.required(D(t.msg_en)).test("not-empty",D(t.msg_en),e=>{var l;return"string"!=typeof e||e&&(null==(l=null==e?void 0:e.trim())?void 0:l.length)>0}):(null==(o=l.field_properties)?void 0:o.is_multiselect)?e.min(1,D(t.msg_en)):e.nullable();case"min_length":case"min_val":return e.min(t.value,D(t.msg_en));case"max_length":case"max_val":return e.max(t.value,D(t.msg_en));default:return e}},B(l));a[e]=t}else{if(a[e]){if("object"!=typeof a[e]||Array.isArray(a[e]))throw new Error(`Conflict: The key "${e}" already exists and is not an object.`)}else a[e]={};a=a[e]}}),t}(e.name,e,t):(r=e.validation.reduce((l,t)=>Pt(l,t,e,D),B(e)),l[e.name]=r),o=q(t))})),_e.object().shape({[i]:_e.object().shape({...l,...o})})})(l)),mode:"all"}),H=c.useWatch({control:F,name:i}),[Y,J]=s.useState([]),[Q,Z]=s.useState([]),[X,ee]=s.useState(!1),[le,te]=s.useState(""),[oe,ae]=s.useState(!1),[re,ne]=s.useState([]),ie=e=>{null==m||m(e)},se=s.useCallback(e=>{var l,t,o;const a=(null==(l=null==e?void 0:e.members)?void 0:l.map(e=>e))||[],r=V(i),n=e.section_type===f.SECTION_TYPES.FORM_SWITCH_SECTION,s=(null==e?void 0:e.form_switcher_name)||(null==(t=null==e?void 0:e.form_switcher_label)?void 0:t.toLowerCase().split(" ").join("_")),d=null==(o=null==e?void 0:e.switcher_forms)?void 0:o.map(e=>({...e,formMembers:a.filter(l=>l.section_form_id===e.id)})),c=(null==r?void 0:r[s])?d.find(e=>e.name===(null==r?void 0:r[s])):{};let u;return u=n?[...a.filter(e=>!e.section_form_id&&!e.is_form_switcher_section),...(null==c?void 0:c.formMembers)||[]]:null==e?void 0:e.members,{isFormSwitcher:n,formSwitcherName:s,switchForms:d,selectedSectionForm:c,members:u,values:r}},[i,V]),de=s.useCallback((e,l,t,o)=>{var a;const r=null==(a=null==o?void 0:o[t])?void 0:a[null==l?void 0:l.country_code_field_name],n=`+${e.dialCode}`;(null==l?void 0:l.is_country_code_separate)&&(null==l?void 0:l.country_code_field_name)&&r!==n&&z(`${t}.${null==l?void 0:l.country_code_field_name}`,n)},[z]),ce=s.useCallback(e=>{e.forEach(e=>{null==e||e.formMembers.forEach(e=>{const t=(null==e?void 0:e.name)||e.label.toLowerCase().split(" ").join("_"),a=b.get(o,`${i}.${t}`,null),r=l.map(l=>((null==e?void 0:e.section_form_id)===(null==l?void 0:l.section_form_id)&&delete l.value,{...l,...a?{value:a}:{}}));a||(O(`${i}.${t}`),G(`${i}.${t}`)),null==x||x(r)})})},[l,o,i,O,x,G]),ue=s.useCallback((e,l,t={})=>{const o=e.split(".");let a=t;return o.forEach((e,t)=>{if(t===o.length-1)if(a[e]){if("object"!=typeof a[e]||Array.isArray(a[e]))throw new Error(`Conflict: The key "${e}" already exists and is not an object.`)}else{let t=l.value;if(t&&("image"!==l.field_type||"file"!==l.field_type))if("date"===l.field_type)t=v(t);else if("time"===l.field_type){const[e,l,o]=t.split(":").map(Number);t=v().set("hour",e).set("minute",l).set("second",o).set("millisecond",0)}else l.name.includes("_id")&&!Array.isArray(null==l?void 0:l.value)&&(t=Number(t));a[e]=t}else{if(a[e]){if("object"!=typeof a[e]||Array.isArray(a[e]))throw new Error(`Conflict: The key "${e}" already exists and is not an object.`)}else a[e]={};a=a[e]}}),t},[]),me=s.useCallback((e,l)=>(b.forOwn(e,(t,o)=>{b.has(l,o)&&b.isEqual(t,l[o])&&delete e[o]}),e),[]),pe=s.useCallback(e=>{var l;const t=[];e&&e&&(null==(l=e[0])||l.formMembers.forEach(e=>{(null==e?void 0:e.validation)&&Array.isArray(null==e?void 0:e.validation)&&(null==e||e.validation.forEach(l=>{(null==l?void 0:l.thenValidations)&&Array.isArray(null==l?void 0:l.thenValidations)?null==l||l.thenValidations.forEach(l=>{"required"===(null==l?void 0:l.type)&&!0===(null==l?void 0:l.value)&&(null==e?void 0:e.name)&&t.push(e.name)}):e.validation.some(e=>"required"===e.type&&!0===e.value)&&t.push(e.name)}))})),t&&ne(b.uniq(t))},[]),he=s.useCallback(e=>null==e||Array.isArray(e)&&0===e.length||"object"==typeof e&&0===Object.keys(e).length,[]),ye=s.useCallback((e,l)=>{const t=[];return l.forEach(l=>{const o=l.split(".");let a=e;for(let e=0;e<o.length;e++){const r=o[e];if(!(null==a?void 0:a[r])&&0!==(null==a?void 0:a[r]))return void t.push(l);a=a[r]}he(a)&&t.push(l)}),t},[he]);return s.useEffect(()=>{T&&T(Q.length)},[T,Q]),s.useEffect(()=>{const e=e=>{if(e.origin!==window.origin)return;const{state:l}=e.data;if(null==l?void 0:l.length){const e=g.formBuilderDeConversion(l);e.tab?Z(e.tab):e.section&&J(e.section)}};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[]),s.useEffect(()=>{var e,t;if(l){const a=g.formBuilderDeConversion(l);(null==a?void 0:a.tab)?(Z(a.tab),void 0!==C&&J((null==(e=a.tab[C])?void 0:e.data)||[])):J(a.section);const r=b.get(o,i,{}),n=me(H||{},r||{});if("edit"===d&&!(null==(t=Object.keys(n))?void 0:t.length)){let e={},t={};l.forEach(l=>{var o;const a=l.value;if(null==(o=l.name)?void 0:o.includes("."))t=ue(l.name,l,t);else if(a&&("image"!==l.field_type||"file"!==l.field_type))if(null==l?void 0:l.is_section_field){const t=(null==l?void 0:l.form_switcher_name)||(null==l?void 0:l.form_switcher_label);e={...e,[t]:a}}else if((null==l?void 0:l.name)&&["company_id","email_ids"].includes(null==l?void 0:l.name)&&["edit_customer","add_customer","edit_vendor","add_vendor"].includes(i))e={...e,[l.name]:a};else if("date"===l.field_type)e={...e,[l.name]:v(a)};else if("time"===l.field_type){const[t,o,r]=a.split(":").map(Number);e={...e,[l.name]:v().set("hour",t).set("minute",o).set("second",r).set("millisecond",0)}}else e=l.name.includes("_id")&&!Array.isArray(null==l?void 0:l.value)?"edit_user"===i&&"role_id"===l.name?{...e,[l.name]:a}:{...e,[l.name]:Number(a)}:{...e,[l.name]:a}});const o={...e,...t};$({[i]:{...o}})}null==h||h({control:F,handleSubmit:E,setValue:z,reset:$,resetField:O,getValues:V,unregister:G,trigger:W,watch:L,getFieldState:U,errors:R,...K})}},[l]),s.useEffect(()=>{(null==C?void 0:C.toString())&&Q&&Q[C]&&J(Q[C].data)},[C,Q]),s.useEffect(()=>{H&&p&&(null==p||p(H))},[p,H]),s.useEffect(()=>{(null==R?void 0:R[i])?ee(!0):ee(!1)},[i,JSON.stringify(R)]),s.useEffect(()=>{var e;const l=[];null!=C&&(null==(e=Q[C])||e.data.forEach(e=>{e.members&&Array.isArray(e.members)&&e.members.forEach(e=>{e.validation&&Array.isArray(e.validation)&&e.validation.some(e=>"required"===e.type&&!0===e.value)&&l.push(e.name)})}),ne(l))},[Q,C]),s.useEffect(()=>{if(null==H?void 0:H.account_type){const e=[];Y&&Y.forEach(l=>{var t,o;const a=Y&&(null==(t=null==l?void 0:l.members)?void 0:t.map(e=>e))||[],r=Y&&(null==(o=null==l?void 0:l.switcher_forms)?void 0:o.map(e=>({...e,formMembers:a.filter(l=>l.section_form_id===e.id)})));r&&e.push(r)});const l=(null==H?void 0:H.account_type)||"Individual",t=e&&Array.isArray(e[0])?e[0].filter(e=>e.name===l):[];t&&pe(t)}},[null==H?void 0:H.account_type,Y,pe]),s.useEffect(()=>{re.length>0?0===ye(H,re).length?ae(!0):ae(!1):ae(!0)},[re,H,C]),s.useEffect(()=>{w&&w(oe)},[w,oe]),e.jsx(a.Box,{sx:{width:"100%",padding:"2rem",...P},children:e.jsx(c.FormProvider,{...{control:F,handleSubmit:E,setValue:z,reset:$,resetField:O,getValues:V,unregister:G,trigger:W,watch:L,errors:R,...K},children:e.jsxs("form",{id:i,name:i,onSubmit:E(r),children:[Boolean(null==Q?void 0:Q.length)&&e.jsxs(e.Fragment,{children:[X&&e.jsx(vt,{severity:"error",onClose:()=>ee(!1),children:"Please fill all the required fields."}),e.jsx(gt,{tabs:Q,activeTabs:S,activeValue:C,setActiveValue:_,isFormTabValid:oe})]}),Y&&Y.map((l,t)=>{const{isFormSwitcher:o,formSwitcherName:a,switchForms:r,members:s,values:d}=se(l);return e.jsx(At,{section:l,index:t,members:s,switchForms:r,isFormSwitcher:o,control:F,fieldArrayName:i,formSwitcherName:a,displayAvtar:u,isButton:k,currencyOption:le,values:d,onBlur:I,setValue:z,onSelectFooterClick:j,getSelectedData:N,setCurrencyOptions:te,refreshOptions:M,handleFieldCleanUp:ce,handleSetCountryCodeField:de,handleTableAddClick:ie,onTableCellChange:A,t:D,images:n.images})})]})})})},exports.FormSection=At,exports.FormSwitcher=Tt,exports.HeaderCard=Se,exports.InfoCard=Ul,exports.Loader=()=>e.jsx("div",{className:"loader loader--style1",title:"0",children:e.jsxs("svg",{version:"1.1",id:"loader-1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"80px",height:"80px",viewBox:"0 0 40 40",enableBackground:"new 0 0 40 40",children:[e.jsx("path",{opacity:"0.2",fill:"#333",d:"M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,14.946,14.946\n s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634\n c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z"}),e.jsx("path",{fill:"#333",d:"M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0\n C22.32,8.481,24.301,9.057,26.013,10.047z",children:e.jsx("animateTransform",{attributeType:"xml",attributeName:"transform",type:"rotate",from:"0 20 20",to:"360 20 20",dur:"0.9s",repeatCount:"indefinite"})})]})}),exports.LocationSearchSelect=Ct,exports.MaterialTable=Nl,exports.ModalLoader=Dl,exports.ModuleTile=l=>{const t="transparent"===l.module.bg?"transparent":"";return e.jsx(E.Link,{to:l.module.link,children:e.jsxs(U,{className:"module-tile-container",children:[e.jsx(U,{className:`module-box ${t}`,style:{background:l.module.bg},children:e.jsx(fe,{component:"img",image:l.module.icon,alt:`${l.module.label} logo`})}),e.jsx(i.Typography,{type:"s3",className:"module-label",children:l.module.label})]})})},exports.OperatorSelect=Qt,exports.PageAction=vo,exports.PageNavigator=jo,exports.Pagination=so,exports.PhoneInput=Cl,exports.Radio=Ve,exports.RemoveAction=Ne,exports.RemoveGroupAction=Zt,exports.SaveFilterModal=Xt,exports.SearchableSelect=Yt,exports.SharePopUp=go,exports.SharedPageModal=ho,exports.SharedPageView=uo,exports.SourceTypeAddModal=Lt,exports.TabBar=gt,exports.TimePicker=ut,exports.TitleDropdownButton=oo,exports.Toggle=Pe,exports.ToggleSwitch=ht,exports.UploadExcel=ro,exports.UploadMedia=Al,exports.ValueEditor=Jt,exports.ViewModal=we,exports.createApiThunk=Wt,exports.dynamicSelectAdd=Kt,exports.userRoles=xo;
|
|
2
|
-
//# sourceMappingURL=android-12-switch-DMaoWQwq.js.map
|