@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 +1,2 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),t=require("react-hook-form"),a=require("./index-BQ2NBHDS.js"),l=require("@mui/icons-material/Close"),r=require("@mui/icons-material/Add"),n=require("./android-12-switch-DMaoWQwq.js"),o=require("./appbar-6Ucw59ku.js"),i=require("react"),s=require("react-datepicker");require("react-datepicker/dist/react-datepicker.css");/* empty css */const d=require("./images-DrJQoSCu.js"),c=require("@mui/icons-material"),u=require("@mui/material"),m=require("./useLangauge-p2qKwusp.js"),p=require("dayjs"),h=require("./useAuth-C1y8BBuX.js");;/* empty css */const x=require("@mui/lab/Timeline"),g=require("@mui/lab/TimelineItem"),y=require("@mui/lab/TimelineSeparator"),v=require("@mui/lab/TimelineConnector"),f=require("@mui/lab/TimelineContent"),b=require("@mui/lab/TimelineDot"),j=require("./common-wRWMk0Fs.js"),w=require("react-i18next"),C=require("yup"),S=require("./form-builder-deconversion-BbeAseMU.js"),T=require("./api-DG3x2G1d.js"),k=require("notistack"),_=require("./trash-lbX6jsCI.js"),D=require("react-redux"),M=require("./apiHelper-CLLyiIkN.js"),A=require("@asseinfo/react-kanban"),N=require("./navigation-utils-DgdbFA8i.js"),B=require("@fullcalendar/react"),E=require("@fullcalendar/daygrid"),R=require("@fullcalendar/list"),I=require("@fullcalendar/interaction"),P=require("@fullcalendar/timegrid"),F=require("@fullcalendar/resource-timegrid"),$=require("@fullcalendar/timeline"),z=require("@fullcalendar/resource-timeline"),q=require("@mui/material/styles"),O=require("@mui/material/Box"),L=require("./tick-ChY3vEPD.js"),Y=require("react-flags-select"),W=require("react-router-dom"),V=require("./page-context-qa1FKO9A.js"),K=require("gantt-task-react"),H=require("@mui/material/styles/useTheme"),U=require("@mui/icons-material/KeyboardArrowDown"),G=require("react-date-range");require("react-date-range/dist/styles.css"),require("react-date-range/dist/theme/default.css");const X=require("./action-bar-BmEN5Ob9.js"),J=require("@mui/material/Accordion"),Q=require("@mui/material/Chip"),Z=require("@mui/material/AccordionSummary"),ee=require("@mui/material/AccordionDetails"),te=require("@mui/material/Typography"),ae=require("@mui/icons-material/ExpandMore"),le=require("@mui/icons-material/RadioButtonChecked"),re=require("@glideapps/glide-data-grid"),ne=require("@glideapps/glide-data-grid-cells"),oe=require("react-laag");require("react-responsive-carousel/lib/styles/carousel.min.css");const ie=require("@mui/material/Menu"),se=require("@mui/material/MenuItem"),de=require("lodash"),ce=require("./useAccountSetting-DZvJOGz7.js"),ue=require("./hooks-BdfwliGF.js"),me=require("./store-CwOVutHK.js"),pe=require("@mui/material/IconButton"),he=require("@mui/material/Tab"),xe=require("@mui/lab/TabContext"),ge=require("@mui/lab/TabList"),ye=require("@mui/lab/TabPanel"),ve=require("@mui/base"),fe=require("@mui/material/LinearProgress"),be=require("react-dropzone"),je=require("@mui/icons-material/Remove"),we=require("./api-config-CkfRrKRY.js");;/* empty css */const Ce=require("@mui/material/List"),Se=require("@mui/material/ListItem"),Te=require("@mui/material/ListItemText"),ke=require("material-react-table"),_e=require("@mui/icons-material/ChevronRight"),De=require("@mui/icons-material/ChevronLeft"),Me=require("./modules-BiUx1fbP.js"),Ae=require("./pathname.rental-Br768eN2.js"),Ne=require("./pathname.hrms-DGxdM-k7.js"),Be=require("d3"),Ee=require("@mui/material/Card"),Re=require("@mui/material/CardContent"),Ie=require("@mui/icons-material/ArrowDropDown"),Pe=require("@mui/icons-material/ArrowDropUp"),Fe=require("@mui/material/Checkbox"),$e=require("./typography-BzrMi9XI.js"),ze=require("./arrow-up-BHInahU_.js"),qe=require("lucide-react");function Oe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const a in e)if("default"!==a){const l=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,l.get?l:{enumerable:!0,get:()=>e[a]})}return t.default=e,Object.freeze(t)}const Le=Oe(C),Ye=Oe(Be),We=a=>{const{fields:i,append:s}=t.useFieldArray({control:a.control,name:"abjMember"}),d=(e,t)=>{switch(e){case"input":s({type:"input",appendAfter:t});break;case"select":s({type:"select",appendAfter:t})}};return e.jsxs(e.Fragment,{children:[e.jsx(t.Controller,{control:a.control,name:a.name,defaultValue:a.defaultValue||"",render:({field:e})=>(Object.keys(a.field1).length&&Object.keys(a.field1)!==Object.keys(e)&&a.updateField({...e}),a.children)}),e.jsx(l,{style:{fontSize:"15px",cursor:"pointer"},onClick:()=>d("input",a.name)}),e.jsx(r,{style:{fontSize:"15px",cursor:"pointer"},onClick:()=>d("select",a.name)}),i.map(t=>{if(t.appendAfter===a.name)return e.jsxs(e.Fragment,{children:["input"===t.type&&e.jsx(o.DynamicInput,{placeholder:"Enter value",label:"Message",formControl:a.control,name:"message",fieldArrayName:"abjMember"}),"select"===t.type&&e.jsx(n.DynamicSelect,{placeholder:"Select value",label:"Is True",options:[{value:"option1",label:"Option 1"},{value:"option2",label:"Option 2"}],formControl:a.control,name:"is_true",fieldArrayName:"abjMember"})]})})]})};function Ve(e){return(Ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ke(e,t){if(t.length<e)throw new TypeError(e+" argument required, but only "+t.length+" present")}function He(e){Ke(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||"object"===Ve(e)&&"[object Date]"===t?new Date(e.getTime()):"number"==typeof e||"[object Number]"===t?new Date(e):("string"!=typeof e&&"[object String]"!==t||"undefined"==typeof console||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn((new Error).stack)),new Date(NaN))}We.propTypes={name:a.PropTypes.string.isRequired,defaultValue:a.PropTypes.string,field1:a.PropTypes.object,children:a.PropTypes.node.isRequired,updateField:a.PropTypes.func.isRequired,control:a.PropTypes.object.isRequired};var Ue={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function Ge(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}var Xe={date:Ge({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Ge({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:Ge({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Je={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Qe(e){return function(t,a){var l;if("formatting"===(null!=a&&a.context?String(a.context):"standalone")&&e.formattingValues){var r=e.defaultFormattingWidth||e.defaultWidth,n=null!=a&&a.width?String(a.width):r;l=e.formattingValues[n]||e.formattingValues[r]}else{var o=e.defaultWidth,i=null!=a&&a.width?String(a.width):e.defaultWidth;l=e.values[i]||e.values[o]}return l[e.argumentCallback?e.argumentCallback(t):t]}}function Ze(e){return function(t){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=a.width,r=l&&e.matchPatterns[l]||e.matchPatterns[e.defaultMatchWidth],n=t.match(r);if(!n)return null;var o,i=n[0],s=l&&e.parsePatterns[l]||e.parsePatterns[e.defaultParseWidth],d=Array.isArray(s)?function(e,t){for(var a=0;a<e.length;a++)if(t(e[a]))return a}(s,function(e){return e.test(i)}):function(e,t){for(var a in e)if(e.hasOwnProperty(a)&&t(e[a]))return a}(s,function(e){return e.test(i)});return o=e.valueCallback?e.valueCallback(d):d,{value:o=a.valueCallback?a.valueCallback(o):o,rest:t.slice(i.length)}}}var et,tt={code:"en-US",formatDistance:function(e,t,a){var l,r=Ue[e];return l="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",t.toString()),null!=a&&a.addSuffix?a.comparison&&a.comparison>0?"in "+l:l+" ago":l},formatLong:Xe,formatRelative:function(e,t,a,l){return Je[e]},localize:{ordinalNumber:function(e,t){var a=Number(e),l=a%100;if(l>20||l<10)switch(l%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},era:Qe({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Qe({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:Qe({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:Qe({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:Qe({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(et={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}},function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=e.match(et.matchPattern);if(!a)return null;var l=a[0],r=e.match(et.parsePattern);if(!r)return null;var n=et.valueCallback?et.valueCallback(r[0]):r[0];return{value:n=t.valueCallback?t.valueCallback(n):n,rest:e.slice(l.length)}}),era:Ze({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:Ze({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:Ze({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:Ze({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:Ze({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function at(e){return Ke(1,arguments),He(e).getMonth()}function lt(e){return Ke(1,arguments),He(e).getFullYear()}const rt=["January","February","March","April","May","June","July","August","September","October","November","December"],nt=({value:t,onClick:a,placeholderText:l,isRtl:r})=>e.jsxs("div",{className:"calender-container",children:[e.jsx("input",{type:"text",value:t,onClick:a,placeholder:l,className:"open-selected-calender"}),e.jsx("div",{className:r?"icon-box_rtl":"icon-box",children:e.jsx(d.CalenderIcon,{})})]});function ot(t){const{start:a=null,end:l=null,startYear:r=1980,onDateRangeChange:n,...o}=t,[d,p]=i.useState(a),[h,x]=i.useState(l),{isRtl:g}=m.useLanguage(),y=[],v=lt(new Date);for(let e=r;e<=v+10;e++)y.push(e);return e.jsx(u.Box,{className:"DateRangePicker",children:e.jsx(s,{dateFormat:"dd-MM-yyyy",...o,customInput:e.jsx(nt,{placeholderText:"DD-MM-YYYY",value:"",isRtl:g,onClick:()=>{}}),startDate:d,endDate:h,onChange:e=>{const[t,a]=e;p(t),x(a),n(e)},selectsRange:!0,isClearable:!0,renderCustomHeader:({date:t,decreaseMonth:a,increaseMonth:l,decreaseYear:r,increaseYear:n,prevMonthButtonDisabled:o,nextMonthButtonDisabled:i,prevYearButtonDisabled:s,nextYearButtonDisabled:d})=>e.jsxs("div",{className:"date-picker-container",children:[e.jsxs("div",{className:"d-flex",children:[e.jsx("button",{onClick:a,disabled:o,className:"btn-transparent",type:"button",children:e.jsx(c.KeyboardArrowLeft,{})}),e.jsx("div",{className:"month-view",children:rt[at(t)]}),e.jsx("button",{onClick:l,disabled:i,className:"btn-transparent",type:"button",children:e.jsx(c.KeyboardArrowRight,{})})]}),e.jsxs("div",{className:"d-flex",children:[e.jsx("button",{onClick:r,disabled:s,className:"btn-transparent",type:"button",children:e.jsx(c.KeyboardArrowLeft,{})}),e.jsx("select",{className:"select-year",value:lt(t),onChange:e=>{r(),p(new Date(+e.target.value,at(t)))},children:y.map(t=>e.jsx("option",{value:t,children:t},t))}),e.jsx("button",{onClick:n,disabled:d,className:"btn-transparent",type:"button",children:e.jsx(c.KeyboardArrowRight,{})})]})]})})})}const it=a=>{const l=p(a.min_date||null).isValid()?p(a.min_date).toDate():null,r=p(a.max_date||null).isValid()?p(a.max_date).toDate():null;return e.jsx(t.Controller,{control:a.formControl,name:`${a.fieldArrayName}.${a.name}`,render:({field:t,fieldState:n})=>{var o,i,s;return e.jsxs(e.Fragment,{children:[(null==a?void 0:a.label)&&e.jsxs(h.Typography,{type:"s5",weight:"medium",mb:.5,color:a.error?"theme.error.600":"theme.secondary.800",children:[a.label,a.required&&e.jsx("span",{className:"requiredStar",children:"*"})]}),e.jsx(ot,{start:null==(o=t.value)?void 0:o[0],end:null==(i=t.value)?void 0:i[1],startYear:a.startYear||1980,onDateRangeChange:e=>{t.onChange(e),a.onChange&&a.onChange(e)},placeholderText:a.placeholder||"MM-DD-YYYY - MM-DD-YYYY",dataPosition:a.position,dataName:`${a.fieldArrayName}.${a.name}`,label:a.label,required:"builder"!==a.formType&&a.required,minDate:l,maxDate:r,disabled:a.disabled,error:Boolean(n.error),helperText:null==(s=n.error)?void 0:s.message})]})}})};it.propTypes={formControl:a.PropTypes.shape({register:a.PropTypes.func.isRequired,setValue:a.PropTypes.func}).isRequired,name:a.PropTypes.string.isRequired,label:a.PropTypes.string,fieldArrayName:a.PropTypes.string,required:a.PropTypes.bool,position:a.PropTypes.number,formType:a.PropTypes.string,placeholder:a.PropTypes.string,startYear:a.PropTypes.number,disabled:a.PropTypes.bool,min_date:a.PropTypes.any,max_date:a.PropTypes.any,onChange:a.PropTypes.func};const st=a=>{const{readOnly:l=!1}=a;return e.jsx(t.Controller,{control:a.formControl,name:`${a.fieldArrayName}.${a.name}`,render:({field:t,fieldState:r})=>{var o;return e.jsx(n.DateTimePicker,{...t,dataPosition:a.position,dataName:`${a.fieldArrayName}.${a.name}`,label:a.label,placeholder:a.placeholder,required:"builder"!==a.formType&&a.required,defaultValue:a.defaultValue,disableFutureDates:a.is_future_dates_allowed,disablePastDates:a.is_past_dates_allowed,helperText:null==(o=r.error)?void 0:o.message,error:Boolean(r.error),disabled:a.disabled,minDate:a.min_date,maxDate:a.max_date,minDateTime:a.min_date_time,maxDateTime:a.max_date_time,textFieldProps:l?{readOnly:!0}:{readOnly:!1},onChange:e=>{if(a.min_date_time&&e&&p(e).isSame(a.min_date_time,"day")){const l=p(e);if(l.isBefore(a.min_date_time)){const e=l.hour(a.min_date_time.hour()).minute(a.min_date_time.minute());return void t.onChange(e)}}t.onChange(e)}})}})};st.propTypes={formControl:a.PropTypes.shape({register:a.PropTypes.func.isRequired,setValue:a.PropTypes.func}).isRequired,name:a.PropTypes.string.isRequired,label:a.PropTypes.string.isRequired,fieldArrayName:a.PropTypes.string,required:a.PropTypes.bool,position:a.PropTypes.number,formType:a.PropTypes.string,placeholder:a.PropTypes.string,defaultValue:a.PropTypes.any,is_future_dates_allowed:a.PropTypes.bool,is_past_dates_allowed:a.PropTypes.bool,typeOfField:a.PropTypes.string,disable:a.PropTypes.bool,min_date:a.PropTypes.any,max_date:a.PropTypes.any};const dt=i.lazy(()=>Promise.resolve().then(()=>require("./custom-editor-CqKvR1Cc.js"))),ct=i.memo(a=>{const l=i.useMemo(()=>`${a.fieldArrayName}.${a.name}`,[a.fieldArrayName,a.name]),{minDate:r,maxDate:o}=i.useMemo(()=>({minDate:p(a.min_date||null).isValid()?p(a.min_date):null,maxDate:p(a.max_date||null).isValid()?p(a.max_date):null}),[a.min_date,a.max_date]),s=i.useMemo(()=>"builder"!==a.formType&&a.required,[a.formType,a.required]);return e.jsx(t.Controller,{control:a.formControl,name:l,render:({field:t,fieldState:i})=>{var d;return e.jsx(n.DatePicker,{...t,...a,dataPosition:a.position,dataName:l,label:a.label,placeholder:a.placeholder,required:s,defaultValue:a.defaultValue,disableFutureDates:a.is_future_dates_allowed,disablePastDates:a.is_past_dates_allowed,helperText:null==(d=i.error)?void 0:d.message,error:Boolean(i.error),disabled:a.disabled,minDate:r,maxDate:o})}})});ct.displayName="CustomDatePicker",ct.propTypes={formControl:a.PropTypes.shape({register:a.PropTypes.func.isRequired,setValue:a.PropTypes.func}).isRequired,name:a.PropTypes.string.isRequired,label:a.PropTypes.string.isRequired,fieldArrayName:a.PropTypes.string,required:a.PropTypes.bool,position:a.PropTypes.number,formType:a.PropTypes.string,placeholder:a.PropTypes.string,defaultValue:a.PropTypes.any,is_future_dates_allowed:a.PropTypes.bool,is_past_dates_allowed:a.PropTypes.bool,typeOfField:a.PropTypes.string,disabled:a.PropTypes.bool,min_date:a.PropTypes.any,max_date:a.PropTypes.any};const ut=u.styled(u.TextField)(({theme:{palette:e}})=>{var t,a,l,r;return{width:"100%","& .MuiOutlinedInput-root":{height:"2rem","& fieldset":{borderColor:null==(t=e.theme)?void 0:t.secondary[300],borderWidth:2},"&:hover fieldset":{borderColor:null==(a=e.theme)?void 0:a.secondary[300]},"&.Mui-focused fieldset":{borderColor:null==(l=e.theme)?void 0:l.primary[700]},"&.Mui-error fieldset":{borderColor:null==(r=e.theme)?void 0:r.error[600]}}}}),mt=Le.object().shape({approver_id:Le.array().required("Please select the approvers").min(1,"Please select the approvers")}),pt=({isOpen:a,setIsOpen:l,modalProps:r,title:s,onConfirm:d,isProcessing:m})=>{const[p,x]=i.useState({isLoading:!0,isError:!1,error:"null",data:[]}),{isLoading:g,isError:y,error:v,data:f}=p,{control:b,handleSubmit:w,reset:C,setValue:D,getValues:M,watch:A,trigger:N}=t.useForm({resolver:o.o(mt),mode:"all"});A("approver_id");const B=M("approver_id"),E=async e=>{await N()&&(d(e.approver_id),R())},R=()=>{C({approver_id:[]}),l()},I=({data:t,options:a})=>{const l=t.map(e=>{const t=a.find(t=>t.id===e);return t?P(t):e});return e.jsxs(u.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[e.jsxs(h.Typography,{type:"s5",color:"inherit",sx:{display:"flex",gap:1,alignItems:"center",mt:.5},children:[l.slice(0,3).join(", "),t.length>4&&e.jsx(S.Chip,{variant:"outlined",type:"normal",className:"quickApprovalModal--DisplayNameChip",label:e.jsx(_.MoreIcon,{fontSize:"small"})})]}),e.jsx(o.Button,{variant:"text",onClick:()=>D("approver_id",[]),children:e.jsx(h.Typography,{type:"s5",color:"inherit",children:"Remove"})})]})};i.useEffect(()=>{a&&(async()=>{var e;try{const t={skip:0,limit:99,filters:"(is_active.eq=true)"},a=await T.getV1User({...t,...j.getToken()}),l=(null==(e=null==a?void 0:a.data)?void 0:e.users)||[];x({isLoading:!1,isError:!1,error:null,data:l})}catch(t){x({isLoading:!1,isError:!0,error:"Failed to fetch Approvers",data:[]})}})()},[a]),i.useEffect(()=>{y&&k.enqueueSnackbar(v??"Something went wrong",{variant:"error"})},[v,y]);const P=e=>{const{first_name:t="",last_name:a=""}=e||{};return j.formatLabel(`${t} ${a}`)};return i.useEffect(()=>()=>{R()},[]),e.jsx(o.Modal,{open:a,onClose:R,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:!0,...r,children:e.jsxs("form",{onSubmit:w(E),children:[e.jsxs(u.DialogTitle,{className:"quickApprovalModal--Title",children:[e.jsx(h.Typography,{type:"s3",color:"inherit",weight:"medium",children:s||"Quick Approval"}),e.jsx(u.IconButton,{onClick:R,children:e.jsx(c.Close,{fontSize:"small"})})]}),e.jsx(u.DialogContent,{className:"quickApprovalModal--ModalContentContainer",children:e.jsx(t.Controller,{name:"approver_id",control:b,render:({field:t,fieldState:a})=>{var l,r,i;return e.jsxs(e.Fragment,{children:[e.jsx(o.Select,{name:"approver_id",value:t.value||[],onChange:t.onChange,error:Boolean(null==(l=a.error)?void 0:l.message),helperText:(null==(r=a.error)?void 0:r.message)||"",size:"small",renderValue:t=>e.jsx(n.ChipOrPlaceholder,{data:t,placeholder:"Select",onDelete:()=>D("approver_id",[])}),multiple:!0,fullWidth:!0,children:f.map(a=>{const l=["theme.tertiary1","theme.tertiary2","theme.tertiary3"],r=l[Math.floor(Math.random()*l.length)],i={borderRadius:"0.25rem !important",textAlign:"center",backgroundColor:`${r}.200`,color:`${r}.1000`};return e.jsx(u.MenuItem,{value:a.id,selected:Boolean(t.value&&t.value.includes(a.id)),children:e.jsxs(u.Box,{className:"quickApprovalModal--UserListingContainer",children:[e.jsxs(u.Box,{className:"quickApprovalModal--UserContent",children:[e.jsx(o.Avatar,{src:a.profile_image,alt:P(a),sx:i,size:24}),e.jsx(h.Typography,{type:"s4",color:"theme.secondary.1000",children:P(a)})]}),e.jsx(n.Checkbox,{checked:Boolean(t.value&&t.value.includes(a.id))})]})},a.id)})}),Array.isArray(null==t?void 0:t.value)&&(null==(i=null==t?void 0:t.value)?void 0:i.length)>0&&e.jsx(I,{data:t.value,options:f})]})}})}),e.jsxs(u.DialogActions,{className:"quickApprovalModal--DialogActions",children:[e.jsx(o.Button,{className:"quickApprovalModal--DialogActions--Cancel",onClick:R,disabled:g||m,children:"Cancel"}),e.jsx(o.Button,{type:"button",onClick:w(E),endIcon:m?e.jsx(u.CircularProgress,{size:15,color:"inherit"}):void 0,disabled:m||g||Boolean(!(null==B?void 0:B.length)),children:"Send Request"})]})]})})},ht=({column:t})=>{const[a,l]=i.useState(!1),[r,n]=i.useState(t.title);return e.jsxs("div",{className:"kanban-column lead-card",children:[a?e.jsxs("div",{className:"create-status-box",children:[e.jsx("input",{type:"text",placeholder:"Enter new status title",value:r,onChange:e=>n(e.target.value)}),e.jsxs("div",{className:"add-btns",children:[e.jsx("button",{onClick:()=>(t.title=r,void l(!1)),children:"Rename"}),e.jsx("button",{onClick:()=>l(!1),children:"Cancel"})]})]}):e.jsx("h2",{className:"kanban-column-title",onDoubleClick:()=>l(!0),children:t.title}),e.jsx("span",{className:"count-length-text",children:t.cards.length}),e.jsx(u.IconButton,{color:"inherit",size:"small",className:"more-menu-btn",children:e.jsx("img",{src:d.images.more,alt:"more icon"})})]})},xt=({data:t})=>e.jsx(n.Accordion,{title:e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:"Items"}),accordionProps:{defaultExpanded:!0,sx:{borderBottomWidth:1,"& .MuiAccordionSummary-root":{borderBottomWidth:1}}},children:e.jsxs(u.Box,{className:"calculationSummary--SummaryContainer",children:[e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Total Quantity"}),e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:t.totalQuantity})]}),e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Total"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.total]})]})]})}),gt=({data:t,enalblePromotions:a})=>e.jsx(n.Accordion,{title:e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:"Discounts"}),accordionProps:{defaultExpanded:!0,sx:{borderBottomWidth:1,"& .MuiAccordionSummary-root":{borderBottomWidth:1}}},children:e.jsxs(u.Box,{className:"calculationSummary--SummaryContainer",children:[e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Item Discount"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.itemDiscount]})]}),Number(t.additionalDiscount)>0&&e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Additional Discount"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.additionalDiscount]})]}),Boolean(a)&&e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Promotion Amount"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.promotionAmount]})]}),e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Total Discount"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.totalDiscount]})]})]})}),yt=({data:t})=>e.jsx(n.Accordion,{title:e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:"Subtotal"}),accordionProps:{defaultExpanded:!0,sx:{borderBottomWidth:1,"& .MuiAccordionSummary-root":{borderBottomWidth:1}}},children:e.jsxs(u.Box,{className:"calculationSummary--SummaryContainer",children:[e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Subtotal Excluding Taxes"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.subtotalExTax]})]}),e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Subtotal Excluding discount"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.subtotalExDiscount]})]})]})}),vt=({data:t,enableShippings:a})=>e.jsx(n.Accordion,{title:e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:"Taxes and Charges"}),accordionProps:{defaultExpanded:!0,sx:{borderBottomWidth:1,"& .MuiAccordionSummary-root":{borderBottomWidth:1}}},children:e.jsxs(u.Box,{className:"calculationSummary--SummaryContainer",children:[e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Taxes and Charges Added"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.taxes]})]}),e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Taxes and Charges deducted"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.deductedTax]})]}),e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Total Taxes and Charges Added"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.total]})]}),Boolean(a)&&e.jsxs(e.Fragment,{children:[e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Shipping Amount"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.shippingAmount]})]}),e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Handling Amount"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.handlingAmount]})]})]})]})}),ft=({data:t})=>e.jsx(n.Accordion,{title:e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:"Total"}),accordionProps:{defaultExpanded:!0,sx:{borderBottomWidth:1,"& .MuiAccordionSummary-root":{borderBottomWidth:1}}},children:e.jsxs(u.Box,{className:"calculationSummary--SummaryContainer",children:[e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Grand Total"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.total]})]}),Number(t.roundOffDifferenceAmount)>0&&e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Round Off Difference"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.roundOffDifferenceAmount]})]})]})}),bt=({children:t,...a})=>e.jsx(u.Box,{className:"card-wrapper",...a,children:t}),jt=Le.object({login:Le.object({password:Le.string().required("Please enter password").min(8,"Password must be at least 8 characters").matches(/[A-Z]/,"Password must contain at least one uppercase letter").matches(/[!@#$%^&*(),.?":{}|<>]/,"Password must contain at least one special character")})}),wt=q.styled(Y)(({theme:{palette:e}})=>{var t,a,l;return{".country-button":{span:{fontSize:"0.875rem"},svg:{fontSize:"1.25rem"},padding:"0.2rem 0.5rem 0.2rem 0rem",borderRadius:".25rem",border:"1px solid #D3D3D4"},ul:{input:{padding:"0.5rem",borderRadius:"0.5rem",fontSize:"0.8125rem",margin:"0px 0.75rem",border:`1px solid ${null==(t=e.theme)?void 0:t.secondary[200]}`,background:`url(${d.images.search}) no-repeat scroll 0.5rem 0.5rem`,paddingLeft:"2rem",backgroundRepeat:"no-repeat",backgroundColor:`${null==(a=e.theme)?void 0:a.secondary[100]}`},li:{fontSize:"0.8125rem",padding:"0.5rem 1rem"},boxShadow:"0px 0px 2px 0px #E0E0E0, 0px 1px 4px -2px rgba(24, 39, 75, 0.02), 0px 4px 4px -2px rgba(24, 39, 75, 0.06)",borderRadius:"0.5rem",marginTop:"0.25rem",border:"none",div:{borderBottom:`1px solid ${null==(l=e.theme)?void 0:l.secondary[200]}`,paddingBottom:"0.5rem"}}}}),Ct=u.styled(u.Box)(({theme:e})=>({position:"relative",display:"inline-flex",alignItems:"center",borderRadius:e.spacing(3),padding:e.spacing(.5),cursor:"pointer",transition:"all 0.3s ease-in-out",minWidth:"max-content",backgroundColor:e.palette.common.white,border:"1px solid",borderColor:e.palette.grey[200],"&.disabled":{opacity:.5,cursor:"not-allowed"}})),St=u.styled(u.Box)(({theme:e})=>({position:"absolute",backgroundColor:e.palette.theme.primary[100],borderRadius:e.spacing(2.5),transition:"all 0.3s ease-in-out",top:0,bottom:0,zIndex:1})),Tt=u.styled(u.ButtonBase)(({theme:e,active:t})=>({position:"relative",zIndex:2,padding:e.spacing(1,1.5),borderRadius:e.spacing(2.5),fontSize:"0.75rem",fontWeight:500,whiteSpace:"nowrap",userSelect:"none",transition:"color 0.3s ease-in-out",color:t?e.palette.primary.main:e.palette.grey[600],"&:hover:not(.disabled)":{color:t?e.palette.primary.main:e.palette.grey[800]},"&.disabled":{cursor:"not-allowed"}})),kt=({children:t,defaultExpanded:a=!0,expandedGridSize:l=3,collapsedGridSize:r=0,className:n="",ariaLabel:o="Toggle summary panel",onToggle:s,persistState:d=!1,storageKey:p="grid-summary-panel-state",showToggleButton:h=!0,mobileDrawer:x=!0,showCollapseIcon:g=!0})=>{const y=u.useTheme(),v=u.useMediaQuery(y.breakpoints.down("md")),{currentLanguage:f}=m.useLanguage(),b=i.useMemo(()=>"rtl"===(null==f?void 0:f.direction),[f]),[j,w]=i.useState(()=>{if(d&&"undefined"!=typeof window){const e=localStorage.getItem(p);return e?JSON.parse(e):a}return a}),[C,S]=i.useState(!1);i.useEffect(()=>{if(!j)return void S(!1);const e=setTimeout(()=>{S(!0)},250);return()=>clearTimeout(e)},[j]);const T=()=>{const e=!j,t=e?l:r;w(e),d&&"undefined"!=typeof window&&localStorage.setItem(p,JSON.stringify(e)),null==s||s(e,t)},k=j?l:r;return v&&x?e.jsxs(e.Fragment,{children:[h&&e.jsx(u.IconButton,{onClick:T,sx:{position:"fixed",top:"50%",[b?"left":"right"]:0,zIndex:y.zIndex.fab,bgcolor:y.palette.background.paper,border:`1px solid ${y.palette.divider}`,borderRadius:"8px 0 0 8px","&:hover":{bgcolor:y.palette.action.hover}},"aria-label":o,children:e.jsx(c.ChevronLeft,{})}),e.jsx(u.Drawer,{anchor:"right",open:j,onClose:T,sx:e=>({"& .MuiDrawer-paper":{width:"90vw",[e.breakpoints.up("md")]:{maxWidth:"400px",marginTop:"65px"},[e.breakpoints.up("sm")]:{maxWidth:"300px",marginTop:"65px"},[e.breakpoints.up("xs")]:{maxWidth:"200px",marginTop:"56px"}}}),children:t})]}):e.jsxs(u.Grid,{item:!0,xs:k,sx:{position:"relative",transition:y.transitions.create(["flex-basis","max-width"],{easing:y.transitions.easing.sharp,duration:y.transitions.duration.enteringScreen}),overflow:"visible",minHeight:"100%",display:"block",minWidth:0===k?0:"auto"},className:n,children:[h&&!j&&e.jsx(u.Tooltip,{title:"Expand summary",placement:"left",children:e.jsx(u.IconButton,{onClick:T,sx:{position:"fixed",top:"20%",[b?"left":"right"]:0,width:"30px",zIndex:y.zIndex.fab,bgcolor:y.palette.background.paper,border:`1px solid ${y.palette.divider}`,borderRadius:"8px 0 0 8px","&:hover":{bgcolor:y.palette.action.hover}},"aria-label":"Expand summary panel",children:j?e.jsx(c.ChevronRight,{}):e.jsx(c.ChevronLeft,{})})}),k>0&&C&&e.jsxs(u.Box,{sx:{height:"100%",width:"100%",overflow:"visible",display:"flex",flexDirection:"column",bgcolor:y.palette.background.paper,borderLeft:`1px solid ${y.palette.divider}`,borderRadius:"8px 0 0 8px",position:"relative"},children:[g&&j&&e.jsx(u.Tooltip,{title:"Close summary",placement:"left",children:e.jsx(u.IconButton,{onClick:T,size:"small",sx:{position:"absolute",top:"-15px",[b?"right":"left"]:"-15px",zIndex:1200,bgcolor:y.palette.background.paper,border:`1px solid ${y.palette.divider}`,borderRadius:"50%","&:hover":{bgcolor:"#fff"},boxShadow:"none"},children:e.jsx(c.Close,{sx:{fontSize:14}})})}),e.jsx(u.Collapse,{in:j,orientation:"horizontal",sx:{height:"100%","& .MuiCollapse-wrapperInner":{height:"100%",width:"100%"},width:"100%"},children:e.jsx(u.Box,{sx:{width:"100%",height:"100%",overflow:"auto",minWidth:0},children:t})}),!j&&e.jsx(u.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",width:"100%",color:y.palette.text.secondary,cursor:"pointer"},onClick:T,children:e.jsx(u.Box,{sx:{writingMode:"vertical-lr",textOrientation:"mixed",fontSize:"0.875rem",fontWeight:500,letterSpacing:"0.1em"},children:"SUMMARY"})})]})]})},_t=({buttons:t,dropdownMenuButtonData:a=null,toggleCallback:l,className:r,zIndex:i=999,iconPosition:s="start",...d})=>e.jsxs("div",{className:r,children:[null==t?void 0:t.map(t=>e.jsx(o.Button,{className:t.class?t.class:`wrapper--${null==t?void 0:t.btnStyle}`,variant:t.variant?t.variant:"contained",startIcon:t.icon?t.icon:"",onClick:t.action,children:t.title??""},t.title)),a&&e.jsx("div",{style:{zIndex:i},children:e.jsx(n.DropdownButton,{options:a.options||[],..."start"===s?{startIcon:a.icon}:{endIcon:a.icon},isMenuThirdItemDisabled:!0,isOnlyDropDownButton:!0,variant:"text",buttonGroupProps:{variant:"text"},onlyDropDownButtonProps:{style:{backgroundColor:"white !important",color:"black !important",...a.sx}},toggleCallback:l,...d,children:a.children})})]}),Dt={"& .MuiOutlinedInput-root":{"& fieldset":{border:"none"},"&:hover fieldset":{border:"none"},"&.Mui-focused fieldset":{border:"none"}}},Mt=({options:t,multiple:a,placeholder:l,with_checkboxes:r,values:o,field:i})=>{const s=[];return a||s.push(e.jsx(u.MenuItem,{disabled:!0,value:"",children:e.jsx(h.Typography,{type:"s3",color:"theme.secondary.1000",children:e.jsx("em",{children:l})})})),null==t||t.forEach(t=>{s.push(e.jsx(u.MenuItem,{value:t.value,disabled:Boolean(t.disabled),className:(null==t?void 0:t.isGroup)?"select--MenuItemHeader":"",children:e.jsxs(u.Box,{sx:{display:"flex",gap:1},children:[a&&r&&e.jsx(n.Checkbox,{checked:de.some(o,t.value)}),e.jsx(h.Typography,{type:"s3",color:"theme.secondary.1000",children:t.label})]})},t.value)),(null==t?void 0:t.isGroup)&&Array.isArray(null==t?void 0:t.options)&&t.options.forEach(l=>{s.push(e.jsx(u.MenuItem,{value:l.value,disabled:Boolean(l.disabled),sx:{pl:5},children:e.jsxs(u.Box,{sx:{display:"flex",gap:1},children:[a&&r&&e.jsx(n.Checkbox,{checked:Boolean(o&&(null==o?void 0:o.indexOf(l.value))>-1)}),e.jsx(h.Typography,{type:"s3",color:"theme.secondary.1000",children:l.label})]})},`${t.value}-${l.value}`))})}),i.enable_footer&&s.push(e.jsxs(u.Box,{children:[e.jsx(u.Divider,{flexItem:!0}),e.jsxs(u.MenuItem,{sx:{gap:1},onClick:i.onFooterClick,children:[e.jsx(c.Add,{fontSize:"small"}),e.jsxs(h.Typography,{type:"s4",color:"theme.secondary.1000",children:["Create New ",i.label]})]})]})),s},At=({data:t,options:a})=>{const l=t.map(e=>{var t;return(null==(t=null==a?void 0:a.find(t=>{var a,l;return((null==(a=t.value)?void 0:a.id)||(null==(l=t.value)?void 0:l.name)||t.value)===((null==e?void 0:e.id)||(null==e?void 0:e.name)||e)}))?void 0:t.label)||e});return e.jsxs(h.Typography,{type:"s4",color:"inherit",sx:{display:"flex",gap:1,alignItems:"center",mt:.5,position:"absolute"},children:[l.slice(0,4).join(", "),t.length>4&&"..."]})},Nt=t=>{var a;const[l,r]=i.useState([]),[s,d]=i.useState(t.defaultValue||t.value||(t.is_multiselect?[]:"")),m=e=>null==e?void 0:e.filter(e=>e),p=i.useCallback(()=>{r(t.options)},[t.options]);i.useEffect(()=>{p()},[p]),i.useEffect(()=>{d(t.defaultValue||t.value||(t.is_multiselect?[]:""))},[t.defaultValue,t.value,t.is_multiselect]);const{t:h}=w.useTranslation();return e.jsxs(e.Fragment,{children:[e.jsx(o.Select,{fullWidth:!0,placeholder:t.placeholder,label:t.label,value:s,defaultValue:t.defaultValue||(t.is_multiselect?[]:""),required:t.required,size:t.size||"small",multiple:Boolean(null==t?void 0:t.is_multiselect),disabled:Boolean(null==t?void 0:t.disabled),variant:"outlined",sx:Boolean(null==t?void 0:t.is_multiselect)&&(null==s?void 0:s.length)?{"& .MuiSelect-select":{padding:"5.5px !important",minWidth:"165px"}}:{minWidth:"165px"},className:t.is_multiselect&&(null==(a=m(s))?void 0:a.length)?"MultiSelect":"",input:(null==t?void 0:t.is_multiselect)||t.disabled?void 0:e.jsx(u.OutlinedInput,{label:"",endAdornment:e.jsx(u.InputAdornment,{position:"end",children:t.value&&e.jsx(u.IconButton,{"aria-label":"clear selection",onClick:()=>t.onChange(null),edge:"end",sx:{mr:1.5},size:"small",children:e.jsx(c.Close,{sx:{fontSize:"1rem"}})})})}),renderValue:a=>{var r;return e.jsx(e.Fragment,{children:Array.isArray(a)?e.jsx(n.ChipOrPlaceholder,{selectedLabel:t.selectedLabel,data:m(a),placeholder:t.placeholder,onDelete:null==t?void 0:t.onChipRemove,disabled:t.disabled,chipProps:{sx:{bgcolor:"theme.primary.100",border:0,"& .MuiTypography-body1":{color:"theme.primary.800",fontWeight:"500"},"& .MuiChip-deleteIcon":{color:"theme.primary.800","&:hover":{color:"theme.primary.900"}}}}}):(null==(r=null==l?void 0:l.find(e=>{var t,l;return((null==(t=e.value)?void 0:t.id)||(null==(l=e.value)?void 0:l.name)||e.value)===((null==a?void 0:a.id)||(null==a?void 0:a.name)||a)}))?void 0:r.label)||a||t.placeholder})},searchPlaceholder:`${h("common.search")} ${t.label}`,handleSearch:t.handleSearch,searchValue:t.searchValue||"",onChange:(e,a)=>{var l,r;let n=null==(l=null==e?void 0:e.target)?void 0:l.value;if(t.is_multiselect){const e=null==(r=null==a?void 0:a.props)?void 0:r.value;s.find(t=>(null==t?void 0:t.name)==(null==e?void 0:e.name))&&(n=s.filter(t=>(null==t?void 0:t.name)!=(null==e?void 0:e.name))),n=null==n?void 0:n.filter(Boolean)}d(n),t.onChange&&t.onChange(n)},loading:null==t?void 0:t.is_loading,children:Mt({options:l,multiple:Boolean(t.is_multiselect),placeholder:t.placeholder,values:s,with_checkboxes:!0,field:t})}),t.is_multiselect&&Array.isArray(s)&&e.jsx(At,{data:s,options:l})]})};Nt.propTypes={name:a.PropTypes.string.isRequired,placeholder:a.PropTypes.string.isRequired,label:a.PropTypes.string.isRequired,size:a.PropTypes.string,options:a.PropTypes.arrayOf(a.PropTypes.shape({label:a.PropTypes.string,value:a.PropTypes.string})).isRequired,defaultValue:a.PropTypes.string,fieldArrayName:a.PropTypes.string,id:a.PropTypes.string,required:a.PropTypes.bool,is_multiselect:a.PropTypes.bool,position:a.PropTypes.number,disabled:a.PropTypes.bool,onChipRemove:a.PropTypes.func,enable_footer:a.PropTypes.bool,footer_action:a.PropTypes.string,onFooterClick:a.PropTypes.any,is_loading:a.PropTypes.bool,selectedLabel:a.PropTypes.string,onChange:a.PropTypes.func};const Bt=({buttons:t,dropdownMenuButtonData:a=null,toggleCallback:l,className:r,zIndex:i=999})=>e.jsxs("div",{className:r,children:[null==t?void 0:t.map(t=>e.jsx(o.Button,{className:t.class?t.class:`wrapper--${null==t?void 0:t.btnStyle}`,variant:t.variant?t.variant:"contained",startIcon:t.icon?t.icon:"",disabled:Boolean(t.disabled),onClick:t.action,children:t.title??""},t.title)),a&&e.jsx("div",{style:{zIndex:i},children:e.jsx(n.DropdownButton,{options:a.options||[],startIcon:a.icon,isMenuThirdItemDisabled:!0,isOnlyDropDownButton:!0,variant:"text",buttonGroupProps:{variant:"text",sx:({palette:e})=>({"& .MuiButton-root":{border:"1px solid !important",borderColor:`${e.grey[200]} !important`,borderRadius:"20px",pt:.25,pb:.25,pr:.75,color:`${e.grey[800]} !important`,":hover":{bgcolor:`${e.grey[200]} !important`}}})},onlyDropDownButtonProps:{style:{backgroundColor:"white !important",color:"black !important",...a.sx}},toggleCallback:l,children:a.children})})]}),Et=[{header:"Report name",accessorKey:"name",visible:!0,type:"string"},{header:"Email ID",accessorKey:"emails",visible:!0,type:"custom"},{header:"Date",accessorKey:"schedule_date",visible:!0,type:"date"},{header:"Time",accessorKey:"schedule_time",visible:!0,type:"time"},{header:"Recurring",accessorKey:"autopost",visible:!0,type:"string"},{header:"Report Page",accessorKey:"report_data.name",visible:!0,type:"string"},{header:"Main Page",accessorKey:"main_page",visible:!0,type:"string"},{header:"Status",accessorKey:"status",visible:!0,type:"status"}],Rt="schedule_report",It={schedule_report:{schedule_date:p(),schedule_time:p()}},Pt={type:"type",autopost:e=>(null==e?void 0:e.is_recurring)?null==e?void 0:e.autopost:void 0,emails:"emails",id:e=>(null==e?void 0:e.id)||void 0,is_recurring:e=>Boolean(null==e?void 0:e.is_recurring),name:"name",next_schedule_date:"next_schedule_date",schedule_date:"schedule_date",schedule_time:"schedule_time",subject:"subject",report_id:"report_id",filters:e=>(null==e?void 0:e.filters)||void 0},Ft=e=>o.o(Le.object().shape({[Rt]:Le.object().shape({report_id:e?Le.string().required("Report is required"):Le.string(),name:Le.string().required("Report name is required"),subject:Le.string(),schedule_date:Le.mixed().required("Date is required").test("is-future-date","Date cannot be in the past",e=>{if(!e)return!1;const t=p(e).startOf("day"),a=p().startOf("day");return t.isSame(a)||t.isAfter(a)}),schedule_time:Le.mixed().required("Time is required").test("is-future-time","Time cannot be in the past",function(e){const{schedule_date:t}=this.parent;if(!e||!t)return!1;const a=p(t).startOf("day"),l=p().startOf("day");if(a.isAfter(l))return!0;const r=p(),n=p(e);return p(t).hour(n.hour()).minute(n.minute()).second(0).isAfter(r)}),email:Le.array(),emails:Le.string().test("emails-required","Email is required",function(e){const{email:t}=this.parent;return!(!(null==t?void 0:t.length)&&!e)}),is_recurring:Le.boolean(),autopost:Le.string().when("is_recurring",{is:!0,then:e=>e.required("Auto post is required"),otherwise:e=>e.optional().nullable()})})})),$t=[{label:"Day",value:"Day"},{label:"Week",value:"Week"},{label:"Month",value:"Month"},{label:"3 month",value:"3 month"},{label:"6 month",value:"6 month"},{label:"1 Year",value:"1 Year"}],zt=async e=>T.putV1ReportsUpdateScheduleReportId(e),qt=async e=>T.postV1ReportsScheduleReport(e),Ot=({label:a,isOpen:l=!1,modalProps:r,itemData:s,onSubmit:d,onClose:m,module:x="accounting",filters:g,report:y=null})=>{const[v,f]=i.useState(!1),{control:b,handleSubmit:w,reset:C,setValue:S,watch:_,trigger:D}=t.useForm({resolver:Ft(!(null==s?void 0:s.id)),mode:"all",shouldUnregister:!0,defaultValues:It}),M=_(`${Rt}.is_recurring`),A=i.useMemo(()=>!(!(null==s?void 0:s.id)&&!y),[null==s?void 0:s.id,y]),N=async e=>{if(!(await D()))return;const t=null==e?void 0:e[Rt],a={...t,type:x,filters:g,schedule_date:j.formatDateForPayload(t.schedule_date),schedule_time:j.formatTimeForPayload(t.schedule_time),...s&&(null==s?void 0:s.id)?{id:String(s.id)||""}:{}};null==a||delete a.email;const l=j.mapApiPayload(Pt,a),r=(null==s?void 0:s.id)?zt:qt;try{await r({...l,...j.getToken()}),null==d||d(),k.enqueueSnackbar("Report scheduled successfully",{}),B()}catch(n){const e=j.getErrorMessage(null==n?void 0:n.message);k.enqueueSnackbar(e,{variant:"error"})}finally{f(!1)}},B=()=>{m(),setTimeout(()=>{C({[Rt]:{}})},300)},E=i.useCallback(async()=>{var e,t;if(console.log("report",y),l&&y)try{const{data:a={}}=await(async e=>{try{return await T.getV1ReportsReportList(e)}catch(t){console.log("error",t)}})({...j.getToken(),filters:`(name.like=%${y}%)`});S(`${Rt}.report_id`,null==(t=null==(e=null==a?void 0:a.reports)?void 0:e[0])?void 0:t.id)}catch(a){console.log("error",a)}},[y,l,S]);i.useEffect(()=>{var e,t;const a=null==(t=null==(e=null==s?void 0:s.schedule_time)?void 0:e.split(":"))?void 0:t.map(Number);(null==s?void 0:s.id)?C({[Rt]:{...s,schedule_date:(null==s?void 0:s.schedule_date)?p(null==s?void 0:s.schedule_date):"",schedule_time:3===(null==a?void 0:a.length)?p().set("hour",a[0]).set("minute",a[1]).set("second",a[2]).set("millisecond",0):""}}):C(It)},[l,null==s?void 0:s.id,x]);const R=_(`${Rt}.schedule_date`);i.useEffect(()=>{R&&D(`${Rt}.schedule_time`)},[R,D]);const I=i.useMemo(()=>R&&p(R).startOf("day").isSame(p().startOf("day")),[R]);return i.useEffect(()=>{E()},[E]),e.jsx(o.Modal,{open:l,onClose:m,maxWidth:"md",fullWidth:!0,...r,children:e.jsxs("form",{onSubmit:w(N),id:"scheduleReportModal",children:[v&&e.jsx(n.ModalLoader,{}),e.jsxs(u.DialogTitle,{className:"scheduleReportModal--Title",children:[e.jsx(h.Typography,{type:"s3",color:"inherit",weight:"medium",children:a||"Schedule"}),e.jsx(u.IconButton,{onClick:B,children:e.jsx(c.Close,{fontSize:"small"})})]}),e.jsx(u.DialogContent,{children:e.jsxs(u.Grid,{container:!0,rowGap:1.5,columnSpacing:3,pt:3,children:[e.jsx(u.Grid,{item:!0,sm:12,children:e.jsx(u.Grid,{item:!0,sm:6,children:e.jsx(n.DynamicSearchSelect,{disabled:Boolean(null==s?void 0:s.id)||A,label:"Report",apiType:"reports",name:"report_id",placeholder:"Select report",fieldArrayName:Rt,formControl:b,required:!0,customeFilter:{"&type.eq":x,"&allow_scheduling.eq":1}})})}),e.jsx(u.Grid,{item:!0,sm:6,children:e.jsx(o.DynamicInput,{type:"text",formControl:b,label:"Report name",name:"name",fieldArrayName:Rt,placeholder:"Enter Report Name",required:!0})}),e.jsx(u.Grid,{item:!0,sm:6,children:e.jsx(o.DynamicInput,{type:"text",formControl:b,label:"Subject",name:"subject",fieldArrayName:Rt,placeholder:"Enter Subject"})}),e.jsx(u.Grid,{item:!0,sm:6,children:e.jsx(n.DynamicDate,{formControl:b,name:"schedule_date",placeholder:"DD-MM-YYYY",label:"Date",fieldArrayName:Rt,required:!0,min_date:p()})}),e.jsx(u.Grid,{item:!0,sm:6,children:e.jsx(n.DynamicTime,{formControl:b,placeholder:"hh:mm",label:"Time",option:"24hr",name:"schedule_time",fieldArrayName:Rt,required:!0,rest:{timeSteps:{minutes:1},ampm:!1,...I&&{minTime:p()}}})}),e.jsx(u.Grid,{item:!0,xs:12,children:e.jsx(n.ChipGenerator,{control:b,name:"emails",label:"Email",required:!0,fieldArrayName:Rt,placeholder:"Enter Emails: example1@mail.com, example2@mail.com",validation:[{type:"email",message:"Please enter a valid email address",pattern:/^[^\s@]+@[^\s@]+\.[^\s@]+$/}]})}),e.jsx(u.Grid,{item:!0,sm:12,children:e.jsx(n.DynamicCheckBox,{formControl:b,name:"is_recurring",title:"Recurring",fieldArrayName:Rt,titlePosition:"end"})}),M?e.jsx(u.Grid,{item:!0,sm:6,children:e.jsx(n.DynamicSearchSelect,{label:"Auto Post",options:$t||[],name:"autopost",placeholder:"Select Auto Post",fieldArrayName:Rt,formControl:b,required:!0})}):null]})}),e.jsx(u.DialogActions,{className:"scheduleReportModal--ActionContainer",children:e.jsxs(u.Box,{display:"flex",gap:1.5,children:[e.jsx(o.Button,{className:"scheduleReportModal--ActionContainer--WhiteBtn",onClick:B,disabled:v,children:"Discard"}),e.jsx(o.Button,{type:"button",onClick:w(N),endIcon:v?e.jsx(u.CircularProgress,{size:20,color:"inherit"}):void 0,disabled:v,children:"Schedule"})]})})]})})};function Lt({snackbarKey:t}){const{closeSnackbar:a}=k.useSnackbar();return e.jsx(u.Box,{children:e.jsx(pe,{onClick:()=>a(t),sx:{width:20,height:20},children:e.jsx(l,{sx:{color:"#fff",width:16,height:16}})})})}const Yt=({open:t,onClose:a,onReplace:l,onKeepBoth:r,title:n,isFile:s})=>(i.useEffect(()=>{},[t]),e.jsxs(u.Dialog,{open:t,className:"filter-container",onClose:a,children:[e.jsxs(u.DialogTitle,{className:"filter-header",sx:{padding:"20px"},children:[" ",e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:"Confirmation"}),e.jsx(u.IconButton,{size:"small",onClick:a,children:e.jsx(c.Close,{fontSize:"small"})})]}),e.jsx(u.DialogContent,{sx:{marginTop:"20px"},children:e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:s?`The destination already has a file named ${n}`:"The destination already has a folder name "})}),e.jsxs(u.DialogActions,{className:"filter-footer",children:[e.jsx(o.Button,{className:"cancel-filter-btn",onClick:r,children:"Keep Both"}),e.jsx(o.Button,{onClick:l,children:"Replace"})]})]})),Wt=(e,t=2)=>{if(0===e)return"0 Bytes";const a=t<0?0:t,l=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,l)).toFixed(a))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][l]},Vt=({data:t,placeholder:a,onDelete:l,chipProps:r})=>e.jsx(e.Fragment,{children:t.length?e.jsx(S.Chip,{variant:"outlined",type:"normal",label:`${t.length} Selected`,deleteIcon:e.jsx(c.Close,{fontSize:"large"}),onDelete:l,onMouseDown:e=>e.stopPropagation(),...r}):e.jsx(h.Typography,{color:"inherit",type:"s3",children:a})}),Kt=({data:t,options:a})=>{const l=t.map(e=>{var t;return(null==(t=a.find(t=>t.value===e))?void 0:t.text)||e});return e.jsxs(h.Typography,{type:"s4",color:"inherit",sx:{display:"flex",gap:1,alignItems:"center",mt:.5},children:[l.slice(.4).join(", "),t.length>4&&e.jsx(S.Chip,{variant:"outlined",type:"normal",label:e.jsx(_.MoreIcon,{})})]})},Ht=({options:t,multiple:a,placeholder:l,with_checkboxes:r,onChange:o,values:i})=>{const s=[];return a||s.push(e.jsx(u.MenuItem,{disabled:!0,value:"",children:e.jsx("em",{children:l})})),t.forEach(t=>{s.push(e.jsx(u.MenuItem,{value:t.value,className:(null==t?void 0:t.isGroup)?"select--MenuItemHeader":"",children:e.jsxs(u.Box,{sx:{display:"flex",gap:1},children:[a&&r&&e.jsx(n.Checkbox,{checked:(null==i?void 0:i.indexOf(t.value))>-1,onChange:()=>((e,t)=>{const a=t.map(e=>e.value),l=i.includes(e)?i.filter(t=>t!==e&&!a.includes(t)):[...i,e,...a];o(l)})(t.value,t.options||[])}),e.jsx(h.Typography,{type:"s4",color:"inherit",children:t.text})]})})),(null==t?void 0:t.isGroup)&&Array.isArray(null==t?void 0:t.options)&&t.options.forEach(t=>{s.push(e.jsx(u.MenuItem,{value:t.value,sx:{pl:5},children:e.jsxs(u.Box,{sx:{display:"flex",gap:1},children:[a&&r&&e.jsx(n.Checkbox,{checked:(null==i?void 0:i.indexOf(t.value))>-1}),e.jsx(h.Typography,{type:"s4",color:"inherit",children:t.text})]})}))})}),s},Ut=({column:t,row:a,col:l,errors:r,validationSchema:s,setValidationErrors:d,onChangeRowField:c,getSelectedData:m,syncFieldValue:x})=>{var g,y,v,f,b,j,w,C;const[S,T]=i.useState(),[k,_]=i.useState(!1),D=i.useRef(null),M=a.getAllCells().map(e=>e.column.columnDef).filter(e=>void 0===(null==e?void 0:e.enableEditing)||!0===(null==e?void 0:e.enableEditing)),A=l.editVariant,N=(null==(g=t.columnDef)?void 0:g.editProperties)||{};let B=!1;(null==N?void 0:N.disable)&&(B="function"==typeof N.disable?Boolean(null==N?void 0:N.disable(a,a._valuesCache)):Boolean(N.disable));const E=i.useCallback(async(e,t)=>{try{if("function"==typeof N.customeFilter){const a=await N.customeFilter(e,t);return D.current=a,a}D.current=null==N?void 0:N.customeFilter}catch(a){return null}},[N,a,a._valuesCache]);i.useEffect(()=>{E(a,a._valuesCache)},[E,a,a._valuesCache]);const R=null==N?void 0:N.valueKey;let I="";if("select"===A&&(null==N?void 0:N.is_multiple))I=R?de.get(a.original,R,[]):[];else if(I=R?de.get(a.original,R,a.original[t.id]):a.original[t.id],"select"===A&&("string"==typeof I||"number"==typeof I)&&(null==l?void 0:l.editSelectOptions)){const e=l.editSelectOptions.find(e=>e.value===I||e.id===I||e.name===I||String(e.id)===String(I));e&&(I=e)}const P=async(e,n,o)=>{const i=o;let u;switch(n){case"date":case"file":case"image":case"phone":case"time":u=e;break;case"text":case"number":default:u=e.target.value;break;case"checkbox":u=e.target.checked}if(T({...S,[t.id]:u}),c){const t=await c(e,n,a,l,i);t&&(a._valuesCache={...a._valuesCache,...t},T({...S,...t}))}T({...S,[t.id]:u}),a._valuesCache={...a._valuesCache,[t.id]:u},x(a.id,t.id,u),await(async e=>{try{await s.validateAt(t.id,{[t.id]:e},{abortEarly:!1});const a={};for(const e in r)e!=t.id&&(a[e]=r[e]);d(a)}catch(a){if(a instanceof Le.ValidationError){const e={};a.inner.forEach(t=>{t.path&&(e[t.path]=t.message)});const t={...r,...e};d(t)}}})(u)};return i.useEffect(()=>{T({...S,...a._valuesCache})},[a._valuesCache]),i.useEffect(()=>{if(!k){const e=Object.keys(a._valuesCache||{}),t={};a.getAllCells().forEach(l=>{var r,n,o;if(void 0===(null==(r=l.column.columnDef)?void 0:r.enableEditing)||!0===(null==(n=l.column.columnDef)?void 0:n.enableEditing)){const{is_multiple:r,valueKey:n}=(null==(o=l.column.columnDef)?void 0:o.editProperties)||{};if(e.includes(l.column.id)){const e=de.get(a.original,n);t[l.column.id]="select"===A&&r?e?Array.isArray(e)?e:[e]:[]:"date"===A||"date_time"===A||"time"===A?e?p(e).isValid()?p(e):void 0:p(a.original[l.column.id]).isValid()?p(a.original[l.column.id]):void 0:de.get(a.original,n,a.original[l.column.id])}}}),a._valuesCache=t,T(t),_(!0)}},[a,A,k]),e.jsxs(e.Fragment,{children:[(!A||"number"===A)&&e.jsx(o.TextField,{defaultValue:I,onChange:e=>P(e,A),value:null==S?void 0:S[t.id],autoFocus:(null==(y=null==M?void 0:M[0])?void 0:y.accessorKey)===t.id,type:A||"text",error:!!(null==r?void 0:r[t.id]),helperText:null==r?void 0:r[t.id],placeholder:(null==N?void 0:N.placeholder)||"",name:(null==N?void 0:N.field_name)||"",disabled:B}),"select"===A&&e.jsxs(u.Box,{display:"flex",flexDirection:"column",width:"100%",children:[e.jsx(n.SearchableSelect,{name:(null==N?void 0:N.field_name)||"",defaultValue:I,placeholder:(null==N?void 0:N.placeholder)||"",searchPlaceholder:`Search ${l.header}`,onChange:(e,t)=>P(e,"select",t),apiType:null==N?void 0:N.apiType,autoFocus:(null==(v=null==M?void 0:M[0])?void 0:v.accessorKey)===t.id,options:null==l?void 0:l.editSelectOptions,customeFilter:D.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==S?void 0:S[t.id])?null==S?void 0:S[t.id]:[]:null==S?void 0:S[t.id],getSelectedData:e=>m(null==N?void 0:N.field_name,e)}),(null==r?void 0:r[t.id])&&e.jsx(h.Typography,{color:"theme.error.600",type:"s5",children:null==r?void 0:r[t.id]})]}),"date"===A&&e.jsx(n.DatePicker,{name:(null==N?void 0:N.field_name)||"",defaultValue:I,onChange:e=>P(e,"date"),textFieldProps:{autoFocus:(null==(f=null==M?void 0:M[0])?void 0:f.accessorKey)===t.id},error:!!(null==r?void 0:r[t.id]),helperText:null==r?void 0:r[t.id],format:null==N?void 0:N.dateFormat,placeholder:(null==N?void 0:N.placeholder)||(null==N?void 0:N.dateFormat),value:p(a._valuesCache[t.id]).isValid()?p(a._valuesCache[t.id]):void 0,disabled:B,minDate:null==N?void 0:N.min_date,maxDate:null==N?void 0:N.max_date}),"date_time"===A&&e.jsx(n.DateTimePicker,{name:(null==N?void 0:N.field_name)||"",defaultValue:I,onChange:e=>P(e,"date"),textFieldProps:{autoFocus:(null==(b=null==M?void 0:M[0])?void 0:b.accessorKey)===t.id},error:!!(null==r?void 0:r[t.id]),helperText:null==r?void 0:r[t.id],format:null==N?void 0:N.dateFormat,placeholder:(null==N?void 0:N.placeholder)||(null==N?void 0:N.dateFormat),value:p(a._valuesCache[t.id]).isValid()?p(a._valuesCache[t.id]):void 0,disabled:B}),"time"===A&&e.jsx(n.TimePicker,{name:(null==N?void 0:N.field_name)||"",label:"",value:p(a._valuesCache[t.id]).isValid()?p(a._valuesCache[t.id]):void 0,onChange:e=>P(e,"time"),error:!!(null==r?void 0:r[t.id]),helperText:null==r?void 0:r[t.id],placeholder:(null==N?void 0:N.placeholder)||"HH:mm A",disabled:B,is24hrFormat:null==N?void 0:N.is24hrFormat}),("file"===A||"image"===A)&&e.jsxs(u.Box,{display:"flex",flexDirection:"column",children:[e.jsx(n.UploadMedia,{name:(null==N?void 0:N.field_name)||"table_file",dataPosition:0,dataName:"table_file",label:"",type:A,max_size:10,onChange:e=>P(e,"file"),error:!!(null==r?void 0:r[t.id]),multiple:Boolean(null==t?void 0:t.is_multiple),value:a._valuesCache[t.id]}),(null==r?void 0:r[t.id])&&e.jsx(h.Typography,{color:"theme.error.600",type:"s5",children:null==r?void 0:r[t.id]})]}),"phone"===A&&e.jsx(n.PhoneInput,{name:(null==N?void 0:N.field_name)||"",default_value:I,onChange:e=>P(e,"phone"),textFieldProps:{autoFocus:(null==(j=null==M?void 0:M[0])?void 0:j.accessorKey)===t.id},error:!!(null==r?void 0:r[t.id]),helperText:null==r?void 0:r[t.id],format:null==N?void 0:N.dateFormat,placeholder:(null==N?void 0:N.placeholder)||(null==N?void 0:N.dateFormat),value:null==(w=a._valuesCache)?void 0:w[t.id],disabled:B,isInlineEditing:!0}),"checkbox"===A&&e.jsx(n.Checkbox,{name:(null==N?void 0:N.field_name)||"",defaultChecked:Boolean(I),onChange:e=>P(e,"checkbox"),error:!!(null==r?void 0:r[t.id]),helperText:null==r?void 0:r[t.id],format:null==N?void 0:N.dateFormat,placeholder:(null==N?void 0:N.placeholder)||(null==N?void 0:N.dateFormat),value:null==(C=a._valuesCache)?void 0:C[t.id],disabled:B})]})},Gt=u.styled(u.Box)(({theme:{palette:e}})=>{var t,a,l,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":{maxHeight:"clamp(350px, 100vh - 200px, 9999px) !important"},".MuiPaper-root":{boxShadow:"none"},".MuiPaginationItem-root":{"&.Mui-selected":{backgroundColor:null==(a=null==e?void 0:e.theme)?void 0:a.primary[700],color:"white"}},".MuiTableRow-root":{"&.Mui-selected":{backgroundColor:`${null==(l=null==e?void 0:e.theme)?void 0:l.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"}}}}),Xt=i.memo(({enablePagination:t=!1,rows:a,columns:l,totalPages:n,paginationModel:s,columnOrder:c,updateData:m,handleColumnOrdering:x,enableEditing:g,enableColumnDragging:y,states:v,rowActionMenu:f,destructiveActionMenu:b,disableDefaultActionColumn:j,enableRowSelection:C,defaultActionColumnItems:T=[],enableBottomToolbar:D,SetSelectedRowId:M,isResetRow:A,onCreateRow:N,onEditRow:B,onDeleteRow:E,editDisplayMode:R,enableRowCreate:I,onChangeRowField:P,onSelectRow:F,enableColumnResizing:$=!0,selectedRowIds:z=[],onColumnVisibility:q,onSortingChange:O,getSelectedData:L,disabledDefaultActionColumnIcon:Y=!1,enableAddCustomField:V=!0,enableRowDragging:K=!1,handleColumnResizing:H=()=>{},columnSizes:U={},hideSaveButton:G=!1,hideDeleteButton:X,enableFirstRowEdit:J=!1,...Q})=>{const{t:Z}=w.useTranslation(),{formData:ee=null,updatePageInfo:te,activePage:ae}=ce.usePages(),le=ce.useDeepMemo(ae),{pageNo:re}=s,[ne,oe]=i.useState({}),[ie,se]=i.useState(l),[de,ue]=i.useState(null),[me,pe]=i.useState(!1),[he,xe]=i.useState(null),ge=ie.filter(e=>e.visible),ye=ie.filter(e=>!e.visible),[ve,fe]=i.useState(ye),[be,je]=i.useState(null),[we,Ce]=i.useState({}),[Se,Te]=i.useState([]),[Be,Ee]=i.useState(!1),[Re,Ie]=i.useState(!1),[Pe,Fe]=i.useState(!1),[$e,ze]=i.useState(null),[qe,Oe]=i.useState({}),[Ye,We]=i.useState(!1),[Ve,Ke]=i.useState([]),[He,Ue]=i.useState(!1),[Ge,Xe]=i.useState(le.column_sizes),[Je,Qe]=i.useState({columnSizingStart:[],deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,startOffset:null,startSize:null});i.useState(0);const Ze=W.useNavigate(),et=location.pathname.split("/")[2];let tt="";switch(et){case"accounting":tt=Ae.PathnameAccounting.CUSTOM_FORM;break;case"inventory":tt=Ae.PathnameInventory.CUSTOM_FORM;break;case"manufacturing":tt=Ae.PathnameManufacturing.CUSTOM_FORM;break;case"procurement":tt=Ae.PathnamePurchase.CUSTOM_FORM;break;case"crm":tt=Ae.PathnameCrm.CUSTOM_FORM;break;case"user":tt=Ne.PathnameUsers.CUSTOM_FORM;break;case"rental":tt=Ae.PathnameRental.CUSTOM_FORM;break;case"drive":tt=Me.PathnameDocument.ADD_CUSTOM_FIELDS}const at=`/dashboard/${et}${tt}`,lt=(e,t,a)=>{var l;let r=e;switch(t.type){case"required":t.value?(r=r.required(t.msg_en).typeError(t.msg_en),(null==a?void 0:a.editVariant)&&"text"!==(null==a?void 0:a.editVariant)||(r=r.test("no-blank-spaces","Blank space is not allowed",e=>"string"!=typeof e||e.trim().length>0))):(null==(l=null==a?void 0:a.editProperties)?void 0:l.is_multiple)&&(r=r.min(1,t.msg_en));break;case"notRequired":r=r.notRequired();break;case"nullable":r=r.nullable(t.value??!0);break;case"defined":r=r.defined(t.msg_en);break;case"optional":r=r.optional();break;case"strict":r=r.strict(t.value??!0);break;case"typeError":r=r.typeError(t.msg_en);break;case"oneOf":r=r.oneOf(t.values,t.msg_en);break;case"notOneOf":r=r.notOneOf(t.values,t.msg_en);break;case"default":r=r.default(t.value);break;case"transform":r=r.transform(t.fn);break;case"label":r=r.label(t.value);break;case"meta":r=r.meta(t.value);break;case"trim":r=r.trim();break;case"lowercase":r=r.lowercase();break;case"uppercase":r=r.uppercase();break;case"email":r=r.email(t.msg_en);break;case"url":r=r.url(t.msg_en);break;case"uuid":r=r.uuid(t.msg_en);break;case"length":r=r.length(t.value,t.msg_en);break;case"min":case"minItems":case"minDate":r=r.min(t.value,t.msg_en);break;case"max":case"maxItems":case"maxDate":r=r.max(t.value,t.msg_en);break;case"matches":r=r.matches(t.regex,t.msg_en);break;case"startsWith":r=r.matches(new RegExp(`^${t.value}`),t.msg_en);break;case"endsWith":r=r.matches(new RegExp(`${t.value}$`),t.msg_en);break;case"lessThan":r=r.lessThan(t.value,t.msg_en);break;case"moreThan":r=r.moreThan(t.value,t.msg_en);break;case"positive":r=r.positive(t.msg_en);break;case"negative":r=r.negative(t.msg_en);break;case"integer":r=r.integer(t.msg_en);break;case"round":r=r.round(t.method||"round");break;case"truncate":r=r.truncate();break;case"ensure":r=r.ensure();break;case"compact":r=r.compact(t.rejector);break;case"of":r=r.of(t.schema);break;case"shape":r=r.shape(t.fields);break;case"noUnknown":r=r.noUnknown(t.value??!0,t.msg_en);break;case"test":r=r.test(t.name||"custom-test",t.msg_en,t.testFn);break;case"when":return r.when(t.relation,{is:e=>"function"==typeof t.is?t.is(e):Array.isArray(t.values)?t.values.includes(e):e===t.values,then:e=>{var l;return(null==(l=null==t?void 0:t.thenValidations)?void 0:l.reduce((e,t)=>lt(e,t,a),e))||e},otherwise:e=>{var l;return(null==(l=null==t?void 0:t.otherWiseValidations)?void 0:l.reduce((e,t)=>lt(e,t,a),e))||e}})}return r};i.useEffect(()=>{se(l);const e=l.reduce((e,t)=>{var a;const l=null==(a=null==t?void 0:t.editProperties)?void 0:a.validations;if(!(null==l?void 0:l.length))return e;const r=(e=>{var t;switch(e.editVariant){case"select":return(null==(t=null==e?void 0:e.editProperties)?void 0:t.is_multiple)?Le.array():Le.string();case"number":return Le.number().nullable().transform((e,t)=>""===t?null:e);case"url":return Le.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 Le.string()}})(t);return e[t.accessorKey]=l.reduce((e,a)=>lt(e,a,t),r),e},{});Te(Le.object().shape(e))},[l]),i.useEffect(()=>{(null==Je?void 0:Je.isResizingColumn)||(te({column_sizes:{...le.column_sizes,...Ge}}),null==H||H(Ge))},[null==Je?void 0:Je.isResizingColumn,Ge]);const rt=e=>{ue(e.currentTarget)},nt=i.useCallback((e,t)=>{const a={};return(null==e?void 0:e["mrt-row-actions"])&&delete e["mrt-row-actions"],Object.keys(e).forEach(l=>{const r=e[l],n=t.find(e=>e.accessorKey==l);r?r instanceof File?a[l]=r.name:n&&"date"==(null==n?void 0:n.editVariant)?a[l]=p(r).format((null==n?void 0:n.dateFormat)||"DD-MM-YYYY"):n&&"select"==(null==n?void 0:n.editVariant)&&"object"==typeof r&&null!==r?a[l]=r.name||r.label||r.display_name||r.title||r.value||r.id||r:(n&&(null==n||n.editVariant),a[l]=r):a[l]=r}),a},[]),ot=i.useCallback(e=>{var t;return null==(t=null==e?void 0:e.validations)?void 0:t.some(e=>"required"===e.type)},[]);i.useEffect(()=>{const e={};!Ye&&z.length&&(a.forEach(t=>{z.includes(t.id)&&(e[t.id]=!0)}),Oe(e),We(!0))},[a,z]),i.useEffect(()=>{if(O instanceof Function){const e=Array.isArray(Ve)?Ve:[];O(e[0]||null)}},[Ve]);const it=e=>{const t=document.createElement("canvas").getContext("2d");return t?t.measureText(e).width+5:50},st=i.useCallback(async({row:e,values:t,table:a},l)=>{const r="edit"===l,n=r?Ie:Ee;try{await Se.validate(t,{abortEarly:!1}),Ce({}),n(!0),Ue(!1);const l=e.getAllCells().map(e=>e.column.columnDef);e._valuesCache=nt(t,l);const o={row:e,values:t,table:a};r?(await(null==B?void 0:B(o,"edit")),a.setEditingRow(null)):(await(null==N?void 0:N(o)),a.setCreatingRow(null))}catch(o){o instanceof Le.ValidationError?Ce((e=>e.inner.reduce((e,{path:t,message:a})=>(t&&(e[t]=a),e),{}))(o)):k.enqueueSnackbar(o instanceof Error?o.message:"Something went wrong",{variant:"error"})}finally{n(!1)}},[Se,B,N,nt]),dt=i.useCallback(async e=>{try{return await Se.validate(e,{abortEarly:!1}),Ce({}),!0}catch(t){return!1}},[Se]),ct=i.useRef({}),ut=i.useCallback((e,t,a)=>{ct.current[e]={...ct.current[e]??{},[t]:a}},[]),mt=i.useCallback(e=>{delete ct.current[e]},[]),pt=i.useCallback(e=>({...e.original,...e._valuesCache,...ct.current[e.id]??{}}),[]),ht=i.useCallback(async e=>{const t=e.getState().editingRow,a=e.getState().creatingRow;if(!t)return;const l=pt(t);await dt(l)?(await st({row:t,values:l,table:e},"edit"),mt(t.id),!a&&I?(Ue(!1),setTimeout(()=>e.setCreatingRow(!0),200)):Ue(!1)):await st({row:t,values:l,table:e},"edit")},[pt,st,mt,dt,I]),xt=i.useCallback(async e=>{const t=e.getState().creatingRow;if(!t)return;const a=pt(t);(null==a?void 0:a["mrt-row-actions"])&&delete a["mrt-row-actions"];const l=await dt(a);await st({row:t,values:a,table:e},"create"),l&&l&&(Ue(!1),mt("mrt-row-create"),setTimeout(()=>e.setCreatingRow(!0),200))},[pt,mt,dt]),gt=ke.useMaterialReactTable({defaultColumn:{minSize:0,size:void 0},columns:[...ge.map(t=>(it(t.header||""),Math.max(...a.map(e=>it(String(e[t.accessorKey]??"")))),{...t,..."row"===R?{Edit:({cell:a,row:l,table:r,column:n})=>e.jsx(Ut,{cell:a,column:n,col:t,row:l,table:r,callback:e=>console.log("Save",e),errors:we,validationSchema:Se,setValidationErrors:Ce,onChangeRowField:P,getSelectedData:(e,t)=>null==L?void 0:L(e,t),syncFieldValue:ut})}:{},Header:e.jsxs(u.Box,{display:"flex",alignItems:"center",children:[t.header,(null==t?void 0:t.required)||ot(null==t?void 0:t.editProperties)&&e.jsx(h.Typography,{type:"s5",color:"theme.error.600",children:"*"})]}),enableColumnDragging:"actions"!==t.id,size:void 0,maxSize:800})),...j?[]:[{id:"actions",enableEditing:!1,size:(null==T?void 0:T.length)>1?80:50,header:e.jsx(u.IconButton,{size:"small",sx:{p:.5,"&:hover":{backgroundColor:"transparent"}},onClick:rt,children:e.jsx("img",{src:d.images.common.arrowIcon,alt:"Arrow Icon"})}),enableColumnDragging:!1,visible:!0,muiTableHeadCellProps:{className:"pinned-column"},muiTableBodyCellProps:{className:"pinned-column",sx:{whiteSpace:"pre-wrap"}},Cell:t=>(null==T?void 0:T.length)?T.map(e=>{const a={...e.props,onClick:()=>e.props.onClick(t)};return i.cloneElement(e,a)}):!Y&&e.jsx(u.IconButton,{onClick:e=>{return a=e,l=t.row.original,oe(l),void xe(a.currentTarget);var a,l},disabled:!(null==f?void 0:f.length)&&!(null==b?void 0:b.length),children:e.jsx("img",{src:d.images.more,alt:"More Icon"})})}]],data:a,muiTablePaperProps:{sx:{tableLayout:"auto"}},columnResizeMode:"onChange",onEditingRowSave:async e=>{await st(e,"edit")},onCreatingRowSave:async e=>{await st(e,"create")},onCreatingRowCancel:()=>(Oe({}),void Ue(!1)),onEditingRowCancel:()=>{Ue(!1)},onSortingChange:(null==v?void 0:v.sorting)?O:Ke,displayColumnDefOptions:{"mrt-row-actions":{Header:e.jsx(u.IconButton,{onClick:rt,size:"small",children:e.jsx("img",{src:d.images.common.arrowIcon,alt:"Arrow Icon"})}),muiTableBodyCellProps:({row:e,table:t})=>{var a,l;const r=(null==(a=t.getState().creatingRow)?void 0:a.id)===e.id,n=(null==(l=t.getState().editingRow)?void 0:l.id)===e.id;return{sx:{"& .MuiBox-root":{gap:0},backgroundColor:"#fff",whiteSpace:"pre-wrap",...G&&(n||r)?{"& .MuiBox-root > .MuiIconButton-root:first-of-type":{display:"none !important"},'& button[aria-label*="Save"]':{display:"none !important"},'& button[title*="Save"]':{display:"none !important"},'& .MuiIconButton-root[class*="save"]':{display:"none !important"},'& .MuiIconButton-root[data-testid*="save"]':{display:"none !important"}}:{}}}}},"mrt-row-expand":{size:70},"mrt-row-select":{size:50}},renderRowActions:({row:t,table:a})=>e.jsx(e.Fragment,{children:(null==Q?void 0:Q.enableExpanding)?e.jsx(e.Fragment,{children:(null==t?void 0:t.parentId)&&e.jsx(u.Box,{sx:{display:"flex",gap:0},children:E&&!(null==X?void 0:X(t.original))&&e.jsx(o.Tooltip,{title:"Delete",children:e.jsx(u.IconButton,{disabled:He,onClick:()=>ze(t),size:"small",className:"delete-row",children:e.jsx(_.Trash,{fontSize:"small",sx:{color:"theme.secondary.1000"}})})})})}):e.jsx(u.Box,{sx:{display:"flex",gap:0},children:E&&!(null==X?void 0:X(t.original))&&e.jsx(o.Tooltip,{title:"Delete",children:e.jsx(u.IconButton,{disabled:He,onClick:()=>ze(t),className:"delete-row",children:e.jsx(_.Trash,{fontSize:"small",sx:{color:"theme.secondary.1000"}})})})})}),...Boolean(I)&&{renderBottomToolbarCustomActions:({table:t})=>e.jsx(o.Button,{variant:"outlined",startIcon:e.jsx(r,{}),className:"add-row-btn",disabled:He,onClick:()=>{t.setCreatingRow(!0),Ue(!0)},children:Z("common.add")})},onRowSelectionChange:Oe,enableColumnOrdering:!0,enableRowSelection:C??!0,enableEditing:e=>g instanceof Function?g(e):g??!0,editDisplayMode:R??"row",createDisplayMode:"row",positionCreatingRow:"bottom",enableColumnResizing:$,enableRowDragging:K,enableTopToolbar:!1,enableColumnActions:!1,enableSorting:!0,enableGrouping:!0,enableBottomToolbar:D??!1,enableColumnDragging:y??!0,enableStickyHeader:!0,enableSortingRemoval:!1,state:{columnOrder:c,columnPinning:{left:["actions","mrt-row-actions"]},isSaving:Be||Re,showProgressBars:!1,rowSelection:qe,...v,sorting:Array.isArray(null==v?void 0:v.sorting)?null==v?void 0:v.sorting:Array.isArray(Ve)?Ve:[],columnSizing:Ge},getRowId:e=>null==e?void 0:e.id,muiTableBodyRowProps:({row:e,table:t})=>{var a,l,r,n,o,i,s;const d=(null==(l=null==(a=t.getState())?void 0:a.editingRow)?void 0:l.id)||(null==(n=null==(r=t.getState())?void 0:r.creatingRow)?void 0:n.id)||null;null==(i=null==(o=t.getState())?void 0:o.creatingRow)||i.id;const c=Boolean(null==(s=null==e?void 0:e.original)?void 0:s.has_error);return{onClick:()=>{je(e.id)},sx:{cursor:"pointer",backgroundColor:d?"inherit":c?"theme.error.100":"inherit","&:hover":{backgroundColor:d?d===e.id?"transparent":"inherit":c?"theme.error.200":"#e8e8e8"},"&:hover td:after":{backgroundColor:"transparent"}}}},onColumnOrderChange:e=>{x&&x(e)},onColumnSizingChange:Xe,onColumnSizingInfoChange:Qe,renderEmptyRowsFallback:()=>e.jsxs(u.Box,{className:"no-data",children:[e.jsx("img",{src:d.images.common.tableNoData}),e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:Z("common.noData")})]}),enablePagination:t,paginationDisplayMode:"pages",muiPaginationProps:{shape:"rounded",page:re,count:n,showRowsPerPage:!1,boundaryCount:3},muiEditTextFieldProps:({row:e,column:t})=>({InputProps:{disableUnderline:!0},onBlur:a=>{m(a.target.value,t,e.id)},variant:"outlined",sx:({palette:e})=>{var t;return{"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:`${null==(t=e.theme)?void 0:t.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:({cell:e,column:t,table:a,row:l})=>({sx:{lineHeight:"140%",letterSpacing:"-0.26px",fontWeight:"400",fontSize:"0.8125rem","&.pinned-column":{backgroundColor:"#fff"},"&:hover":{backgroundColor:"transparent"},whiteSpace:"pre-wrap"},onClick:e=>{var r,n,o,i;const s=e.target.closest(".MuiTableCell-body");if(!s||s.querySelector(".delete-row"))return;if(!1===t.columnDef.isOnClickEditable)return;const d=(null==(n=null==(r=a.getState())?void 0:r.editingRow)?void 0:n.id)||(null==(i=null==(o=a.getState())?void 0:o.creatingRow)?void 0:i.id)||null,c=d===l.id;d&&d!==l.id||He||c||d||(a.setEditingRow(l),Ue(!0))},onKeyUp:e=>{var t;const r=(null==(t=a.getState().creatingRow)?void 0:t.id)??null;if("Escape"===e.key){if(r===l.id)mt("mrt-row-create"),a.setCreatingRow(null);else{const e=a.getState().editingRow;e&&(st({row:e,values:e.original,table:a},"edit"),mt(e.id))}return Ue(!1),Ce({}),e.preventDefault(),void e.stopPropagation()}"Enter"===e.key&&setTimeout(()=>{const e=a.getState().creatingRow,t=a.getState().editingRow;e&&xt(a),t&&ht(a)},0)}}),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(_.RecgtangleIcon,{sx:{width:20,height:20}}),checkedIcon:e.jsx(_.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(_.RecgtangleIcon,{sx:{width:20,height:20}}),checkedIcon:e.jsx(_.CheckBoxIcon,{sx:{width:20,height:20}})},muiBottomToolbarProps:{sx:{boxShadow:"none","& .MuiBox-root":{paddingLeft:0}}},layoutMode:"grid",icons:{DragHandleIcon:()=>e.jsx(_.RecgtangleIcon,{fontSize:"medium"}),SortIcon:()=>e.jsx(_.ArrowUpDown,{fontSize:"medium"}),ArrowDownwardIcon:()=>e.jsx(_.ArrowUpDown,{fontSize:"medium"}),ArrowUpwardIcon:()=>e.jsx(_.ArrowUpDown,{fontSize:"medium"}),ExpandMoreIcon:()=>e.jsx(_.ArrowUpDown,{fontSize:"medium"}),ExpandLessIcon:()=>e.jsx(_.ArrowUpDown,{fontSize:"medium"}),SyncAltIcon:()=>e.jsx(_.ArrowUpDown,{fontSize:"medium"}),CancelIcon:t=>e.jsx(_.Close,{fontSize:"small",...t,color:"theme.secondary.1000"})},...Q});i.useEffect(()=>{var e,t;C&&(null==(e=null==gt?void 0:gt.getSelectedRowModel())?void 0:e.rows)&&(null==M||M(null==(t=null==gt?void 0:gt.getSelectedRowModel())?void 0:t.rows))},[C]),i.useEffect(()=>{if(F)if(null==Q?void 0:Q.enableExpanding){const e=[],t=gt.getState().rowSelection,a=(l,r="")=>{l.forEach((l,n)=>{var o;const i=r?`${r}.${n}`:`${l.id}`;t[i]&&e.push(l),(null==(o=l.subRows)?void 0:o.length)&&a(l.subRows,i)})};a(gt.getRowModel().rows),F(e,qe)}else F(gt.getSelectedRowModel().rows,qe)},[qe,gt]),i.useEffect(()=>{A&&(null==gt||gt.resetRowSelection())},[A,gt]);const yt=i.useRef(!1);return i.useEffect(()=>{if(J&&!yt.current&&(null==a?void 0:a.length)>0){const e=gt.getRowModel().rows[0];e&&(yt.current=!0,e._valuesCache&&0!==Object.keys(e._valuesCache).length||(e._valuesCache={...e.original}),gt.setEditingRow(e),Ue(!0))}},[J,a,gt]),i.useEffect(()=>{if(!gt)return;let e,t,a=0,l=!1;const r=r=>{r.target.closest('.MuiSelect-root, .MuiMenuItem-root, .MuiPopover-root, .MuiList-root, .MuiMenu-list, .MuiButtonBase-root, .MuiFormControl-root, .MuiInputBase-root, .MuiTextField-root, .MuiOutlinedInput-root, .MuiFilledInput-root, .MuiAutocomplete-popper, .MuiPickersPopper-root, [role="option"], [role="listbox"], [role="combobox"]')&&(l=!0,a=Date.now(),t&&clearTimeout(t),e&&clearTimeout(e),e=setTimeout(()=>{l=!1},500))},n=e=>{var r,n;const o=null==(r=gt.getState())?void 0:r.editingRow,i=null==(n=gt.getState())?void 0:n.creatingRow;if(!o&&!i)return;const s=e.target,d=Date.now();l||d-a<300||s.closest(".MRT-TableWrapper")||(t&&clearTimeout(t),t=setTimeout(async()=>{var e,t;const a=null==(e=gt.getState())?void 0:e.editingRow,r=null==(t=gt.getState())?void 0:t.creatingRow;if(!l){if(r){const e=pt(r);return await st({row:r,values:e,table:gt},"create"),mt("mrt-row-create"),void Ue(!1)}if(a){const e=pt(a);await st({row:a,values:e,table:gt},"edit"),mt(a.id),Ue(!1)}}},200))};return document.addEventListener("mousedown",r,!0),document.addEventListener("click",n,!0),()=>{document.removeEventListener("mousedown",r,!0),document.removeEventListener("click",n,!0),e&&clearTimeout(e),t&&clearTimeout(t)}},[gt,st,pt,mt]),e.jsxs(Gt,{className:"MRT-TableWrapper custom-table",children:[e.jsx(ke.MaterialReactTable,{table:gt}),e.jsx(S.Menu,{anchorEl:de,open:Boolean(de),onClose:()=>{ue(null)},className:"add-role-drp",children:me?e.jsxs("div",{children:[e.jsxs(u.MenuItem,{onClick:()=>{pe(!1)},className:"role-drp-list add-column-title",children:[e.jsx(u.ListItemIcon,{className:"add-icon",children:e.jsx(De,{})}),e.jsx(u.ListItemText,{className:"title",children:Z("common.addColumn_label")})]}),e.jsx(u.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),e.jsx("div",{className:"searchbar-box-list",children:e.jsx(o.SearchBar,{placeholder:"Search User",handleSearch:e=>(e=>{const t=ye.filter(t=>t.header.toLowerCase().includes(e.toLowerCase()));fe(t)})(e)})}),e.jsx("div",{className:"all-attribute-title",children:e.jsx(h.Typography,{variant:"body2",color:"text.secondary",children:Z("common.allAttributes_label")})}),ve.map(t=>e.jsx(u.MenuItem,{onClick:()=>(e=>{const t=ie.map(t=>({...t,visible:t.accessorKey===e.accessorKey||t.visible}));null==q||q(JSON.parse(JSON.stringify(t))),se(t);const a=ve.filter(t=>t.accessorKey!==e.accessorKey);fe(a),ue(null),pe(!1)})(t),children:e.jsx(h.Typography,{color:"theme.secondary.1000",type:"s3",children:t.header})},t.accessorKey)),e.jsx(u.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),V&&e.jsxs(u.MenuItem,{onClick:()=>{Ze(at,{state:ee}),ue(null),pe(!1)},className:"role-drp-list",children:[e.jsx(u.ListItemIcon,{className:"add-icon",children:e.jsx("img",{src:d.images.common.addIcon,alt:"Add Icon"})}),e.jsx(u.ListItemText,{className:"title",children:Z("common.addCustomField_label")})]})]}):e.jsxs(e.Fragment,{children:[ge.map(t=>e.jsxs(u.MenuItem,{onClick:()=>(e=>{const t=ie.map(t=>({...t,visible:t.accessorKey!==e.accessorKey&&t.visible}));se(t),null==q||q(JSON.parse(JSON.stringify(t))),fe([...ve,e]),ue(null)})(t),className:"role-drp-list",children:[e.jsx(u.ListItemIcon,{className:"add-icon",children:e.jsx("img",{src:d.images.common.dotsIcon,alt:"Add Icon"})}),e.jsx(u.ListItemText,{className:"title",children:t.header}),e.jsx(u.ListItemIcon,{className:"eye-icon",children:e.jsx("img",{src:d.images.common.eyeIcon,alt:"Eye Icon"})})]},t.accessorKey)),e.jsx(u.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),e.jsxs(u.MenuItem,{onClick:()=>{pe(!0)},className:"role-drp-list",children:[e.jsx(u.ListItemIcon,{className:"add-icon",children:e.jsx("img",{src:d.images.common.addIcon,alt:"Add Icon"})}),e.jsx(u.ListItemText,{className:"title",children:Z("common.addColumn_label")}),e.jsx(h.Typography,{variant:"body2",color:"text.secondary",className:"eye-icon",children:e.jsx(_e,{sx:{fontSize:"1.25rem !important"}})})]})]})}),e.jsxs(S.Menu,{anchorEl:he,open:Boolean(he),onClose:()=>{xe(null)},children:[null==f?void 0:f.map(t=>e.jsxs(u.MenuItem,{onClick:async()=>{await t.handleAction(ne),xe(null)},disabled:"function"==typeof t.disabled?t.disabled(ne):Boolean(t.disabled),sx:{alignItems:"center",gap:.5},children:[null==t?void 0:t.icon,e.jsx(h.Typography,{type:"s4",color:"inherit",children:"function"==typeof t.label?t.label(ne):t.label})]})),(null==b?void 0:b.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx(u.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),e.jsx("div",{className:"dropdown-inner--DestructiveHeader",children:null==b?void 0:b.map(t=>e.jsx(u.MenuItem,{onClick:()=>{t.handleAction(ne),xe(null)},className:"dropdown-inner--DestructiveActions",disabled:"function"==typeof t.disabled?t.disabled(ne):Boolean(t.disabled),children:e.jsx(h.Typography,{type:"s4",color:"inherit",children:"function"==typeof t.label?t.label(ne):t.label})}))})]})]}),e.jsx(o.ConfirmPopUp,{open:Boolean($e),onClose:()=>ze(null),onConfirm:()=>(async()=>{Fe(!0),$e&&(await(null==E?void 0:E($e)),ze(null)),Fe(!1)})(),title:"Delete Item",description:"Are you sure you want to delete entry ?",loading:Pe})]})});function Jt(e,t){e.each(function(){const e=Ye.select(this),a=e.text();if(a.length<=8)return;if(a.length>12)return void e.text(a.substring(0,10)+"...");const l=a.split(/\s+/).reverse();let r,n=[],o=0;const i=e.attr("y"),s=parseFloat(e.attr("dy"))||0;let d=e.text(null).append("tspan").attr("x",0).attr("y",i).attr("dy",`${s}em`);for(;r=l.pop();)n.push(r),d.text(n.join(" ")),d.node()&&d.node().getComputedTextLength()>t&&(n.pop(),d.text(n.join(" ")),n=[r],d=e.append("tspan").attr("x",0).attr("y",i).attr("dy",`${1.1*++o+s}em`).text(r))})}const Qt=["#5BCE97","#B3D8E2","#F5F6F5","#AE6B9E","#CBD49A","#EEE0B3"],Zt=(e,t="")=>e>=1e6?`${t} ${(e/1e6).toFixed(1)} M`:e>=1e5?`${t} ${(e/1e5).toFixed(1)} L`:e>=1e3?`${(e/1e3).toFixed(1)} K`:`${t} ${e.toFixed(2)}`,ea=t=>e.jsx(Ee,{sx:{width:"16.625rem",borderRadius:"0.5rem",border:"0.5px solid theme.secondary.200, #F5F6F5",backgroundColor:"theme.secondary.100",boxShadow:"\n 0px 0px 2px 0px #E0E0E0, \n 0px 1px 4px - 2px rgba(24, 39, 75, 0.02), \n 0px 4px 4px - 2px rgba(24, 39, 75, 0.06)",m:3},children:e.jsxs(Re,{sx:{display:"flex",flexDirection:"column",padding:"1rem 1rem 1.25rem 1rem",justifyContent:"space-between",alignItems:"flex-start",flexShrink:0},children:[e.jsxs(O,{sx:{display:"flex",width:"100%",justifyContent:"space-between",marginBottom:1},children:[e.jsxs(O,{children:[e.jsx(h.Typography,{type:"s3",weight:"medium",children:t.data.name||"Kristin Watson"}),e.jsx(h.Typography,{type:"s3",color:"theme.secondary.800",children:t.data.company||"Barone LLC."})]}),e.jsx(O,{children:e.jsx(h.Typography,{type:"s4",sx:{padding:"0.25rem 0.375rem",gap:"0.5rem",borderRadius:"0.5rem",backgroundColor:"theme.secondary.200"},color:"theme.secondary.900",children:t.data.status||"Lost"})})]}),e.jsx(h.Typography,{type:"s3",sx:{overflow:"hidden",color:"theme.secondary.900",textDecorationLine:"underline"},children:t.data.email||"kristen.watson@example.com"}),e.jsxs(O,{sx:{mt:"1.25rem",display:"flex",alignItems:"center"},children:[e.jsx(h.Typography,{type:"s3",sx:{mr:".2rem"},color:"theme.secondary.900",children:t.data.amount||"$10,000,000"}),e.jsx(h.Typography,{type:"s4",color:"theme.secondary.800",children:"est value"})]})]})}),ta=t=>{const{children:a,data:l,isLoading:r}=t;return e.jsx(e.Fragment,{children:r?e.jsx(V.ErpLoader,{}):e.jsx(e.Fragment,{children:(null==l?void 0:l.length)?e.jsx("div",{className:"grid-wrapper",children:a}):e.jsxs(u.Box,{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",children:[e.jsx("img",{src:d.images.common.tableNoData}),e.jsx(h.Typography,{color:"theme.secondary.1000",weight:"medium",align:"center",children:"No data"})]})})})},aa=({data:t,config:a})=>{const l=W.useNavigate(),r=location.pathname.split("/")[2],n=`/dashboard/${r}${((null==a?void 0:a[r])||{redirectionPath:""}).redirectionPath}`,o=e=>{l(n,{state:{form:e}})},i=e=>{var t,a;return null==(a=null==(t=null==e?void 0:e.split("_"))?void 0:t.map(e=>(null==e?void 0:e.charAt(0).toUpperCase())+(null==e?void 0:e.slice(1).toLowerCase())))?void 0:a.join(" ")};return e.jsx(ta,{data:t,children:t.map((t,a)=>{var l;return e.jsxs(bt,{children:[e.jsx("div",{className:"gridView--CardHeader",children:e.jsx("div",{className:"gridView--redirection",onClick:()=>o(t),children:e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.900",children:i(null==t?void 0:t.name)})})}),e.jsxs("div",{className:"gridView--redirection",onClick:()=>o(t),children:[e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.900",children:(null==(l=null==t?void 0:t.fields)?void 0:l.filter(e=>!e.is_system_field).length)||0}),(null==t?void 0:t.description)&&e.jsx(h.Typography,{type:"s4",weight:"medium",color:"inherit",children:i(null==t?void 0:t.description)}),e.jsx("div",{className:"gridView--CardBottom",children:e.jsx(h.Typography,{type:"s5",color:"theme.secondary.600",children:j.createdOnAndBy(t)})})]})]},(null==t?void 0:t._id)||a)})})},la=["name","fields","noOfCustomFields","customFields"],ra=[{label:"Table",position:0}];function na({rowData:t,level:a=0,tableHeaders:l,totalHeaders:r,headers:n,collapsAll:o=!1,collapsLevel:s=0,isIncrese:d,data:c,rowPath:m,selectedRowPaths:p,onCheckboxChange:x,enableCheckBox:g,rowHeight:y,columnWidths:v={}}){var f,b,j,C,T;const[k,_]=i.useState(!1),{t:D}=w.useTranslation();i.useEffect(()=>{d&&s>a&&_(!0),!d&&s<=a+2&&_(!1)},[s,a,d]);const M=()=>{_(e=>!e)};function A(e,t){if(""==(null==t?void 0:t.name))return"";const a=(null==t?void 0:t.name.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e))||("0"==(null==t?void 0:t.name.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e))?"0":"-");return S.formateValueByType({value:a,...t})}const N=p.some(e=>e.length===m.length&&e.every((e,t)=>e===m[t]));return e.jsxs(e.Fragment,{children:[e.jsxs(u.TableRow,{sx:{cursor:"pointer",height:y,overflow:"hidden","&:not(:last-child) td":{},"&:last-child td":{borderBottom:"none",borderBottomColor:"divider",borderTop:"0"}},children:[(null==(f=l[a])?void 0:f.enableCheckbox)&&e.jsx(u.TableCell,{className:"dynamic-report-row",sx:{paddingLeft:"8px",wordWrap:"break-word",width:"60px",minWidth:"60px",maxWidth:"60px",overflow:"hidden"},children:e.jsx(Fe,{checked:N,onChange:e=>x(m,e.target.checked),onClick:e=>e.stopPropagation()})}),l[a].headers.map((r,o)=>{if(r.joinWithLeft)return null;const i=l[a].headers.slice(o+1).findIndex(e=>!e.joinWithLeft),s=-1===i?l[a].headers.slice(o+1).length+1:i+1,d=r.mergeCells?s:1;let m=0;for(let e=o;e<o+d&&e<n.length;e++)m+=(v[D(n[e].label)]>100?v[D(n[e].label)]:100)||100;const p=!(null==r?void 0:r.showData)||(null==r?void 0:r.showData(k));return e.jsx(u.TableCell,{className:"dynamic-report-row",colSpan:d,sx:{paddingLeft:0===o?"8px":"16px",wordWrap:"break-word",width:`${m}px`,minWidth:`${m}px`,maxWidth:`${m}px`,height:y,overflow:"hidden"},children:p&&(null==r?void 0:r.isCollaps)?e.jsxs(u.Box,{onClick:M,sx:{paddingLeft:a>o&&0===o?2*a:0,display:"flex",alignItems:"center",justifyContent:(null==r?void 0:r.position)?null==r?void 0:r.position:"start",width:"100%",height:y,overflow:"hidden"},children:[e.jsx(u.IconButton,{size:"small",sx:{p:0},children:k?e.jsx(Pe,{sx:{fontSize:"20px"}}):e.jsx(Ie,{sx:{fontSize:"20px"}})}),(null==r?void 0:r.render)?r.render(A(t,r),t,c):e.jsx(h.Typography,{type:"s4",weight:"medium",color:"theme.neutral.1000",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A(t,r)})]}):p&&e.jsx(u.Box,{sx:{paddingLeft:a>o&&0===o?2*a:0,display:"flex",alignItems:"center",justifyContent:(null==r?void 0:r.position)?null==r?void 0:r.position:"start",width:"100%",height:y,overflow:"hidden"},children:(null==r?void 0:r.render)?r.render(A(t,r),t,c):e.jsx(h.Typography,{type:"s4",weight:"normal",color:"theme.neutral.800",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A(t,r)})})},o)})]}),Array.isArray(t[null==(b=l[a+1])?void 0:b.rowKey])&&e.jsx(u.TableRow,{sx:{},children:e.jsx(u.TableCell,{sx:{border:"0 !important",borderBottom:"0 !important"},style:{padding:0},colSpan:l[a].headers.filter(e=>!e.joinWithLeft).length+(g?1:0),children:e.jsxs(u.Collapse,{in:k,timeout:"auto",unmountOnExit:!0,children:[null==(C=t[null==(j=l[a+1])?void 0:j.rowKey])?void 0:C.map((t,i,u)=>e.jsx(na,{rowData:t,level:a+1,tableHeaders:l,headers:n,collapsAll:o,collapsLevel:s,isIncrese:d,totalHeaders:r,data:c,rowPath:[...m,i],selectedRowPaths:p,onCheckboxChange:x,dataSlice:u,dataIndex:i,enableCheckBox:g,rowHeight:y,columnWidths:v},t.id||[...m,i].join("-"))),(null==t?void 0:t.total)&&Object.keys(null==t?void 0:t.total).length>0&&r&&e.jsxs(u.TableRow,{sx:{backgroundColor:(null==(T=null==r?void 0:r[0])?void 0:T.bgColor)||"#FAFAFA"},children:[g&&e.jsx(u.TableCell,{sx:{width:"60px",minWidth:"60px",maxWidth:"60px"}}),r.map((l,o)=>{var i;if(l.joinWithLeft)return null;const s=-1===r.slice(o+1).findIndex(e=>!e.joinWithLeft&&e!==l)?(null==(i=r.slice(o+1))?void 0:i.length)+1:r.slice(o+1).findIndex(e=>!e.joinWithLeft&&e!==l)+1,d=l.mergeCells?s:1;let c=0;for(let e=o;e<o+d&&e<n.length;e++)c+=v[D(n[e].label)]||100;return e.jsx(u.TableCell,{className:"dynamic-report-row",colSpan:d,sx:{paddingLeft:0===o?24*a+"px":"16px",width:`${c}px`,minWidth:`${c}px`,maxWidth:`${c}px`},children:e.jsx(u.Box,{sx:{display:"flex",alignItems:"center",justifyContent:(null==l?void 0:l.position)||"start",width:"100%"},children:(null==l?void 0:l.render)?null==l?void 0:l.render(A(t,l),t):e.jsx(h.Typography,{type:"s4",weight:"bold",color:"theme.neutral.1000",children:A(null==t?void 0:t.total,l)})})},o)})]})]})})})]})}const oa={fontSize:"14px",fontFamily:$e.primaryFont,fontWeight:"500"};let ia=null;function sa(){if(ia)return ia;try{const e=document.createElement("canvas");return ia=e.getContext("2d"),ia}catch(e){return console.warn("Canvas context creation failed, falling back to DOM measurement:",e),null}}function da(e,t=oa){if(!e||0===e.length)return 0;const a=String(e);return sa()?function(e,t){const a=sa();return a?(a.font=`${t.fontWeight} ${t.fontSize} ${t.fontFamily}`,a.measureText(e).width):(console.warn("Canvas context not available, returning 0"),0)}(a,t):function(e,t){try{const a=document.createElement("span");a.style.position="absolute",a.style.visibility="hidden",a.style.whiteSpace="nowrap",a.style.fontSize=t.fontSize,a.style.fontFamily=t.fontFamily,a.style.fontWeight=String(t.fontWeight),a.textContent=e,document.body.appendChild(a);const l=a.offsetWidth;return document.body.removeChild(a),l}catch(a){return console.warn("DOM measurement failed:",a),8*e.length}}(a,t)}function ca(e,t){if(null==e)return"-";if("date"===t||e instanceof Date)try{return new Date(e).toLocaleDateString()}catch{return String(e)}if("number"===t||"number"==typeof e)return String(e);if("object"==typeof e)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}const ua={amount:{format:j.toFixedWithNumbers},date:{format:j.formatDate},string:{format:e=>e},toFixed:{format:e=>j.toFixedWithNumbers(e)}};function ma(e,t){var a;const l=(null==t?void 0:t.type)||"string";if(!(null==t?void 0:t.name)||""===(null==t?void 0:t.name))return"";const r=null==t?void 0:t.name.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e);return 0===r||"0"===r?"0":void 0!==r?null==(a=ua[l])?void 0:a.format(r):"-"}const pa=q.styled(u.CircularProgress)(({theme:e})=>{var t;return{color:null==(t=e.palette)?void 0:t.theme.primary[500]}}),ha=q.styled(u.Box)(()=>({position:"fixed",display:"flex",width:"100%",height:"100%",justifyContent:"center",alignItems:"center",backgroundColor:"#ffffff96",zIndex:1,left:0,top:0})),xa=q.styled(u.CircularProgress)(({theme:e})=>{var t;return{color:null==(t=e.palette)?void 0:t.theme.primary[500]}}),ga=[{name:"null",label:"is null"},{name:"notNull",label:"is not null"}],ya=[{name:"contains",label:"contains"},{name:"beginsWith",label:"begins with"},{name:"endsWith",label:"ends with"},{name:"doesNotContain",label:"does not contain"},{name:"doesNotBeginWith",label:"does not begin with"},{name:"doesNotEndWith",label:"does not end with"},...ga],va=[{name:"=",label:"equal to"},{name:"<",label:"less than"},{name:"<=",label:"less than or equal to"},{name:">",label:"greater than"},{name:">=",label:"greater than or equal to"},...ga],fa=[{name:"in",label:"in"},{name:"notIn",label:"not in"},...ga],ba=[{name:"Select",label:"Select",valueEditorType:"select",operators:fa,values:[{name:"Select",label:"Select"}]},{name:"role",label:"Role",inputType:"text",valueEditorType:"text",operators:ya,comparator:"datatype"},{name:"status",label:"Status",valueEditorType:"select",operators:fa,comparator:"datatype",values:[{name:"Select",label:"Select"},{name:"enable",label:"Enable"},{name:"disabled",label:"Disabled"}]},{name:"roleType",label:"Role Type",valueEditorType:"select",operators:fa,comparator:"datatype",values:[{name:"Select",label:"Select"},{name:"admin",label:"Admin"},{name:"manager",label:"Manager"},{name:"executive",label:"Executive"},{name:"support",label:"Support"}]},{name:"roleLevel",label:"Role level",valueEditorType:"text",operators:va,comparator:"datatype"},{name:"dateCreated",label:"Date Created",operators:[{name:"=",label:"on"},{name:"!=",label:"not on"},{name:"<",label:"before"},{name:"<=",label:"on or before"},{name:">",label:"after"},{name:">=",label:"on or after"},...ga],datatype:"date",inputType:"date"},{name:"companyName",label:"Company Name",valueEditorType:"text",operators:ya,comparator:"datatype"},{name:"location",label:"Location",valueEditorType:"text",operators:ya,comparator:"datatype"},{name:"email",label:"Email",valueEditorType:"text",operators:ya,comparator:"datatype"}],ja=[{name:"document",label:"Document",inputType:"text",valueEditorType:"text",operators:ya,comparator:"datatype"},{name:"filesize",label:"File size",valueEditorType:"text",operators:va,comparator:"datatype"},{name:"owner",label:"Owner",valueEditorType:"text",operators:ya,comparator:"datatype"}];function wa({chart:t,currency:a}){const l=i.useRef(null),r=i.useRef(null),n=i.useRef(null),o=i.useMemo(()=>(null==t?void 0:t.labels)?t.labels.map((e,a)=>{var l,r,n;return{name:e,value:(null==(n=null==(r=null==(l=t.datasets)?void 0:l[0])?void 0:r.values)?void 0:n[a])||0}}):[],[t]),s=a||(null==t?void 0:t.currency)||"AED",d=i.useMemo(()=>Math.max(...o.map(e=>Math.abs(e.value))),[o]),c=i.useMemo(()=>o.some(e=>e.value<0),[o]),u=c?100:90,m=Math.max(42*o.length+70,230),p={top:15,right:90,bottom:20,left:u};return i.useEffect(()=>{var e;if(!l.current||!o.length)return;const t=Ye.select(l.current);t.selectAll("*").remove();const a=(null==(e=l.current.parentElement)?void 0:e.clientWidth)||300,r=Math.max(a-20,200)-p.left-p.right,i=m-p.top-p.bottom,u=1.15*d,h=Ye.scaleLinear().domain([c?-u:0,u]).range([0,r]),x=Ye.scaleBand().domain(o.map(e=>e.name)).range([0,i]).padding(.35),g=t.append("g").attr("transform",`translate(${p.left},${p.top})`);c&&g.append("line").attr("x1",h(0)).attr("x2",h(0)).attr("y1",0).attr("y2",i).attr("stroke","#9CA3AF").attr("stroke-width",1);const y=h.ticks(5).filter(e=>0!==e);g.selectAll(".grid-line").data(y).enter().append("line").attr("x1",e=>h(e)).attr("x2",e=>h(e)).attr("y1",0).attr("y2",i).attr("stroke","#E5E7EB").attr("stroke-dasharray","3,3"),g.selectAll(".x-tick").data(y).enter().append("text").attr("x",e=>h(e)).attr("y",i+16).attr("text-anchor","middle").attr("font-size","10px").attr("fill","#6B7280").text(e=>(e=>{const t=Math.abs(e);return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)})(e)),g.selectAll(".bar").data(o).enter().append("rect").attr("x",e=>e.value>=0?h(0):h(e.value)).attr("y",e=>x(e.name)||0).attr("width",e=>Math.abs(h(e.value)-h(0))).attr("height",x.bandwidth()).attr("fill",e=>e.value>=0?"#4AC08C":"#E85D3A").attr("rx",3).style("cursor","pointer").on("mouseenter",function(e,t){Ye.select(this).attr("fill",e=>e.value>=0?"#3AA87A":"#D14529"),n.current&&(n.current.style.opacity="1",n.current.innerHTML=`<strong>${t.name}</strong><br/>${((e,t)=>{const a=Math.abs(e)>=1e6?"M":Math.abs(e)>=1e3?"K":"",l=Math.abs(e),r=l>=1e6?(l/1e6).toFixed(1):l>=1e3?(l/1e3).toFixed(1):String(l);return`${e<0?`-${r}${a}`:`${r}${a}`} ${t}`})(t.value,s)}`,n.current.style.left=`${e.offsetX+15}px`,n.current.style.top=e.offsetY-10+"px")}).on("mouseleave",function(e,t){Ye.select(this).attr("fill",e=>e.value>=0?"#4AC08C":"#E85D3A"),n.current&&(n.current.style.opacity="0")}),g.selectAll(".value-label").data(o).enter().append("text").attr("x",e=>e.value>=0?h(e.value)+6:h(0)+6).attr("y",e=>(x(e.name)||0)+x.bandwidth()/2).attr("dy","0.35em").attr("text-anchor","start").attr("font-size","9px").attr("font-weight","600").attr("fill","#374151").text(e=>(e=>{const t=Math.abs(e)>=1e6?"M":Math.abs(e)>=1e3?"K":"",a=Math.abs(e),l=a>=1e6?(a/1e6).toFixed(1):a>=1e3?(a/1e3).toFixed(1):String(a);return e<0?`-${l}${t}`:`${l}${t}`})(e.value));const v=g.append("g").attr("transform","translate(0,0)").call(Ye.axisLeft(x).tickSize(0).tickFormat(e=>{return(t=String(e)).length<=15?t:t.slice(0,13)+"…";var t}));v.selectAll("text").attr("font-size","10px").attr("fill","#6B7280"),v.selectAll(".domain").remove()},[o,s,d,c,90,u,m,p]),e.jsxs("div",{className:"ai-summary-panel__card",ref:r,children:[e.jsx("p",{className:"ai-summary-panel__card-title",children:(null==t?void 0:t.title)||""}),e.jsxs("div",{style:{position:"relative",overflow:"visible",height:m,width:"100%"},children:[e.jsx("svg",{ref:l,width:"100%",height:m,style:{display:"block"}}),e.jsx("div",{ref:n,style:{position:"absolute",backgroundColor:"white",padding:"8px 12px",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0,0,0,0.12)",fontSize:"11px",color:"#374151",opacity:0,transition:"opacity 0.15s",pointerEvents:"none",zIndex:10,border:"1px solid #E5E7EB",lineHeight:1.4}})]})]})}function Ca({chart:t,currency:a}){const l=i.useRef(null),r=i.useRef(null),n=i.useRef(null),o=i.useMemo(()=>(null==t?void 0:t.labels)?t.labels.map((e,a)=>{var l,r,n;return{name:e,value:(null==(n=null==(r=null==(l=t.datasets)?void 0:l[0])?void 0:r.values)?void 0:n[a])||0}}):[],[t]),s=a||(null==t?void 0:t.currency)||"AED",d=i.useMemo(()=>o.length<=6,[o]),c=Math.max(40*o.length+120,220),u=i.useMemo(()=>Math.max(...o.map(e=>Math.abs(e.value))),[o]);return i.useEffect(()=>{var e;if(!l.current||!o.length)return;const t=Ye.select(l.current);t.selectAll("*").remove();const a=(null==(e=l.current.parentElement)?void 0:e.clientWidth)||300,r=Math.max(a-20,200)-50-12,i=c-25-45,u=o.some(e=>e.value<0),m=o.length>5?.15:.25,p=Ye.scaleBand().domain(o.map(e=>e.name)).range([0,r]).padding(m),h=u?Math.min(0,Ye.min(o,e=>e.value)||0):0,x=Math.max(0,Ye.max(o,e=>e.value)||0),g=Ye.scaleLinear().domain([1.15*h,1.15*x]).range([i,0]),y=t.append("g").attr("transform","translate(50,25)"),v=g.ticks(4).filter(e=>0!==e);y.selectAll(".grid-line").data(v).enter().append("line").attr("x1",0).attr("x2",r).attr("y1",e=>g(e)).attr("y2",e=>g(e)).attr("stroke","#E5E7EB").attr("stroke-dasharray","3,3"),y.selectAll(".y-tick").data(v).enter().append("text").attr("x",-6).attr("y",e=>g(e)).attr("dy","0.35em").attr("text-anchor","end").attr("font-size","9px").attr("fill","#6B7280").text(e=>(e=>{const t=Math.abs(e);return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)})(e)),u&&y.append("line").attr("x1",0).attr("x2",r).attr("y1",g(0)).attr("y2",g(0)).attr("stroke","#9CA3AF").attr("stroke-width",1),y.selectAll(".bar").data(o).enter().append("rect").attr("x",e=>p(e.name)||0).attr("y",e=>e.value>=0?g(e.value):g(0)).attr("width",p.bandwidth()).attr("height",e=>Math.abs(g(e.value)-g(0))).attr("fill",e=>e.value>=0?"#4AC08C":"#E85D3A").attr("rx",3).style("cursor","pointer").on("mouseenter",function(e,t){Ye.select(this).attr("opacity","0.85"),n.current&&(n.current.style.opacity="1",n.current.innerHTML=`<strong>${t.name}</strong><br/>${((e,t)=>{const a=Math.abs(e)>=1e6?"M":Math.abs(e)>=1e3?"K":"",l=Math.abs(e),r=l>=1e6?(l/1e6).toFixed(1):l>=1e3?(l/1e3).toFixed(1):String(l);return`${e<0?`-${r}${a}`:`${r}${a}`} ${t}`})(t.value,s)}`,n.current.style.left=`${e.offsetX+15}px`,n.current.style.top=e.offsetY-10+"px")}).on("mouseleave",function(){Ye.select(this).attr("opacity","1"),n.current&&(n.current.style.opacity="0")}),d&&y.selectAll(".value-label").data(o).enter().append("text").attr("x",e=>(p(e.name)||0)+p.bandwidth()/2).attr("y",e=>e.value>=0?g(e.value)-5:g(e.value)+12).attr("text-anchor","middle").attr("font-size","8px").attr("font-weight","600").attr("fill","#374151").text(e=>(e=>{const t=Math.abs(e)>=1e6?"M":Math.abs(e)>=1e3?"K":"",a=Math.abs(e),l=a>=1e6?(a/1e6).toFixed(1):a>=1e3?(a/1e3).toFixed(1):String(a);return e<0?`-${l}${t}`:`${l}${t}`})(e.value));const f=y.append("g").attr("transform",`translate(0,${i})`).call(Ye.axisBottom(p).tickSize(0));f.selectAll("text").attr("font-size","9px").attr("fill","#6B7280"),f.selectAll(".domain").remove(),o.length>5&&f.selectAll("text").each(function(){const e=Ye.select(this);var t;e.text((t=e.text()).length<=8?t:t.slice(0,6)+"…")})},[o,s,d,c,u]),e.jsxs("div",{className:"ai-summary-panel__card",ref:r,children:[e.jsx("p",{className:"ai-summary-panel__card-title",children:(null==t?void 0:t.title)||""}),e.jsxs("div",{style:{position:"relative",overflow:"visible",height:c,width:"100%"},children:[e.jsx("svg",{ref:l,width:"100%",height:c,style:{display:"block"}}),e.jsx("div",{ref:n,style:{position:"absolute",backgroundColor:"white",padding:"8px 12px",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0,0,0,0.12)",fontSize:"11px",color:"#374151",opacity:0,transition:"opacity 0.15s",pointerEvents:"none",zIndex:10,border:"1px solid #E5E7EB",lineHeight:1.4}})]})]})}const Sa=["#4AC08C","#3AA87A","#2E8E68","#247457","#7FD3AE","#C9EFE0","#6BBF8A","#5AAF7C"];function Ta({chart:t}){var a;const l=i.useRef(null),r=i.useRef(null),n=i.useRef(null),o=(null==t?void 0:t.labels)||[],s=(null==(a=null==t?void 0:t.datasets)?void 0:a[0])||{},d=(null==s?void 0:s.values)||[],c=(null==t?void 0:t.currency)||"",u=(null==t?void 0:t.unit)||"",m=i.useMemo(()=>d.reduce((e,t)=>e+(t||0),0),[d]),p=i.useMemo(()=>o.map((e,t)=>({name:e,value:d[t]||0,pct:m>0?(d[t]||0)/m*100:0})),[o,d,m]),h=i.useMemo(()=>[...p].sort((e,t)=>t.value-e.value),[p]);return i.useEffect(()=>{var e;if(!l.current||!p.length)return;const t=Ye.select(l.current);t.selectAll("*").remove();const a=(null==(e=r.current)?void 0:e.clientWidth)||300,o=Math.min(.6*a,170),i=o/2-4,s=i-16,d=t.append("g").attr("transform",`translate(${o/2},${o/2})`),h=Ye.pie().value(e=>e.value).sort(null).padAngle(.02),x=Ye.arc().innerRadius(s).outerRadius(i).cornerRadius(3);d.selectAll("path").data(h(p)).enter().append("path").attr("d",x).attr("fill",(e,t)=>Sa[t%Sa.length]).style("cursor","pointer").on("mouseenter",function(e,t){if(Ye.select(this).attr("opacity","0.85"),n.current){n.current.style.opacity="1",((e,t,a)=>{if(a)return`${e} ${a}`;if(t){const a=Math.abs(e);return a>=1e6?`${t} ${(a/1e6).toFixed(2)}M`:a>=1e3?`${t} ${(a/1e3).toFixed(1)}K`:`${t} ${e}`}e.toString()})(t.data.value,c,u);const a=(e,t)=>t?Math.abs(e)>=1e6?`${(Math.abs(e)/1e6).toFixed(2)}M ${t}`:Math.abs(e)>=1e3?`${(Math.abs(e)/1e3).toFixed(1)}K ${t}`:`${e} ${t}`:String(e);n.current.innerHTML=`<strong>${t.data.name}</strong><br/>${a(t.data.value,c)}<br/>(${t.data.pct.toFixed(1)}%)`,n.current.style.left=`${e.offsetX+15}px`,n.current.style.top=e.offsetY-10+"px"}}).on("mouseleave",function(){Ye.select(this).attr("opacity","1"),n.current&&(n.current.style.opacity="0")});const g=(y=m)>=1e6?(y/1e6).toFixed(1)+"M":y>=1e3?(y/1e3).toFixed(1)+"K":String(y);var y;d.append("text").attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-size",g.length>8?"10px":"12px").attr("font-weight","600").attr("fill","#1F2125").text(g)},[p,c,u,t,m]),e.jsxs("div",{className:"ai-summary-panel__card",ref:r,children:[e.jsx("p",{className:"ai-summary-panel__card-title",children:(null==t?void 0:t.title)||""}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"50px",width:"100%"},children:[e.jsxs("div",{style:{position:"relative",display:"flex",justifyContent:"center",width:"100%"},children:[e.jsx("svg",{ref:l,width:"100%",height:180,style:{maxWidth:"180px"}}),e.jsx("div",{ref:n,style:{position:"absolute",backgroundColor:"white",padding:"8px 12px",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0,0,0,0.12)",fontSize:"11px",color:"#374151",opacity:0,transition:"opacity 0.15s",pointerEvents:"none",zIndex:10,border:"1px solid #E5E7EB",lineHeight:1.4}})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:"6px 12px",maxWidth:"100%"},children:h.map((t,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"5px",padding:"4px 8px",borderRadius:"4px",cursor:"pointer"},children:[e.jsx("div",{style:{width:"9px",height:"9px",borderRadius:"2px",backgroundColor:Sa[a%Sa.length],flexShrink:0}}),e.jsx("span",{style:{fontSize:"10px",color:"#374151",maxWidth:"85px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t.name,children:t.name}),e.jsxs("span",{style:{fontSize:"10px",color:"#6B7280",fontWeight:"500",flexShrink:0},children:[t.pct.toFixed(0),"%"]})]},t.name))})]})]})}const ka=["#4AC08C","#3AA87A","#2E8E68","#247457","#7FD3AE","#C9EFE0","#6BBF8A","#5AAF7C"];function _a({chart:t,currency:a}){const l=i.useRef(null),r=i.useRef(null),n=i.useRef(null),o=(null==t?void 0:t.labels)||[],s=(null==t?void 0:t.datasets)||[],d=a||(null==t?void 0:t.currency)||"AED",c=i.useMemo(()=>o.map((e,t)=>{const a={name:e};return s.forEach((e,l)=>{var r;a[e.label||`dataset_${l}`]=(null==(r=e.values)?void 0:r[t])??0}),a}),[o,s]),u=i.useMemo(()=>s.map(e=>e.label||`dataset_${s.indexOf(e)}`),[s]),m=i.useMemo(()=>c.length*s.length<=12,[c,s]),p=i.useMemo(()=>o.some(e=>e.length>6),[o]),h=Math.max(48*c.length+35*s.length+150,300),x={top:25,right:15,bottom:p?100:80,left:60};return i.useEffect(()=>{var e;if(!l.current||!c.length)return;const t=Ye.select(l.current);t.selectAll("*").remove();const a=(null==(e=l.current.parentElement)?void 0:e.clientWidth)||300,r=Math.max(a-20,200)-x.left-x.right,o=h-x.top-x.bottom,i=Ye.scaleBand().domain(c.map(e=>e.name)).range([0,r]).padding(.2),s=Ye.scaleBand().domain(u).range([0,i.bandwidth()]).padding(.1),g=Ye.max(c,e=>Math.max(...u.map(t=>Math.abs(Number(e[t]))||0))||0),y=Ye.scaleLinear().domain([0,1.25*g]).range([o,0]),v=t.append("g").attr("transform",`translate(${x.left},${x.top})`),f=y.ticks(4).filter(e=>e>0);v.selectAll(".grid-line").data(f).enter().append("line").attr("x1",0).attr("x2",r).attr("y1",e=>y(e)).attr("y2",e=>y(e)).attr("stroke","#E5E7EB").attr("stroke-dasharray","3,3"),v.selectAll(".y-tick").data(f).enter().append("text").attr("x",-6).attr("y",e=>y(e)).attr("dy","0.35em").attr("text-anchor","end").attr("font-size","10px").attr("fill","#6B7280").text(e=>(e=>{const t=Math.abs(e);return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)})(e)),c.forEach(e=>{const t=v.append("g").attr("transform",`translate(${i(e.name)},0)`);u.forEach((a,l)=>{const r=Number(e[a])||0,i=Math.abs(r),c=y(i);t.append("rect").attr("x",s(a)||0).attr("y",c).attr("width",s.bandwidth()).attr("height",o-c).attr("fill",ka[l%ka.length]).attr("rx",3).style("cursor","pointer").on("mouseenter",function(t){Ye.select(this).attr("opacity","0.85"),n.current&&(n.current.style.opacity="1",n.current.innerHTML=`<strong>${a}</strong> - ${e.name}<br/>${((e,t)=>{const a=Math.abs(e)>=1e6?"M":Math.abs(e)>=1e3?"K":"",l=Math.abs(e),r=l>=1e6?(l/1e6).toFixed(1):l>=1e3?(l/1e3).toFixed(1):String(l);return`${e<0?`-${r}${a}`:`${r}${a}`} ${t}`})(r,d)}`,n.current.style.left=`${t.offsetX+15}px`,n.current.style.top=t.offsetY-10+"px")}).on("mouseleave",function(){Ye.select(this).attr("opacity","1"),n.current&&(n.current.style.opacity="0")}),m&&s.bandwidth()>28&&i>0&&t.append("text").attr("x",(s(a)||0)+s.bandwidth()/2).attr("y",c-5).attr("text-anchor","middle").attr("font-size","8px").attr("font-weight","600").attr("fill","#374151").text((e=>{const t=Math.abs(e)>=1e6?"M":Math.abs(e)>=1e3?"K":"",a=Math.abs(e),l=a>=1e6?(a/1e6).toFixed(1):a>=1e3?(a/1e3).toFixed(1):String(a);return e<0?`-${l}${t}`:`${l}${t}`})(r))})});const b=v.append("g").attr("transform",`translate(0,${o})`).call(Ye.axisBottom(i).tickSize(0).tickFormat(e=>{return t=String(e),a=p?12:14,t.length<=a?t:t.slice(0,a-2)+"…";var t,a}));b.selectAll("text").attr("font-size","10px").attr("fill","#6B7280"),p&&b.selectAll("text").attr("transform","rotate(-30)").attr("text-anchor","end"),b.selectAll(".domain").remove()},[c,u,d,m,p,h,x]),e.jsxs("div",{className:"ai-summary-panel__card",ref:r,children:[e.jsx("p",{className:"ai-summary-panel__card-title",children:(null==t?void 0:t.title)||""}),e.jsx("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap",marginBottom:"10px"},children:u.map((t,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"2px",backgroundColor:ka[a%ka.length]}}),e.jsx("span",{style:{fontSize:"10px",color:"#6B7280"},children:t})]},t))}),e.jsxs("div",{style:{position:"relative",overflow:"visible",height:h,width:"100%"},children:[e.jsx("svg",{ref:l,width:"100%",height:h,style:{display:"block"}}),e.jsx("div",{ref:n,style:{position:"absolute",backgroundColor:"white",padding:"8px 12px",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0,0,0,0.12)",fontSize:"11px",color:"#374151",opacity:0,transition:"opacity 0.15s",pointerEvents:"none",zIndex:10,border:"1px solid #E5E7EB",lineHeight:1.4}})]})]})}function Da({charts:t,currency:a="AED"}){const l={bar:Ca,horizontal_bar:wa,donut:Ta,grouped_bar:_a};return e.jsx("div",{className:"ai-summary-panel__visuals",children:t.map((t,r)=>{const n=l[t.chart_type];return n?e.jsx(n,{chart:t,currency:a},r):null})})}exports.AISummaryPanel=function(t={}){const{aiSummaryData:a,isLoading:l,onExpand:r}=t,n=i.useMemo(()=>{var e,t;if(!a)return{summaryText:"",insights:[],charts:[]};const l=(a.flags||[]).map(e=>({icon:"critical"===e.severity?qe.AlertTriangle:"warning"===e.severity?qe.Clock:qe.TrendingUp,text:e.message,title:"critical"===e.severity?"Critical":"warning"===e.severity?"Warning":"Info",color:"critical"===e.severity?"#E85D3A":"warning"===e.severity?"#D97706":"#059669"}));return{summaryText:a.summary||"",insights:l,charts:a.charts||[],currency:(null==(t=null==(e=null==a?void 0:a.charts)?void 0:e[0])?void 0:t.currency)||"AED"}},[a]),[o,s]=i.useState(!1),[d,c]=i.useState(!1),[u,m]=i.useState(!1),{displayed:p,done:h}=function(e,t=18){const[a,l]=i.useState(""),[r,n]=i.useState(!1);return i.useEffect(()=>{let a=0;const r=setInterval(()=>{a++,l(e.slice(0,a)),a>=e.length&&(clearInterval(r),n(!0))},t);return()=>clearInterval(r)},[e,t]),{displayed:a,done:r}}(n.summaryText,12);return i.useEffect(()=>{h&&setTimeout(()=>m(!0),200)},[h]),e.jsxs("div",{className:"ai-summary-panel",children:[!o&&e.jsxs("button",{onClick:()=>{s(!0),null==r||r()},className:"ai-summary-panel__collapsed-toggle",disabled:l,children:[e.jsx("div",{className:"ai-summary-panel__collapsed-toggle-icon",children:l?e.jsx("div",{className:"ai-summary-panel__loading-spinner"}):e.jsx(qe.Sparkles,{})}),e.jsx("span",{className:"ai-summary-panel__collapsed-toggle-title",children:"AI Summary"}),e.jsx("span",{className:"ai-summary-panel__collapsed-toggle-subtitle",children:l?"Generating insights...":"Click to expand insights"}),!l&&e.jsx(qe.ChevronDown,{className:"ai-summary-panel__collapsed-toggle-chevron"})]}),o&&e.jsxs("div",{className:"ai-summary-panel__expanded",children:[e.jsxs("div",{className:"ai-summary-panel__header",children:[e.jsxs("div",{className:"ai-summary-panel__header-left",children:[e.jsx("div",{className:"ai-summary-panel__header-icon",children:e.jsx(qe.Sparkles,{})}),e.jsx("span",{className:"ai-summary-panel__header-title",children:"AI Summary"}),e.jsx("span",{className:"ai-summary-panel__header-badge",children:"Beta"})]}),e.jsxs("div",{className:"ai-summary-panel__header-actions",children:[e.jsx("button",{onClick:function(){navigator.clipboard.writeText(n.summaryText),c(!0),setTimeout(()=>c(!1),2e3)},className:"ai-summary-panel__header-btn "+(d?"copied":""),children:d?e.jsx(qe.Check,{}):e.jsx(qe.Copy,{})}),e.jsx("button",{onClick:()=>s(!1),className:"ai-summary-panel__header-btn",children:e.jsx(qe.ChevronUp,{})})]})]}),e.jsxs("div",{className:"ai-summary-panel__body",children:[l&&e.jsxs("div",{className:"ai-summary-panel__loading",children:[e.jsx("div",{className:"ai-summary-panel__loading-spinner-large"}),e.jsx("span",{className:"ai-summary-panel__loading-text",children:"Generating AI insights..."})]}),!l&&e.jsxs("p",{className:"ai-summary-panel__summary",children:[p,!h&&e.jsx("span",{className:"ai-summary-panel__summary-cursor"})]}),n.charts.length>0&&u&&e.jsx(Da,{charts:n.charts,currency:n.currency}),u&&e.jsx("div",{className:"ai-summary-panel__insights",children:n.insights.map((t,a)=>{var l;return e.jsxs("div",{className:`ai-summary-panel__insight-chip ai-summary-panel__insight-chip--${(null==(l=t.title)?void 0:l.toLowerCase())||"info"}`,children:[e.jsx(t.icon,{style:{color:t.color}}),e.jsx("span",{className:"ai-summary-panel__insight-chip-title",children:t.title}),e.jsxs("span",{className:"ai-summary-panel__insight-chip-text",children:["— ",t.text]}),e.jsx("svg",{className:"ai-summary-panel__insight-chip-arrow",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M9 18l6-6-6-6"})})]},a)})})]})]})]})},exports.ActivityTag=t=>{const{t:a}=w.useTranslation(),{data:l}=t,r={view:a("common.viewed_text"),delete:a("common.deleted_text"),create:a("common.created_text"),update:a("common.updated_text")};return e.jsx(u.Box,{children:e.jsx(x,{className:"Timeline",children:e.jsxs(u.Box,{sx:{display:"flex",flexDirection:"column",gap:2,padding:"16px"},className:"box-class",children:[e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.800",children:a("common.activities_label")}),e.jsx(u.Box,{sx:{height:400,overflowY:"auto",gap:1.5,display:"flex",flexDirection:"column"},children:null==l?void 0:l.map((t,a)=>{var n,o;return e.jsx("div",{className:"Timeline--Activity",children:e.jsxs(g,{children:[e.jsxs(y,{children:[e.jsx(b,{color:"primary",sx:{backgroundColor:"#D3D3D4"}}),l.length-1!==a&&e.jsx(v,{})]}),e.jsxs(f,{className:"Timeline--Content",children:[e.jsxs(h.Typography,{type:"s5",color:"theme.secondary.800",className:"Timeline--ActivityLogItem",children:[e.jsx("b",{children:j.formatText(t.username)})," ",r[t.action]," ",e.jsx("b",{children:j.formatText(null==(n=t.resource)?void 0:n.replace("_"," "))})]}),e.jsx(h.Typography,{type:"s5",color:"theme.secondary.800",className:"Timeline--ActivityLogItem",children:(o=null==t?void 0:t.created_at,`${p(o).format("DD MMM, YYYY")} • ${p(o).format("HH:mm")}`)})]})]},a)})})})]})})})},exports.ActivityTag$1=t=>{const{type:a,data:l,placeholder:r,error:s=!1,textfield:c,textfieldTitle:u,onCommentSubmit:m,onChange:p,containerProps:w,accordion:C=!0,...S}=t,{user:T}=h.useAuth(),k=i.useRef(null),_=()=>{k.current&&(k.current.scrollTop=k.current.scrollHeight)};i.useEffect(()=>{_()},[l]);const D=e=>{const t=new Date,a=new Date(e),l=t.getTime()-a.getTime(),r=Math.floor(l/1e3),n=Math.floor(r/60),o=Math.floor(n/60);if(r<60)return`${r} second${1!==r?"s":""} ago`;if(n<60)return`${n} minute${1!==n?"s":""} ago`;if(o<24)return`${o} hour${1!==o?"s":""} ago`;{const e={day:"numeric",month:"short",year:"numeric"},t={hour:"numeric",minute:"numeric",hour12:!1};return`${a.toLocaleString("en-US",e)} • ${a.toLocaleString("en-US",t)}`}},M="activity"===a?null==l?void 0:l.map((t,a)=>e.jsx("div",{className:"Timeline--Activity",children:e.jsxs(g,{children:[e.jsxs(y,{children:[e.jsx(b,{}),l.length-1!==a&&e.jsx(v,{})]}),e.jsx(f,{className:"Timeline--Content",children:e.jsxs(h.Typography,{type:"s4",color:"theme.secondary.800",className:"Timeline--ActivityLogItem",children:[t.message," · ",D(t.created_at)]})})]},a)})):e.jsx(e.Fragment,{children:e.jsx("div",{className:"Timeline--Chat",ref:k,children:l.map((t,a)=>e.jsxs(g,{children:[e.jsxs(y,{children:[e.jsx(o.Avatar,{src:d.images.chat,size:17}),e.jsx(v,{})]}),e.jsxs(f,{children:[t.name," commented this · ",D(t.created_at),e.jsx("div",{className:"Timeline--CommentWrap",children:e.jsx("p",{className:"Timeline--Comment",children:t.message})})]})]},a))})});return e.jsx("div",{className:"ActivityContainer",...w,children:e.jsxs(x,{className:"Timeline",children:[C?e.jsx(n.Accordion,{title:"Activities",accordionProps:{defaultExpanded:!0},children:M}):e.jsx("div",{className:"Timeline--ActivityBox",children:M}),c&&e.jsxs("div",{className:"Timeline--CommentBox",children:[u,e.jsxs("div",{className:"Timeline--CommentText",children:[e.jsx(o.Avatar,{size:32,alt:j.formatText(null==T?void 0:T.full_name),className:"avatar-class"}),e.jsx(ut,{error:s,placeholder:r,className:"textfield",onKeyDown:e=>{if("Enter"===e.key){const t=e.target.value;""!==t.trim()&&(m(t),_())}},onChange:p,...S})]})]})]})})},exports.ApprovalWrapper=({data:t,addApprover:a,fetchApi:l,showAcceptOrReject:r,moduleIdKey:s,moduleId:d,successMessage:c,showSubmitBtn:u,updateApi:m,approvalDetails:p,title:h})=>{const{t:x}=w.useTranslation(),g=D.useDispatch(),[y,v]=i.useState(!1),[f,b]=i.useState(!1),[j,C]=i.useState(""),S=async(e,r)=>{if(t){v(!0);const t={[s]:d,type:e,...r&&(null==r?void 0:r.length)&&{approver_id:r}},n=await g(a(t));v(!1),M.apiHelper(n,()=>(k.enqueueSnackbar(x(c)),void l()))}};return e.jsxs(e.Fragment,{children:[(u||"Rejected"===(null==t?void 0:t.status))&&e.jsx(n.DropdownButton,{isMenuThirdItemDisabled:!0,onClick:()=>S("submit_for_approval"),options:[{label:x("common.submitForApproval"),callback:()=>S("submit_for_approval")},{label:x("common.quickApproval"),callback:()=>b(!0)}],loading:y,children:"Rejected"===(null==t?void 0:t.status)?x("common.reSubmit"):x("common.submit")}),e.jsx(pt,{isOpen:f,setIsOpen:()=>b(!1),onConfirm:e=>S("quick_approval",e),isProcessing:y}),e.jsx(o.ConfirmPopUp,{open:Boolean(j),onClose:()=>C(""),onConfirm:async()=>{if((null==p?void 0:p.id)&&j){const e={id:null==p?void 0:p.id,[s]:d,status:j};v(!0);const t=await g(m(e));v(!1);const a=j;if(C(""),M.apiHelper(t,()=>l()),"fulfilled"===t.meta.requestStatus){const e=`${h} ${x("Approved"===a?"common.accepted":"common.rejected")}`;k.enqueueSnackbar(e)}}},title:`${j} request`,description:`Are you sure you want to ${j} ${h} : ${null==t?void 0:t.id} ?`,buttonTexts:{confirm:x("common.submit"),cancel:x("common.cancel")},buttonColors:{confirm:"Rejected"===j?"error":"info"},modalType:"info",loading:y}),r&&e.jsx(n.DropdownButton,{isMenuThirdItemDisabled:!0,onClick:()=>C("Approved"),options:[{label:x("common.accept"),callback:()=>C("Approved")},{label:x("common.reject"),callback:()=>C("Rejected"),color:"theme.error.500"}],loading:y,children:x("common.accept")})]})},exports.AreaLineChart=({data:t,height:a=400,customLabelFormatter:l,yAxisLabelType:r="inValue",currency:n,colors:o,customLegend:s})=>{const d=i.useRef(null),c=i.useRef(null),[m,p]=i.useState(0),[h,x]=i.useState(null);return i.useEffect(()=>{const e=c.current,t=new ResizeObserver(e=>{if(e[0]){const t=e[0].contentRect.width;p(t)}});return e&&t.observe(e),()=>{e&&t.unobserve(e)}},[]),i.useEffect(()=>{var e,i;if(0===m)return;const s=m-40-30,c=a-20-30;Ye.select(d.current).selectAll("*").remove();const u=Ye.select(d.current).attr("width",m).attr("height",a).append("g").attr("transform","translate(40,20)"),p=Ye.scalePoint().domain(null==(i=null==(e=t[0])?void 0:e.values)?void 0:i.map(e=>e.month)).range([0,s]),h=Ye.scaleLinear().domain([0,Ye.max(t,e=>Ye.max(e.values,e=>e.value))]).range([c,0]),g=Math.floor(s/80),y=Ye.axisBottom(p).ticks(g),v=u.append("g").attr("transform",`translate(0,${c})`).call(y);v.selectAll("text").attr("transform","translate(0, 10)").attr("color","#8E8E93").style("text-anchor","middle");const f=u.append("g");f.append("g").attr("color","#8E8E93").attr("transform","translate(-10,0)").call(Ye.axisLeft(h).tickSize(-s).tickFormat(e=>{return l?l(e):(t=e,a=n,"inPercent"===(o=r)?`${Ye.format(".0%")(t/100)}`:"inValue"===o?`${a||""} ${Ye.format(".2s")(t).replace("k","K")}`:t.toString());var t,a,o}).tickSizeOuter(0)).selectAll("line").attr("stroke-dasharray","3,3").attr("stroke","#D3D3D4"),v.selectAll(".tick line").remove(),f.select(".domain").attr("stroke","none"),v.select(".domain").attr("stroke","none");const b=Ye.area().x(e=>p(e.month)).y0(c).y1(e=>h(e.value));t.forEach((e,t)=>{const a=u.append("defs").append("linearGradient").attr("id",`area-gradient-${t}`).attr("x1","0%").attr("x2","0%").attr("y1","0%").attr("y2","100%");var l;a.append("stop").attr("offset","0%").attr("stop-color",o[t]).attr("stop-opacity",.4),a.append("stop").attr("offset","100%").attr("stop-color",o[t]).attr("stop-opacity",.1),u.append("path").datum(e.values).attr("fill",`url(#area-gradient-${t})`).attr("d",b),u.append("path").datum(e.values).attr("fill","none").attr("stroke",o[t]).attr("stroke-width",2).attr("d",(l=e.isSmooth||!1,Ye.line().x(e=>p(e.month)).y(e=>h(e.value)).curve(l?Ye.curveMonotoneX:Ye.curveLinear))),(null==e?void 0:e.showCircle)&&u.selectAll(`circle-${t}`).data(e.values).enter().append("circle").attr("cx",e=>p(e.month)).attr("cy",e=>h(e.value)).attr("r",5).attr("fill",o[t]).attr("stroke","#fff").style("cursor","pointer").on("mouseover",function(t,a){x({x:`${t.pageX+10}px`,y:t.pageY-30+"px",content:`${e.name}: ${a.value}`}),Ye.select(this).transition().attr("r",7).attr("fill","#ff4500")}).on("mouseout",function(){x(null),Ye.select(this).transition().attr("r",5).attr("fill",o[t])})})},[t,m,a,l,r,n,o,s]),e.jsxs("div",{ref:c,style:{width:"100%",height:"100%"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("svg",{ref:d,width:"100%",height:a}),s&&s]}),h&&e.jsx(u.Box,{sx:{position:"absolute",left:h.x,top:h.y,pointerEvents:"none",backgroundColor:"#2EB273",zIndex:"99999",border:"none",borderRadius:"3px",transform:"translate(-50%, -100%)",padding:"2px 6px 2px 6px",gap:"10px"},children:e.jsx("span",{style:{fontSize:"16px",weight:"500",color:"#ffff"},children:h.content})})]})},exports.BarChart=({data:t,numOfLines:a=5,initialWidth:l=500,height:r=400,line:n=!1,yAxisLabelType:o="inValue",currency:s,customLabelFormatter:d})=>{const c=i.useRef(null),u=i.useRef(null),[m,p]=i.useState(l),h=i.useMemo(()=>Math.max(...t.map(e=>e.value)),[t]),x=i.useMemo(()=>1.25*h,[h]),g=i.useMemo(()=>{const e=[],t=x/a;for(let l=0;l<=a;l++)e.push(t*l);return e},[x,a]),y=t.length>12,v=y?Math.max(120*t.length,m):m;return i.useEffect(()=>{const e=u.current,t=new ResizeObserver(e=>{if(e[0]){const t=e[0].contentRect.width;p(t)}});return e&&t.observe(e),()=>{e&&t.unobserve(e)}},[]),i.useEffect(()=>{if(0===m)return;const e=Ye.select(c.current);e.selectAll("*").remove();const l=Math.max(60,110),i=v-l-20,u=h?r-20-25:0,p=Ye.scaleBand().domain(t.map(e=>e.label)).range([0,i]).padding(.5),y=Ye.scaleLinear().domain([0,x]).range([u,0]),f=e.append("g").attr("transform",`translate(${l},${h?20:r-50})`);n&&g.slice(1).forEach(e=>{f.append("line").attr("class","dotted-line").attr("x1",0).attr("y1",y(e)).attr("x2",i).attr("y2",y(e)).style("stroke","#D3D3D4").style("stroke-dasharray","3,3").style("opacity",1)}),f.selectAll(".bar").data(t).enter().append("rect").attr("rx",5).attr("ry",5).attr("class","bar").attr("x",e=>p(e.label)).attr("y",e=>y(e.value)).attr("width",p.bandwidth()).attr("height",e=>u-y(e.value)).style("fill",e=>e.color);const b=f.append("g").attr("class","x-axis").attr("transform",`translate(0, ${u})`).call(Ye.axisTop(p).tickPadding(10)).call(Ye.axisBottom(p).tickPadding(5));b.selectAll(".tick line").remove(),b.selectAll(".tick text").call(Jt,80);const j=u,w=Math.floor(j/30),C=Math.min(a,w,8),S=[],T=x/C;for(let t=0;t<=C;t++)S.push(T*t);const k=f.append("g").attr("class","y-axis").call(Ye.axisLeft(y).tickValues(S).tickFormat(e=>{return d?d(e):(t=e,a=s,"inPercent"===(l=o)?`${Ye.format(".0%")(t/100)}`:"inValue"===l?`${a||""} ${Ye.format(".2s")(t).replace("k","K")}`:t.toString());var t,a,l}).tickSizeOuter(0).tickPadding(8));k.selectAll(".tick line").remove(),k.select(".domain").attr("stroke","none"),b.select(".domain").attr("stroke","none"),k.selectAll(".tick text").style("font-size","11px").style("fill","#666").style("font-family","Inter, system-ui, Avenir, Helvetica, Arial, sans-serif").style("text-anchor","end")},[t,m,r,n,x,g,s,o,d,v]),e.jsx("div",{ref:u,style:{width:"100%",overflowX:y?"auto":"hidden",overflowY:"hidden"},children:e.jsx("svg",{ref:c,width:v,height:r,viewBox:`0 0 ${v} ${r}`})})},exports.BarChart$1=({data:t,numOfLines:a=5,width:l=500,height:r=300,line:n=!1})=>{const o=i.useRef(null),s=i.useMemo(()=>Math.max(...t.map(e=>e.value)),[t]),d=i.useMemo(()=>1.25*s,[s]),c=i.useMemo(()=>{const e=[],t=d/a;for(let l=0;l<=a;l++)e.push(t*l);return e},[d,a]);return i.useEffect(()=>{if(!o.current)return;const e=Ye.select(o.current);e.selectAll("*").remove();const a=l-40-20,i=r-20-70,s=Ye.scaleBand().domain(t.map(e=>e.label)).range([0,a]).padding(.1),u=Ye.scaleLinear().domain([0,d]).range([i,0]),m=e.append("g").attr("transform","translate(40,20)");n&&c.slice(1).forEach(e=>{m.append("line").attr("class","dotted-line").attr("x1",0).attr("y1",u(e)).attr("x2",a).attr("y2",u(e)).style("stroke","gray").style("stroke-dasharray","3,3").style("opacity",1)}),m.selectAll(".bar").data(t).enter().append("rect").attr("class","bar").attr("x",e=>s(e.label)).attr("y",e=>u(e.value)).attr("width",s.bandwidth()).attr("height",e=>i-u(e.value)).style("fill","#357AF6").style("opacity","1").on("mousemove",(e,t)=>{var a,r;let n=e.offsetX+40-25;const o=e.offsetY+20-40,i=null==(r=null==(a=p.node())?void 0:a.getBoundingClientRect())?void 0:r.width;(i?n+i:n)>l&&(n=Math.floor(i?n-i-20:n-20));const s=`${t.label} - ${t.value}`;p.attr("x",n).attr("y",o).style("opacity",9).style("height",s.length>=16?50:35),h.html(s)}).on("mouseleave",()=>{p.style("opacity",0)}),m.append("g").attr("class","x-axis").attr("transform",`translate(0, ${i})`).call(Ye.axisBottom(s)).selectAll(".tick line").remove(),m.append("g").attr("class","y-axis").call(Ye.axisLeft(u).tickValues(c).tickFormat(e=>{return(t=e)>=1e9?(t/1e9).toFixed(1)+"B":t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t;var t}).tickSizeOuter(0)).selectAll(".tick line").remove();const p=e.append("foreignObject").attr("class","tooltip").attr("width",120).attr("height",20).style("opacity",0).style("position","absolute").style("background-color","white").style("border","none").style("box-shadow","0rem 0rem 0.469rem 0rem rgba(0, 0, 0, 0.15)").style("border-radius","0.313rem").style("padding","0.625rem").style("font-size","0.75rem"),h=p.append("xhtml:div").style("font-size","0.75rem").style("color","black")},[t,r,l,n,d,c]),e.jsx(e.Fragment,{children:e.jsx("svg",{ref:o,width:l,height:r})})},exports.BarLineChart=({data:t,height:a=400,margin:l={top:20,right:30,bottom:30,left:50},bars:r,lines:n,line:o=!0,showGrid:s=!0,barColors:d,lineColors:c})=>{var m;const p=i.useRef(null),x=i.useRef(null),g=i.useRef(null),[y,v]=i.useState(null),[f,b]=i.useState(0),j=e=>Ye.format(".2s")(e).replace("k","K"),w=t.length>r.length,C=w?Math.max(60*t.length,f):f;return i.useEffect(()=>{const e=x.current,t=new ResizeObserver(e=>{if(e[0]){const t=e[0].contentRect.width;b(t)}});return e&&t.observe(e),()=>{e&&t.unobserve(e)}},[]),i.useEffect(()=>{if(0===f)return;const e=Ye.max(t,e=>Math.max(...r.map(t=>e[t.field]),...n.map(t=>e[t.field])))??0,i=Ye.min(t,e=>Math.min(...r.map(t=>e[t.field]),...n.map(t=>e[t.field])))??0,u=Ye.select(p.current),m=C-l.left-l.right,h=e||i?a-l.top-l.bottom:0,x=Ye.scaleBand().domain(t.map(e=>e.month)).range([0,m]).padding(.3),y=Ye.scaleLinear().domain([i,e]).nice().range([h,0]);u.selectAll("*").remove();const b=u.append("g").attr("transform",`translate(${l.left},${l.top})`);b.append("g").call(Ye.axisLeft(y).tickFormat(j)).call(e=>e.select(".domain").remove()).select(".domain").attr("stroke","none"),b.append("g").attr("transform",`translate(0,${h})`).call(Ye.axisBottom(x)).selectAll(".tick text").attr("text-anchor","middle").select(".domain").attr("stroke","none"),s&&b.selectAll(".grid-line").data(y.ticks()).enter().append("line").attr("class","grid-line").attr("x1",0).attr("x2",m).attr("y1",e=>y(e)).attr("y2",e=>y(e)).style("stroke","#ddd").style("stroke-dasharray","8,8").style("stroke-width",1),o&&b.selectAll(".grid-line-2").data(y.ticks()).enter().append("line").attr("class","grid-line-2").attr("x1",0).attr("x2",m).attr("y1",e=>y(e)).attr("y2",e=>y(e)).style("stroke","#ddd").style("stroke-dasharray","8,8").style("stroke-width",1),r.forEach((e,a)=>{b.selectAll(`.bar-${e.field}`).data(t).enter().append("rect").attr("class",`bar bar-${e.field}`).attr("x",e=>x(e.month)??0).attr("y",t=>t[e.field]>=0?y(t[e.field]):y(0)).attr("rx",5).attr("ry",5).attr("width",x.bandwidth()/r.length).attr("height",t=>Math.abs(y(t[e.field])-y(0))).attr("fill",d[a]).attr("transform",`translate(${a*x.bandwidth()/r.length}, 0)`).on("mouseover",function(e,t){var a;const[r,n]=Ye.pointer(e,p.current),o=(null==(a=g.current)?void 0:a.scrollLeft)||0;v({x:r+l.left-o,y:n+l.top,content:t})}).on("mouseout",()=>v(null))}),n.forEach((e,a)=>{const r=Ye.line().x(e=>(x(e.month)??0)+x.bandwidth()/2).y(t=>y(t[e.field])).curve(Ye.curveMonotoneX);b.append("path").datum(t).attr("fill","none").attr("stroke",c[a]).attr("stroke-width",2).attr("d",r).on("mouseover",function(a){var r;const[n]=Ye.pointer(a,p.current),o=x.domain().find(e=>{const t=x(e)??0;return n>=t&&n<=t+x.bandwidth()});if(o){const a=t.find(e=>e.month===o);if(a){const t=(null==(r=g.current)?void 0:r.scrollLeft)||0;v({x:n+l.left-t,y:y(a[e.field])+l.top,content:a})}}}).on("mouseout",()=>v(null))})},[t,f,C,o,a,l,r,n,s,d,c]),e.jsx("div",{ref:x,style:{width:"100%",height:"100%"},children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:g,style:{width:"100%",overflowX:w?"auto":"hidden",overflowY:"hidden"},children:e.jsx("svg",{ref:p,width:C,height:a,viewBox:`0 0 ${C} ${a}`,style:{display:"block"}})}),y&&e.jsx("div",{style:{position:"absolute",left:y.x,top:y.y,pointerEvents:"none",backgroundColor:"white",zIndex:"99999",border:"none",padding:"5px",borderRadius:"3px",transform:"translate(-50%, -100%)"},children:e.jsxs(u.Box,{children:[e.jsx("div",{style:{background:"#F3F2F2",padding:"10px"},children:e.jsx(h.Typography,{type:"s4",style:{whiteSpace:"noWrap",width:"200px",color:"#232529"},children:null==(m=y.content)?void 0:m.month})}),e.jsxs(u.Box,{sx:{p:1.5,display:"flex",flexDirection:"column",gap:1.5},children:[r.map((t,a)=>e.jsxs(u.Box,{sx:{display:"flex",gap:1.5,alignItems:"center"},children:[e.jsx("div",{className:"circle",style:{backgroundColor:d[a]}}),e.jsxs(h.Typography,{type:"s5",color:"theme.secondary.900",children:[t.label,": ",e.jsxs("span",{style:{fontWeight:600},children:["$ ",y.content[t.field]]})]})]},`bar-${a}`)),n.map((t,a)=>e.jsxs(u.Box,{sx:{display:"flex",gap:1.5,alignItems:"center"},children:[e.jsx("div",{className:"circle",style:{backgroundColor:c[a]}}),e.jsxs(h.Typography,{type:"s5",color:"theme.secondary.900",children:[t.label,": ",e.jsxs("span",{style:{fontWeight:600},children:["$ ",y.content[t.field]]})]})]},`line-${a}`))]})]})})]})})},exports.BoardWrapper=t=>{const[a,l]=i.useState(t.data),[r,n]=i.useState(!1),[o,s]=i.useState("");return e.jsx("div",{className:"card-board-wrap",children:e.jsx(A,{initialBoard:a,allowAddCard:!0,allowAddColumn:!0,renderColumnHeader:t=>e.jsx("div",{className:"column-header",children:e.jsx(ht,{column:t},t.id)}),renderColumnAdder:()=>r?e.jsxs("div",{className:"create-status-box",children:[e.jsx("input",{type:"text",placeholder:"Enter new status title",value:o,onChange:e=>s(e.target.value)}),e.jsxs("div",{className:"add-btns",children:[e.jsx("button",{onClick:()=>(e=>{const t={...a};t.columns.push({id:Date.now(),title:e,cards:[]}),l(t),n(!1),s("")})(o),children:"Add"}),e.jsx("button",{onClick:()=>n(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"create-status-box",onClick:()=>n(!0),role:"button",children:["Create new status",e.jsx("img",{src:d.images.common.addIcon,alt:"add icon"})]}),allowRemoveCard:!0,allowRenameColumn:!0,onCardNew:console.log,onCardRemove:console.log,onColumnRemove:console.log,onColumnRename:console.log,onNewCardConfirm:e=>({id:(new Date).getTime(),...e})})})},exports.CalculationSummary=({items:t,expenses:a,formValues:l,enalblePromotions:r,enableShippings:n,currencySymbol:o})=>{var s;const{user:d}=h.useAuth(),c=o||(null==(s=null==d?void 0:d.currency_data)?void 0:s.symbol)||"",[m,p]=i.useState({totalQuantity:0,total:0,currencySymbol:c}),[x,g]=i.useState({itemDiscount:0,additionalDiscount:0,totalDiscount:0,currencySymbol:c}),[y,v]=i.useState({subtotalExTax:0,subtotalExDiscount:0,currencySymbol:c}),[f,b]=i.useState({taxes:0,deductedTax:0,total:0,shippingAmount:0,handlingAmount:0,currencySymbol:c}),[j,w]=i.useState({total:0,roundOffDifferenceAmount:0,currencySymbol:c});return i.useEffect(()=>{const e=Number(null==l?void 0:l.exchange_rate)||1;let{totalQuantity:r,totalDiscount:n,totalItemsExpenseDiscount:i,totalTaxAmount:s,additinoalDiscountAmount:d,finalAmount:c,roundOffDifference:u}=N.calculateEntries(t,a,null==l?void 0:l.additional_discount_on,null==l?void 0:l.additional_discount_percentage,null==l?void 0:l.additional_discount_amount,null==l?void 0:l.round_off,null==l?void 0:l.round_off_option);n/=e,d/=e,i/=e,s/=e,c/=e,u/=e;const h=((Number(null==l?void 0:l.shipping_cost)||0)+(Number(null==l?void 0:l.shipping_tax_amount)||0))/e,C=((Number(null==l?void 0:l.handling_cost)||0)+(Number(null==l?void 0:l.handling_tax_amount)||0))/e,S=Number((null==l?void 0:l.promotion_amount)||0)/e;c-=S;const T=c+h+C-S;p({...m,totalQuantity:r,total:c.toFixed(2),currencySymbol:o}),g({...x,itemDiscount:i.toFixed(2),additionalDiscount:Number(d).toFixed(2),totalDiscount:(n+S).toFixed(2),promotionAmount:S.toFixed(2),currencySymbol:o}),v({...y,subtotalExTax:(c-s).toFixed(2),subtotalExDiscount:Number(c+Number(n)).toFixed(2),currencySymbol:o}),b({...f,taxes:s.toFixed(2),total:s.toFixed(2),shippingAmount:h.toFixed(2),handlingAmount:C.toFixed(2),currencySymbol:o}),w({...j,total:T.toFixed(2),roundOffDifferenceAmount:u.toFixed(2),currencySymbol:o})},[t,null==l?void 0:l.additional_discount_amount,null==l?void 0:l.additional_discount_on,null==l?void 0:l.additional_discount_percentage,null==l?void 0:l.currency_id,null==l?void 0:l.round_off,null==l?void 0:l.round_off_option,null==l?void 0:l.shipping_cost,null==l?void 0:l.shipping_tax_amount,null==l?void 0:l.handling_cost,null==l?void 0:l.handling_tax_amount,null==l?void 0:l.promotion_amount,null==l?void 0:l.exchange_rate,null==l?void 0:l.currency_data,c]),e.jsxs(u.Box,{className:"addPurchaseInvoice--RightContainer",children:[e.jsx(xt,{data:m}),e.jsx(gt,{data:x,enalblePromotions:r}),e.jsx(yt,{data:y}),e.jsx(vt,{data:f,enableShippings:n}),e.jsx(ft,{data:j})]})},exports.CalendarWrapper=t=>{const[a]=i.useState(t.data);return e.jsx("div",{className:"calendar-wrapper",children:e.jsx(B,{eventContent:null==t?void 0:t.renderEventContent,schedulerLicenseKey:"GPL-My-Project-Is-Open-Source",initialView:"dayGridMonth",droppable:!0,displayEventTime:!0,headerToolbar:{left:"title",right:"prev,next,today"},buttonText:{today:"Today"},selectable:!0,plugins:[E,I,P,F,$,R,z],eventClick:e=>{},events:a.events,select:null==t?void 0:t.handleSelectedDates,dayMaxEvents:2,showNonCurrentDates:!1,height:"75vh",eventColor:"#"+Math.floor(16777215*Math.random()).toString(16)})})},exports.CardWrapper=bt,exports.ChangeUserPasswordModal=({showModal:a,setShowModal:l,userId:r})=>{const{changeUserPasswordByAdmin:n}=h.useAuth(),[s,d]=i.useState(!1),[c,m]=i.useState(null),{control:p,handleSubmit:x,reset:g,trigger:y}=t.useForm({resolver:o.o(jt),mode:"all"}),v=async e=>{if(await y())return e.login.id=r,e.login.isNotify=s,await n(e.login,(e,t)=>{t?(m({message:e,type:"normal"}),l(!1),g({login:{password:"",id:"",isNotify:!1}})):m({message:e,type:"alert"})}),e},[f,b]=i.useState(!1),j=q.styled(O)(()=>({display:"flex",flexDirection:"column"}));return e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{open:a,onClose:()=>l(!1),children:e.jsx(e.Fragment,{children:e.jsx("form",{onSubmit:x(v),children:e.jsxs(j,{gap:4,className:"popup-change-pass",children:[e.jsxs(j,{gap:2,children:[e.jsx(O,{children:e.jsx(h.Typography,{align:"center",type:"h1",weight:"medium",color:"theme.secondary.1000",children:"Change Password"})}),e.jsxs(j,{gap:2,children:[e.jsx(O,{children:e.jsx(o.DynamicInput,{formControl:p,label:"Enter New Password",name:"password",type:f?"text":"password",placeholder:"Enter New Password",fieldArrayName:"login",endIcon:e.jsx(e.Fragment,{children:f?e.jsx(L.Eye,{fontSize:"small",htmlColor:"#292D32"}):e.jsx(L.EyeOff,{fontSize:"small",htmlColor:"#292D32"})}),onIconClick:()=>b(!f)})}),e.jsx(O,{children:e.jsx(u.FormControlLabel,{control:e.jsx(u.Checkbox,{size:"small",onChange:e=>d(e.target.checked),sx:{"&.Mui-checked":{color:"#2EB273"}}}),label:"Notify User of Password Change",sx:{"& .MuiFormControlLabel-label":{fontSize:"14px"}}})})]})]}),e.jsx(j,{gap:2,children:e.jsx(o.Button,{type:"button",onClick:x(v),size:"large",variant:"contained",children:"Change Password"})})]})})})}),e.jsx(o.Toast,{open:Boolean(c),message:null==c?void 0:c.message,type:null==c?void 0:c.type,handleClose:()=>m(null),anchorOrigin:{horizontal:"right",vertical:"bottom"},autoHideDuration:3e3})]})},exports.ChartLegends=function({legends:t,colors:a}){return e.jsx(u.Box,{sx:{display:"flex",justifyContent:"center",alignContent:"space-between"},children:t.map((t,l)=>e.jsxs("div",{style:{marginLeft:"20px",display:"flex"},children:[e.jsx("div",{className:"legends-circle",style:{backgroundColor:a[l]}}),e.jsx(h.Typography,{type:"s5",sx:{color:"#656669"},children:t})]}))})},exports.ControllerSelect=({name:a,fieldArrayName:l,options:r,label:n,placeholder:i,formControl:s,position:d,required:c,size:m="small",multiple:p,disabled:h,searchPlaceholder:x,handleSearch:g,classes:y,with_checkboxes:v,onChipRemove:f})=>e.jsx(t.Controller,{control:s,name:`${l}.${a}`,render:({field:t,fieldState:{error:s}})=>e.jsxs(e.Fragment,{children:[e.jsx(o.Select,{fullWidth:!0,name:a,dataPosition:d,dataName:`${l}.${a}`,placeholder:i,label:n,value:t.value||(p?[]:""),defaultValue:"",onChange:e=>{var a,l,r;return p&&(null==(l=null==(a=e.target)?void 0:a.value.filter(e=>e))?void 0:l.length)>0||!p&&(null==(r=e.target)?void 0:r.value)?t.onChange(e.target.value):t.onChange("")},required:Boolean(c),size:m,multiple:Boolean(p),disabled:Boolean(h),searchPlaceholder:x,handleSearch:g,className:y,variant:"outlined",error:Boolean(s),renderValue:t=>e.jsx(e.Fragment,{children:Array.isArray(t)?e.jsx(Vt,{data:t,placeholder:i,onDelete:f}):t||i}),children:Ht({options:r,multiple:Boolean(p),placeholder:i,values:t.value,with_checkboxes:Boolean(v),onChange:t.onChange})}),s&&e.jsx(u.FormHelperText,{error:!0,children:s.message}),p&&Array.isArray(null==t?void 0:t.value)&&e.jsx(Kt,{data:t.value,options:r})]})}),exports.CountrySelect=({country:t,handleCountry:a})=>e.jsxs(e.Fragment,{children:[e.jsx(h.Typography,{type:"s4",fontWeight:"medium",mb:.5,children:"Country"}),e.jsx(wt,{fullWidth:!0,searchable:!0,searchPlaceholder:"Search Country",selected:t||"IN",selectButtonClassName:"country-button",onSelect:a,showSelectedLabel:!0})]}),exports.CustomDatePicker=ct,exports.CustomGridCard=({title:t,subTitle:a,children:l,data:r,rowActionMenu:n,destructiveActionMenu:o})=>{const[s,d]=i.useState(null),[c,m]=i.useState(null);return e.jsxs(u.Card,{sx:{width:"16.625rem",borderRadius:"0.5rem",border:"0.5px solid #eeeff1",boxShadow:"\n 0px 0px 2px 0px #e0e0e0,\n 0px 1px 4px -2px rgba(24, 39, 75, 0.02),\n 0px 4px 4px -2px rgba(24, 39, 75, 0.06);"},children:[e.jsxs(u.CardContent,{sx:{display:"flex",flexDirection:"column",padding:"1rem 1rem 1.25rem 1rem",justifyContent:"space-between",alignItems:"flex-start",flexShrink:0},children:[e.jsxs(u.Box,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:t}),e.jsx(u.IconButton,{color:"inherit",size:"small",onClick:e=>((e,t)=>{m(t),d(e.currentTarget)})(e,r),children:e.jsx(_.MoreIcon,{sx:{transform:"rotate(90deg)"},orient:"vertical",fontSize:"small"})})]}),e.jsx(u.Box,{children:e.jsx(h.Typography,{type:"s4",color:"theme.secondary.800",children:a})}),l,(null==r?void 0:r.created_at)&&e.jsx(u.Box,{children:e.jsxs(h.Typography,{type:"s4",color:"theme.secondary.800",children:["Created On ",j.formatDate(null==r?void 0:r.created_at,"DD MMM, YYYY")]})})]}),e.jsxs(S.Menu,{anchorEl:s,open:Boolean(s),onClose:()=>d(null),children:[e.jsx(u.Box,{children:n.map(t=>e.jsx(u.MenuItem,{onClick:()=>{c&&t.handleAction(c),d(null)},children:e.jsx(h.Typography,{type:"s4",color:"inherit",children:t.label})}))}),e.jsx(u.Box,{className:"dropdown-inner--DestructiveHeader",children:o.map(t=>e.jsx(u.MenuItem,{onClick:()=>{c&&t.handleAction(c),d(null)},className:"dropdown-inner--DestructiveActions",children:e.jsx(h.Typography,{type:"s4",color:"inherit",children:t.label})}))})]})]})},exports.CustomToggleSwitch=({leftLabel:t="Collapse All",rightLabel:a="Expand All",defaultChecked:l=!1,onChange:r,disabled:n=!1,sx:o={},...s})=>{const[d,c]=i.useState(l),u=e=>{var l;n||(l=e,n||(c(l),r&&r(l,l?a:t)))};return e.jsxs(Ct,{className:n?"disabled":"",sx:o,...s,children:[e.jsx(St,{sx:{left:d?"50%":0,right:d?0:"50%"}}),e.jsx(Tt,{active:!d,className:n?"disabled":"",onClick:()=>u(!1),disableRipple:!0,disabled:n,children:t}),e.jsx(Tt,{active:d,className:n?"disabled":"",onClick:()=>u(!0),disableRipple:!0,disabled:n,children:a})]})},exports.DashBoardCard=function(t){const{title:a,value:l}=t;return e.jsx(e.Fragment,{children:e.jsx(u.Box,{className:"card-class",children:e.jsxs(u.Box,{p:2,sx:{display:"flex",flexDirection:"column",border:"1px solid",borderRadius:"8px",gap:1,borderColor:"#EEEFF1"},children:[e.jsx(u.Box,{className:"dashboard-card-icon",children:e.jsx("img",{src:d.images.ArrowCircleUpIcon})}),e.jsx(h.Typography,{type:"s5",weight:"normal",color:"theme.neutral.800",children:a}),e.jsx(h.Typography,{type:"h2",weight:"bold",color:"theme.neutral.1000",children:l})]})})})},exports.DashBoardHeader=({title:t,customElement:a,showEdit:l=!0,showDropDowan:r=!0})=>{const{t:n}=w.useTranslation(),[o,s]=i.useState(!1),[c,m]=i.useState(null),p=()=>{m(null)};return e.jsx("div",{children:e.jsxs("div",{className:"header-title",children:[e.jsx(h.Typography,{type:"h3",weight:"medium",color:"theme.secondary.1000",children:t}),e.jsxs("div",{className:"header-right-wrap",children:[a,l&&e.jsx(S.Chip,{type:"normal",label:n(o?"manufacturing.dashboard.editing_dashboard_mode_label":"manufacturing.dashboard.edit_layout_mode_label"),className:o?"edit-box":"edit-box edit-box--InActive",icon:e.jsx("img",{src:o?d.images.common.editIcon:d.images.edit,alt:n("common.edit")}),onClick:()=>s(!0),active:o}),r&&e.jsxs("div",{children:[e.jsx(u.IconButton,{color:"inherit",size:"small",onClick:e=>{m(e.currentTarget)},children:e.jsx("img",{src:d.images.more,alt:n("manufacturing.dashboard.more_icon_label")})}),e.jsx(S.Menu,{anchorEl:c,open:Boolean(c),onClose:p,className:"dropdown-inner calender-drp",children:e.jsx(u.MenuItem,{onClick:p,children:n("common.export")})})]})]})]})})},exports.DateRangePicker=ot,exports.DonutChart=({data:t,height:a=140,width:l=140,legend:r=!0,direction:n="vertical",total:o="300",donutThickerValue:s,CustomLegends:d,title:c=""})=>{var u;const m=i.useRef(null),{user:p}=h.useAuth(),x=(null==(u=null==p?void 0:p.currency_data)?void 0:u.symbol)||"";return i.useEffect(()=>{if(!m.current)return;const e=Ye.select(m.current);e.selectAll("*").remove();const r=Math.min(l,a)/2-6;let n=Math.min(l,a)/2-12;s&&(n=r-s);const i=e.append("g").attr("transform",`translate(${l/2}, ${a/2})`),d=Ye.pie().value(e=>(e=>{if("number"==typeof e)return e;const t=(null==e?void 0:e.match(/\d.+/))||null;return t?Number(t[0]):0})(e.value)).padAngle(0),u=Ye.arc().outerRadius(r).innerRadius(n);i.selectAll(".arc").data(d(t)).enter().append("g").attr("class","arc").append("path").attr("d",u).attr("fill",e=>{var t;return null==(t=null==e?void 0:e.data)?void 0:t.color}).attr("stroke","none"),i.append("text").attr("text-anchor","middle").attr("font-size","18px").attr("font-weight","600").attr("alignment-baseline","central").html(o),i.append("text").attr("text-anchor","middle").attr("maring-top","20px").attr("font-size","13px").attr("font-weight","600").attr("dy","2em").attr("color","#7B7C7F").html(c)},[t,a,o,l,x,s,d,c]),r?e.jsx(e.Fragment,{children:e.jsxs("div",{className:`donut-chart-container ${n}`,children:[e.jsx("div",{children:e.jsx("svg",{ref:m,width:l,height:a})}),d?e.jsx(d,{data:t}):e.jsx("div",{className:"donut-legend",children:e.jsx("div",{className:`donut-chart-legend ${n}`,children:t.map(t=>e.jsxs("div",{className:"legend",style:{borderLeft:`0.188rem solid ${t.color}`},children:[e.jsx("div",{className:"legend-title",style:{color:`${t.labelColor}`},children:t.label}),e.jsx("div",{className:"legend-value",children:e.jsx(h.Typography,{type:"s5",weight:"medium",color:t.valueColor,style:{whiteSpace:"nowrap"},children:Zt(t.value,x)})})]},t.label))})})]})}):e.jsx("svg",{ref:m,width:l,height:a})},exports.DonutChart$1=({data:t,height:a=140,width:l=140,isUserDashbord:r,legend:n=!0,direction:o="horizontal",totalUsers:s,total:d=(r?s:"2.4 GB"),colors:c=Qt,titleProps:u={},valueProps:m={}})=>{const p=i.useRef(null);return i.useEffect(()=>{if(!p.current)return;const e=Ye.select(p.current);e.selectAll("*").remove();const r=Math.min(l,a)/2-6,n=Math.min(l,a)/2-12,o=e.append("g").attr("transform",`translate(${l/2}, ${a/2})`),i=Ye.pie().value(e=>(e=>{if("number"==typeof e)return e;const t=(null==e?void 0:e.match(/\d.+/))||null;return t?Number(t[0]):0})(e.value)),s=Ye.arc().outerRadius(r).innerRadius(n);o.selectAll(".arc").data(i(t)).enter().append("g").attr("class","arc").append("path").attr("d",s).attr("fill",(e,t)=>c[t%c.length]),o.append("text").attr("text-anchor","middle").attr("font-size","18px").attr("font-weight","600").attr("alignment-baseline","central").html(d)},[c,t,a,d,l]),n?e.jsx(e.Fragment,{children:e.jsxs("div",{className:`donut-chart-container ${o}`,children:[e.jsx("div",{children:e.jsx("svg",{ref:p,width:l,height:a})}),e.jsx("div",{className:"donut-chart-legend",children:t&&t.map((t,a)=>e.jsxs("div",{className:"legend",style:{borderLeft:`0.188rem solid ${c[a]}`},children:[e.jsx("div",{className:"legend-title",children:e.jsx(h.Typography,{type:"s5",color:"theme.secondary.800",...u,children:t.label})}),e.jsx("div",{className:"legend-value",children:e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.1000",children:e.jsx(h.Typography,{type:"s5",color:"theme.secondary.1000",weight:"bold",...m,children:t.value})})})]},t.label))})]})}):e.jsx("svg",{ref:p,width:l,height:a})},exports.DyanmicTextEditor=({formControl:a,name:l,fieldArrayName:r,placeholder:n})=>e.jsx(e.Fragment,{children:e.jsx(t.Controller,{name:`${r}.${l}`,control:a,render:({field:t,fieldState:a})=>{var l,r;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"editor-container",children:e.jsx(dt,{handleEditorReady:()=>{t.value&&t.onChange(t.value)},data:t.value,onEditorChange:e=>{t.onChange(e)},config:{placeholder:n}})}),(null==(l=a.error)?void 0:l.message)&&e.jsx(h.Typography,{color:"theme.error.600",type:"s5",children:null==(r=a.error)?void 0:r.message})]})}})}),exports.DynamicDateRange=it,exports.DynamicDateTime=st,exports.DynamicLayoutWrapper=({children:t,mainContentProps:a={},summaryContent:l,summaryProps:r={},maxGridSize:n=12,defaultSummaryExpanded:o=!0,expandedSummarySize:s=3,collapsedSummarySize:d=0,containerProps:c={},onLayoutChange:m,enableTransitions:p=!0,transitionDuration:h,transitionEasing:x,storageKey:g="grid-summary-panel-state"})=>{const y=u.useTheme(),v=u.useMediaQuery(y.breakpoints.down("md")),f=i.useCallback(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(g);return e?JSON.parse(e):o}return o},[o,g]),b=i.useMemo(()=>v||!f()?n:o?n-s:n-d,[v,f,n,o,s,d]),[j,w]=i.useState(b),C=i.useCallback((e,t)=>{if(v)return void w(n);const a=Math.max(1,Math.min(n-t,n));w(a),null==m||m(a,t,e)},[v,n,m]),S=i.useMemo(()=>{if(!p)return{};const e=h||y.transitions.duration.enteringScreen,t=x||y.transitions.easing.sharp;return{transition:y.transitions.create(["flex-basis","max-width"],{easing:t,duration:e})}},[p,y,h,x]),T={defaultExpanded:o,expandedGridSize:s,collapsedGridSize:d,persistState:!0,ariaLabel:"Toggle summary panel",...r,onToggle:C,children:l,storageKey:g};return e.jsxs(u.Grid,{container:!0,...c,children:[e.jsx(u.Grid,{item:!0,xs:j,sx:{...S,...a.sx},...a,children:t}),e.jsx(kt,{...T})]})},exports.DynamicModal=({open:t,onClose:a,title:r,children:n,handleSaveAction:i,buttons:s=[],...d})=>{const{t:c}=w.useTranslation(),m=s.length?[...s]:[{label:c("common.cancel"),onClick:a,variant:"outlined",sx:{color:"black !important"}},...i?[{label:c("common.save"),onClick:i,variant:"contained",color:"primary"}]:[]];return e.jsxs(o.Modal,{open:t,onClose:a,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,...d,children:[e.jsxs(u.DialogTitle,{id:"alert-dialog-title",className:"itemEntryModal--DialogTitle",children:[e.jsx(h.Typography,{type:"s3",color:"inherit",weight:"medium",children:c(r)}),e.jsx(u.IconButton,{onClick:a,children:e.jsx(l,{fontSize:"small"})})]}),e.jsx(u.DialogContent,{children:n}),e.jsx(u.DialogActions,{children:m.map((t,a)=>e.jsx(o.Button,{sx:{...t.sx},onClick:t.onClick,variant:t.variant,color:t.color,children:t.label},a))})]})},exports.ElementController=We,exports.EntityViewWrapper=function({fetchEntity:t,fallbackRoute:a,children:l,idField:r="id"}){const n=W.useParams(),o=W.useLocation(),s=W.useNavigate(),[d,c]=i.useState(null),[u,m]=i.useState(!0);return i.useEffect(()=>{(async()=>{m(!0);const e=N.getEntityId(n,o,r);if(e)try{const a=await t(e);c(a)}catch(l){console.error("Error fetching entity:",l),s(a)}finally{m(!1)}else s(a)})()},[t,n,o,s,a,r]),u?e.jsx(V.ErpLoader,{}):d?e.jsx(e.Fragment,{children:l(d)}):null},exports.ExpandableSummaryWrapper=kt,exports.FormData=[{field_type:"text",label:"Name",placeholder:"Enter name",default_value:"",min_length:2,max_length:30,is_multiline:!1,is_required:!0,is_unique:!1,id:"35356fb9-9007-495a-ba9e-925449cb3eb2"},{field_type:"email",label:"Email",placeholder:"Enter email address",default_value:"",is_required:!1,is_unique:!1,id:"4f4ac646-bf48-4ed3-ae5b-910071e19b59"},{field_type:"phone",label:"Phone",placeholder:"Enter phone number",default_value:"",is_required:!1,is_unique:!1,id:"500d8a78-e389-474d-831b-43190da011a6"},{field_type:"select",label:"Status",placeholder:"Choose option",default_value:"option1",options:[{text:"Active",value:"1"},{text:"Inactive",value:"0"}],is_multiselect:!1,is_required:!0,is_unique:!1,id:"fa44f220-0d82-4569-a28c-997de8e66d5a"},{field_type:"text",label:"Address",placeholder:"Enter address",default_value:"",min_length:2,max_length:30,is_multiline:!1,is_required:!0,is_unique:!1,id:"d25f2f1b-811f-4c3d-a53b-5162f766ad47"},{field_type:"text",label:"Message",placeholder:"Enter message",default_value:"",min_length:2,max_length:30,is_multiline:!1,is_required:!0,is_unique:!1,id:"22de0b1b-080a-4a0b-9d5f-e6f4916d8b07"}],exports.FormLoader=t=>e.jsx(ha,{children:e.jsx(pa,{size:50,...t})}),exports.Forms=({config:t})=>{const{t:a}=w.useTranslation();M.useAppTranslations();const l=W.useNavigate(),r=W.useLocation(),{user:o}=h.useAuth();console.log("user.........",o),ce.useApi();const[s,d]=i.useState({rows:[],isLoading:!1,paginationModel:{pageNo:1,limit:10,totalCount:0}}),[c,m]=i.useState(()=>{const e=localStorage.getItem("form-view");return e?JSON.parse(e):ra}),[p,x]=i.useState(""),[g,y]=i.useState(()=>{var e;return(null==(e=null==c?void 0:c[0])?void 0:e.label)||X.viewTypes.TABLE}),[v,f]=i.useState(la),[b,C]=i.useState([]),S=i.useMemo(()=>r.pathname.split("/")[2],[r.pathname]),k=i.useMemo(()=>({...t}),[t]),_=i.useMemo(()=>k[S]||{filterName:"",redirectionPath:""},[S,k]);console.log("external moduleConfig..........",_);const D=i.useMemo(()=>`/dashboard/${S}${_.redirectionPath}`,[S,_.redirectionPath]),A=i.useMemo(()=>`(company_id.eq=${null==o?void 0:o.company_id}&module.eq=${_.filterName})`,[null==o?void 0:o.company_id,_.filterName]),N=i.useMemo(()=>{const{pageNo:e,limit:t,totalCount:a}=s.paginationModel;return{total:t?Math.ceil(a/t):0,skip:t*(e-1),pageNo:e,limit:t}},[s.paginationModel]),B=i.useCallback(e=>e?e.split(/[:_-]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):e,[]),E=i.useCallback(e=>{f(e.slice(1))},[]),R=i.useCallback(e=>{d(t=>({...t,paginationModel:{...e,totalCount:t.paginationModel.totalCount}}))},[]),I=i.useCallback(e=>{x(e)},[]),P=i.useCallback(e=>{l(D,{state:e})},[l,D]),F=i.useMemo(()=>[{accessorKey:"name",header:"Form Name",visible:!0,Cell:({row:t})=>{var a;return(null==(a=null==t?void 0:t.original)?void 0:a.name)?e.jsx("div",{onClick:()=>P(t.original),style:{cursor:"pointer"},children:B(t.original.name)}):"-"}},{accessorKey:"fields.length",header:"No. of Fields",visible:!0,size:150},{accessorKey:"fields",header:"No. of custom fields",visible:!0,size:80,Cell:({row:t})=>{var a;return(null==(a=null==t?void 0:t.original)?void 0:a.fields)?e.jsx("div",{children:t.original.fields.filter(e=>!e.is_system_field).length}):"-"}},{accessorKey:"fields",header:"Custom Fields",visible:!0,Cell:({row:t})=>{var l,r;const n=(null==(r=null==(l=null==t?void 0:t.original)?void 0:l.fields)?void 0:r.filter(e=>!(null==e?void 0:e.is_system_field)&&(null==e?void 0:e.label)))||[];return n.length?e.jsxs(u.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexWrap:"wrap",p:.5},children:[n.slice(0,5).map((t,l)=>{var r;return e.jsx(h.Typography,{type:"s5",weight:"medium",className:"forms--CustomField",children:(null==(r=null==t?void 0:t.label)?void 0:r.includes("."))?a(t.label):t.label},`${t.label}-${l}`)}),n.length>5&&e.jsxs(h.Typography,{type:"s5",weight:"medium",className:"forms--CustomField",children:["+",n.length-5," more"]})]}):"-"}}],[B,P,a]),$=i.useMemo(()=>[{name:"Default",_id:1,data:[]}],[]),z=i.useCallback(async()=>{var e,t,a;if(console.log("moduleConfig.............",_),!_.filterName||!(null==o?void 0:o.company_id))return;const l=null==b?void 0:b[0],r={skip:N.skip,limit:N.limit,search:p,filters:A,...l&&{order:`${l.id}:${l.desc?-1:1}`},...j.getToken(),"x-timezone":(null==(e=j.getToken()["x-timezone"])?void 0:e.toString())||""};console.log("params..............",r),d(e=>({...e,isLoading:!0}));const n=await T.getV1FormBuilder({...r,...j.getToken});console.log("response........",n),d({rows:null==(t=null==n?void 0:n.data)?void 0:t.form,isLoading:!1,paginationModel:{...s.paginationModel,...null==(a=null==n?void 0:n.data)?void 0:a.pagination}})},[A,N.skip,N.limit,b,p,_.filterName,null==o?void 0:o.company_id]);return i.useEffect(()=>{z()},[z]),i.useEffect(()=>{(null==c?void 0:c.length)&&c[0].label!==g&&y(c[0].label)},[c]),i.useEffect(()=>{if(null==c?void 0:c.length){const e=setTimeout(()=>{localStorage.setItem("form-view",JSON.stringify(c))},300);return()=>clearTimeout(e)}},[c]),e.jsxs("section",{className:"forms",children:[e.jsx(n.ActionBar,{title:"Form",button:!1,data:c,setData:m,active:g,setActive:e=>{y(e)},handleSearch:I,showFilter:!1}),g===X.viewTypes.TABLE&&e.jsx(n.MaterialTable,{enablePagination:!1,columnOrder:["mrt-row-select",...v],handleColumnOrdering:E,rows:s.rows,columns:F,totalPages:1,paginationModel:{pageNo:1,limit:10},enableEditing:!1,states:{sorting:b||[]},onSortingChange:C,disableDefaultActionColumn:!0,getSelectedData:()=>{}}),g===X.viewTypes.GRID&&e.jsx(aa,{data:s.rows,config:t}),e.jsx(n.Footer,{pages:$,setPages:()=>{},currentPage:1,setCurrentPage:()=>{},total:N.total,paginationModel:{pageNo:s.paginationModel.pageNo,limit:s.paginationModel.limit},handlePaginationModel:R,sharedPages:[],resource:"",savePageConfiguration:()=>{},handlePageDelete:()=>{},enablePages:!1,isPaginationDisplayed:!0})]})},exports.GanttChart=t=>{var a,l,r,n,o,s,d,c,u,m,p,h;const{data:x,showList:g,progressChange:y,dateChange:v}=t,f=H(),b=x,[j,w]=i.useState(b),C=null==(l=null==(a=null==f?void 0:f.palette)?void 0:a.theme)?void 0:l.tertiary6[300],S=null==(n=null==(r=null==f?void 0:f.palette)?void 0:r.theme)?void 0:n.tertiary6[200],T=null==(s=null==(o=null==f?void 0:f.palette)?void 0:o.theme)?void 0:s.tertiary4[700],k=null==(c=null==(d=null==f?void 0:f.palette)?void 0:d.theme)?void 0:c.tertiary3[400],_=null==(m=null==(u=null==f?void 0:f.palette)?void 0:u.theme)?void 0:m.tertiary3[300],D=null==(h=null==(p=null==f?void 0:f.palette)?void 0:p.theme)?void 0:h.tertiary5[400];return e.jsx(K.Gantt,{tasks:j,viewMode:K.ViewMode.Day,listCellWidth:g?"190px":"",columnWidth:80,barCornerRadius:8,fontSize:"12",fontFamily:"Inter",onProgressChange:y?e=>{if(y){const t=b.findIndex(t=>t.id===e.id),a=[...b];a[t]=e,w(a)}}:void 0,onDateChange:v?e=>{if(v){const t=b.findIndex(t=>t.id===e.id),a=[...b];a[t]=e,w(a)}}:void 0,barProgressColor:C,barProgressSelectedColor:C,barBackgroundColor:S,barBackgroundSelectedColor:S,milestoneBackgroundColor:T,milestoneBackgroundSelectedColor:T,projectBackgroundColor:_,projectBackgroundSelectedColor:_,projectProgressColor:k,projectProgressSelectedColor:k,todayColor:D,onExpanderClick:e=>{w(t=>t.map(t=>t.id===e.id?e:t))}})},exports.GeneralScheduleReport=({module:t="accounting",title:a="Schedule report"})=>{const[l,r]=i.useState({pageNo:1,limit:10,totalCount:0}),[s,m]=i.useState(null),[p,x]=i.useState(!0),[g,y]=i.useState(!1),[v,f]=i.useState(null);console.log("🚀 ~ GeneralScheduleReport ~ openScheduleModal:",v);const[b,C]=i.useState(!1),[k,D]=i.useState(null),[M,A]=i.useState([]),N=null==l?void 0:l.limit,B=N?Math.ceil((null==l?void 0:l.totalCount)/N):0,E=N*((null==l?void 0:l.pageNo)-1)||0,{t:R}=w.useTranslation(),I=i.useMemo(()=>S.transformTableColumns({columns:Et,currencySymbol:void 0,translationFn:R,enableFooter:!0,redirectionLink:void 0,redirectionLinkState:void 0,rows:M,statusClasses:"scheduleReport--StatusChip--",customizeValue:(t,a,l)=>"emails"===a?(t=>{const a=null==t?void 0:t.split(",");return a?e.jsx(u.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:a.map(t=>e.jsx(S.Chip,{type:"normal",label:e.jsx(h.Typography,{type:"s4",weight:"medium",color:"inherit",children:t})},t))}):"-"})(l):l}),[Et,M,R]),P=i.useCallback(async()=>{try{y(!0);const{data:e={},pagination:a}=await(async e=>{try{return await T.getV1ReportsScheduleReport(e)}catch(t){console.log("error",t)}})({...j.getToken(),skip:E,limit:N,filters:`(type.eq=${t})`});A(null==e?void 0:e.schedulers),r(e=>({...e,...a}))}catch(e){const t=j.getErrorMessage(null==e?void 0:e.message);m({type:"alert",message:t})}finally{y(!1),x(!1)}},[N,E,t,r]),F=i.useCallback(async()=>{P()},[]);return i.useEffect(()=>{P()},[P]),e.jsxs("section",{className:"scheduleReport",children:[e.jsx(u.Box,{p:2,display:"flex",alignItems:"center",justifyContent:"space-between",children:e.jsx(h.Typography,{type:"h3",weight:"bold",color:"inherit",children:a})}),p?e.jsx(V.ErpLoader,{}):e.jsx(e.Fragment,{children:(null==M?void 0:M.length)>0?e.jsxs(e.Fragment,{children:[e.jsx(n.MaterialTable,{rows:M||[],columns:I,totalPages:0,columnOrder:["mrt-row-select"],states:{isLoading:g},enableColumnDragging:!0,enableEditing:!1,isResetRow:!1,enableRowSelection:!1,paginationModel:{pageNo:1,limit:10},defaultActionColumnItems:[e.jsx(u.IconButton,{onClick:({row:e})=>f(null==e?void 0:e.original),children:e.jsx(_.Edit,{fontSize:"small",htmlColor:"#292D32"})}),e.jsx(u.IconButton,{onClick:({row:e})=>D(null==e?void 0:e.original),children:e.jsx(_.Trash,{fontSize:"small",htmlColor:"#292D32"})})]}),e.jsx(n.Footer,{total:B,paginationModel:{...l,limit:null==l?void 0:l.limit},handlePaginationModel:e=>{r(e)},resource:"purchase-request",enablePages:!1})]}):e.jsx(e.Fragment,{children:!M.length&&e.jsx(n.Fallback,{heading:"No schedule report",subHeading:"Add schedule report",icon:e.jsx("img",{src:d.images.reportsFallback}),children:e.jsx(o.Button,{variant:"contained",startIcon:e.jsx(c.Add,{}),onClick:()=>f(!0),children:"Add"})})})}),e.jsx(o.Toast,{open:Boolean(s),type:null==s?void 0:s.type,message:null==s?void 0:s.message,handleClose:()=>m(null),anchorOrigin:{horizontal:"right",vertical:"bottom"}}),e.jsx(Ot,{isOpen:Boolean(v),onClose:()=>f(null),itemData:v,onSubmit:F,module:t}),e.jsx(o.ConfirmPopUp,{open:Boolean(k),onClose:()=>D(null),onConfirm:async()=>{try{k&&(C(!0),await(async e=>{try{const{data:t={}}=await T.deleteV1ReportsScheduleReportId(e);return t}catch(t){console.log("error",t)}})({...j.getToken(),id:k.id}),m({type:"normal",message:"Report schedule deleted successfully"}),P(),D(null))}catch(e){const t=j.getErrorMessage(null==e?void 0:e.message);m({type:"alert",message:t})}finally{C(!1)}},title:"Delete schedule report",loading:b,description:`Are you sure you want to delete schedule report: ${null==k?void 0:k.name} ?`})]})},exports.GridCard=aa,exports.GridCard$1=t=>e.jsx(e.Fragment,{children:t.data.map(t=>e.jsx(ea,{data:t}))}),exports.GridFallback=t=>{const{heading:a="",subHeading:l="No data available",icon:r=e.jsx("img",{src:d.images.invoiceFallback}),children:n,...o}=t;return e.jsxs(u.Box,{className:"fallback",...o,children:[r,e.jsx(h.Typography,{type:"h5",weight:"medium",color:"theme.secondary.1000",className:"fallback--Text",children:a}),e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.800",className:"fallback--Text",children:l}),e.jsx("div",{children:n})]})},exports.GridWrapper=ta,exports.GroupedBarChart=({chartData:t,height:a=500,barWidth:l=40,margin:r={top:40,right:20,bottom:40,left:50},line:n=!1})=>{var o;const s=i.useRef(null),d=i.useRef(null),c=i.useRef(null),[u,m]=i.useState(0),p=i.useMemo(()=>Math.max(...t.map(e=>e.data.map(e=>e.value)).flat()),[t]),x=t.length>12,g=x?Math.max(120*t.length,u):u,{user:y}=h.useAuth(),v=(null==(o=null==y?void 0:y.currency_data)?void 0:o.symbol)||"";return i.useEffect(()=>{const e=d.current,t=new ResizeObserver(e=>{if(e[0]){const t=e[0].contentRect.width;m(t)}});return e&&t.observe(e),()=>{e&&t.unobserve(e)}},[]),i.useEffect(()=>{if(0===u)return;const e=g-r.left-r.right,o=p?a-r.top-r.bottom:0;Ye.select(s.current).selectAll("*").remove();const i=Ye.select(s.current).attr("height",a).append("g").attr("transform",`translate(${r.left}, ${p?r.top:a-50})`),d=Ye.scaleBand().domain(t.map(e=>e.month)).range([0,e]).padding(.2),c=Ye.scaleBand().domain(["Total Transaction","Total Value","Average Value"]).range([0,d.bandwidth()]).padding(.1),m=Ye.scaleLinear().domain([0,Ye.max(t,e=>Ye.max(e.data,e=>e.value))]).nice().range([o,0]),h=i.append("g").attr("class","x-axis").attr("transform",`translate(0, ${o})`).call(Ye.axisBottom(d).tickPadding(20));i.append("g").attr("class","y-axis").call(Ye.axisLeft(m).tickPadding(10).tickFormat(e=>{return t=e,`${v} ${Ye.format(".2s")(t).replace("k","K")}`;var t})).select(".domain").attr("stroke","none"),h.select(".domain").attr("stroke","none"),n&&i.selectAll(".grid-line").data(m.ticks()).enter().append("line").attr("class","grid-line").attr("x1",0).attr("x2",e).attr("y1",e=>m(e)).attr("y2",e=>m(e)).style("stroke","#ddd").style("stroke-dasharray","3,3").style("stroke-width",1),i.selectAll(".month-group").data(t).enter().append("g").attr("class","month-group").attr("transform",e=>`translate(${d(e.month)}, 0)`).selectAll("rect").data(e=>e.data).enter().append("rect").attr("x",e=>c(e.type)+(c.bandwidth()-l)/2).attr("y",e=>m(e.value)).attr("width",l).attr("height",e=>o-m(e.value)).attr("fill",e=>e.color).attr("rx",5).attr("ry",5)},[t,l,a,g,u,n,r,v,p]),e.jsx("div",{ref:d,style:{width:"100%",height:"100%"},children:e.jsx("div",{style:{position:"relative"},children:e.jsx("div",{ref:c,style:{width:"100%",overflowX:x?"auto":"hidden",overflowY:"hidden"},children:e.jsx("svg",{ref:s,width:g,height:a,viewBox:`0 0 ${g} ${a}`,style:{display:"block"}})})})})},exports.HrLine=t=>{const{title:a}=t;return e.jsxs("div",{className:"HrLine",children:[e.jsx("hr",{className:"HrLine--Length"}),a,e.jsx("hr",{className:"HrLine--Length"})]})},exports.InventoryReportsTitleBar=t=>{const{title:a,handleAddButton:l,buttons:r=[],dropdownMenuButtonData:s,isTitleMenu:c=!1,titleMenus:m=[],reportFilterFields:x=[],toggleCallback:g,tabs:y,activeValue:v,setActiveValue:f,isDateFilterEnabled:b,onDateFilterChange:w,filters:C={},isDateRange:S=!0,activeView:T="",setActiveView:k,handleSearch:D,showLevelBtn:M=!1,handleRowsExpand:A,handleRowsCollapse:B,customElement:E,showLeftContent:R=!0,isViewButton:I=!1,handleRedirect:P,buttonText:F="",dataLength:$,filterDropDown:z=[],filterKeys:q,customFilterConfig:O=[],customSelectedFilter:L=[],showDateFilter:Y=!0,customFilterComponents:W=[]}=t,V=[...Y?[{value:"date"}]:[],{value:"location"},{value:"company"}],K=[{key:"company",label:"Search Company",placeholder:"Company",apiType:"company",valueKey:(null==q?void 0:q.company)?q.company:"company",customFilter:null},{key:"assembly_item",label:"Search Assembaly Items",placeholder:"Assembaly Items",apiType:"assemblyItems",valueKey:(null==q?void 0:q.assembly_item)?q.assembly_item:"assembly_item_id"},{key:"item",label:"Search Items",placeholder:"Items",apiType:"reportItems",valueKey:(null==q?void 0:q.item)?q.item:"item_id",multiple:!0},{key:"location",label:"Search Warehouse Location",placeholder:"Warehouse Location",apiType:"location",valueKey:(null==q?void 0:q.location)?q.location:"warehouse_id",customFilter:null,multiple:!0},{key:"bom",label:"Search Bill of Materials",placeholder:"Filter Bill of Materials",apiType:"bom",valueKey:(null==q?void 0:q.bom)?q.bom:"bom_id",customFilter:null,multiple:!0},{key:"work_order",label:"Search Work Order",placeholder:" Work Order",apiType:"workOrder",valueKey:(null==q?void 0:q.work_order)?q.work_order:"work_order_id",customFilter:null,multiple:!0},{key:"routing",label:"Search Routing",placeholder:" Routing",apiType:"routing",valueKey:(null==q?void 0:q.routing)?q.routing:"routing_id",customFilter:null,multiple:!0},{key:"operation",label:"Search Operation",placeholder:" Operation",apiType:"operations",valueKey:(null==q?void 0:q.operation)?q.operation:"operation_id",customFilter:null,multiple:!0},{key:"equipment",label:"Search Equipment",placeholder:" Equipment",apiType:"equipment",valueKey:(null==q?void 0:q.equipment)?q.equipment:"equipment_id",customFilter:null,multiple:!0},{key:"work_center",label:"Search Work Center",placeholder:" Work Center",apiType:"workCenter",valueKey:(null==q?void 0:q.work_center)?q.work_center:"work_center_id",customFilter:null,multiple:!0}],H=i.useMemo(()=>[...K,...O],[]),J={border:"none","&.Mui-focused":{borderColor:"transparent"},"& .MuiOutlinedInput-input":{padding:"0px",fontSize:"14px",color:"#289b64"},"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiSelect-icon":{color:"green"}},Q=e=>{if(w)if(Y)w(e);else{const{start_date:t,end_date:a,as_of_date:l,...r}=e;w(r)}},[Z,ee]=i.useState([]),[te,ae]=i.useState("TODAY"),[le,re]=i.useState(!1),[ne,oe]=i.useState(new Date(p((null==C?void 0:C.as_of_date)||"").format("YYYY-MM-DD"))),ie=i.useMemo(()=>[...V,...L],[]),[se,de]=i.useState(ie),[ce,ue]=i.useState(1),[me,pe]=i.useState({startDate:new Date(p((null==C?void 0:C.start_date)||"").format("YYYY-MM-DD")),endDate:new Date(p((null==C?void 0:C.end_date)||"").format("YYYY-MM-DD")),key:"selection"}),he=i.useRef(null),[xe,ge]=i.useState(null),ye=i.useRef(null),ve=i.useRef(null),fe=()=>{he.current=null,re(!1)},be=e=>{if(Y)if(ae(e),"CUSTOM"===e)he.current=ye.current,re(!0);else{const t=N.handleCompareDateRangeSync({range:N.RANGE[e],from:"",to:""});Q({start_date:(null==t?void 0:t.from)?null==t?void 0:t.from:"",end_date:(null==t?void 0:t.to)?null==t?void 0:t.to:""}),fe()}},je=e=>{he.current&&he.current.contains(e.target)||fe()},we=[{label:N.RANGE.TODAY,callback:()=>{be("TODAY")}},{label:N.RANGE.THIS_WEEK,callback:()=>{be("THIS_WEEK")}},{label:N.RANGE.THIS_MONTH,callback:()=>{be("THIS_MONTH")}},{label:N.RANGE.THIS_QUARTER,callback:()=>{be("THIS_QUARTER")}},{label:N.RANGE.THIS_YEAR,callback:()=>{be("THIS_YEAR")}},{label:N.RANGE.YESTERDAY,callback:()=>{be("YESTERDAY")}},{label:N.RANGE.PREVIOUS_WEEK,callback:()=>{be("PREVIOUS_WEEK")}},{label:N.RANGE.PREVIOUS_MONTH,callback:()=>{be("PREVIOUS_MONTH")}},{label:N.RANGE.PREVIOUS_QUARTER,callback:()=>{be("PREVIOUS_QUARTER")}},{label:N.RANGE.PREVIOUS_YEAR,callback:()=>{be("PREVIOUS_YEAR")}},{label:N.RANGE.CUSTOM,callback:()=>{be("CUSTOM")}}],Ce=()=>{const e={start_date:p(me.startDate).format("YYYY-MM-DD"),end_date:p(me.endDate).format("YYYY-MM-DD")},t={as_of_date:p(ne).format("YYYY-MM-DD")};Q({...S?e:t}),fe()};function Se(e){return se.some(t=>(null==t?void 0:t.value)==e)}return i.useEffect(()=>{oe(new Date(p((null==C?void 0:C.as_of_date)||"").format("YYYY-MM-DD")))},[null==C?void 0:C.as_of_date]),i.useEffect(()=>{pe({...me,startDate:new Date(p((null==C?void 0:C.start_date)||"").format("YYYY-MM-DD")),endDate:new Date(p((null==C?void 0:C.end_date)||"").format("YYYY-MM-DD"))})},[null==C?void 0:C.end_date,null==C?void 0:C.start_date]),i.useEffect(()=>{le&&(S?pe({...me,startDate:new Date(p((null==C?void 0:C.start_date)||"").format("YYYY-MM-DD")),endDate:new Date(p((null==C?void 0:C.end_date)||"").format("YYYY-MM-DD"))}):oe(new Date(p((null==C?void 0:C.as_of_date)||"").format("YYYY-MM-DD"))))},[le,S]),i.useEffect(()=>{ee(j.generateFields(x))},[x]),e.jsxs("div",{children:[e.jsxs("div",{className:"inventoryReportsTitleBar",children:[R&&e.jsxs("div",{className:"inventoryReportsTitleBar--LeftContent",children:[c?e.jsx("div",{style:{zIndex:999},children:e.jsx(n.TitleDropdownButton,{onClick:l,options:m,isMenuThirdItemDisabled:!0,children:a})}):e.jsx(h.Typography,{type:"h3",weight:"medium",color:"theme.secondary.1000",children:a}),[{label:X.viewTypes.TABLE,position:1},{label:X.viewTypes.CHART,position:2}].map(e=>e).sort((e,t)=>e.position-t.position).map(t=>e.jsx(n.HeaderCard,{title:null==t?void 0:t.label,active:T,onClick:()=>null==k?void 0:k(t.label)},null==t?void 0:t.position))]}),I&&e.jsx("div",{className:"inventoryReportsTitleBar--ExtraButtonUi",children:e.jsx(o.Button,{onClick:P,children:F})}),e.jsx(_t,{zIndex:999,className:"inventoryReportsTitleBar--RightContent",buttons:r,dropdownMenuButtonData:s,toggleCallback:g,variant:"contained",iconPosition:"end"}),E&&e.jsx(u.Box,{children:E})]}),e.jsx(u.Divider,{sx:{mb:2,mx:1,borderColor:"grey.200"}}),(null==y?void 0:y.length)?e.jsx("div",{children:e.jsx(n.TabBar,{tabs:y||[],activeValue:v,setActiveValue:f})}):null,e.jsxs(u.Box,{sx:{display:"flex",justifyContent:"space-between",gap:1,flexWrap:"wrap",mx:1},children:[e.jsxs("div",{className:"inventoryReportsTitleBar--FilterWrapper",children:[Y&&Se("date")&&S&&e.jsx("div",{style:{display:"flex",gap:"8px"},children:e.jsxs("div",{className:"inventoryReportsTitleBar--FilterWrapper--Chip",ref:ve,onClick:()=>{le?fe():(he.current=ve.current,re(!0))},children:[e.jsxs("div",{className:"inventoryReportsTitleBar--FilterWrapper--Chip--Text",title:`${p(null==C?void 0:C.start_date).format("DD/MM/YYYY")} - ${p(null==C?void 0:C.end_date).format("DD/MM/YYYY")}`,children:[e.jsx(h.Typography,{type:"s4",weight:"medium",children:"Date Range:"}),e.jsxs(h.Typography,{className:"inventoryReportsTitleBar--FilterWrapper--Chip--Text--Value",type:"s4",children:[p(null==C?void 0:C.start_date).format("DD/MM/YYYY")," -"," ",p(null==C?void 0:C.end_date).format("DD/MM/YYYY")]})]}),e.jsx(U,{})]})}),Y&&Se("date")&&(null==C?void 0:C.as_of_date)&&!S&&e.jsx("div",{style:{display:"flex",gap:"8px"},children:e.jsxs("div",{className:"inventoryReportsTitleBar--FilterWrapper--Chip",ref:ve,onClick:()=>{le?fe():(he.current=ve.current,re(!0))},children:[e.jsxs("div",{className:"inventoryReportsTitleBar--FilterWrapper--Chip--Text",title:`${p(null==C?void 0:C.as_of_date).format("DD/MM/YYYY")}`,children:[e.jsx(h.Typography,{type:"s4",weight:"medium",children:"Date:"}),e.jsx(h.Typography,{className:"inventoryReportsTitleBar--FilterWrapper--Chip--Text--Value",type:"s4",children:p(null==C?void 0:C.as_of_date).format("DD/MM/YYYY")})]}),e.jsx(U,{})]})}),e.jsxs(e.Fragment,{children:[H.map(({key:t,label:a,placeholder:l,apiType:r,valueKey:o,customFilter:i,multiple:s=!1})=>Se(t)?e.jsx("div",{className:"search-filter",children:e.jsx(n.SearchableSelect,{labelId:`${t}-label`,searchPlaceholder:a,value:null==C?void 0:C[o],onChange:e=>Q({[o]:e.target.value}),apiType:r,multiple:s,placeholder:l,customeFilter:i,customStyle:Dt,inputStyle:J})},t):null),W.map(({key:t,component:a})=>e.jsx(i.Fragment,{children:a},t))]})]}),b&&Y&&e.jsxs("div",{className:"inventoryReportsTitleBar--FilterAction",children:["(",e.jsxs(e.Fragment,{children:[e.jsx(_t,{zIndex:997,className:"inventoryReportsTitleBar--RightContent",dropdownMenuButtonData:{icon:e.jsx("img",{src:d.images.sidebar.calendar2}),children:e.jsxs(e.Fragment,{children:[N.RANGE[te],e.jsx(U,{})]}),options:we},toggleCallback:g}),e.jsx("div",{ref:ye})]}),")"]}),e.jsxs("div",{className:"inventoryReportsTitleBar--FilterAction",children:[e.jsx(o.Button,{sx:({palette:e})=>({border:"1px solid",borderColor:"grey.200",borderRadius:"50px",color:`${e.grey[800]} !important`,"&:hover":{bgcolor:`${e.grey[200]} !important`}}),variant:"text",startIcon:e.jsx(_.Filter,{fontSize:"small"}),onClick:e=>ge(e.currentTarget),children:"Filter"}),M&&e.jsx(u.Divider,{flexItem:!0,orientation:"vertical",sx:{alignSelf:"auto"}}),e.jsx(u.Menu,{anchorEl:xe,open:Boolean(xe),onClose:()=>{ge(null)},children:null==z?void 0:z.map(t=>{return e.jsxs(u.MenuItem,{onClick:()=>{return e=t,void(se.some(t=>t.value==e.value)?de(se.filter(t=>(null==t?void 0:t.value)!=e.value)):de([...se,e]));var e},value:null==t?void 0:t.value,children:[e.jsx(n.Checkbox,{checked:(a=t,se.some(e=>(null==e?void 0:e.value)==(null==a?void 0:a.value)))}),e.jsx(h.Typography,{sx:{marginLeft:"10px"},color:"theme.neutral.800",type:"s3",children:null==t?void 0:t.name})]},t);var a})}),M&&e.jsx(e.Fragment,{children:e.jsxs(u.Box,{className:"inventoryReportsTitleBar--FilterAction--lvWrapper",children:[e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"grey.800",children:[" Level ",ce," of ",$]}),e.jsxs(u.ButtonGroup,{variant:"outlined",disableElevation:!0,sx:({palette:e})=>({"& .MuiButton-root":{borderColor:`${e.grey[200]} !important`,"&:hover":{bgcolor:`${e.grey[200]} !important`}},"& .MuiButtonGroup-firstButton":{borderTopLeftRadius:20,borderBottomLeftRadius:20},"& .MuiButtonGroup-lastButton":{borderTopRightRadius:20,borderBottomRightRadius:20}}),children:[e.jsx(u.Button,{onClick:()=>{ue(ce==$?ce:ce+1),null==B||B(ce)},children:e.jsx("img",{src:d.images.common.expand})}),e.jsx(u.Button,{onClick:()=>{ue(1!=ce?ce-1:1),null==A||A(ce)},children:e.jsx("img",{src:d.images.common.collapse})})]})]})}),e.jsx(o.SearchBar,{placeholder:"Search",handleSearch:e=>null==D?void 0:D(e),sx:{width:"250px",background:"#fff !important",border:"1px solid #F3F2F2 !important"}})]})]}),e.jsx(u.Divider,{sx:{my:2,mx:1,borderColor:"grey.200"}}),e.jsx(u.Popper,{sx:{zIndex:9999},open:le,anchorEl:he.current,role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:t,placement:a})=>e.jsx(u.Grow,{...t,style:{margin:"0 20px 0 20px",transformOrigin:"bottom"===a?"center top":"center bottom"},children:e.jsx(u.Paper,{children:e.jsx(u.ClickAwayListener,{onClickAway:je,children:e.jsxs(u.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end"},children:[e.jsx("div",{children:S?e.jsx(G.DateRange,{editableDateInputs:!0,onChange:e=>pe(e.selection),moveRangeOnFirstSelection:!1,ranges:[me],locale:tt}):e.jsx(G.Calendar,{onChange:e=>oe(e),date:ne,locale:tt})}),e.jsx(u.Box,{sx:{padding:"0 12px 12px 0"},children:e.jsx(o.Button,{variant:"contained",sx:{width:"fit-content"},onClick:Ce,children:"Apply"})})]})})})})})]})},exports.ItemResponseDetails=t=>{var a;const{isOpen:l,onClose:r,data:s,isRental:d=!1}=t,[m,p]=i.useState([]),[x,g]=i.useState(!1),{t:y}=w.useTranslation(),v=i.useCallback(async()=>{if(l)try{g(!0);const e=`(rfq_line_item_id.in=${[null==s?void 0:s.id]})`,t=d?await j.fetchRentalResponseItems(e):await j.fetchRfqItemsByIdForResponse(e);p(t)}catch(e){const t=j.getErrorMessage(null==e?void 0:e.message);k.enqueueSnackbar(t,{variant:"error"})}finally{setTimeout(()=>g(!1),300)}},[l,null==s?void 0:s.id,d]);return i.useEffect(()=>{v()},[v]),e.jsxs(o.Modal,{open:l,onClose:r,maxWidth:"md",fullWidth:!0,children:[x&&e.jsx(n.ModalLoader,{}),e.jsxs(u.DialogTitle,{className:"itemEntryModal--DialogTitle",children:[e.jsx(h.Typography,{type:"s3",color:"inherit",weight:"medium",children:"Response Details"}),e.jsx(u.IconButton,{onClick:r,children:e.jsx(c.Close,{fontSize:"small"})})]}),e.jsx(u.Grid,{container:!0,children:e.jsx(u.Grid,{item:!0,xs:4,children:e.jsxs(u.Box,{sx:{display:"flex",padding:2,flexDirection:"column"},children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Item"}),e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.neutral.1000",children:null==(a=null==s?void 0:s.item_data)?void 0:a.name})]})})}),e.jsx(u.Grid,{container:!0,p:2,spacing:3,children:e.jsx(u.Grid,{item:!0,xs:12,children:e.jsx(u.Box,{sx:{paddingTop:"1.2rem"},children:e.jsx(n.MaterialTable,{rows:m||[],columns:S.transformTableColumns({columns:j.responseItemDetailsColumns,currencySymbol:void 0,translationFn:y,customizeValue:(e,t,a)=>{var l,r;if("item_data.vendor_info.vendor_name"===t)return a||(null==(r=null==(l=null==e?void 0:e.original)?void 0:l.item_data)?void 0:r.name)}}),paginationModel:{pageNo:1,limit:10},totalPages:20,enableColumnDragging:!0,isResetRow:!1,enableEditing:!1,columnOrder:["mrt-row-select"],enableRowSelection:!1,disabledDefaultActionColumnIcon:!0,enableBottomToolbar:!1})})})})]})},exports.LabelValue=({key:t,label:a,children:l})=>e.jsxs(u.Box,{gap:1,flexDirection:"column",display:"flex",children:[e.jsx(h.Typography,{type:"s3",weight:"bold",color:"theme.secondary.1000",children:a}),l]},t),exports.LineChart=({data:t,numOfLines:a=5,width:l=500,height:r=300})=>{const n=i.useRef(null),o=i.useRef(null),s=i.useMemo(()=>Math.max(...t.map(e=>e.value)),[t]),d=i.useMemo(()=>1.25*s,[s]),c=i.useMemo(()=>{const e=[],t=d/a;for(let l=0;l<=a;l++)e.push(t*l);return e},[d,a]),u=t.length>12?Math.max(120*t.length,l):l;return i.useEffect(()=>{const e=o.current,t=new ResizeObserver(e=>{if(e[0]){const t=e[0].contentRect.width;setContainerWidth(t)}});return e&&t.observe(e),()=>{e&&t.unobserve(e)}},[]),i.useEffect(()=>{const e=Ye.select(n.current);e.selectAll("*").remove();const a=u-40-20,o=r-20-70,i=Ye.scaleBand().domain(t.map(e=>e.label)).range([0,a]).padding(.1),s=Ye.scaleLinear().domain([0,Ye.max(t,e=>e.value)]).range([o,0]),d=e.append("g").attr("transform","translate(40,20)"),m=Ye.line().x(e=>i(e.label)+i.bandwidth()/2).y(e=>s(e.value));d.append("path").datum(t).attr("class","line").attr("d",m).style("fill","none").style("stroke","#357AF6").style("stroke-width",2),d.selectAll(".point").data(t).enter().append("circle").attr("class","point").attr("cx",e=>i(e.label)+i.bandwidth()/2).attr("cy",e=>s(e.value)).attr("r",4).style("fill","#357AF6").on("mousemove",(e,t)=>{const a=e.offsetX+40-25,l=e.offsetY+20-40,r=`${t.label} - ${t.value}`;h.attr("x",a).attr("y",l).style("opacity",9).style("height",r.length>=16?50:35),x.html(r)}).on("mouseleave",()=>{h.style("opacity",0)}),c.slice(1).forEach(e=>{d.append("line").attr("class","dotted-line").attr("x1",0).attr("y1",s(e)).attr("x2",l).attr("y2",s(e)).style("stroke","gray").style("stroke-dasharray","3,3")}),d.append("g").attr("class","x-axis").attr("transform",`translate(0, ${o})`).call(Ye.axisBottom(i)).selectAll(".tick line").remove();const p=d.append("g").attr("class","y-axis").call(Ye.axisLeft(s).tickValues(c).tickFormat(e=>{return(t=e)>=1e9?(t/1e9).toFixed(1)+"B":t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t;var t}).tickSizeOuter(0),0);p.selectAll(".domain").remove(),p.selectAll(".tick line").remove();const h=e.append("foreignObject").attr("class","tooltip").attr("width",120).attr("height",20).style("opacity",0).style("position","absolute").style("background-color","white").style("border","none").style("box-shadow","0rem 0rem 0.469rem 0rem rgba(0, 0, 0, 0.15)").style("border-radius","0.313rem").style("padding","0.625rem").style("font-size","0.75rem"),x=h.append("xhtml:div").style("font-size","0.75rem").style("color","black")},[t,r,l,d,c,u]),e.jsx("div",{ref:o,style:{width:"100%",height:"100%"},children:e.jsx("svg",{ref:n,width:u,height:r,viewBox:`0 0 ${u} ${r}`})})},exports.List=t=>{const[a,l]=i.useState(!1),[r,n]=i.useState(t.header),[o,s]=i.useState(t.tableData),[d,c]=i.useState(),[u,m]=i.useState(!0),p=i.useCallback(()=>l(!1),[]),h=ne.useExtraCells(),x=i.useCallback((e,t)=>{n(a=>{const l=r.findIndex(t=>t.title===e.title),n=[...a];return n.splice(l,1,{...a[l],width:t}),n})},[r]),g=i.useCallback(([e,t])=>{const a=o[t][r[e].id],{dataType:l}=r[e];return"Number"===l?{allowOverlay:!0,kind:re.GridCellKind.Number,data:a,displayData:a.toString()}:"Image"===l?{kind:re.GridCellKind.Image,data:[a],allowOverlay:!0,allowAdd:!0}:"Bubble"===l?{kind:re.GridCellKind.Bubble,data:["sss","ss"],allowOverlay:!0}:"SingleDropdown"===l?{kind:re.GridCellKind.Custom,allowOverlay:!0,copyData:"4",data:{kind:"dropdown-cell",allowedValues:["Good","Better","Best"],value:"Good"}}:"DatePicker"===l?{kind:re.GridCellKind.Custom,allowOverlay:!0,copyData:"4",data:{kind:"date-picker-cell",date:new Date,displayDate:(new Date).toISOString(),format:"date"}}:{kind:re.GridCellKind.Text,allowOverlay:!0,readonly:!1,displayData:a,data:a}},[o,r]),y=i.useCallback((e,t)=>{if(t.kind!==re.GridCellKind.Text)return;const[a,l]=e,n=r[a].id;o[l][n]=t.data,s(o)},[o,r]),v=i.useCallback(()=>{const e={};console.log(Object.entries(o[0]));for(const[t]of Object.entries(o[0]))e[t]="";s([...o,e])},[o]),f=i.useCallback(()=>{console.log("Header clicked")},[]),{renderLayer:b,layerProps:j}=oe.useLayer({isOpen:void 0!==d,triggerOffset:2,onOutsideClick:()=>{u&&(c(void 0),m(e=>!e)),m(e=>!e)},trigger:{getBounds:()=>({bottom:((null==d?void 0:d.bounds.y)??0)+((null==d?void 0:d.bounds.height)??0),height:(null==d?void 0:d.bounds.height)??0,left:(null==d?void 0:d.bounds.x)??0,right:((null==d?void 0:d.bounds.x)??0)+((null==d?void 0:d.bounds.width)??0),top:(null==d?void 0:d.bounds.y)??0,width:(null==d?void 0:d.bounds.width)??0})},placement:"bottom-end",auto:!0}),w=i.useCallback((e,t)=>{m(e=>!e),c({col:e,bounds:t})},[]),C=i.useCallback(()=>{const e=o.map(e=>({...e,new:""}));s(e),n([...r,{title:"New",id:"new",hasMenu:!0}])},[o,r]),S=i.useCallback((e,t)=>{n(a=>{const l=[...a],[r]=l.splice(e,1);return l.splice(t,0,r),l})},[]);return e.jsxs(J,{children:[e.jsx(Z,{expandIcon:e.jsx(ae,{}),children:e.jsx(te,{children:e.jsx(Q,{size:"small",color:"primary",icon:e.jsx(le,{}),label:"Accordion 1"})})}),e.jsx(ee,{}),e.jsx(re,{...h,getCellContent:g,columns:r,onCellEdited:y,onHeaderMenuClick:w,onHeaderClicked:f,onCellContextMenu:(e,t)=>t.preventDefault(),rows:o.length,rowMarkers:"both",showSearch:a,getCellsForSelection:!0,onSearchClose:p,onRowAppended:v,onDragOverCell:e=>{console.log(e)},onRowMoved:(e,t)=>window.alert(`Moved row ${e} to ${t}`),onColumnMoved:S,trailingRowOptions:{sticky:!0,tint:!1,hint:"New row..."},smoothScrollX:!0,smoothScrollY:!0,verticalBorder:e=>e>0,onDragStart:e=>{e.setData("text/plain","Drag data here!")},rightElement:e.jsx("div",{className:"addCol",children:e.jsx("button",{onClick:()=>C(),children:"+"})}),rightElementProps:{fill:!1,sticky:!0},onColumnResize:x}),e.jsx("div",{id:"portal"}),void 0!==d&&b(e.jsx("div",{...j,style:{...j.style,width:300,padding:4,borderRadius:8,backgroundColor:"white",border:"1px solid black"},children:e.jsxs("ul",{children:[e.jsx("li",{children:"Action 1"}),e.jsx("li",{children:"Action 2"}),e.jsx("li",{children:"Action 3"})]})}))]})},exports.ListingComponent=({title:t,tableColumns:a,columnOrder:l=["mrt-row-select"],rowActionMenu:s,destructiveActionMenu:c,handleAddButton:u,searchText:m,handleSearch:p,disabledViews:h=["Kanban","Calendar","Gantt"],fields:x,selectedIds:g=[],pageName:y,importModuleName:v,showAddButton:f=!0,actionButtons:b,paginationResource:j,enablePages:C=!1,GridComponent:S,onSelectRow:T,onColumnOrdering:_,onColumnVisibility:A,onSortingChange:N,fallbackIcon:B,className:E="",onDeleteConfirm:R,deleteTitle:I,deleteDescription:P,fetchApi:F,resetState:$,setPaginationModel:z,deleteApi:q,storeName:O,isUseFields:L,customeFilter:Y,customFields:W,isLoading:V,customRows:K=[],...H})=>{var U,G;const{t:J}=w.useTranslation(),Q=D.useDispatch(),{activePage:Z,updatePageInfo:ee}=ce.usePages(),{paginationModel:te,rows:ae,isLoading:le}=ue.useAppSelector(e=>null==e?void 0:e[O]),{pageNo:re,limit:ne,totalCount:oe}=te,ie=Z.page_size||ne,se=ie*(re-1),[de,me]=i.useState({selectedRows:g,itemToDelete:null,isDeleting:!1}),pe=Math.ceil(oe/ie),he=i.useMemo(()=>(null==K?void 0:K.length)?K:ae,[ae,K]),xe=e=>{me(t=>({...t,itemToDelete:e}))},ge=i.useMemo(()=>{if(c)return c.map(e=>({...e,handleAction:e.label.toLowerCase().includes("delete")?xe:e.handleAction}))},[c]),ye=e=>{Z.page_size!=(null==e?void 0:e.limit)&&ee({page_size:e.limit}),Q(z(e))},ve=i.useCallback(()=>{Q($())},[Q,$]),fe=M.useGenericDataFetcher((null==a?void 0:a.length)?a:Z,{skip:se,limit:ie},F,Y,[],!0,W);return i.useEffect(()=>{fe()},[fe]),i.useEffect(()=>ve,[ve]),i.useEffect(()=>{var e;(null==(e=null==Z?void 0:Z.views)?void 0:e.length)||ee({active_view:X.viewTypes.TABLE,views:[{label:"Table",position:0}]})},[null==Z?void 0:Z.views]),e.jsxs("section",{className:`listing-component ${E}`,children:[e.jsx(n.ActionBar,{title:t,data:(null==Z?void 0:Z.views)||[{label:"Table",position:0}],setData:e=>ee({views:e}),active:Z.active_view,setActive:e=>ee({active_view:e}),handleAddButton:u,searchText:m||Z.search||"",handleSearch:e=>{ee({search:e}),ye({pageNo:1}),null==p||p(e)},disabledViews:h,fields:x,isUseFields:L,selectedIds:de.selectedRows,pageName:y,importModuleName:v,button:f,actionBtn:b,...H}),e.jsxs(e.Fragment,{children:[(null==Z?void 0:Z.active_view)===X.viewTypes.TABLE&&e.jsx(n.MaterialTable,{rows:he||[],columns:a,paginationModel:te,totalPages:pe,columnOrder:[...l,...Z.column_order],states:{isLoading:V||le},onSortingChange:N?e=>{ee({sort:e}),N(e)}:void 0,enableColumnDragging:!1,enableEditing:!1,rowActionMenu:s,destructiveActionMenu:ge,isResetRow:!1,onSelectRow:e=>{const t=e.map(e=>e.original.id);me(e=>({...e,selectedRows:t})),null==T||T(e)},handleColumnOrdering:_?e=>{const t=e.slice(1);ee({column_order:t}),_(t)}:void 0,onColumnVisibility:A?e=>{ee({visible_columns:e}),A(e)}:void 0}),(null==Z?void 0:Z.active_view)===X.viewTypes.GRID&&S&&e.jsx(S,{data:he,rowActionMenu:s,destructiveActionMenu:ge}),!(null==Z?void 0:Z.active_view)&&!le&&e.jsx(n.Fallback,{heading:t,icon:B||e.jsx("img",{src:d.images.shippmentFallback,alt:"fallback"}),children:f&&u&&e.jsx(o.Button,{variant:"contained",startIcon:e.jsx(r,{}),onClick:u,children:`${J("common.add")} ${J("common.new")}`})}),e.jsx(n.Footer,{total:pe,paginationModel:{...te,limit:Z.page_size},handlePaginationModel:e=>{Z.page_size!==(null==e?void 0:e.limit)&&ee({page_size:e.limit}),ye(e)},resource:j,enablePages:C}),e.jsx(o.ConfirmPopUp,{open:Boolean(de.itemToDelete),onClose:()=>{me(e=>({...e,itemToDelete:null}))},onConfirm:async()=>{if(de.itemToDelete){me(e=>({...e,isDeleting:!0}));try{R?await R(de.itemToDelete):await(async e=>{const a=await Q(q(String(e.id)));M.apiHelper(a,()=>{k.enqueueSnackbar(` ${t}: ${null==e?void 0:e.id} ${J("common.msg.deleted")}`),fe()})})(de.itemToDelete),me(e=>({...e,itemToDelete:null,isDeleting:!1}))}catch(e){me(e=>({...e,isDeleting:!1}))}}},loading:de.isDeleting,title:I||`${J("common.delete")} ${t}`,description:P?P(de.itemToDelete):`${J("common.deleteMsg")} ${t}: ${(null==(U=de.itemToDelete)?void 0:U.id)||(null==(G=de.itemToDelete)?void 0:G.name)||""} ?`})]})]})},exports.MaterialEditableTable=Xt,exports.MultiLine=t=>{const{options:a}=t,[l,n]=i.useState(a),[s,c]=i.useState(null),m=Boolean(s),p=()=>{c(null)};return e.jsx("div",{className:"main-card-nodal",children:e.jsxs(bt,{children:[e.jsxs("div",{className:"payable-header",children:[e.jsx(h.Typography,{className:"payable-title",children:"Payable Account"}),e.jsx(u.IconButton,{color:"inherit",size:"small",onClick:e=>{c(e.currentTarget)},children:e.jsx("img",{src:d.images.more,alt:"more icon"})}),e.jsx(ie,{anchorEl:s,open:m,onClose:p,children:e.jsx(se,{onClick:p,children:"View"})})]}),e.jsx(o.SearchBar,{placeholder:"Search Companies",handleSearch:e=>{(e=>{const t=e.toLowerCase(),l=a.filter(e=>e.name.toLowerCase().includes(t)||e.role.toLowerCase().includes(t));n(l)})(e)},debounceTime:1}),l.map(t=>e.jsxs("div",{className:"list-items",children:[e.jsx(h.Typography,{className:"title",children:t.name}),e.jsx(h.Typography,{className:"description",children:t.role})]},t.id)),e.jsxs("div",{className:"bottom-footer",onClick:()=>{alert("Clicked ")},children:[e.jsx(r,{}),e.jsx(h.Typography,{children:"Create a Cost Center"})]})]})})},exports.MultiLineChart=({data:t,yAxisData:a,xAxisData:l,colors:r=["steelblue","orange","green","red"],height:n=400,margin:o={top:20,right:50,bottom:30,left:50},line:s=!1,yAxisLabelType:d="inValue",currency:c,customLabelFormatter:u})=>{const m=i.useRef(null),p=i.useRef(null),[h,x]=i.useState(0);return i.useEffect(()=>{},[d]),i.useEffect(()=>{const e=p.current,t=new ResizeObserver(e=>{if(e[0]){const t=e[0].contentRect.width;x(t)}});return e&&t.observe(e),()=>{e&&t.unobserve(e)}},[]),i.useEffect(()=>{if(0===h)return;const e=Ye.select(m.current);e.selectAll("*").remove();const i=h-o.left-o.right,p=n-o.top-o.bottom,x=Ye.scaleLinear().domain([0,l.length]).range([0,i]),g=Ye.scaleLinear().domain([0,Ye.max(a)]).nice().range([p,0]),y=e.append("g").attr("class","x-axis").attr("transform",`translate(${o.left},${n-o.bottom})`).call(Ye.axisBottom(x).ticks(l.length-1).tickFormat((e,t)=>l[t]));y.selectAll("text").attr("transform","translate(20, 10)").style("text-anchor","middle"),y.select(".domain").attr("stroke","none");const v=e.append("g").attr("class","y-axis").attr("transform",`translate(${o.left},${o.top})`).call(Ye.axisLeft(g).tickPadding(10).tickFormat(e=>{return u?u(e):(t=e,a=c,"inPercent"===(l=d)?`${Ye.format(".0%")(t/100)}`:"inValue"===l?`${a||""} ${Ye.format(".2s")(t).replace("k","K")}`:t.toString());var t,a,l}).tickSizeOuter(0));s&&v.selectAll(".grid-line").data(g.ticks()).enter().append("line").attr("class","grid-line").attr("x1",0).attr("x2",i).attr("y1",e=>g(e)).attr("y2",e=>g(e)).style("stroke","#ddd").style("stroke-dasharray","6,3").style("stroke-width",1),y.selectAll(".tick line").remove(),v.selectAll(".tick line").remove(),v.select(".domain").attr("stroke","none"),Object.keys(t).forEach((a,l)=>{var n,i,s;if("months"!==a){const d=Ye.line().x((e,t)=>x(t)).y(e=>g(e)).curve(t[a].isSmooth?Ye.curveMonotoneX:Ye.curveLinear);e.append("path").datum(null==(n=t[a])?void 0:n.data).attr("fill","none").attr("stroke",r[l%r.length]).attr("stroke-width",2).attr("transform",`translate(${o.left},${o.top})`).attr("d",d).on("mouseover",function(){Ye.select(this).attr("stroke-width",4)}).on("mouseout",function(){Ye.select(this).attr("stroke-width",2)}),(null==(i=t[a])?void 0:i.displayDot)&&e.selectAll(`.circle-${a}`).data(null==(s=t[a])?void 0:s.data).enter().append("circle").attr("class",`circle-${a}`).attr("cx",(e,t)=>x(t)+o.left).attr("cy",e=>g(e)+o.top).attr("r",4).attr("fill",r[l%r.length]).attr("stroke","white").attr("stroke-width",1.5).on("mouseover",function(){Ye.select(this).attr("r",6)}).on("mouseout",function(){Ye.select(this).attr("r",4)})}})},[t,a,l,n,h,r,o,s,d,c,u]),e.jsx("div",{ref:p,style:{width:"100%",height:"100%"},children:e.jsx("div",{style:{position:"relative"},children:e.jsx("svg",{ref:m,width:"100%",height:n,viewBox:`0 0 ${h} ${n}`})})})},exports.MultiSelect=Nt,exports.PageLoader=t=>e.jsx(u.Box,{position:"absolute",left:"50%",top:"50%",children:e.jsx(xa,{size:50,...t})}),exports.ProtectedRoute=({module:t,action:a,multiModule:l,complexPermissions:r,customPermissionCheck:n,redirectTo:o="/403",showError:s=!0,children:d})=>{const c=ce.usePermissions(),m=i.useMemo(()=>{if(!c)return!1;if(n)return n(c);if(r){const{permissions:e,operator:t="AND"}=r,a=e.map(({module:e,action:t})=>de.get(c,e,{})[t]??!1);return"AND"===t?a.every(Boolean):a.some(Boolean)}if(l){const{modules:e,action:t,operator:a="OR"}=l,r=e.map(e=>de.get(c,e,{})[t]??!1);return"AND"===a?r.every(Boolean):r.some(Boolean)}return!(!t||!a)&&(de.get(c,t,{})[a]??!1)},[c,t,a,l,r,n]),p=()=>e.jsxs(u.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",gap:2,textAlign:"center",p:3},children:[e.jsx(h.Typography,{type:"h1",color:"theme.secondary.900",weight:"bold",sx:{fontSize:{xs:"4rem",sm:"6rem"}},children:"403"}),e.jsx(u.Divider,{flexItem:!0}),e.jsx(h.Typography,{type:"s3",color:"theme.secondary.900",weight:"medium",children:"Access Denied"}),e.jsx(h.Typography,{type:"body2",color:"theme.secondary.700",weight:"regular",sx:{mt:1,maxWidth:"300px"},children:"You don't have the required permissions to access this resource."})]});return c&&0!==Object.keys(c).length?m?e.jsx(e.Fragment,{children:d}):s?e.jsx(p,{}):e.jsx(W.Navigate,{to:o,replace:!0}):null},exports.QuickApprovalModal=pt,exports.ReportButtons=Bt,exports.ReportTable=function({headers:t,data:a,tableHeaders:l,totalHeaders:r=[],handleSort:n,collapsLevel:s=0,isIncrese:d,enableSearch:c=!0,headerHeight:m="16px",onSelectionChange:x,enableCheckbox:g=!1,afterHeader:y,totalKey:v="total",rowHeight:f="auto"}){var b,j,C,T,k,_,D,M,A,N;const[B,E]=i.useState(null),[R,I]=i.useState(null),[P,F]=i.useState(null),[$,z]=i.useState({}),{t:q}=w.useTranslation(),[O,Y]=i.useState([]),[W,V]=i.useState({}),[K,H]=i.useState(null),U=i.useRef(0),G=i.useRef(0),X=i.useRef({}),[J,Q]=i.useState(!1),[Z,ee]=i.useState(!1);function te(e,t){var a;if(""==(null==t?void 0:t.name))return"";const l=(null==(a=null==t?void 0:t.name)?void 0:a.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e))||("0"==(null==t?void 0:t.name.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e))?"0":"-");return S.formateValueByType({value:l,...t})}function ae(e,t,a,l=[],r=0){if(!Array.isArray(e))return[];let n=[];return e.forEach((e,a)=>{var o,i;const s=[...l,a];(null==(o=t[r])?void 0:o.enableCheckbox)&&n.push(s);const d=r+1,c=null==(i=t[d])?void 0:i.rowKey;c&&Array.isArray(e[c])&&(n=n.concat(ae(e[c],t,0,s,d)))}),n}i.useEffect(()=>{var e;if(!J&&a&&t.length>0&&!Z){const r=function(e){const{maxRows:t,headers:a,data:l,tableHeaders:r,t:n}=e,o={};if(a.forEach(e=>{o[n(e.label)]=[]}),!l||!Array.isArray(l)||0===l.length)return o;let i=0;const s=t;return function e(t,d=0){var c;if(!Array.isArray(t)||i>=s)return;const u=r&&r[d]&&r[d].headers?r[d].headers:a;for(let m=0;m<t.length&&i<s;m++){const s=t[m];if(a.forEach(e=>{const t=n(e.label);if(!o[t])return;let a;if(u.find(e=>n(e.label)===t))if(e.render&&"function"==typeof e.render)try{const t=e.render(ma(s,e),s,l);if("string"==typeof t)a=t;else if("number"==typeof t)a=String(t);else if(t&&"object"==typeof t&&"props"in t){const e=t.props;a=e&&e.children?String(e.children):String(t)}else a=String(t)}catch(r){a=ca(ma(s,e),e.type)}else a=ca(ma(s,e),e.type);else a="-";o[t].push(a)}),i++,r&&r[d+1]){const t=null==(c=r[d+1])?void 0:c.rowKey;t&&s[t]&&Array.isArray(s[t])&&e(s[t],d+1)}}}(l,0),o}({maxRows:9999,headers:t,data:Array.isArray(a)?a:(null==a?void 0:a[null==(e=l[0])?void 0:e.rowKey])||[],tableHeaders:l,t:q}),n=function(e,t,a=oa,l={min:80,padding:24},r){const n={};return e.forEach(e=>{const o=r(e.label);if(e.width){const t="string"==typeof e.width?parseInt(e.width.replace(/[^\d]/g,""),10):e.width;return void(n[o]=t)}let i=da(o,a);e.enableSorting&&(i+=48);let s=0;(t[o]||[]).forEach(e=>{const t=da(e,a);s=Math.max(s,t)});let d=Math.max(i<100?i+24:i,s);d+=l.padding,d=s>10?Math.max(l.min,d):Math.max(60,d),l.max&&(d=Math.min(l.max,d)),n[o]=Math.round(d)>100?Math.round(d):100}),n}(t,r,oa,{min:100,padding:32,max:400},q);V(n),Q(!0)}},[a,t,J,Z,l]);const le=(e,t)=>{Y(a=>t?[...a,e]:a.filter(t=>!(t.length===e.length&&t.every((t,a)=>t===e[a]))))},re=ae(Array.isArray(P)?P:null==P?void 0:P[null==(b=l[0])?void 0:b.rowKey],l),ne=re.length>0&&re.every(e=>O.some(t=>t.length===e.length&&t.every((t,a)=>t===e[a]))),oe=re.some(e=>O.some(t=>t.length===e.length&&t.every((t,a)=>t===e[a])));function ie(e,t,a,l){if(null==e)return!1;const r=t.toLowerCase();return"string"==typeof a&&(a=[a]),"date"==(null==l?void 0:l.type)?p(e).format("DD-MM-YYYY").includes(r):"string"==typeof e?e.toLowerCase().includes(r):"object"==typeof e?Array.isArray(e)?e.some(e=>ie(e,r,a,l)):a?a.some(t=>{const a=e[t];if(null!=a)return"string"==typeof a?a.toLowerCase().includes(r):ie(a,r,null,l);const n=Object.keys(e).filter(t=>"object"==typeof e[t]&&null!==e[t]);return n.length>0&&n.some(t=>ie(e[t],r,null,l))}):Object.values(e).some(e=>ie(e,r,null,l)):String(e).toLowerCase().includes(r)}i.useEffect(()=>{var e,t,a;let r=Array.isArray(R)?R:null==R?void 0:R[null==(e=l[0])?void 0:e.rowKey];null==(t=Object.keys($))||t.forEach(e=>{var t,a;const l=null==(a=null==(t=null==$?void 0:$[e])?void 0:t.query)?void 0:a.toLowerCase();l&&(r=null==r?void 0:r.filter(t=>{var a;return ie(t,l,e,null==(a=null==$?void 0:$[e])?void 0:a.header)}))}),F(Array.isArray(R)?r:{...R,[null==(a=l[0])?void 0:a.rowKey]:r})},[$,R]);const se=e=>{if(!K)return;const t=e.clientX-U.current,a=Math.max(100,G.current+t);V(e=>({...e,[K]:a}))},de=()=>{H(null)};i.useEffect(()=>{if(K)return document.addEventListener("mousemove",se),document.addEventListener("mouseup",de),()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",de)}},[K]),i.useEffect(()=>{I(a),F(a),Q(!1)},[a]),i.useEffect(()=>()=>Q(!1),[]),i.useEffect(()=>{if(x){const e=O.filter(e=>{var t;const a=e.length-1;return null==(t=l[a])?void 0:t.enableCheckbox}).map(e=>function(e,t,a){var l,r;let n=Array.isArray(e)?e:null==e?void 0:e[null==(l=t[0])?void 0:l.rowKey],o=null;for(let i=0;i<a.length;i++){if(!n||!Array.isArray(n))return null;if(o=n[a[i]],i<a.length-1){const e=null==(r=t[i+1])?void 0:r.rowKey;n=null==o?void 0:o[e]}}return o}(P,l,e)).filter(Boolean);x(e)}},[O,P]);const ce=(null==P?void 0:P[v])&&!(0===(null==P?void 0:P.length)||0===(null==(C=P[null==(j=l[0])?void 0:j.rowKey])?void 0:C.length));return e.jsxs(u.TableContainer,{sx:{width:"100%",maxHeight:"600px",overflowX:"auto",backgroundColor:"white",display:"block",position:"relative"},className:"dynamic-reports",children:[e.jsxs(u.Table,{"aria-label":"collapsible table",sx:{borderCollapse:"collapse",width:"max-content",tableLayout:"fixed",marginBottom:ce?"0px":"10px"},children:[e.jsxs(u.TableHead,{sx:{position:"sticky",top:0,zIndex:10,backgroundColor:"white"},children:[e.jsxs(u.TableRow,{sx:{zIndex:11,backgroundColor:"white"},children:[g&&e.jsx(u.TableCell,{sx:{width:"60px",minWidth:"60px",maxWidth:"60px",height:m,padding:"8px",position:"sticky",left:0,backgroundColor:"white",zIndex:9999},children:e.jsx(Fe,{checked:ne,indeterminate:!ne&&oe,onChange:e=>(e=>{var t;const a=ae(Array.isArray(P)?P:null==P?void 0:P[null==(t=l[0])?void 0:t.rowKey],l);Y(e?a:[])})(e.target.checked)})}),t.map((t,a)=>{const l=(null==t?void 0:t.enableSorting)??!0,r=W[q(t.label)]||100;return e.jsxs(u.TableCell,{className:"dynamic-report-header",sx:{width:`${r}px`,minWidth:`${r}px`,maxWidth:`${r}px`,height:m,position:"relative",padding:"8px",overflow:"hidden"},children:[e.jsxs(u.Box,{ref:e=>X.current[t.name]=e,sx:{display:"flex",justifyContent:"space-between",height:m,alignItems:"center",width:"calc(100% - 8px)",overflow:"hidden",paddingRight:"0px"},children:[e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.primary",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0,lineHeight:"unset"},children:"string"==typeof(null==t?void 0:t.label)?q(null==t?void 0:t.label):null==t?void 0:t.label}),l&&e.jsx(u.IconButton,{size:"small",sx:{padding:"4px 0px"},onClick:()=>{ee(!0),E(B==t.name?null:t.name),n&&n(t.name,B==t.name?"asc":"desc")},children:B==t.name?e.jsx(ze.ArrowUp,{fontSize:"small"}):e.jsx(L.ArrowDown,{fontSize:"small"})})]}),e.jsx(u.Box,{className:"dynamic-report-resize-handle",onMouseDown:e=>((e,t)=>{console.log("columnName",t),e.preventDefault(),e.stopPropagation(),H(t),U.current=e.clientX,G.current=W[t]||100})(e,q(t.label)),sx:{position:"absolute",right:0,top:0,bottom:0,width:"16px",cursor:"col-resize",backgroundColor:"transparent","&:hover":{backgroundColor:"transparent","&::before, &::after":{backgroundColor:"transparent"}},"&::before":{content:'""',position:"absolute",left:"2px",top:0,bottom:0,width:"2px",backgroundColor:"transparent",transition:"background-color 0.2s ease"},"&::after":{content:'""',position:"absolute",right:"2px",top:0,bottom:0,width:"2px",backgroundColor:"transparent",transition:"background-color 0.2s ease"},zIndex:2,userSelect:"none"}})]},a)})]}),c&&e.jsxs(u.TableRow,{children:[g&&e.jsx(u.TableCell,{sx:{width:"60px",minWidth:"60px",maxWidth:"60px",height:m,padding:"0px",position:"sticky",left:0,backgroundColor:"white",zIndex:9999}}),t.map((a,l)=>{const r=W[q(a.label)]||50;return e.jsx(u.TableCell,{className:"dynamic-report-search",sx:{width:`${r}px`,minWidth:`${r}px`,maxWidth:`${r}px`,padding:"8px"},children:e.jsx(o.SearchBar,{sx:{padding:"4px !important"},InputProps:{sx:{marginLeft:"0.5rem !important"}},handleSearch:e=>{return r=e,n=a.name,o=t[l],void z(e=>({...e,[n]:{query:r,header:o}}));var r,n,o}})},null==a?void 0:a.label)})]}),y&&e.jsx(u.TableRow,{children:e.jsx(u.TableCell,{colSpan:t.length+(g?1:0),sx:{padding:0,borderBottom:"none",backgroundColor:"white"},children:i.createElement(y,{columnWidths:W})})})]}),P&&e.jsx(u.TableBody,{children:Array.isArray(P)?null==P?void 0:P.map((a,n,o)=>e.jsx(na,{level:0,rowPath:[n],rowData:a,tableHeaders:l,totalHeaders:r,headers:t,collapsAll:s>=n+1,collapsLevel:s,isIncrese:!!d,data:P,selectedRowPaths:O,onCheckboxChange:le,dataSlice:o,dataIndex:n,enableCheckBox:g,rowHeight:f,columnWidths:W},a.id||n)):(null==(T=l[0])?void 0:T.rowKey)&&e.jsx(e.Fragment,{children:null==(_=P[null==(k=l[0])?void 0:k.rowKey])?void 0:_.map((a,n,o)=>e.jsx(na,{level:0,rowPath:[n],rowData:a,tableHeaders:l,totalHeaders:r,headers:t,collapsAll:s>=n+1,collapsLevel:s,isIncrese:!!d,data:P,selectedRowPaths:O,onCheckboxChange:le,dataSlice:o,dataIndex:n,enableCheckBox:g,rowHeight:f,columnWidths:W},a.id||n))})})]}),ce&&e.jsx(u.Box,{sx:{bottom:"-2px",width:"max-content",backgroundColor:(null==(D=null==r?void 0:r[0])?void 0:D.bgColor)||"#FAFAFA",borderTop:"1px solid #e0e0e0"},children:e.jsx(u.Table,{sx:{width:"max-content",tableLayout:"fixed",marginBottom:0},children:e.jsx(u.TableBody,{children:e.jsxs(u.TableRow,{children:[g&&e.jsx(u.TableCell,{sx:{width:"60px",minWidth:"60px",maxWidth:"60px",padding:"8px",position:"sticky",left:0,backgroundColor:(null==(M=null==r?void 0:r[0])?void 0:M.bgColor)||"#FAFAFA",zIndex:10,borderBottom:"none"}}),null==r?void 0:r.map((a,l)=>{var n;if(a.joinWithLeft)return null;const o=-1==r.slice(l).findIndex(e=>!e.joinWithLeft&&e!==a)?null==(n=r.slice(l))?void 0:n.length:r.slice(l).findIndex(e=>!e.joinWithLeft&&e!==a),i=a.mergeCells&&o||1;let s=0;for(let e=l;e<l+i&&e<t.length;e++)s+=W[q(t[e].label)]||100;return e.jsx(u.TableCell,{className:"dynamic-report-row",colSpan:i,sx:{paddingLeft:"8px",width:`${s}px`,minWidth:`${s}px`,maxWidth:`${s}px`,borderBottom:"none"},children:e.jsx(u.Box,{sx:{display:"flex",alignItems:"center",justifyContent:`${(null==a?void 0:a.position)?null==a?void 0:a.position:"start"}`,width:"100%"},children:(null==a?void 0:a.render)?a.render(null==P?void 0:P[v][a.name],P):e.jsx(h.Typography,{type:"s4",weight:"bold",color:"theme.neutral.1000",children:te(null==P?void 0:P[v],a)})})},l)})]})})})}),(0===(null==a?void 0:a.length)||0===(null==(N=null==a?void 0:a[null==(A=l[0])?void 0:A.rowKey])?void 0:N.length))&&S.renderEmptyRowsFallback(q("common.noData"))]})},exports.ReportsTitleBar=t=>{var a;const{title:l,handleAddButton:r,buttons:s=[],dropdownMenuButtonData:c,isTitleMenu:m=!1,titleMenus:x=[],reportFilterFields:g=[],toggleCallback:y,tabs:v,activeValue:f,setActiveValue:b,isDateFilterEnabled:C=!0,onDateFilterChange:S,filters:T={},isDateRange:k=!1,showDateFilter:D=!0,dateFilter:M="TODAY",filterDropDown:A,handleRowsCollapse:B,handleRowsExpand:E,showLevelBtn:R=!1,dataLength:I=0,filterKeys:P={},searchBar:F,customFilterComponents:$=[]}=t,z=(null==P?void 0:P.start_date)||"start_date",q=(null==P?void 0:P.end_date)||"end_date",O=(null==P?void 0:P.as_of_date)||"as_of_date",L=ue.useAppDispatch(),Y={"&.MuiOutlinedInput-root":{"& fieldset":{border:"none",borderColor:"#ade7cb",borderRadius:"25px"},"& .MuiSelect-outlined":{padding:"4.5px 14px !important"},display:"flex",gap:"4px",width:"220px",border:"1px solid #ade7cb",borderRadius:"50px",backgroundColor:"#ebf9f2",color:"#289b64",alignItems:"center",cursor:"pointer",height:"32px"}},W={border:"none","&.Mui-focused":{borderColor:"transparent"},"& .MuiOutlinedInput-input":{fontSize:"14px",color:"#289b64"},"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiSelect-icon":{color:"green"}},V=[...D?[{value:"date"}]:[],{value:"company"}],[K,H]=i.useState(V),[X,J]=i.useState(1),[Q,Z]=i.useState(null),[ee,te]=i.useState([]),[ae,le]=i.useState(),[re,ne]=i.useState(!1),[oe,ie]=i.useState(null),[se,de]=i.useState(p(null==T?void 0:T[O]).isValid()?p(null==T?void 0:T[O]).toDate():new Date),{t:ce}=w.useTranslation(),[pe,he]=i.useState({startDate:p(null==T?void 0:T[z]).isValid()?p(null==T?void 0:T[z]).toDate():new Date,endDate:p(null==T?void 0:T[q]).isValid()?p(null==T?void 0:T[q]).toDate():new Date,key:"selection"}),xe=i.useRef(null),ge=i.useRef(null),ye=i.useRef(null),ve=()=>{xe.current=null,ne(!1)},fe=e=>{if(!S)return;let t={...e};if(e.hasOwnProperty("start_date")&&(null==P?void 0:P.start_date)&&(t[P.start_date]=e.start_date,"start_date"!==P.start_date&&delete t.start_date),e.hasOwnProperty("end_date")&&(null==P?void 0:P.end_date)&&(t[P.end_date]=e.end_date,"end_date"!==P.end_date&&delete t.end_date),e.hasOwnProperty("as_of_date")&&(null==P?void 0:P.as_of_date)&&(t[P.as_of_date]=e.as_of_date,"as_of_date"!==P.as_of_date&&delete t.as_of_date),D)S(t);else{const e=["start_date","end_date","as_of_date",null==P?void 0:P.start_date,null==P?void 0:P.end_date,null==P?void 0:P.as_of_date].filter(Boolean),a={...t};e.forEach(e=>delete a[e]),S(a)}},be=async e=>{if(D)if(le(e),"CUSTOM"===e)xe.current=ge.current,ne(!0);else{const t=await N.handleCompareDateRange({range:N.RANGE[e],from:"",to:""});fe({start_date:(null==t?void 0:t.from)?null==t?void 0:t.from:"",end_date:(null==t?void 0:t.to)?null==t?void 0:t.to:""}),ve()}},je=e=>{xe.current&&xe.current.contains(e.target)||ve()},we=(null==A?void 0:A.map(e=>({key:e.value||e.key,label:e.name||e.label||`Search ${e.value||e.key}`,placeholder:e.placeholder||e.name||e.label,apiType:e.options?void 0:e.apiType||e.value||e.key,valueKey:(null==P?void 0:P[e.value||e.key])||e.value||e.key,customFilter:e.customFilter||null,multiple:e.multiple||!1,options:e.options||void 0})))||[],Ce=[{label:N.RANGE.TODAY,callback:()=>{be("TODAY")}},{label:N.RANGE.THIS_WEEK,callback:()=>{be("THIS_WEEK")}},{label:N.RANGE.THIS_MONTH,callback:()=>{be("THIS_MONTH")}},{label:N.RANGE.THIS_QUARTER,callback:()=>{be("THIS_QUARTER")}},{label:N.RANGE.THIS_YEAR,callback:()=>{be("THIS_YEAR")}},{label:N.RANGE.YESTERDAY,callback:()=>{be("YESTERDAY")}},{label:N.RANGE.PREVIOUS_WEEK,callback:()=>{be("PREVIOUS_WEEK")}},{label:N.RANGE.PREVIOUS_MONTH,callback:()=>{be("PREVIOUS_MONTH")}},{label:N.RANGE.PREVIOUS_QUARTER,callback:()=>{be("PREVIOUS_QUARTER")}},{label:N.RANGE.PREVIOUS_YEAR,callback:()=>{be("PREVIOUS_YEAR")}},{label:N.RANGE.CUSTOM,callback:()=>{be("CUSTOM")}}],Se=()=>{const e={start_date:p(pe.startDate).format("YYYY-MM-DD"),end_date:p(pe.endDate).format("YYYY-MM-DD")},t={as_of_date:p(se).format("YYYY-MM-DD")};fe({...k?e:t}),ve()},Te=e=>({startDate:p(null==e?void 0:e[z]).isValid()?p(e[z]).toDate():new Date,endDate:p(null==e?void 0:e[q]).isValid()?p(e[q]).toDate():new Date});i.useEffect(()=>{(null==T?void 0:T[O])&&de(p(null==T?void 0:T[O]).isValid()?p(null==T?void 0:T[O]).toDate():new Date)},[null==T?void 0:T[O],O]),i.useEffect(()=>{he({...pe,...Te(T)})},[null==T?void 0:T[q],null==T?void 0:T[z]]),i.useEffect(()=>{re&&(k?he({...pe,...Te(T)}):de(p(null==T?void 0:T[O]).isValid()?p(null==T?void 0:T[O]).toDate():new Date))},[re,k]),i.useEffect(()=>{L(me.fetchCompanies())},[]),i.useEffect(()=>{te(j.generateFields(g))},[]),i.useEffect(()=>{be(M)},[M]);const ke=i.memo(()=>{var t;return e.jsx(u.Menu,{open:Boolean(oe),anchorEl:oe,onClose:()=>ie(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:null==(t=null==c?void 0:c.options)?void 0:t.map((t,a)=>e.jsx(u.MenuItem,{onClick:()=>{t.callback(),ie(null)},children:e.jsxs(h.Typography,{type:"s4",weight:"medium",color:"inherit",children:[" ",t.label]})},a))})});return e.jsxs("div",{children:[e.jsxs("div",{className:"reportsTitleBar",children:[e.jsx("div",{className:"reportsTitleBar--LeftContent",children:m?e.jsx("div",{style:{zIndex:999},children:e.jsx(n.TitleDropdownButton,{onClick:r,options:x,isMenuThirdItemDisabled:!0,children:l})}):e.jsx(h.Typography,{type:"h3",weight:"medium",color:"theme.secondary.1000",children:l})}),F&&e.jsx("div",{className:"reportsTitleBar--SearchBar",children:F}),e.jsx(Bt,{zIndex:999,className:"reportsTitleBar--RightContent",buttons:s})]}),(null==v?void 0:v.length)?e.jsx("div",{children:e.jsx(n.TabBar,{tabs:v||[],activeValue:f,setActiveValue:b,isTabViewOnly:!0})}):null,e.jsxs(u.Box,{sx:{display:"flex",justifyContent:"space-between",my:2.5,alignItems:"center",flexWrap:"wrap",gap:1},children:[e.jsxs("div",{className:"reportsTitleBar--FilterWrapper",children:[e.jsxs(e.Fragment,{children:[we.map(({key:t,label:a,placeholder:l,apiType:r,valueKey:o,customFilter:i,multiple:s=!1,options:d,show:c=!0,showCancelButton:u=!0})=>{if(m=t,!K.some(e=>(null==e?void 0:e.value)==m)||!c)return null;var m;const p=(null==P?void 0:P.company)||"company",h=null==T?void 0:T[p],x=Array.isArray(h)?h.length>0:!!h;let g=i;return["department","designation","location"].includes(r)&&(g={..."object"==typeof i?i:{},"&company_id.in":x?Array.isArray(h)?h.join(","):h:0}),e.jsx(n.SearchableSelect,{labelId:`${t}-label`,searchPlaceholder:a,value:null==T?void 0:T[o],onChange:e=>fe({[o]:e.target.value}),showCancelButton:u,apiType:r,isInternal:!r&&!!d,options:d,multiple:s,placeholder:l,customeFilter:g,customStyle:Y,inputStyle:W})}),$.map(({key:t,component:a})=>e.jsx(i.Fragment,{children:a},t))]}),D&&k&&(null==T?void 0:T[q])&&e.jsx("div",{style:{display:"flex",gap:"8px"},children:e.jsxs("div",{className:"reportsTitleBar--FilterWrapper--Chip",ref:ye,onClick:()=>{re?ve():(xe.current=ye.current,ne(!0))},children:[e.jsxs("div",{className:"reportsTitleBar--FilterWrapper--Chip--Text",title:`${p(null==T?void 0:T[z]).format("DD/MM/YYYY")} - ${p(null==T?void 0:T[q]).format("DD/MM/YYYY")}`,children:[e.jsxs(h.Typography,{type:"s4",weight:"medium",children:[ce("common.dateRange"),":"]}),e.jsxs(h.Typography,{className:"reportsTitleBar--FilterWrapper--Chip--Text--Value",type:"s4",children:[p(null==T?void 0:T[z]).format("DD/MM/YYYY")," -"," ",p(null==T?void 0:T[q]).format("DD/MM/YYYY")]})]}),e.jsx(U,{})]})}),D&&!k&&C&&!["TODAY","YESTERDAY"].includes(ae)&&e.jsxs(e.Fragment,{children:[(null==pe?void 0:pe.startDate)&&e.jsx("div",{style:{display:"flex",gap:"8px"},children:e.jsx("div",{className:"reportsTitleBar--FilterWrapper--Chip",style:{padding:" 5px 12px"},children:e.jsxs("div",{className:"reportsTitleBar--FilterWrapper--Chip--Text",title:`${p(null==pe?void 0:pe.startDate).format("DD/MM/YYYY")}`,children:[e.jsxs(h.Typography,{type:"s4",weight:"medium",children:[ce("common.startDate"),":"]}),e.jsx(h.Typography,{className:"reportsTitleBar--FilterWrapper--Chip--Text--Value",type:"s4",children:p(null==pe?void 0:pe.startDate).format("DD/MM/YYYY")})]})})}),(null==pe?void 0:pe.endDate)&&e.jsx("div",{style:{display:"flex",gap:"8px"},children:e.jsx("div",{className:"reportsTitleBar--FilterWrapper--Chip",style:{padding:" 5px 12px"},children:e.jsxs("div",{className:"reportsTitleBar--FilterWrapper--Chip--Text",title:`${p(null==pe?void 0:pe.endDate).format("DD/MM/YYYY")}`,children:[e.jsxs(h.Typography,{type:"s4",weight:"medium",children:[ce("common.endDate"),":"]}),e.jsx(h.Typography,{className:"reportsTitleBar--FilterWrapper--Chip--Text--Value",type:"s4",children:p(null==pe?void 0:pe.endDate).format("DD/MM/YYYY")})]})})})]}),D&&(null==T?void 0:T[O])&&!k&&e.jsx("div",{style:{display:"flex",gap:"8px"},children:e.jsxs("div",{className:"reportsTitleBar--FilterWrapper--Chip",ref:ye,onClick:()=>{re?ve():(xe.current=ye.current,ne(!0))},children:[e.jsxs("div",{className:"reportsTitleBar--FilterWrapper--Chip--Text",title:`${p(null==T?void 0:T[O]).format("DD/MM/YYYY")}`,children:[e.jsxs(h.Typography,{type:"s4",weight:"medium",children:[ce("common.date"),":"]}),e.jsx(h.Typography,{className:"reportsTitleBar--FilterWrapper--Chip--Text--Value",type:"s4",children:p(null==T?void 0:T[O]).format("DD/MM/YYYY")})]}),e.jsx(U,{})]})})]}),e.jsxs("div",{className:"report-display",children:[(null==(a=null==c?void 0:c.options)?void 0:a.length)>0&&e.jsxs(u.Box,{children:[e.jsx(o.Button,{sx:({palette:e})=>({border:"1px solid",borderColor:"grey.200",borderRadius:"50px",color:`${e.grey[800]} !important`,"&:hover":{bgcolor:`${e.grey[200]} !important`}}),variant:"text",startIcon:e.jsx(_.Export,{fontSize:"small"}),onClick:e=>ie(e.currentTarget),children:ce("common.export")}),oe&&e.jsx(ke,{})]}),(null==A?void 0:A.length)&&e.jsxs(e.Fragment,{children:[e.jsx(u.Box,{children:e.jsx(o.Button,{sx:({palette:e})=>({border:"1px solid",borderColor:"grey.200",borderRadius:"50px",color:`${e.grey[800]} !important`,"&:hover":{bgcolor:`${e.grey[200]} !important`}}),variant:"text",startIcon:e.jsx(_.Filter,{fontSize:"small"}),onClick:e=>Z(e.currentTarget),children:ce("common.filter")})}),R&&e.jsx(u.Divider,{flexItem:!0,orientation:"vertical",sx:{height:"50%",alignSelf:"auto"}})]}),e.jsx(u.Menu,{anchorEl:Q,open:Boolean(Q),onClose:()=>{Z(null)},children:null==A?void 0:A.map(t=>{return e.jsxs(u.MenuItem,{onClick:()=>(e=>{if(K.some(t=>t.value==e.value)){H(K.filter(t=>(null==t?void 0:t.value)!=e.value));const t=e.value||e.key,a=(null==P?void 0:P[t])||t;return void fe({[a]:e.multiple?[]:null})}H([...K,e])})(t),value:null==t?void 0:t.value,children:[e.jsx(n.Checkbox,{checked:(a=t,K.some(e=>(null==e?void 0:e.value)==(null==a?void 0:a.value)))}),e.jsx(h.Typography,{sx:{marginLeft:"10px"},color:"theme.neutral.800",type:"s3",children:ce(null==t?void 0:t.name)})]},t);var a})}),R&&e.jsxs(e.Fragment,{children:[e.jsxs(u.Box,{className:"reportsTitleBar--FilterAction--lvWrapper",children:[e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"grey.800",children:[" Level ",X," of ",I]}),e.jsxs(u.ButtonGroup,{variant:"outlined",disableElevation:!0,sx:({palette:e})=>({"& .MuiButton-root":{borderColor:`${e.grey[200]} !important`,"&:hover":{bgcolor:`${e.grey[200]} !important`}},"& .MuiButtonGroup-firstButton":{borderTopLeftRadius:20,borderBottomLeftRadius:20},"& .MuiButtonGroup-lastButton":{borderTopRightRadius:20,borderBottomRightRadius:20}}),children:[e.jsx(u.Button,{onClick:()=>{J(X==I?X:X+1),null==B||B(X)},children:e.jsx("img",{src:d.images.common.expand})}),e.jsx(u.Button,{onClick:()=>{J(1!=X?X-1:1),null==E||E(X)},children:e.jsx("img",{src:d.images.common.collapse})})]})]}),C&&e.jsx(u.Divider,{flexItem:!0,orientation:"vertical",sx:{height:"50%",alignSelf:"auto"}})]}),C&&D&&e.jsxs(u.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(h.Typography,{type:"s3",weight:"medium",color:"grey.800",children:"As of: "}),e.jsx(Bt,{zIndex:997,className:"reportsTitleBar--RightContent",dropdownMenuButtonData:{icon:e.jsx(_.Calendar,{fontSize:"small"}),children:e.jsxs(e.Fragment,{children:[N.RANGE[ae],e.jsx(U,{})]}),options:Ce},toggleCallback:y}),e.jsx("div",{ref:ge})]})]})]}),e.jsx(u.Popper,{sx:{zIndex:9999},open:re,anchorEl:xe.current,role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:t,placement:a})=>e.jsx(u.Grow,{...t,style:{margin:"0 20px 0 20px",transformOrigin:"bottom"===a?"center top":"center bottom"},children:e.jsx(u.Paper,{children:e.jsx(u.ClickAwayListener,{onClickAway:je,children:e.jsxs(u.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end"},children:[e.jsx("div",{children:k?e.jsx(G.DateRange,{editableDateInputs:!0,onChange:e=>he(e.selection),moveRangeOnFirstSelection:!1,ranges:[pe],locale:tt}):e.jsx(G.Calendar,{onChange:e=>de(e),date:se,locale:tt})}),e.jsx(u.Box,{sx:{padding:"0 12px 12px 0"},children:e.jsx(o.Button,{variant:"contained",sx:{width:"fit-content"},onClick:Se,children:ce("common.apply")})})]})})})})})]})},exports.ScheduleReportModal=Ot,exports.Snackbar=t=>{const{children:a,...l}=t;return e.jsx(k.SnackbarProvider,{action:t=>e.jsx(Lt,{snackbarKey:t}),style:{flexWrap:"unset"},anchorOrigin:{vertical:"bottom",horizontal:"right"},...l,children:a})},exports.SubHeaderDoc=()=>e.jsx("section",{children:e.jsxs("div",{className:"top-content",children:[e.jsxs("div",{className:"left-content",children:[e.jsx("a",{href:"#",children:"Forms / "}),"Add Custom Field"]}),e.jsxs("div",{className:"right-content",children:[e.jsx("div",{className:"actions",children:e.jsx(o.Button,{className:"",variant:"middle",children:"Action"})}),e.jsx("div",{className:"show-preview",children:e.jsx(o.Button,{className:"",variant:"middle",children:"Show Preview"})}),e.jsx("div",{className:"update",children:e.jsx(o.Button,{className:"",variant:"contained",children:"Update"})})]})]})}),exports.TabBarUi=t=>{const{tabs:a,onEditTabTitle:r,activeTabValue:n,setActiveTabValue:s,handleTabChange:c,handleRemoveTab:m}=t,[p,h]=i.useState(0),[x,g]=i.useState(null);return i.useEffect(()=>{s&&Boolean(null==a?void 0:a.length)&&s(p)},[a]),e.jsx(u.Box,{children:e.jsxs(xe,{value:n??p,children:[e.jsx(u.Box,{children:e.jsx(ge,{className:"account-payble-tabsui-wrap",onChange:(e,t)=>{h(t),s&&s(t),c&&c()},children:a.map(t=>e.jsx(he,{className:"account-payble-tab-items",label:r&&x===t.tab_order?e.jsx(o.TextField,{value:t.title,autoFocus:!0,onBlur:()=>g(null),onChange:e=>{return a=e,l=t.tab_order,void(r&&r(l,a.target.value));var a,l}}):m?e.jsxs("div",{className:"Tabs--Title",children:[e.jsx("div",{children:t.title}),!t.remove_tab&&e.jsx(l,{style:{fontSize:"15px",cursor:"pointer"},onClick:()=>{m(t.tab_order)}})]}):e.jsxs("div",{className:"text-display",children:[e.jsx("img",{src:d.images.common[t.tabIcon]}),t.title]}),wrapped:!0,onDoubleClick:()=>{return e=t.tab_order,void g(e);var e}},t.tab_order))})}),a.map((t,a)=>t.content&&e.jsx(ye,{value:a,children:p===a&&t.content},t.tab_order))]})})},exports.TextArea=t=>{const{placeholder:a,minRows:l=3,label:r,helperText:n,error:o,...i}=t,s=q.styled(ve.TextareaAutosize)(({theme:{palette:e}})=>{var t,a,l,r,n,i,s,d;return{"&":{padding:"0.4375rem 0.5rem",borderRadius:"0.25rem",borderColor:o?null==(t=e.theme)?void 0:t.error[600]:null==(a=e.theme)?void 0:a.secondary[400],outline:"none",color:null==(l=e.theme)?void 0:l.secondary[800],fontSize:"0.875rem","&::placeholder":{opacity:1},"&:hover":{borderColor:o?null==(r=e.theme)?void 0:r.error[600]:null==(n=e.theme)?void 0:n.secondary[500]},"&:focus-visible":{borderWidth:"0.0625rem",borderStyle:"solid",borderColor:o?null==(i=e.theme)?void 0:i.error[600]:null==(s=e.theme)?void 0:s.primary[700]},"&:disabled":{background:null==(d=e.theme)?void 0:d.secondary[200]}}}});return e.jsxs(e.Fragment,{children:[e.jsx(h.Typography,{type:"s4",fontWeight:"medium",mb:.5,color:o?"theme.error.600":"theme.secondary.800",children:r}),e.jsx(s,{"aria-label":"minimum height",minRows:l,placeholder:a,...i}),e.jsx(h.Typography,{type:"s4",fontWeight:"medium",mt:-.25,color:o?"theme.error.600":"theme.secondary.800",children:n})]})},exports.TimeRangePicker=t=>{const[a,l]=i.useState([]),[r,n]=i.useState(0),[d,m]=i.useState(0),[p,h]=i.useState(void 0),{hour12:x=!1,startTime:g,endTime:y,onTimeRangeChange:v}=t;i.useEffect(()=>{l([]);const e=e=>{if(!e)return null;const[t,a]=e.split(" "),[l,r]=t.split(":").map(Number);let n=l;a&&("PM"===a?12!==l&&(n+=12):"AM"===a&&12===l&&(n-=12));const o=new Date;o.setHours(n,r,0,0);const i=o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:x});let s=i;return 0===o.getHours()?s="00"+i.slice(2):12===o.getHours()&&(s="12"+i.slice(2)),s};l(t=>{if(g&&y){const a=e(g),l=e(y);return[...t,a,l]}return t})},[x,g,y]),i.useEffect(()=>{if(2===d&&m(0),2===a.length){const e=a[0],t=a[1],l=f(e);let r=f(t)-l;r<0&&(r+=1440),n(r)}else n(0)},[d,a]);const f=e=>{const[t,a,l]=e.split(/:| /);let r=parseInt(t);const n=parseInt(a);return l&&"pm"===l.toLowerCase()&&12!==r?r+=12:l&&"am"===l.toLowerCase()&&12===r&&(r=0),60*r+n};i.useEffect(()=>{v({timeRange:a,differenceInMinutes:r})},[r,v,a]);const b=()=>{h(!0!==p||void 0)},j=e=>{l([]),m(0),e.stopPropagation()},w=e.jsx(o.TextField,{className:"time-input",type:"text",value:1===a.length?`${a[0]} - `:2===a.length?`${a[0]} - ${a[1]}`:"",InputProps:{readOnly:!0,endAdornment:e.jsxs(u.InputAdornment,{position:"end",children:[a.length>0&&e.jsx(u.IconButton,{onClick:j,children:e.jsx(c.Close,{})}),e.jsx(u.IconButton,{onClick:b,children:e.jsx(c.AccessTimeRounded,{})})]})}});return e.jsx(e.Fragment,{children:e.jsxs(u.Box,{className:"DateRangePicker",children:[e.jsx(s,{className:"DatePickerWrapper",onChange:e=>{(e=>{const t=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:x});let r=t;0===e.getHours()?r="00"+t.slice(2):12===e.getHours()&&(r="12"+t.slice(2)),a.length<2?l([...a,r]):0===d?l(e=>{const t=[...e];return t[0]=r,t}):1===d&&l(e=>{const t=[...e];return t[1]=r,t}),m(d+1)})(e),b()},showTimeSelect:!0,showTimeSelectOnly:!0,timeIntervals:15,selectsRange:!0,customInput:w,open:p,value:a&&1===a.length?`${a[0]}-`:a&&2===a.length?`${a[0]}-${a[1]}`:void 0}),e.jsx(u.Box,{className:"box-icon",style:a.length>0?{right:"2.5rem"}:{right:"1.563rem"},children:a.length>0&&e.jsx(c.Close,{onClick:j})})]})})},exports.UomFieldWrapper=({label:a,name:l="uom_id",placeholder:r,fieldArrayName:o,required:s=!1,is_loading:d=!1,disabled:c=!1,selectedItem:u,fieldMapping:m={total_on_hand_quantity:"on_hand_quantity",total_available_quantity:"available_quantity",total_committed_quantity:"committed_quantity"},customeFilter:p,getSelectedData:h,fieldPrefix:x,setValue:g,control:y,isConversationFactor:v=!0,active_location:f})=>{const[b,j]=i.useState(null),w=t.useFormContext(),{setValue:C}=w||{},S=void 0!==x?x:o||"",T=(({fieldMapping:e,sourceData:t,conversation_factor:a,fieldPrefix:l="item_entries",setValue:r,shouldUpdate:n=!0,active_location:o})=>i.useCallback(()=>{n&&t&&Object.entries(e).forEach(([e,n])=>{const i=t[e],s=Number(a)||1,d=l?`${l}.${n}`:n;let c;if(null===o)c=0;else if(o&&"object"==typeof o&&(null==t?void 0:t.location_wise_quantity)){const a=t.location_wise_quantity.find(e=>e.location_id===o.id);if(a)switch(e){case"total_on_hand_quantity":c=(a.total_available_quantity-a.total_reserved_quantity)/s;break;case"total_available_quantity":c=a.total_available_quantity/s;break;case"total_committed_quantity":c=a.total_committed_quantity/s;break;default:c="sales_price"==e||"rental_base_price"==e||"cost"==e?0!==s&&Number(i)*s||0:0!==s&&Number(a[e])/s||0}else c=0}else c="sales_price"==e||"rental_base_price"==e||"cost"==e?0!==s&&Number(i)*s||0:0!==s&&Number(i)/s||0;r(d,c)})},[e,t,a,l,r,n,o]))({fieldMapping:i.useMemo(()=>m,[JSON.stringify(m)]),sourceData:u,conversation_factor:null==b?void 0:b.conversation_factor,fieldPrefix:S,setValue:g||C,active_location:f});i.useEffect(()=>{v&&T()},[T,v]);const k=p||{"&template_id.eq":(null==u?void 0:u.unit_of_measurement)||0};return e.jsx(n.DynamicSearchSelect,{label:a,name:l,placeholder:r||"",fieldArrayName:o||"",formControl:y,required:s,is_loading:d,disabled:c,apiType:"uom",customeFilter:k,getSelectedData:(e,t)=>{j(e),null==h||h(e,t)}})},exports.Upload=t=>{const{open:a,title:r,onClose:s,onConfirm:m,accept:p="*",onSubmit:x,multiple:g=!0,existingDriveData:y,fileUploaded:v,type:f}=t,[b,j]=i.useState([]),[w,C]=i.useState(!1),[T,k]=i.useState(!1),[_,D]=i.useState(!1),[M,A]=i.useState(!1),[N,B]=i.useState(new AbortController),E=localStorage.getItem(we.auth.storageTokenKeyName),[R,I]=i.useState(),[P,F]=i.useState(!1),[$,z]=i.useState(),[q,L]=i.useState(null),{getRootProps:Y,getInputProps:W,isDragActive:V}=be.useDropzone({onDropAccepted:e=>{j([...b,...e.map(e=>({file:e,isPrivate:!1,checkboxDisabled:!1,status:"pending",uploadProgress:0,fileSize:e.size,fileName:e.name,fileType:e.type,location:"",message:""}))]),A(!1)},onDragEnter:()=>{A(!0)},onDragLeave:()=>{A(!1)},noClick:!0,noKeyboard:!0,multiple:g,accept:p?(H=p,H.split(",").map(e=>e.trim()).reduce((e,t)=>(e[t]=[],e),{})):p}),K=i.useRef(null);var H;i.useEffect(()=>{const e=null==y?void 0:y.map(e=>e.title);I(e)},[y]),i.useEffect(()=>{const e=e=>{if(w){const t="Are you sure you want to leave? Your uploads are not complete.";return e.returnValue=t,t}};return K.current&&(K.current.multiple=g),window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}},[w,g]);const U=()=>{const e=navigator;return"connection"in e&&e.connection?e.connection.downlink:null},G=t=>{switch(null==t?void 0:t.type.split("/")[0]){case"image":case"application":return e.jsx("div",{className:_?"document-icon-sm":"document-icon-lg",style:{backgroundColor:"#FFEBEB"},children:e.jsx(o.Avatar,{size:20,src:d.images.upload.documentPDF})});default:return e.jsx("div",{className:_?"document-icon-sm":"document-icon-lg",style:{backgroundColor:"#EBF9F2"},children:e.jsx(o.Avatar,{size:20,src:d.images.upload.docFile})})}},X=`${we.getApiConfig().backendBaseUrl}/document/v1/file-upload/`,J=async()=>{C(!0);const e=new AbortController;B(e);const t=b.filter(e=>"canceled"!==e.status).length;for(let l=0;l<b.length;l++){if(100===b[l].uploadProgress||"pending"!==b[l].status)continue;const r=b[l],n=null==r?void 0:r.fileSize;try{n>10485760?await ee(r,l,e)&&setTimeout(()=>{v(!0)},1e3):await Z(r,l,e,t)}catch(a){j(e=>{const t=[...e];return t[l]={...t[l],status:"failed",message:a.message||"Internal Server Error"},t})}finally{C(!1)}}};let Q=0;const Z=async(e,t,a,l)=>{var r,n,o,i;try{const s=["docx","doc","csv","pdf","xls","xlsx","vnd.ms-excel","excel","txt"],d=(null==e?void 0:e.mimeType)||(null==e?void 0:e.fileType)||"";if(s.some(e=>d.includes(e))&&(null==e?void 0:e.fileSize)&&(null==e?void 0:e.fileSize)>=5242880)return L({type:"alert",message:"File size must be within 5 MB!"});const c=await fetch(`${X}?key=${null==e?void 0:e.fileName}&partCount=1&mimeType=${null==e?void 0:e.fileType}&is_private=${!(null==e?void 0:e.isPrivate)}`,{headers:{"Content-Type":"application/json","file-size":null==e?void 0:e.fileSize,"x-token":E},signal:a.signal}),u=await c.json();if(400==(null==u?void 0:u.status_code))return void L({type:"alert",message:null==u?void 0:u.message});const m=null==(n=null==(r=u.data)?void 0:r.preSignedData)?void 0:n.presignedUrl,p=null==(i=null==(o=u.data)?void 0:o.preSignedData)?void 0:i.location,h={Body:null==e?void 0:e.file.slice(0,null==e?void 0:e.fileSize),url:m},g=e.fileSize,y=1099511627776;let v=0;for(;v<g;){const a=v,l=Math.min(v+y,g);await fetch(h.url,{method:"PUT",body:e.file.slice(a,l),headers:{"Content-Type":"application/octet-stream"}}),v=l;const r=Math.round(v/g*100);j(e=>{const a=[...e];return a[t]={...a[t],checkboxDisabled:!0,status:"uploading",uploadProgress:r},a})}j(e=>{const a=[...e];return a[t]={...a[t],status:"completed",location:p,message:"Uploaded Successfully"},Q+=1,l==Q&&(x(a),Q=0),a})}catch(s){j(e=>{const a=[...e];return a[t]={...a[t],status:"failed",message:s.message||"Internal Server Error"},a})}},ee=async(e,t,a)=>{var l,r,n;try{const o=1024*(U()||10)*1024<5242880?5242880:1024*(U()||10)*1024,i=Math.ceil((null==e?void 0:e.fileSize)/o),s=await fetch(`${X}?key=${null==e?void 0:e.fileName}&partCount=${i}&mimeType=${null==e?void 0:e.fileType}&is_private=${!(null==e?void 0:e.isPrivate)}`,{headers:{"Content-Type":"application/json","file-size":null==e?void 0:e.fileSize,"x-token":E},signal:a.signal}),d=await s.json();if(d&&(null==d?void 0:d.status_code)&&400==(null==d?void 0:d.status_code))return L({message:(null==d?void 0:d.message)||"Internal Server Error",type:"error"}),null;const c=null==(l=d.data.preSignedData)?void 0:l.preSignedUrls;if(c.length>0){const a=c[0].presignedUrl.match(/uploadId=([^&]+)/)[1];for(let n=0;n<c.length;n++){const a=c[n].partNumber,l=c[n].presignedUrl,s=(a-1)*o,d=Math.min(s+o,null==e?void 0:e.fileSize),u={Body:null==(r=null==e?void 0:e.file)?void 0:r.slice(s,d),url:l};await fetch(u.url,{method:"PUT",body:u.Body,headers:{"Content-Type":"application/octet-stream"}});const m=Math.round(100*(n+1)/i);j(e=>{const a=[...e];return a[t]={...a[t],checkboxDisabled:!0,status:"uploading",uploadProgress:m},a})}const l=await fetch(`${X}mark-complete`,{method:"POST",headers:{"Content-Type":"application/json","x-token":E},body:JSON.stringify({fileName:null==e?void 0:e.fileName,uploadId:a})}),s=await l.json(),d=null==(n=null==s?void 0:s.data)?void 0:n.location;j(e=>{const a=[...e];return a[t]={...a[t],status:"completed",location:d,message:"Uploaded Successfully"},x(a),a})}else j(e=>{const a=[...e];return a[t]={...a[t],status:"failed",message:"Did not get pre-signed URLs"},a})}catch(o){j(e=>{const a=[...e];return a[t]={...a[t],status:"failed",message:o.message||"Internal Server Error"},a})}},te=()=>{K.current&&(t.multiple?K.current.setAttribute("multiple","true"):K.current.removeAttribute("multiple"),K.current.click())},ae=e=>{const t=e.target.files,a=Array.from(t).map(e=>{const t=e.name;return t.substring(0,t.lastIndexOf("."))||t})[0];z(a),F(null==R?void 0:R.includes(a));const l=Array.from(t).map(e=>({file:e,isPrivate:!1,checkboxDisabled:!1,status:"pending",uploadProgress:0,fileSize:null==e?void 0:e.size,fileName:null==e?void 0:e.name,fileType:null==e?void 0:e.type,location:"",message:""}));j(e=>[...e,...l]),C(!1)},le=e=>{j(t=>t.map((t,a)=>a===e?{...t,status:"canceled"}:t))},re=()=>{D(!_),_?m():s()},ne=()=>{var e;b.length>0?confirm("Your uploads are not complete. Would you like to cancel all ongoing uploads?")&&(N.abort(),(null==(e=null==N?void 0:N.signal)?void 0:e.aborted)&&s(),j([])):s()};i.useEffect(()=>{a&&j([])},[a]);const oe=()=>{F(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(u.Dialog,{open:a,onClose:s,className:"upload",children:[e.jsxs(u.DialogTitle,{className:"upload--head",children:[e.jsx(O,{className:"upload--title",children:e.jsx(h.Typography,{type:"s3",ml:1,weight:"medium",color:"theme.secondary.1000",children:r})}),e.jsxs("div",{children:[e.jsx(u.IconButton,{disableRipple:!0,onClick:re,children:e.jsx(je,{})}),e.jsx(u.IconButton,{disableRipple:!0,onClick:ne,children:e.jsx(l,{})})]})]}),e.jsx(u.Divider,{}),e.jsx(u.DialogContent,{className:"upload--content",children:0===b.length?e.jsx("div",{className:"upload--fileContent "+(V?"drag-active":""),children:e.jsx("div",{...Y(),className:"drop-view",children:M?e.jsxs("div",{className:"after-drop",children:[e.jsx("img",{src:d.images.upload.documentUpload}),e.jsx(h.Typography,{type:"s3",children:"Drag & Drop your files here"})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{...W(),ref:K}),e.jsx("p",{className:"upload--text",children:"Drag and Drop files here or upload from"}),e.jsxs("div",{className:"device-wrap",children:[e.jsxs("div",{className:"select-button",onClick:te,children:[e.jsx("img",{src:d.images.upload.monitor}),e.jsx(h.Typography,{type:"s5",children:"My Device"}),e.jsx("input",{type:"file",...W({multiple:!0}),ref:K,style:{display:"none"},onChange:async()=>{J()},accept:p})]}),e.jsxs("div",{className:"select-button",onClick:te,children:[e.jsx("img",{src:d.images.upload.camera}),e.jsx(h.Typography,{type:"s5",children:"Camera"}),e.jsx("input",{type:"file",...W({multiple:!0}),ref:K,style:{display:"none"},onChange:ae,accept:p})]})]})]})})}):e.jsx("div",{className:"main-container",children:e.jsxs("div",{className:"body-section",children:[e.jsx("div",{className:"document-section",children:e.jsx("div",{className:"document-body",children:b.map((t,a)=>{var l,r,i;return e.jsxs("div",{className:"upload-list",children:[e.jsxs("div",{className:"document-cover",children:[e.jsxs("div",{className:"document-name",children:[G(null==t?void 0:t.file),e.jsx("div",{className:"document-title",children:e.jsxs("div",{className:"document-box",children:[e.jsx("div",{className:"document-desc",children:null==(l=null==t?void 0:t.file)?void 0:l.name}),e.jsxs("div",{className:"document-size",children:[Wt(null==(r=null==t?void 0:t.file)?void 0:r.size),e.jsx("span",{className:"completed"===(null==t?void 0:t.status)&&(null==t?void 0:t.message.length)>0?"success-file":"fail-file",children:null==t?void 0:t.message})]})]})})]}),e.jsx("div",{className:"document-choices",children:"canceled"!==(null==t?void 0:t.status)?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"checkbox",children:[e.jsx(n.Checkbox,{checked:(null==t?void 0:t.isPrivate)||"public"==f,onChange:()=>(e=>{j(t=>t.map((t,a)=>a===e?{...t,isPrivate:!t.isPrivate}:t))})(a),disabled:(null==t?void 0:t.checkboxDisabled)||"public"==f}),e.jsx("div",{className:"checkbox-text",children:"Public"})]}),e.jsx("div",{className:"delete-icon",onClick:()=>le(a),children:e.jsx(o.Avatar,{size:24,src:d.images.upload.trash})})]}):e.jsx(h.Typography,{type:"s4",className:"canceled-text",children:"Upload Canceled"})})]},null==(i=null==t?void 0:t.file)?void 0:i.name),e.jsx("div",{className:"document-progress",children:(null==t?void 0:t.uploadProgress)>0&&e.jsx(fe,{color:"success",variant:"determinate",value:null==t?void 0:t.uploadProgress})})]},a)})})}),g&&e.jsxs(e.Fragment,{children:[e.jsx(S.Chip,{className:"add-file",variant:"outlined",type:"normal",label:"Add File",icon:e.jsx(c.Add,{}),onClick:te}),e.jsx("input",{type:"file",...W({multiple:!0}),ref:K,style:{display:"none"},onChange:ae,accept:p})]})]})})}),e.jsx(u.Divider,{}),e.jsxs(u.DialogActions,{className:"upload--actions",children:[e.jsx(o.Button,{variant:"text",onClick:ne,children:"Cancel"}),e.jsx(o.Button,{color:"secondary",onClick:J,disabled:!b.length||w,children:"Upload"})]})]}),_&&e.jsxs("div",{className:"bottom-corner-box",children:[e.jsxs("div",{className:"top-section",children:[e.jsxs("div",{className:"top-text",children:["Uploading ",b.length," Item",1!==b.length?"s":""]}),e.jsxs("div",{className:"top-options",children:[e.jsx("div",{className:"btn",onClick:re,children:e.jsx(je,{})}),e.jsx("div",{className:"btn",onClick:()=>{k(e=>!e)},children:e.jsx("div",{className:"arrow-btn",children:T?e.jsx(c.KeyboardArrowUp,{}):e.jsx(c.KeyboardArrowDown,{})})}),e.jsx("div",{className:"btn",onClick:ne,children:e.jsx(c.Clear,{})})]})]}),e.jsx("div",{className:"box-list",children:!T&&b.map((t,a)=>{var l;return e.jsxs("div",{className:"bottom-section",children:[e.jsx("div",{className:"doc-icon",children:G(null==t?void 0:t.file)}),e.jsxs("div",{className:"file-detail",children:[e.jsx("div",{className:"file-name",children:e.jsxs("div",{className:"file-text",children:[null==(l=null==t?void 0:t.file)?void 0:l.name,a]})}),e.jsx("div",{className:"file-status",children:"canceled"!==(null==t?void 0:t.status)?e.jsxs(e.Fragment,{children:[0===t.uploadProgress&&e.jsxs("div",{className:"avatar-container",children:[e.jsx(o.Avatar,{size:20,className:"avatar",src:d.images.upload.empty}),e.jsx(o.Avatar,{size:20,onClick:()=>le(a),src:d.images.upload.close,className:"close-icon"})]}),(null==t?void 0:t.uploadProgress)>0&&(null==t?void 0:t.uploadProgress)<100&&e.jsx(u.CircularProgress,{color:"success",variant:"determinate",value:null==t?void 0:t.uploadProgress}),100===(null==t?void 0:t.uploadProgress)&&e.jsxs("div",{className:"avatar-container",children:[e.jsx(o.Avatar,{size:20,className:"avatar",src:d.images.upload.tick}),e.jsx(o.Avatar,{size:20,src:d.images.upload.folder,className:"close-icon"})]})]}):e.jsx(h.Typography,{type:"s4",className:"canceled-text",children:"Upload Canceled"})})]})]})})})]}),P&&e.jsx(Yt,{title:$,open:P,onClose:oe,onReplace:async()=>{const e=`${we.getApiConfig().backendBaseUrl}`,t=null==y?void 0:y.filter(e=>e.title===$)[0].id,a={"Content-type":"application/json; charset=utf-8"},l=localStorage.getItem(we.auth.storageTokenKeyName)||"";a["x-token"]=l,await fetch(`${e}/document/v1/drive/${t}`,{method:"DELETE",headers:a}),oe()},onKeepBoth:()=>{oe()},isFile:!0}),e.jsx(o.Toast,{open:Boolean(q),type:null==q?void 0:q.type,message:null==q?void 0:q.message,handleClose:()=>L(null),anchorOrigin:{horizontal:"right",vertical:"bottom"}})]})},exports.UserDropdown=t=>{const{value:a,data:l,onCheckboxChange:r,...o}=t,{isRoleVisible:s,selectedUsers:d}=a,[c,u]=i.useState(d),[m,p]=i.useState([]),x=(e,t)=>()=>{const a=c.findIndex(t=>t.id===e),l=[...c];-1===a?l.push(t):l.splice(a,1),u(l),r(l)};return i.useEffect(()=>{p(s?(null==l?void 0:l.departments)??[]:(null==l?void 0:l.users)??[])},[s,l]),e.jsx("div",{className:"SwitchList",...o,children:e.jsx(Ce,{children:m&&(null==m?void 0:m.map(t=>{var a;const l=`checkbox-list-secondary-label-${t.id}`;return e.jsxs(Se,{sx:{cursor:"pointer"},onClick:x(t.id,t),children:[e.jsx(Te,{id:l,children:e.jsx(h.Typography,{dangerouslySetInnerHTML:{__html:`${s?null==t?void 0:t.name:`${null==t?void 0:t.first_name} ${null==t?void 0:t.last_name}`} <span>${s?t.count+" Users":null==(a=null==t?void 0:t.department)?void 0:a.name}</span>`}})}),e.jsx("div",{className:"list-secondary-content",children:e.jsx(n.Checkbox,{edge:"end",checked:c.some(e=>e.id===t.id),inputProps:{"aria-labelledby":l}})})]},t.id)}))})})},exports.dynamicFields=ja,exports.fields=ba,exports.validator=e=>!!e.value;
|
|
2
|
-
//# sourceMappingURL=ai-summary-
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),t=require("react-hook-form"),a=require("./index-B9CFxEZ9.js"),l=require("@mui/icons-material/Close"),r=require("@mui/icons-material/Add"),n=require("./android-12-switch-CphTHRb8.js"),o=require("./appbar-C6Es9HGk.js"),i=require("react"),s=require("react-datepicker");require("react-datepicker/dist/react-datepicker.css");/* empty css */const d=require("./images-DrJQoSCu.js"),c=require("@mui/icons-material"),u=require("@mui/material"),m=require("./useLangauge-p2qKwusp.js"),p=require("dayjs"),h=require("./useAuth-C1y8BBuX.js");;/* empty css */const x=require("@mui/lab/Timeline"),g=require("@mui/lab/TimelineItem"),y=require("@mui/lab/TimelineSeparator"),v=require("@mui/lab/TimelineConnector"),f=require("@mui/lab/TimelineContent"),b=require("@mui/lab/TimelineDot"),j=require("./common-wRWMk0Fs.js"),w=require("react-i18next"),C=require("yup"),S=require("./form-builder-deconversion-BbeAseMU.js"),T=require("./api-DG3x2G1d.js"),k=require("notistack"),_=require("./trash-lbX6jsCI.js"),D=require("react-redux"),M=require("./apiHelper-CLLyiIkN.js"),A=require("@asseinfo/react-kanban"),N=require("./navigation-utils-DgdbFA8i.js"),B=require("@fullcalendar/react"),R=require("@fullcalendar/daygrid"),E=require("@fullcalendar/list"),I=require("@fullcalendar/interaction"),P=require("@fullcalendar/timegrid"),F=require("@fullcalendar/resource-timegrid"),$=require("@fullcalendar/timeline"),z=require("@fullcalendar/resource-timeline"),q=require("@mui/material/styles"),O=require("@mui/material/Box"),L=require("./tick-ChY3vEPD.js"),Y=require("react-flags-select"),W=require("react-router-dom"),V=require("./page-context-qa1FKO9A.js"),K=require("gantt-task-react"),H=require("@mui/material/styles/useTheme"),U=require("@mui/icons-material/KeyboardArrowDown"),G=require("react-date-range");require("react-date-range/dist/styles.css"),require("react-date-range/dist/theme/default.css");const X=require("./action-bar-BmEN5Ob9.js"),J=require("@mui/material/Accordion"),Q=require("@mui/material/Chip"),Z=require("@mui/material/AccordionSummary"),ee=require("@mui/material/AccordionDetails"),te=require("@mui/material/Typography"),ae=require("@mui/icons-material/ExpandMore"),le=require("@mui/icons-material/RadioButtonChecked"),re=require("@glideapps/glide-data-grid"),ne=require("@glideapps/glide-data-grid-cells"),oe=require("react-laag");require("react-responsive-carousel/lib/styles/carousel.min.css");const ie=require("@mui/material/Menu"),se=require("@mui/material/MenuItem"),de=require("lodash"),ce=require("./useAccountSetting-DZvJOGz7.js"),ue=require("./hooks-BdfwliGF.js"),me=require("./store-CwOVutHK.js"),pe=require("@mui/material/IconButton"),he=require("@mui/material/Tab"),xe=require("@mui/lab/TabContext"),ge=require("@mui/lab/TabList"),ye=require("@mui/lab/TabPanel"),ve=require("@mui/base"),fe=require("@mui/material/LinearProgress"),be=require("react-dropzone"),je=require("@mui/icons-material/Remove"),we=require("./api-config-CkfRrKRY.js");;/* empty css */const Ce=require("@mui/material/List"),Se=require("@mui/material/ListItem"),Te=require("@mui/material/ListItemText"),ke=require("material-react-table"),_e=require("@mui/icons-material/ChevronRight"),De=require("@mui/icons-material/ChevronLeft"),Me=require("./modules-BiUx1fbP.js"),Ae=require("./pathname.rental-Br768eN2.js"),Ne=require("./pathname.hrms-DGxdM-k7.js"),Be=require("d3"),Re=require("@mui/material/Card"),Ee=require("@mui/material/CardContent"),Ie=require("@mui/icons-material/ArrowDropDown"),Pe=require("@mui/icons-material/ArrowDropUp"),Fe=require("@mui/material/Checkbox"),$e=require("./typography-BzrMi9XI.js"),ze=require("./arrow-up-BHInahU_.js"),qe=require("lucide-react");function Oe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const a in e)if("default"!==a){const l=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,l.get?l:{enumerable:!0,get:()=>e[a]})}return t.default=e,Object.freeze(t)}const Le=Oe(C),Ye=Oe(Be),We=a=>{const{fields:i,append:s}=t.useFieldArray({control:a.control,name:"abjMember"}),d=(e,t)=>{switch(e){case"input":s({type:"input",appendAfter:t});break;case"select":s({type:"select",appendAfter:t})}};return e.jsxs(e.Fragment,{children:[e.jsx(t.Controller,{control:a.control,name:a.name,defaultValue:a.defaultValue||"",render:({field:e})=>(Object.keys(a.field1).length&&Object.keys(a.field1)!==Object.keys(e)&&a.updateField({...e}),a.children)}),e.jsx(l,{style:{fontSize:"15px",cursor:"pointer"},onClick:()=>d("input",a.name)}),e.jsx(r,{style:{fontSize:"15px",cursor:"pointer"},onClick:()=>d("select",a.name)}),i.map(t=>{if(t.appendAfter===a.name)return e.jsxs(e.Fragment,{children:["input"===t.type&&e.jsx(o.DynamicInput,{placeholder:"Enter value",label:"Message",formControl:a.control,name:"message",fieldArrayName:"abjMember"}),"select"===t.type&&e.jsx(n.DynamicSelect,{placeholder:"Select value",label:"Is True",options:[{value:"option1",label:"Option 1"},{value:"option2",label:"Option 2"}],formControl:a.control,name:"is_true",fieldArrayName:"abjMember"})]})})]})};function Ve(e){return(Ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ke(e,t){if(t.length<e)throw new TypeError(e+" argument required, but only "+t.length+" present")}function He(e){Ke(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||"object"===Ve(e)&&"[object Date]"===t?new Date(e.getTime()):"number"==typeof e||"[object Number]"===t?new Date(e):("string"!=typeof e&&"[object String]"!==t||"undefined"==typeof console||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn((new Error).stack)),new Date(NaN))}We.propTypes={name:a.PropTypes.string.isRequired,defaultValue:a.PropTypes.string,field1:a.PropTypes.object,children:a.PropTypes.node.isRequired,updateField:a.PropTypes.func.isRequired,control:a.PropTypes.object.isRequired};var Ue={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function Ge(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}var Xe={date:Ge({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Ge({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:Ge({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Je={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Qe(e){return function(t,a){var l;if("formatting"===(null!=a&&a.context?String(a.context):"standalone")&&e.formattingValues){var r=e.defaultFormattingWidth||e.defaultWidth,n=null!=a&&a.width?String(a.width):r;l=e.formattingValues[n]||e.formattingValues[r]}else{var o=e.defaultWidth,i=null!=a&&a.width?String(a.width):e.defaultWidth;l=e.values[i]||e.values[o]}return l[e.argumentCallback?e.argumentCallback(t):t]}}function Ze(e){return function(t){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=a.width,r=l&&e.matchPatterns[l]||e.matchPatterns[e.defaultMatchWidth],n=t.match(r);if(!n)return null;var o,i=n[0],s=l&&e.parsePatterns[l]||e.parsePatterns[e.defaultParseWidth],d=Array.isArray(s)?function(e,t){for(var a=0;a<e.length;a++)if(t(e[a]))return a}(s,function(e){return e.test(i)}):function(e,t){for(var a in e)if(e.hasOwnProperty(a)&&t(e[a]))return a}(s,function(e){return e.test(i)});return o=e.valueCallback?e.valueCallback(d):d,{value:o=a.valueCallback?a.valueCallback(o):o,rest:t.slice(i.length)}}}var et,tt={code:"en-US",formatDistance:function(e,t,a){var l,r=Ue[e];return l="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",t.toString()),null!=a&&a.addSuffix?a.comparison&&a.comparison>0?"in "+l:l+" ago":l},formatLong:Xe,formatRelative:function(e,t,a,l){return Je[e]},localize:{ordinalNumber:function(e,t){var a=Number(e),l=a%100;if(l>20||l<10)switch(l%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},era:Qe({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Qe({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:Qe({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:Qe({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:Qe({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(et={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}},function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=e.match(et.matchPattern);if(!a)return null;var l=a[0],r=e.match(et.parsePattern);if(!r)return null;var n=et.valueCallback?et.valueCallback(r[0]):r[0];return{value:n=t.valueCallback?t.valueCallback(n):n,rest:e.slice(l.length)}}),era:Ze({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:Ze({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:Ze({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:Ze({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:Ze({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function at(e){return Ke(1,arguments),He(e).getMonth()}function lt(e){return Ke(1,arguments),He(e).getFullYear()}const rt=["January","February","March","April","May","June","July","August","September","October","November","December"],nt=({value:t,onClick:a,placeholderText:l,isRtl:r})=>e.jsxs("div",{className:"calender-container",children:[e.jsx("input",{type:"text",value:t,onClick:a,placeholder:l,className:"open-selected-calender"}),e.jsx("div",{className:r?"icon-box_rtl":"icon-box",children:e.jsx(d.CalenderIcon,{})})]});function ot(t){const{start:a=null,end:l=null,startYear:r=1980,onDateRangeChange:n,...o}=t,[d,p]=i.useState(a),[h,x]=i.useState(l),{isRtl:g}=m.useLanguage(),y=[],v=lt(new Date);for(let e=r;e<=v+10;e++)y.push(e);return e.jsx(u.Box,{className:"DateRangePicker",children:e.jsx(s,{dateFormat:"dd-MM-yyyy",...o,customInput:e.jsx(nt,{placeholderText:"DD-MM-YYYY",value:"",isRtl:g,onClick:()=>{}}),startDate:d,endDate:h,onChange:e=>{const[t,a]=e;p(t),x(a),n(e)},selectsRange:!0,isClearable:!0,renderCustomHeader:({date:t,decreaseMonth:a,increaseMonth:l,decreaseYear:r,increaseYear:n,prevMonthButtonDisabled:o,nextMonthButtonDisabled:i,prevYearButtonDisabled:s,nextYearButtonDisabled:d})=>e.jsxs("div",{className:"date-picker-container",children:[e.jsxs("div",{className:"d-flex",children:[e.jsx("button",{onClick:a,disabled:o,className:"btn-transparent",type:"button",children:e.jsx(c.KeyboardArrowLeft,{})}),e.jsx("div",{className:"month-view",children:rt[at(t)]}),e.jsx("button",{onClick:l,disabled:i,className:"btn-transparent",type:"button",children:e.jsx(c.KeyboardArrowRight,{})})]}),e.jsxs("div",{className:"d-flex",children:[e.jsx("button",{onClick:r,disabled:s,className:"btn-transparent",type:"button",children:e.jsx(c.KeyboardArrowLeft,{})}),e.jsx("select",{className:"select-year",value:lt(t),onChange:e=>{r(),p(new Date(+e.target.value,at(t)))},children:y.map(t=>e.jsx("option",{value:t,children:t},t))}),e.jsx("button",{onClick:n,disabled:d,className:"btn-transparent",type:"button",children:e.jsx(c.KeyboardArrowRight,{})})]})]})})})}const it=a=>{const l=p(a.min_date||null).isValid()?p(a.min_date).toDate():null,r=p(a.max_date||null).isValid()?p(a.max_date).toDate():null;return e.jsx(t.Controller,{control:a.formControl,name:`${a.fieldArrayName}.${a.name}`,render:({field:t,fieldState:n})=>{var o,i,s;return e.jsxs(e.Fragment,{children:[(null==a?void 0:a.label)&&e.jsxs(h.Typography,{type:"s5",weight:"medium",mb:.5,color:a.error?"theme.error.600":"theme.secondary.800",children:[a.label,a.required&&e.jsx("span",{className:"requiredStar",children:"*"})]}),e.jsx(ot,{start:null==(o=t.value)?void 0:o[0],end:null==(i=t.value)?void 0:i[1],startYear:a.startYear||1980,onDateRangeChange:e=>{t.onChange(e),a.onChange&&a.onChange(e)},placeholderText:a.placeholder||"MM-DD-YYYY - MM-DD-YYYY",dataPosition:a.position,dataName:`${a.fieldArrayName}.${a.name}`,label:a.label,required:"builder"!==a.formType&&a.required,minDate:l,maxDate:r,disabled:a.disabled,error:Boolean(n.error),helperText:null==(s=n.error)?void 0:s.message})]})}})};it.propTypes={formControl:a.PropTypes.shape({register:a.PropTypes.func.isRequired,setValue:a.PropTypes.func}).isRequired,name:a.PropTypes.string.isRequired,label:a.PropTypes.string,fieldArrayName:a.PropTypes.string,required:a.PropTypes.bool,position:a.PropTypes.number,formType:a.PropTypes.string,placeholder:a.PropTypes.string,startYear:a.PropTypes.number,disabled:a.PropTypes.bool,min_date:a.PropTypes.any,max_date:a.PropTypes.any,onChange:a.PropTypes.func};const st=a=>{const{readOnly:l=!1}=a;return e.jsx(t.Controller,{control:a.formControl,name:`${a.fieldArrayName}.${a.name}`,render:({field:t,fieldState:r})=>{var o;return e.jsx(n.DateTimePicker,{...t,dataPosition:a.position,dataName:`${a.fieldArrayName}.${a.name}`,label:a.label,placeholder:a.placeholder,required:"builder"!==a.formType&&a.required,defaultValue:a.defaultValue,disableFutureDates:a.is_future_dates_allowed,disablePastDates:a.is_past_dates_allowed,helperText:null==(o=r.error)?void 0:o.message,error:Boolean(r.error),disabled:a.disabled,minDate:a.min_date,maxDate:a.max_date,minDateTime:a.min_date_time,maxDateTime:a.max_date_time,textFieldProps:l?{readOnly:!0}:{readOnly:!1},onChange:e=>{if(a.min_date_time&&e&&p(e).isSame(a.min_date_time,"day")){const l=p(e);if(l.isBefore(a.min_date_time)){const e=l.hour(a.min_date_time.hour()).minute(a.min_date_time.minute());return void t.onChange(e)}}t.onChange(e)}})}})};st.propTypes={formControl:a.PropTypes.shape({register:a.PropTypes.func.isRequired,setValue:a.PropTypes.func}).isRequired,name:a.PropTypes.string.isRequired,label:a.PropTypes.string.isRequired,fieldArrayName:a.PropTypes.string,required:a.PropTypes.bool,position:a.PropTypes.number,formType:a.PropTypes.string,placeholder:a.PropTypes.string,defaultValue:a.PropTypes.any,is_future_dates_allowed:a.PropTypes.bool,is_past_dates_allowed:a.PropTypes.bool,typeOfField:a.PropTypes.string,disable:a.PropTypes.bool,min_date:a.PropTypes.any,max_date:a.PropTypes.any};const dt=i.lazy(()=>Promise.resolve().then(()=>require("./custom-editor-CqKvR1Cc.js"))),ct=i.memo(a=>{const l=i.useMemo(()=>`${a.fieldArrayName}.${a.name}`,[a.fieldArrayName,a.name]),{minDate:r,maxDate:o}=i.useMemo(()=>({minDate:p(a.min_date||null).isValid()?p(a.min_date):null,maxDate:p(a.max_date||null).isValid()?p(a.max_date):null}),[a.min_date,a.max_date]),s=i.useMemo(()=>"builder"!==a.formType&&a.required,[a.formType,a.required]);return e.jsx(t.Controller,{control:a.formControl,name:l,render:({field:t,fieldState:i})=>{var d;return e.jsx(n.DatePicker,{...t,...a,dataPosition:a.position,dataName:l,label:a.label,placeholder:a.placeholder,required:s,defaultValue:a.defaultValue,disableFutureDates:a.is_future_dates_allowed,disablePastDates:a.is_past_dates_allowed,helperText:null==(d=i.error)?void 0:d.message,error:Boolean(i.error),disabled:a.disabled,minDate:r,maxDate:o})}})});ct.displayName="CustomDatePicker",ct.propTypes={formControl:a.PropTypes.shape({register:a.PropTypes.func.isRequired,setValue:a.PropTypes.func}).isRequired,name:a.PropTypes.string.isRequired,label:a.PropTypes.string.isRequired,fieldArrayName:a.PropTypes.string,required:a.PropTypes.bool,position:a.PropTypes.number,formType:a.PropTypes.string,placeholder:a.PropTypes.string,defaultValue:a.PropTypes.any,is_future_dates_allowed:a.PropTypes.bool,is_past_dates_allowed:a.PropTypes.bool,typeOfField:a.PropTypes.string,disabled:a.PropTypes.bool,min_date:a.PropTypes.any,max_date:a.PropTypes.any};const ut=u.styled(u.TextField)(({theme:{palette:e}})=>{var t,a,l,r;return{width:"100%","& .MuiOutlinedInput-root":{height:"2rem","& fieldset":{borderColor:null==(t=e.theme)?void 0:t.secondary[300],borderWidth:2},"&:hover fieldset":{borderColor:null==(a=e.theme)?void 0:a.secondary[300]},"&.Mui-focused fieldset":{borderColor:null==(l=e.theme)?void 0:l.primary[700]},"&.Mui-error fieldset":{borderColor:null==(r=e.theme)?void 0:r.error[600]}}}}),mt=Le.object().shape({approver_id:Le.array().required("Please select the approvers").min(1,"Please select the approvers")}),pt=({isOpen:a,setIsOpen:l,modalProps:r,title:s,onConfirm:d,isProcessing:m})=>{const[p,x]=i.useState({isLoading:!0,isError:!1,error:"null",data:[]}),{isLoading:g,isError:y,error:v,data:f}=p,{control:b,handleSubmit:w,reset:C,setValue:D,getValues:M,watch:A,trigger:N}=t.useForm({resolver:o.o(mt),mode:"all"});A("approver_id");const B=M("approver_id"),R=async e=>{await N()&&(d(e.approver_id),E())},E=()=>{C({approver_id:[]}),l()},I=({data:t,options:a})=>{const l=t.map(e=>{const t=a.find(t=>t.id===e);return t?P(t):e});return e.jsxs(u.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[e.jsxs(h.Typography,{type:"s5",color:"inherit",sx:{display:"flex",gap:1,alignItems:"center",mt:.5},children:[l.slice(0,3).join(", "),t.length>4&&e.jsx(S.Chip,{variant:"outlined",type:"normal",className:"quickApprovalModal--DisplayNameChip",label:e.jsx(_.MoreIcon,{fontSize:"small"})})]}),e.jsx(o.Button,{variant:"text",onClick:()=>D("approver_id",[]),children:e.jsx(h.Typography,{type:"s5",color:"inherit",children:"Remove"})})]})};i.useEffect(()=>{a&&(async()=>{var e;try{const t={skip:0,limit:99,filters:"(is_active.eq=true)"},a=await T.getV1User({...t,...j.getToken()}),l=(null==(e=null==a?void 0:a.data)?void 0:e.users)||[];x({isLoading:!1,isError:!1,error:null,data:l})}catch(t){x({isLoading:!1,isError:!0,error:"Failed to fetch Approvers",data:[]})}})()},[a]),i.useEffect(()=>{y&&k.enqueueSnackbar(v??"Something went wrong",{variant:"error"})},[v,y]);const P=e=>{const{first_name:t="",last_name:a=""}=e||{};return j.formatLabel(`${t} ${a}`)};return i.useEffect(()=>()=>{E()},[]),e.jsx(o.Modal,{open:a,onClose:E,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:!0,...r,children:e.jsxs("form",{onSubmit:w(R),children:[e.jsxs(u.DialogTitle,{className:"quickApprovalModal--Title",children:[e.jsx(h.Typography,{type:"s3",color:"inherit",weight:"medium",children:s||"Quick Approval"}),e.jsx(u.IconButton,{onClick:E,children:e.jsx(c.Close,{fontSize:"small"})})]}),e.jsx(u.DialogContent,{className:"quickApprovalModal--ModalContentContainer",children:e.jsx(t.Controller,{name:"approver_id",control:b,render:({field:t,fieldState:a})=>{var l,r,i;return e.jsxs(e.Fragment,{children:[e.jsx(o.Select,{name:"approver_id",value:t.value||[],onChange:t.onChange,error:Boolean(null==(l=a.error)?void 0:l.message),helperText:(null==(r=a.error)?void 0:r.message)||"",size:"small",renderValue:t=>e.jsx(n.ChipOrPlaceholder,{data:t,placeholder:"Select",onDelete:()=>D("approver_id",[])}),multiple:!0,fullWidth:!0,children:f.map(a=>{const l=["theme.tertiary1","theme.tertiary2","theme.tertiary3"],r=l[Math.floor(Math.random()*l.length)],i={borderRadius:"0.25rem !important",textAlign:"center",backgroundColor:`${r}.200`,color:`${r}.1000`};return e.jsx(u.MenuItem,{value:a.id,selected:Boolean(t.value&&t.value.includes(a.id)),children:e.jsxs(u.Box,{className:"quickApprovalModal--UserListingContainer",children:[e.jsxs(u.Box,{className:"quickApprovalModal--UserContent",children:[e.jsx(o.Avatar,{src:a.profile_image,alt:P(a),sx:i,size:24}),e.jsx(h.Typography,{type:"s4",color:"theme.secondary.1000",children:P(a)})]}),e.jsx(n.Checkbox,{checked:Boolean(t.value&&t.value.includes(a.id))})]})},a.id)})}),Array.isArray(null==t?void 0:t.value)&&(null==(i=null==t?void 0:t.value)?void 0:i.length)>0&&e.jsx(I,{data:t.value,options:f})]})}})}),e.jsxs(u.DialogActions,{className:"quickApprovalModal--DialogActions",children:[e.jsx(o.Button,{className:"quickApprovalModal--DialogActions--Cancel",onClick:E,disabled:g||m,children:"Cancel"}),e.jsx(o.Button,{type:"button",onClick:w(R),endIcon:m?e.jsx(u.CircularProgress,{size:15,color:"inherit"}):void 0,disabled:m||g||Boolean(!(null==B?void 0:B.length)),children:"Send Request"})]})]})})},ht=({column:t})=>{const[a,l]=i.useState(!1),[r,n]=i.useState(t.title);return e.jsxs("div",{className:"kanban-column lead-card",children:[a?e.jsxs("div",{className:"create-status-box",children:[e.jsx("input",{type:"text",placeholder:"Enter new status title",value:r,onChange:e=>n(e.target.value)}),e.jsxs("div",{className:"add-btns",children:[e.jsx("button",{onClick:()=>(t.title=r,void l(!1)),children:"Rename"}),e.jsx("button",{onClick:()=>l(!1),children:"Cancel"})]})]}):e.jsx("h2",{className:"kanban-column-title",onDoubleClick:()=>l(!0),children:t.title}),e.jsx("span",{className:"count-length-text",children:t.cards.length}),e.jsx(u.IconButton,{color:"inherit",size:"small",className:"more-menu-btn",children:e.jsx("img",{src:d.images.more,alt:"more icon"})})]})},xt=({data:t})=>e.jsx(n.Accordion,{title:e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:"Items"}),accordionProps:{defaultExpanded:!0,sx:{borderBottomWidth:1,"& .MuiAccordionSummary-root":{borderBottomWidth:1}}},children:e.jsxs(u.Box,{className:"calculationSummary--SummaryContainer",children:[e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Total Quantity"}),e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:t.totalQuantity})]}),e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Total"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.total]})]})]})}),gt=({data:t,enalblePromotions:a})=>e.jsx(n.Accordion,{title:e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:"Discounts"}),accordionProps:{defaultExpanded:!0,sx:{borderBottomWidth:1,"& .MuiAccordionSummary-root":{borderBottomWidth:1}}},children:e.jsxs(u.Box,{className:"calculationSummary--SummaryContainer",children:[e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Item Discount"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.itemDiscount]})]}),Number(t.additionalDiscount)>0&&e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Additional Discount"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.additionalDiscount]})]}),Boolean(a)&&e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Promotion Amount"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.promotionAmount]})]}),e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Total Discount"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.totalDiscount]})]})]})}),yt=({data:t})=>e.jsx(n.Accordion,{title:e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:"Subtotal"}),accordionProps:{defaultExpanded:!0,sx:{borderBottomWidth:1,"& .MuiAccordionSummary-root":{borderBottomWidth:1}}},children:e.jsxs(u.Box,{className:"calculationSummary--SummaryContainer",children:[e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Subtotal Excluding Taxes"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.subtotalExTax]})]}),e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Subtotal Excluding discount"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.subtotalExDiscount]})]})]})}),vt=({data:t,enableShippings:a})=>e.jsx(n.Accordion,{title:e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:"Taxes and Charges"}),accordionProps:{defaultExpanded:!0,sx:{borderBottomWidth:1,"& .MuiAccordionSummary-root":{borderBottomWidth:1}}},children:e.jsxs(u.Box,{className:"calculationSummary--SummaryContainer",children:[e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Taxes and Charges Added"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.taxes]})]}),e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Taxes and Charges deducted"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.deductedTax]})]}),e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Total Taxes and Charges Added"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.total]})]}),Boolean(a)&&e.jsxs(e.Fragment,{children:[e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Shipping Amount"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.shippingAmount]})]}),e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Handling Amount"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.handlingAmount]})]})]})]})}),ft=({data:t})=>e.jsx(n.Accordion,{title:e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:"Total"}),accordionProps:{defaultExpanded:!0,sx:{borderBottomWidth:1,"& .MuiAccordionSummary-root":{borderBottomWidth:1}}},children:e.jsxs(u.Box,{className:"calculationSummary--SummaryContainer",children:[e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Grand Total"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.total]})]}),Number(t.roundOffDifferenceAmount)>0&&e.jsxs(u.Box,{className:"calculationSummary--SummaryItem",children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Round Off Difference"}),e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:[t.currencySymbol," ",t.roundOffDifferenceAmount]})]})]})}),bt=({children:t,...a})=>e.jsx(u.Box,{className:"card-wrapper",...a,children:t}),jt=Le.object({login:Le.object({password:Le.string().required("Please enter password").min(8,"Password must be at least 8 characters").matches(/[A-Z]/,"Password must contain at least one uppercase letter").matches(/[!@#$%^&*(),.?":{}|<>]/,"Password must contain at least one special character")})}),wt=q.styled(Y)(({theme:{palette:e}})=>{var t,a,l;return{".country-button":{span:{fontSize:"0.875rem"},svg:{fontSize:"1.25rem"},padding:"0.2rem 0.5rem 0.2rem 0rem",borderRadius:".25rem",border:"1px solid #D3D3D4"},ul:{input:{padding:"0.5rem",borderRadius:"0.5rem",fontSize:"0.8125rem",margin:"0px 0.75rem",border:`1px solid ${null==(t=e.theme)?void 0:t.secondary[200]}`,background:`url(${d.images.search}) no-repeat scroll 0.5rem 0.5rem`,paddingLeft:"2rem",backgroundRepeat:"no-repeat",backgroundColor:`${null==(a=e.theme)?void 0:a.secondary[100]}`},li:{fontSize:"0.8125rem",padding:"0.5rem 1rem"},boxShadow:"0px 0px 2px 0px #E0E0E0, 0px 1px 4px -2px rgba(24, 39, 75, 0.02), 0px 4px 4px -2px rgba(24, 39, 75, 0.06)",borderRadius:"0.5rem",marginTop:"0.25rem",border:"none",div:{borderBottom:`1px solid ${null==(l=e.theme)?void 0:l.secondary[200]}`,paddingBottom:"0.5rem"}}}}),Ct=u.styled(u.Box)(({theme:e})=>({position:"relative",display:"inline-flex",alignItems:"center",borderRadius:e.spacing(3),padding:e.spacing(.5),cursor:"pointer",transition:"all 0.3s ease-in-out",minWidth:"max-content",backgroundColor:e.palette.common.white,border:"1px solid",borderColor:e.palette.grey[200],"&.disabled":{opacity:.5,cursor:"not-allowed"}})),St=u.styled(u.Box)(({theme:e})=>({position:"absolute",backgroundColor:e.palette.theme.primary[100],borderRadius:e.spacing(2.5),transition:"all 0.3s ease-in-out",top:0,bottom:0,zIndex:1})),Tt=u.styled(u.ButtonBase)(({theme:e,active:t})=>({position:"relative",zIndex:2,padding:e.spacing(1,1.5),borderRadius:e.spacing(2.5),fontSize:"0.75rem",fontWeight:500,whiteSpace:"nowrap",userSelect:"none",transition:"color 0.3s ease-in-out",color:t?e.palette.primary.main:e.palette.grey[600],"&:hover:not(.disabled)":{color:t?e.palette.primary.main:e.palette.grey[800]},"&.disabled":{cursor:"not-allowed"}})),kt=({children:t,defaultExpanded:a=!0,expandedGridSize:l=3,collapsedGridSize:r=0,className:n="",ariaLabel:o="Toggle summary panel",onToggle:s,persistState:d=!1,storageKey:p="grid-summary-panel-state",showToggleButton:h=!0,mobileDrawer:x=!0,showCollapseIcon:g=!0})=>{const y=u.useTheme(),v=u.useMediaQuery(y.breakpoints.down("md")),{currentLanguage:f}=m.useLanguage(),b=i.useMemo(()=>"rtl"===(null==f?void 0:f.direction),[f]),[j,w]=i.useState(()=>{if(d&&"undefined"!=typeof window){const e=localStorage.getItem(p);return e?JSON.parse(e):a}return a}),[C,S]=i.useState(!1);i.useEffect(()=>{if(!j)return void S(!1);const e=setTimeout(()=>{S(!0)},250);return()=>clearTimeout(e)},[j]);const T=()=>{const e=!j,t=e?l:r;w(e),d&&"undefined"!=typeof window&&localStorage.setItem(p,JSON.stringify(e)),null==s||s(e,t)},k=j?l:r;return v&&x?e.jsxs(e.Fragment,{children:[h&&e.jsx(u.IconButton,{onClick:T,sx:{position:"fixed",top:"50%",[b?"left":"right"]:0,zIndex:y.zIndex.fab,bgcolor:y.palette.background.paper,border:`1px solid ${y.palette.divider}`,borderRadius:"8px 0 0 8px","&:hover":{bgcolor:y.palette.action.hover}},"aria-label":o,children:e.jsx(c.ChevronLeft,{})}),e.jsx(u.Drawer,{anchor:"right",open:j,onClose:T,sx:e=>({"& .MuiDrawer-paper":{width:"90vw",[e.breakpoints.up("md")]:{maxWidth:"400px",marginTop:"65px"},[e.breakpoints.up("sm")]:{maxWidth:"300px",marginTop:"65px"},[e.breakpoints.up("xs")]:{maxWidth:"200px",marginTop:"56px"}}}),children:t})]}):e.jsxs(u.Grid,{item:!0,xs:k,sx:{position:"relative",transition:y.transitions.create(["flex-basis","max-width"],{easing:y.transitions.easing.sharp,duration:y.transitions.duration.enteringScreen}),overflow:"visible",minHeight:"100%",display:"block",minWidth:0===k?0:"auto"},className:n,children:[h&&!j&&e.jsx(u.Tooltip,{title:"Expand summary",placement:"left",children:e.jsx(u.IconButton,{onClick:T,sx:{position:"fixed",top:"20%",[b?"left":"right"]:0,width:"30px",zIndex:y.zIndex.fab,bgcolor:y.palette.background.paper,border:`1px solid ${y.palette.divider}`,borderRadius:"8px 0 0 8px","&:hover":{bgcolor:y.palette.action.hover}},"aria-label":"Expand summary panel",children:j?e.jsx(c.ChevronRight,{}):e.jsx(c.ChevronLeft,{})})}),k>0&&C&&e.jsxs(u.Box,{sx:{height:"100%",width:"100%",overflow:"visible",display:"flex",flexDirection:"column",bgcolor:y.palette.background.paper,borderLeft:`1px solid ${y.palette.divider}`,borderRadius:"8px 0 0 8px",position:"relative"},children:[g&&j&&e.jsx(u.Tooltip,{title:"Close summary",placement:"left",children:e.jsx(u.IconButton,{onClick:T,size:"small",sx:{position:"absolute",top:"-15px",[b?"right":"left"]:"-15px",zIndex:1200,bgcolor:y.palette.background.paper,border:`1px solid ${y.palette.divider}`,borderRadius:"50%","&:hover":{bgcolor:"#fff"},boxShadow:"none"},children:e.jsx(c.Close,{sx:{fontSize:14}})})}),e.jsx(u.Collapse,{in:j,orientation:"horizontal",sx:{height:"100%","& .MuiCollapse-wrapperInner":{height:"100%",width:"100%"},width:"100%"},children:e.jsx(u.Box,{sx:{width:"100%",height:"100%",overflow:"auto",minWidth:0},children:t})}),!j&&e.jsx(u.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",width:"100%",color:y.palette.text.secondary,cursor:"pointer"},onClick:T,children:e.jsx(u.Box,{sx:{writingMode:"vertical-lr",textOrientation:"mixed",fontSize:"0.875rem",fontWeight:500,letterSpacing:"0.1em"},children:"SUMMARY"})})]})]})},_t=({buttons:t,dropdownMenuButtonData:a=null,toggleCallback:l,className:r,zIndex:i=999,iconPosition:s="start",...d})=>e.jsxs("div",{className:r,children:[null==t?void 0:t.map(t=>e.jsx(o.Button,{className:t.class?t.class:`wrapper--${null==t?void 0:t.btnStyle}`,variant:t.variant?t.variant:"contained",startIcon:t.icon?t.icon:"",onClick:t.action,children:t.title??""},t.title)),a&&e.jsx("div",{style:{zIndex:i},children:e.jsx(n.DropdownButton,{options:a.options||[],..."start"===s?{startIcon:a.icon}:{endIcon:a.icon},isMenuThirdItemDisabled:!0,isOnlyDropDownButton:!0,variant:"text",buttonGroupProps:{variant:"text"},onlyDropDownButtonProps:{style:{backgroundColor:"white !important",color:"black !important",...a.sx}},toggleCallback:l,...d,children:a.children})})]}),Dt={"& .MuiOutlinedInput-root":{"& fieldset":{border:"none"},"&:hover fieldset":{border:"none"},"&.Mui-focused fieldset":{border:"none"}}},Mt=({options:t,multiple:a,placeholder:l,with_checkboxes:r,values:o,field:i})=>{const s=[];return a||s.push(e.jsx(u.MenuItem,{disabled:!0,value:"",children:e.jsx(h.Typography,{type:"s3",color:"theme.secondary.1000",children:e.jsx("em",{children:l})})})),null==t||t.forEach(t=>{s.push(e.jsx(u.MenuItem,{value:t.value,disabled:Boolean(t.disabled),className:(null==t?void 0:t.isGroup)?"select--MenuItemHeader":"",children:e.jsxs(u.Box,{sx:{display:"flex",gap:1},children:[a&&r&&e.jsx(n.Checkbox,{checked:de.some(o,t.value)}),e.jsx(h.Typography,{type:"s3",color:"theme.secondary.1000",children:t.label})]})},t.value)),(null==t?void 0:t.isGroup)&&Array.isArray(null==t?void 0:t.options)&&t.options.forEach(l=>{s.push(e.jsx(u.MenuItem,{value:l.value,disabled:Boolean(l.disabled),sx:{pl:5},children:e.jsxs(u.Box,{sx:{display:"flex",gap:1},children:[a&&r&&e.jsx(n.Checkbox,{checked:Boolean(o&&(null==o?void 0:o.indexOf(l.value))>-1)}),e.jsx(h.Typography,{type:"s3",color:"theme.secondary.1000",children:l.label})]})},`${t.value}-${l.value}`))})}),i.enable_footer&&s.push(e.jsxs(u.Box,{children:[e.jsx(u.Divider,{flexItem:!0}),e.jsxs(u.MenuItem,{sx:{gap:1},onClick:i.onFooterClick,children:[e.jsx(c.Add,{fontSize:"small"}),e.jsxs(h.Typography,{type:"s4",color:"theme.secondary.1000",children:["Create New ",i.label]})]})]})),s},At=({data:t,options:a})=>{const l=t.map(e=>{var t;return(null==(t=null==a?void 0:a.find(t=>{var a,l;return((null==(a=t.value)?void 0:a.id)||(null==(l=t.value)?void 0:l.name)||t.value)===((null==e?void 0:e.id)||(null==e?void 0:e.name)||e)}))?void 0:t.label)||e});return e.jsxs(h.Typography,{type:"s4",color:"inherit",sx:{display:"flex",gap:1,alignItems:"center",mt:.5,position:"absolute"},children:[l.slice(0,4).join(", "),t.length>4&&"..."]})},Nt=t=>{var a;const[l,r]=i.useState([]),[s,d]=i.useState(t.defaultValue||t.value||(t.is_multiselect?[]:"")),m=e=>null==e?void 0:e.filter(e=>e),p=i.useCallback(()=>{r(t.options)},[t.options]);i.useEffect(()=>{p()},[p]),i.useEffect(()=>{d(t.defaultValue||t.value||(t.is_multiselect?[]:""))},[t.defaultValue,t.value,t.is_multiselect]);const{t:h}=w.useTranslation();return e.jsxs(e.Fragment,{children:[e.jsx(o.Select,{fullWidth:!0,placeholder:t.placeholder,label:t.label,value:s,defaultValue:t.defaultValue||(t.is_multiselect?[]:""),required:t.required,size:t.size||"small",multiple:Boolean(null==t?void 0:t.is_multiselect),disabled:Boolean(null==t?void 0:t.disabled),variant:"outlined",sx:Boolean(null==t?void 0:t.is_multiselect)&&(null==s?void 0:s.length)?{"& .MuiSelect-select":{padding:"5.5px !important",minWidth:"165px"}}:{minWidth:"165px"},className:t.is_multiselect&&(null==(a=m(s))?void 0:a.length)?"MultiSelect":"",input:(null==t?void 0:t.is_multiselect)||t.disabled?void 0:e.jsx(u.OutlinedInput,{label:"",endAdornment:e.jsx(u.InputAdornment,{position:"end",children:t.value&&e.jsx(u.IconButton,{"aria-label":"clear selection",onClick:()=>t.onChange(null),edge:"end",sx:{mr:1.5},size:"small",children:e.jsx(c.Close,{sx:{fontSize:"1rem"}})})})}),renderValue:a=>{var r;return e.jsx(e.Fragment,{children:Array.isArray(a)?e.jsx(n.ChipOrPlaceholder,{selectedLabel:t.selectedLabel,data:m(a),placeholder:t.placeholder,onDelete:null==t?void 0:t.onChipRemove,disabled:t.disabled,chipProps:{sx:{bgcolor:"theme.primary.100",border:0,"& .MuiTypography-body1":{color:"theme.primary.800",fontWeight:"500"},"& .MuiChip-deleteIcon":{color:"theme.primary.800","&:hover":{color:"theme.primary.900"}}}}}):(null==(r=null==l?void 0:l.find(e=>{var t,l;return((null==(t=e.value)?void 0:t.id)||(null==(l=e.value)?void 0:l.name)||e.value)===((null==a?void 0:a.id)||(null==a?void 0:a.name)||a)}))?void 0:r.label)||a||t.placeholder})},searchPlaceholder:`${h("common.search")} ${t.label}`,handleSearch:t.handleSearch,searchValue:t.searchValue||"",onChange:(e,a)=>{var l,r;let n=null==(l=null==e?void 0:e.target)?void 0:l.value;if(t.is_multiselect){const e=null==(r=null==a?void 0:a.props)?void 0:r.value;s.find(t=>(null==t?void 0:t.name)==(null==e?void 0:e.name))&&(n=s.filter(t=>(null==t?void 0:t.name)!=(null==e?void 0:e.name))),n=null==n?void 0:n.filter(Boolean)}d(n),t.onChange&&t.onChange(n)},loading:null==t?void 0:t.is_loading,children:Mt({options:l,multiple:Boolean(t.is_multiselect),placeholder:t.placeholder,values:s,with_checkboxes:!0,field:t})}),t.is_multiselect&&Array.isArray(s)&&e.jsx(At,{data:s,options:l})]})};Nt.propTypes={name:a.PropTypes.string.isRequired,placeholder:a.PropTypes.string.isRequired,label:a.PropTypes.string.isRequired,size:a.PropTypes.string,options:a.PropTypes.arrayOf(a.PropTypes.shape({label:a.PropTypes.string,value:a.PropTypes.string})).isRequired,defaultValue:a.PropTypes.string,fieldArrayName:a.PropTypes.string,id:a.PropTypes.string,required:a.PropTypes.bool,is_multiselect:a.PropTypes.bool,position:a.PropTypes.number,disabled:a.PropTypes.bool,onChipRemove:a.PropTypes.func,enable_footer:a.PropTypes.bool,footer_action:a.PropTypes.string,onFooterClick:a.PropTypes.any,is_loading:a.PropTypes.bool,selectedLabel:a.PropTypes.string,onChange:a.PropTypes.func};const Bt=({buttons:t,dropdownMenuButtonData:a=null,toggleCallback:l,className:r,zIndex:i=999})=>e.jsxs("div",{className:r,children:[null==t?void 0:t.map(t=>e.jsx(o.Button,{className:t.class?t.class:`wrapper--${null==t?void 0:t.btnStyle}`,variant:t.variant?t.variant:"contained",startIcon:t.icon?t.icon:"",disabled:Boolean(t.disabled),onClick:t.action,children:t.title??""},t.title)),a&&e.jsx("div",{style:{zIndex:i},children:e.jsx(n.DropdownButton,{options:a.options||[],startIcon:a.icon,isMenuThirdItemDisabled:!0,isOnlyDropDownButton:!0,variant:"text",buttonGroupProps:{variant:"text",sx:({palette:e})=>({"& .MuiButton-root":{border:"1px solid !important",borderColor:`${e.grey[200]} !important`,borderRadius:"20px",pt:.25,pb:.25,pr:.75,color:`${e.grey[800]} !important`,":hover":{bgcolor:`${e.grey[200]} !important`}}})},onlyDropDownButtonProps:{style:{backgroundColor:"white !important",color:"black !important",...a.sx}},toggleCallback:l,children:a.children})})]}),Rt=[{header:"Report name",accessorKey:"name",visible:!0,type:"string"},{header:"Email ID",accessorKey:"emails",visible:!0,type:"custom"},{header:"Date",accessorKey:"schedule_date",visible:!0,type:"date"},{header:"Time",accessorKey:"schedule_time",visible:!0,type:"time"},{header:"Recurring",accessorKey:"autopost",visible:!0,type:"string"},{header:"Report Page",accessorKey:"report_data.name",visible:!0,type:"string"},{header:"Main Page",accessorKey:"main_page",visible:!0,type:"string"},{header:"Status",accessorKey:"status",visible:!0,type:"status"}],Et="schedule_report",It={schedule_report:{schedule_date:p(),schedule_time:p()}},Pt={type:"type",autopost:e=>(null==e?void 0:e.is_recurring)?null==e?void 0:e.autopost:void 0,emails:"emails",id:e=>(null==e?void 0:e.id)||void 0,is_recurring:e=>Boolean(null==e?void 0:e.is_recurring),name:"name",next_schedule_date:"next_schedule_date",schedule_date:"schedule_date",schedule_time:"schedule_time",subject:"subject",report_id:"report_id",filters:e=>(null==e?void 0:e.filters)||void 0},Ft=e=>o.o(Le.object().shape({[Et]:Le.object().shape({report_id:e?Le.string().required("Report is required"):Le.string(),name:Le.string().required("Report name is required"),subject:Le.string(),schedule_date:Le.mixed().required("Date is required").test("is-future-date","Date cannot be in the past",e=>{if(!e)return!1;const t=p(e).startOf("day"),a=p().startOf("day");return t.isSame(a)||t.isAfter(a)}),schedule_time:Le.mixed().required("Time is required").test("is-future-time","Time cannot be in the past",function(e){const{schedule_date:t}=this.parent;if(!e||!t)return!1;const a=p(t).startOf("day"),l=p().startOf("day");if(a.isAfter(l))return!0;const r=p(),n=p(e);return p(t).hour(n.hour()).minute(n.minute()).second(0).isAfter(r)}),email:Le.array(),emails:Le.string().test("emails-required","Email is required",function(e){const{email:t}=this.parent;return!(!(null==t?void 0:t.length)&&!e)}),is_recurring:Le.boolean(),autopost:Le.string().when("is_recurring",{is:!0,then:e=>e.required("Auto post is required"),otherwise:e=>e.optional().nullable()})})})),$t=[{label:"Day",value:"Day"},{label:"Week",value:"Week"},{label:"Month",value:"Month"},{label:"3 month",value:"3 month"},{label:"6 month",value:"6 month"},{label:"1 Year",value:"1 Year"}],zt=async e=>T.putV1ReportsUpdateScheduleReportId(e),qt=async e=>T.postV1ReportsScheduleReport(e),Ot=({label:a,isOpen:l=!1,modalProps:r,itemData:s,onSubmit:d,onClose:m,module:x="accounting",filters:g,report:y=null})=>{const[v,f]=i.useState(!1),{control:b,handleSubmit:w,reset:C,setValue:S,watch:_,trigger:D}=t.useForm({resolver:Ft(!(null==s?void 0:s.id)),mode:"all",shouldUnregister:!0,defaultValues:It}),M=_(`${Et}.is_recurring`),A=i.useMemo(()=>!(!(null==s?void 0:s.id)&&!y),[null==s?void 0:s.id,y]),N=async e=>{if(!(await D()))return;const t=null==e?void 0:e[Et],a={...t,type:x,filters:g,schedule_date:j.formatDateForPayload(t.schedule_date),schedule_time:j.formatTimeForPayload(t.schedule_time),...s&&(null==s?void 0:s.id)?{id:String(s.id)||""}:{}};null==a||delete a.email;const l=j.mapApiPayload(Pt,a),r=(null==s?void 0:s.id)?zt:qt;try{await r({...l,...j.getToken()}),null==d||d(),k.enqueueSnackbar("Report scheduled successfully",{}),B()}catch(n){const e=j.getErrorMessage(null==n?void 0:n.message);k.enqueueSnackbar(e,{variant:"error"})}finally{f(!1)}},B=()=>{m(),setTimeout(()=>{C({[Et]:{}})},300)},R=i.useCallback(async()=>{var e,t;if(console.log("report",y),l&&y)try{const{data:a={}}=await(async e=>{try{return await T.getV1ReportsReportList(e)}catch(t){console.log("error",t)}})({...j.getToken(),filters:`(name.like=%${y}%)`});S(`${Et}.report_id`,null==(t=null==(e=null==a?void 0:a.reports)?void 0:e[0])?void 0:t.id)}catch(a){console.log("error",a)}},[y,l,S]);i.useEffect(()=>{var e,t;const a=null==(t=null==(e=null==s?void 0:s.schedule_time)?void 0:e.split(":"))?void 0:t.map(Number);(null==s?void 0:s.id)?C({[Et]:{...s,schedule_date:(null==s?void 0:s.schedule_date)?p(null==s?void 0:s.schedule_date):"",schedule_time:3===(null==a?void 0:a.length)?p().set("hour",a[0]).set("minute",a[1]).set("second",a[2]).set("millisecond",0):""}}):C(It)},[l,null==s?void 0:s.id,x]);const E=_(`${Et}.schedule_date`);i.useEffect(()=>{E&&D(`${Et}.schedule_time`)},[E,D]);const I=i.useMemo(()=>E&&p(E).startOf("day").isSame(p().startOf("day")),[E]);return i.useEffect(()=>{R()},[R]),e.jsx(o.Modal,{open:l,onClose:m,maxWidth:"md",fullWidth:!0,...r,children:e.jsxs("form",{onSubmit:w(N),id:"scheduleReportModal",children:[v&&e.jsx(n.ModalLoader,{}),e.jsxs(u.DialogTitle,{className:"scheduleReportModal--Title",children:[e.jsx(h.Typography,{type:"s3",color:"inherit",weight:"medium",children:a||"Schedule"}),e.jsx(u.IconButton,{onClick:B,children:e.jsx(c.Close,{fontSize:"small"})})]}),e.jsx(u.DialogContent,{children:e.jsxs(u.Grid,{container:!0,rowGap:1.5,columnSpacing:3,pt:3,children:[e.jsx(u.Grid,{item:!0,sm:12,children:e.jsx(u.Grid,{item:!0,sm:6,children:e.jsx(n.DynamicSearchSelect,{disabled:Boolean(null==s?void 0:s.id)||A,label:"Report",apiType:"reports",name:"report_id",placeholder:"Select report",fieldArrayName:Et,formControl:b,required:!0,customeFilter:{"&type.eq":x,"&allow_scheduling.eq":1}})})}),e.jsx(u.Grid,{item:!0,sm:6,children:e.jsx(o.DynamicInput,{type:"text",formControl:b,label:"Report name",name:"name",fieldArrayName:Et,placeholder:"Enter Report Name",required:!0})}),e.jsx(u.Grid,{item:!0,sm:6,children:e.jsx(o.DynamicInput,{type:"text",formControl:b,label:"Subject",name:"subject",fieldArrayName:Et,placeholder:"Enter Subject"})}),e.jsx(u.Grid,{item:!0,sm:6,children:e.jsx(n.DynamicDate,{formControl:b,name:"schedule_date",placeholder:"DD-MM-YYYY",label:"Date",fieldArrayName:Et,required:!0,min_date:p()})}),e.jsx(u.Grid,{item:!0,sm:6,children:e.jsx(n.DynamicTime,{formControl:b,placeholder:"hh:mm",label:"Time",option:"24hr",name:"schedule_time",fieldArrayName:Et,required:!0,rest:{timeSteps:{minutes:1},ampm:!1,...I&&{minTime:p()}}})}),e.jsx(u.Grid,{item:!0,xs:12,children:e.jsx(n.ChipGenerator,{control:b,name:"emails",label:"Email",required:!0,fieldArrayName:Et,placeholder:"Enter Emails: example1@mail.com, example2@mail.com",validation:[{type:"email",message:"Please enter a valid email address",pattern:/^[^\s@]+@[^\s@]+\.[^\s@]+$/}]})}),e.jsx(u.Grid,{item:!0,sm:12,children:e.jsx(n.DynamicCheckBox,{formControl:b,name:"is_recurring",title:"Recurring",fieldArrayName:Et,titlePosition:"end"})}),M?e.jsx(u.Grid,{item:!0,sm:6,children:e.jsx(n.DynamicSearchSelect,{label:"Auto Post",options:$t||[],name:"autopost",placeholder:"Select Auto Post",fieldArrayName:Et,formControl:b,required:!0})}):null]})}),e.jsx(u.DialogActions,{className:"scheduleReportModal--ActionContainer",children:e.jsxs(u.Box,{display:"flex",gap:1.5,children:[e.jsx(o.Button,{className:"scheduleReportModal--ActionContainer--WhiteBtn",onClick:B,disabled:v,children:"Discard"}),e.jsx(o.Button,{type:"button",onClick:w(N),endIcon:v?e.jsx(u.CircularProgress,{size:20,color:"inherit"}):void 0,disabled:v,children:"Schedule"})]})})]})})};function Lt({snackbarKey:t}){const{closeSnackbar:a}=k.useSnackbar();return e.jsx(u.Box,{children:e.jsx(pe,{onClick:()=>a(t),sx:{width:20,height:20},children:e.jsx(l,{sx:{color:"#fff",width:16,height:16}})})})}const Yt=({open:t,onClose:a,onReplace:l,onKeepBoth:r,title:n,isFile:s})=>(i.useEffect(()=>{},[t]),e.jsxs(u.Dialog,{open:t,className:"filter-container",onClose:a,children:[e.jsxs(u.DialogTitle,{className:"filter-header",sx:{padding:"20px"},children:[" ",e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:"Confirmation"}),e.jsx(u.IconButton,{size:"small",onClick:a,children:e.jsx(c.Close,{fontSize:"small"})})]}),e.jsx(u.DialogContent,{sx:{marginTop:"20px"},children:e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:s?`The destination already has a file named ${n}`:"The destination already has a folder name "})}),e.jsxs(u.DialogActions,{className:"filter-footer",children:[e.jsx(o.Button,{className:"cancel-filter-btn",onClick:r,children:"Keep Both"}),e.jsx(o.Button,{onClick:l,children:"Replace"})]})]})),Wt=(e,t=2)=>{if(0===e)return"0 Bytes";const a=t<0?0:t,l=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,l)).toFixed(a))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][l]},Vt=({data:t,placeholder:a,onDelete:l,chipProps:r})=>e.jsx(e.Fragment,{children:t.length?e.jsx(S.Chip,{variant:"outlined",type:"normal",label:`${t.length} Selected`,deleteIcon:e.jsx(c.Close,{fontSize:"large"}),onDelete:l,onMouseDown:e=>e.stopPropagation(),...r}):e.jsx(h.Typography,{color:"inherit",type:"s3",children:a})}),Kt=({data:t,options:a})=>{const l=t.map(e=>{var t;return(null==(t=a.find(t=>t.value===e))?void 0:t.text)||e});return e.jsxs(h.Typography,{type:"s4",color:"inherit",sx:{display:"flex",gap:1,alignItems:"center",mt:.5},children:[l.slice(.4).join(", "),t.length>4&&e.jsx(S.Chip,{variant:"outlined",type:"normal",label:e.jsx(_.MoreIcon,{})})]})},Ht=({options:t,multiple:a,placeholder:l,with_checkboxes:r,onChange:o,values:i})=>{const s=[];return a||s.push(e.jsx(u.MenuItem,{disabled:!0,value:"",children:e.jsx("em",{children:l})})),t.forEach(t=>{s.push(e.jsx(u.MenuItem,{value:t.value,className:(null==t?void 0:t.isGroup)?"select--MenuItemHeader":"",children:e.jsxs(u.Box,{sx:{display:"flex",gap:1},children:[a&&r&&e.jsx(n.Checkbox,{checked:(null==i?void 0:i.indexOf(t.value))>-1,onChange:()=>((e,t)=>{const a=t.map(e=>e.value),l=i.includes(e)?i.filter(t=>t!==e&&!a.includes(t)):[...i,e,...a];o(l)})(t.value,t.options||[])}),e.jsx(h.Typography,{type:"s4",color:"inherit",children:t.text})]})})),(null==t?void 0:t.isGroup)&&Array.isArray(null==t?void 0:t.options)&&t.options.forEach(t=>{s.push(e.jsx(u.MenuItem,{value:t.value,sx:{pl:5},children:e.jsxs(u.Box,{sx:{display:"flex",gap:1},children:[a&&r&&e.jsx(n.Checkbox,{checked:(null==i?void 0:i.indexOf(t.value))>-1}),e.jsx(h.Typography,{type:"s4",color:"inherit",children:t.text})]})}))})}),s},Ut=({column:t,row:a,col:l,errors:r,validationSchema:s,setValidationErrors:d,onChangeRowField:c,getSelectedData:m,syncFieldValue:x})=>{var g,y,v,f,b,j,w,C;const[S,T]=i.useState(),[k,_]=i.useState(!1),D=i.useRef(null),M=a.getAllCells().map(e=>e.column.columnDef).filter(e=>void 0===(null==e?void 0:e.enableEditing)||!0===(null==e?void 0:e.enableEditing)),A=l.editVariant,N=(null==(g=t.columnDef)?void 0:g.editProperties)||{};let B=!1;(null==N?void 0:N.disable)&&(B="function"==typeof N.disable?Boolean(null==N?void 0:N.disable(a,a._valuesCache)):Boolean(N.disable));const R=i.useCallback(async(e,t)=>{try{if("function"==typeof N.customeFilter){const a=await N.customeFilter(e,t);return D.current=a,a}D.current=null==N?void 0:N.customeFilter}catch(a){return null}},[N,a,a._valuesCache]);i.useEffect(()=>{R(a,a._valuesCache)},[R,a,a._valuesCache]);const E=null==N?void 0:N.valueKey;let I="";if("select"===A&&(null==N?void 0:N.is_multiple))I=E?de.get(a.original,E,[]):[];else if(I=E?de.get(a.original,E,a.original[t.id]):a.original[t.id],"select"===A&&("string"==typeof I||"number"==typeof I)&&(null==l?void 0:l.editSelectOptions)){const e=l.editSelectOptions.find(e=>e.value===I||e.id===I||e.name===I||String(e.id)===String(I));e&&(I=e)}const P=async(e,n,o)=>{const i=o;let u;switch(n){case"date":case"file":case"image":case"phone":case"time":u=e;break;case"text":case"number":default:u=e.target.value;break;case"checkbox":u=e.target.checked}if(T({...S,[t.id]:u}),c){const t=await c(e,n,a,l,i);t&&(a._valuesCache={...a._valuesCache,...t},T({...S,...t}))}T({...S,[t.id]:u}),a._valuesCache={...a._valuesCache,[t.id]:u},x(a.id,t.id,u),await(async e=>{try{await s.validateAt(t.id,{[t.id]:e},{abortEarly:!1});const a={};for(const e in r)e!=t.id&&(a[e]=r[e]);d(a)}catch(a){if(a instanceof Le.ValidationError){const e={};a.inner.forEach(t=>{t.path&&(e[t.path]=t.message)});const t={...r,...e};d(t)}}})(u)};return i.useEffect(()=>{T({...S,...a._valuesCache})},[a._valuesCache]),i.useEffect(()=>{if(!k){const e=Object.keys(a._valuesCache||{}),t={};a.getAllCells().forEach(l=>{var r,n,o;if(void 0===(null==(r=l.column.columnDef)?void 0:r.enableEditing)||!0===(null==(n=l.column.columnDef)?void 0:n.enableEditing)){const{is_multiple:r,valueKey:n}=(null==(o=l.column.columnDef)?void 0:o.editProperties)||{};if(e.includes(l.column.id)){const e=de.get(a.original,n);t[l.column.id]="select"===A&&r?e?Array.isArray(e)?e:[e]:[]:"date"===A||"date_time"===A||"time"===A?e?p(e).isValid()?p(e):void 0:p(a.original[l.column.id]).isValid()?p(a.original[l.column.id]):void 0:de.get(a.original,n,a.original[l.column.id])}}}),a._valuesCache=t,T(t),_(!0)}},[a,A,k]),e.jsxs(e.Fragment,{children:[(!A||"number"===A)&&e.jsx(o.TextField,{defaultValue:I,onChange:e=>P(e,A),value:null==S?void 0:S[t.id],autoFocus:(null==(y=null==M?void 0:M[0])?void 0:y.accessorKey)===t.id,type:A||"text",error:!!(null==r?void 0:r[t.id]),helperText:null==r?void 0:r[t.id],placeholder:(null==N?void 0:N.placeholder)||"",name:(null==N?void 0:N.field_name)||"",disabled:B}),"select"===A&&e.jsxs(u.Box,{display:"flex",flexDirection:"column",width:"100%",children:[e.jsx(n.SearchableSelect,{name:(null==N?void 0:N.field_name)||"",defaultValue:I,placeholder:(null==N?void 0:N.placeholder)||"",searchPlaceholder:`Search ${l.header}`,onChange:(e,t)=>P(e,"select",t),apiType:null==N?void 0:N.apiType,autoFocus:(null==(v=null==M?void 0:M[0])?void 0:v.accessorKey)===t.id,options:null==l?void 0:l.editSelectOptions,customeFilter:D.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==S?void 0:S[t.id])?null==S?void 0:S[t.id]:[]:null==S?void 0:S[t.id],getSelectedData:e=>m(null==N?void 0:N.field_name,e)}),(null==r?void 0:r[t.id])&&e.jsx(h.Typography,{color:"theme.error.600",type:"s5",children:null==r?void 0:r[t.id]})]}),"date"===A&&e.jsx(n.DatePicker,{name:(null==N?void 0:N.field_name)||"",defaultValue:I,onChange:e=>P(e,"date"),textFieldProps:{autoFocus:(null==(f=null==M?void 0:M[0])?void 0:f.accessorKey)===t.id},error:!!(null==r?void 0:r[t.id]),helperText:null==r?void 0:r[t.id],format:null==N?void 0:N.dateFormat,placeholder:(null==N?void 0:N.placeholder)||(null==N?void 0:N.dateFormat),value:p(a._valuesCache[t.id]).isValid()?p(a._valuesCache[t.id]):void 0,disabled:B,minDate:null==N?void 0:N.min_date,maxDate:null==N?void 0:N.max_date}),"date_time"===A&&e.jsx(n.DateTimePicker,{name:(null==N?void 0:N.field_name)||"",defaultValue:I,onChange:e=>P(e,"date"),textFieldProps:{autoFocus:(null==(b=null==M?void 0:M[0])?void 0:b.accessorKey)===t.id},error:!!(null==r?void 0:r[t.id]),helperText:null==r?void 0:r[t.id],format:null==N?void 0:N.dateFormat,placeholder:(null==N?void 0:N.placeholder)||(null==N?void 0:N.dateFormat),value:p(a._valuesCache[t.id]).isValid()?p(a._valuesCache[t.id]):void 0,disabled:B}),"time"===A&&e.jsx(n.TimePicker,{name:(null==N?void 0:N.field_name)||"",label:"",value:p(a._valuesCache[t.id]).isValid()?p(a._valuesCache[t.id]):void 0,onChange:e=>P(e,"time"),error:!!(null==r?void 0:r[t.id]),helperText:null==r?void 0:r[t.id],placeholder:(null==N?void 0:N.placeholder)||"HH:mm A",disabled:B,is24hrFormat:null==N?void 0:N.is24hrFormat}),("file"===A||"image"===A)&&e.jsxs(u.Box,{display:"flex",flexDirection:"column",children:[e.jsx(n.UploadMedia,{name:(null==N?void 0:N.field_name)||"table_file",dataPosition:0,dataName:"table_file",label:"",type:A,max_size:10,onChange:e=>P(e,"file"),error:!!(null==r?void 0:r[t.id]),multiple:Boolean(null==t?void 0:t.is_multiple),value:a._valuesCache[t.id]}),(null==r?void 0:r[t.id])&&e.jsx(h.Typography,{color:"theme.error.600",type:"s5",children:null==r?void 0:r[t.id]})]}),"phone"===A&&e.jsx(n.PhoneInput,{name:(null==N?void 0:N.field_name)||"",default_value:I,onChange:e=>P(e,"phone"),textFieldProps:{autoFocus:(null==(j=null==M?void 0:M[0])?void 0:j.accessorKey)===t.id},error:!!(null==r?void 0:r[t.id]),helperText:null==r?void 0:r[t.id],format:null==N?void 0:N.dateFormat,placeholder:(null==N?void 0:N.placeholder)||(null==N?void 0:N.dateFormat),value:null==(w=a._valuesCache)?void 0:w[t.id],disabled:B,isInlineEditing:!0}),"checkbox"===A&&e.jsx(n.Checkbox,{name:(null==N?void 0:N.field_name)||"",defaultChecked:Boolean(I),onChange:e=>P(e,"checkbox"),error:!!(null==r?void 0:r[t.id]),helperText:null==r?void 0:r[t.id],format:null==N?void 0:N.dateFormat,placeholder:(null==N?void 0:N.placeholder)||(null==N?void 0:N.dateFormat),value:null==(C=a._valuesCache)?void 0:C[t.id],disabled:B})]})},Gt=u.styled(u.Box)(({theme:{palette:e}})=>{var t,a,l,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":{maxHeight:"clamp(350px, 100vh - 200px, 9999px) !important"},".MuiPaper-root":{boxShadow:"none"},".MuiPaginationItem-root":{"&.Mui-selected":{backgroundColor:null==(a=null==e?void 0:e.theme)?void 0:a.primary[700],color:"white"}},".MuiTableRow-root":{"&.Mui-selected":{backgroundColor:`${null==(l=null==e?void 0:e.theme)?void 0:l.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"}}}}),Xt=i.memo(({enablePagination:t=!1,rows:a,columns:l,totalPages:n,paginationModel:s,columnOrder:c,updateData:m,handleColumnOrdering:x,enableEditing:g,enableColumnDragging:y,states:v,rowActionMenu:f,destructiveActionMenu:b,disableDefaultActionColumn:j,enableRowSelection:C,defaultActionColumnItems:T=[],enableBottomToolbar:D,SetSelectedRowId:M,isResetRow:A,onCreateRow:N,onEditRow:B,onDeleteRow:R,editDisplayMode:E,enableRowCreate:I,onChangeRowField:P,onSelectRow:F,enableColumnResizing:$=!0,selectedRowIds:z=[],onColumnVisibility:q,onSortingChange:O,getSelectedData:L,disabledDefaultActionColumnIcon:Y=!1,enableAddCustomField:V=!0,enableRowDragging:K=!1,handleColumnResizing:H=()=>{},columnSizes:U={},hideSaveButton:G=!1,hideDeleteButton:X,enableFirstRowEdit:J=!1,...Q})=>{const{t:Z}=w.useTranslation(),{formData:ee=null,updatePageInfo:te,activePage:ae}=ce.usePages(),le=ce.useDeepMemo(ae),{pageNo:re}=s,[ne,oe]=i.useState({}),[ie,se]=i.useState(l),[de,ue]=i.useState(null),[me,pe]=i.useState(!1),[he,xe]=i.useState(null),ge=ie.filter(e=>e.visible),ye=ie.filter(e=>!e.visible),[ve,fe]=i.useState(ye),[be,je]=i.useState(null),[we,Ce]=i.useState({}),[Se,Te]=i.useState([]),[Be,Re]=i.useState(!1),[Ee,Ie]=i.useState(!1),[Pe,Fe]=i.useState(!1),[$e,ze]=i.useState(null),[qe,Oe]=i.useState({}),[Ye,We]=i.useState(!1),[Ve,Ke]=i.useState([]),[He,Ue]=i.useState(!1),[Ge,Xe]=i.useState(le.column_sizes),[Je,Qe]=i.useState({columnSizingStart:[],deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,startOffset:null,startSize:null});i.useState(0);const Ze=W.useNavigate(),et=location.pathname.split("/")[2];let tt="";switch(et){case"accounting":tt=Ae.PathnameAccounting.CUSTOM_FORM;break;case"inventory":tt=Ae.PathnameInventory.CUSTOM_FORM;break;case"manufacturing":tt=Ae.PathnameManufacturing.CUSTOM_FORM;break;case"procurement":tt=Ae.PathnamePurchase.CUSTOM_FORM;break;case"crm":tt=Ae.PathnameCrm.CUSTOM_FORM;break;case"user":tt=Ne.PathnameUsers.CUSTOM_FORM;break;case"rental":tt=Ae.PathnameRental.CUSTOM_FORM;break;case"drive":tt=Me.PathnameDocument.ADD_CUSTOM_FIELDS}const at=`/dashboard/${et}${tt}`,lt=(e,t,a)=>{var l;let r=e;switch(t.type){case"required":t.value?(r=r.required(t.msg_en).typeError(t.msg_en),(null==a?void 0:a.editVariant)&&"text"!==(null==a?void 0:a.editVariant)||(r=r.test("no-blank-spaces","Blank space is not allowed",e=>"string"!=typeof e||e.trim().length>0))):(null==(l=null==a?void 0:a.editProperties)?void 0:l.is_multiple)&&(r=r.min(1,t.msg_en));break;case"notRequired":r=r.notRequired();break;case"nullable":r=r.nullable(t.value??!0);break;case"defined":r=r.defined(t.msg_en);break;case"optional":r=r.optional();break;case"strict":r=r.strict(t.value??!0);break;case"typeError":r=r.typeError(t.msg_en);break;case"oneOf":r=r.oneOf(t.values,t.msg_en);break;case"notOneOf":r=r.notOneOf(t.values,t.msg_en);break;case"default":r=r.default(t.value);break;case"transform":r=r.transform(t.fn);break;case"label":r=r.label(t.value);break;case"meta":r=r.meta(t.value);break;case"trim":r=r.trim();break;case"lowercase":r=r.lowercase();break;case"uppercase":r=r.uppercase();break;case"email":r=r.email(t.msg_en);break;case"url":r=r.url(t.msg_en);break;case"uuid":r=r.uuid(t.msg_en);break;case"length":r=r.length(t.value,t.msg_en);break;case"min":case"minItems":case"minDate":r=r.min(t.value,t.msg_en);break;case"max":case"maxItems":case"maxDate":r=r.max(t.value,t.msg_en);break;case"matches":r=r.matches(t.regex,t.msg_en);break;case"startsWith":r=r.matches(new RegExp(`^${t.value}`),t.msg_en);break;case"endsWith":r=r.matches(new RegExp(`${t.value}$`),t.msg_en);break;case"lessThan":r=r.lessThan(t.value,t.msg_en);break;case"moreThan":r=r.moreThan(t.value,t.msg_en);break;case"positive":r=r.positive(t.msg_en);break;case"negative":r=r.negative(t.msg_en);break;case"integer":r=r.integer(t.msg_en);break;case"round":r=r.round(t.method||"round");break;case"truncate":r=r.truncate();break;case"ensure":r=r.ensure();break;case"compact":r=r.compact(t.rejector);break;case"of":r=r.of(t.schema);break;case"shape":r=r.shape(t.fields);break;case"noUnknown":r=r.noUnknown(t.value??!0,t.msg_en);break;case"test":r=r.test(t.name||"custom-test",t.msg_en,t.testFn);break;case"when":return r.when(t.relation,{is:e=>"function"==typeof t.is?t.is(e):Array.isArray(t.values)?t.values.includes(e):e===t.values,then:e=>{var l;return(null==(l=null==t?void 0:t.thenValidations)?void 0:l.reduce((e,t)=>lt(e,t,a),e))||e},otherwise:e=>{var l;return(null==(l=null==t?void 0:t.otherWiseValidations)?void 0:l.reduce((e,t)=>lt(e,t,a),e))||e}})}return r};i.useEffect(()=>{se(l);const e=l.reduce((e,t)=>{var a;const l=null==(a=null==t?void 0:t.editProperties)?void 0:a.validations;if(!(null==l?void 0:l.length))return e;const r=(e=>{var t;switch(e.editVariant){case"select":return(null==(t=null==e?void 0:e.editProperties)?void 0:t.is_multiple)?Le.array():Le.string();case"number":return Le.number().nullable().transform((e,t)=>""===t?null:e);case"url":return Le.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 Le.string()}})(t);return e[t.accessorKey]=l.reduce((e,a)=>lt(e,a,t),r),e},{});Te(Le.object().shape(e))},[l]),i.useEffect(()=>{(null==Je?void 0:Je.isResizingColumn)||(te({column_sizes:{...le.column_sizes,...Ge}}),null==H||H(Ge))},[null==Je?void 0:Je.isResizingColumn,Ge]);const rt=e=>{ue(e.currentTarget)},nt=i.useCallback((e,t)=>{const a={};return(null==e?void 0:e["mrt-row-actions"])&&delete e["mrt-row-actions"],Object.keys(e).forEach(l=>{const r=e[l],n=t.find(e=>e.accessorKey==l);r?r instanceof File?a[l]=r.name:n&&"date"==(null==n?void 0:n.editVariant)?a[l]=p(r).format((null==n?void 0:n.dateFormat)||"DD-MM-YYYY"):n&&"select"==(null==n?void 0:n.editVariant)&&"object"==typeof r&&null!==r?a[l]=r.name||r.label||r.display_name||r.title||r.value||r.id||r:(n&&(null==n||n.editVariant),a[l]=r):a[l]=r}),a},[]),ot=i.useCallback(e=>{var t;return null==(t=null==e?void 0:e.validations)?void 0:t.some(e=>"required"===e.type)},[]);i.useEffect(()=>{const e={};!Ye&&z.length&&(a.forEach(t=>{z.includes(t.id)&&(e[t.id]=!0)}),Oe(e),We(!0))},[a,z]),i.useEffect(()=>{if(O instanceof Function){const e=Array.isArray(Ve)?Ve:[];O(e[0]||null)}},[Ve]);const it=e=>{const t=document.createElement("canvas").getContext("2d");return t?t.measureText(e).width+5:50},st=i.useCallback(async({row:e,values:t,table:a},l)=>{const r="edit"===l,n=r?Ie:Re;try{await Se.validate(t,{abortEarly:!1}),Ce({}),n(!0),Ue(!1);const l=e.getAllCells().map(e=>e.column.columnDef);e._valuesCache=nt(t,l);const o={row:e,values:t,table:a};r?(await(null==B?void 0:B(o,"edit")),a.setEditingRow(null)):(await(null==N?void 0:N(o)),a.setCreatingRow(null))}catch(o){o instanceof Le.ValidationError?Ce((e=>e.inner.reduce((e,{path:t,message:a})=>(t&&(e[t]=a),e),{}))(o)):k.enqueueSnackbar(o instanceof Error?o.message:"Something went wrong",{variant:"error"})}finally{n(!1)}},[Se,B,N,nt]),dt=i.useCallback(async e=>{try{return await Se.validate(e,{abortEarly:!1}),Ce({}),!0}catch(t){return!1}},[Se]),ct=i.useRef({}),ut=i.useCallback((e,t,a)=>{ct.current[e]={...ct.current[e]??{},[t]:a}},[]),mt=i.useCallback(e=>{delete ct.current[e]},[]),pt=i.useCallback(e=>({...e.original,...e._valuesCache,...ct.current[e.id]??{}}),[]),ht=i.useCallback(async e=>{const t=e.getState().editingRow,a=e.getState().creatingRow;if(!t)return;const l=pt(t);await dt(l)?(await st({row:t,values:l,table:e},"edit"),mt(t.id),!a&&I?(Ue(!1),setTimeout(()=>e.setCreatingRow(!0),200)):Ue(!1)):await st({row:t,values:l,table:e},"edit")},[pt,st,mt,dt,I]),xt=i.useCallback(async e=>{const t=e.getState().creatingRow;if(!t)return;const a=pt(t);(null==a?void 0:a["mrt-row-actions"])&&delete a["mrt-row-actions"];const l=await dt(a);await st({row:t,values:a,table:e},"create"),l&&l&&(Ue(!1),mt("mrt-row-create"),setTimeout(()=>e.setCreatingRow(!0),200))},[pt,mt,dt]),gt=ke.useMaterialReactTable({defaultColumn:{minSize:0,size:void 0},columns:[...ge.map(t=>(it(t.header||""),Math.max(...a.map(e=>it(String(e[t.accessorKey]??"")))),{...t,..."row"===E?{Edit:({cell:a,row:l,table:r,column:n})=>e.jsx(Ut,{cell:a,column:n,col:t,row:l,table:r,callback:e=>console.log("Save",e),errors:we,validationSchema:Se,setValidationErrors:Ce,onChangeRowField:P,getSelectedData:(e,t)=>null==L?void 0:L(e,t),syncFieldValue:ut})}:{},Header:e.jsxs(u.Box,{display:"flex",alignItems:"center",children:[t.header,(null==t?void 0:t.required)||ot(null==t?void 0:t.editProperties)&&e.jsx(h.Typography,{type:"s5",color:"theme.error.600",children:"*"})]}),enableColumnDragging:"actions"!==t.id,size:void 0,maxSize:800})),...j?[]:[{id:"actions",enableEditing:!1,size:(null==T?void 0:T.length)>1?80:50,header:e.jsx(u.IconButton,{size:"small",sx:{p:.5,"&:hover":{backgroundColor:"transparent"}},onClick:rt,children:e.jsx("img",{src:d.images.common.arrowIcon,alt:"Arrow Icon"})}),enableColumnDragging:!1,visible:!0,muiTableHeadCellProps:{className:"pinned-column"},muiTableBodyCellProps:{className:"pinned-column",sx:{whiteSpace:"pre-wrap"}},Cell:t=>(null==T?void 0:T.length)?T.map(e=>{const a={...e.props,onClick:()=>e.props.onClick(t)};return i.cloneElement(e,a)}):!Y&&e.jsx(u.IconButton,{onClick:e=>{return a=e,l=t.row.original,oe(l),void xe(a.currentTarget);var a,l},disabled:!(null==f?void 0:f.length)&&!(null==b?void 0:b.length),children:e.jsx("img",{src:d.images.more,alt:"More Icon"})})}]],data:a,muiTablePaperProps:{sx:{tableLayout:"auto"}},columnResizeMode:"onChange",onEditingRowSave:async e=>{await st(e,"edit")},onCreatingRowSave:async e=>{await st(e,"create")},onCreatingRowCancel:()=>(Oe({}),void Ue(!1)),onEditingRowCancel:()=>{Ue(!1)},onSortingChange:(null==v?void 0:v.sorting)?O:Ke,displayColumnDefOptions:{"mrt-row-actions":{Header:e.jsx(u.IconButton,{onClick:rt,size:"small",children:e.jsx("img",{src:d.images.common.arrowIcon,alt:"Arrow Icon"})}),muiTableBodyCellProps:({row:e,table:t})=>{var a,l;const r=(null==(a=t.getState().creatingRow)?void 0:a.id)===e.id,n=(null==(l=t.getState().editingRow)?void 0:l.id)===e.id;return{sx:{"& .MuiBox-root":{gap:0},backgroundColor:"#fff",whiteSpace:"pre-wrap",...G&&(n||r)?{"& .MuiBox-root > .MuiIconButton-root:first-of-type":{display:"none !important"},'& button[aria-label*="Save"]':{display:"none !important"},'& button[title*="Save"]':{display:"none !important"},'& .MuiIconButton-root[class*="save"]':{display:"none !important"},'& .MuiIconButton-root[data-testid*="save"]':{display:"none !important"}}:{}}}}},"mrt-row-expand":{size:70},"mrt-row-select":{size:50}},renderRowActions:({row:t,table:a})=>e.jsx(e.Fragment,{children:(null==Q?void 0:Q.enableExpanding)?e.jsx(e.Fragment,{children:(null==t?void 0:t.parentId)&&e.jsx(u.Box,{sx:{display:"flex",gap:0},children:R&&!(null==X?void 0:X(t.original))&&e.jsx(o.Tooltip,{title:"Delete",children:e.jsx(u.IconButton,{disabled:He,onClick:()=>ze(t),size:"small",className:"delete-row",children:e.jsx(_.Trash,{fontSize:"small",sx:{color:"theme.secondary.1000"}})})})})}):e.jsx(u.Box,{sx:{display:"flex",gap:0},children:R&&!(null==X?void 0:X(t.original))&&e.jsx(o.Tooltip,{title:"Delete",children:e.jsx(u.IconButton,{disabled:He,onClick:()=>ze(t),className:"delete-row",children:e.jsx(_.Trash,{fontSize:"small",sx:{color:"theme.secondary.1000"}})})})})}),...Boolean(I)&&{renderBottomToolbarCustomActions:({table:t})=>e.jsx(o.Button,{variant:"outlined",startIcon:e.jsx(r,{}),className:"add-row-btn",disabled:He,onClick:()=>{t.setCreatingRow(!0),Ue(!0)},children:Z("common.add")})},onRowSelectionChange:Oe,enableColumnOrdering:!0,enableRowSelection:C??!0,enableEditing:e=>g instanceof Function?g(e):g??!0,editDisplayMode:E??"row",createDisplayMode:"row",positionCreatingRow:"bottom",enableColumnResizing:$,enableRowDragging:K,enableTopToolbar:!1,enableColumnActions:!1,enableSorting:!0,enableGrouping:!0,enableBottomToolbar:D??!1,enableColumnDragging:y??!0,enableStickyHeader:!0,enableSortingRemoval:!1,state:{columnOrder:c,columnPinning:{left:["actions","mrt-row-actions"]},isSaving:Be||Ee,showProgressBars:!1,rowSelection:qe,...v,sorting:Array.isArray(null==v?void 0:v.sorting)?null==v?void 0:v.sorting:Array.isArray(Ve)?Ve:[],columnSizing:Ge},getRowId:e=>null==e?void 0:e.id,muiTableBodyRowProps:({row:e,table:t})=>{var a,l,r,n,o,i,s;const d=(null==(l=null==(a=t.getState())?void 0:a.editingRow)?void 0:l.id)||(null==(n=null==(r=t.getState())?void 0:r.creatingRow)?void 0:n.id)||null;null==(i=null==(o=t.getState())?void 0:o.creatingRow)||i.id;const c=Boolean(null==(s=null==e?void 0:e.original)?void 0:s.has_error);return{onClick:()=>{je(e.id)},sx:{cursor:"pointer",backgroundColor:d?"inherit":c?"theme.error.100":"inherit","&:hover":{backgroundColor:d?d===e.id?"transparent":"inherit":c?"theme.error.200":"#e8e8e8"},"&:hover td:after":{backgroundColor:"transparent"}}}},onColumnOrderChange:e=>{x&&x(e)},onColumnSizingChange:Xe,onColumnSizingInfoChange:Qe,renderEmptyRowsFallback:()=>e.jsxs(u.Box,{className:"no-data",children:[e.jsx("img",{src:d.images.common.tableNoData}),e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:Z("common.noData")})]}),enablePagination:t,paginationDisplayMode:"pages",muiPaginationProps:{shape:"rounded",page:re,count:n,showRowsPerPage:!1,boundaryCount:3},muiEditTextFieldProps:({row:e,column:t})=>({InputProps:{disableUnderline:!0},onBlur:a=>{m(a.target.value,t,e.id)},variant:"outlined",sx:({palette:e})=>{var t;return{"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:`${null==(t=e.theme)?void 0:t.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:({cell:e,column:t,table:a,row:l})=>({sx:{lineHeight:"140%",letterSpacing:"-0.26px",fontWeight:"400",fontSize:"0.8125rem","&.pinned-column":{backgroundColor:"#fff"},"&:hover":{backgroundColor:"transparent"},whiteSpace:"pre-wrap"},onClick:e=>{var r,n,o,i;const s=e.target.closest(".MuiTableCell-body");if(!s||s.querySelector(".delete-row"))return;if(!1===t.columnDef.isOnClickEditable)return;const d=(null==(n=null==(r=a.getState())?void 0:r.editingRow)?void 0:n.id)||(null==(i=null==(o=a.getState())?void 0:o.creatingRow)?void 0:i.id)||null,c=d===l.id;d&&d!==l.id||He||c||d||(a.setEditingRow(l),Ue(!0))},onKeyUp:e=>{var t;const r=(null==(t=a.getState().creatingRow)?void 0:t.id)??null;if("Escape"===e.key){if(r===l.id)mt("mrt-row-create"),a.setCreatingRow(null);else{const e=a.getState().editingRow;e&&(st({row:e,values:e.original,table:a},"edit"),mt(e.id))}return Ue(!1),Ce({}),e.preventDefault(),void e.stopPropagation()}"Enter"===e.key&&setTimeout(()=>{const e=a.getState().creatingRow,t=a.getState().editingRow;e&&xt(a),t&&ht(a)},0)}}),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(_.RecgtangleIcon,{sx:{width:20,height:20}}),checkedIcon:e.jsx(_.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(_.RecgtangleIcon,{sx:{width:20,height:20}}),checkedIcon:e.jsx(_.CheckBoxIcon,{sx:{width:20,height:20}})},muiBottomToolbarProps:{sx:{boxShadow:"none","& .MuiBox-root":{paddingLeft:0}}},layoutMode:"grid",icons:{DragHandleIcon:()=>e.jsx(_.RecgtangleIcon,{fontSize:"medium"}),SortIcon:()=>e.jsx(_.ArrowUpDown,{fontSize:"medium"}),ArrowDownwardIcon:()=>e.jsx(_.ArrowUpDown,{fontSize:"medium"}),ArrowUpwardIcon:()=>e.jsx(_.ArrowUpDown,{fontSize:"medium"}),ExpandMoreIcon:()=>e.jsx(_.ArrowUpDown,{fontSize:"medium"}),ExpandLessIcon:()=>e.jsx(_.ArrowUpDown,{fontSize:"medium"}),SyncAltIcon:()=>e.jsx(_.ArrowUpDown,{fontSize:"medium"}),CancelIcon:t=>e.jsx(_.Close,{fontSize:"small",...t,color:"theme.secondary.1000"})},...Q});i.useEffect(()=>{var e,t;C&&(null==(e=null==gt?void 0:gt.getSelectedRowModel())?void 0:e.rows)&&(null==M||M(null==(t=null==gt?void 0:gt.getSelectedRowModel())?void 0:t.rows))},[C]),i.useEffect(()=>{if(F)if(null==Q?void 0:Q.enableExpanding){const e=[],t=gt.getState().rowSelection,a=(l,r="")=>{l.forEach((l,n)=>{var o;const i=r?`${r}.${n}`:`${l.id}`;t[i]&&e.push(l),(null==(o=l.subRows)?void 0:o.length)&&a(l.subRows,i)})};a(gt.getRowModel().rows),F(e,qe)}else F(gt.getSelectedRowModel().rows,qe)},[qe,gt]),i.useEffect(()=>{A&&(null==gt||gt.resetRowSelection())},[A,gt]);const yt=i.useRef(!1);return i.useEffect(()=>{if(J&&!yt.current&&(null==a?void 0:a.length)>0){const e=gt.getRowModel().rows[0];e&&(yt.current=!0,e._valuesCache&&0!==Object.keys(e._valuesCache).length||(e._valuesCache={...e.original}),gt.setEditingRow(e),Ue(!0))}},[J,a,gt]),i.useEffect(()=>{if(!gt)return;let e,t,a=0,l=!1;const r=r=>{r.target.closest('.MuiSelect-root, .MuiMenuItem-root, .MuiPopover-root, .MuiList-root, .MuiMenu-list, .MuiButtonBase-root, .MuiFormControl-root, .MuiInputBase-root, .MuiTextField-root, .MuiOutlinedInput-root, .MuiFilledInput-root, .MuiAutocomplete-popper, .MuiPickersPopper-root, [role="option"], [role="listbox"], [role="combobox"]')&&(l=!0,a=Date.now(),t&&clearTimeout(t),e&&clearTimeout(e),e=setTimeout(()=>{l=!1},500))},n=e=>{var r,n;const o=null==(r=gt.getState())?void 0:r.editingRow,i=null==(n=gt.getState())?void 0:n.creatingRow;if(!o&&!i)return;const s=e.target,d=Date.now();l||d-a<300||s.closest(".MRT-TableWrapper")||(t&&clearTimeout(t),t=setTimeout(async()=>{var e,t;const a=null==(e=gt.getState())?void 0:e.editingRow,r=null==(t=gt.getState())?void 0:t.creatingRow;if(!l){if(r){const e=pt(r);return await st({row:r,values:e,table:gt},"create"),mt("mrt-row-create"),void Ue(!1)}if(a){const e=pt(a);await st({row:a,values:e,table:gt},"edit"),mt(a.id),Ue(!1)}}},200))};return document.addEventListener("mousedown",r,!0),document.addEventListener("click",n,!0),()=>{document.removeEventListener("mousedown",r,!0),document.removeEventListener("click",n,!0),e&&clearTimeout(e),t&&clearTimeout(t)}},[gt,st,pt,mt]),e.jsxs(Gt,{className:"MRT-TableWrapper custom-table",children:[e.jsx(ke.MaterialReactTable,{table:gt}),e.jsx(S.Menu,{anchorEl:de,open:Boolean(de),onClose:()=>{ue(null)},className:"add-role-drp",children:me?e.jsxs("div",{children:[e.jsxs(u.MenuItem,{onClick:()=>{pe(!1)},className:"role-drp-list add-column-title",children:[e.jsx(u.ListItemIcon,{className:"add-icon",children:e.jsx(De,{})}),e.jsx(u.ListItemText,{className:"title",children:Z("common.addColumn_label")})]}),e.jsx(u.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),e.jsx("div",{className:"searchbar-box-list",children:e.jsx(o.SearchBar,{placeholder:"Search User",handleSearch:e=>(e=>{const t=ye.filter(t=>t.header.toLowerCase().includes(e.toLowerCase()));fe(t)})(e)})}),e.jsx("div",{className:"all-attribute-title",children:e.jsx(h.Typography,{variant:"body2",color:"text.secondary",children:Z("common.allAttributes_label")})}),ve.map(t=>e.jsx(u.MenuItem,{onClick:()=>(e=>{const t=ie.map(t=>({...t,visible:t.accessorKey===e.accessorKey||t.visible}));null==q||q(JSON.parse(JSON.stringify(t))),se(t);const a=ve.filter(t=>t.accessorKey!==e.accessorKey);fe(a),ue(null),pe(!1)})(t),children:e.jsx(h.Typography,{color:"theme.secondary.1000",type:"s3",children:t.header})},t.accessorKey)),e.jsx(u.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),V&&e.jsxs(u.MenuItem,{onClick:()=>{Ze(at,{state:ee}),ue(null),pe(!1)},className:"role-drp-list",children:[e.jsx(u.ListItemIcon,{className:"add-icon",children:e.jsx("img",{src:d.images.common.addIcon,alt:"Add Icon"})}),e.jsx(u.ListItemText,{className:"title",children:Z("common.addCustomField_label")})]})]}):e.jsxs(e.Fragment,{children:[ge.map(t=>e.jsxs(u.MenuItem,{onClick:()=>(e=>{const t=ie.map(t=>({...t,visible:t.accessorKey!==e.accessorKey&&t.visible}));se(t),null==q||q(JSON.parse(JSON.stringify(t))),fe([...ve,e]),ue(null)})(t),className:"role-drp-list",children:[e.jsx(u.ListItemIcon,{className:"add-icon",children:e.jsx("img",{src:d.images.common.dotsIcon,alt:"Add Icon"})}),e.jsx(u.ListItemText,{className:"title",children:t.header}),e.jsx(u.ListItemIcon,{className:"eye-icon",children:e.jsx("img",{src:d.images.common.eyeIcon,alt:"Eye Icon"})})]},t.accessorKey)),e.jsx(u.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),e.jsxs(u.MenuItem,{onClick:()=>{pe(!0)},className:"role-drp-list",children:[e.jsx(u.ListItemIcon,{className:"add-icon",children:e.jsx("img",{src:d.images.common.addIcon,alt:"Add Icon"})}),e.jsx(u.ListItemText,{className:"title",children:Z("common.addColumn_label")}),e.jsx(h.Typography,{variant:"body2",color:"text.secondary",className:"eye-icon",children:e.jsx(_e,{sx:{fontSize:"1.25rem !important"}})})]})]})}),e.jsxs(S.Menu,{anchorEl:he,open:Boolean(he),onClose:()=>{xe(null)},children:[null==f?void 0:f.map(t=>e.jsxs(u.MenuItem,{onClick:async()=>{await t.handleAction(ne),xe(null)},disabled:"function"==typeof t.disabled?t.disabled(ne):Boolean(t.disabled),sx:{alignItems:"center",gap:.5},children:[null==t?void 0:t.icon,e.jsx(h.Typography,{type:"s4",color:"inherit",children:"function"==typeof t.label?t.label(ne):t.label})]})),(null==b?void 0:b.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx(u.Divider,{flexItem:!0,sx:{mt:"0.25rem !important",mb:"0.25rem !important"}}),e.jsx("div",{className:"dropdown-inner--DestructiveHeader",children:null==b?void 0:b.map(t=>e.jsx(u.MenuItem,{onClick:()=>{t.handleAction(ne),xe(null)},className:"dropdown-inner--DestructiveActions",disabled:"function"==typeof t.disabled?t.disabled(ne):Boolean(t.disabled),children:e.jsx(h.Typography,{type:"s4",color:"inherit",children:"function"==typeof t.label?t.label(ne):t.label})}))})]})]}),e.jsx(o.ConfirmPopUp,{open:Boolean($e),onClose:()=>ze(null),onConfirm:()=>(async()=>{Fe(!0),$e&&(await(null==R?void 0:R($e)),ze(null)),Fe(!1)})(),title:"Delete Item",description:"Are you sure you want to delete entry ?",loading:Pe})]})});function Jt(e,t){e.each(function(){const e=Ye.select(this),a=e.text();if(a.length<=8)return;if(a.length>12)return void e.text(a.substring(0,10)+"...");const l=a.split(/\s+/).reverse();let r,n=[],o=0;const i=e.attr("y"),s=parseFloat(e.attr("dy"))||0;let d=e.text(null).append("tspan").attr("x",0).attr("y",i).attr("dy",`${s}em`);for(;r=l.pop();)n.push(r),d.text(n.join(" ")),d.node()&&d.node().getComputedTextLength()>t&&(n.pop(),d.text(n.join(" ")),n=[r],d=e.append("tspan").attr("x",0).attr("y",i).attr("dy",`${1.1*++o+s}em`).text(r))})}const Qt=["#5BCE97","#B3D8E2","#F5F6F5","#AE6B9E","#CBD49A","#EEE0B3"],Zt=(e,t="")=>e>=1e6?`${t} ${(e/1e6).toFixed(1)} M`:e>=1e5?`${t} ${(e/1e5).toFixed(1)} L`:e>=1e3?`${(e/1e3).toFixed(1)} K`:`${t} ${e.toFixed(2)}`,ea=t=>e.jsx(Re,{sx:{width:"16.625rem",borderRadius:"0.5rem",border:"0.5px solid theme.secondary.200, #F5F6F5",backgroundColor:"theme.secondary.100",boxShadow:"\n 0px 0px 2px 0px #E0E0E0, \n 0px 1px 4px - 2px rgba(24, 39, 75, 0.02), \n 0px 4px 4px - 2px rgba(24, 39, 75, 0.06)",m:3},children:e.jsxs(Ee,{sx:{display:"flex",flexDirection:"column",padding:"1rem 1rem 1.25rem 1rem",justifyContent:"space-between",alignItems:"flex-start",flexShrink:0},children:[e.jsxs(O,{sx:{display:"flex",width:"100%",justifyContent:"space-between",marginBottom:1},children:[e.jsxs(O,{children:[e.jsx(h.Typography,{type:"s3",weight:"medium",children:t.data.name||"Kristin Watson"}),e.jsx(h.Typography,{type:"s3",color:"theme.secondary.800",children:t.data.company||"Barone LLC."})]}),e.jsx(O,{children:e.jsx(h.Typography,{type:"s4",sx:{padding:"0.25rem 0.375rem",gap:"0.5rem",borderRadius:"0.5rem",backgroundColor:"theme.secondary.200"},color:"theme.secondary.900",children:t.data.status||"Lost"})})]}),e.jsx(h.Typography,{type:"s3",sx:{overflow:"hidden",color:"theme.secondary.900",textDecorationLine:"underline"},children:t.data.email||"kristen.watson@example.com"}),e.jsxs(O,{sx:{mt:"1.25rem",display:"flex",alignItems:"center"},children:[e.jsx(h.Typography,{type:"s3",sx:{mr:".2rem"},color:"theme.secondary.900",children:t.data.amount||"$10,000,000"}),e.jsx(h.Typography,{type:"s4",color:"theme.secondary.800",children:"est value"})]})]})}),ta=t=>{const{children:a,data:l,isLoading:r}=t;return e.jsx(e.Fragment,{children:r?e.jsx(V.ErpLoader,{}):e.jsx(e.Fragment,{children:(null==l?void 0:l.length)?e.jsx("div",{className:"grid-wrapper",children:a}):e.jsxs(u.Box,{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",children:[e.jsx("img",{src:d.images.common.tableNoData}),e.jsx(h.Typography,{color:"theme.secondary.1000",weight:"medium",align:"center",children:"No data"})]})})})},aa=({data:t,config:a})=>{const l=W.useNavigate(),r=location.pathname.split("/")[2],n=`/dashboard/${r}${((null==a?void 0:a[r])||{redirectionPath:""}).redirectionPath}`,o=e=>{l(n,{state:{form:e}})},i=e=>{var t,a;return null==(a=null==(t=null==e?void 0:e.split("_"))?void 0:t.map(e=>(null==e?void 0:e.charAt(0).toUpperCase())+(null==e?void 0:e.slice(1).toLowerCase())))?void 0:a.join(" ")};return e.jsx(ta,{data:t,children:t.map((t,a)=>{var l;return e.jsxs(bt,{children:[e.jsx("div",{className:"gridView--CardHeader",children:e.jsx("div",{className:"gridView--redirection",onClick:()=>o(t),children:e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.900",children:i(null==t?void 0:t.name)})})}),e.jsxs("div",{className:"gridView--redirection",onClick:()=>o(t),children:[e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.900",children:(null==(l=null==t?void 0:t.fields)?void 0:l.filter(e=>!e.is_system_field).length)||0}),(null==t?void 0:t.description)&&e.jsx(h.Typography,{type:"s4",weight:"medium",color:"inherit",children:i(null==t?void 0:t.description)}),e.jsx("div",{className:"gridView--CardBottom",children:e.jsx(h.Typography,{type:"s5",color:"theme.secondary.600",children:j.createdOnAndBy(t)})})]})]},(null==t?void 0:t._id)||a)})})},la=["name","fields","noOfCustomFields","customFields"],ra=[{label:"Table",position:0}];function na({rowData:t,level:a=0,tableHeaders:l,totalHeaders:r,headers:n,collapsAll:o=!1,collapsLevel:s=0,isIncrese:d,data:c,rowPath:m,selectedRowPaths:p,onCheckboxChange:x,enableCheckBox:g,rowHeight:y,columnWidths:v={}}){var f,b,j,C,T;const[k,_]=i.useState(!1),{t:D}=w.useTranslation();i.useEffect(()=>{d&&s>a&&_(!0),!d&&s<=a+2&&_(!1)},[s,a,d]);const M=()=>{_(e=>!e)};function A(e,t){if(""==(null==t?void 0:t.name))return"";const a=(null==t?void 0:t.name.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e))||("0"==(null==t?void 0:t.name.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e))?"0":"-");return S.formateValueByType({value:a,...t})}const N=p.some(e=>e.length===m.length&&e.every((e,t)=>e===m[t]));return e.jsxs(e.Fragment,{children:[e.jsxs(u.TableRow,{sx:{cursor:"pointer",height:y,overflow:"hidden","&:not(:last-child) td":{},"&:last-child td":{borderBottom:"none",borderBottomColor:"divider",borderTop:"0"}},children:[(null==(f=l[a])?void 0:f.enableCheckbox)&&e.jsx(u.TableCell,{className:"dynamic-report-row",sx:{paddingLeft:"8px",wordWrap:"break-word",width:"60px",minWidth:"60px",maxWidth:"60px",overflow:"hidden"},children:e.jsx(Fe,{checked:N,onChange:e=>x(m,e.target.checked),onClick:e=>e.stopPropagation()})}),l[a].headers.map((r,o)=>{if(r.joinWithLeft)return null;const i=l[a].headers.slice(o+1).findIndex(e=>!e.joinWithLeft),s=-1===i?l[a].headers.slice(o+1).length+1:i+1,d=r.mergeCells?s:1;let m=0;for(let e=o;e<o+d&&e<n.length;e++)m+=(v[D(n[e].label)]>100?v[D(n[e].label)]:100)||100;const p=!(null==r?void 0:r.showData)||(null==r?void 0:r.showData(k));return e.jsx(u.TableCell,{className:"dynamic-report-row",colSpan:d,sx:{paddingLeft:0===o?"8px":"16px",wordWrap:"break-word",width:`${m}px`,minWidth:`${m}px`,maxWidth:`${m}px`,height:y,overflow:"hidden"},children:p&&(null==r?void 0:r.isCollaps)?e.jsxs(u.Box,{onClick:M,sx:{paddingLeft:a>o&&0===o?2*a:0,display:"flex",alignItems:"center",justifyContent:(null==r?void 0:r.position)?null==r?void 0:r.position:"start",width:"100%",height:y,overflow:"hidden"},children:[e.jsx(u.IconButton,{size:"small",sx:{p:0},children:k?e.jsx(Pe,{sx:{fontSize:"20px"}}):e.jsx(Ie,{sx:{fontSize:"20px"}})}),(null==r?void 0:r.render)?r.render(A(t,r),t,c):e.jsx(h.Typography,{type:"s4",weight:"medium",color:"theme.neutral.1000",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A(t,r)})]}):p&&e.jsx(u.Box,{sx:{paddingLeft:a>o&&0===o?2*a:0,display:"flex",alignItems:"center",justifyContent:(null==r?void 0:r.position)?null==r?void 0:r.position:"start",width:"100%",height:y,overflow:"hidden"},children:(null==r?void 0:r.render)?r.render(A(t,r),t,c):e.jsx(h.Typography,{type:"s4",weight:"normal",color:"theme.neutral.800",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A(t,r)})})},o)})]}),Array.isArray(t[null==(b=l[a+1])?void 0:b.rowKey])&&e.jsx(u.TableRow,{sx:{},children:e.jsx(u.TableCell,{sx:{border:"0 !important",borderBottom:"0 !important"},style:{padding:0},colSpan:l[a].headers.filter(e=>!e.joinWithLeft).length+(g?1:0),children:e.jsxs(u.Collapse,{in:k,timeout:"auto",unmountOnExit:!0,children:[null==(C=t[null==(j=l[a+1])?void 0:j.rowKey])?void 0:C.map((t,i,u)=>e.jsx(na,{rowData:t,level:a+1,tableHeaders:l,headers:n,collapsAll:o,collapsLevel:s,isIncrese:d,totalHeaders:r,data:c,rowPath:[...m,i],selectedRowPaths:p,onCheckboxChange:x,dataSlice:u,dataIndex:i,enableCheckBox:g,rowHeight:y,columnWidths:v},t.id||[...m,i].join("-"))),(null==t?void 0:t.total)&&Object.keys(null==t?void 0:t.total).length>0&&r&&e.jsxs(u.TableRow,{sx:{backgroundColor:(null==(T=null==r?void 0:r[0])?void 0:T.bgColor)||"#FAFAFA"},children:[g&&e.jsx(u.TableCell,{sx:{width:"60px",minWidth:"60px",maxWidth:"60px"}}),r.map((l,o)=>{var i;if(l.joinWithLeft)return null;const s=-1===r.slice(o+1).findIndex(e=>!e.joinWithLeft&&e!==l)?(null==(i=r.slice(o+1))?void 0:i.length)+1:r.slice(o+1).findIndex(e=>!e.joinWithLeft&&e!==l)+1,d=l.mergeCells?s:1;let c=0;for(let e=o;e<o+d&&e<n.length;e++)c+=v[D(n[e].label)]||100;return e.jsx(u.TableCell,{className:"dynamic-report-row",colSpan:d,sx:{paddingLeft:0===o?24*a+"px":"16px",width:`${c}px`,minWidth:`${c}px`,maxWidth:`${c}px`},children:e.jsx(u.Box,{sx:{display:"flex",alignItems:"center",justifyContent:(null==l?void 0:l.position)||"start",width:"100%"},children:(null==l?void 0:l.render)?null==l?void 0:l.render(A(t,l),t):e.jsx(h.Typography,{type:"s4",weight:"bold",color:"theme.neutral.1000",children:A(null==t?void 0:t.total,l)})})},o)})]})]})})})]})}const oa={fontSize:"14px",fontFamily:$e.primaryFont,fontWeight:"500"};let ia=null;function sa(){if(ia)return ia;try{const e=document.createElement("canvas");return ia=e.getContext("2d"),ia}catch(e){return console.warn("Canvas context creation failed, falling back to DOM measurement:",e),null}}function da(e,t=oa){if(!e||0===e.length)return 0;const a=String(e);return sa()?function(e,t){const a=sa();return a?(a.font=`${t.fontWeight} ${t.fontSize} ${t.fontFamily}`,a.measureText(e).width):(console.warn("Canvas context not available, returning 0"),0)}(a,t):function(e,t){try{const a=document.createElement("span");a.style.position="absolute",a.style.visibility="hidden",a.style.whiteSpace="nowrap",a.style.fontSize=t.fontSize,a.style.fontFamily=t.fontFamily,a.style.fontWeight=String(t.fontWeight),a.textContent=e,document.body.appendChild(a);const l=a.offsetWidth;return document.body.removeChild(a),l}catch(a){return console.warn("DOM measurement failed:",a),8*e.length}}(a,t)}function ca(e,t){if(null==e)return"-";if("date"===t||e instanceof Date)try{return new Date(e).toLocaleDateString()}catch{return String(e)}if("number"===t||"number"==typeof e)return String(e);if("object"==typeof e)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}const ua={amount:{format:j.toFixedWithNumbers},date:{format:j.formatDate},string:{format:e=>e},toFixed:{format:e=>j.toFixedWithNumbers(e)}};function ma(e,t){var a;const l=(null==t?void 0:t.type)||"string";if(!(null==t?void 0:t.name)||""===(null==t?void 0:t.name))return"";const r=null==t?void 0:t.name.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e);return 0===r||"0"===r?"0":void 0!==r?null==(a=ua[l])?void 0:a.format(r):"-"}const pa=q.styled(u.CircularProgress)(({theme:e})=>{var t;return{color:null==(t=e.palette)?void 0:t.theme.primary[500]}}),ha=q.styled(u.Box)(()=>({position:"fixed",display:"flex",width:"100%",height:"100%",justifyContent:"center",alignItems:"center",backgroundColor:"#ffffff96",zIndex:1,left:0,top:0})),xa=q.styled(u.CircularProgress)(({theme:e})=>{var t;return{color:null==(t=e.palette)?void 0:t.theme.primary[500]}}),ga=[{name:"null",label:"is null"},{name:"notNull",label:"is not null"}],ya=[{name:"contains",label:"contains"},{name:"beginsWith",label:"begins with"},{name:"endsWith",label:"ends with"},{name:"doesNotContain",label:"does not contain"},{name:"doesNotBeginWith",label:"does not begin with"},{name:"doesNotEndWith",label:"does not end with"},...ga],va=[{name:"=",label:"equal to"},{name:"<",label:"less than"},{name:"<=",label:"less than or equal to"},{name:">",label:"greater than"},{name:">=",label:"greater than or equal to"},...ga],fa=[{name:"in",label:"in"},{name:"notIn",label:"not in"},...ga],ba=[{name:"Select",label:"Select",valueEditorType:"select",operators:fa,values:[{name:"Select",label:"Select"}]},{name:"role",label:"Role",inputType:"text",valueEditorType:"text",operators:ya,comparator:"datatype"},{name:"status",label:"Status",valueEditorType:"select",operators:fa,comparator:"datatype",values:[{name:"Select",label:"Select"},{name:"enable",label:"Enable"},{name:"disabled",label:"Disabled"}]},{name:"roleType",label:"Role Type",valueEditorType:"select",operators:fa,comparator:"datatype",values:[{name:"Select",label:"Select"},{name:"admin",label:"Admin"},{name:"manager",label:"Manager"},{name:"executive",label:"Executive"},{name:"support",label:"Support"}]},{name:"roleLevel",label:"Role level",valueEditorType:"text",operators:va,comparator:"datatype"},{name:"dateCreated",label:"Date Created",operators:[{name:"=",label:"on"},{name:"!=",label:"not on"},{name:"<",label:"before"},{name:"<=",label:"on or before"},{name:">",label:"after"},{name:">=",label:"on or after"},...ga],datatype:"date",inputType:"date"},{name:"companyName",label:"Company Name",valueEditorType:"text",operators:ya,comparator:"datatype"},{name:"location",label:"Location",valueEditorType:"text",operators:ya,comparator:"datatype"},{name:"email",label:"Email",valueEditorType:"text",operators:ya,comparator:"datatype"}],ja=[{name:"document",label:"Document",inputType:"text",valueEditorType:"text",operators:ya,comparator:"datatype"},{name:"filesize",label:"File size",valueEditorType:"text",operators:va,comparator:"datatype"},{name:"owner",label:"Owner",valueEditorType:"text",operators:ya,comparator:"datatype"}];function wa({chart:t,currency:a}){const l=i.useRef(null),r=i.useRef(null),n=i.useRef(null),o=i.useMemo(()=>(null==t?void 0:t.labels)?t.labels.map((e,a)=>{var l,r,n;return{name:e,value:(null==(n=null==(r=null==(l=t.datasets)?void 0:l[0])?void 0:r.values)?void 0:n[a])||0}}):[],[t]),s=a||(null==t?void 0:t.currency)||"AED",d=i.useMemo(()=>Math.max(...o.map(e=>Math.abs(e.value))),[o]),c=i.useMemo(()=>o.some(e=>e.value<0),[o]),u=c?100:90,m=Math.max(42*o.length+70,230),p={top:15,right:90,bottom:20,left:u};return i.useEffect(()=>{var e;if(!l.current||!o.length)return;const t=Ye.select(l.current);t.selectAll("*").remove();const a=(null==(e=l.current.parentElement)?void 0:e.clientWidth)||300,r=Math.max(a-20,200)-p.left-p.right,i=m-p.top-p.bottom,u=1.15*d,h=Ye.scaleLinear().domain([c?-u:0,u]).range([0,r]),x=Ye.scaleBand().domain(o.map(e=>e.name)).range([0,i]).padding(.35),g=t.append("g").attr("transform",`translate(${p.left},${p.top})`);c&&g.append("line").attr("x1",h(0)).attr("x2",h(0)).attr("y1",0).attr("y2",i).attr("stroke","#9CA3AF").attr("stroke-width",1);const y=h.ticks(5).filter(e=>0!==e);g.selectAll(".grid-line").data(y).enter().append("line").attr("x1",e=>h(e)).attr("x2",e=>h(e)).attr("y1",0).attr("y2",i).attr("stroke","#E5E7EB").attr("stroke-dasharray","3,3"),g.selectAll(".x-tick").data(y).enter().append("text").attr("x",e=>h(e)).attr("y",i+16).attr("text-anchor","middle").attr("font-size","10px").attr("fill","#6B7280").text(e=>(e=>{const t=Math.abs(e);return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)})(e)),g.selectAll(".bar").data(o).enter().append("rect").attr("x",e=>e.value>=0?h(0):h(e.value)).attr("y",e=>x(e.name)||0).attr("width",e=>Math.abs(h(e.value)-h(0))).attr("height",x.bandwidth()).attr("fill",e=>e.value>=0?"#4AC08C":"#E85D3A").attr("rx",3).style("cursor","pointer").on("mouseenter",function(e,t){Ye.select(this).attr("fill",e=>e.value>=0?"#3AA87A":"#D14529"),n.current&&(n.current.style.opacity="1",n.current.innerHTML=`<strong>${t.name}</strong><br/>${((e,t)=>{const a=Math.abs(e)>=1e6?"M":Math.abs(e)>=1e3?"K":"",l=Math.abs(e),r=l>=1e6?(l/1e6).toFixed(1):l>=1e3?(l/1e3).toFixed(1):String(l);return`${e<0?`-${r}${a}`:`${r}${a}`} ${t}`})(t.value,s)}`,n.current.style.left=`${e.offsetX+15}px`,n.current.style.top=e.offsetY-10+"px")}).on("mouseleave",function(e,t){Ye.select(this).attr("fill",e=>e.value>=0?"#4AC08C":"#E85D3A"),n.current&&(n.current.style.opacity="0")}),g.selectAll(".value-label").data(o).enter().append("text").attr("x",e=>e.value>=0?h(e.value)+6:h(0)+6).attr("y",e=>(x(e.name)||0)+x.bandwidth()/2).attr("dy","0.35em").attr("text-anchor","start").attr("font-size","9px").attr("font-weight","600").attr("fill","#374151").text(e=>(e=>{const t=Math.abs(e)>=1e6?"M":Math.abs(e)>=1e3?"K":"",a=Math.abs(e),l=a>=1e6?(a/1e6).toFixed(1):a>=1e3?(a/1e3).toFixed(1):String(a);return e<0?`-${l}${t}`:`${l}${t}`})(e.value));const v=g.append("g").attr("transform","translate(0,0)").call(Ye.axisLeft(x).tickSize(0).tickFormat(e=>{return(t=String(e)).length<=15?t:t.slice(0,13)+"…";var t}));v.selectAll("text").attr("font-size","10px").attr("fill","#6B7280"),v.selectAll(".domain").remove()},[o,s,d,c,90,u,m,p]),e.jsxs("div",{className:"ai-summary-panel__card",ref:r,children:[e.jsx("p",{className:"ai-summary-panel__card-title",children:(null==t?void 0:t.title)||""}),e.jsxs("div",{style:{position:"relative",overflow:"visible",height:m,width:"100%"},children:[e.jsx("svg",{ref:l,width:"100%",height:m,style:{display:"block"}}),e.jsx("div",{ref:n,style:{position:"absolute",backgroundColor:"white",padding:"8px 12px",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0,0,0,0.12)",fontSize:"11px",color:"#374151",opacity:0,transition:"opacity 0.15s",pointerEvents:"none",zIndex:10,border:"1px solid #E5E7EB",lineHeight:1.4}})]})]})}function Ca({chart:t,currency:a}){const l=i.useRef(null),r=i.useRef(null),n=i.useRef(null),o=i.useMemo(()=>(null==t?void 0:t.labels)?t.labels.map((e,a)=>{var l,r,n;return{name:e,value:(null==(n=null==(r=null==(l=t.datasets)?void 0:l[0])?void 0:r.values)?void 0:n[a])||0}}):[],[t]),s=a||(null==t?void 0:t.currency)||"AED",d=i.useMemo(()=>o.length<=6,[o]),c=Math.max(40*o.length+120,220),u=i.useMemo(()=>Math.max(...o.map(e=>Math.abs(e.value))),[o]);return i.useEffect(()=>{var e;if(!l.current||!o.length)return;const t=Ye.select(l.current);t.selectAll("*").remove();const a=(null==(e=l.current.parentElement)?void 0:e.clientWidth)||300,r=Math.max(a-20,200)-50-12,i=c-25-45,u=o.some(e=>e.value<0),m=o.length>5?.15:.25,p=Ye.scaleBand().domain(o.map(e=>e.name)).range([0,r]).padding(m),h=u?Math.min(0,Ye.min(o,e=>e.value)||0):0,x=Math.max(0,Ye.max(o,e=>e.value)||0),g=Ye.scaleLinear().domain([1.15*h,1.15*x]).range([i,0]),y=t.append("g").attr("transform","translate(50,25)"),v=g.ticks(4).filter(e=>0!==e);y.selectAll(".grid-line").data(v).enter().append("line").attr("x1",0).attr("x2",r).attr("y1",e=>g(e)).attr("y2",e=>g(e)).attr("stroke","#E5E7EB").attr("stroke-dasharray","3,3"),y.selectAll(".y-tick").data(v).enter().append("text").attr("x",-6).attr("y",e=>g(e)).attr("dy","0.35em").attr("text-anchor","end").attr("font-size","9px").attr("fill","#6B7280").text(e=>(e=>{const t=Math.abs(e);return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)})(e)),u&&y.append("line").attr("x1",0).attr("x2",r).attr("y1",g(0)).attr("y2",g(0)).attr("stroke","#9CA3AF").attr("stroke-width",1),y.selectAll(".bar").data(o).enter().append("rect").attr("x",e=>p(e.name)||0).attr("y",e=>e.value>=0?g(e.value):g(0)).attr("width",p.bandwidth()).attr("height",e=>Math.abs(g(e.value)-g(0))).attr("fill",e=>e.value>=0?"#4AC08C":"#E85D3A").attr("rx",3).style("cursor","pointer").on("mouseenter",function(e,t){Ye.select(this).attr("opacity","0.85"),n.current&&(n.current.style.opacity="1",n.current.innerHTML=`<strong>${t.name}</strong><br/>${((e,t)=>{const a=Math.abs(e)>=1e6?"M":Math.abs(e)>=1e3?"K":"",l=Math.abs(e),r=l>=1e6?(l/1e6).toFixed(1):l>=1e3?(l/1e3).toFixed(1):String(l);return`${e<0?`-${r}${a}`:`${r}${a}`} ${t}`})(t.value,s)}`,n.current.style.left=`${e.offsetX+15}px`,n.current.style.top=e.offsetY-10+"px")}).on("mouseleave",function(){Ye.select(this).attr("opacity","1"),n.current&&(n.current.style.opacity="0")}),d&&y.selectAll(".value-label").data(o).enter().append("text").attr("x",e=>(p(e.name)||0)+p.bandwidth()/2).attr("y",e=>e.value>=0?g(e.value)-5:g(e.value)+12).attr("text-anchor","middle").attr("font-size","8px").attr("font-weight","600").attr("fill","#374151").text(e=>(e=>{const t=Math.abs(e)>=1e6?"M":Math.abs(e)>=1e3?"K":"",a=Math.abs(e),l=a>=1e6?(a/1e6).toFixed(1):a>=1e3?(a/1e3).toFixed(1):String(a);return e<0?`-${l}${t}`:`${l}${t}`})(e.value));const f=y.append("g").attr("transform",`translate(0,${i})`).call(Ye.axisBottom(p).tickSize(0));f.selectAll("text").attr("font-size","9px").attr("fill","#6B7280"),f.selectAll(".domain").remove(),o.length>5&&f.selectAll("text").each(function(){const e=Ye.select(this);var t;e.text((t=e.text()).length<=8?t:t.slice(0,6)+"…")})},[o,s,d,c,u]),e.jsxs("div",{className:"ai-summary-panel__card",ref:r,children:[e.jsx("p",{className:"ai-summary-panel__card-title",children:(null==t?void 0:t.title)||""}),e.jsxs("div",{style:{position:"relative",overflow:"visible",height:c,width:"100%"},children:[e.jsx("svg",{ref:l,width:"100%",height:c,style:{display:"block"}}),e.jsx("div",{ref:n,style:{position:"absolute",backgroundColor:"white",padding:"8px 12px",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0,0,0,0.12)",fontSize:"11px",color:"#374151",opacity:0,transition:"opacity 0.15s",pointerEvents:"none",zIndex:10,border:"1px solid #E5E7EB",lineHeight:1.4}})]})]})}const Sa=["#4AC08C","#3AA87A","#2E8E68","#247457","#7FD3AE","#C9EFE0","#6BBF8A","#5AAF7C"];function Ta({chart:t}){var a;const l=i.useRef(null),r=i.useRef(null),n=i.useRef(null),o=(null==t?void 0:t.labels)||[],s=(null==(a=null==t?void 0:t.datasets)?void 0:a[0])||{},d=(null==s?void 0:s.values)||[],c=(null==t?void 0:t.currency)||"",u=(null==t?void 0:t.unit)||"",m=i.useMemo(()=>d.reduce((e,t)=>e+(t||0),0),[d]),p=i.useMemo(()=>o.map((e,t)=>({name:e,value:d[t]||0,pct:m>0?(d[t]||0)/m*100:0})),[o,d,m]),h=i.useMemo(()=>[...p].sort((e,t)=>t.value-e.value),[p]);return i.useEffect(()=>{var e;if(!l.current||!p.length)return;const t=Ye.select(l.current);t.selectAll("*").remove();const a=(null==(e=r.current)?void 0:e.clientWidth)||300,o=Math.min(.6*a,170),i=o/2-4,s=i-16,d=t.append("g").attr("transform",`translate(${o/2},${o/2})`),h=Ye.pie().value(e=>e.value).sort(null).padAngle(.02),x=Ye.arc().innerRadius(s).outerRadius(i).cornerRadius(3);d.selectAll("path").data(h(p)).enter().append("path").attr("d",x).attr("fill",(e,t)=>Sa[t%Sa.length]).style("cursor","pointer").on("mouseenter",function(e,t){if(Ye.select(this).attr("opacity","0.85"),n.current){n.current.style.opacity="1",((e,t,a)=>{if(a)return`${e} ${a}`;if(t){const a=Math.abs(e);return a>=1e6?`${t} ${(a/1e6).toFixed(2)}M`:a>=1e3?`${t} ${(a/1e3).toFixed(1)}K`:`${t} ${e}`}e.toString()})(t.data.value,c,u);const a=(e,t)=>t?Math.abs(e)>=1e6?`${(Math.abs(e)/1e6).toFixed(2)}M ${t}`:Math.abs(e)>=1e3?`${(Math.abs(e)/1e3).toFixed(1)}K ${t}`:`${e} ${t}`:String(e);n.current.innerHTML=`<strong>${t.data.name}</strong><br/>${a(t.data.value,c)}<br/>(${t.data.pct.toFixed(1)}%)`,n.current.style.left=`${e.offsetX+15}px`,n.current.style.top=e.offsetY-10+"px"}}).on("mouseleave",function(){Ye.select(this).attr("opacity","1"),n.current&&(n.current.style.opacity="0")});const g=(y=m)>=1e6?(y/1e6).toFixed(1)+"M":y>=1e3?(y/1e3).toFixed(1)+"K":String(y);var y;d.append("text").attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-size",g.length>8?"10px":"12px").attr("font-weight","600").attr("fill","#1F2125").text(g)},[p,c,u,t,m]),e.jsxs("div",{className:"ai-summary-panel__card",ref:r,children:[e.jsx("p",{className:"ai-summary-panel__card-title",children:(null==t?void 0:t.title)||""}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"50px",width:"100%"},children:[e.jsxs("div",{style:{position:"relative",display:"flex",justifyContent:"center",width:"100%"},children:[e.jsx("svg",{ref:l,width:"100%",height:180,style:{maxWidth:"180px"}}),e.jsx("div",{ref:n,style:{position:"absolute",backgroundColor:"white",padding:"8px 12px",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0,0,0,0.12)",fontSize:"11px",color:"#374151",opacity:0,transition:"opacity 0.15s",pointerEvents:"none",zIndex:10,border:"1px solid #E5E7EB",lineHeight:1.4}})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:"6px 12px",maxWidth:"100%"},children:h.map((t,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"5px",padding:"4px 8px",borderRadius:"4px",cursor:"pointer"},children:[e.jsx("div",{style:{width:"9px",height:"9px",borderRadius:"2px",backgroundColor:Sa[a%Sa.length],flexShrink:0}}),e.jsx("span",{style:{fontSize:"10px",color:"#374151",maxWidth:"85px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t.name,children:t.name}),e.jsxs("span",{style:{fontSize:"10px",color:"#6B7280",fontWeight:"500",flexShrink:0},children:[t.pct.toFixed(0),"%"]})]},t.name))})]})]})}const ka=["#4AC08C","#3AA87A","#2E8E68","#247457","#7FD3AE","#C9EFE0","#6BBF8A","#5AAF7C"];function _a({chart:t,currency:a}){const l=i.useRef(null),r=i.useRef(null),n=i.useRef(null),o=(null==t?void 0:t.labels)||[],s=(null==t?void 0:t.datasets)||[],d=a||(null==t?void 0:t.currency)||"AED",c=i.useMemo(()=>o.map((e,t)=>{const a={name:e};return s.forEach((e,l)=>{var r;a[e.label||`dataset_${l}`]=(null==(r=e.values)?void 0:r[t])??0}),a}),[o,s]),u=i.useMemo(()=>s.map(e=>e.label||`dataset_${s.indexOf(e)}`),[s]),m=i.useMemo(()=>c.length*s.length<=12,[c,s]),p=i.useMemo(()=>o.some(e=>e.length>6),[o]),h=Math.max(48*c.length+35*s.length+150,300),x={top:25,right:15,bottom:p?100:80,left:60};return i.useEffect(()=>{var e;if(!l.current||!c.length)return;const t=Ye.select(l.current);t.selectAll("*").remove();const a=(null==(e=l.current.parentElement)?void 0:e.clientWidth)||300,r=Math.max(a-20,200)-x.left-x.right,o=h-x.top-x.bottom,i=Ye.scaleBand().domain(c.map(e=>e.name)).range([0,r]).padding(.2),s=Ye.scaleBand().domain(u).range([0,i.bandwidth()]).padding(.1),g=Ye.max(c,e=>Math.max(...u.map(t=>Math.abs(Number(e[t]))||0))||0),y=Ye.scaleLinear().domain([0,1.25*g]).range([o,0]),v=t.append("g").attr("transform",`translate(${x.left},${x.top})`),f=y.ticks(4).filter(e=>e>0);v.selectAll(".grid-line").data(f).enter().append("line").attr("x1",0).attr("x2",r).attr("y1",e=>y(e)).attr("y2",e=>y(e)).attr("stroke","#E5E7EB").attr("stroke-dasharray","3,3"),v.selectAll(".y-tick").data(f).enter().append("text").attr("x",-6).attr("y",e=>y(e)).attr("dy","0.35em").attr("text-anchor","end").attr("font-size","10px").attr("fill","#6B7280").text(e=>(e=>{const t=Math.abs(e);return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)})(e)),c.forEach(e=>{const t=v.append("g").attr("transform",`translate(${i(e.name)},0)`);u.forEach((a,l)=>{const r=Number(e[a])||0,i=Math.abs(r),c=y(i);t.append("rect").attr("x",s(a)||0).attr("y",c).attr("width",s.bandwidth()).attr("height",o-c).attr("fill",ka[l%ka.length]).attr("rx",3).style("cursor","pointer").on("mouseenter",function(t){Ye.select(this).attr("opacity","0.85"),n.current&&(n.current.style.opacity="1",n.current.innerHTML=`<strong>${a}</strong> - ${e.name}<br/>${((e,t)=>{const a=Math.abs(e)>=1e6?"M":Math.abs(e)>=1e3?"K":"",l=Math.abs(e),r=l>=1e6?(l/1e6).toFixed(1):l>=1e3?(l/1e3).toFixed(1):String(l);return`${e<0?`-${r}${a}`:`${r}${a}`} ${t}`})(r,d)}`,n.current.style.left=`${t.offsetX+15}px`,n.current.style.top=t.offsetY-10+"px")}).on("mouseleave",function(){Ye.select(this).attr("opacity","1"),n.current&&(n.current.style.opacity="0")}),m&&s.bandwidth()>28&&i>0&&t.append("text").attr("x",(s(a)||0)+s.bandwidth()/2).attr("y",c-5).attr("text-anchor","middle").attr("font-size","8px").attr("font-weight","600").attr("fill","#374151").text((e=>{const t=Math.abs(e)>=1e6?"M":Math.abs(e)>=1e3?"K":"",a=Math.abs(e),l=a>=1e6?(a/1e6).toFixed(1):a>=1e3?(a/1e3).toFixed(1):String(a);return e<0?`-${l}${t}`:`${l}${t}`})(r))})});const b=v.append("g").attr("transform",`translate(0,${o})`).call(Ye.axisBottom(i).tickSize(0).tickFormat(e=>{return t=String(e),a=p?12:14,t.length<=a?t:t.slice(0,a-2)+"…";var t,a}));b.selectAll("text").attr("font-size","10px").attr("fill","#6B7280"),p&&b.selectAll("text").attr("transform","rotate(-30)").attr("text-anchor","end"),b.selectAll(".domain").remove()},[c,u,d,m,p,h,x]),e.jsxs("div",{className:"ai-summary-panel__card",ref:r,children:[e.jsx("p",{className:"ai-summary-panel__card-title",children:(null==t?void 0:t.title)||""}),e.jsx("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap",marginBottom:"10px"},children:u.map((t,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"2px",backgroundColor:ka[a%ka.length]}}),e.jsx("span",{style:{fontSize:"10px",color:"#6B7280"},children:t})]},t))}),e.jsxs("div",{style:{position:"relative",overflow:"visible",height:h,width:"100%"},children:[e.jsx("svg",{ref:l,width:"100%",height:h,style:{display:"block"}}),e.jsx("div",{ref:n,style:{position:"absolute",backgroundColor:"white",padding:"8px 12px",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0,0,0,0.12)",fontSize:"11px",color:"#374151",opacity:0,transition:"opacity 0.15s",pointerEvents:"none",zIndex:10,border:"1px solid #E5E7EB",lineHeight:1.4}})]})]})}function Da({charts:t,currency:a="AED"}){const l={bar:Ca,horizontal_bar:wa,donut:Ta,grouped_bar:_a};return e.jsx("div",{className:"ai-summary-panel__visuals",children:t.map((t,r)=>{const n=l[t.chart_type];return n?e.jsx(n,{chart:t,currency:a},r):null})})}exports.AISummaryPanel=function(t={}){const{aiSummaryData:a,isLoading:l,onExpand:r}=t,n=i.useMemo(()=>{var e,t;if(!a)return{summaryText:"",insights:[],charts:[]};const l=(a.flags||[]).map(e=>({icon:"critical"===e.severity?qe.AlertTriangle:"warning"===e.severity?qe.Clock:qe.TrendingUp,text:e.message,title:"critical"===e.severity?"Critical":"warning"===e.severity?"Warning":"Info",color:"critical"===e.severity?"#E85D3A":"warning"===e.severity?"#D97706":"#059669"}));return{summaryText:a.summary||"",insights:l,charts:a.charts||[],currency:(null==(t=null==(e=null==a?void 0:a.charts)?void 0:e[0])?void 0:t.currency)||"AED"}},[a]),[o,s]=i.useState(!1),[d,c]=i.useState(!1),[u,m]=i.useState(!1),{displayed:p,done:h}=function(e,t=18){const[a,l]=i.useState(""),[r,n]=i.useState(!1);return i.useEffect(()=>{let a=0;const r=setInterval(()=>{a++,l(e.slice(0,a)),a>=e.length&&(clearInterval(r),n(!0))},t);return()=>clearInterval(r)},[e,t]),{displayed:a,done:r}}(n.summaryText,12);return i.useEffect(()=>{h&&setTimeout(()=>m(!0),200)},[h]),e.jsxs("div",{className:"ai-summary-panel",children:[!o&&e.jsxs("button",{onClick:()=>{s(!0),null==r||r()},className:"ai-summary-panel__collapsed-toggle",disabled:l,children:[e.jsx("div",{className:"ai-summary-panel__collapsed-toggle-icon",children:l?e.jsx("div",{className:"ai-summary-panel__loading-spinner"}):e.jsx(qe.Sparkles,{})}),e.jsx("span",{className:"ai-summary-panel__collapsed-toggle-title",children:"AI Summary"}),e.jsx("span",{className:"ai-summary-panel__collapsed-toggle-subtitle",children:l?"Generating insights...":"Click to expand insights"}),!l&&e.jsx(qe.ChevronDown,{className:"ai-summary-panel__collapsed-toggle-chevron"})]}),o&&e.jsxs("div",{className:"ai-summary-panel__expanded",children:[e.jsxs("div",{className:"ai-summary-panel__header",children:[e.jsxs("div",{className:"ai-summary-panel__header-left",children:[e.jsx("div",{className:"ai-summary-panel__header-icon",children:e.jsx(qe.Sparkles,{})}),e.jsx("span",{className:"ai-summary-panel__header-title",children:"AI Summary"}),e.jsx("span",{className:"ai-summary-panel__header-badge",children:"Beta"})]}),e.jsxs("div",{className:"ai-summary-panel__header-actions",children:[e.jsx("button",{onClick:function(){navigator.clipboard.writeText(n.summaryText),c(!0),setTimeout(()=>c(!1),2e3)},className:"ai-summary-panel__header-btn "+(d?"copied":""),children:d?e.jsx(qe.Check,{}):e.jsx(qe.Copy,{})}),e.jsx("button",{onClick:()=>s(!1),className:"ai-summary-panel__header-btn",children:e.jsx(qe.ChevronUp,{})})]})]}),e.jsxs("div",{className:"ai-summary-panel__body",children:[l&&e.jsxs("div",{className:"ai-summary-panel__loading",children:[e.jsx("div",{className:"ai-summary-panel__loading-spinner-large"}),e.jsx("span",{className:"ai-summary-panel__loading-text",children:"Generating AI insights..."})]}),!l&&e.jsxs("p",{className:"ai-summary-panel__summary",children:[p,!h&&e.jsx("span",{className:"ai-summary-panel__summary-cursor"})]}),n.charts.length>0&&u&&e.jsx(Da,{charts:n.charts,currency:n.currency}),u&&e.jsx("div",{className:"ai-summary-panel__insights",children:n.insights.map((t,a)=>{var l;return e.jsxs("div",{className:`ai-summary-panel__insight-chip ai-summary-panel__insight-chip--${(null==(l=t.title)?void 0:l.toLowerCase())||"info"}`,children:[e.jsx(t.icon,{style:{color:t.color}}),e.jsx("span",{className:"ai-summary-panel__insight-chip-title",children:t.title}),e.jsxs("span",{className:"ai-summary-panel__insight-chip-text",children:["— ",t.text]}),e.jsx("svg",{className:"ai-summary-panel__insight-chip-arrow",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M9 18l6-6-6-6"})})]},a)})})]})]})]})},exports.ActivityTag=t=>{const{t:a}=w.useTranslation(),{data:l}=t,r={view:a("common.viewed_text"),delete:a("common.deleted_text"),create:a("common.created_text"),update:a("common.updated_text")};return e.jsx(u.Box,{children:e.jsx(x,{className:"Timeline",children:e.jsxs(u.Box,{sx:{display:"flex",flexDirection:"column",gap:2,padding:"16px"},className:"box-class",children:[e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.800",children:a("common.activities_label")}),e.jsx(u.Box,{sx:{height:400,overflowY:"auto",gap:1.5,display:"flex",flexDirection:"column"},children:null==l?void 0:l.map((t,a)=>{var n,o;return e.jsx("div",{className:"Timeline--Activity",children:e.jsxs(g,{children:[e.jsxs(y,{children:[e.jsx(b,{color:"primary",sx:{backgroundColor:"#D3D3D4"}}),l.length-1!==a&&e.jsx(v,{})]}),e.jsxs(f,{className:"Timeline--Content",children:[e.jsxs(h.Typography,{type:"s5",color:"theme.secondary.800",className:"Timeline--ActivityLogItem",children:[e.jsx("b",{children:j.formatText(t.username)})," ",r[t.action]," ",e.jsx("b",{children:j.formatText(null==(n=t.resource)?void 0:n.replace("_"," "))})]}),e.jsx(h.Typography,{type:"s5",color:"theme.secondary.800",className:"Timeline--ActivityLogItem",children:(o=null==t?void 0:t.created_at,`${p(o).format("DD MMM, YYYY")} • ${p(o).format("HH:mm")}`)})]})]},a)})})})]})})})},exports.ActivityTag$1=t=>{const{type:a,data:l,placeholder:r,error:s=!1,textfield:c,textfieldTitle:u,onCommentSubmit:m,onChange:p,containerProps:w,accordion:C=!0,...S}=t,{user:T}=h.useAuth(),k=i.useRef(null),_=()=>{k.current&&(k.current.scrollTop=k.current.scrollHeight)};i.useEffect(()=>{_()},[l]);const D=e=>{const t=new Date,a=new Date(e),l=t.getTime()-a.getTime(),r=Math.floor(l/1e3),n=Math.floor(r/60),o=Math.floor(n/60);if(r<60)return`${r} second${1!==r?"s":""} ago`;if(n<60)return`${n} minute${1!==n?"s":""} ago`;if(o<24)return`${o} hour${1!==o?"s":""} ago`;{const e={day:"numeric",month:"short",year:"numeric"},t={hour:"numeric",minute:"numeric",hour12:!1};return`${a.toLocaleString("en-US",e)} • ${a.toLocaleString("en-US",t)}`}},M="activity"===a?null==l?void 0:l.map((t,a)=>e.jsx("div",{className:"Timeline--Activity",children:e.jsxs(g,{children:[e.jsxs(y,{children:[e.jsx(b,{}),l.length-1!==a&&e.jsx(v,{})]}),e.jsx(f,{className:"Timeline--Content",children:e.jsxs(h.Typography,{type:"s4",color:"theme.secondary.800",className:"Timeline--ActivityLogItem",children:[t.message," · ",D(t.created_at)]})})]},a)})):e.jsx(e.Fragment,{children:e.jsx("div",{className:"Timeline--Chat",ref:k,children:l.map((t,a)=>e.jsxs(g,{children:[e.jsxs(y,{children:[e.jsx(o.Avatar,{src:d.images.chat,size:17}),e.jsx(v,{})]}),e.jsxs(f,{children:[t.name," commented this · ",D(t.created_at),e.jsx("div",{className:"Timeline--CommentWrap",children:e.jsx("p",{className:"Timeline--Comment",children:t.message})})]})]},a))})});return e.jsx("div",{className:"ActivityContainer",...w,children:e.jsxs(x,{className:"Timeline",children:[C?e.jsx(n.Accordion,{title:"Activities",accordionProps:{defaultExpanded:!0},children:M}):e.jsx("div",{className:"Timeline--ActivityBox",children:M}),c&&e.jsxs("div",{className:"Timeline--CommentBox",children:[u,e.jsxs("div",{className:"Timeline--CommentText",children:[e.jsx(o.Avatar,{size:32,alt:j.formatText(null==T?void 0:T.full_name),className:"avatar-class"}),e.jsx(ut,{error:s,placeholder:r,className:"textfield",onKeyDown:e=>{if("Enter"===e.key){const t=e.target.value;""!==t.trim()&&(m(t),_())}},onChange:p,...S})]})]})]})})},exports.ApprovalWrapper=({data:t,addApprover:a,fetchApi:l,showAcceptOrReject:r,moduleIdKey:s,moduleId:d,successMessage:c,showSubmitBtn:u,updateApi:m,approvalDetails:p,title:h})=>{const{t:x}=w.useTranslation(),g=D.useDispatch(),[y,v]=i.useState(!1),[f,b]=i.useState(!1),[j,C]=i.useState(""),S=async(e,r)=>{if(t){v(!0);const t={[s]:d,type:e,...r&&(null==r?void 0:r.length)&&{approver_id:r}},n=await g(a(t));v(!1),M.apiHelper(n,()=>(k.enqueueSnackbar(x(c)),void l()))}};return e.jsxs(e.Fragment,{children:[(u||"Rejected"===(null==t?void 0:t.status))&&e.jsx(n.DropdownButton,{isMenuThirdItemDisabled:!0,onClick:()=>S("submit_for_approval"),options:[{label:x("common.submitForApproval"),callback:()=>S("submit_for_approval")},{label:x("common.quickApproval"),callback:()=>b(!0)}],loading:y,children:"Rejected"===(null==t?void 0:t.status)?x("common.reSubmit"):x("common.submit")}),e.jsx(pt,{isOpen:f,setIsOpen:()=>b(!1),onConfirm:e=>S("quick_approval",e),isProcessing:y}),e.jsx(o.ConfirmPopUp,{open:Boolean(j),onClose:()=>C(""),onConfirm:async()=>{if((null==p?void 0:p.id)&&j){const e={id:null==p?void 0:p.id,[s]:d,status:j};v(!0);const t=await g(m(e));v(!1);const a=j;if(C(""),M.apiHelper(t,()=>l()),"fulfilled"===t.meta.requestStatus){const e=`${h} ${x("Approved"===a?"common.accepted":"common.rejected")}`;k.enqueueSnackbar(e)}}},title:`${j} request`,description:`Are you sure you want to ${j} ${h} : ${null==t?void 0:t.id} ?`,buttonTexts:{confirm:x("common.submit"),cancel:x("common.cancel")},buttonColors:{confirm:"Rejected"===j?"error":"info"},modalType:"info",loading:y}),r&&e.jsx(n.DropdownButton,{isMenuThirdItemDisabled:!0,onClick:()=>C("Approved"),options:[{label:x("common.accept"),callback:()=>C("Approved")},{label:x("common.reject"),callback:()=>C("Rejected"),color:"theme.error.500"}],loading:y,children:x("common.accept")})]})},exports.AreaLineChart=({data:t,height:a=400,customLabelFormatter:l,yAxisLabelType:r="inValue",currency:n,colors:o,customLegend:s})=>{const d=i.useRef(null),c=i.useRef(null),[m,p]=i.useState(0),[h,x]=i.useState(null);return i.useEffect(()=>{const e=c.current,t=new ResizeObserver(e=>{if(e[0]){const t=e[0].contentRect.width;p(t)}});return e&&t.observe(e),()=>{e&&t.unobserve(e)}},[]),i.useEffect(()=>{var e,i;if(0===m)return;const s=m-40-30,c=a-20-30;Ye.select(d.current).selectAll("*").remove();const u=Ye.select(d.current).attr("width",m).attr("height",a).append("g").attr("transform","translate(40,20)"),p=Ye.scalePoint().domain(null==(i=null==(e=t[0])?void 0:e.values)?void 0:i.map(e=>e.month)).range([0,s]),h=Ye.scaleLinear().domain([0,Ye.max(t,e=>Ye.max(e.values,e=>e.value))]).range([c,0]),g=Math.floor(s/80),y=Ye.axisBottom(p).ticks(g),v=u.append("g").attr("transform",`translate(0,${c})`).call(y);v.selectAll("text").attr("transform","translate(0, 10)").attr("color","#8E8E93").style("text-anchor","middle");const f=u.append("g");f.append("g").attr("color","#8E8E93").attr("transform","translate(-10,0)").call(Ye.axisLeft(h).tickSize(-s).tickFormat(e=>{return l?l(e):(t=e,a=n,"inPercent"===(o=r)?`${Ye.format(".0%")(t/100)}`:"inValue"===o?`${a||""} ${Ye.format(".2s")(t).replace("k","K")}`:t.toString());var t,a,o}).tickSizeOuter(0)).selectAll("line").attr("stroke-dasharray","3,3").attr("stroke","#D3D3D4"),v.selectAll(".tick line").remove(),f.select(".domain").attr("stroke","none"),v.select(".domain").attr("stroke","none");const b=Ye.area().x(e=>p(e.month)).y0(c).y1(e=>h(e.value));t.forEach((e,t)=>{const a=u.append("defs").append("linearGradient").attr("id",`area-gradient-${t}`).attr("x1","0%").attr("x2","0%").attr("y1","0%").attr("y2","100%");var l;a.append("stop").attr("offset","0%").attr("stop-color",o[t]).attr("stop-opacity",.4),a.append("stop").attr("offset","100%").attr("stop-color",o[t]).attr("stop-opacity",.1),u.append("path").datum(e.values).attr("fill",`url(#area-gradient-${t})`).attr("d",b),u.append("path").datum(e.values).attr("fill","none").attr("stroke",o[t]).attr("stroke-width",2).attr("d",(l=e.isSmooth||!1,Ye.line().x(e=>p(e.month)).y(e=>h(e.value)).curve(l?Ye.curveMonotoneX:Ye.curveLinear))),(null==e?void 0:e.showCircle)&&u.selectAll(`circle-${t}`).data(e.values).enter().append("circle").attr("cx",e=>p(e.month)).attr("cy",e=>h(e.value)).attr("r",5).attr("fill",o[t]).attr("stroke","#fff").style("cursor","pointer").on("mouseover",function(t,a){x({x:`${t.pageX+10}px`,y:t.pageY-30+"px",content:`${e.name}: ${a.value}`}),Ye.select(this).transition().attr("r",7).attr("fill","#ff4500")}).on("mouseout",function(){x(null),Ye.select(this).transition().attr("r",5).attr("fill",o[t])})})},[t,m,a,l,r,n,o,s]),e.jsxs("div",{ref:c,style:{width:"100%",height:"100%"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("svg",{ref:d,width:"100%",height:a}),s&&s]}),h&&e.jsx(u.Box,{sx:{position:"absolute",left:h.x,top:h.y,pointerEvents:"none",backgroundColor:"#2EB273",zIndex:"99999",border:"none",borderRadius:"3px",transform:"translate(-50%, -100%)",padding:"2px 6px 2px 6px",gap:"10px"},children:e.jsx("span",{style:{fontSize:"16px",weight:"500",color:"#ffff"},children:h.content})})]})},exports.BarChart=({data:t,numOfLines:a=5,initialWidth:l=500,height:r=400,line:n=!1,yAxisLabelType:o="inValue",currency:s,customLabelFormatter:d})=>{const c=i.useRef(null),u=i.useRef(null),[m,p]=i.useState(l),h=i.useMemo(()=>Math.max(...t.map(e=>e.value)),[t]),x=i.useMemo(()=>1.25*h,[h]),g=i.useMemo(()=>{const e=[],t=x/a;for(let l=0;l<=a;l++)e.push(t*l);return e},[x,a]),y=t.length>12,v=y?Math.max(120*t.length,m):m;return i.useEffect(()=>{const e=u.current,t=new ResizeObserver(e=>{if(e[0]){const t=e[0].contentRect.width;p(t)}});return e&&t.observe(e),()=>{e&&t.unobserve(e)}},[]),i.useEffect(()=>{if(0===m)return;const e=Ye.select(c.current);e.selectAll("*").remove();const l=Math.max(60,110),i=v-l-20,u=h?r-20-25:0,p=Ye.scaleBand().domain(t.map(e=>e.label)).range([0,i]).padding(.5),y=Ye.scaleLinear().domain([0,x]).range([u,0]),f=e.append("g").attr("transform",`translate(${l},${h?20:r-50})`);n&&g.slice(1).forEach(e=>{f.append("line").attr("class","dotted-line").attr("x1",0).attr("y1",y(e)).attr("x2",i).attr("y2",y(e)).style("stroke","#D3D3D4").style("stroke-dasharray","3,3").style("opacity",1)}),f.selectAll(".bar").data(t).enter().append("rect").attr("rx",5).attr("ry",5).attr("class","bar").attr("x",e=>p(e.label)).attr("y",e=>y(e.value)).attr("width",p.bandwidth()).attr("height",e=>u-y(e.value)).style("fill",e=>e.color);const b=f.append("g").attr("class","x-axis").attr("transform",`translate(0, ${u})`).call(Ye.axisTop(p).tickPadding(10)).call(Ye.axisBottom(p).tickPadding(5));b.selectAll(".tick line").remove(),b.selectAll(".tick text").call(Jt,80);const j=u,w=Math.floor(j/30),C=Math.min(a,w,8),S=[],T=x/C;for(let t=0;t<=C;t++)S.push(T*t);const k=f.append("g").attr("class","y-axis").call(Ye.axisLeft(y).tickValues(S).tickFormat(e=>{return d?d(e):(t=e,a=s,"inPercent"===(l=o)?`${Ye.format(".0%")(t/100)}`:"inValue"===l?`${a||""} ${Ye.format(".2s")(t).replace("k","K")}`:t.toString());var t,a,l}).tickSizeOuter(0).tickPadding(8));k.selectAll(".tick line").remove(),k.select(".domain").attr("stroke","none"),b.select(".domain").attr("stroke","none"),k.selectAll(".tick text").style("font-size","11px").style("fill","#666").style("font-family","Inter, system-ui, Avenir, Helvetica, Arial, sans-serif").style("text-anchor","end")},[t,m,r,n,x,g,s,o,d,v]),e.jsx("div",{ref:u,style:{width:"100%",overflowX:y?"auto":"hidden",overflowY:"hidden"},children:e.jsx("svg",{ref:c,width:v,height:r,viewBox:`0 0 ${v} ${r}`})})},exports.BarChart$1=({data:t,numOfLines:a=5,width:l=500,height:r=300,line:n=!1})=>{const o=i.useRef(null),s=i.useMemo(()=>Math.max(...t.map(e=>e.value)),[t]),d=i.useMemo(()=>1.25*s,[s]),c=i.useMemo(()=>{const e=[],t=d/a;for(let l=0;l<=a;l++)e.push(t*l);return e},[d,a]);return i.useEffect(()=>{if(!o.current)return;const e=Ye.select(o.current);e.selectAll("*").remove();const a=l-40-20,i=r-20-70,s=Ye.scaleBand().domain(t.map(e=>e.label)).range([0,a]).padding(.1),u=Ye.scaleLinear().domain([0,d]).range([i,0]),m=e.append("g").attr("transform","translate(40,20)");n&&c.slice(1).forEach(e=>{m.append("line").attr("class","dotted-line").attr("x1",0).attr("y1",u(e)).attr("x2",a).attr("y2",u(e)).style("stroke","gray").style("stroke-dasharray","3,3").style("opacity",1)}),m.selectAll(".bar").data(t).enter().append("rect").attr("class","bar").attr("x",e=>s(e.label)).attr("y",e=>u(e.value)).attr("width",s.bandwidth()).attr("height",e=>i-u(e.value)).style("fill","#357AF6").style("opacity","1").on("mousemove",(e,t)=>{var a,r;let n=e.offsetX+40-25;const o=e.offsetY+20-40,i=null==(r=null==(a=p.node())?void 0:a.getBoundingClientRect())?void 0:r.width;(i?n+i:n)>l&&(n=Math.floor(i?n-i-20:n-20));const s=`${t.label} - ${t.value}`;p.attr("x",n).attr("y",o).style("opacity",9).style("height",s.length>=16?50:35),h.html(s)}).on("mouseleave",()=>{p.style("opacity",0)}),m.append("g").attr("class","x-axis").attr("transform",`translate(0, ${i})`).call(Ye.axisBottom(s)).selectAll(".tick line").remove(),m.append("g").attr("class","y-axis").call(Ye.axisLeft(u).tickValues(c).tickFormat(e=>{return(t=e)>=1e9?(t/1e9).toFixed(1)+"B":t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t;var t}).tickSizeOuter(0)).selectAll(".tick line").remove();const p=e.append("foreignObject").attr("class","tooltip").attr("width",120).attr("height",20).style("opacity",0).style("position","absolute").style("background-color","white").style("border","none").style("box-shadow","0rem 0rem 0.469rem 0rem rgba(0, 0, 0, 0.15)").style("border-radius","0.313rem").style("padding","0.625rem").style("font-size","0.75rem"),h=p.append("xhtml:div").style("font-size","0.75rem").style("color","black")},[t,r,l,n,d,c]),e.jsx(e.Fragment,{children:e.jsx("svg",{ref:o,width:l,height:r})})},exports.BarLineChart=({data:t,height:a=400,margin:l={top:20,right:30,bottom:30,left:50},bars:r,lines:n,line:o=!0,showGrid:s=!0,barColors:d,lineColors:c})=>{var m;const p=i.useRef(null),x=i.useRef(null),g=i.useRef(null),[y,v]=i.useState(null),[f,b]=i.useState(0),j=e=>Ye.format(".2s")(e).replace("k","K"),w=t.length>r.length,C=w?Math.max(60*t.length,f):f;return i.useEffect(()=>{const e=x.current,t=new ResizeObserver(e=>{if(e[0]){const t=e[0].contentRect.width;b(t)}});return e&&t.observe(e),()=>{e&&t.unobserve(e)}},[]),i.useEffect(()=>{if(0===f)return;const e=Ye.max(t,e=>Math.max(...r.map(t=>e[t.field]),...n.map(t=>e[t.field])))??0,i=Ye.min(t,e=>Math.min(...r.map(t=>e[t.field]),...n.map(t=>e[t.field])))??0,u=Ye.select(p.current),m=C-l.left-l.right,h=e||i?a-l.top-l.bottom:0,x=Ye.scaleBand().domain(t.map(e=>e.month)).range([0,m]).padding(.3),y=Ye.scaleLinear().domain([i,e]).nice().range([h,0]);u.selectAll("*").remove();const b=u.append("g").attr("transform",`translate(${l.left},${l.top})`);b.append("g").call(Ye.axisLeft(y).tickFormat(j)).call(e=>e.select(".domain").remove()).select(".domain").attr("stroke","none"),b.append("g").attr("transform",`translate(0,${h})`).call(Ye.axisBottom(x)).selectAll(".tick text").attr("text-anchor","middle").select(".domain").attr("stroke","none"),s&&b.selectAll(".grid-line").data(y.ticks()).enter().append("line").attr("class","grid-line").attr("x1",0).attr("x2",m).attr("y1",e=>y(e)).attr("y2",e=>y(e)).style("stroke","#ddd").style("stroke-dasharray","8,8").style("stroke-width",1),o&&b.selectAll(".grid-line-2").data(y.ticks()).enter().append("line").attr("class","grid-line-2").attr("x1",0).attr("x2",m).attr("y1",e=>y(e)).attr("y2",e=>y(e)).style("stroke","#ddd").style("stroke-dasharray","8,8").style("stroke-width",1),r.forEach((e,a)=>{b.selectAll(`.bar-${e.field}`).data(t).enter().append("rect").attr("class",`bar bar-${e.field}`).attr("x",e=>x(e.month)??0).attr("y",t=>t[e.field]>=0?y(t[e.field]):y(0)).attr("rx",5).attr("ry",5).attr("width",x.bandwidth()/r.length).attr("height",t=>Math.abs(y(t[e.field])-y(0))).attr("fill",d[a]).attr("transform",`translate(${a*x.bandwidth()/r.length}, 0)`).on("mouseover",function(e,t){var a;const[r,n]=Ye.pointer(e,p.current),o=(null==(a=g.current)?void 0:a.scrollLeft)||0;v({x:r+l.left-o,y:n+l.top,content:t})}).on("mouseout",()=>v(null))}),n.forEach((e,a)=>{const r=Ye.line().x(e=>(x(e.month)??0)+x.bandwidth()/2).y(t=>y(t[e.field])).curve(Ye.curveMonotoneX);b.append("path").datum(t).attr("fill","none").attr("stroke",c[a]).attr("stroke-width",2).attr("d",r).on("mouseover",function(a){var r;const[n]=Ye.pointer(a,p.current),o=x.domain().find(e=>{const t=x(e)??0;return n>=t&&n<=t+x.bandwidth()});if(o){const a=t.find(e=>e.month===o);if(a){const t=(null==(r=g.current)?void 0:r.scrollLeft)||0;v({x:n+l.left-t,y:y(a[e.field])+l.top,content:a})}}}).on("mouseout",()=>v(null))})},[t,f,C,o,a,l,r,n,s,d,c]),e.jsx("div",{ref:x,style:{width:"100%",height:"100%"},children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:g,style:{width:"100%",overflowX:w?"auto":"hidden",overflowY:"hidden"},children:e.jsx("svg",{ref:p,width:C,height:a,viewBox:`0 0 ${C} ${a}`,style:{display:"block"}})}),y&&e.jsx("div",{style:{position:"absolute",left:y.x,top:y.y,pointerEvents:"none",backgroundColor:"white",zIndex:"99999",border:"none",padding:"5px",borderRadius:"3px",transform:"translate(-50%, -100%)"},children:e.jsxs(u.Box,{children:[e.jsx("div",{style:{background:"#F3F2F2",padding:"10px"},children:e.jsx(h.Typography,{type:"s4",style:{whiteSpace:"noWrap",width:"200px",color:"#232529"},children:null==(m=y.content)?void 0:m.month})}),e.jsxs(u.Box,{sx:{p:1.5,display:"flex",flexDirection:"column",gap:1.5},children:[r.map((t,a)=>e.jsxs(u.Box,{sx:{display:"flex",gap:1.5,alignItems:"center"},children:[e.jsx("div",{className:"circle",style:{backgroundColor:d[a]}}),e.jsxs(h.Typography,{type:"s5",color:"theme.secondary.900",children:[t.label,": ",e.jsxs("span",{style:{fontWeight:600},children:["$ ",y.content[t.field]]})]})]},`bar-${a}`)),n.map((t,a)=>e.jsxs(u.Box,{sx:{display:"flex",gap:1.5,alignItems:"center"},children:[e.jsx("div",{className:"circle",style:{backgroundColor:c[a]}}),e.jsxs(h.Typography,{type:"s5",color:"theme.secondary.900",children:[t.label,": ",e.jsxs("span",{style:{fontWeight:600},children:["$ ",y.content[t.field]]})]})]},`line-${a}`))]})]})})]})})},exports.BoardWrapper=t=>{const[a,l]=i.useState(t.data),[r,n]=i.useState(!1),[o,s]=i.useState("");return e.jsx("div",{className:"card-board-wrap",children:e.jsx(A,{initialBoard:a,allowAddCard:!0,allowAddColumn:!0,renderColumnHeader:t=>e.jsx("div",{className:"column-header",children:e.jsx(ht,{column:t},t.id)}),renderColumnAdder:()=>r?e.jsxs("div",{className:"create-status-box",children:[e.jsx("input",{type:"text",placeholder:"Enter new status title",value:o,onChange:e=>s(e.target.value)}),e.jsxs("div",{className:"add-btns",children:[e.jsx("button",{onClick:()=>(e=>{const t={...a};t.columns.push({id:Date.now(),title:e,cards:[]}),l(t),n(!1),s("")})(o),children:"Add"}),e.jsx("button",{onClick:()=>n(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"create-status-box",onClick:()=>n(!0),role:"button",children:["Create new status",e.jsx("img",{src:d.images.common.addIcon,alt:"add icon"})]}),allowRemoveCard:!0,allowRenameColumn:!0,onCardNew:console.log,onCardRemove:console.log,onColumnRemove:console.log,onColumnRename:console.log,onNewCardConfirm:e=>({id:(new Date).getTime(),...e})})})},exports.CalculationSummary=({items:t,expenses:a,formValues:l,enalblePromotions:r,enableShippings:n,currencySymbol:o})=>{var s;const{user:d}=h.useAuth(),c=o||(null==(s=null==d?void 0:d.currency_data)?void 0:s.symbol)||"",[m,p]=i.useState({totalQuantity:0,total:0,currencySymbol:c}),[x,g]=i.useState({itemDiscount:0,additionalDiscount:0,totalDiscount:0,currencySymbol:c}),[y,v]=i.useState({subtotalExTax:0,subtotalExDiscount:0,currencySymbol:c}),[f,b]=i.useState({taxes:0,deductedTax:0,total:0,shippingAmount:0,handlingAmount:0,currencySymbol:c}),[j,w]=i.useState({total:0,roundOffDifferenceAmount:0,currencySymbol:c});return i.useEffect(()=>{const e=Number(null==l?void 0:l.exchange_rate)||1;let{totalQuantity:r,totalDiscount:n,totalItemsExpenseDiscount:i,totalTaxAmount:s,additinoalDiscountAmount:d,finalAmount:c,roundOffDifference:u}=N.calculateEntries(t,a,null==l?void 0:l.additional_discount_on,null==l?void 0:l.additional_discount_percentage,null==l?void 0:l.additional_discount_amount,null==l?void 0:l.round_off,null==l?void 0:l.round_off_option);n/=e,d/=e,i/=e,s/=e,c/=e,u/=e;const h=((Number(null==l?void 0:l.shipping_cost)||0)+(Number(null==l?void 0:l.shipping_tax_amount)||0))/e,C=((Number(null==l?void 0:l.handling_cost)||0)+(Number(null==l?void 0:l.handling_tax_amount)||0))/e,S=Number((null==l?void 0:l.promotion_amount)||0)/e;c-=S;const T=c+h+C-S;p({...m,totalQuantity:r,total:c.toFixed(2),currencySymbol:o}),g({...x,itemDiscount:i.toFixed(2),additionalDiscount:Number(d).toFixed(2),totalDiscount:(n+S).toFixed(2),promotionAmount:S.toFixed(2),currencySymbol:o}),v({...y,subtotalExTax:(c-s).toFixed(2),subtotalExDiscount:Number(c+Number(n)).toFixed(2),currencySymbol:o}),b({...f,taxes:s.toFixed(2),total:s.toFixed(2),shippingAmount:h.toFixed(2),handlingAmount:C.toFixed(2),currencySymbol:o}),w({...j,total:T.toFixed(2),roundOffDifferenceAmount:u.toFixed(2),currencySymbol:o})},[t,null==l?void 0:l.additional_discount_amount,null==l?void 0:l.additional_discount_on,null==l?void 0:l.additional_discount_percentage,null==l?void 0:l.currency_id,null==l?void 0:l.round_off,null==l?void 0:l.round_off_option,null==l?void 0:l.shipping_cost,null==l?void 0:l.shipping_tax_amount,null==l?void 0:l.handling_cost,null==l?void 0:l.handling_tax_amount,null==l?void 0:l.promotion_amount,null==l?void 0:l.exchange_rate,null==l?void 0:l.currency_data,c]),e.jsxs(u.Box,{className:"addPurchaseInvoice--RightContainer",children:[e.jsx(xt,{data:m}),e.jsx(gt,{data:x,enalblePromotions:r}),e.jsx(yt,{data:y}),e.jsx(vt,{data:f,enableShippings:n}),e.jsx(ft,{data:j})]})},exports.CalendarWrapper=t=>{const[a]=i.useState(t.data);return e.jsx("div",{className:"calendar-wrapper",children:e.jsx(B,{eventContent:null==t?void 0:t.renderEventContent,schedulerLicenseKey:"GPL-My-Project-Is-Open-Source",initialView:"dayGridMonth",droppable:!0,displayEventTime:!0,headerToolbar:{left:"title",right:"prev,next,today"},buttonText:{today:"Today"},selectable:!0,plugins:[R,I,P,F,$,E,z],eventClick:e=>{},events:a.events,select:null==t?void 0:t.handleSelectedDates,dayMaxEvents:2,showNonCurrentDates:!1,height:"75vh",eventColor:"#"+Math.floor(16777215*Math.random()).toString(16)})})},exports.CardWrapper=bt,exports.ChangeUserPasswordModal=({showModal:a,setShowModal:l,userId:r})=>{const{changeUserPasswordByAdmin:n}=h.useAuth(),[s,d]=i.useState(!1),[c,m]=i.useState(null),{control:p,handleSubmit:x,reset:g,trigger:y}=t.useForm({resolver:o.o(jt),mode:"all"}),v=async e=>{if(await y())return e.login.id=r,e.login.isNotify=s,await n(e.login,(e,t)=>{t?(m({message:e,type:"normal"}),l(!1),g({login:{password:"",id:"",isNotify:!1}})):m({message:e,type:"alert"})}),e},[f,b]=i.useState(!1),j=q.styled(O)(()=>({display:"flex",flexDirection:"column"}));return e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{open:a,onClose:()=>l(!1),children:e.jsx(e.Fragment,{children:e.jsx("form",{onSubmit:x(v),children:e.jsxs(j,{gap:4,className:"popup-change-pass",children:[e.jsxs(j,{gap:2,children:[e.jsx(O,{children:e.jsx(h.Typography,{align:"center",type:"h1",weight:"medium",color:"theme.secondary.1000",children:"Change Password"})}),e.jsxs(j,{gap:2,children:[e.jsx(O,{children:e.jsx(o.DynamicInput,{formControl:p,label:"Enter New Password",name:"password",type:f?"text":"password",placeholder:"Enter New Password",fieldArrayName:"login",endIcon:e.jsx(e.Fragment,{children:f?e.jsx(L.Eye,{fontSize:"small",htmlColor:"#292D32"}):e.jsx(L.EyeOff,{fontSize:"small",htmlColor:"#292D32"})}),onIconClick:()=>b(!f)})}),e.jsx(O,{children:e.jsx(u.FormControlLabel,{control:e.jsx(u.Checkbox,{size:"small",onChange:e=>d(e.target.checked),sx:{"&.Mui-checked":{color:"#2EB273"}}}),label:"Notify User of Password Change",sx:{"& .MuiFormControlLabel-label":{fontSize:"14px"}}})})]})]}),e.jsx(j,{gap:2,children:e.jsx(o.Button,{type:"button",onClick:x(v),size:"large",variant:"contained",children:"Change Password"})})]})})})}),e.jsx(o.Toast,{open:Boolean(c),message:null==c?void 0:c.message,type:null==c?void 0:c.type,handleClose:()=>m(null),anchorOrigin:{horizontal:"right",vertical:"bottom"},autoHideDuration:3e3})]})},exports.ChartLegends=function({legends:t,colors:a}){return e.jsx(u.Box,{sx:{display:"flex",justifyContent:"center",alignContent:"space-between"},children:t.map((t,l)=>e.jsxs("div",{style:{marginLeft:"20px",display:"flex"},children:[e.jsx("div",{className:"legends-circle",style:{backgroundColor:a[l]}}),e.jsx(h.Typography,{type:"s5",sx:{color:"#656669"},children:t})]}))})},exports.ControllerSelect=({name:a,fieldArrayName:l,options:r,label:n,placeholder:i,formControl:s,position:d,required:c,size:m="small",multiple:p,disabled:h,searchPlaceholder:x,handleSearch:g,classes:y,with_checkboxes:v,onChipRemove:f})=>e.jsx(t.Controller,{control:s,name:`${l}.${a}`,render:({field:t,fieldState:{error:s}})=>e.jsxs(e.Fragment,{children:[e.jsx(o.Select,{fullWidth:!0,name:a,dataPosition:d,dataName:`${l}.${a}`,placeholder:i,label:n,value:t.value||(p?[]:""),defaultValue:"",onChange:e=>{var a,l,r;return p&&(null==(l=null==(a=e.target)?void 0:a.value.filter(e=>e))?void 0:l.length)>0||!p&&(null==(r=e.target)?void 0:r.value)?t.onChange(e.target.value):t.onChange("")},required:Boolean(c),size:m,multiple:Boolean(p),disabled:Boolean(h),searchPlaceholder:x,handleSearch:g,className:y,variant:"outlined",error:Boolean(s),renderValue:t=>e.jsx(e.Fragment,{children:Array.isArray(t)?e.jsx(Vt,{data:t,placeholder:i,onDelete:f}):t||i}),children:Ht({options:r,multiple:Boolean(p),placeholder:i,values:t.value,with_checkboxes:Boolean(v),onChange:t.onChange})}),s&&e.jsx(u.FormHelperText,{error:!0,children:s.message}),p&&Array.isArray(null==t?void 0:t.value)&&e.jsx(Kt,{data:t.value,options:r})]})}),exports.CountrySelect=({country:t,handleCountry:a})=>e.jsxs(e.Fragment,{children:[e.jsx(h.Typography,{type:"s4",fontWeight:"medium",mb:.5,children:"Country"}),e.jsx(wt,{fullWidth:!0,searchable:!0,searchPlaceholder:"Search Country",selected:t||"IN",selectButtonClassName:"country-button",onSelect:a,showSelectedLabel:!0})]}),exports.CustomDatePicker=ct,exports.CustomGridCard=({title:t,subTitle:a,children:l,data:r,rowActionMenu:n,destructiveActionMenu:o})=>{const[s,d]=i.useState(null),[c,m]=i.useState(null);return e.jsxs(u.Card,{sx:{width:"16.625rem",borderRadius:"0.5rem",border:"0.5px solid #eeeff1",boxShadow:"\n 0px 0px 2px 0px #e0e0e0,\n 0px 1px 4px -2px rgba(24, 39, 75, 0.02),\n 0px 4px 4px -2px rgba(24, 39, 75, 0.06);"},children:[e.jsxs(u.CardContent,{sx:{display:"flex",flexDirection:"column",padding:"1rem 1rem 1.25rem 1rem",justifyContent:"space-between",alignItems:"flex-start",flexShrink:0},children:[e.jsxs(u.Box,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:t}),e.jsx(u.IconButton,{color:"inherit",size:"small",onClick:e=>((e,t)=>{m(t),d(e.currentTarget)})(e,r),children:e.jsx(_.MoreIcon,{sx:{transform:"rotate(90deg)"},orient:"vertical",fontSize:"small"})})]}),e.jsx(u.Box,{children:e.jsx(h.Typography,{type:"s4",color:"theme.secondary.800",children:a})}),l,(null==r?void 0:r.created_at)&&e.jsx(u.Box,{children:e.jsxs(h.Typography,{type:"s4",color:"theme.secondary.800",children:["Created On ",j.formatDate(null==r?void 0:r.created_at,"DD MMM, YYYY")]})})]}),e.jsxs(S.Menu,{anchorEl:s,open:Boolean(s),onClose:()=>d(null),children:[e.jsx(u.Box,{children:n.map(t=>e.jsx(u.MenuItem,{onClick:()=>{c&&t.handleAction(c),d(null)},children:e.jsx(h.Typography,{type:"s4",color:"inherit",children:t.label})}))}),e.jsx(u.Box,{className:"dropdown-inner--DestructiveHeader",children:o.map(t=>e.jsx(u.MenuItem,{onClick:()=>{c&&t.handleAction(c),d(null)},className:"dropdown-inner--DestructiveActions",children:e.jsx(h.Typography,{type:"s4",color:"inherit",children:t.label})}))})]})]})},exports.CustomToggleSwitch=({leftLabel:t="Collapse All",rightLabel:a="Expand All",defaultChecked:l=!1,onChange:r,disabled:n=!1,sx:o={},...s})=>{const[d,c]=i.useState(l),u=e=>{var l;n||(l=e,n||(c(l),r&&r(l,l?a:t)))};return e.jsxs(Ct,{className:n?"disabled":"",sx:o,...s,children:[e.jsx(St,{sx:{left:d?"50%":0,right:d?0:"50%"}}),e.jsx(Tt,{active:!d,className:n?"disabled":"",onClick:()=>u(!1),disableRipple:!0,disabled:n,children:t}),e.jsx(Tt,{active:d,className:n?"disabled":"",onClick:()=>u(!0),disableRipple:!0,disabled:n,children:a})]})},exports.DashBoardCard=function(t){const{title:a,value:l}=t;return e.jsx(e.Fragment,{children:e.jsx(u.Box,{className:"card-class",children:e.jsxs(u.Box,{p:2,sx:{display:"flex",flexDirection:"column",border:"1px solid",borderRadius:"8px",gap:1,borderColor:"#EEEFF1"},children:[e.jsx(u.Box,{className:"dashboard-card-icon",children:e.jsx("img",{src:d.images.ArrowCircleUpIcon})}),e.jsx(h.Typography,{type:"s5",weight:"normal",color:"theme.neutral.800",children:a}),e.jsx(h.Typography,{type:"h2",weight:"bold",color:"theme.neutral.1000",children:l})]})})})},exports.DashBoardHeader=({title:t,customElement:a,showEdit:l=!0,showDropDowan:r=!0})=>{const{t:n}=w.useTranslation(),[o,s]=i.useState(!1),[c,m]=i.useState(null),p=()=>{m(null)};return e.jsx("div",{children:e.jsxs("div",{className:"header-title",children:[e.jsx(h.Typography,{type:"h3",weight:"medium",color:"theme.secondary.1000",children:t}),e.jsxs("div",{className:"header-right-wrap",children:[a,l&&e.jsx(S.Chip,{type:"normal",label:n(o?"manufacturing.dashboard.editing_dashboard_mode_label":"manufacturing.dashboard.edit_layout_mode_label"),className:o?"edit-box":"edit-box edit-box--InActive",icon:e.jsx("img",{src:o?d.images.common.editIcon:d.images.edit,alt:n("common.edit")}),onClick:()=>s(!0),active:o}),r&&e.jsxs("div",{children:[e.jsx(u.IconButton,{color:"inherit",size:"small",onClick:e=>{m(e.currentTarget)},children:e.jsx("img",{src:d.images.more,alt:n("manufacturing.dashboard.more_icon_label")})}),e.jsx(S.Menu,{anchorEl:c,open:Boolean(c),onClose:p,className:"dropdown-inner calender-drp",children:e.jsx(u.MenuItem,{onClick:p,children:n("common.export")})})]})]})]})})},exports.DateRangePicker=ot,exports.DonutChart=({data:t,height:a=140,width:l=140,legend:r=!0,direction:n="vertical",total:o="300",donutThickerValue:s,CustomLegends:d,title:c=""})=>{var u;const m=i.useRef(null),{user:p}=h.useAuth(),x=(null==(u=null==p?void 0:p.currency_data)?void 0:u.symbol)||"";return i.useEffect(()=>{if(!m.current)return;const e=Ye.select(m.current);e.selectAll("*").remove();const r=Math.min(l,a)/2-6;let n=Math.min(l,a)/2-12;s&&(n=r-s);const i=e.append("g").attr("transform",`translate(${l/2}, ${a/2})`),d=Ye.pie().value(e=>(e=>{if("number"==typeof e)return e;const t=(null==e?void 0:e.match(/\d.+/))||null;return t?Number(t[0]):0})(e.value)).padAngle(0),u=Ye.arc().outerRadius(r).innerRadius(n);i.selectAll(".arc").data(d(t)).enter().append("g").attr("class","arc").append("path").attr("d",u).attr("fill",e=>{var t;return null==(t=null==e?void 0:e.data)?void 0:t.color}).attr("stroke","none"),i.append("text").attr("text-anchor","middle").attr("font-size","18px").attr("font-weight","600").attr("alignment-baseline","central").html(o),i.append("text").attr("text-anchor","middle").attr("maring-top","20px").attr("font-size","13px").attr("font-weight","600").attr("dy","2em").attr("color","#7B7C7F").html(c)},[t,a,o,l,x,s,d,c]),r?e.jsx(e.Fragment,{children:e.jsxs("div",{className:`donut-chart-container ${n}`,children:[e.jsx("div",{children:e.jsx("svg",{ref:m,width:l,height:a})}),d?e.jsx(d,{data:t}):e.jsx("div",{className:"donut-legend",children:e.jsx("div",{className:`donut-chart-legend ${n}`,children:t.map(t=>e.jsxs("div",{className:"legend",style:{borderLeft:`0.188rem solid ${t.color}`},children:[e.jsx("div",{className:"legend-title",style:{color:`${t.labelColor}`},children:t.label}),e.jsx("div",{className:"legend-value",children:e.jsx(h.Typography,{type:"s5",weight:"medium",color:t.valueColor,style:{whiteSpace:"nowrap"},children:Zt(t.value,x)})})]},t.label))})})]})}):e.jsx("svg",{ref:m,width:l,height:a})},exports.DonutChart$1=({data:t,height:a=140,width:l=140,isUserDashbord:r,legend:n=!0,direction:o="horizontal",totalUsers:s,total:d=(r?s:"2.4 GB"),colors:c=Qt,titleProps:u={},valueProps:m={}})=>{const p=i.useRef(null);return i.useEffect(()=>{if(!p.current)return;const e=Ye.select(p.current);e.selectAll("*").remove();const r=Math.min(l,a)/2-6,n=Math.min(l,a)/2-12,o=e.append("g").attr("transform",`translate(${l/2}, ${a/2})`),i=Ye.pie().value(e=>(e=>{if("number"==typeof e)return e;const t=(null==e?void 0:e.match(/\d.+/))||null;return t?Number(t[0]):0})(e.value)),s=Ye.arc().outerRadius(r).innerRadius(n);o.selectAll(".arc").data(i(t)).enter().append("g").attr("class","arc").append("path").attr("d",s).attr("fill",(e,t)=>c[t%c.length]),o.append("text").attr("text-anchor","middle").attr("font-size","18px").attr("font-weight","600").attr("alignment-baseline","central").html(d)},[c,t,a,d,l]),n?e.jsx(e.Fragment,{children:e.jsxs("div",{className:`donut-chart-container ${o}`,children:[e.jsx("div",{children:e.jsx("svg",{ref:p,width:l,height:a})}),e.jsx("div",{className:"donut-chart-legend",children:t&&t.map((t,a)=>e.jsxs("div",{className:"legend",style:{borderLeft:`0.188rem solid ${c[a]}`},children:[e.jsx("div",{className:"legend-title",children:e.jsx(h.Typography,{type:"s5",color:"theme.secondary.800",...u,children:t.label})}),e.jsx("div",{className:"legend-value",children:e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.1000",children:e.jsx(h.Typography,{type:"s5",color:"theme.secondary.1000",weight:"bold",...m,children:t.value})})})]},t.label))})]})}):e.jsx("svg",{ref:p,width:l,height:a})},exports.DyanmicTextEditor=({formControl:a,name:l,fieldArrayName:r,placeholder:n})=>e.jsx(e.Fragment,{children:e.jsx(t.Controller,{name:`${r}.${l}`,control:a,render:({field:t,fieldState:a})=>{var l,r;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"editor-container",children:e.jsx(dt,{handleEditorReady:()=>{t.value&&t.onChange(t.value)},data:t.value,onEditorChange:e=>{t.onChange(e)},config:{placeholder:n}})}),(null==(l=a.error)?void 0:l.message)&&e.jsx(h.Typography,{color:"theme.error.600",type:"s5",children:null==(r=a.error)?void 0:r.message})]})}})}),exports.DynamicDateRange=it,exports.DynamicDateTime=st,exports.DynamicLayoutWrapper=({children:t,mainContentProps:a={},summaryContent:l,summaryProps:r={},maxGridSize:n=12,defaultSummaryExpanded:o=!0,expandedSummarySize:s=3,collapsedSummarySize:d=0,containerProps:c={},onLayoutChange:m,enableTransitions:p=!0,transitionDuration:h,transitionEasing:x,storageKey:g="grid-summary-panel-state"})=>{const y=u.useTheme(),v=u.useMediaQuery(y.breakpoints.down("md")),f=i.useCallback(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(g);return e?JSON.parse(e):o}return o},[o,g]),b=i.useMemo(()=>v||!f()?n:o?n-s:n-d,[v,f,n,o,s,d]),[j,w]=i.useState(b),C=i.useCallback((e,t)=>{if(v)return void w(n);const a=Math.max(1,Math.min(n-t,n));w(a),null==m||m(a,t,e)},[v,n,m]),S=i.useMemo(()=>{if(!p)return{};const e=h||y.transitions.duration.enteringScreen,t=x||y.transitions.easing.sharp;return{transition:y.transitions.create(["flex-basis","max-width"],{easing:t,duration:e})}},[p,y,h,x]),T={defaultExpanded:o,expandedGridSize:s,collapsedGridSize:d,persistState:!0,ariaLabel:"Toggle summary panel",...r,onToggle:C,children:l,storageKey:g};return e.jsxs(u.Grid,{container:!0,...c,children:[e.jsx(u.Grid,{item:!0,xs:j,sx:{...S,...a.sx},...a,children:t}),e.jsx(kt,{...T})]})},exports.DynamicModal=({open:t,onClose:a,title:r,children:n,handleSaveAction:i,buttons:s=[],...d})=>{const{t:c}=w.useTranslation(),m=s.length?[...s]:[{label:c("common.cancel"),onClick:a,variant:"outlined",sx:{color:"black !important"}},...i?[{label:c("common.save"),onClick:i,variant:"contained",color:"primary"}]:[]];return e.jsxs(o.Modal,{open:t,onClose:a,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,...d,children:[e.jsxs(u.DialogTitle,{id:"alert-dialog-title",className:"itemEntryModal--DialogTitle",children:[e.jsx(h.Typography,{type:"s3",color:"inherit",weight:"medium",children:c(r)}),e.jsx(u.IconButton,{onClick:a,children:e.jsx(l,{fontSize:"small"})})]}),e.jsx(u.DialogContent,{children:n}),e.jsx(u.DialogActions,{children:m.map((t,a)=>e.jsx(o.Button,{sx:{...t.sx},onClick:t.onClick,variant:t.variant,color:t.color,children:t.label},a))})]})},exports.DynamicRow=na,exports.ElementController=We,exports.EntityViewWrapper=function({fetchEntity:t,fallbackRoute:a,children:l,idField:r="id"}){const n=W.useParams(),o=W.useLocation(),s=W.useNavigate(),[d,c]=i.useState(null),[u,m]=i.useState(!0);return i.useEffect(()=>{(async()=>{m(!0);const e=N.getEntityId(n,o,r);if(e)try{const a=await t(e);c(a)}catch(l){console.error("Error fetching entity:",l),s(a)}finally{m(!1)}else s(a)})()},[t,n,o,s,a,r]),u?e.jsx(V.ErpLoader,{}):d?e.jsx(e.Fragment,{children:l(d)}):null},exports.ExpandableSummaryWrapper=kt,exports.FormData=[{field_type:"text",label:"Name",placeholder:"Enter name",default_value:"",min_length:2,max_length:30,is_multiline:!1,is_required:!0,is_unique:!1,id:"35356fb9-9007-495a-ba9e-925449cb3eb2"},{field_type:"email",label:"Email",placeholder:"Enter email address",default_value:"",is_required:!1,is_unique:!1,id:"4f4ac646-bf48-4ed3-ae5b-910071e19b59"},{field_type:"phone",label:"Phone",placeholder:"Enter phone number",default_value:"",is_required:!1,is_unique:!1,id:"500d8a78-e389-474d-831b-43190da011a6"},{field_type:"select",label:"Status",placeholder:"Choose option",default_value:"option1",options:[{text:"Active",value:"1"},{text:"Inactive",value:"0"}],is_multiselect:!1,is_required:!0,is_unique:!1,id:"fa44f220-0d82-4569-a28c-997de8e66d5a"},{field_type:"text",label:"Address",placeholder:"Enter address",default_value:"",min_length:2,max_length:30,is_multiline:!1,is_required:!0,is_unique:!1,id:"d25f2f1b-811f-4c3d-a53b-5162f766ad47"},{field_type:"text",label:"Message",placeholder:"Enter message",default_value:"",min_length:2,max_length:30,is_multiline:!1,is_required:!0,is_unique:!1,id:"22de0b1b-080a-4a0b-9d5f-e6f4916d8b07"}],exports.FormLoader=t=>e.jsx(ha,{children:e.jsx(pa,{size:50,...t})}),exports.Forms=({config:t})=>{const{t:a}=w.useTranslation();M.useAppTranslations();const l=W.useNavigate(),r=W.useLocation(),{user:o}=h.useAuth();console.log("user.........",o),ce.useApi();const[s,d]=i.useState({rows:[],isLoading:!1,paginationModel:{pageNo:1,limit:10,totalCount:0}}),[c,m]=i.useState(()=>{const e=localStorage.getItem("form-view");return e?JSON.parse(e):ra}),[p,x]=i.useState(""),[g,y]=i.useState(()=>{var e;return(null==(e=null==c?void 0:c[0])?void 0:e.label)||X.viewTypes.TABLE}),[v,f]=i.useState(la),[b,C]=i.useState([]),S=i.useMemo(()=>r.pathname.split("/")[2],[r.pathname]),k=i.useMemo(()=>({...t}),[t]),_=i.useMemo(()=>k[S]||{filterName:"",redirectionPath:""},[S,k]);console.log("external moduleConfig..........",_);const D=i.useMemo(()=>`/dashboard/${S}${_.redirectionPath}`,[S,_.redirectionPath]),A=i.useMemo(()=>`(company_id.eq=${null==o?void 0:o.company_id}&module.eq=${_.filterName})`,[null==o?void 0:o.company_id,_.filterName]),N=i.useMemo(()=>{const{pageNo:e,limit:t,totalCount:a}=s.paginationModel;return{total:t?Math.ceil(a/t):0,skip:t*(e-1),pageNo:e,limit:t}},[s.paginationModel]),B=i.useCallback(e=>e?e.split(/[:_-]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):e,[]),R=i.useCallback(e=>{f(e.slice(1))},[]),E=i.useCallback(e=>{d(t=>({...t,paginationModel:{...e,totalCount:t.paginationModel.totalCount}}))},[]),I=i.useCallback(e=>{x(e)},[]),P=i.useCallback(e=>{l(D,{state:e})},[l,D]),F=i.useMemo(()=>[{accessorKey:"name",header:"Form Name",visible:!0,Cell:({row:t})=>{var a;return(null==(a=null==t?void 0:t.original)?void 0:a.name)?e.jsx("div",{onClick:()=>P(t.original),style:{cursor:"pointer"},children:B(t.original.name)}):"-"}},{accessorKey:"fields.length",header:"No. of Fields",visible:!0,size:150},{accessorKey:"fields",header:"No. of custom fields",visible:!0,size:80,Cell:({row:t})=>{var a;return(null==(a=null==t?void 0:t.original)?void 0:a.fields)?e.jsx("div",{children:t.original.fields.filter(e=>!e.is_system_field).length}):"-"}},{accessorKey:"fields",header:"Custom Fields",visible:!0,Cell:({row:t})=>{var l,r;const n=(null==(r=null==(l=null==t?void 0:t.original)?void 0:l.fields)?void 0:r.filter(e=>!(null==e?void 0:e.is_system_field)&&(null==e?void 0:e.label)))||[];return n.length?e.jsxs(u.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexWrap:"wrap",p:.5},children:[n.slice(0,5).map((t,l)=>{var r;return e.jsx(h.Typography,{type:"s5",weight:"medium",className:"forms--CustomField",children:(null==(r=null==t?void 0:t.label)?void 0:r.includes("."))?a(t.label):t.label},`${t.label}-${l}`)}),n.length>5&&e.jsxs(h.Typography,{type:"s5",weight:"medium",className:"forms--CustomField",children:["+",n.length-5," more"]})]}):"-"}}],[B,P,a]),$=i.useMemo(()=>[{name:"Default",_id:1,data:[]}],[]),z=i.useCallback(async()=>{var e,t,a;if(console.log("moduleConfig.............",_),!_.filterName||!(null==o?void 0:o.company_id))return;const l=null==b?void 0:b[0],r={skip:N.skip,limit:N.limit,search:p,filters:A,...l&&{order:`${l.id}:${l.desc?-1:1}`},...j.getToken(),"x-timezone":(null==(e=j.getToken()["x-timezone"])?void 0:e.toString())||""};console.log("params..............",r),d(e=>({...e,isLoading:!0}));const n=await T.getV1FormBuilder({...r,...j.getToken});console.log("response........",n),d({rows:null==(t=null==n?void 0:n.data)?void 0:t.form,isLoading:!1,paginationModel:{...s.paginationModel,...null==(a=null==n?void 0:n.data)?void 0:a.pagination}})},[A,N.skip,N.limit,b,p,_.filterName,null==o?void 0:o.company_id]);return i.useEffect(()=>{z()},[z]),i.useEffect(()=>{(null==c?void 0:c.length)&&c[0].label!==g&&y(c[0].label)},[c]),i.useEffect(()=>{if(null==c?void 0:c.length){const e=setTimeout(()=>{localStorage.setItem("form-view",JSON.stringify(c))},300);return()=>clearTimeout(e)}},[c]),e.jsxs("section",{className:"forms",children:[e.jsx(n.ActionBar,{title:"Form",button:!1,data:c,setData:m,active:g,setActive:e=>{y(e)},handleSearch:I,showFilter:!1}),g===X.viewTypes.TABLE&&e.jsx(n.MaterialTable,{enablePagination:!1,columnOrder:["mrt-row-select",...v],handleColumnOrdering:R,rows:s.rows,columns:F,totalPages:1,paginationModel:{pageNo:1,limit:10},enableEditing:!1,states:{sorting:b||[]},onSortingChange:C,disableDefaultActionColumn:!0,getSelectedData:()=>{}}),g===X.viewTypes.GRID&&e.jsx(aa,{data:s.rows,config:t}),e.jsx(n.Footer,{pages:$,setPages:()=>{},currentPage:1,setCurrentPage:()=>{},total:N.total,paginationModel:{pageNo:s.paginationModel.pageNo,limit:s.paginationModel.limit},handlePaginationModel:E,sharedPages:[],resource:"",savePageConfiguration:()=>{},handlePageDelete:()=>{},enablePages:!1,isPaginationDisplayed:!0})]})},exports.GanttChart=t=>{var a,l,r,n,o,s,d,c,u,m,p,h;const{data:x,showList:g,progressChange:y,dateChange:v}=t,f=H(),b=x,[j,w]=i.useState(b),C=null==(l=null==(a=null==f?void 0:f.palette)?void 0:a.theme)?void 0:l.tertiary6[300],S=null==(n=null==(r=null==f?void 0:f.palette)?void 0:r.theme)?void 0:n.tertiary6[200],T=null==(s=null==(o=null==f?void 0:f.palette)?void 0:o.theme)?void 0:s.tertiary4[700],k=null==(c=null==(d=null==f?void 0:f.palette)?void 0:d.theme)?void 0:c.tertiary3[400],_=null==(m=null==(u=null==f?void 0:f.palette)?void 0:u.theme)?void 0:m.tertiary3[300],D=null==(h=null==(p=null==f?void 0:f.palette)?void 0:p.theme)?void 0:h.tertiary5[400];return e.jsx(K.Gantt,{tasks:j,viewMode:K.ViewMode.Day,listCellWidth:g?"190px":"",columnWidth:80,barCornerRadius:8,fontSize:"12",fontFamily:"Inter",onProgressChange:y?e=>{if(y){const t=b.findIndex(t=>t.id===e.id),a=[...b];a[t]=e,w(a)}}:void 0,onDateChange:v?e=>{if(v){const t=b.findIndex(t=>t.id===e.id),a=[...b];a[t]=e,w(a)}}:void 0,barProgressColor:C,barProgressSelectedColor:C,barBackgroundColor:S,barBackgroundSelectedColor:S,milestoneBackgroundColor:T,milestoneBackgroundSelectedColor:T,projectBackgroundColor:_,projectBackgroundSelectedColor:_,projectProgressColor:k,projectProgressSelectedColor:k,todayColor:D,onExpanderClick:e=>{w(t=>t.map(t=>t.id===e.id?e:t))}})},exports.GeneralScheduleReport=({module:t="accounting",title:a="Schedule report"})=>{const[l,r]=i.useState({pageNo:1,limit:10,totalCount:0}),[s,m]=i.useState(null),[p,x]=i.useState(!0),[g,y]=i.useState(!1),[v,f]=i.useState(null);console.log("🚀 ~ GeneralScheduleReport ~ openScheduleModal:",v);const[b,C]=i.useState(!1),[k,D]=i.useState(null),[M,A]=i.useState([]),N=null==l?void 0:l.limit,B=N?Math.ceil((null==l?void 0:l.totalCount)/N):0,R=N*((null==l?void 0:l.pageNo)-1)||0,{t:E}=w.useTranslation(),I=i.useMemo(()=>S.transformTableColumns({columns:Rt,currencySymbol:void 0,translationFn:E,enableFooter:!0,redirectionLink:void 0,redirectionLinkState:void 0,rows:M,statusClasses:"scheduleReport--StatusChip--",customizeValue:(t,a,l)=>"emails"===a?(t=>{const a=null==t?void 0:t.split(",");return a?e.jsx(u.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:a.map(t=>e.jsx(S.Chip,{type:"normal",label:e.jsx(h.Typography,{type:"s4",weight:"medium",color:"inherit",children:t})},t))}):"-"})(l):l}),[Rt,M,E]),P=i.useCallback(async()=>{try{y(!0);const{data:e={},pagination:a}=await(async e=>{try{return await T.getV1ReportsScheduleReport(e)}catch(t){console.log("error",t)}})({...j.getToken(),skip:R,limit:N,filters:`(type.eq=${t})`});A(null==e?void 0:e.schedulers),r(e=>({...e,...a}))}catch(e){const t=j.getErrorMessage(null==e?void 0:e.message);m({type:"alert",message:t})}finally{y(!1),x(!1)}},[N,R,t,r]),F=i.useCallback(async()=>{P()},[]);return i.useEffect(()=>{P()},[P]),e.jsxs("section",{className:"scheduleReport",children:[e.jsx(u.Box,{p:2,display:"flex",alignItems:"center",justifyContent:"space-between",children:e.jsx(h.Typography,{type:"h3",weight:"bold",color:"inherit",children:a})}),p?e.jsx(V.ErpLoader,{}):e.jsx(e.Fragment,{children:(null==M?void 0:M.length)>0?e.jsxs(e.Fragment,{children:[e.jsx(n.MaterialTable,{rows:M||[],columns:I,totalPages:0,columnOrder:["mrt-row-select"],states:{isLoading:g},enableColumnDragging:!0,enableEditing:!1,isResetRow:!1,enableRowSelection:!1,paginationModel:{pageNo:1,limit:10},defaultActionColumnItems:[e.jsx(u.IconButton,{onClick:({row:e})=>f(null==e?void 0:e.original),children:e.jsx(_.Edit,{fontSize:"small",htmlColor:"#292D32"})}),e.jsx(u.IconButton,{onClick:({row:e})=>D(null==e?void 0:e.original),children:e.jsx(_.Trash,{fontSize:"small",htmlColor:"#292D32"})})]}),e.jsx(n.Footer,{total:B,paginationModel:{...l,limit:null==l?void 0:l.limit},handlePaginationModel:e=>{r(e)},resource:"purchase-request",enablePages:!1})]}):e.jsx(e.Fragment,{children:!M.length&&e.jsx(n.Fallback,{heading:"No schedule report",subHeading:"Add schedule report",icon:e.jsx("img",{src:d.images.reportsFallback}),children:e.jsx(o.Button,{variant:"contained",startIcon:e.jsx(c.Add,{}),onClick:()=>f(!0),children:"Add"})})})}),e.jsx(o.Toast,{open:Boolean(s),type:null==s?void 0:s.type,message:null==s?void 0:s.message,handleClose:()=>m(null),anchorOrigin:{horizontal:"right",vertical:"bottom"}}),e.jsx(Ot,{isOpen:Boolean(v),onClose:()=>f(null),itemData:v,onSubmit:F,module:t}),e.jsx(o.ConfirmPopUp,{open:Boolean(k),onClose:()=>D(null),onConfirm:async()=>{try{k&&(C(!0),await(async e=>{try{const{data:t={}}=await T.deleteV1ReportsScheduleReportId(e);return t}catch(t){console.log("error",t)}})({...j.getToken(),id:k.id}),m({type:"normal",message:"Report schedule deleted successfully"}),P(),D(null))}catch(e){const t=j.getErrorMessage(null==e?void 0:e.message);m({type:"alert",message:t})}finally{C(!1)}},title:"Delete schedule report",loading:b,description:`Are you sure you want to delete schedule report: ${null==k?void 0:k.name} ?`})]})},exports.GridCard=aa,exports.GridCard$1=t=>e.jsx(e.Fragment,{children:t.data.map(t=>e.jsx(ea,{data:t}))}),exports.GridFallback=t=>{const{heading:a="",subHeading:l="No data available",icon:r=e.jsx("img",{src:d.images.invoiceFallback}),children:n,...o}=t;return e.jsxs(u.Box,{className:"fallback",...o,children:[r,e.jsx(h.Typography,{type:"h5",weight:"medium",color:"theme.secondary.1000",className:"fallback--Text",children:a}),e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.secondary.800",className:"fallback--Text",children:l}),e.jsx("div",{children:n})]})},exports.GridWrapper=ta,exports.GroupedBarChart=({chartData:t,height:a=500,barWidth:l=40,margin:r={top:40,right:20,bottom:40,left:50},line:n=!1})=>{var o;const s=i.useRef(null),d=i.useRef(null),c=i.useRef(null),[u,m]=i.useState(0),p=i.useMemo(()=>Math.max(...t.map(e=>e.data.map(e=>e.value)).flat()),[t]),x=t.length>12,g=x?Math.max(120*t.length,u):u,{user:y}=h.useAuth(),v=(null==(o=null==y?void 0:y.currency_data)?void 0:o.symbol)||"";return i.useEffect(()=>{const e=d.current,t=new ResizeObserver(e=>{if(e[0]){const t=e[0].contentRect.width;m(t)}});return e&&t.observe(e),()=>{e&&t.unobserve(e)}},[]),i.useEffect(()=>{if(0===u)return;const e=g-r.left-r.right,o=p?a-r.top-r.bottom:0;Ye.select(s.current).selectAll("*").remove();const i=Ye.select(s.current).attr("height",a).append("g").attr("transform",`translate(${r.left}, ${p?r.top:a-50})`),d=Ye.scaleBand().domain(t.map(e=>e.month)).range([0,e]).padding(.2),c=Ye.scaleBand().domain(["Total Transaction","Total Value","Average Value"]).range([0,d.bandwidth()]).padding(.1),m=Ye.scaleLinear().domain([0,Ye.max(t,e=>Ye.max(e.data,e=>e.value))]).nice().range([o,0]),h=i.append("g").attr("class","x-axis").attr("transform",`translate(0, ${o})`).call(Ye.axisBottom(d).tickPadding(20));i.append("g").attr("class","y-axis").call(Ye.axisLeft(m).tickPadding(10).tickFormat(e=>{return t=e,`${v} ${Ye.format(".2s")(t).replace("k","K")}`;var t})).select(".domain").attr("stroke","none"),h.select(".domain").attr("stroke","none"),n&&i.selectAll(".grid-line").data(m.ticks()).enter().append("line").attr("class","grid-line").attr("x1",0).attr("x2",e).attr("y1",e=>m(e)).attr("y2",e=>m(e)).style("stroke","#ddd").style("stroke-dasharray","3,3").style("stroke-width",1),i.selectAll(".month-group").data(t).enter().append("g").attr("class","month-group").attr("transform",e=>`translate(${d(e.month)}, 0)`).selectAll("rect").data(e=>e.data).enter().append("rect").attr("x",e=>c(e.type)+(c.bandwidth()-l)/2).attr("y",e=>m(e.value)).attr("width",l).attr("height",e=>o-m(e.value)).attr("fill",e=>e.color).attr("rx",5).attr("ry",5)},[t,l,a,g,u,n,r,v,p]),e.jsx("div",{ref:d,style:{width:"100%",height:"100%"},children:e.jsx("div",{style:{position:"relative"},children:e.jsx("div",{ref:c,style:{width:"100%",overflowX:x?"auto":"hidden",overflowY:"hidden"},children:e.jsx("svg",{ref:s,width:g,height:a,viewBox:`0 0 ${g} ${a}`,style:{display:"block"}})})})})},exports.HrLine=t=>{const{title:a}=t;return e.jsxs("div",{className:"HrLine",children:[e.jsx("hr",{className:"HrLine--Length"}),a,e.jsx("hr",{className:"HrLine--Length"})]})},exports.InventoryReportsTitleBar=t=>{const{title:a,handleAddButton:l,buttons:r=[],dropdownMenuButtonData:s,isTitleMenu:c=!1,titleMenus:m=[],reportFilterFields:x=[],toggleCallback:g,tabs:y,activeValue:v,setActiveValue:f,isDateFilterEnabled:b,onDateFilterChange:w,filters:C={},isDateRange:S=!0,activeView:T="",setActiveView:k,handleSearch:D,showLevelBtn:M=!1,handleRowsExpand:A,handleRowsCollapse:B,customElement:R,showLeftContent:E=!0,isViewButton:I=!1,handleRedirect:P,buttonText:F="",dataLength:$,filterDropDown:z=[],filterKeys:q,customFilterConfig:O=[],customSelectedFilter:L=[],showDateFilter:Y=!0,customFilterComponents:W=[]}=t,V=[...Y?[{value:"date"}]:[],{value:"location"},{value:"company"}],K=[{key:"company",label:"Search Company",placeholder:"Company",apiType:"company",valueKey:(null==q?void 0:q.company)?q.company:"company",customFilter:null},{key:"assembly_item",label:"Search Assembaly Items",placeholder:"Assembaly Items",apiType:"assemblyItems",valueKey:(null==q?void 0:q.assembly_item)?q.assembly_item:"assembly_item_id"},{key:"item",label:"Search Items",placeholder:"Items",apiType:"reportItems",valueKey:(null==q?void 0:q.item)?q.item:"item_id",multiple:!0},{key:"location",label:"Search Warehouse Location",placeholder:"Warehouse Location",apiType:"location",valueKey:(null==q?void 0:q.location)?q.location:"warehouse_id",customFilter:null,multiple:!0},{key:"bom",label:"Search Bill of Materials",placeholder:"Filter Bill of Materials",apiType:"bom",valueKey:(null==q?void 0:q.bom)?q.bom:"bom_id",customFilter:null,multiple:!0},{key:"work_order",label:"Search Work Order",placeholder:" Work Order",apiType:"workOrder",valueKey:(null==q?void 0:q.work_order)?q.work_order:"work_order_id",customFilter:null,multiple:!0},{key:"routing",label:"Search Routing",placeholder:" Routing",apiType:"routing",valueKey:(null==q?void 0:q.routing)?q.routing:"routing_id",customFilter:null,multiple:!0},{key:"operation",label:"Search Operation",placeholder:" Operation",apiType:"operations",valueKey:(null==q?void 0:q.operation)?q.operation:"operation_id",customFilter:null,multiple:!0},{key:"equipment",label:"Search Equipment",placeholder:" Equipment",apiType:"equipment",valueKey:(null==q?void 0:q.equipment)?q.equipment:"equipment_id",customFilter:null,multiple:!0},{key:"work_center",label:"Search Work Center",placeholder:" Work Center",apiType:"workCenter",valueKey:(null==q?void 0:q.work_center)?q.work_center:"work_center_id",customFilter:null,multiple:!0}],H=i.useMemo(()=>[...K,...O],[]),J={border:"none","&.Mui-focused":{borderColor:"transparent"},"& .MuiOutlinedInput-input":{padding:"0px",fontSize:"14px",color:"#289b64"},"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiSelect-icon":{color:"green"}},Q=e=>{if(w)if(Y)w(e);else{const{start_date:t,end_date:a,as_of_date:l,...r}=e;w(r)}},[Z,ee]=i.useState([]),[te,ae]=i.useState("TODAY"),[le,re]=i.useState(!1),[ne,oe]=i.useState(new Date(p((null==C?void 0:C.as_of_date)||"").format("YYYY-MM-DD"))),ie=i.useMemo(()=>[...V,...L],[]),[se,de]=i.useState(ie),[ce,ue]=i.useState(1),[me,pe]=i.useState({startDate:new Date(p((null==C?void 0:C.start_date)||"").format("YYYY-MM-DD")),endDate:new Date(p((null==C?void 0:C.end_date)||"").format("YYYY-MM-DD")),key:"selection"}),he=i.useRef(null),[xe,ge]=i.useState(null),ye=i.useRef(null),ve=i.useRef(null),fe=()=>{he.current=null,re(!1)},be=e=>{if(Y)if(ae(e),"CUSTOM"===e)he.current=ye.current,re(!0);else{const t=N.handleCompareDateRangeSync({range:N.RANGE[e],from:"",to:""});Q({start_date:(null==t?void 0:t.from)?null==t?void 0:t.from:"",end_date:(null==t?void 0:t.to)?null==t?void 0:t.to:""}),fe()}},je=e=>{he.current&&he.current.contains(e.target)||fe()},we=[{label:N.RANGE.TODAY,callback:()=>{be("TODAY")}},{label:N.RANGE.THIS_WEEK,callback:()=>{be("THIS_WEEK")}},{label:N.RANGE.THIS_MONTH,callback:()=>{be("THIS_MONTH")}},{label:N.RANGE.THIS_QUARTER,callback:()=>{be("THIS_QUARTER")}},{label:N.RANGE.THIS_YEAR,callback:()=>{be("THIS_YEAR")}},{label:N.RANGE.YESTERDAY,callback:()=>{be("YESTERDAY")}},{label:N.RANGE.PREVIOUS_WEEK,callback:()=>{be("PREVIOUS_WEEK")}},{label:N.RANGE.PREVIOUS_MONTH,callback:()=>{be("PREVIOUS_MONTH")}},{label:N.RANGE.PREVIOUS_QUARTER,callback:()=>{be("PREVIOUS_QUARTER")}},{label:N.RANGE.PREVIOUS_YEAR,callback:()=>{be("PREVIOUS_YEAR")}},{label:N.RANGE.CUSTOM,callback:()=>{be("CUSTOM")}}],Ce=()=>{const e={start_date:p(me.startDate).format("YYYY-MM-DD"),end_date:p(me.endDate).format("YYYY-MM-DD")},t={as_of_date:p(ne).format("YYYY-MM-DD")};Q({...S?e:t}),fe()};function Se(e){return se.some(t=>(null==t?void 0:t.value)==e)}return i.useEffect(()=>{oe(new Date(p((null==C?void 0:C.as_of_date)||"").format("YYYY-MM-DD")))},[null==C?void 0:C.as_of_date]),i.useEffect(()=>{pe({...me,startDate:new Date(p((null==C?void 0:C.start_date)||"").format("YYYY-MM-DD")),endDate:new Date(p((null==C?void 0:C.end_date)||"").format("YYYY-MM-DD"))})},[null==C?void 0:C.end_date,null==C?void 0:C.start_date]),i.useEffect(()=>{le&&(S?pe({...me,startDate:new Date(p((null==C?void 0:C.start_date)||"").format("YYYY-MM-DD")),endDate:new Date(p((null==C?void 0:C.end_date)||"").format("YYYY-MM-DD"))}):oe(new Date(p((null==C?void 0:C.as_of_date)||"").format("YYYY-MM-DD"))))},[le,S]),i.useEffect(()=>{ee(j.generateFields(x))},[x]),e.jsxs("div",{children:[e.jsxs("div",{className:"inventoryReportsTitleBar",children:[E&&e.jsxs("div",{className:"inventoryReportsTitleBar--LeftContent",children:[c?e.jsx("div",{style:{zIndex:999},children:e.jsx(n.TitleDropdownButton,{onClick:l,options:m,isMenuThirdItemDisabled:!0,children:a})}):e.jsx(h.Typography,{type:"h3",weight:"medium",color:"theme.secondary.1000",children:a}),[{label:X.viewTypes.TABLE,position:1},{label:X.viewTypes.CHART,position:2}].map(e=>e).sort((e,t)=>e.position-t.position).map(t=>e.jsx(n.HeaderCard,{title:null==t?void 0:t.label,active:T,onClick:()=>null==k?void 0:k(t.label)},null==t?void 0:t.position))]}),I&&e.jsx("div",{className:"inventoryReportsTitleBar--ExtraButtonUi",children:e.jsx(o.Button,{onClick:P,children:F})}),e.jsx(_t,{zIndex:999,className:"inventoryReportsTitleBar--RightContent",buttons:r,dropdownMenuButtonData:s,toggleCallback:g,variant:"contained",iconPosition:"end"}),R&&e.jsx(u.Box,{children:R})]}),e.jsx(u.Divider,{sx:{mb:2,mx:1,borderColor:"grey.200"}}),(null==y?void 0:y.length)?e.jsx("div",{children:e.jsx(n.TabBar,{tabs:y||[],activeValue:v,setActiveValue:f})}):null,e.jsxs(u.Box,{sx:{display:"flex",justifyContent:"space-between",gap:1,flexWrap:"wrap",mx:1},children:[e.jsxs("div",{className:"inventoryReportsTitleBar--FilterWrapper",children:[Y&&Se("date")&&S&&e.jsx("div",{style:{display:"flex",gap:"8px"},children:e.jsxs("div",{className:"inventoryReportsTitleBar--FilterWrapper--Chip",ref:ve,onClick:()=>{le?fe():(he.current=ve.current,re(!0))},children:[e.jsxs("div",{className:"inventoryReportsTitleBar--FilterWrapper--Chip--Text",title:`${p(null==C?void 0:C.start_date).format("DD/MM/YYYY")} - ${p(null==C?void 0:C.end_date).format("DD/MM/YYYY")}`,children:[e.jsx(h.Typography,{type:"s4",weight:"medium",children:"Date Range:"}),e.jsxs(h.Typography,{className:"inventoryReportsTitleBar--FilterWrapper--Chip--Text--Value",type:"s4",children:[p(null==C?void 0:C.start_date).format("DD/MM/YYYY")," -"," ",p(null==C?void 0:C.end_date).format("DD/MM/YYYY")]})]}),e.jsx(U,{})]})}),Y&&Se("date")&&(null==C?void 0:C.as_of_date)&&!S&&e.jsx("div",{style:{display:"flex",gap:"8px"},children:e.jsxs("div",{className:"inventoryReportsTitleBar--FilterWrapper--Chip",ref:ve,onClick:()=>{le?fe():(he.current=ve.current,re(!0))},children:[e.jsxs("div",{className:"inventoryReportsTitleBar--FilterWrapper--Chip--Text",title:`${p(null==C?void 0:C.as_of_date).format("DD/MM/YYYY")}`,children:[e.jsx(h.Typography,{type:"s4",weight:"medium",children:"Date:"}),e.jsx(h.Typography,{className:"inventoryReportsTitleBar--FilterWrapper--Chip--Text--Value",type:"s4",children:p(null==C?void 0:C.as_of_date).format("DD/MM/YYYY")})]}),e.jsx(U,{})]})}),e.jsxs(e.Fragment,{children:[H.map(({key:t,label:a,placeholder:l,apiType:r,valueKey:o,customFilter:i,multiple:s=!1})=>Se(t)?e.jsx("div",{className:"search-filter",children:e.jsx(n.SearchableSelect,{labelId:`${t}-label`,searchPlaceholder:a,value:null==C?void 0:C[o],onChange:e=>Q({[o]:e.target.value}),apiType:r,multiple:s,placeholder:l,customeFilter:i,customStyle:Dt,inputStyle:J})},t):null),W.map(({key:t,component:a})=>e.jsx(i.Fragment,{children:a},t))]})]}),b&&Y&&e.jsxs("div",{className:"inventoryReportsTitleBar--FilterAction",children:["(",e.jsxs(e.Fragment,{children:[e.jsx(_t,{zIndex:997,className:"inventoryReportsTitleBar--RightContent",dropdownMenuButtonData:{icon:e.jsx("img",{src:d.images.sidebar.calendar2}),children:e.jsxs(e.Fragment,{children:[N.RANGE[te],e.jsx(U,{})]}),options:we},toggleCallback:g}),e.jsx("div",{ref:ye})]}),")"]}),e.jsxs("div",{className:"inventoryReportsTitleBar--FilterAction",children:[e.jsx(o.Button,{sx:({palette:e})=>({border:"1px solid",borderColor:"grey.200",borderRadius:"50px",color:`${e.grey[800]} !important`,"&:hover":{bgcolor:`${e.grey[200]} !important`}}),variant:"text",startIcon:e.jsx(_.Filter,{fontSize:"small"}),onClick:e=>ge(e.currentTarget),children:"Filter"}),M&&e.jsx(u.Divider,{flexItem:!0,orientation:"vertical",sx:{alignSelf:"auto"}}),e.jsx(u.Menu,{anchorEl:xe,open:Boolean(xe),onClose:()=>{ge(null)},children:null==z?void 0:z.map(t=>{return e.jsxs(u.MenuItem,{onClick:()=>{return e=t,void(se.some(t=>t.value==e.value)?de(se.filter(t=>(null==t?void 0:t.value)!=e.value)):de([...se,e]));var e},value:null==t?void 0:t.value,children:[e.jsx(n.Checkbox,{checked:(a=t,se.some(e=>(null==e?void 0:e.value)==(null==a?void 0:a.value)))}),e.jsx(h.Typography,{sx:{marginLeft:"10px"},color:"theme.neutral.800",type:"s3",children:null==t?void 0:t.name})]},t);var a})}),M&&e.jsx(e.Fragment,{children:e.jsxs(u.Box,{className:"inventoryReportsTitleBar--FilterAction--lvWrapper",children:[e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"grey.800",children:[" Level ",ce," of ",$]}),e.jsxs(u.ButtonGroup,{variant:"outlined",disableElevation:!0,sx:({palette:e})=>({"& .MuiButton-root":{borderColor:`${e.grey[200]} !important`,"&:hover":{bgcolor:`${e.grey[200]} !important`}},"& .MuiButtonGroup-firstButton":{borderTopLeftRadius:20,borderBottomLeftRadius:20},"& .MuiButtonGroup-lastButton":{borderTopRightRadius:20,borderBottomRightRadius:20}}),children:[e.jsx(u.Button,{onClick:()=>{ue(ce==$?ce:ce+1),null==B||B(ce)},children:e.jsx("img",{src:d.images.common.expand})}),e.jsx(u.Button,{onClick:()=>{ue(1!=ce?ce-1:1),null==A||A(ce)},children:e.jsx("img",{src:d.images.common.collapse})})]})]})}),e.jsx(o.SearchBar,{placeholder:"Search",handleSearch:e=>null==D?void 0:D(e),sx:{width:"250px",background:"#fff !important",border:"1px solid #F3F2F2 !important"}})]})]}),e.jsx(u.Divider,{sx:{my:2,mx:1,borderColor:"grey.200"}}),e.jsx(u.Popper,{sx:{zIndex:9999},open:le,anchorEl:he.current,role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:t,placement:a})=>e.jsx(u.Grow,{...t,style:{margin:"0 20px 0 20px",transformOrigin:"bottom"===a?"center top":"center bottom"},children:e.jsx(u.Paper,{children:e.jsx(u.ClickAwayListener,{onClickAway:je,children:e.jsxs(u.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end"},children:[e.jsx("div",{children:S?e.jsx(G.DateRange,{editableDateInputs:!0,onChange:e=>pe(e.selection),moveRangeOnFirstSelection:!1,ranges:[me],locale:tt}):e.jsx(G.Calendar,{onChange:e=>oe(e),date:ne,locale:tt})}),e.jsx(u.Box,{sx:{padding:"0 12px 12px 0"},children:e.jsx(o.Button,{variant:"contained",sx:{width:"fit-content"},onClick:Ce,children:"Apply"})})]})})})})})]})},exports.ItemResponseDetails=t=>{var a;const{isOpen:l,onClose:r,data:s,isRental:d=!1}=t,[m,p]=i.useState([]),[x,g]=i.useState(!1),{t:y}=w.useTranslation(),v=i.useCallback(async()=>{if(l)try{g(!0);const e=`(rfq_line_item_id.in=${[null==s?void 0:s.id]})`,t=d?await j.fetchRentalResponseItems(e):await j.fetchRfqItemsByIdForResponse(e);p(t)}catch(e){const t=j.getErrorMessage(null==e?void 0:e.message);k.enqueueSnackbar(t,{variant:"error"})}finally{setTimeout(()=>g(!1),300)}},[l,null==s?void 0:s.id,d]);return i.useEffect(()=>{v()},[v]),e.jsxs(o.Modal,{open:l,onClose:r,maxWidth:"md",fullWidth:!0,children:[x&&e.jsx(n.ModalLoader,{}),e.jsxs(u.DialogTitle,{className:"itemEntryModal--DialogTitle",children:[e.jsx(h.Typography,{type:"s3",color:"inherit",weight:"medium",children:"Response Details"}),e.jsx(u.IconButton,{onClick:r,children:e.jsx(c.Close,{fontSize:"small"})})]}),e.jsx(u.Grid,{container:!0,children:e.jsx(u.Grid,{item:!0,xs:4,children:e.jsxs(u.Box,{sx:{display:"flex",padding:2,flexDirection:"column"},children:[e.jsx(h.Typography,{type:"s5",weight:"medium",color:"theme.secondary.800",children:"Item"}),e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.neutral.1000",children:null==(a=null==s?void 0:s.item_data)?void 0:a.name})]})})}),e.jsx(u.Grid,{container:!0,p:2,spacing:3,children:e.jsx(u.Grid,{item:!0,xs:12,children:e.jsx(u.Box,{sx:{paddingTop:"1.2rem"},children:e.jsx(n.MaterialTable,{rows:m||[],columns:S.transformTableColumns({columns:j.responseItemDetailsColumns,currencySymbol:void 0,translationFn:y,customizeValue:(e,t,a)=>{var l,r;if("item_data.vendor_info.vendor_name"===t)return a||(null==(r=null==(l=null==e?void 0:e.original)?void 0:l.item_data)?void 0:r.name)}}),paginationModel:{pageNo:1,limit:10},totalPages:20,enableColumnDragging:!0,isResetRow:!1,enableEditing:!1,columnOrder:["mrt-row-select"],enableRowSelection:!1,disabledDefaultActionColumnIcon:!0,enableBottomToolbar:!1})})})})]})},exports.LabelValue=({key:t,label:a,children:l})=>e.jsxs(u.Box,{gap:1,flexDirection:"column",display:"flex",children:[e.jsx(h.Typography,{type:"s3",weight:"bold",color:"theme.secondary.1000",children:a}),l]},t),exports.LineChart=({data:t,numOfLines:a=5,width:l=500,height:r=300})=>{const n=i.useRef(null),o=i.useRef(null),s=i.useMemo(()=>Math.max(...t.map(e=>e.value)),[t]),d=i.useMemo(()=>1.25*s,[s]),c=i.useMemo(()=>{const e=[],t=d/a;for(let l=0;l<=a;l++)e.push(t*l);return e},[d,a]),u=t.length>12?Math.max(120*t.length,l):l;return i.useEffect(()=>{const e=o.current,t=new ResizeObserver(e=>{if(e[0]){const t=e[0].contentRect.width;setContainerWidth(t)}});return e&&t.observe(e),()=>{e&&t.unobserve(e)}},[]),i.useEffect(()=>{const e=Ye.select(n.current);e.selectAll("*").remove();const a=u-40-20,o=r-20-70,i=Ye.scaleBand().domain(t.map(e=>e.label)).range([0,a]).padding(.1),s=Ye.scaleLinear().domain([0,Ye.max(t,e=>e.value)]).range([o,0]),d=e.append("g").attr("transform","translate(40,20)"),m=Ye.line().x(e=>i(e.label)+i.bandwidth()/2).y(e=>s(e.value));d.append("path").datum(t).attr("class","line").attr("d",m).style("fill","none").style("stroke","#357AF6").style("stroke-width",2),d.selectAll(".point").data(t).enter().append("circle").attr("class","point").attr("cx",e=>i(e.label)+i.bandwidth()/2).attr("cy",e=>s(e.value)).attr("r",4).style("fill","#357AF6").on("mousemove",(e,t)=>{const a=e.offsetX+40-25,l=e.offsetY+20-40,r=`${t.label} - ${t.value}`;h.attr("x",a).attr("y",l).style("opacity",9).style("height",r.length>=16?50:35),x.html(r)}).on("mouseleave",()=>{h.style("opacity",0)}),c.slice(1).forEach(e=>{d.append("line").attr("class","dotted-line").attr("x1",0).attr("y1",s(e)).attr("x2",l).attr("y2",s(e)).style("stroke","gray").style("stroke-dasharray","3,3")}),d.append("g").attr("class","x-axis").attr("transform",`translate(0, ${o})`).call(Ye.axisBottom(i)).selectAll(".tick line").remove();const p=d.append("g").attr("class","y-axis").call(Ye.axisLeft(s).tickValues(c).tickFormat(e=>{return(t=e)>=1e9?(t/1e9).toFixed(1)+"B":t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t;var t}).tickSizeOuter(0),0);p.selectAll(".domain").remove(),p.selectAll(".tick line").remove();const h=e.append("foreignObject").attr("class","tooltip").attr("width",120).attr("height",20).style("opacity",0).style("position","absolute").style("background-color","white").style("border","none").style("box-shadow","0rem 0rem 0.469rem 0rem rgba(0, 0, 0, 0.15)").style("border-radius","0.313rem").style("padding","0.625rem").style("font-size","0.75rem"),x=h.append("xhtml:div").style("font-size","0.75rem").style("color","black")},[t,r,l,d,c,u]),e.jsx("div",{ref:o,style:{width:"100%",height:"100%"},children:e.jsx("svg",{ref:n,width:u,height:r,viewBox:`0 0 ${u} ${r}`})})},exports.List=t=>{const[a,l]=i.useState(!1),[r,n]=i.useState(t.header),[o,s]=i.useState(t.tableData),[d,c]=i.useState(),[u,m]=i.useState(!0),p=i.useCallback(()=>l(!1),[]),h=ne.useExtraCells(),x=i.useCallback((e,t)=>{n(a=>{const l=r.findIndex(t=>t.title===e.title),n=[...a];return n.splice(l,1,{...a[l],width:t}),n})},[r]),g=i.useCallback(([e,t])=>{const a=o[t][r[e].id],{dataType:l}=r[e];return"Number"===l?{allowOverlay:!0,kind:re.GridCellKind.Number,data:a,displayData:a.toString()}:"Image"===l?{kind:re.GridCellKind.Image,data:[a],allowOverlay:!0,allowAdd:!0}:"Bubble"===l?{kind:re.GridCellKind.Bubble,data:["sss","ss"],allowOverlay:!0}:"SingleDropdown"===l?{kind:re.GridCellKind.Custom,allowOverlay:!0,copyData:"4",data:{kind:"dropdown-cell",allowedValues:["Good","Better","Best"],value:"Good"}}:"DatePicker"===l?{kind:re.GridCellKind.Custom,allowOverlay:!0,copyData:"4",data:{kind:"date-picker-cell",date:new Date,displayDate:(new Date).toISOString(),format:"date"}}:{kind:re.GridCellKind.Text,allowOverlay:!0,readonly:!1,displayData:a,data:a}},[o,r]),y=i.useCallback((e,t)=>{if(t.kind!==re.GridCellKind.Text)return;const[a,l]=e,n=r[a].id;o[l][n]=t.data,s(o)},[o,r]),v=i.useCallback(()=>{const e={};console.log(Object.entries(o[0]));for(const[t]of Object.entries(o[0]))e[t]="";s([...o,e])},[o]),f=i.useCallback(()=>{console.log("Header clicked")},[]),{renderLayer:b,layerProps:j}=oe.useLayer({isOpen:void 0!==d,triggerOffset:2,onOutsideClick:()=>{u&&(c(void 0),m(e=>!e)),m(e=>!e)},trigger:{getBounds:()=>({bottom:((null==d?void 0:d.bounds.y)??0)+((null==d?void 0:d.bounds.height)??0),height:(null==d?void 0:d.bounds.height)??0,left:(null==d?void 0:d.bounds.x)??0,right:((null==d?void 0:d.bounds.x)??0)+((null==d?void 0:d.bounds.width)??0),top:(null==d?void 0:d.bounds.y)??0,width:(null==d?void 0:d.bounds.width)??0})},placement:"bottom-end",auto:!0}),w=i.useCallback((e,t)=>{m(e=>!e),c({col:e,bounds:t})},[]),C=i.useCallback(()=>{const e=o.map(e=>({...e,new:""}));s(e),n([...r,{title:"New",id:"new",hasMenu:!0}])},[o,r]),S=i.useCallback((e,t)=>{n(a=>{const l=[...a],[r]=l.splice(e,1);return l.splice(t,0,r),l})},[]);return e.jsxs(J,{children:[e.jsx(Z,{expandIcon:e.jsx(ae,{}),children:e.jsx(te,{children:e.jsx(Q,{size:"small",color:"primary",icon:e.jsx(le,{}),label:"Accordion 1"})})}),e.jsx(ee,{}),e.jsx(re,{...h,getCellContent:g,columns:r,onCellEdited:y,onHeaderMenuClick:w,onHeaderClicked:f,onCellContextMenu:(e,t)=>t.preventDefault(),rows:o.length,rowMarkers:"both",showSearch:a,getCellsForSelection:!0,onSearchClose:p,onRowAppended:v,onDragOverCell:e=>{console.log(e)},onRowMoved:(e,t)=>window.alert(`Moved row ${e} to ${t}`),onColumnMoved:S,trailingRowOptions:{sticky:!0,tint:!1,hint:"New row..."},smoothScrollX:!0,smoothScrollY:!0,verticalBorder:e=>e>0,onDragStart:e=>{e.setData("text/plain","Drag data here!")},rightElement:e.jsx("div",{className:"addCol",children:e.jsx("button",{onClick:()=>C(),children:"+"})}),rightElementProps:{fill:!1,sticky:!0},onColumnResize:x}),e.jsx("div",{id:"portal"}),void 0!==d&&b(e.jsx("div",{...j,style:{...j.style,width:300,padding:4,borderRadius:8,backgroundColor:"white",border:"1px solid black"},children:e.jsxs("ul",{children:[e.jsx("li",{children:"Action 1"}),e.jsx("li",{children:"Action 2"}),e.jsx("li",{children:"Action 3"})]})}))]})},exports.ListingComponent=({title:t,tableColumns:a,columnOrder:l=["mrt-row-select"],rowActionMenu:s,destructiveActionMenu:c,handleAddButton:u,searchText:m,handleSearch:p,disabledViews:h=["Kanban","Calendar","Gantt"],fields:x,selectedIds:g=[],pageName:y,importModuleName:v,showAddButton:f=!0,actionButtons:b,paginationResource:j,enablePages:C=!1,GridComponent:S,onSelectRow:T,onColumnOrdering:_,onColumnVisibility:A,onSortingChange:N,fallbackIcon:B,className:R="",onDeleteConfirm:E,deleteTitle:I,deleteDescription:P,fetchApi:F,resetState:$,setPaginationModel:z,deleteApi:q,storeName:O,isUseFields:L,customeFilter:Y,customFields:W,isLoading:V,customRows:K=[],...H})=>{var U,G;const{t:J}=w.useTranslation(),Q=D.useDispatch(),{activePage:Z,updatePageInfo:ee}=ce.usePages(),{paginationModel:te,rows:ae,isLoading:le}=ue.useAppSelector(e=>null==e?void 0:e[O]),{pageNo:re,limit:ne,totalCount:oe}=te,ie=Z.page_size||ne,se=ie*(re-1),[de,me]=i.useState({selectedRows:g,itemToDelete:null,isDeleting:!1}),pe=Math.ceil(oe/ie),he=i.useMemo(()=>(null==K?void 0:K.length)?K:ae,[ae,K]),xe=e=>{me(t=>({...t,itemToDelete:e}))},ge=i.useMemo(()=>{if(c)return c.map(e=>({...e,handleAction:e.label.toLowerCase().includes("delete")?xe:e.handleAction}))},[c]),ye=e=>{Z.page_size!=(null==e?void 0:e.limit)&&ee({page_size:e.limit}),Q(z(e))},ve=i.useCallback(()=>{Q($())},[Q,$]),fe=M.useGenericDataFetcher((null==a?void 0:a.length)?a:Z,{skip:se,limit:ie},F,Y,[],!0,W);return i.useEffect(()=>{fe()},[fe]),i.useEffect(()=>ve,[ve]),i.useEffect(()=>{var e;(null==(e=null==Z?void 0:Z.views)?void 0:e.length)||ee({active_view:X.viewTypes.TABLE,views:[{label:"Table",position:0}]})},[null==Z?void 0:Z.views]),e.jsxs("section",{className:`listing-component ${R}`,children:[e.jsx(n.ActionBar,{title:t,data:(null==Z?void 0:Z.views)||[{label:"Table",position:0}],setData:e=>ee({views:e}),active:Z.active_view,setActive:e=>ee({active_view:e}),handleAddButton:u,searchText:m||Z.search||"",handleSearch:e=>{ee({search:e}),ye({pageNo:1}),null==p||p(e)},disabledViews:h,fields:x,isUseFields:L,selectedIds:de.selectedRows,pageName:y,importModuleName:v,button:f,actionBtn:b,...H}),e.jsxs(e.Fragment,{children:[(null==Z?void 0:Z.active_view)===X.viewTypes.TABLE&&e.jsx(n.MaterialTable,{rows:he||[],columns:a,paginationModel:te,totalPages:pe,columnOrder:[...l,...Z.column_order],states:{isLoading:V||le},onSortingChange:N?e=>{ee({sort:e}),N(e)}:void 0,enableColumnDragging:!1,enableEditing:!1,rowActionMenu:s,destructiveActionMenu:ge,isResetRow:!1,onSelectRow:e=>{const t=e.map(e=>e.original.id);me(e=>({...e,selectedRows:t})),null==T||T(e)},handleColumnOrdering:_?e=>{const t=e.slice(1);ee({column_order:t}),_(t)}:void 0,onColumnVisibility:A?e=>{ee({visible_columns:e}),A(e)}:void 0}),(null==Z?void 0:Z.active_view)===X.viewTypes.GRID&&S&&e.jsx(S,{data:he,rowActionMenu:s,destructiveActionMenu:ge}),!(null==Z?void 0:Z.active_view)&&!le&&e.jsx(n.Fallback,{heading:t,icon:B||e.jsx("img",{src:d.images.shippmentFallback,alt:"fallback"}),children:f&&u&&e.jsx(o.Button,{variant:"contained",startIcon:e.jsx(r,{}),onClick:u,children:`${J("common.add")} ${J("common.new")}`})}),e.jsx(n.Footer,{total:pe,paginationModel:{...te,limit:Z.page_size},handlePaginationModel:e=>{Z.page_size!==(null==e?void 0:e.limit)&&ee({page_size:e.limit}),ye(e)},resource:j,enablePages:C}),e.jsx(o.ConfirmPopUp,{open:Boolean(de.itemToDelete),onClose:()=>{me(e=>({...e,itemToDelete:null}))},onConfirm:async()=>{if(de.itemToDelete){me(e=>({...e,isDeleting:!0}));try{E?await E(de.itemToDelete):await(async e=>{const a=await Q(q(String(e.id)));M.apiHelper(a,()=>{k.enqueueSnackbar(` ${t}: ${null==e?void 0:e.id} ${J("common.msg.deleted")}`),fe()})})(de.itemToDelete),me(e=>({...e,itemToDelete:null,isDeleting:!1}))}catch(e){me(e=>({...e,isDeleting:!1}))}}},loading:de.isDeleting,title:I||`${J("common.delete")} ${t}`,description:P?P(de.itemToDelete):`${J("common.deleteMsg")} ${t}: ${(null==(U=de.itemToDelete)?void 0:U.id)||(null==(G=de.itemToDelete)?void 0:G.name)||""} ?`})]})]})},exports.MaterialEditableTable=Xt,exports.MultiLine=t=>{const{options:a}=t,[l,n]=i.useState(a),[s,c]=i.useState(null),m=Boolean(s),p=()=>{c(null)};return e.jsx("div",{className:"main-card-nodal",children:e.jsxs(bt,{children:[e.jsxs("div",{className:"payable-header",children:[e.jsx(h.Typography,{className:"payable-title",children:"Payable Account"}),e.jsx(u.IconButton,{color:"inherit",size:"small",onClick:e=>{c(e.currentTarget)},children:e.jsx("img",{src:d.images.more,alt:"more icon"})}),e.jsx(ie,{anchorEl:s,open:m,onClose:p,children:e.jsx(se,{onClick:p,children:"View"})})]}),e.jsx(o.SearchBar,{placeholder:"Search Companies",handleSearch:e=>{(e=>{const t=e.toLowerCase(),l=a.filter(e=>e.name.toLowerCase().includes(t)||e.role.toLowerCase().includes(t));n(l)})(e)},debounceTime:1}),l.map(t=>e.jsxs("div",{className:"list-items",children:[e.jsx(h.Typography,{className:"title",children:t.name}),e.jsx(h.Typography,{className:"description",children:t.role})]},t.id)),e.jsxs("div",{className:"bottom-footer",onClick:()=>{alert("Clicked ")},children:[e.jsx(r,{}),e.jsx(h.Typography,{children:"Create a Cost Center"})]})]})})},exports.MultiLineChart=({data:t,yAxisData:a,xAxisData:l,colors:r=["steelblue","orange","green","red"],height:n=400,margin:o={top:20,right:50,bottom:30,left:50},line:s=!1,yAxisLabelType:d="inValue",currency:c,customLabelFormatter:u})=>{const m=i.useRef(null),p=i.useRef(null),[h,x]=i.useState(0);return i.useEffect(()=>{},[d]),i.useEffect(()=>{const e=p.current,t=new ResizeObserver(e=>{if(e[0]){const t=e[0].contentRect.width;x(t)}});return e&&t.observe(e),()=>{e&&t.unobserve(e)}},[]),i.useEffect(()=>{if(0===h)return;const e=Ye.select(m.current);e.selectAll("*").remove();const i=h-o.left-o.right,p=n-o.top-o.bottom,x=Ye.scaleLinear().domain([0,l.length]).range([0,i]),g=Ye.scaleLinear().domain([0,Ye.max(a)]).nice().range([p,0]),y=e.append("g").attr("class","x-axis").attr("transform",`translate(${o.left},${n-o.bottom})`).call(Ye.axisBottom(x).ticks(l.length-1).tickFormat((e,t)=>l[t]));y.selectAll("text").attr("transform","translate(20, 10)").style("text-anchor","middle"),y.select(".domain").attr("stroke","none");const v=e.append("g").attr("class","y-axis").attr("transform",`translate(${o.left},${o.top})`).call(Ye.axisLeft(g).tickPadding(10).tickFormat(e=>{return u?u(e):(t=e,a=c,"inPercent"===(l=d)?`${Ye.format(".0%")(t/100)}`:"inValue"===l?`${a||""} ${Ye.format(".2s")(t).replace("k","K")}`:t.toString());var t,a,l}).tickSizeOuter(0));s&&v.selectAll(".grid-line").data(g.ticks()).enter().append("line").attr("class","grid-line").attr("x1",0).attr("x2",i).attr("y1",e=>g(e)).attr("y2",e=>g(e)).style("stroke","#ddd").style("stroke-dasharray","6,3").style("stroke-width",1),y.selectAll(".tick line").remove(),v.selectAll(".tick line").remove(),v.select(".domain").attr("stroke","none"),Object.keys(t).forEach((a,l)=>{var n,i,s;if("months"!==a){const d=Ye.line().x((e,t)=>x(t)).y(e=>g(e)).curve(t[a].isSmooth?Ye.curveMonotoneX:Ye.curveLinear);e.append("path").datum(null==(n=t[a])?void 0:n.data).attr("fill","none").attr("stroke",r[l%r.length]).attr("stroke-width",2).attr("transform",`translate(${o.left},${o.top})`).attr("d",d).on("mouseover",function(){Ye.select(this).attr("stroke-width",4)}).on("mouseout",function(){Ye.select(this).attr("stroke-width",2)}),(null==(i=t[a])?void 0:i.displayDot)&&e.selectAll(`.circle-${a}`).data(null==(s=t[a])?void 0:s.data).enter().append("circle").attr("class",`circle-${a}`).attr("cx",(e,t)=>x(t)+o.left).attr("cy",e=>g(e)+o.top).attr("r",4).attr("fill",r[l%r.length]).attr("stroke","white").attr("stroke-width",1.5).on("mouseover",function(){Ye.select(this).attr("r",6)}).on("mouseout",function(){Ye.select(this).attr("r",4)})}})},[t,a,l,n,h,r,o,s,d,c,u]),e.jsx("div",{ref:p,style:{width:"100%",height:"100%"},children:e.jsx("div",{style:{position:"relative"},children:e.jsx("svg",{ref:m,width:"100%",height:n,viewBox:`0 0 ${h} ${n}`})})})},exports.MultiSelect=Nt,exports.PageLoader=t=>e.jsx(u.Box,{position:"absolute",left:"50%",top:"50%",children:e.jsx(xa,{size:50,...t})}),exports.ProtectedRoute=({module:t,action:a,multiModule:l,complexPermissions:r,customPermissionCheck:n,redirectTo:o="/403",showError:s=!0,children:d})=>{const c=ce.usePermissions(),m=i.useMemo(()=>{if(!c)return!1;if(n)return n(c);if(r){const{permissions:e,operator:t="AND"}=r,a=e.map(({module:e,action:t})=>de.get(c,e,{})[t]??!1);return"AND"===t?a.every(Boolean):a.some(Boolean)}if(l){const{modules:e,action:t,operator:a="OR"}=l,r=e.map(e=>de.get(c,e,{})[t]??!1);return"AND"===a?r.every(Boolean):r.some(Boolean)}return!(!t||!a)&&(de.get(c,t,{})[a]??!1)},[c,t,a,l,r,n]),p=()=>e.jsxs(u.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",gap:2,textAlign:"center",p:3},children:[e.jsx(h.Typography,{type:"h1",color:"theme.secondary.900",weight:"bold",sx:{fontSize:{xs:"4rem",sm:"6rem"}},children:"403"}),e.jsx(u.Divider,{flexItem:!0}),e.jsx(h.Typography,{type:"s3",color:"theme.secondary.900",weight:"medium",children:"Access Denied"}),e.jsx(h.Typography,{type:"body2",color:"theme.secondary.700",weight:"regular",sx:{mt:1,maxWidth:"300px"},children:"You don't have the required permissions to access this resource."})]});return c&&0!==Object.keys(c).length?m?e.jsx(e.Fragment,{children:d}):s?e.jsx(p,{}):e.jsx(W.Navigate,{to:o,replace:!0}):null},exports.QuickApprovalModal=pt,exports.ReportButtons=Bt,exports.ReportTable=function({headers:t,data:a,tableHeaders:l,totalHeaders:r=[],handleSort:n,collapsLevel:s=0,isIncrese:d,enableSearch:c=!0,headerHeight:m="16px",onSelectionChange:x,enableCheckbox:g=!1,afterHeader:y,totalKey:v="total",rowHeight:f="auto"}){var b,j,C,T,k,_,D,M,A,N;const[B,R]=i.useState(null),[E,I]=i.useState(null),[P,F]=i.useState(null),[$,z]=i.useState({}),{t:q}=w.useTranslation(),[O,Y]=i.useState([]),[W,V]=i.useState({}),[K,H]=i.useState(null),U=i.useRef(0),G=i.useRef(0),X=i.useRef({}),[J,Q]=i.useState(!1),[Z,ee]=i.useState(!1);function te(e,t){var a;if(""==(null==t?void 0:t.name))return"";const l=(null==(a=null==t?void 0:t.name)?void 0:a.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e))||("0"==(null==t?void 0:t.name.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e))?"0":"-");return S.formateValueByType({value:l,...t})}function ae(e,t,a,l=[],r=0){if(!Array.isArray(e))return[];let n=[];return e.forEach((e,a)=>{var o,i;const s=[...l,a];(null==(o=t[r])?void 0:o.enableCheckbox)&&n.push(s);const d=r+1,c=null==(i=t[d])?void 0:i.rowKey;c&&Array.isArray(e[c])&&(n=n.concat(ae(e[c],t,0,s,d)))}),n}i.useEffect(()=>{var e;if(!J&&a&&t.length>0&&!Z){const r=function(e){const{maxRows:t,headers:a,data:l,tableHeaders:r,t:n}=e,o={};if(a.forEach(e=>{o[n(e.label)]=[]}),!l||!Array.isArray(l)||0===l.length)return o;let i=0;const s=t;return function e(t,d=0){var c;if(!Array.isArray(t)||i>=s)return;const u=r&&r[d]&&r[d].headers?r[d].headers:a;for(let m=0;m<t.length&&i<s;m++){const s=t[m];if(a.forEach(e=>{const t=n(e.label);if(!o[t])return;let a;if(u.find(e=>n(e.label)===t))if(e.render&&"function"==typeof e.render)try{const t=e.render(ma(s,e),s,l);if("string"==typeof t)a=t;else if("number"==typeof t)a=String(t);else if(t&&"object"==typeof t&&"props"in t){const e=t.props;a=e&&e.children?String(e.children):String(t)}else a=String(t)}catch(r){a=ca(ma(s,e),e.type)}else a=ca(ma(s,e),e.type);else a="-";o[t].push(a)}),i++,r&&r[d+1]){const t=null==(c=r[d+1])?void 0:c.rowKey;t&&s[t]&&Array.isArray(s[t])&&e(s[t],d+1)}}}(l,0),o}({maxRows:9999,headers:t,data:Array.isArray(a)?a:(null==a?void 0:a[null==(e=l[0])?void 0:e.rowKey])||[],tableHeaders:l,t:q}),n=function(e,t,a=oa,l={min:80,padding:24},r){const n={};return e.forEach(e=>{const o=r(e.label);if(e.width){const t="string"==typeof e.width?parseInt(e.width.replace(/[^\d]/g,""),10):e.width;return void(n[o]=t)}let i=da(o,a);e.enableSorting&&(i+=48);let s=0;(t[o]||[]).forEach(e=>{const t=da(e,a);s=Math.max(s,t)});let d=Math.max(i<100?i+24:i,s);d+=l.padding,d=s>10?Math.max(l.min,d):Math.max(60,d),l.max&&(d=Math.min(l.max,d)),n[o]=Math.round(d)>100?Math.round(d):100}),n}(t,r,oa,{min:100,padding:32,max:400},q);V(n),Q(!0)}},[a,t,J,Z,l]);const le=(e,t)=>{Y(a=>t?[...a,e]:a.filter(t=>!(t.length===e.length&&t.every((t,a)=>t===e[a]))))},re=ae(Array.isArray(P)?P:null==P?void 0:P[null==(b=l[0])?void 0:b.rowKey],l),ne=re.length>0&&re.every(e=>O.some(t=>t.length===e.length&&t.every((t,a)=>t===e[a]))),oe=re.some(e=>O.some(t=>t.length===e.length&&t.every((t,a)=>t===e[a])));function ie(e,t,a,l){if(null==e)return!1;const r=t.toLowerCase();return"string"==typeof a&&(a=[a]),"date"==(null==l?void 0:l.type)?p(e).format("DD-MM-YYYY").includes(r):"string"==typeof e?e.toLowerCase().includes(r):"object"==typeof e?Array.isArray(e)?e.some(e=>ie(e,r,a,l)):a?a.some(t=>{const a=e[t];if(null!=a)return"string"==typeof a?a.toLowerCase().includes(r):ie(a,r,null,l);const n=Object.keys(e).filter(t=>"object"==typeof e[t]&&null!==e[t]);return n.length>0&&n.some(t=>ie(e[t],r,null,l))}):Object.values(e).some(e=>ie(e,r,null,l)):String(e).toLowerCase().includes(r)}i.useEffect(()=>{var e,t,a;let r=Array.isArray(E)?E:null==E?void 0:E[null==(e=l[0])?void 0:e.rowKey];null==(t=Object.keys($))||t.forEach(e=>{var t,a;const l=null==(a=null==(t=null==$?void 0:$[e])?void 0:t.query)?void 0:a.toLowerCase();l&&(r=null==r?void 0:r.filter(t=>{var a;return ie(t,l,e,null==(a=null==$?void 0:$[e])?void 0:a.header)}))}),F(Array.isArray(E)?r:{...E,[null==(a=l[0])?void 0:a.rowKey]:r})},[$,E]);const se=e=>{if(!K)return;const t=e.clientX-U.current,a=Math.max(100,G.current+t);V(e=>({...e,[K]:a}))},de=()=>{H(null)};i.useEffect(()=>{if(K)return document.addEventListener("mousemove",se),document.addEventListener("mouseup",de),()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",de)}},[K]),i.useEffect(()=>{I(a),F(a),Q(!1)},[a]),i.useEffect(()=>()=>Q(!1),[]),i.useEffect(()=>{if(x){const e=O.filter(e=>{var t;const a=e.length-1;return null==(t=l[a])?void 0:t.enableCheckbox}).map(e=>function(e,t,a){var l,r;let n=Array.isArray(e)?e:null==e?void 0:e[null==(l=t[0])?void 0:l.rowKey],o=null;for(let i=0;i<a.length;i++){if(!n||!Array.isArray(n))return null;if(o=n[a[i]],i<a.length-1){const e=null==(r=t[i+1])?void 0:r.rowKey;n=null==o?void 0:o[e]}}return o}(P,l,e)).filter(Boolean);x(e)}},[O,P]);const ce=(null==P?void 0:P[v])&&!(0===(null==P?void 0:P.length)||0===(null==(C=P[null==(j=l[0])?void 0:j.rowKey])?void 0:C.length));return e.jsxs(u.TableContainer,{sx:{width:"100%",maxHeight:"600px",overflowX:"auto",backgroundColor:"white",display:"block",position:"relative"},className:"dynamic-reports",children:[e.jsxs(u.Table,{"aria-label":"collapsible table",sx:{borderCollapse:"collapse",width:"max-content",tableLayout:"fixed",marginBottom:ce?"0px":"10px"},children:[e.jsxs(u.TableHead,{sx:{position:"sticky",top:0,zIndex:10,backgroundColor:"white"},children:[e.jsxs(u.TableRow,{sx:{zIndex:11,backgroundColor:"white"},children:[g&&e.jsx(u.TableCell,{sx:{width:"60px",minWidth:"60px",maxWidth:"60px",height:m,padding:"8px",position:"sticky",left:0,backgroundColor:"white",zIndex:9999},children:e.jsx(Fe,{checked:ne,indeterminate:!ne&&oe,onChange:e=>(e=>{var t;const a=ae(Array.isArray(P)?P:null==P?void 0:P[null==(t=l[0])?void 0:t.rowKey],l);Y(e?a:[])})(e.target.checked)})}),t.map((t,a)=>{const l=(null==t?void 0:t.enableSorting)??!0,r=W[q(t.label)]||100;return e.jsxs(u.TableCell,{className:"dynamic-report-header",sx:{width:`${r}px`,minWidth:`${r}px`,maxWidth:`${r}px`,height:m,position:"relative",padding:"8px",overflow:"hidden"},children:[e.jsxs(u.Box,{ref:e=>X.current[t.name]=e,sx:{display:"flex",justifyContent:"space-between",height:m,alignItems:"center",width:"calc(100% - 8px)",overflow:"hidden",paddingRight:"0px"},children:[e.jsx(h.Typography,{type:"s3",weight:"medium",color:"theme.primary",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0,lineHeight:"unset"},children:"string"==typeof(null==t?void 0:t.label)?q(null==t?void 0:t.label):null==t?void 0:t.label}),l&&e.jsx(u.IconButton,{size:"small",sx:{padding:"4px 0px"},onClick:()=>{ee(!0),R(B==t.name?null:t.name),n&&n(t.name,B==t.name?"asc":"desc")},children:B==t.name?e.jsx(ze.ArrowUp,{fontSize:"small"}):e.jsx(L.ArrowDown,{fontSize:"small"})})]}),e.jsx(u.Box,{className:"dynamic-report-resize-handle",onMouseDown:e=>((e,t)=>{console.log("columnName",t),e.preventDefault(),e.stopPropagation(),H(t),U.current=e.clientX,G.current=W[t]||100})(e,q(t.label)),sx:{position:"absolute",right:0,top:0,bottom:0,width:"16px",cursor:"col-resize",backgroundColor:"transparent","&:hover":{backgroundColor:"transparent","&::before, &::after":{backgroundColor:"transparent"}},"&::before":{content:'""',position:"absolute",left:"2px",top:0,bottom:0,width:"2px",backgroundColor:"transparent",transition:"background-color 0.2s ease"},"&::after":{content:'""',position:"absolute",right:"2px",top:0,bottom:0,width:"2px",backgroundColor:"transparent",transition:"background-color 0.2s ease"},zIndex:2,userSelect:"none"}})]},a)})]}),c&&e.jsxs(u.TableRow,{children:[g&&e.jsx(u.TableCell,{sx:{width:"60px",minWidth:"60px",maxWidth:"60px",height:m,padding:"0px",position:"sticky",left:0,backgroundColor:"white",zIndex:9999}}),t.map((a,l)=>{const r=W[q(a.label)]||50;return e.jsx(u.TableCell,{className:"dynamic-report-search",sx:{width:`${r}px`,minWidth:`${r}px`,maxWidth:`${r}px`,padding:"8px"},children:e.jsx(o.SearchBar,{sx:{padding:"4px !important"},InputProps:{sx:{marginLeft:"0.5rem !important"}},handleSearch:e=>{return r=e,n=a.name,o=t[l],void z(e=>({...e,[n]:{query:r,header:o}}));var r,n,o}})},null==a?void 0:a.label)})]}),y&&e.jsx(u.TableRow,{children:e.jsx(u.TableCell,{colSpan:t.length+(g?1:0),sx:{padding:0,borderBottom:"none",backgroundColor:"white"},children:i.createElement(y,{columnWidths:W})})})]}),P&&e.jsx(u.TableBody,{children:Array.isArray(P)?null==P?void 0:P.map((a,n,o)=>e.jsx(na,{level:0,rowPath:[n],rowData:a,tableHeaders:l,totalHeaders:r,headers:t,collapsAll:s>=n+1,collapsLevel:s,isIncrese:!!d,data:P,selectedRowPaths:O,onCheckboxChange:le,dataSlice:o,dataIndex:n,enableCheckBox:g,rowHeight:f,columnWidths:W},a.id||n)):(null==(T=l[0])?void 0:T.rowKey)&&e.jsx(e.Fragment,{children:null==(_=P[null==(k=l[0])?void 0:k.rowKey])?void 0:_.map((a,n,o)=>e.jsx(na,{level:0,rowPath:[n],rowData:a,tableHeaders:l,totalHeaders:r,headers:t,collapsAll:s>=n+1,collapsLevel:s,isIncrese:!!d,data:P,selectedRowPaths:O,onCheckboxChange:le,dataSlice:o,dataIndex:n,enableCheckBox:g,rowHeight:f,columnWidths:W},a.id||n))})})]}),ce&&e.jsx(u.Box,{sx:{bottom:"-2px",width:"max-content",backgroundColor:(null==(D=null==r?void 0:r[0])?void 0:D.bgColor)||"#FAFAFA",borderTop:"1px solid #e0e0e0"},children:e.jsx(u.Table,{sx:{width:"max-content",tableLayout:"fixed",marginBottom:0},children:e.jsx(u.TableBody,{children:e.jsxs(u.TableRow,{children:[g&&e.jsx(u.TableCell,{sx:{width:"60px",minWidth:"60px",maxWidth:"60px",padding:"8px",position:"sticky",left:0,backgroundColor:(null==(M=null==r?void 0:r[0])?void 0:M.bgColor)||"#FAFAFA",zIndex:10,borderBottom:"none"}}),null==r?void 0:r.map((a,l)=>{var n;if(a.joinWithLeft)return null;const o=-1==r.slice(l).findIndex(e=>!e.joinWithLeft&&e!==a)?null==(n=r.slice(l))?void 0:n.length:r.slice(l).findIndex(e=>!e.joinWithLeft&&e!==a),i=a.mergeCells&&o||1;let s=0;for(let e=l;e<l+i&&e<t.length;e++)s+=W[q(t[e].label)]||100;return e.jsx(u.TableCell,{className:"dynamic-report-row",colSpan:i,sx:{paddingLeft:"8px",width:`${s}px`,minWidth:`${s}px`,maxWidth:`${s}px`,borderBottom:"none"},children:e.jsx(u.Box,{sx:{display:"flex",alignItems:"center",justifyContent:`${(null==a?void 0:a.position)?null==a?void 0:a.position:"start"}`,width:"100%"},children:(null==a?void 0:a.render)?a.render(null==P?void 0:P[v][a.name],P):e.jsx(h.Typography,{type:"s4",weight:"bold",color:"theme.neutral.1000",children:te(null==P?void 0:P[v],a)})})},l)})]})})})}),(0===(null==a?void 0:a.length)||0===(null==(N=null==a?void 0:a[null==(A=l[0])?void 0:A.rowKey])?void 0:N.length))&&S.renderEmptyRowsFallback(q("common.noData"))]})},exports.ReportsTitleBar=t=>{var a;const{title:l,handleAddButton:r,buttons:s=[],dropdownMenuButtonData:c,isTitleMenu:m=!1,titleMenus:x=[],reportFilterFields:g=[],toggleCallback:y,tabs:v,activeValue:f,setActiveValue:b,isDateFilterEnabled:C=!0,onDateFilterChange:S,filters:T={},isDateRange:k=!1,showDateFilter:D=!0,dateFilter:M="TODAY",filterDropDown:A,handleRowsCollapse:B,handleRowsExpand:R,showLevelBtn:E=!1,dataLength:I=0,filterKeys:P={},searchBar:F,customFilterComponents:$=[]}=t,z=(null==P?void 0:P.start_date)||"start_date",q=(null==P?void 0:P.end_date)||"end_date",O=(null==P?void 0:P.as_of_date)||"as_of_date",L=ue.useAppDispatch(),Y={"&.MuiOutlinedInput-root":{"& fieldset":{border:"none",borderColor:"#ade7cb",borderRadius:"25px"},"& .MuiSelect-outlined":{padding:"4.5px 14px !important"},display:"flex",gap:"4px",width:"220px",border:"1px solid #ade7cb",borderRadius:"50px",backgroundColor:"#ebf9f2",color:"#289b64",alignItems:"center",cursor:"pointer",height:"32px"}},W={border:"none","&.Mui-focused":{borderColor:"transparent"},"& .MuiOutlinedInput-input":{fontSize:"14px",color:"#289b64"},"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiSelect-icon":{color:"green"}},V=[...D?[{value:"date"}]:[],{value:"company"}],[K,H]=i.useState(V),[X,J]=i.useState(1),[Q,Z]=i.useState(null),[ee,te]=i.useState([]),[ae,le]=i.useState(),[re,ne]=i.useState(!1),[oe,ie]=i.useState(null),[se,de]=i.useState(p(null==T?void 0:T[O]).isValid()?p(null==T?void 0:T[O]).toDate():new Date),{t:ce}=w.useTranslation(),[pe,he]=i.useState({startDate:p(null==T?void 0:T[z]).isValid()?p(null==T?void 0:T[z]).toDate():new Date,endDate:p(null==T?void 0:T[q]).isValid()?p(null==T?void 0:T[q]).toDate():new Date,key:"selection"}),xe=i.useRef(null),ge=i.useRef(null),ye=i.useRef(null),ve=()=>{xe.current=null,ne(!1)},fe=e=>{if(!S)return;let t={...e};if(e.hasOwnProperty("start_date")&&(null==P?void 0:P.start_date)&&(t[P.start_date]=e.start_date,"start_date"!==P.start_date&&delete t.start_date),e.hasOwnProperty("end_date")&&(null==P?void 0:P.end_date)&&(t[P.end_date]=e.end_date,"end_date"!==P.end_date&&delete t.end_date),e.hasOwnProperty("as_of_date")&&(null==P?void 0:P.as_of_date)&&(t[P.as_of_date]=e.as_of_date,"as_of_date"!==P.as_of_date&&delete t.as_of_date),D)S(t);else{const e=["start_date","end_date","as_of_date",null==P?void 0:P.start_date,null==P?void 0:P.end_date,null==P?void 0:P.as_of_date].filter(Boolean),a={...t};e.forEach(e=>delete a[e]),S(a)}},be=async e=>{if(D)if(le(e),"CUSTOM"===e)xe.current=ge.current,ne(!0);else{const t=await N.handleCompareDateRange({range:N.RANGE[e],from:"",to:""});fe({start_date:(null==t?void 0:t.from)?null==t?void 0:t.from:"",end_date:(null==t?void 0:t.to)?null==t?void 0:t.to:""}),ve()}},je=e=>{xe.current&&xe.current.contains(e.target)||ve()},we=(null==A?void 0:A.map(e=>({key:e.value||e.key,label:e.name||e.label||`Search ${e.value||e.key}`,placeholder:e.placeholder||e.name||e.label,apiType:e.options?void 0:e.apiType||e.value||e.key,valueKey:(null==P?void 0:P[e.value||e.key])||e.value||e.key,customFilter:e.customFilter||null,multiple:e.multiple||!1,options:e.options||void 0})))||[],Ce=[{label:N.RANGE.TODAY,callback:()=>{be("TODAY")}},{label:N.RANGE.THIS_WEEK,callback:()=>{be("THIS_WEEK")}},{label:N.RANGE.THIS_MONTH,callback:()=>{be("THIS_MONTH")}},{label:N.RANGE.THIS_QUARTER,callback:()=>{be("THIS_QUARTER")}},{label:N.RANGE.THIS_YEAR,callback:()=>{be("THIS_YEAR")}},{label:N.RANGE.YESTERDAY,callback:()=>{be("YESTERDAY")}},{label:N.RANGE.PREVIOUS_WEEK,callback:()=>{be("PREVIOUS_WEEK")}},{label:N.RANGE.PREVIOUS_MONTH,callback:()=>{be("PREVIOUS_MONTH")}},{label:N.RANGE.PREVIOUS_QUARTER,callback:()=>{be("PREVIOUS_QUARTER")}},{label:N.RANGE.PREVIOUS_YEAR,callback:()=>{be("PREVIOUS_YEAR")}},{label:N.RANGE.CUSTOM,callback:()=>{be("CUSTOM")}}],Se=()=>{const e={start_date:p(pe.startDate).format("YYYY-MM-DD"),end_date:p(pe.endDate).format("YYYY-MM-DD")},t={as_of_date:p(se).format("YYYY-MM-DD")};fe({...k?e:t}),ve()},Te=e=>({startDate:p(null==e?void 0:e[z]).isValid()?p(e[z]).toDate():new Date,endDate:p(null==e?void 0:e[q]).isValid()?p(e[q]).toDate():new Date});i.useEffect(()=>{(null==T?void 0:T[O])&&de(p(null==T?void 0:T[O]).isValid()?p(null==T?void 0:T[O]).toDate():new Date)},[null==T?void 0:T[O],O]),i.useEffect(()=>{he({...pe,...Te(T)})},[null==T?void 0:T[q],null==T?void 0:T[z]]),i.useEffect(()=>{re&&(k?he({...pe,...Te(T)}):de(p(null==T?void 0:T[O]).isValid()?p(null==T?void 0:T[O]).toDate():new Date))},[re,k]),i.useEffect(()=>{L(me.fetchCompanies())},[]),i.useEffect(()=>{te(j.generateFields(g))},[]),i.useEffect(()=>{be(M)},[M]);const ke=i.memo(()=>{var t;return e.jsx(u.Menu,{open:Boolean(oe),anchorEl:oe,onClose:()=>ie(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:null==(t=null==c?void 0:c.options)?void 0:t.map((t,a)=>e.jsx(u.MenuItem,{onClick:()=>{t.callback(),ie(null)},children:e.jsxs(h.Typography,{type:"s4",weight:"medium",color:"inherit",children:[" ",t.label]})},a))})});return e.jsxs("div",{children:[e.jsxs("div",{className:"reportsTitleBar",children:[e.jsx("div",{className:"reportsTitleBar--LeftContent",children:m?e.jsx("div",{style:{zIndex:999},children:e.jsx(n.TitleDropdownButton,{onClick:r,options:x,isMenuThirdItemDisabled:!0,children:l})}):e.jsx(h.Typography,{type:"h3",weight:"medium",color:"theme.secondary.1000",children:l})}),F&&e.jsx("div",{className:"reportsTitleBar--SearchBar",children:F}),e.jsx(Bt,{zIndex:999,className:"reportsTitleBar--RightContent",buttons:s})]}),(null==v?void 0:v.length)?e.jsx("div",{children:e.jsx(n.TabBar,{tabs:v||[],activeValue:f,setActiveValue:b,isTabViewOnly:!0})}):null,e.jsxs(u.Box,{sx:{display:"flex",justifyContent:"space-between",my:2.5,alignItems:"center",flexWrap:"wrap",gap:1},children:[e.jsxs("div",{className:"reportsTitleBar--FilterWrapper",children:[e.jsxs(e.Fragment,{children:[we.map(({key:t,label:a,placeholder:l,apiType:r,valueKey:o,customFilter:i,multiple:s=!1,options:d,show:c=!0,showCancelButton:u=!0})=>{if(m=t,!K.some(e=>(null==e?void 0:e.value)==m)||!c)return null;var m;const p=(null==P?void 0:P.company)||"company",h=null==T?void 0:T[p],x=Array.isArray(h)?h.length>0:!!h;let g=i;return["department","designation","location"].includes(r)&&(g={..."object"==typeof i?i:{},"&company_id.in":x?Array.isArray(h)?h.join(","):h:0}),e.jsx(n.SearchableSelect,{labelId:`${t}-label`,searchPlaceholder:a,value:null==T?void 0:T[o],onChange:e=>fe({[o]:e.target.value}),showCancelButton:u,apiType:r,isInternal:!r&&!!d,options:d,multiple:s,placeholder:l,customeFilter:g,customStyle:Y,inputStyle:W})}),$.map(({key:t,component:a})=>e.jsx(i.Fragment,{children:a},t))]}),D&&k&&(null==T?void 0:T[q])&&e.jsx("div",{style:{display:"flex",gap:"8px"},children:e.jsxs("div",{className:"reportsTitleBar--FilterWrapper--Chip",ref:ye,onClick:()=>{re?ve():(xe.current=ye.current,ne(!0))},children:[e.jsxs("div",{className:"reportsTitleBar--FilterWrapper--Chip--Text",title:`${p(null==T?void 0:T[z]).format("DD/MM/YYYY")} - ${p(null==T?void 0:T[q]).format("DD/MM/YYYY")}`,children:[e.jsxs(h.Typography,{type:"s4",weight:"medium",children:[ce("common.dateRange"),":"]}),e.jsxs(h.Typography,{className:"reportsTitleBar--FilterWrapper--Chip--Text--Value",type:"s4",children:[p(null==T?void 0:T[z]).format("DD/MM/YYYY")," -"," ",p(null==T?void 0:T[q]).format("DD/MM/YYYY")]})]}),e.jsx(U,{})]})}),D&&!k&&C&&!["TODAY","YESTERDAY"].includes(ae)&&e.jsxs(e.Fragment,{children:[(null==pe?void 0:pe.startDate)&&e.jsx("div",{style:{display:"flex",gap:"8px"},children:e.jsx("div",{className:"reportsTitleBar--FilterWrapper--Chip",style:{padding:" 5px 12px"},children:e.jsxs("div",{className:"reportsTitleBar--FilterWrapper--Chip--Text",title:`${p(null==pe?void 0:pe.startDate).format("DD/MM/YYYY")}`,children:[e.jsxs(h.Typography,{type:"s4",weight:"medium",children:[ce("common.startDate"),":"]}),e.jsx(h.Typography,{className:"reportsTitleBar--FilterWrapper--Chip--Text--Value",type:"s4",children:p(null==pe?void 0:pe.startDate).format("DD/MM/YYYY")})]})})}),(null==pe?void 0:pe.endDate)&&e.jsx("div",{style:{display:"flex",gap:"8px"},children:e.jsx("div",{className:"reportsTitleBar--FilterWrapper--Chip",style:{padding:" 5px 12px"},children:e.jsxs("div",{className:"reportsTitleBar--FilterWrapper--Chip--Text",title:`${p(null==pe?void 0:pe.endDate).format("DD/MM/YYYY")}`,children:[e.jsxs(h.Typography,{type:"s4",weight:"medium",children:[ce("common.endDate"),":"]}),e.jsx(h.Typography,{className:"reportsTitleBar--FilterWrapper--Chip--Text--Value",type:"s4",children:p(null==pe?void 0:pe.endDate).format("DD/MM/YYYY")})]})})})]}),D&&(null==T?void 0:T[O])&&!k&&e.jsx("div",{style:{display:"flex",gap:"8px"},children:e.jsxs("div",{className:"reportsTitleBar--FilterWrapper--Chip",ref:ye,onClick:()=>{re?ve():(xe.current=ye.current,ne(!0))},children:[e.jsxs("div",{className:"reportsTitleBar--FilterWrapper--Chip--Text",title:`${p(null==T?void 0:T[O]).format("DD/MM/YYYY")}`,children:[e.jsxs(h.Typography,{type:"s4",weight:"medium",children:[ce("common.date"),":"]}),e.jsx(h.Typography,{className:"reportsTitleBar--FilterWrapper--Chip--Text--Value",type:"s4",children:p(null==T?void 0:T[O]).format("DD/MM/YYYY")})]}),e.jsx(U,{})]})})]}),e.jsxs("div",{className:"report-display",children:[(null==(a=null==c?void 0:c.options)?void 0:a.length)>0&&e.jsxs(u.Box,{children:[e.jsx(o.Button,{sx:({palette:e})=>({border:"1px solid",borderColor:"grey.200",borderRadius:"50px",color:`${e.grey[800]} !important`,"&:hover":{bgcolor:`${e.grey[200]} !important`}}),variant:"text",startIcon:e.jsx(_.Export,{fontSize:"small"}),onClick:e=>ie(e.currentTarget),children:ce("common.export")}),oe&&e.jsx(ke,{})]}),(null==A?void 0:A.length)&&e.jsxs(e.Fragment,{children:[e.jsx(u.Box,{children:e.jsx(o.Button,{sx:({palette:e})=>({border:"1px solid",borderColor:"grey.200",borderRadius:"50px",color:`${e.grey[800]} !important`,"&:hover":{bgcolor:`${e.grey[200]} !important`}}),variant:"text",startIcon:e.jsx(_.Filter,{fontSize:"small"}),onClick:e=>Z(e.currentTarget),children:ce("common.filter")})}),E&&e.jsx(u.Divider,{flexItem:!0,orientation:"vertical",sx:{height:"50%",alignSelf:"auto"}})]}),e.jsx(u.Menu,{anchorEl:Q,open:Boolean(Q),onClose:()=>{Z(null)},children:null==A?void 0:A.map(t=>{return e.jsxs(u.MenuItem,{onClick:()=>(e=>{if(K.some(t=>t.value==e.value)){H(K.filter(t=>(null==t?void 0:t.value)!=e.value));const t=e.value||e.key,a=(null==P?void 0:P[t])||t;return void fe({[a]:e.multiple?[]:null})}H([...K,e])})(t),value:null==t?void 0:t.value,children:[e.jsx(n.Checkbox,{checked:(a=t,K.some(e=>(null==e?void 0:e.value)==(null==a?void 0:a.value)))}),e.jsx(h.Typography,{sx:{marginLeft:"10px"},color:"theme.neutral.800",type:"s3",children:ce(null==t?void 0:t.name)})]},t);var a})}),E&&e.jsxs(e.Fragment,{children:[e.jsxs(u.Box,{className:"reportsTitleBar--FilterAction--lvWrapper",children:[e.jsxs(h.Typography,{type:"s3",weight:"medium",color:"grey.800",children:[" Level ",X," of ",I]}),e.jsxs(u.ButtonGroup,{variant:"outlined",disableElevation:!0,sx:({palette:e})=>({"& .MuiButton-root":{borderColor:`${e.grey[200]} !important`,"&:hover":{bgcolor:`${e.grey[200]} !important`}},"& .MuiButtonGroup-firstButton":{borderTopLeftRadius:20,borderBottomLeftRadius:20},"& .MuiButtonGroup-lastButton":{borderTopRightRadius:20,borderBottomRightRadius:20}}),children:[e.jsx(u.Button,{onClick:()=>{J(X==I?X:X+1),null==B||B(X)},children:e.jsx("img",{src:d.images.common.expand})}),e.jsx(u.Button,{onClick:()=>{J(1!=X?X-1:1),null==R||R(X)},children:e.jsx("img",{src:d.images.common.collapse})})]})]}),C&&e.jsx(u.Divider,{flexItem:!0,orientation:"vertical",sx:{height:"50%",alignSelf:"auto"}})]}),C&&D&&e.jsxs(u.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(h.Typography,{type:"s3",weight:"medium",color:"grey.800",children:"As of: "}),e.jsx(Bt,{zIndex:997,className:"reportsTitleBar--RightContent",dropdownMenuButtonData:{icon:e.jsx(_.Calendar,{fontSize:"small"}),children:e.jsxs(e.Fragment,{children:[N.RANGE[ae],e.jsx(U,{})]}),options:Ce},toggleCallback:y}),e.jsx("div",{ref:ge})]})]})]}),e.jsx(u.Popper,{sx:{zIndex:9999},open:re,anchorEl:xe.current,role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:t,placement:a})=>e.jsx(u.Grow,{...t,style:{margin:"0 20px 0 20px",transformOrigin:"bottom"===a?"center top":"center bottom"},children:e.jsx(u.Paper,{children:e.jsx(u.ClickAwayListener,{onClickAway:je,children:e.jsxs(u.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end"},children:[e.jsx("div",{children:k?e.jsx(G.DateRange,{editableDateInputs:!0,onChange:e=>he(e.selection),moveRangeOnFirstSelection:!1,ranges:[pe],locale:tt}):e.jsx(G.Calendar,{onChange:e=>de(e),date:se,locale:tt})}),e.jsx(u.Box,{sx:{padding:"0 12px 12px 0"},children:e.jsx(o.Button,{variant:"contained",sx:{width:"fit-content"},onClick:Se,children:ce("common.apply")})})]})})})})})]})},exports.ScheduleReportModal=Ot,exports.Snackbar=t=>{const{children:a,...l}=t;return e.jsx(k.SnackbarProvider,{action:t=>e.jsx(Lt,{snackbarKey:t}),style:{flexWrap:"unset"},anchorOrigin:{vertical:"bottom",horizontal:"right"},...l,children:a})},exports.SubHeaderDoc=()=>e.jsx("section",{children:e.jsxs("div",{className:"top-content",children:[e.jsxs("div",{className:"left-content",children:[e.jsx("a",{href:"#",children:"Forms / "}),"Add Custom Field"]}),e.jsxs("div",{className:"right-content",children:[e.jsx("div",{className:"actions",children:e.jsx(o.Button,{className:"",variant:"middle",children:"Action"})}),e.jsx("div",{className:"show-preview",children:e.jsx(o.Button,{className:"",variant:"middle",children:"Show Preview"})}),e.jsx("div",{className:"update",children:e.jsx(o.Button,{className:"",variant:"contained",children:"Update"})})]})]})}),exports.TabBarUi=t=>{const{tabs:a,onEditTabTitle:r,activeTabValue:n,setActiveTabValue:s,handleTabChange:c,handleRemoveTab:m}=t,[p,h]=i.useState(0),[x,g]=i.useState(null);return i.useEffect(()=>{s&&Boolean(null==a?void 0:a.length)&&s(p)},[a]),e.jsx(u.Box,{children:e.jsxs(xe,{value:n??p,children:[e.jsx(u.Box,{children:e.jsx(ge,{className:"account-payble-tabsui-wrap",onChange:(e,t)=>{h(t),s&&s(t),c&&c()},children:a.map(t=>e.jsx(he,{className:"account-payble-tab-items",label:r&&x===t.tab_order?e.jsx(o.TextField,{value:t.title,autoFocus:!0,onBlur:()=>g(null),onChange:e=>{return a=e,l=t.tab_order,void(r&&r(l,a.target.value));var a,l}}):m?e.jsxs("div",{className:"Tabs--Title",children:[e.jsx("div",{children:t.title}),!t.remove_tab&&e.jsx(l,{style:{fontSize:"15px",cursor:"pointer"},onClick:()=>{m(t.tab_order)}})]}):e.jsxs("div",{className:"text-display",children:[e.jsx("img",{src:d.images.common[t.tabIcon]}),t.title]}),wrapped:!0,onDoubleClick:()=>{return e=t.tab_order,void g(e);var e}},t.tab_order))})}),a.map((t,a)=>t.content&&e.jsx(ye,{value:a,children:p===a&&t.content},t.tab_order))]})})},exports.TextArea=t=>{const{placeholder:a,minRows:l=3,label:r,helperText:n,error:o,...i}=t,s=q.styled(ve.TextareaAutosize)(({theme:{palette:e}})=>{var t,a,l,r,n,i,s,d;return{"&":{padding:"0.4375rem 0.5rem",borderRadius:"0.25rem",borderColor:o?null==(t=e.theme)?void 0:t.error[600]:null==(a=e.theme)?void 0:a.secondary[400],outline:"none",color:null==(l=e.theme)?void 0:l.secondary[800],fontSize:"0.875rem","&::placeholder":{opacity:1},"&:hover":{borderColor:o?null==(r=e.theme)?void 0:r.error[600]:null==(n=e.theme)?void 0:n.secondary[500]},"&:focus-visible":{borderWidth:"0.0625rem",borderStyle:"solid",borderColor:o?null==(i=e.theme)?void 0:i.error[600]:null==(s=e.theme)?void 0:s.primary[700]},"&:disabled":{background:null==(d=e.theme)?void 0:d.secondary[200]}}}});return e.jsxs(e.Fragment,{children:[e.jsx(h.Typography,{type:"s4",fontWeight:"medium",mb:.5,color:o?"theme.error.600":"theme.secondary.800",children:r}),e.jsx(s,{"aria-label":"minimum height",minRows:l,placeholder:a,...i}),e.jsx(h.Typography,{type:"s4",fontWeight:"medium",mt:-.25,color:o?"theme.error.600":"theme.secondary.800",children:n})]})},exports.TimeRangePicker=t=>{const[a,l]=i.useState([]),[r,n]=i.useState(0),[d,m]=i.useState(0),[p,h]=i.useState(void 0),{hour12:x=!1,startTime:g,endTime:y,onTimeRangeChange:v}=t;i.useEffect(()=>{l([]);const e=e=>{if(!e)return null;const[t,a]=e.split(" "),[l,r]=t.split(":").map(Number);let n=l;a&&("PM"===a?12!==l&&(n+=12):"AM"===a&&12===l&&(n-=12));const o=new Date;o.setHours(n,r,0,0);const i=o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:x});let s=i;return 0===o.getHours()?s="00"+i.slice(2):12===o.getHours()&&(s="12"+i.slice(2)),s};l(t=>{if(g&&y){const a=e(g),l=e(y);return[...t,a,l]}return t})},[x,g,y]),i.useEffect(()=>{if(2===d&&m(0),2===a.length){const e=a[0],t=a[1],l=f(e);let r=f(t)-l;r<0&&(r+=1440),n(r)}else n(0)},[d,a]);const f=e=>{const[t,a,l]=e.split(/:| /);let r=parseInt(t);const n=parseInt(a);return l&&"pm"===l.toLowerCase()&&12!==r?r+=12:l&&"am"===l.toLowerCase()&&12===r&&(r=0),60*r+n};i.useEffect(()=>{v({timeRange:a,differenceInMinutes:r})},[r,v,a]);const b=()=>{h(!0!==p||void 0)},j=e=>{l([]),m(0),e.stopPropagation()},w=e.jsx(o.TextField,{className:"time-input",type:"text",value:1===a.length?`${a[0]} - `:2===a.length?`${a[0]} - ${a[1]}`:"",InputProps:{readOnly:!0,endAdornment:e.jsxs(u.InputAdornment,{position:"end",children:[a.length>0&&e.jsx(u.IconButton,{onClick:j,children:e.jsx(c.Close,{})}),e.jsx(u.IconButton,{onClick:b,children:e.jsx(c.AccessTimeRounded,{})})]})}});return e.jsx(e.Fragment,{children:e.jsxs(u.Box,{className:"DateRangePicker",children:[e.jsx(s,{className:"DatePickerWrapper",onChange:e=>{(e=>{const t=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:x});let r=t;0===e.getHours()?r="00"+t.slice(2):12===e.getHours()&&(r="12"+t.slice(2)),a.length<2?l([...a,r]):0===d?l(e=>{const t=[...e];return t[0]=r,t}):1===d&&l(e=>{const t=[...e];return t[1]=r,t}),m(d+1)})(e),b()},showTimeSelect:!0,showTimeSelectOnly:!0,timeIntervals:15,selectsRange:!0,customInput:w,open:p,value:a&&1===a.length?`${a[0]}-`:a&&2===a.length?`${a[0]}-${a[1]}`:void 0}),e.jsx(u.Box,{className:"box-icon",style:a.length>0?{right:"2.5rem"}:{right:"1.563rem"},children:a.length>0&&e.jsx(c.Close,{onClick:j})})]})})},exports.UomFieldWrapper=({label:a,name:l="uom_id",placeholder:r,fieldArrayName:o,required:s=!1,is_loading:d=!1,disabled:c=!1,selectedItem:u,fieldMapping:m={total_on_hand_quantity:"on_hand_quantity",total_available_quantity:"available_quantity",total_committed_quantity:"committed_quantity"},customeFilter:p,getSelectedData:h,fieldPrefix:x,setValue:g,control:y,isConversationFactor:v=!0,active_location:f})=>{const[b,j]=i.useState(null),w=t.useFormContext(),{setValue:C}=w||{},S=void 0!==x?x:o||"",T=(({fieldMapping:e,sourceData:t,conversation_factor:a,fieldPrefix:l="item_entries",setValue:r,shouldUpdate:n=!0,active_location:o})=>i.useCallback(()=>{n&&t&&Object.entries(e).forEach(([e,n])=>{const i=t[e],s=Number(a)||1,d=l?`${l}.${n}`:n;let c;if(null===o)c=0;else if(o&&"object"==typeof o&&(null==t?void 0:t.location_wise_quantity)){const a=t.location_wise_quantity.find(e=>e.location_id===o.id);if(a)switch(e){case"total_on_hand_quantity":c=(a.total_available_quantity-a.total_reserved_quantity)/s;break;case"total_available_quantity":c=a.total_available_quantity/s;break;case"total_committed_quantity":c=a.total_committed_quantity/s;break;default:c="sales_price"==e||"rental_base_price"==e||"cost"==e?0!==s&&Number(i)*s||0:0!==s&&Number(a[e])/s||0}else c=0}else c="sales_price"==e||"rental_base_price"==e||"cost"==e?0!==s&&Number(i)*s||0:0!==s&&Number(i)/s||0;r(d,c)})},[e,t,a,l,r,n,o]))({fieldMapping:i.useMemo(()=>m,[JSON.stringify(m)]),sourceData:u,conversation_factor:null==b?void 0:b.conversation_factor,fieldPrefix:S,setValue:g||C,active_location:f});i.useEffect(()=>{v&&T()},[T,v]);const k=p||{"&template_id.eq":(null==u?void 0:u.unit_of_measurement)||0};return e.jsx(n.DynamicSearchSelect,{label:a,name:l,placeholder:r||"",fieldArrayName:o||"",formControl:y,required:s,is_loading:d,disabled:c,apiType:"uom",customeFilter:k,getSelectedData:(e,t)=>{j(e),null==h||h(e,t)}})},exports.Upload=t=>{const{open:a,title:r,onClose:s,onConfirm:m,accept:p="*",onSubmit:x,multiple:g=!0,existingDriveData:y,fileUploaded:v,type:f}=t,[b,j]=i.useState([]),[w,C]=i.useState(!1),[T,k]=i.useState(!1),[_,D]=i.useState(!1),[M,A]=i.useState(!1),[N,B]=i.useState(new AbortController),R=localStorage.getItem(we.auth.storageTokenKeyName),[E,I]=i.useState(),[P,F]=i.useState(!1),[$,z]=i.useState(),[q,L]=i.useState(null),{getRootProps:Y,getInputProps:W,isDragActive:V}=be.useDropzone({onDropAccepted:e=>{j([...b,...e.map(e=>({file:e,isPrivate:!1,checkboxDisabled:!1,status:"pending",uploadProgress:0,fileSize:e.size,fileName:e.name,fileType:e.type,location:"",message:""}))]),A(!1)},onDragEnter:()=>{A(!0)},onDragLeave:()=>{A(!1)},noClick:!0,noKeyboard:!0,multiple:g,accept:p?(H=p,H.split(",").map(e=>e.trim()).reduce((e,t)=>(e[t]=[],e),{})):p}),K=i.useRef(null);var H;i.useEffect(()=>{const e=null==y?void 0:y.map(e=>e.title);I(e)},[y]),i.useEffect(()=>{const e=e=>{if(w){const t="Are you sure you want to leave? Your uploads are not complete.";return e.returnValue=t,t}};return K.current&&(K.current.multiple=g),window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}},[w,g]);const U=()=>{const e=navigator;return"connection"in e&&e.connection?e.connection.downlink:null},G=t=>{switch(null==t?void 0:t.type.split("/")[0]){case"image":case"application":return e.jsx("div",{className:_?"document-icon-sm":"document-icon-lg",style:{backgroundColor:"#FFEBEB"},children:e.jsx(o.Avatar,{size:20,src:d.images.upload.documentPDF})});default:return e.jsx("div",{className:_?"document-icon-sm":"document-icon-lg",style:{backgroundColor:"#EBF9F2"},children:e.jsx(o.Avatar,{size:20,src:d.images.upload.docFile})})}},X=`${we.getApiConfig().backendBaseUrl}/document/v1/file-upload/`,J=async()=>{C(!0);const e=new AbortController;B(e);const t=b.filter(e=>"canceled"!==e.status).length;for(let l=0;l<b.length;l++){if(100===b[l].uploadProgress||"pending"!==b[l].status)continue;const r=b[l],n=null==r?void 0:r.fileSize;try{n>10485760?await ee(r,l,e)&&setTimeout(()=>{v(!0)},1e3):await Z(r,l,e,t)}catch(a){j(e=>{const t=[...e];return t[l]={...t[l],status:"failed",message:a.message||"Internal Server Error"},t})}finally{C(!1)}}};let Q=0;const Z=async(e,t,a,l)=>{var r,n,o,i;try{const s=["docx","doc","csv","pdf","xls","xlsx","vnd.ms-excel","excel","txt"],d=(null==e?void 0:e.mimeType)||(null==e?void 0:e.fileType)||"";if(s.some(e=>d.includes(e))&&(null==e?void 0:e.fileSize)&&(null==e?void 0:e.fileSize)>=5242880)return L({type:"alert",message:"File size must be within 5 MB!"});const c=await fetch(`${X}?key=${null==e?void 0:e.fileName}&partCount=1&mimeType=${null==e?void 0:e.fileType}&is_private=${!(null==e?void 0:e.isPrivate)}`,{headers:{"Content-Type":"application/json","file-size":null==e?void 0:e.fileSize,"x-token":R},signal:a.signal}),u=await c.json();if(400==(null==u?void 0:u.status_code))return void L({type:"alert",message:null==u?void 0:u.message});const m=null==(n=null==(r=u.data)?void 0:r.preSignedData)?void 0:n.presignedUrl,p=null==(i=null==(o=u.data)?void 0:o.preSignedData)?void 0:i.location,h={Body:null==e?void 0:e.file.slice(0,null==e?void 0:e.fileSize),url:m},g=e.fileSize,y=1099511627776;let v=0;for(;v<g;){const a=v,l=Math.min(v+y,g);await fetch(h.url,{method:"PUT",body:e.file.slice(a,l),headers:{"Content-Type":"application/octet-stream"}}),v=l;const r=Math.round(v/g*100);j(e=>{const a=[...e];return a[t]={...a[t],checkboxDisabled:!0,status:"uploading",uploadProgress:r},a})}j(e=>{const a=[...e];return a[t]={...a[t],status:"completed",location:p,message:"Uploaded Successfully"},Q+=1,l==Q&&(x(a),Q=0),a})}catch(s){j(e=>{const a=[...e];return a[t]={...a[t],status:"failed",message:s.message||"Internal Server Error"},a})}},ee=async(e,t,a)=>{var l,r,n;try{const o=1024*(U()||10)*1024<5242880?5242880:1024*(U()||10)*1024,i=Math.ceil((null==e?void 0:e.fileSize)/o),s=await fetch(`${X}?key=${null==e?void 0:e.fileName}&partCount=${i}&mimeType=${null==e?void 0:e.fileType}&is_private=${!(null==e?void 0:e.isPrivate)}`,{headers:{"Content-Type":"application/json","file-size":null==e?void 0:e.fileSize,"x-token":R},signal:a.signal}),d=await s.json();if(d&&(null==d?void 0:d.status_code)&&400==(null==d?void 0:d.status_code))return L({message:(null==d?void 0:d.message)||"Internal Server Error",type:"error"}),null;const c=null==(l=d.data.preSignedData)?void 0:l.preSignedUrls;if(c.length>0){const a=c[0].presignedUrl.match(/uploadId=([^&]+)/)[1];for(let n=0;n<c.length;n++){const a=c[n].partNumber,l=c[n].presignedUrl,s=(a-1)*o,d=Math.min(s+o,null==e?void 0:e.fileSize),u={Body:null==(r=null==e?void 0:e.file)?void 0:r.slice(s,d),url:l};await fetch(u.url,{method:"PUT",body:u.Body,headers:{"Content-Type":"application/octet-stream"}});const m=Math.round(100*(n+1)/i);j(e=>{const a=[...e];return a[t]={...a[t],checkboxDisabled:!0,status:"uploading",uploadProgress:m},a})}const l=await fetch(`${X}mark-complete`,{method:"POST",headers:{"Content-Type":"application/json","x-token":R},body:JSON.stringify({fileName:null==e?void 0:e.fileName,uploadId:a})}),s=await l.json(),d=null==(n=null==s?void 0:s.data)?void 0:n.location;j(e=>{const a=[...e];return a[t]={...a[t],status:"completed",location:d,message:"Uploaded Successfully"},x(a),a})}else j(e=>{const a=[...e];return a[t]={...a[t],status:"failed",message:"Did not get pre-signed URLs"},a})}catch(o){j(e=>{const a=[...e];return a[t]={...a[t],status:"failed",message:o.message||"Internal Server Error"},a})}},te=()=>{K.current&&(t.multiple?K.current.setAttribute("multiple","true"):K.current.removeAttribute("multiple"),K.current.click())},ae=e=>{const t=e.target.files,a=Array.from(t).map(e=>{const t=e.name;return t.substring(0,t.lastIndexOf("."))||t})[0];z(a),F(null==E?void 0:E.includes(a));const l=Array.from(t).map(e=>({file:e,isPrivate:!1,checkboxDisabled:!1,status:"pending",uploadProgress:0,fileSize:null==e?void 0:e.size,fileName:null==e?void 0:e.name,fileType:null==e?void 0:e.type,location:"",message:""}));j(e=>[...e,...l]),C(!1)},le=e=>{j(t=>t.map((t,a)=>a===e?{...t,status:"canceled"}:t))},re=()=>{D(!_),_?m():s()},ne=()=>{var e;b.length>0?confirm("Your uploads are not complete. Would you like to cancel all ongoing uploads?")&&(N.abort(),(null==(e=null==N?void 0:N.signal)?void 0:e.aborted)&&s(),j([])):s()};i.useEffect(()=>{a&&j([])},[a]);const oe=()=>{F(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(u.Dialog,{open:a,onClose:s,className:"upload",children:[e.jsxs(u.DialogTitle,{className:"upload--head",children:[e.jsx(O,{className:"upload--title",children:e.jsx(h.Typography,{type:"s3",ml:1,weight:"medium",color:"theme.secondary.1000",children:r})}),e.jsxs("div",{children:[e.jsx(u.IconButton,{disableRipple:!0,onClick:re,children:e.jsx(je,{})}),e.jsx(u.IconButton,{disableRipple:!0,onClick:ne,children:e.jsx(l,{})})]})]}),e.jsx(u.Divider,{}),e.jsx(u.DialogContent,{className:"upload--content",children:0===b.length?e.jsx("div",{className:"upload--fileContent "+(V?"drag-active":""),children:e.jsx("div",{...Y(),className:"drop-view",children:M?e.jsxs("div",{className:"after-drop",children:[e.jsx("img",{src:d.images.upload.documentUpload}),e.jsx(h.Typography,{type:"s3",children:"Drag & Drop your files here"})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{...W(),ref:K}),e.jsx("p",{className:"upload--text",children:"Drag and Drop files here or upload from"}),e.jsxs("div",{className:"device-wrap",children:[e.jsxs("div",{className:"select-button",onClick:te,children:[e.jsx("img",{src:d.images.upload.monitor}),e.jsx(h.Typography,{type:"s5",children:"My Device"}),e.jsx("input",{type:"file",...W({multiple:!0}),ref:K,style:{display:"none"},onChange:async()=>{J()},accept:p})]}),e.jsxs("div",{className:"select-button",onClick:te,children:[e.jsx("img",{src:d.images.upload.camera}),e.jsx(h.Typography,{type:"s5",children:"Camera"}),e.jsx("input",{type:"file",...W({multiple:!0}),ref:K,style:{display:"none"},onChange:ae,accept:p})]})]})]})})}):e.jsx("div",{className:"main-container",children:e.jsxs("div",{className:"body-section",children:[e.jsx("div",{className:"document-section",children:e.jsx("div",{className:"document-body",children:b.map((t,a)=>{var l,r,i;return e.jsxs("div",{className:"upload-list",children:[e.jsxs("div",{className:"document-cover",children:[e.jsxs("div",{className:"document-name",children:[G(null==t?void 0:t.file),e.jsx("div",{className:"document-title",children:e.jsxs("div",{className:"document-box",children:[e.jsx("div",{className:"document-desc",children:null==(l=null==t?void 0:t.file)?void 0:l.name}),e.jsxs("div",{className:"document-size",children:[Wt(null==(r=null==t?void 0:t.file)?void 0:r.size),e.jsx("span",{className:"completed"===(null==t?void 0:t.status)&&(null==t?void 0:t.message.length)>0?"success-file":"fail-file",children:null==t?void 0:t.message})]})]})})]}),e.jsx("div",{className:"document-choices",children:"canceled"!==(null==t?void 0:t.status)?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"checkbox",children:[e.jsx(n.Checkbox,{checked:(null==t?void 0:t.isPrivate)||"public"==f,onChange:()=>(e=>{j(t=>t.map((t,a)=>a===e?{...t,isPrivate:!t.isPrivate}:t))})(a),disabled:(null==t?void 0:t.checkboxDisabled)||"public"==f}),e.jsx("div",{className:"checkbox-text",children:"Public"})]}),e.jsx("div",{className:"delete-icon",onClick:()=>le(a),children:e.jsx(o.Avatar,{size:24,src:d.images.upload.trash})})]}):e.jsx(h.Typography,{type:"s4",className:"canceled-text",children:"Upload Canceled"})})]},null==(i=null==t?void 0:t.file)?void 0:i.name),e.jsx("div",{className:"document-progress",children:(null==t?void 0:t.uploadProgress)>0&&e.jsx(fe,{color:"success",variant:"determinate",value:null==t?void 0:t.uploadProgress})})]},a)})})}),g&&e.jsxs(e.Fragment,{children:[e.jsx(S.Chip,{className:"add-file",variant:"outlined",type:"normal",label:"Add File",icon:e.jsx(c.Add,{}),onClick:te}),e.jsx("input",{type:"file",...W({multiple:!0}),ref:K,style:{display:"none"},onChange:ae,accept:p})]})]})})}),e.jsx(u.Divider,{}),e.jsxs(u.DialogActions,{className:"upload--actions",children:[e.jsx(o.Button,{variant:"text",onClick:ne,children:"Cancel"}),e.jsx(o.Button,{color:"secondary",onClick:J,disabled:!b.length||w,children:"Upload"})]})]}),_&&e.jsxs("div",{className:"bottom-corner-box",children:[e.jsxs("div",{className:"top-section",children:[e.jsxs("div",{className:"top-text",children:["Uploading ",b.length," Item",1!==b.length?"s":""]}),e.jsxs("div",{className:"top-options",children:[e.jsx("div",{className:"btn",onClick:re,children:e.jsx(je,{})}),e.jsx("div",{className:"btn",onClick:()=>{k(e=>!e)},children:e.jsx("div",{className:"arrow-btn",children:T?e.jsx(c.KeyboardArrowUp,{}):e.jsx(c.KeyboardArrowDown,{})})}),e.jsx("div",{className:"btn",onClick:ne,children:e.jsx(c.Clear,{})})]})]}),e.jsx("div",{className:"box-list",children:!T&&b.map((t,a)=>{var l;return e.jsxs("div",{className:"bottom-section",children:[e.jsx("div",{className:"doc-icon",children:G(null==t?void 0:t.file)}),e.jsxs("div",{className:"file-detail",children:[e.jsx("div",{className:"file-name",children:e.jsxs("div",{className:"file-text",children:[null==(l=null==t?void 0:t.file)?void 0:l.name,a]})}),e.jsx("div",{className:"file-status",children:"canceled"!==(null==t?void 0:t.status)?e.jsxs(e.Fragment,{children:[0===t.uploadProgress&&e.jsxs("div",{className:"avatar-container",children:[e.jsx(o.Avatar,{size:20,className:"avatar",src:d.images.upload.empty}),e.jsx(o.Avatar,{size:20,onClick:()=>le(a),src:d.images.upload.close,className:"close-icon"})]}),(null==t?void 0:t.uploadProgress)>0&&(null==t?void 0:t.uploadProgress)<100&&e.jsx(u.CircularProgress,{color:"success",variant:"determinate",value:null==t?void 0:t.uploadProgress}),100===(null==t?void 0:t.uploadProgress)&&e.jsxs("div",{className:"avatar-container",children:[e.jsx(o.Avatar,{size:20,className:"avatar",src:d.images.upload.tick}),e.jsx(o.Avatar,{size:20,src:d.images.upload.folder,className:"close-icon"})]})]}):e.jsx(h.Typography,{type:"s4",className:"canceled-text",children:"Upload Canceled"})})]})]})})})]}),P&&e.jsx(Yt,{title:$,open:P,onClose:oe,onReplace:async()=>{const e=`${we.getApiConfig().backendBaseUrl}`,t=null==y?void 0:y.filter(e=>e.title===$)[0].id,a={"Content-type":"application/json; charset=utf-8"},l=localStorage.getItem(we.auth.storageTokenKeyName)||"";a["x-token"]=l,await fetch(`${e}/document/v1/drive/${t}`,{method:"DELETE",headers:a}),oe()},onKeepBoth:()=>{oe()},isFile:!0}),e.jsx(o.Toast,{open:Boolean(q),type:null==q?void 0:q.type,message:null==q?void 0:q.message,handleClose:()=>L(null),anchorOrigin:{horizontal:"right",vertical:"bottom"}})]})},exports.UserDropdown=t=>{const{value:a,data:l,onCheckboxChange:r,...o}=t,{isRoleVisible:s,selectedUsers:d}=a,[c,u]=i.useState(d),[m,p]=i.useState([]),x=(e,t)=>()=>{const a=c.findIndex(t=>t.id===e),l=[...c];-1===a?l.push(t):l.splice(a,1),u(l),r(l)};return i.useEffect(()=>{p(s?(null==l?void 0:l.departments)??[]:(null==l?void 0:l.users)??[])},[s,l]),e.jsx("div",{className:"SwitchList",...o,children:e.jsx(Ce,{children:m&&(null==m?void 0:m.map(t=>{var a;const l=`checkbox-list-secondary-label-${t.id}`;return e.jsxs(Se,{sx:{cursor:"pointer"},onClick:x(t.id,t),children:[e.jsx(Te,{id:l,children:e.jsx(h.Typography,{dangerouslySetInnerHTML:{__html:`${s?null==t?void 0:t.name:`${null==t?void 0:t.first_name} ${null==t?void 0:t.last_name}`} <span>${s?t.count+" Users":null==(a=null==t?void 0:t.department)?void 0:a.name}</span>`}})}),e.jsx("div",{className:"list-secondary-content",children:e.jsx(n.Checkbox,{edge:"end",checked:c.some(e=>e.id===t.id),inputProps:{"aria-labelledby":l}})})]},t.id)}))})})},exports.createPermissionConfig={single:(e,t)=>({module:e,action:t}),multiModule:(e,t,a="OR")=>({multiModule:{modules:e,action:t,operator:a}}),complex:(e,t="AND")=>({complexPermissions:{permissions:e,operator:t}}),custom:e=>({customPermissionCheck:e})},exports.dynamicFields=ja,exports.fields=ba,exports.validator=e=>!!e.value;
|
|
2
|
+
//# sourceMappingURL=ai-summary-4NVNEHfi.js.map
|