/*! For license information please see main.4ee79c04.js.LICENSE.txt */ (()=>{var e={45:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(8587);function o(e,t){if(null==e)return{};var n,o,a=(0,r.A)(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o{"use strict";n.d(t,{A:()=>a});var r=n(9379),o=n(8387);function a(e,t){if(!e)return t;function n(e,t){const n={};return Object.keys(t).forEach(r=>{(function(e,t){const n=e.charCodeAt(2);return"o"===e[0]&&"n"===e[1]&&n>=65&&n<=90&&"function"===typeof t})(r,t[r])&&"function"===typeof e[r]&&(n[r]=function(){e[r](...arguments),t[r](...arguments)})}),n}if("function"===typeof e||"function"===typeof t)return a=>{const i="function"===typeof t?t(a):t,s="function"===typeof e?e((0,r.A)((0,r.A)({},a),i)):e,l=(0,o.A)(null===a||void 0===a?void 0:a.className,null===i||void 0===i?void 0:i.className,null===s||void 0===s?void 0:s.className),c=n(s,i);return(0,r.A)((0,r.A)((0,r.A)((0,r.A)((0,r.A)((0,r.A)({},i),s),c),!!l&&{className:l}),(null===i||void 0===i?void 0:i.style)&&(null===s||void 0===s?void 0:s.style)&&{style:(0,r.A)((0,r.A)({},i.style),s.style)}),(null===i||void 0===i?void 0:i.sx)&&(null===s||void 0===s?void 0:s.sx)&&{sx:[...Array.isArray(i.sx)?i.sx:[i.sx],...Array.isArray(s.sx)?s.sx:[s.sx]]})};const a=t,i=n(e,a),s=(0,o.A)(null===a||void 0===a?void 0:a.className,null===e||void 0===e?void 0:e.className);return(0,r.A)((0,r.A)((0,r.A)((0,r.A)((0,r.A)((0,r.A)({},t),e),i),!!s&&{className:s}),(null===a||void 0===a?void 0:a.style)&&(null===e||void 0===e?void 0:e.style)&&{style:(0,r.A)((0,r.A)({},a.style),e.style)}),(null===a||void 0===a?void 0:a.sx)&&(null===e||void 0===e?void 0:e.sx)&&{sx:[...Array.isArray(a.sx)?a.sx:[a.sx],...Array.isArray(e.sx)?e.sx:[e.sx]]})}},159:(e,t,n)=>{"use strict";n.d(t,{Ay:()=>s,BO:()=>i,Yn:()=>a});var r=n(3635),o=n(6167);function a(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!t||"string"!==typeof t)return null;if(e&&e.vars&&n){const n="vars.".concat(t).split(".").reduce((e,t)=>e&&e[t]?e[t]:null,e);if(null!=n)return n}return t.split(".").reduce((e,t)=>e&&null!=e[t]?e[t]:null,e)}function i(e,t,n){let r,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n;return r="function"===typeof e?e(n):Array.isArray(e)?e[n]||o:a(e,n)||o,t&&(r=t(r,o,e)),r}const s=function(e){const{prop:t,cssProperty:n=e.prop,themeKey:s,transform:l}=e,c=e=>{if(null==e[t])return null;const c=e[t],u=a(e.theme,s)||{};return(0,o.NI)(e,c,e=>{let o=i(u,l,e);return e===o&&"string"===typeof e&&(o=i(u,l,"".concat(t).concat("default"===e?"":(0,r.A)(e)),e)),!1===n?o:{[n]:o}})};return c.propTypes={},c.filterProps=[t],c}},172:(e,t,n)=>{"use strict";n.d(t,{A:()=>O});var r=n(9379),o=n(45),a=n(7528),i=n(5043),s=n(8387),l=n(1807),c=n(3290),u=n(8128),d=n(1612),p=n(8301),f=n(7194),m=n(4412),h=n(9857),g=n(6061);function y(e){return(0,g.Ay)("MuiCircularProgress",e)}(0,h.A)("MuiCircularProgress",["root","determinate","indeterminate","colorPrimary","colorSecondary","svg","circle","circleDeterminate","circleIndeterminate","circleDisableShrink"]);var v=n(579);const A=["className","color","disableShrink","size","style","thickness","value","variant"];var b,w,S,k;const x=44,C=(0,c.i7)(b||(b=(0,a.A)(["\n 0% {\n transform: rotate(0deg);\n }\n\n 100% {\n transform: rotate(360deg);\n }\n"]))),E=(0,c.i7)(w||(w=(0,a.A)(["\n 0% {\n stroke-dasharray: 1px, 200px;\n stroke-dashoffset: 0;\n }\n\n 50% {\n stroke-dasharray: 100px, 200px;\n stroke-dashoffset: -15px;\n }\n\n 100% {\n stroke-dasharray: 1px, 200px;\n stroke-dashoffset: -126px;\n }\n"]))),T="string"!==typeof C?(0,c.AH)(S||(S=(0,a.A)(["\n animation: "," 1.4s linear infinite;\n "])),C):null,N="string"!==typeof E?(0,c.AH)(k||(k=(0,a.A)(["\n animation: "," 1.4s ease-in-out infinite;\n "])),E):null,P=(0,u.Ay)("span",{name:"MuiCircularProgress",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,t[n.variant],t["color".concat((0,f.A)(n.color))]]}})((0,d.A)(e=>{let{theme:t}=e;return{display:"inline-block",variants:[{props:{variant:"determinate"},style:{transition:t.transitions.create("transform")}},{props:{variant:"indeterminate"},style:T||{animation:"".concat(C," 1.4s linear infinite")}},...Object.entries(t.palette).filter((0,m.A)()).map(e=>{let[n]=e;return{props:{color:n},style:{color:(t.vars||t).palette[n].main}}})]}})),M=(0,u.Ay)("svg",{name:"MuiCircularProgress",slot:"Svg"})({display:"block"}),R=(0,u.Ay)("circle",{name:"MuiCircularProgress",slot:"Circle",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.circle,t["circle".concat((0,f.A)(n.variant))],n.disableShrink&&t.circleDisableShrink]}})((0,d.A)(e=>{let{theme:t}=e;return{stroke:"currentColor",variants:[{props:{variant:"determinate"},style:{transition:t.transitions.create("stroke-dashoffset")}},{props:{variant:"indeterminate"},style:{strokeDasharray:"80px, 200px",strokeDashoffset:0}},{props:e=>{let{ownerState:t}=e;return"indeterminate"===t.variant&&!t.disableShrink},style:N||{animation:"".concat(E," 1.4s ease-in-out infinite")}}]}})),O=i.forwardRef(function(e,t){const n=(0,p.b)({props:e,name:"MuiCircularProgress"}),{className:a,color:i="primary",disableShrink:c=!1,size:u=40,style:d,thickness:m=3.6,value:h=0,variant:g="indeterminate"}=n,b=(0,o.A)(n,A),w=(0,r.A)((0,r.A)({},n),{},{color:i,disableShrink:c,size:u,thickness:m,value:h,variant:g}),S=(e=>{const{classes:t,variant:n,color:r,disableShrink:o}=e,a={root:["root",n,"color".concat((0,f.A)(r))],svg:["svg"],circle:["circle","circle".concat((0,f.A)(n)),o&&"circleDisableShrink"]};return(0,l.A)(a,y,t)})(w),k={},C={},E={};if("determinate"===g){const e=2*Math.PI*((x-m)/2);k.strokeDasharray=e.toFixed(3),E["aria-valuenow"]=Math.round(h),k.strokeDashoffset="".concat(((100-h)/100*e).toFixed(3),"px"),C.transform="rotate(-90deg)"}return(0,v.jsx)(P,(0,r.A)((0,r.A)((0,r.A)({className:(0,s.A)(S.root,a),style:(0,r.A)((0,r.A)({width:u,height:u},C),d),ownerState:w,ref:t,role:"progressbar"},E),b),{},{children:(0,v.jsx)(M,{className:S.svg,ownerState:w,viewBox:"".concat(22," ").concat(22," ").concat(x," ").concat(x),children:(0,v.jsx)(R,{className:S.circle,style:k,ownerState:w,cx:x,cy:x,r:(x-m)/2,fill:"none",strokeWidth:m})})}))})},191:(e,t)=>{"use strict";var n=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler");Symbol.for("react.provider");var s=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.for("react.view_transition"),h=Symbol.for("react.client.reference");function g(e){if("object"===typeof e&&null!==e){var t=e.$$typeof;switch(t){case n:switch(e=e.type){case o:case i:case a:case u:case d:case m:return e;default:switch(e=e&&e.$$typeof){case l:case c:case f:case p:case s:return e;default:return t}}case r:return t}}}t.Hy=function(e){return"string"===typeof e||"function"===typeof e||e===o||e===i||e===a||e===u||e===d||"object"===typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===p||e.$$typeof===l||e.$$typeof===s||e.$$typeof===c||e.$$typeof===h||void 0!==e.getModuleId)}},219:(e,t,n)=>{"use strict";var r=n(3763),o={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},a={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},i={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};function l(e){return r.isMemo(e)?i:s[e.$$typeof]||o}s[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s[r.Memo]=i;var c=Object.defineProperty,u=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols,p=Object.getOwnPropertyDescriptor,f=Object.getPrototypeOf,m=Object.prototype;e.exports=function e(t,n,r){if("string"!==typeof n){if(m){var o=f(n);o&&o!==m&&e(t,o,r)}var i=u(n);d&&(i=i.concat(d(n)));for(var s=l(t),h=l(n),g=0;g{"use strict";n.d(t,{A:()=>i});n(5043);var r=n(4265),o=n(7333),a=n(416);function i(){const e=(0,r.A)(o.A);return e[a.A]||e}},405:(e,t,n)=>{"use strict";n.d(t,{A:()=>h});var r=n(9379),o=n(45),a=n(5043),i=n(8692),s=n(2475),l=n(267),c=n(6906),u=n(8348),d=n(579);const p=["addEndListener","appear","children","easing","in","onEnter","onEntered","onEntering","onExit","onExited","onExiting","style","timeout","TransitionComponent"],f=["ownerState"],m={entering:{opacity:1},entered:{opacity:1}},h=a.forwardRef(function(e,t){const n=(0,l.A)(),h={enter:n.transitions.duration.enteringScreen,exit:n.transitions.duration.leavingScreen},{addEndListener:g,appear:y=!0,children:v,easing:A,in:b,onEnter:w,onEntered:S,onEntering:k,onExit:x,onExited:C,onExiting:E,style:T,timeout:N=h,TransitionComponent:P=i.Ay}=e,M=(0,o.A)(e,p),R=a.useRef(null),O=(0,u.A)(R,(0,s.A)(v),t),j=e=>t=>{if(e){const n=R.current;void 0===t?e(n):e(n,t)}},L=j(k),I=j((e,t)=>{(0,c.q)(e);const r=(0,c.c)({style:T,timeout:N,easing:A},{mode:"enter"});e.style.webkitTransition=n.transitions.create("opacity",r),e.style.transition=n.transitions.create("opacity",r),w&&w(e,t)}),D=j(S),F=j(E),B=j(e=>{const t=(0,c.c)({style:T,timeout:N,easing:A},{mode:"exit"});e.style.webkitTransition=n.transitions.create("opacity",t),e.style.transition=n.transitions.create("opacity",t),x&&x(e)}),z=j(C);return(0,d.jsx)(P,(0,r.A)((0,r.A)({appear:y,in:b,nodeRef:R,onEnter:I,onEntered:D,onEntering:L,onExit:B,onExited:z,onExiting:F,addEndListener:e=>{g&&g(R.current,e)},timeout:N},M),{},{children:(e,t)=>{let{ownerState:n}=t,i=(0,o.A)(t,f);return a.cloneElement(v,(0,r.A)({style:(0,r.A)((0,r.A)((0,r.A)({opacity:0,visibility:"exited"!==e||b?void 0:"hidden"},m[e]),T),v.props.style),ref:O},i))}}))})},416:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r="$$material"},446:function(e){e.exports=function(){"use strict";var e=1e3,t=6e4,n=36e5,r="millisecond",o="second",a="minute",i="hour",s="day",l="week",c="month",u="quarter",d="year",p="date",f="Invalid Date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}},y=function(e,t,n){var r=String(e);return!r||r.length>=t?e:""+Array(t+1-r.length).join(n)+e},v={s:y,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),o=n%60;return(t<=0?"+":"-")+y(r,2,"0")+":"+y(o,2,"0")},m:function e(t,n){if(t.date()1)return e(i[0])}else{var s=t.name;b[s]=t,o=s}return!r&&o&&(A=o),o||!r&&A},x=function(e,t){if(S(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new E(n)},C=v;C.l=k,C.i=S,C.w=function(e,t){return x(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=k(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[w]=!0}var y=g.prototype;return y.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(C.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(m);if(r){var o=r[2]-1||0,a=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],o,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],o,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},y.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},y.$utils=function(){return C},y.isValid=function(){return!(this.$d.toString()===f)},y.isSame=function(e,t){var n=x(e);return this.startOf(t)<=n&&n<=this.endOf(t)},y.isAfter=function(e,t){return x(e){"use strict";n.d(t,{A:()=>r});const r=function(e){return"ownerState"!==e&&"theme"!==e&&"sx"!==e&&"as"!==e}},579:(e,t,n)=>{"use strict";e.exports=n(2799)},706:(e,t,n)=>{"use strict";n.d(t,{K:()=>c});var r=n(45),o=n(9379);const a=JSON.parse('{"p":[{"id":"1","employeeId":"EMP001","firstName":"John","lastName":"Doe","fullName":"John Doe","title":"Operations Manager","email":"john.doe@company.com","officialEmail":"john.doe@company.com","mobileNumber":"+919876543210","panCard":"ABCDE1234F","adharNumber":"123456789012","dateOfBirth":"1990-01-15","gender":"Male","bloodGroup":"O+","fathersName":"Robert Doe","maritalStatus":"married","address":"123 Main Street","city":"Mumbai","state":"Maharashtra","pincode":"400001","dateOfJoining":"2020-01-15","employmentType":"full_time","employeeRole":"manager","reportingManager":"Manager 1","bankName":"State Bank of India","accountName":"John Doe","accountType":"SAVINGS","accountNumber":"1234567890","ifscCode":"SBIN0001234","epfNumber":"EPF123456789","uanNumber":"UAN123456789","emergencyContact":"+919876543211","status":"active","profilePic":null,"createdAt":"2020-01-15T10:30:00Z","updatedAt":"2023-12-01T15:45:00Z","createdBy":"admin","updatedBy":"admin"},{"id":"2","employeeId":"EMP002","firstName":"Jane","lastName":"Smith","fullName":"Jane Smith","title":"Operations Manager","email":"jane.smith@company.com","officialEmail":"jane.smith@company.com","mobileNumber":"+919876543212","panCard":"FGHIJ5678K","adharNumber":"987654321098","dateOfBirth":"1988-05-20","gender":"Female","bloodGroup":"A+","fathersName":"Michael Smith","maritalStatus":"single","address":"456 Oak Avenue","city":"Delhi","state":"Delhi","pincode":"110001","dateOfJoining":"2019-06-01","employmentType":"full_time","employeeRole":"manager","reportingManager":"Manager 2","bankName":"HDFC Bank","accountName":"Jane Smith","accountType":"CURRENT","accountNumber":"0987654321","ifscCode":"HDFC0001234","epfNumber":"EPF987654321","uanNumber":"UAN987654321","emergencyContact":"+919876543213","status":"active","profilePic":null,"createdAt":"2019-06-01T09:15:00Z","updatedAt":"2023-11-15T14:30:00Z","createdBy":"admin","updatedBy":"admin"}]}');var i=n(3845);const s=["vendorId","users","createdAt","updatedAt","addressLine1","addressLine2"],l=e=>new Promise(t=>setTimeout(t,e));const c=new class{setTokens(e,t){localStorage.setItem("accessToken",e),localStorage.setItem("refreshToken",t)}getAccessToken(){return localStorage.getItem("accessToken")}getRefreshToken(){return localStorage.getItem("refreshToken")}async refreshAccessToken(){try{const e=this.getRefreshToken();if(!e)return null;const t="".concat("https://139.59.48.74","/auth/refresh"),n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})});if(!n.ok)return this.clearTokens(),window.location.href="/login",null;const r=(await n.json()).accessToken;return localStorage.setItem("accessToken",r),r}catch(e){return console.error("Error refreshing access token:",e),this.clearTokens(),window.location.href="/login",null}}clearTokens(){localStorage.removeItem("accessToken"),localStorage.removeItem("refreshToken")}handleUnauthorizedResponse(e,t){throw console.error("401 Unauthorized from",e,"removing tokens and redirecting"),this.clearTokens(),window.location.href="/login",new Error("Unauthorized")}async authFetch(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const r=this.getAccessToken();r?console.log("Making authenticated request to:",e,"with token:",r.substring(0,20)+"..."):console.warn("No access token found for request:",e);const a=(0,o.A)((0,o.A)({},t.headers||{}),r?{Authorization:"Bearer ".concat(r)}:{}),i=await fetch(e,(0,o.A)((0,o.A)({},t),{},{headers:a}));if(console.log("Response status for",e,":",i.status),401===i.status&&this.getRefreshToken()&&0===n){console.log("401 received, attempting to refresh token and retry...");const n=await this.refreshAccessToken();if(n){const r=(0,o.A)((0,o.A)({},t.headers||{}),{},{Authorization:"Bearer ".concat(n)}),a=await fetch(e,(0,o.A)((0,o.A)({},t),{},{headers:r}));return 401===a.status&&this.handleUnauthorizedResponse(e,a),a}}return 401===i.status&&this.handleUnauthorizedResponse(e,i),i}async handleAuthFetch(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=await fetch(e,t);return 401===n.status&&this.handleUnauthorizedResponse(e,n),n}getImageUrl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"thumb";return"".concat("https://139.59.48.74","/api/files/image?size=").concat(t,"&path=").concat(encodeURIComponent(e))}async getCustomersRaw(){let{page:e=1,limit:t=10,from:n="",to:r="",sortBy:a="",sortDir:i="",search:s=""}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const l=new URLSearchParams((0,o.A)((0,o.A)((0,o.A)((0,o.A)((0,o.A)({pageNo:String(e),limit:String(t)},n?{from:n}:{}),r?{to:r}:{}),a?{sortBy:a}:{}),i?{sortDir:i}:{}),s?{search:s}:{})),c="".concat("https://139.59.48.74","/api/users/customers?").concat(l.toString()),u=await this.authFetch(c);if(!u.ok)throw new Error("Failed to fetch customers");return u.json()}async getCustomers(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const t=await this.getCustomersRaw(e);return{success:!0,data:t.data,pagination:{page:t.current_page,limit:t.per_page,total:t.total_items,totalPages:t.total_pages}}}catch(n){var t;return(null!==n&&void 0!==n&&null!==(t=n.message)&&void 0!==t&&t.toLowerCase().includes("401")||"Unauthorized"===(null===n||void 0===n?void 0:n.message))&&(this.clearTokens(),window.location.href="/login"),{success:!1,data:[],message:n instanceof Error?n.message:"Failed to fetch customers"}}}async searchCustomers(e){try{const t="".concat("https://139.59.48.74","/api/users/customers/search?keyword=").concat(encodeURIComponent(e)),n=await this.authFetch(t);if(!n.ok)throw new Error("Failed to search customers");const r=await n.json();return{success:!0,data:Array.isArray(r)?r:[],message:"Search completed successfully"}}catch(n){var t;return(null!==n&&void 0!==n&&null!==(t=n.message)&&void 0!==t&&t.toLowerCase().includes("401")||"Unauthorized"===(null===n||void 0===n?void 0:n.message))&&(this.clearTokens(),window.location.href="/login"),{success:!1,data:[],message:n instanceof Error?n.message:"Failed to search customers"}}}async globalSearch(e){try{const t="".concat("https://139.59.48.74","/api/users/search?keyword=").concat(encodeURIComponent(e)),n=await this.authFetch(t);if(!n.ok)throw new Error("Failed to perform global search");const r=await n.json();return console.log("Global search API response:",r),console.log("Vendors in search results:",r.vendors),r.vendors&&r.vendors.length>0&&console.log("First vendor from search:",r.vendors[0]),{success:!0,data:r,message:"Global search completed successfully"}}catch(n){var t;return(null!==n&&void 0!==n&&null!==(t=n.message)&&void 0!==t&&t.toLowerCase().includes("401")||"Unauthorized"===(null===n||void 0===n?void 0:n.message))&&(this.clearTokens(),window.location.href="/login"),{success:!1,data:{customers:[],vendors:[],managers:[]},message:n instanceof Error?n.message:"Failed to perform global search"}}}async getCustomerById(e){const t="".concat("https://139.59.48.74","/api/users/customer/").concat(e),n=await this.authFetch(t);if(!n.ok)throw new Error("Failed to fetch customer stages");return n.json()}async createCustomer(e){const t="".concat("https://139.59.48.74","/api/users/customer"),n={username:e.username||e.mobileNumber||e.email,email:e.email,admin:null,customer:{id:null,firstName:e.firstName,lastName:e.lastName,title:e.title,fullName:"".concat(e.firstName," ").concat(e.lastName).trim(),mobileNumber:e.mobileNumber,panCard:e.panCard,adharNumber:e.adharNumber,gstin:e.gstin||null,dateOfBirth:e.dateOfBirth,gender:e.gender,pincode:e.pincode,accountName:e.accountName||null,accountType:e.accountType,stateCode:e.stateCode||null,ifscCode:e.ifscCode,accountNumber:e.accountNumber,address:e.address||null,city:e.city||null,phoneNumber:null,altPhoneNumber:null,createdBy:null,createdAt:null,updatedBy:null,updatedAt:null,status:null,plotNo:null,agreementDocument:null,isActive:void 0===e.active||e.active}},r=await this.authFetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const e=await r.json();return 409===r.status&&e.field&&e.error?{success:!1,data:void 0,message:"".concat(e.field,": ").concat(e.error),field:e.field,fieldError:e.error}:{success:!1,data:void 0,message:e.message||"Failed to create customer"}}return{success:!0,data:await r.json(),message:"Customer created successfully"}}async updateCustomer(e,t){const n="".concat("https://139.59.48.74","/api/users/customer/").concat(e);console.log("updateCustomer - Received customerData:",t),console.log("updateCustomer - Received customerData keys:",Object.keys(t));const r=(0,o.A)((0,o.A)({},t),{},{id:e});console.log("updateCustomer - Final payload:",r),console.log("updateCustomer - Final payload keys:",Object.keys(r));try{const e=await this.authFetch(n,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!e.ok){const t=await e.json();return 409===e.status&&t.field&&t.error?{success:!1,data:void 0,message:"".concat(t.field,": ").concat(t.error),field:t.field,fieldError:t.error}:{success:!1,data:void 0,message:t.message||"Failed to update customer"}}return{success:!0,data:await e.json(),message:"Customer updated successfully"}}catch(a){return console.error("Error updating customer:",a),{success:!1,data:void 0,message:a instanceof Error?a.message:"An error occurred while updating customer"}}}async updateCustomerStage(e){const t="".concat("https://139.59.48.74","/api/users/customer/stage"),n=await this.authFetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error("Failed to update customer stage");return n.json()}async updateDemandStage(e,t){const n="".concat("https://139.59.48.74","/api/customers/").concat(e,"/stages"),r=await this.authFetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error("Failed to update demand stage");return r.json()}async getCustomerPlots(e){try{const t="".concat("https://139.59.48.74","/api/sectors/plots?customerId=").concat(e,"&page=0&size=100"),n=await this.authFetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){return{success:!1,data:[],message:(await n.json()).message||"Failed to fetch customer plots"}}const r=await n.json();let o,a=[];return Array.isArray(r)?a=r:r.content&&Array.isArray(r.content)?(a=r.content,o={total:r.totalElements||0,page:r.number||0,limit:r.size||100,totalPages:r.totalPages||0}):r.data&&Array.isArray(r.data)?(a=r.data,o=r.pagination):a=Array.isArray(r)?r:[],{success:!0,data:a,message:a.length?"Plots found":"No plots found for this customer",pagination:o}}catch(t){return console.error("Error fetching customer plots:",t),{success:!1,data:[],message:t instanceof Error?t.message:"An error occurred while fetching customer plots"}}}async getCustomerPlotsWithCategoryTasks(e){try{const t="".concat("https://139.59.48.74","/api/sectors/plots?customerId=").concat(e,"&page=0&size=100&includeCategoryTasks=true"),n=await this.authFetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){return{success:!1,data:[],message:(await n.json()).message||"Failed to fetch customer plots with category tasks"}}const r=await n.json();let o,a=[];return Array.isArray(r)?a=r:r.content&&Array.isArray(r.content)?(a=r.content,o={total:r.totalElements||0,page:r.number||0,limit:r.size||100,totalPages:r.totalPages||0}):r.data&&Array.isArray(r.data)?(a=r.data,o=r.pagination):a=Array.isArray(r)?r:[],{success:!0,data:a,message:a.length?"Plots with category tasks found":"No plots found for this customer",pagination:o}}catch(t){return console.error("Error fetching customer plots with category tasks:",t),{success:!1,data:[],message:t instanceof Error?t.message:"An error occurred while fetching customer plots with category tasks"}}}async getCustomerPayments(e){throw new Error("getCustomerPayments is not implemented yet. Please provide the payment API details.")}async getCustomerStages(e){const t="".concat("https://139.59.48.74","/api/users/customer/").concat(e,"/stages"),n=await this.authFetch(t);if(!n.ok)throw new Error("Failed to fetch customer stages");return n.json()}async getCustomerDemands(e){const t="".concat("https://139.59.48.74","/api/demands/customer/").concat(e),n=await this.authFetch(t,{headers:{"Content-Type":"application/json"}});if(!n.ok)throw new Error("Failed to fetch demands");const r=await n.json();return Array.isArray(r)?r:r.data}async getStatusAndDemandsAndPayments(e){const t=await this.getCustomerStages(e);let n=[];return t&&t.find(e=>"LAND_ORDER_CONFIRM"===e.stage)&&(n=await this.getCustomerDemands(e)),{statusData:t,demandData:n,paymentData:[]}}async deleteCustomer(e){try{const t="".concat("https://139.59.48.74","/api/users/customer/").concat(e),n=await this.authFetch(t,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!n.ok){return{success:!1,data:void 0,message:(await n.json()).message||"Failed to delete customer"}}return{success:!0,data:void 0,message:"Customer deleted successfully"}}catch(t){return console.error("Error deleting customer:",t),{success:!1,data:void 0,message:t instanceof Error?t.message:"An error occurred while deleting the customer"}}}async getEmployees(){let{page:e=1,limit:t=10,search:n=""}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};await l(500);let r=[...a.p];if(n){const e=n.toLowerCase();r=r.filter(t=>t.fullName.toLowerCase().includes(e)||t.employeeId.toLowerCase().includes(e)||t.email.toLowerCase().includes(e))}const o=(e-1)*t;return{success:!0,data:r.slice(o,o+t),pagination:{total:r.length,page:e,limit:t,totalPages:Math.ceil(r.length/t)}}}async createEmployee(e){try{var t;const n="".concat("https://139.59.48.74","/api/users/manager"),r={admin:null,customer:null,manager:{id:null,firstName:e.firstName||"",lastName:e.lastName||"",title:"manager"===e.employeeRole?"Operations Manager":"",mobileNumber:e.mobileNumber||"",altPhoneNumber:"",address:e.address||"",employeeId:e.employeeId||"",createdBy:null,createdAt:null,updatedBy:null,updatedAt:null,active:"active"===e.status,email:e.email||"",panCard:e.panCard||"",adharNumber:e.adharNumber||"",pincode:e.pincode||"",fullName:(e.firstName||"")+" "+(e.lastName||""),accountType:(null===(t=e.accountType)||void 0===t?void 0:t.toUpperCase())||"SAVINGS",gender:e.gender?e.gender.charAt(0).toUpperCase()+e.gender.slice(1):"",accountNumber:e.accountNumber||"",ifscCode:e.ifscCode||"",reportingManager:e.reportingManager||""},vendor:null,username:e.mobileNumber||""},o=await this.authFetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok){const e=await o.json();return 409===o.status&&e.field&&e.error?{success:!1,data:void 0,message:"".concat(e.field,": ").concat(e.error),field:e.field,fieldError:e.error}:{success:!1,data:void 0,message:e.message||"Failed to create employee"}}const a=o.headers.get("content-type");let i;return i=a&&a.includes("text/plain")?await o.text():await o.json(),{success:!0,data:i,message:"Employee created successfully"}}catch(n){return console.error("Error creating employee:",n),{success:!1,data:void 0,message:n instanceof Error?n.message:"An error occurred while creating the employee"}}}async updateEmployee(e,t){try{const o="".concat("https://139.59.48.74","/api/users/manager/").concat(e);console.log("updateEmployee - URL:",o),console.log("updateEmployee - Employee data (changed fields only):",t),console.log("updateEmployee - Changed fields count:",Object.keys(t).length),console.log("updateEmployee - Changed fields keys:",Object.keys(t)),console.log("updateEmployee - Changed fields values:",Object.values(t));const a={id:e};if(this.hasMeaningfulValue(t.firstName)&&(a.firstName=t.firstName,console.log("Adding firstName:",t.firstName)),this.hasMeaningfulValue(t.lastName)&&(a.lastName=t.lastName,console.log("Adding lastName:",t.lastName)),void 0!==t.employeeRole&&null!==t.employeeRole){const e="manager"===t.employeeRole?"Operations Manager":null;null!==e&&(a.title=e,console.log("Adding title:",e))}var n;if(this.hasMeaningfulValue(t.mobileNumber)&&(a.mobileNumber=t.mobileNumber,console.log("Adding mobileNumber:",t.mobileNumber)),this.hasMeaningfulValue(t.address)&&(a.address=t.address,console.log("Adding address:",t.address)),this.hasMeaningfulValue(t.employeeId)&&(a.employeeId=t.employeeId,console.log("Adding employeeId:",t.employeeId)),void 0!==t.status&&null!==t.status&&(a.active="active"===t.status,console.log("Adding active status:","active"===t.status)),this.hasMeaningfulValue(t.email)&&(a.email=t.email,console.log("Adding email:",t.email)),this.hasMeaningfulValue(t.panCard)&&(a.panCard=t.panCard,console.log("Adding panCard:",t.panCard)),this.hasMeaningfulValue(t.adharNumber)&&(a.adharNumber=t.adharNumber,console.log("Adding adharNumber:",t.adharNumber)),this.hasMeaningfulValue(t.dateOfBirth)&&(a.dateOfBirth=t.dateOfBirth,console.log("Adding dateOfBirth:",t.dateOfBirth)),this.hasMeaningfulValue(t.dateOfJoining)&&(a.dateOfJoining=t.dateOfJoining,console.log("Adding dateOfJoining:",t.dateOfJoining)),this.hasMeaningfulValue(t.pincode)&&(a.pincode=t.pincode,console.log("Adding pincode:",t.pincode)),this.hasMeaningfulValue(t.firstName)&&this.hasMeaningfulValue(t.lastName)&&(a.fullName="".concat(t.firstName," ").concat(t.lastName).trim(),console.log("Adding fullName:",a.fullName)),void 0!==t.accountType&&null!==t.accountType)a.accountType=null===(n=t.accountType)||void 0===n?void 0:n.toUpperCase(),console.log("Adding accountType:",a.accountType);void 0!==t.gender&&null!==t.gender&&(a.gender=t.gender,console.log("Adding gender:",t.gender)),this.hasMeaningfulValue(t.bloodGroup)&&(a.bloodGroup=t.bloodGroup,console.log("Adding bloodGroup:",t.bloodGroup)),this.hasMeaningfulValue(t.fathersName)&&(a.fathersName=t.fathersName,console.log("Adding fathersName:",t.fathersName)),void 0!==t.maritalStatus&&null!==t.maritalStatus&&(a.maritalStatus=t.maritalStatus,console.log("Adding maritalStatus:",t.maritalStatus)),this.hasMeaningfulValue(t.city)&&(a.city=t.city,console.log("Adding city:",t.city)),this.hasMeaningfulValue(t.state)&&(a.stateCode=t.state,console.log("Adding stateCode:",t.state)),void 0!==t.employmentType&&null!==t.employmentType&&(a.employmentType=t.employmentType,console.log("Adding employmentType:",t.employmentType)),this.hasMeaningfulValue(t.bankName)&&(a.bankName=t.bankName,console.log("Adding bankName:",t.bankName)),this.hasMeaningfulValue(t.accountName)&&(a.accountName=t.accountName,console.log("Adding accountName:",t.accountName)),this.hasMeaningfulValue(t.accountNumber)&&(a.accountNumber=t.accountNumber,console.log("Adding accountNumber:",t.accountNumber)),this.hasMeaningfulValue(t.ifscCode)&&(a.ifscCode=t.ifscCode,console.log("Adding ifscCode:",t.ifscCode)),this.hasMeaningfulValue(t.epfNumber)&&(a.epfNumber=t.epfNumber,console.log("Adding epfNumber:",t.epfNumber)),this.hasMeaningfulValue(t.uanNumber)&&(a.uanNumber=t.uanNumber,console.log("Adding uanNumber:",t.uanNumber)),this.hasMeaningfulValue(t.emergencyContact)&&(a.emergencyContact=t.emergencyContact,console.log("Adding emergencyContact:",t.emergencyContact)),this.hasMeaningfulValue(t.reportingManager)&&(a.reportingManager=t.reportingManager,console.log("Adding reportingManager:",t.reportingManager)),console.log("updateEmployee - Final payload keys:",Object.keys(a)),console.log("updateEmployee - Final payload values:",Object.values(a)),console.log("updateEmployee - Final payload:",a);const i=await this.authFetch(o,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(console.log("updateEmployee - Response status:",i.status),console.log("updateEmployee - Response headers:",i.headers),!i.ok){let e="Failed to update employee";try{const t=await i.json();if(409===i.status&&t.field&&t.error)return{success:!1,data:void 0,message:"".concat(t.field,": ").concat(t.error),field:t.field,fieldError:t.error};e=t.message||t.error||e}catch(r){console.error("Failed to parse error response:",r)}return{success:!1,data:void 0,message:e}}const s=i.headers.get("content-type");let l;return l=s&&s.includes("text/plain")?await i.text():await i.json(),console.log("updateEmployee - Success response:",l),{success:!0,data:l,message:"Employee updated successfully"}}catch(o){return console.error("Error updating employee:",o),{success:!1,data:void 0,message:o instanceof Error?o.message:"An error occurred while updating the employee"}}}async deleteEmployee(e,t){try{const n="https://139.59.48.74";let r;r="admin"===t?"".concat(n,"/api/users/admin/").concat(e):"".concat(n,"/api/users/manager/").concat(e);const o=await this.authFetch(r,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!o.ok){return{success:!1,data:void 0,message:(await o.json()).message||"Failed to delete employee"}}return{success:!0,data:void 0,message:"Employee deleted successfully"}}catch(n){return console.error("Error deleting employee:",n),{success:!1,data:void 0,message:n instanceof Error?n.message:"An error occurred while deleting the employee"}}}async getReportingManagers(){return await l(500),{success:!0,data:["Manager 1","Manager 2","Manager 3"],message:"Reporting managers retrieved successfully"}}async getVendors(){let{page:e=1,limit:t=10,search:n=""}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const r="".concat("https://139.59.48.74","/api/users/vendors"),a=new URLSearchParams((0,o.A)({page:e.toString(),limit:t.toString(),activeOnly:"true"},n&&{search:n})),i=await this.authFetch("".concat(r,"?").concat(a),{method:"GET",headers:{"Content-Type":"application/json"}});if(!i.ok){return{success:!1,data:[],message:(await i.json()).message||"Failed to fetch vendors"}}const s=await i.json();console.log("Raw vendor API response:",s);let l=[];if(Array.isArray(s))l=s;else if(s&&Array.isArray(s.data))l=s.data;else{if(!(s&&s.content&&Array.isArray(s.content)))return console.error("Unexpected API response structure:",s),{success:!1,data:[],message:"Invalid response format from server"};l=s.content}console.log("Vendors data to transform:",l);const c=l.map(e=>{console.log("Processing vendor:",e),console.log("vendor.isActive value:",e.isActive);const t=e.contactPersonFName||"",n=e.contactPersonLName||"",r={id:String(e.id),vendorId:e.vendorId||"VD".concat(e.id),name:e.vendorName||"",profilePic:e.profilePic||"",email:e.email||"",phone:e.mobileNumber||"",contactPersonFName:t,contactPersonLName:n,panCard:e.panCard||"",gstin:e.gstNumber||"",adharNumber:e.adharNumber||"",vendorType:(()=>{const t=e.vendorType;if(!t)return"";return{Supplier:"COMPANY",Individual:"INDIVIDUAL",Company:"COMPANY",Firm:"FIRM",Trust:"TRUST",NGO:"NGO"}[t]||t})(),businessCategory:(()=>{const t=e.businessCategory;if(!t)return"";return{Civil:"CIVIL",Gardner:"GARDNER","Vertical Construction":"VERTICAL CONSTRUCTION",VerticalConstruction:"VERTICAL CONSTRUCTION"}[t]||t})(),msmeUdyamNumber:e.msmeUdyamNumber||"",cin:e.cin||"",tan:e.tan||"",fssaiNumber:e.fssaiNumber||"",esicNumber:e.esicNumber||"",uan:e.uan||"",bankName:e.bankName||"",accountName:e.accountName||"",accountType:e.accountType||"",accountNumber:e.accountNumber||"",ifscCode:e.ifscCode||"",addressLine1:e.address||"",addressLine2:e.addressLine2||"",city:e.city||"",state:e.state||"",stateCode:e.stateCode||"",pincode:e.pincode||"",country:e.country||"",website:e.website||"",status:e.isActive?"Active":"Inactive",isActive:e.isActive||!1,documents:e.documents||[],users:e.users||[],createdAt:e.createdAt||"",updatedAt:e.updatedAt||""};return console.log("Transformed vendor - name:",r.name,"status:",r.status,"isActive:",r.isActive),r});return{success:!0,data:c,message:"Vendors fetched successfully",pagination:{total:s.total||s.totalElements||c.length,page:e,limit:t,totalPages:s.totalPages||Math.ceil((s.total||s.totalElements||c.length)/t)}}}catch(r){return console.error("Error fetching vendors:",r),{success:!1,data:[],message:r instanceof Error?r.message:"An error occurred while fetching vendors"}}}async searchVendors(e){try{const t="".concat("https://139.59.48.74","/api/users/vendors/search?keyword=").concat(encodeURIComponent(e)),n=await this.authFetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){return{success:!1,data:[],message:(await n.json()).message||"Failed to search vendors"}}const r=await n.json();return{success:!0,data:(r||[]).map(e=>({id:String(e.id),vendorId:e.vendorId||"VD".concat(e.id),name:e.vendorName||"",profilePic:e.profilePic||"",email:e.email||"",phone:e.mobileNumber||"",contactPersonFName:e.contactPersonFName||"",contactPersonLName:e.contactPersonLName||"",panCard:e.panCard||"",gstin:e.gstNumber||"",adharNumber:e.adharNumber||"",vendorType:(()=>{const t=e.vendorType;if(!t)return"";return{Supplier:"COMPANY",Individual:"INDIVIDUAL",Company:"COMPANY",Firm:"FIRM",Trust:"TRUST",NGO:"NGO"}[t]||t})(),businessCategory:(()=>{const t=e.businessCategory;if(!t)return"";return{Civil:"CIVIL",Gardner:"GARDNER","Vertical Construction":"VERTICAL CONSTRUCTION",VerticalConstruction:"VERTICAL CONSTRUCTION"}[t]||t})(),msmeUdyamNumber:e.msmeUdyamNumber||"",cin:e.cin||"",tan:e.tan||"",fssaiNumber:e.fssaiNumber||"",esicNumber:e.esicNumber||"",uan:e.uan||"",bankName:e.bankName||"",accountName:e.accountName||"",accountType:e.accountType||"",accountNumber:e.accountNumber||"",ifscCode:e.ifscCode||"",addressLine1:e.address||"",addressLine2:e.addressLine2||"",city:e.city||"",state:e.state||"",stateCode:e.stateCode||"",pincode:e.pincode||"",country:e.country||"",website:e.website||"",status:e.isActive?"Active":"Inactive",isActive:e.isActive||!1,documents:e.documents||[],users:e.users||[],createdAt:e.createdAt||"",updatedAt:e.updatedAt||""})),message:"Vendors search completed successfully"}}catch(t){return console.error("Error searching vendors:",t),{success:!1,data:[],message:t instanceof Error?t.message:"An error occurred while searching vendors"}}}async createVendor(e){try{var t;const r="".concat("https://139.59.48.74","/api/users/vendor");let o="";try{o=(await this.getUserProfile()).username}catch(n){return console.error("Failed to get user profile:",n),{success:!1,data:void 0,message:"Failed to get user information"}}const a={vendorName:e.name,contactPersonFName:e.contactPersonFName,contactPersonLName:e.contactPersonLName,profilePic:e.profilePic,email:e.email,mobileNumber:e.phone,panCard:e.panCard,gstNumber:e.gstin,adharNumber:e.adharNumber,vendorType:e.vendorType,businessCategory:e.businessCategory,msmeUdyamNumber:e.msmeUdyamNumber,cin:e.cin,tan:e.tan,fssaiNumber:e.fssaiNumber,esicNumber:e.esicNumber,uan:e.uan,bankName:e.bankName,accountName:e.accountName,accountType:(null===(t=e.accountType)||void 0===t?void 0:t.toUpperCase())||"SAVING",accountNumber:e.accountNumber,ifscCode:e.ifscCode,address:e.address,isActive:e.isActive,city:e.city,stateCode:e.stateCode,pincode:e.pincode,country:e.country,website:e.website,status:e.status},i={username:a.mobileNumber,email:a.email,vendor:a},s=await this.authFetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok){const e=await s.json();return 409===s.status&&e.field&&e.error?{success:!1,data:void 0,message:"".concat(e.field,": ").concat(e.error),field:e.field,fieldError:e.error}:{success:!1,data:void 0,message:e.message||"Failed to create vendor"}}return{success:!0,data:await s.json(),message:"Vendor created successfully"}}catch(n){return console.error("Error creating vendor:",n),{success:!1,data:void 0,message:n instanceof Error?n.message:"An error occurred while creating vendor"}}}async updateVendor(e,t){try{const n="".concat("https://139.59.48.74","/api/users/vendor/").concat(e);console.log("updateVendor - URL:",n),console.log("updateVendor - Vendor data (changed fields only):",t),console.log("updateVendor - Changed fields count:",Object.keys(t).length);const{vendorId:o,users:a,createdAt:i,updatedAt:l,addressLine1:c,addressLine2:u}=t,d=(0,r.A)(t,s),p={id:e};for(const[e,t]of Object.entries(d))void 0!==t&&null!==t&&""!==t&&(p[e]=t);const f=await this.authFetch(n,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(!f.ok){const e=await f.json();return 409===f.status&&e.field&&e.error?{success:!1,data:void 0,message:"".concat(e.field,": ").concat(e.error),field:e.field,fieldError:e.error}:{success:!1,data:void 0,message:e.message||"Failed to update vendor"}}return{success:!0,data:await f.json(),message:"Vendor updated successfully"}}catch(n){return console.error("Error updating vendor:",n),{success:!1,data:void 0,message:n instanceof Error?n.message:"An error occurred while updating vendor"}}}async deleteVendor(e){try{const t="".concat("https://139.59.48.74","/api/users/vendor/").concat(e),n=await this.authFetch(t,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!n.ok){return{success:!1,data:void 0,message:(await n.json()).message||"Failed to delete vendor"}}return{success:!0,data:void 0,message:"Vendor deleted successfully"}}catch(t){return console.error("Error deleting vendor:",t),{success:!1,data:void 0,message:t instanceof Error?t.message:"An error occurred while deleting vendor"}}}async getVendorUsers(e){try{const t="".concat("https://139.59.48.74","/api/users/vendor/").concat(e,"/users"),n=await this.authFetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(401===n.status&&this.handleUnauthorizedResponse(t,n),!n.ok){return{success:!1,data:[],message:(await n.json()).message||"Failed to fetch vendor users"}}const r=await n.json();return{success:!0,data:Array.isArray(r)?r:r.data||[],message:"Vendor users fetched successfully"}}catch(t){return{success:!1,data:[],message:t instanceof Error?t.message:"An error occurred while fetching vendor users"}}}async createVendorUser(e,t){try{const n="".concat("https://139.59.48.74","/api/users/vendor/").concat(e,"/user"),r=await this.authFetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const e=await r.json();return 409===r.status&&e.field&&e.error?{success:!1,data:void 0,message:"".concat(e.field,": ").concat(e.error),field:e.field,fieldError:e.error}:{success:!1,data:void 0,message:e.message||"Failed to create vendor user"}}return{success:!0,data:await r.json(),message:"Vendor user created successfully"}}catch(n){return console.error("Error creating vendor user:",n),{success:!1,data:void 0,message:n instanceof Error?n.message:"An error occurred while creating vendor user"}}}async updateVendorUser(e,t,n){try{const r="".concat("https://139.59.48.74","/api/users/vendor/").concat(e,"/user/").concat(t),o=await this.authFetch(r,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!o.ok){const e=await o.json();return 409===o.status&&e.field&&e.error?{success:!1,data:void 0,message:"".concat(e.field,": ").concat(e.error),field:e.field,fieldError:e.error}:{success:!1,data:void 0,message:e.message||"Failed to update vendor user"}}return{success:!0,data:await o.json(),message:"Vendor user updated successfully"}}catch(r){return console.error("Error updating vendor user:",r),{success:!1,data:void 0,message:r instanceof Error?r.message:"An error occurred while updating vendor user"}}}async deleteVendorUser(e,t){try{const n="".concat("https://139.59.48.74","/api/users/vendor/").concat(e,"/user/").concat(t),r=await this.authFetch(n,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!r.ok){return{success:!1,data:void 0,message:(await r.json()).message||"Failed to delete vendor user"}}return{success:!0,data:void 0,message:"Vendor user deleted successfully"}}catch(n){return console.error("Error deleting vendor user:",n),{success:!1,data:void 0,message:n instanceof Error?n.message:"An error occurred while deleting vendor user"}}}async getSectors(){const e="".concat("https://139.59.48.74","/api/sectors"),t=await this.authFetch(e,{headers:{"Content-Type":"application/json"}});if(!t.ok)throw new Error("Failed to fetch sectors");return t.json()}async createSector(e){try{const t="".concat("https://139.59.48.74","/api/sectors"),n=await this.authFetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const e=await n.json();return 409===n.status&&e.field&&e.error?{success:!1,data:void 0,message:"".concat(e.field,": ").concat(e.error),field:e.field,fieldError:e.error}:{success:!1,data:void 0,message:e.message||"Failed to create sector"}}return{success:!0,data:await n.json(),message:"Sector created successfully"}}catch(t){return console.error("Error creating sector:",t),{success:!1,data:void 0,message:t instanceof Error?t.message:"An error occurred while creating the sector"}}}async updateSector(e,t){try{const n="".concat("https://139.59.48.74","/api/sectors/").concat(e),r=await this.authFetch(n,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const e=await r.json();return 409===r.status&&e.field&&e.error?{success:!1,data:void 0,message:"".concat(e.field,": ").concat(e.error),field:e.field,fieldError:e.error}:{success:!1,data:void 0,message:e.message||"Failed to update sector"}}return{success:!0,data:await r.json(),message:"Sector updated successfully"}}catch(n){return console.error("Error updating sector:",n),{success:!1,data:void 0,message:n instanceof Error?n.message:"An error occurred while updating the sector"}}}async deleteSector(e){try{const t="".concat("https://139.59.48.74","/api/sectors/").concat(e),n=await this.authFetch(t,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!n.ok){return{success:!1,data:void 0,message:(await n.json()).message||"Failed to delete sector"}}return{success:!0,data:void 0,message:"Sector deleted successfully"}}catch(t){return console.error("Error deleting sector:",t),{success:!1,data:void 0,message:t instanceof Error?t.message:"An error occurred while deleting the sector"}}}async createPlot(e,t){try{const n="".concat("https://139.59.48.74","/api/sectors/").concat(e,"/plot"),r=await this.authFetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const e=await r.json();return 409===r.status&&e.field&&e.error?{success:!1,data:void 0,message:"".concat(e.field,": ").concat(e.error),field:e.field,fieldError:e.error}:{success:!1,data:void 0,message:e.message||"Failed to create plot"}}return{success:!0,data:await r.json(),message:"Plot created successfully"}}catch(n){return console.error("Error creating plot:",n),{success:!1,data:void 0,message:n instanceof Error?n.message:"An error occurred while creating the plot"}}}async updatePlot(e,t,n){try{const r="".concat("https://139.59.48.74","/api/sectors/").concat(e,"/plot/").concat(t),o=await this.authFetch(r,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!o.ok){const e=await o.json();return 409===o.status&&e.field&&e.error?{success:!1,data:void 0,message:"".concat(e.field,": ").concat(e.error),field:e.field,fieldError:e.error}:{success:!1,data:void 0,message:e.message||"Failed to update plot"}}return{success:!0,data:await o.json(),message:"Plot updated successfully"}}catch(r){return console.error("Error updating plot:",r),{success:!1,data:void 0,message:r instanceof Error?r.message:"An error occurred while updating the plot"}}}async deletePlot(e){try{const t="".concat("https://139.59.48.74","/api/sectors/plot/").concat(e),n=await this.authFetch(t,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!n.ok){return{success:!1,data:void 0,message:(await n.json()).message||"Failed to delete plot"}}return{success:!0,data:void 0,message:"Plot deleted successfully"}}catch(t){return console.error("Error deleting plot:",t),{success:!1,data:void 0,message:t instanceof Error?t.message:"An error occurred while deleting the plot"}}}async allocatePlot(e,t,n){try{const r="".concat("https://139.59.48.74","/api/sectors/").concat(e,"/plot/").concat(t),o=await this.authFetch(r,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!o.ok){return{success:!1,data:void 0,message:(await o.json()).message||"Failed to allocate plot"}}return{success:!0,data:await o.json(),message:"Plot allocated successfully"}}catch(r){return console.error("Error allocating plot:",r),{success:!1,data:void 0,message:r instanceof Error?r.message:"An error occurred while allocating plot"}}}async getPlotsBySector(e){try{const t="".concat("https://139.59.48.74","/api/sectors/plots?sectorId=").concat(e,"&page=0&size=100"),n=await this.authFetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){return{success:!1,data:[],message:(await n.json()).message||"Failed to fetch plots"}}const r=await n.json();let o,a=[];return Array.isArray(r)?a=r:r.content&&Array.isArray(r.content)?(a=r.content,o={total:r.totalElements||0,page:r.number||0,limit:r.size||100,totalPages:r.totalPages||0}):r.data&&Array.isArray(r.data)?(a=r.data,o=r.pagination):a=Array.isArray(r)?r:[],{success:!0,data:a,message:"Plots fetched successfully",pagination:o}}catch(t){return console.error("Error fetching plots:",t),{success:!1,data:[],message:t instanceof Error?t.message:"An error occurred while fetching plots"}}}async getPlotDetails(e,t){const n="".concat("https://139.59.48.74","/api/sectors/").concat(e,"/plot/").concat(t),r=await this.authFetch(n,{headers:{"Content-Type":"application/json"}});if(!r.ok)throw new Error("Failed to fetch plot details");return r.json()}async uploadFile(e,t,n,r){const o="IMAGE"===r?"upload-image":"upload",a="".concat("https://139.59.48.74","/api/files/").concat(o,"/").concat(n,"/").concat(e),i=new FormData;i.append("IMAGE"===r?"image":"file",t);const s=await this.authFetch(a,{method:"POST",headers:{},body:i});if(!s.ok)throw new Error("Failed to upload file");const l=s.headers.get("content-type");if(l&&l.includes("text/plain"))return await s.text();{const e=await s.json();return e.path||e.filePath||e.url||""}}async uploadDemandFile(e,t){return this.uploadFile(e,t,"demand")}async uploadRegistrationFile(e,t){return this.uploadFile(e,t,"registration")}async uploadVideoToYouTube(e,t,n,r){const o="".concat("https://139.59.48.74","/api/youtube/upload"),a=new FormData;a.append("title","".concat(e,"-").concat(t,"-video")),a.append("description",n),a.append("privacyStatus","unlisted"),a.append("file",r);const i=await this.authFetch(o,{method:"POST",headers:{},body:a});if(!i.ok)throw new Error("Failed to upload video to YouTube");return i.text()}async createDemand(e){const t="".concat("https://139.59.48.74","/api/demands"),n=await this.authFetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error("Demand creation failed");return n.json()}async deleteDemand(e){const t="".concat("https://139.59.48.74","/api/demands/").concat(e),n=await this.authFetch(t,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!n.ok)throw new Error("Demand deletion failed");return n}async addPayment(e,t){const n="".concat("https://139.59.48.74","/api/payments/demand/").concat(t),r=await this.authFetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error("Payment creation failed");return r.json()}async deletePayment(e){const t="".concat("https://139.59.48.74","/api/payments/").concat(e),n=await this.authFetch(t,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!n.ok)throw new Error("Payment deletion failed");if(204===n.status||200===n.status)return{success:!0,message:"Payment deleted successfully"};const r=n.headers.get("content-type");return r&&r.includes("application/json")?n.json():{success:!0,message:"Payment deleted successfully"}}async deleteInvoicePayment(e){try{const t="".concat("https://139.59.48.74","/api/payments/").concat(e),n=await this.authFetch(t,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!n.ok){return{success:!1,data:void 0,message:(await n.json()).message||"Failed to delete payment"}}return{success:!0,data:void 0,message:"Payment deleted successfully"}}catch(t){return console.error("Error deleting invoice payment:",t),{success:!1,data:void 0,message:t instanceof Error?t.message:"An unexpected error occurred"}}}async createManagerEmployee(e){try{const n="".concat("https://139.59.48.74","/api/users/manager");console.log("createManagerEmployee - URL:",n),console.log("createManagerEmployee - Payload:",e);const r=await this.authFetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(console.log("createManagerEmployee - Response status:",r.status),console.log("createManagerEmployee - Response headers:",r.headers),!r.ok){let e="Failed to create manager employee";try{const t=await r.json();if(409===r.status&&t.field&&t.error)return{success:!1,data:void 0,message:"".concat(t.field,": ").concat(t.error),field:t.field,fieldError:t.error};e=t.message||t.error||e}catch(t){console.error("Failed to parse error response:",t)}return{success:!1,data:void 0,message:e}}const o=r.headers.get("content-type");let a;return a=o&&o.includes("text/plain")?await r.text():await r.json(),console.log("createManagerEmployee - Success response:",a),{success:!0,data:a,message:"Manager employee created successfully"}}catch(n){return console.error("createManagerEmployee - Unexpected error:",n),{success:!1,data:void 0,message:n instanceof Error?n.message:"An unexpected error occurred"}}}async getManagers(){let{page:e=1,limit:t=10,search:n=""}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const r="".concat("https://139.59.48.74","/api/users/managers?page=").concat(e,"&limit=").concat(t,"&search=").concat(encodeURIComponent(n)),a=await this.authFetch(r,{method:"GET",headers:{"Content-Type":"application/json"}});if(!a.ok){return{success:!1,data:[],message:(await a.json()).message||"Failed to fetch managers"}}const i=await a.json();let s=[];return Array.isArray(i)?s=i:i&&"object"===typeof i&&(s=i.data&&Array.isArray(i.data)?i.data:i.content&&Array.isArray(i.content)?i.content:[]),s=s.map(e=>(0,o.A)((0,o.A)({},e),{},{id:String(e.id),employeeRole:"manager"})),{success:!0,data:s,message:"Managers fetched successfully"}}catch(r){return console.error("Error fetching managers:",r),{success:!1,data:[],message:r instanceof Error?r.message:"An error occurred while fetching managers"}}}async searchManagers(e){try{const t="".concat("https://139.59.48.74","/api/users/managers/search?keyword=").concat(encodeURIComponent(e)),n=await this.authFetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){return{success:!1,data:[],message:(await n.json()).message||"Failed to search managers"}}const r=await n.json();return{success:!0,data:(r||[]).map(e=>({id:String(e.id),firstName:e.firstName||"",lastName:e.lastName||"",fullName:e.fullName||"".concat(e.firstName||""," ").concat(e.lastName||"").trim(),email:e.email||"",phoneNumber:e.mobileNumber||e.phoneNumber||"",altPhoneNumber:e.altPhoneNumber||"",address:e.address||"",employeeId:e.employeeId||"",panCard:e.panCard||"",adharNumber:e.adharNumber||"",gstin:e.gstin||"",dateOfBirth:e.dateOfBirth||"",gender:e.gender||"",pincode:e.pincode||"",accountName:e.accountName||"",accountType:e.accountType||"",stateCode:e.stateCode||"",ifscCode:e.ifscCode||"",accountNumber:e.accountNumber||"",city:e.city||"",status:e.status||"Active",isActive:e.isActive||!0,createdAt:e.createdAt||"",updatedAt:e.updatedAt||"",employeeRole:"manager"})),message:"Managers search completed successfully"}}catch(t){return console.error("Error searching managers:",t),{success:!1,data:[],message:t instanceof Error?t.message:"An error occurred while searching managers"}}}async getAdmins(){let{page:e=1,limit:t=10,search:n=""}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const r="".concat("https://139.59.48.74","/api/users/admins?page=").concat(e,"&limit=").concat(t,"&search=").concat(encodeURIComponent(n)),a=await this.authFetch(r,{method:"GET",headers:{"Content-Type":"application/json"}});if(!a.ok){return{success:!1,data:[],message:(await a.json()).message||"Failed to fetch admins"}}const i=await a.json();let s=[];return Array.isArray(i)?s=i:i&&"object"===typeof i&&(s=i.data&&Array.isArray(i.data)?i.data:i.content&&Array.isArray(i.content)?i.content:[]),s=s.map(e=>(0,o.A)((0,o.A)({},e),{},{id:String(e.id),employeeRole:"admin"})),{success:!0,data:s,message:"Admins fetched successfully"}}catch(r){return console.error("Error fetching admins:",r),{success:!1,data:[],message:r instanceof Error?r.message:"An error occurred while fetching admins"}}}async createAdminEmployee(e){try{const n="".concat("https://139.59.48.74","/api/users/admin");console.log("createAdminEmployee - URL:",n),console.log("createAdminEmployee - Payload:",e);const r=await this.authFetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(console.log("createAdminEmployee - Response status:",r.status),console.log("createAdminEmployee - Response headers:",r.headers),!r.ok){let e="Failed to create admin employee";try{const t=await r.json();if(409===r.status&&t.field&&t.error)return{success:!1,data:void 0,message:"".concat(t.field,": ").concat(t.error),field:t.field,fieldError:t.error};e=t.message||t.error||e}catch(t){console.error("Failed to parse error response:",t)}return{success:!1,data:void 0,message:e}}const o=r.headers.get("content-type");let a;return a=o&&o.includes("text/plain")?await r.text():await r.json(),console.log("createAdminEmployee - Success response:",a),{success:!0,data:a,message:"Admin employee created successfully"}}catch(n){return console.error("createAdminEmployee - Unexpected error:",n),{success:!1,data:void 0,message:n instanceof Error?n.message:"An unexpected error occurred"}}}async updateAdminEmployee(e,t){try{const r="".concat("https://139.59.48.74","/api/users/admin/").concat(e);console.log("updateAdminEmployee - URL:",r),console.log("updateAdminEmployee - Employee data (changed fields only):",t),console.log("updateAdminEmployee - Changed fields count:",Object.keys(t).length);const o={id:e};this.hasMeaningfulValue(t.firstName)&&(o.firstName=t.firstName,console.log("Adding firstName:",t.firstName)),this.hasMeaningfulValue(t.lastName)&&(o.lastName=t.lastName,console.log("Adding lastName:",t.lastName)),this.hasMeaningfulValue(t.title)&&(o.title=t.title,console.log("Adding title:",t.title)),this.hasMeaningfulValue(t.mobileNumber)&&(o.phoneNumber=t.mobileNumber,o.username=t.mobileNumber,console.log("Adding phoneNumber:",t.mobileNumber)),this.hasMeaningfulValue(t.address)&&(o.address=t.address,console.log("Adding address:",t.address)),this.hasMeaningfulValue(t.employeeId)&&(o.employeeId=t.employeeId,console.log("Adding employeeId:",t.employeeId)),void 0!==t.status&&null!==t.status&&(o.active="active"===t.status,console.log("Adding active status:","active"===t.status)),this.hasMeaningfulValue(t.email)&&(o.email=t.email,console.log("Adding email:",t.email)),this.hasMeaningfulValue(t.panCard)&&(o.panCard=t.panCard,console.log("Adding panCard:",t.panCard)),this.hasMeaningfulValue(t.adharNumber)&&(o.adharNumber=t.adharNumber,console.log("Adding adharNumber:",t.adharNumber)),this.hasMeaningfulValue(t.dateOfBirth)&&(o.dateOfBirth=t.dateOfBirth,console.log("Adding dateOfBirth:",t.dateOfBirth)),this.hasMeaningfulValue(t.dateOfJoining)&&(o.dateOfJoining=t.dateOfJoining,console.log("Adding dateOfJoining:",t.dateOfJoining)),this.hasMeaningfulValue(t.pincode)&&(o.pincode=t.pincode,console.log("Adding pincode:",t.pincode)),this.hasMeaningfulValue(t.firstName)&&this.hasMeaningfulValue(t.lastName)&&(o.fullName="".concat(t.firstName," ").concat(t.lastName).trim(),console.log("Adding fullName:",o.fullName)),void 0!==t.accountType&&null!==t.accountType&&(o.accountType=t.accountType,console.log("Adding accountType:",t.accountType)),void 0!==t.gender&&null!==t.gender&&(o.gender=t.gender,console.log("Adding gender:",t.gender)),this.hasMeaningfulValue(t.bloodGroup)&&(o.bloodGroup=t.bloodGroup,console.log("Adding bloodGroup:",t.bloodGroup)),this.hasMeaningfulValue(t.fathersName)&&(o.fathersName=t.fathersName,console.log("Adding fathersName:",t.fathersName)),void 0!==t.maritalStatus&&null!==t.maritalStatus&&(o.maritalStatus=t.maritalStatus,console.log("Adding maritalStatus:",t.maritalStatus)),this.hasMeaningfulValue(t.city)&&(o.city=t.city,console.log("Adding city:",t.city)),this.hasMeaningfulValue(t.state)&&(o.stateCode=t.state,console.log("Adding stateCode:",t.state)),void 0!==t.employmentType&&null!==t.employmentType&&(o.employmentType=t.employmentType,console.log("Adding employmentType:",t.employmentType)),this.hasMeaningfulValue(t.bankName)&&(o.bankName=t.bankName,console.log("Adding bankName:",t.bankName)),this.hasMeaningfulValue(t.accountName)&&(o.accountName=t.accountName,console.log("Adding accountName:",t.accountName)),this.hasMeaningfulValue(t.accountNumber)&&(o.accountNumber=t.accountNumber,console.log("Adding accountNumber:",t.accountNumber)),this.hasMeaningfulValue(t.ifscCode)&&(o.ifscCode=t.ifscCode,console.log("Adding ifscCode:",t.ifscCode)),this.hasMeaningfulValue(t.epfNumber)&&(o.epfNumber=t.epfNumber,console.log("Adding epfNumber:",t.epfNumber)),this.hasMeaningfulValue(t.uanNumber)&&(o.uanNumber=t.uanNumber,console.log("Adding uanNumber:",t.uanNumber)),this.hasMeaningfulValue(t.emergencyContact)&&(o.emergencyContact=t.emergencyContact,console.log("Adding emergencyContact:",t.emergencyContact)),this.hasMeaningfulValue(t.reportingManager)&&(o.reportingManager=t.reportingManager,console.log("Adding reportingManager:",t.reportingManager)),console.log("updateAdminEmployee - Payload:",o);const a=await this.authFetch(r,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(console.log("updateAdminEmployee - Response status:",a.status),console.log("updateAdminEmployee - Response headers:",a.headers),!a.ok){let e="Failed to update admin employee";try{const t=await a.json();if(409===a.status&&t.field&&t.error)return{success:!1,data:void 0,message:"".concat(t.field,": ").concat(t.error),field:t.field,fieldError:t.error};e=t.message||t.error||e}catch(n){console.error("Failed to parse error response:",n)}return{success:!1,data:void 0,message:e}}const i=a.headers.get("content-type");let s;return s=i&&i.includes("text/plain")?await a.text():await a.json(),console.log("updateAdminEmployee - Success response:",s),{success:!0,data:s,message:"Admin employee updated successfully"}}catch(r){return console.error("updateAdminEmployee - Unexpected error:",r),{success:!1,data:void 0,message:r instanceof Error?r.message:"An unexpected error occurred"}}}hasMeaningfulValue(e){return void 0!==e&&null!==e&&""!==e}createDefinedPayload(e){const t={};for(const[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t}async login(e,t){const n="".concat("https://139.59.48.74","/auth/login"),r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})});if(!r.ok)throw new Error("Login failed");const o=await r.json();return this.setTokens(o.accessToken,o.refreshToken),o}async forgotPassword(e){try{const t="".concat("https://139.59.48.74","/auth/forgot-password"),n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mobile:e})});if(!n.ok){const e=await n.json();return{success:!1,data:{message:e.message||"Failed to send OTP"},message:e.message||"Failed to send OTP"}}return{success:!0,data:{message:(await n.json()).message||"OTP sent successfully"},message:"OTP sent successfully"}}catch(t){return console.error("Error sending OTP:",t),{success:!1,data:{message:"An error occurred while sending OTP"},message:"An error occurred while sending OTP"}}}async verifyOtp(e,t){try{const n="".concat("https://139.59.48.74","/auth/reset-password"),r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,otp:t,newPassword:"temp_password"})});if(!r.ok){const e=await r.json();return{success:!1,data:{message:e.message||"Invalid OTP"},message:e.message||"Invalid OTP"}}return{success:!0,data:{message:(await r.json()).message||"OTP verified successfully"},message:"OTP verified successfully"}}catch(n){return console.error("Error verifying OTP:",n),{success:!1,data:{message:"An error occurred while verifying OTP"},message:"An error occurred while verifying OTP"}}}async resetPassword(e,t,n){try{const a="".concat("https://139.59.48.74","/auth/reset-password"),i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,otp:t,newPassword:n})});if(!i.ok){let e="Failed to reset password";const t=i.headers.get("content-type");if(t&&t.includes("application/json"))try{e=(await i.json()).message||e}catch(r){console.error("Error parsing JSON response:",r)}else try{const t=await i.text();e="An error occurred: Invalid OTP"===t?"You have entered invalid OTP.":t||e}catch(o){console.error("Error parsing text response:",o)}return{success:!1,data:{message:e},message:e}}return{success:!0,data:{message:(await i.json()).message||"Password reset successfully"},message:"Password reset successfully"}}catch(a){return console.error("Error resetting password:",a),{success:!1,data:{message:"An error occurred while resetting password"},message:"An error occurred while resetting password"}}}async getUserProfile(){const e="".concat("https://139.59.48.74","/api/users/validate"),t=await this.authFetch(e,{method:"POST"});if(!t.ok)throw new Error("Failed to fetch user profile");return t.json()}async createTask(e){try{const t="".concat("https://139.59.48.74","/api/tasks/create"),n=await this.authFetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){return{success:!1,data:void 0,message:(await n.json()).message||"Failed to create task"}}return{success:!0,data:await n.json(),message:"Task created successfully"}}catch(t){return console.error("Error creating task:",t),{success:!1,data:void 0,message:t instanceof Error?t.message:"An error occurred while creating the task"}}}async updateTask(e,t){try{const n="".concat("https://139.59.48.74","/api/tasks/").concat(e,"/update"),r="string"===typeof t?{status:t}:t;console.log("API Service - updateTask - URL:",n),console.log("API Service - updateTask - Original payload:",t),console.log("API Service - updateTask - Request body being sent:",r),console.log("API Service - updateTask - Request body JSON:",JSON.stringify(r,null,2));const o=await this.authFetch(n,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok){return{success:!1,data:void 0,message:(await o.json()).message||"Failed to update task"}}return{success:!0,data:await o.json(),message:"Task updated successfully"}}catch(n){return console.error("Error updating task:",n),{success:!1,data:void 0,message:n instanceof Error?n.message:"An error occurred while updating the task"}}}async updateTaskWithImages(e,t,n){try{const r="".concat("https://139.59.48.74","/api/tasks/").concat(e,"/update"),o=await this.getTaskById(e);let a=[];if(o.success&&o.data){const e=o.data;switch(t){case i.e1.ACCEPTED:a=e.acceptedImages||[];break;case i.e1.PLANTED:a=e.plantedImages||[];break;case i.e1.PROGRESS1:a=e.progress1Images||[];break;case i.e1.PROGRESS2:a=e.progress2Images||[];break;case i.e1.UNDER_REVIEW:a=e.reviewImages||[];break;case i.e1.COMPLETED:a=e.completionImages||[];break;default:a=e.images||[]}}const s=[...a,...n],l={status:t};t===i.e1.ACCEPTED?l.acceptedImages=s:t===i.e1.PLANTED?l.plantedImages=s:t===i.e1.PROGRESS1?l.progress1Images=s:t===i.e1.PROGRESS2?l.progress2Images=s:t===i.e1.UNDER_REVIEW?l.reviewImages=s:t===i.e1.COMPLETED?l.completionImages=s:l.images=s,console.log("updateTaskWithImages - Request body:",JSON.stringify(l,null,2));const c=await this.authFetch(r,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!c.ok){return{success:!1,data:void 0,message:(await c.json()).message||"Failed to update task with images"}}return{success:!0,data:await c.json(),message:"Task updated with images successfully"}}catch(r){return console.error("Error updating task with images:",r),{success:!1,data:void 0,message:r instanceof Error?r.message:"An error occurred while updating the task with images"}}}async getAllTasks(e){try{let t="".concat("https://139.59.48.74","/api/tasks/");const n=e=>{const t=new Date(e),n=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0");return"".concat(n,"-").concat(r,"-").concat(o,"T00:00:00")};if(null!==e&&void 0!==e&&e.vendorId&&"all"!==e.vendorId&&(t+="?vendorId=".concat(e.vendorId)),null!==e&&void 0!==e&&e.startDate){const r=n(e.startDate);t+=e.vendorId&&"all"!==e.vendorId?"&from=".concat(r):"?from=".concat(r)}if(null!==e&&void 0!==e&&e.endDate){const r=n(e.endDate);t+="&to=".concat(r)}if(null!==e&&void 0!==e&&e.workType&&"all"!==e.workType){const n=t.includes("?")?"&":"?";t+="".concat(n,"taskType=").concat(e.workType)}const r=await this.authFetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok){return{success:!1,data:{created:[],accepted:[],planted:[],inProgress:[],review:[],completed:[],paymentRelease:[],cancelled:[]},message:(await r.json()).message||"Failed to fetch tasks"}}const o=await r.json();console.log("API Response Status:",r.status),console.log("API Response Headers:",Object.fromEntries(r.headers.entries())),console.log("Raw API response data:",o),console.log("Data type:",typeof o),console.log("Is array:",Array.isArray(o));const a={created:[],accepted:[],planted:[],inProgress:[],review:[],completed:[],paymentRelease:[],cancelled:[]};return console.log("Processing data array, length:",Array.isArray(o)?o.length:"not an array"),Array.isArray(o)?o.forEach(e=>{var t,n,r;let o="";if(e.createdBy&&Array.isArray(e.createdBy)&&e.createdBy.length>0){const t=e.createdBy[0];o="".concat(t.firstName," ").concat(t.lastName).trim()}const s={id:(null===(t=e.id)||void 0===t?void 0:t.toString())||"",workType:e.taskType||"",taskType:e.taskType||"",priority:"Normal",taskId:(null===(n=e.id)||void 0===n?void 0:n.toString())||"",createdBy:o,tentativeDate:e.completionDate?new Date(e.completionDate).toLocaleDateString():"",description:e.description||"",status:e.status||i.e1.CREATED,vendorId:(null===(r=e.vendorId)||void 0===r?void 0:r.toString())||void 0};switch(console.log("Task transformation:",{original:{id:e.id,taskType:e.taskType,createdBy:e.createdBy,description:e.description,status:e.status},transformed:s}),s.status){case i.e1.CREATED:a.created.push(s);break;case i.e1.ACCEPTED:a.accepted.push(s);break;case i.e1.PLANTED:a.planted.push(s);break;case i.e1.PROGRESS1:case i.e1.PROGRESS2:a.inProgress.push(s);break;case i.e1.UNDER_REVIEW:a.review.push(s);break;case i.e1.COMPLETED:a.completed.push(s);break;case i.e1.CLOSED:a.paymentRelease.push(s);break;case i.e1.CANCELLED:a.cancelled.push(s);break;default:a.created.push(s)}}):(console.warn("API response is not an array:",o),console.warn("Expected array of task objects, got:",typeof o)),{success:!0,data:a,message:"Tasks fetched successfully"}}catch(t){return console.error("Error fetching tasks:",t),{success:!1,data:{created:[],accepted:[],planted:[],inProgress:[],review:[],completed:[],paymentRelease:[],cancelled:[]},message:t instanceof Error?t.message:"An error occurred while fetching tasks"}}}async getTaskById(e){try{console.log("Fetching task details for ID:",e);const t="https://139.59.48.74",n=await this.authFetch("".concat(t,"/api/tasks/").concat(e),{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok)throw new Error("HTTP error! status: ".concat(n.status));const r=await n.json();return console.log("API response data:",r),{success:!0,data:r,message:"Task details fetched successfully"}}catch(t){return console.error("Error fetching task details:",t),{success:!1,data:void 0,message:"Failed to fetch task details: ".concat(t instanceof Error?t.message:"Unknown error")}}}async updateTaskStatus(e){try{console.log("ApiService - Updating task status with payload:",JSON.stringify(e,null,2));const t={status:e.stage.toUpperCase()};switch(e.stage.toUpperCase()){case"ACCEPTED":e.comment&&(t.acceptedDescription=e.comment),e.acceptedImages&&(t.acceptedImages=e.acceptedImages);break;case"PLANTED":e.comment&&(t.progress1Description=e.comment),e.plantedImages&&(t.plantedImages=e.plantedImages);break;case"IN_PROGRESS":e.comment&&(t.progress1Description=e.comment),e.progress1Images&&(t.progress1Images=e.progress1Images);break;case"REVIEW":e.comment&&(t.reviewComment=e.comment),e.progress2Images&&(t.progress2Images=e.progress2Images);break;case"COMPLETED":e.comment&&(t.completedDescription=e.comment),e.document&&(t.document=e.document),e.completionDate&&(t.completionDate=e.completionDate),e.invoiceNumber&&(t.invoiceNumber=e.invoiceNumber),e.invoiceAmount&&(t.invoiceAmount=e.invoiceAmount);break;default:e.comment&&(t.comment=e.comment),e.images&&(t.images=e.images)}e.document&&(t.document=e.document),e.assignedTo&&(t.assignedTo=e.assignedTo),e.priority&&(t.priority=e.priority),console.log("ApiService - Converted payload for backend:",JSON.stringify(t,null,2));const n="https://139.59.48.74",r=await this.authFetch("".concat(n,"/api/tasks/").concat(e.taskId,"/update"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){return{success:!1,data:void 0,message:(await r.json()).message||"Failed to update task status"}}const o=await r.json();return console.log("Update task status response:",o),{success:!0,data:o,message:"Task status updated successfully"}}catch(t){return console.error("Error updating task status:",t),{success:!1,data:void 0,message:"Failed to update task status: ".concat(t instanceof Error?t.message:"Unknown error")}}}async downloadFile(e,t){try{const n="".concat("https://139.59.48.74","/api/files/file?path=").concat(encodeURIComponent(e)),r=await this.authFetch(n,{method:"GET"});if(!r.ok)throw new Error("Failed to download file");const o=await r.blob(),a=window.URL.createObjectURL(o),i=document.createElement("a");i.href=a,i.download=t,i.target="_blank",document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(a)}catch(n){throw console.error("Error downloading file:",n),n}}async downloadTaskPDF(e){try{const t="https://139.59.48.74",n=await this.authFetch("".concat(t,"/api/tasks/pdf?taskId=").concat(e),{method:"POST"});if(!n.ok)throw new Error("HTTP error! status: ".concat(n.status));const r=await n.blob(),o=window.URL.createObjectURL(r),a=document.createElement("a");a.href=o,a.download="task-".concat(e,".pdf"),document.body.appendChild(a),a.click(),document.body.removeChild(a),window.URL.revokeObjectURL(o),console.log("PDF downloaded successfully")}catch(t){throw console.error("Error downloading PDF:",t),t}}async uploadPaymentExcel(e){try{const t=new FormData;t.append("file",e);const n="https://139.59.48.74",r=await this.authFetch("".concat(n,"/api/tasks/updatePaymentFromExcel"),{method:"POST",body:t});if(!r.ok)throw new Error("HTTP error! status: ".concat(r.status));const o=await r.json();return Array.isArray(o)?o:[]}catch(t){throw console.error("Error uploading payment Excel:",t),t}}async downloadTasksExcel(e,t){try{let n="".concat("https://139.59.48.74","/api/tasks/downloadTasksToExcel");e&&"all"!==e&&(n+="?vendorId=".concat(e)),t&&"all"!==t&&(n+=e&&"all"!==e?"&taskType=".concat(t):"?taskType=".concat(t));const r=await this.authFetch(n,{method:"GET"});if(!r.ok)throw new Error("HTTP error! status: ".concat(r.status));const o=await r.blob(),a=window.URL.createObjectURL(o),i=document.createElement("a");i.href=a,i.download="completed-tasks-".concat(e&&"all"!==e?"vendor-".concat(e):"all-vendors").concat(t&&"all"!==t?"-".concat(t):"",".xlsx"),document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(a),console.log("Excel file downloaded successfully")}catch(n){throw console.error("Error downloading Excel file:",n),n}}async getCommentsByTaskId(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:50;try{const r="https://139.59.48.74",o=await this.authFetch("".concat(r,"/api/comments/task/").concat(e,"?page=").concat(t,"&size=").concat(n),{method:"GET"});if(!o.ok)throw new Error("HTTP error! status: ".concat(o.status));const a=await o.json();return{success:!0,data:a.content||a,message:"Comments fetched successfully"}}catch(r){return console.error("Error fetching comments:",r),{success:!1,data:[],message:"Failed to fetch comments: ".concat(r instanceof Error?r.message:"Unknown error")}}}async createComment(e){try{const t="https://139.59.48.74",n=await this.authFetch("".concat(t,"/api/comments/task"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error("HTTP error! status: ".concat(n.status));return{success:!0,data:await n.json(),message:"Comment created successfully"}}catch(t){return console.error("Error creating comment:",t),{success:!1,data:void 0,message:"Failed to create comment: ".concat(t instanceof Error?t.message:"Unknown error")}}}async deleteComment(e){try{const t="https://139.59.48.74",n=await this.authFetch("".concat(t,"/api/comments/").concat(e),{method:"DELETE"});if(!n.ok)throw new Error("HTTP error! status: ".concat(n.status));return{success:!0,data:void 0,message:"Comment deleted successfully"}}catch(t){return console.error("Error deleting comment:",t),{success:!1,data:void 0,message:"Failed to delete comment: ".concat(t instanceof Error?t.message:"Unknown error")}}}async getInvoices(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=arguments.length>2?arguments[2]:void 0;try{let r="".concat("https://139.59.48.74","/api/invoices?page=").concat(e,"&size=").concat(t);n&&(n.status&&(r+="&status=".concat(encodeURIComponent(n.status))),n.vendorId&&(r+="&vendorId=".concat(encodeURIComponent(n.vendorId))),n.vendorName&&(r+="&vendorName=".concat(encodeURIComponent(n.vendorName))),n.invoiceType&&(r+="&invoiceType=".concat(encodeURIComponent(n.invoiceType))),n.dateFrom&&(r+="&dateFrom=".concat(encodeURIComponent(n.dateFrom))),n.dateTo&&(r+="&dateTo=".concat(encodeURIComponent(n.dateTo))));const o=await this.authFetch(r,{method:"GET"});if(!o.ok)throw new Error("HTTP error! status: ".concat(o.status));return{success:!0,data:await o.json(),message:"Invoices fetched successfully"}}catch(r){return console.error("Error fetching invoices:",r),r instanceof Error&&r.message.includes("403")?{success:!1,data:void 0,message:"Access denied. You do not have permission to view invoices."}:{success:!1,data:void 0,message:r instanceof Error?r.message:"An error occurred while fetching invoices"}}}async getInvoiceById(e){try{const t="http://localhost:9080",n=await this.authFetch("".concat(t,"/api/invoices/").concat(e),{method:"GET"});if(!n.ok)throw new Error("HTTP error! status: ".concat(n.status));return{success:!0,data:await n.json(),message:"Invoice fetched successfully"}}catch(t){return console.error("Error fetching invoice:",t),{success:!1,data:void 0,message:"Failed to fetch invoice: ".concat(t instanceof Error?t.message:"Unknown error")}}}async createInvoice(e){try{const t="https://139.59.48.74",n=await this.authFetch("".concat(t,"/api/invoices"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const e=await n.json();if(409===n.status&&e.field&&e.error)return{success:!1,data:void 0,message:"".concat(e.field,": ").concat(e.error),field:e.field,fieldError:e.error};throw new Error("HTTP error! status: ".concat(n.status))}return{success:!0,data:await n.json(),message:"Invoice created successfully"}}catch(t){return console.error("Error creating invoice:",t),{success:!1,data:void 0,message:"Failed to create invoice: ".concat(t instanceof Error?t.message:"Unknown error")}}}async updateInvoice(e,t){try{const n="https://139.59.48.74",r=await this.authFetch("".concat(n,"/api/invoices/").concat(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const e=await r.json();if(409===r.status&&e.field&&e.error)return{success:!1,data:void 0,message:"".concat(e.field,": ").concat(e.error),field:e.field,fieldError:e.error};throw new Error("HTTP error! status: ".concat(r.status))}return{success:!0,data:await r.json(),message:"Invoice updated successfully"}}catch(n){return console.error("Error updating invoice:",n),{success:!1,data:void 0,message:"Failed to update invoice: ".concat(n instanceof Error?n.message:"Unknown error")}}}async deleteInvoice(e){try{const t="https://139.59.48.74",n=await this.authFetch("".concat(t,"/api/invoices/").concat(e),{method:"DELETE"});if(!n.ok)throw new Error("HTTP error! status: ".concat(n.status));return{success:!0,data:void 0,message:"Invoice deleted successfully"}}catch(t){return console.error("Error deleting invoice:",t),{success:!1,data:void 0,message:"Failed to delete invoice: ".concat(t instanceof Error?t.message:"Unknown error")}}}async createPayment(e){try{const t="https://139.59.48.74",n=await this.authFetch("".concat(t,"/api/payments/invoice/").concat(e.invoice.id),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const e=await n.json();if(409===n.status&&e.field&&e.error)return{success:!1,data:void 0,message:"".concat(e.field,": ").concat(e.error),field:e.field,fieldError:e.error};throw new Error("HTTP error! status: ".concat(n.status))}return{success:!0,data:await n.json(),message:"Payment created successfully"}}catch(t){return console.error("Error creating payment:",t),{success:!1,data:void 0,message:"Failed to create payment: ".concat(t instanceof Error?t.message:"Unknown error")}}}async getVendorById(e){try{const t="".concat("https://139.59.48.74","/api/users/vendors/").concat(e),n=await this.authFetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){return{success:!1,data:void 0,message:(await n.json()).message||"Failed to fetch vendor"}}const r=await n.json();return{success:!0,data:{id:String(r.id),vendorId:r.vendorId||"VD".concat(r.id),name:r.vendorName||"",profilePic:r.profilePic||"",email:r.email||"",phone:r.mobileNumber||"",contactPersonFName:r.contactPersonFName||"",contactPersonLName:r.contactPersonLName||"",panCard:r.panCard||"",gstin:r.gstNumber||"",adharNumber:r.adharNumber||"",vendorType:r.vendorType||"",businessCategory:r.businessCategory||"",msmeUdyamNumber:r.msmeUdyamNumber||"",cin:r.cin||"",tan:r.tan||"",fssaiNumber:r.fssaiNumber||"",esicNumber:r.esicNumber||"",uan:r.uan||"",bankName:r.bankName||"",accountName:r.accountName||"",accountType:r.accountType||"",accountNumber:r.accountNumber||"",ifscCode:r.ifscCode||"",addressLine1:r.address||"",addressLine2:r.addressLine2||"",city:r.city||"",state:r.state||"",stateCode:r.stateCode||"",pincode:r.pincode||"",country:r.country||"",website:r.website||"",status:r.isActive?"Active":"Inactive",isActive:r.isActive||!1,documents:r.documents||[],users:r.users||[],createdAt:r.createdAt||"",updatedAt:r.updatedAt||""},message:"Vendor fetched successfully"}}catch(t){return console.error("Error fetching vendor by ID:",t),{success:!1,data:void 0,message:t instanceof Error?t.message:"An error occurred while fetching vendor"}}}async updateAdmin(e,t){try{const n="".concat("https://139.59.48.74","/api/users/admin/").concat(e),r=await this.authFetch(n,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(401===r.status&&this.handleUnauthorizedResponse(n,r),!r.ok){return{success:!1,data:void 0,message:(await r.json()).message||"Failed to update admin profile"}}return{success:!0,data:await r.json(),message:"Admin profile updated successfully"}}catch(n){return console.error("Error updating admin profile:",n),{success:!1,data:void 0,message:n instanceof Error?n.message:"An error occurred while updating admin profile"}}}async updateManager(e,t){try{const n="".concat("https://139.59.48.74","/api/users/manager/").concat(e),r=await this.authFetch(n,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(401===r.status&&this.handleUnauthorizedResponse(n,r),!r.ok){return{success:!1,data:void 0,message:(await r.json()).message||"Failed to update manager profile"}}return{success:!0,data:await r.json(),message:"Manager profile updated successfully"}}catch(n){return console.error("Error updating manager profile:",n),{success:!1,data:void 0,message:n instanceof Error?n.message:"An error occurred while updating manager profile"}}}async updateSuperAdmin(e,t){try{const n="".concat("https://139.59.48.74","/api/users/superadmin/").concat(e),r=await this.authFetch(n,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(401===r.status&&this.handleUnauthorizedResponse(n,r),!r.ok){return{success:!1,data:void 0,message:(await r.json()).message||"Failed to update super admin profile"}}return{success:!0,data:await r.json(),message:"Super admin profile updated successfully"}}catch(n){return console.error("Error updating super admin profile:",n),{success:!1,data:void 0,message:n instanceof Error?n.message:"An error occurred while updating super admin profile"}}}async getUserReportsStage(){try{const e="".concat("https://139.59.48.74","/api/user-reports/stage"),t=await this.authFetch(e,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)return{success:!1,data:null,message:"HTTP error! status: ".concat(t.status)};return{success:!0,data:await t.json(),message:"User reports stage data fetched successfully"}}catch(e){return console.error("Error fetching user reports stage data:",e),{success:!1,data:null,message:e instanceof Error?e.message:"An error occurred while fetching user reports stage data"}}}async getDemandsCollection(e,t){try{const n="".concat("https://139.59.48.74","/api/reports/demands/collection?year=").concat(e,"&month=").concat(t),r=await this.authFetch(n,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok)return{success:!1,data:null,message:"HTTP error! status: ".concat(r.status)};return{success:!0,data:await r.json(),message:"Demands collection data fetched successfully"}}catch(n){return console.error("Error fetching demands collection data:",n),{success:!1,data:null,message:n instanceof Error?n.message:"An error occurred while fetching demands collection data"}}}async getDemandsPending(){try{const e="".concat("https://139.59.48.74","/api/reports/demands/pending"),t=await this.authFetch(e,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)return{success:!1,data:null,message:"HTTP error! status: ".concat(t.status)};return{success:!0,data:await t.json(),message:"Demands pending data fetched successfully"}}catch(e){return console.error("Error fetching demands pending data:",e),{success:!1,data:null,message:e instanceof Error?e.message:"An error occurred while fetching demands pending data"}}}async getBreachedTasks(){try{const e="".concat("https://139.59.48.74","/api/reports/tasks/breached"),t=await this.authFetch(e,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)return{success:!1,data:null,message:"HTTP error! status: ".concat(t.status)};return{success:!0,data:await t.json(),message:"Breached tasks data fetched successfully"}}catch(e){return console.error("Error fetching breached tasks data:",e),{success:!1,data:null,message:e instanceof Error?e.message:"An error occurred while fetching breached tasks data"}}}async getUserNotifications(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{const n="https://139.59.48.74",r=t?"".concat(n,"/api/notif/vendor/").concat(e):"".concat(n,"/api/notif/user/").concat(e),o=await this.authFetch(r,{method:"GET",headers:{"Content-Type":"application/json"}});if(!o.ok)return{success:!1,data:null,message:"HTTP error! status: ".concat(o.status)};return{success:!0,data:await o.json(),message:"Notifications fetched successfully"}}catch(n){return console.error("Error fetching breached tasks data:",n),{success:!1,data:null,message:n instanceof Error?n.message:"An error occurred while fetching notifications data"}}}async getUserNotificationsCount(e){try{const t="".concat("https://139.59.48.74","/api/notif/user/").concat(e,"/count"),n=await this.authFetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok)return{success:!1,data:null,message:"HTTP error! status: ".concat(n.status)};return{success:!0,data:await n.json(),message:"Notifications count fetched successfully"}}catch(t){return console.error("Error fetching breached tasks data:",t),{success:!1,data:null,message:t instanceof Error?t.message:"An error occurred while fetching notifications count data"}}}async markNotificationRead(e){try{const t="".concat("https://139.59.48.74","/api/notif/").concat(e,"/read"),n=await this.authFetch(t,{method:"PUT",headers:{"Content-Type":"application/json"}});if(!n.ok)return{success:!1,data:null,message:"HTTP error! status: ".concat(n.status)};return{success:!0,data:await n.json(),message:"Notifications status updated successfully"}}catch(t){return console.error("Error fetching breached tasks data:",t),{success:!1,data:null,message:t instanceof Error?t.message:"An error occurred while updating notification status"}}}}},713:(e,t,n)=>{"use strict";var r;n.d(t,{A:()=>l});var o=n(9379),a=n(5043);let i=0;const s=(0,o.A)({},r||(r=n.t(a,2))).useId;function l(e){if(void 0!==s){const t=s();return null!==e&&void 0!==e?e:t}return function(e){const[t,n]=a.useState(e),r=e||t;return a.useEffect(()=>{null==t&&(i+=1,n("mui-".concat(i)))},[t]),r}(e)}},918:(e,t,n)=>{"use strict";function r(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}n.d(t,{A:()=>r})},1032:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(2485);const o=(0,n(8128).Ay)(r.A)(e=>{let{theme:t}=e;return{height:44,minHeight:44,backgroundColor:"#F5F5F5 !important",borderRadius:6,"& .MuiOutlinedInput-notchedOutline":{border:"1px solid #DBDBDB !important",borderRadius:6},"& input":{backgroundColor:"#F5F5F5 !important",fontSize:14,color:"#22322F",padding:"0 1px 0 0",border:"none !important",boxShadow:"none !important",height:"100%",lineHeight:1,display:"flex",alignItems:"center"},"& .MuiInputAdornment-root":{marginRight:16}}})},1033:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=function(e,t,n){return"function"===typeof e?e(t,n):e}},1039:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(5043),o=n(6509);const a=function(e){const t=r.useRef(e);return(0,o.A)(()=>{t.current=e}),r.useRef(function(){return(0,t.current)(...arguments)}).current}},1045:(e,t,n)=>{"use strict";n.d(t,{BV:()=>Me,C5:()=>Ee,Kd:()=>pt,Zp:()=>ue,ok:()=>vt,qh:()=>Ne,sv:()=>Te,zy:()=>se});var r=n(45),o=n(9379),a=n(5043);n(4358);const i=["sri"],s=["page"],l=["page","matches"],c=["onClick","discover","prefetch","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],u=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],d=["discover","fetcherKey","navigate","reloadDocument","replace","state","method","action","onSubmit","relative","preventScrollReset","viewTransition"];var p="popstate";function f(){return b(function(e,t){let{pathname:n,search:r,hash:o}=e.location;return y("",{pathname:n,search:r,hash:o},t.state&&t.state.usr||null,t.state&&t.state.key||"default")},function(e,t){return"string"===typeof t?t:v(t)},null,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}function m(e,t){if(!1===e||null===e||"undefined"===typeof e)throw new Error(t)}function h(e,t){if(!e){"undefined"!==typeof console&&console.warn(t);try{throw new Error(t)}catch(n){}}}function g(e,t){return{usr:e.state,key:e.key,idx:t}}function y(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3?arguments[3]:void 0;return(0,o.A)((0,o.A)({pathname:"string"===typeof e?e:e.pathname,search:"",hash:""},"string"===typeof t?A(t):t),{},{state:n,key:t&&t.key||r||Math.random().toString(36).substring(2,10)})}function v(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&"?"!==n&&(t+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(t+="#"===r.charAt(0)?r:"#"+r),t}function A(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function b(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},{window:a=document.defaultView,v5Compat:i=!1}=r,s=a.history,l="POP",c=null,u=d();function d(){return(s.state||{idx:null}).idx}function f(){l="POP";let e=d(),t=null==e?null:e-u;u=e,c&&c({action:l,location:h.location,delta:t})}function m(e){return w(e)}null==u&&(u=0,s.replaceState((0,o.A)((0,o.A)({},s.state),{},{idx:u}),""));let h={get action(){return l},get location(){return e(a,s)},listen(e){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(p,f),c=e,()=>{a.removeEventListener(p,f),c=null}},createHref:e=>t(a,e),createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(e,t){l="PUSH";let r=y(h.location,e,t);n&&n(r,e),u=d()+1;let o=g(r,u),p=h.createHref(r);try{s.pushState(o,"",p)}catch(f){if(f instanceof DOMException&&"DataCloneError"===f.name)throw f;a.location.assign(p)}i&&c&&c({action:l,location:h.location,delta:1})},replace:function(e,t){l="REPLACE";let r=y(h.location,e,t);n&&n(r,e),u=d();let o=g(r,u),a=h.createHref(r);s.replaceState(o,"",a),i&&c&&c({action:l,location:h.location,delta:0})},go:e=>s.go(e)};return h}function w(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n="http://localhost";"undefined"!==typeof window&&(n="null"!==window.location.origin?window.location.origin:window.location.href),m(n,"No window.location.(origin|href) available to create URL");let r="string"===typeof e?e:v(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}new WeakMap;function S(e,t){return k(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:"/",!1)}function k(e,t,n,r){let o=B(("string"===typeof t?A(t):t).pathname||"/",n);if(null==o)return null;let a=x(e);!function(e){e.sort((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){let n=e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n]);return n?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)))}(a);let i=null;for(let s=0;null==i&&s1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=(e,o,a)=>{let i={relativePath:void 0===a?e.path||"":a,caseSensitive:!0===e.caseSensitive,childrenIndex:o,route:e};i.relativePath.startsWith("/")&&(m(i.relativePath.startsWith(r),'Absolute route path "'.concat(i.relativePath,'" nested under path "').concat(r,'" is not valid. An absolute child route path must start with the combined path of all its parent routes.')),i.relativePath=i.relativePath.slice(r.length));let s=W([r,i.relativePath]),l=n.concat(i);e.children&&e.children.length>0&&(m(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'.concat(s,'".')),x(e.children,t,l,s)),(null!=e.path||e.index)&&t.push({path:s,score:j(s,e.index),routesMeta:l})};return e.forEach((e,t)=>{var n;if(""!==e.path&&null!==(n=e.path)&&void 0!==n&&n.includes("?"))for(let r of C(e.path))o(e,t,r);else o(e,t)}),t}function C(e){let t=e.split("/");if(0===t.length)return[];let[n,...r]=t,o=n.endsWith("?"),a=n.replace(/\?$/,"");if(0===r.length)return o?[a,""]:[a];let i=C(r.join("/")),s=[];return s.push(...i.map(e=>""===e?a:[a,e].join("/"))),o&&s.push(...i),s.map(t=>e.startsWith("/")&&""===t?"/":t)}var E=/^:[\w-]+$/,T=3,N=2,P=1,M=10,R=-2,O=e=>"*"===e;function j(e,t){let n=e.split("/"),r=n.length;return n.some(O)&&(r+=R),t&&(r+=N),n.filter(e=>!O(e)).reduce((e,t)=>e+(E.test(t)?T:""===t?P:M),r)}function L(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],{routesMeta:r}=e,o={},a="/",i=[];for(let s=0;s{let{paramName:r,isOptional:o}=t;if("*"===r){let e=s[n]||"";i=a.slice(0,a.length-e.length).replace(/(.)\/+$/,"$1")}const l=s[n];return e[r]=o&&!l?void 0:(l||"").replace(/%2F/g,"/"),e},{}),pathname:a,pathnameBase:i,pattern:e}}function D(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];h("*"===e||!e.endsWith("*")||e.endsWith("/*"),'Route path "'.concat(e,'" will be treated as if it were "').concat(e.replace(/\*$/,"/*"),'" because the `*` character must always follow a `/` in the pattern. To get rid of this warning, please change the route path to "').concat(e.replace(/\*$/,"/*"),'".'));let r=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:null!=n}),n?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),o+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":""!==e&&"/"!==e&&(o+="(?:(?=\\/|$))"),[new RegExp(o,t?void 0:"i"),r]}function F(e){try{return e.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(t){return h(!1,'The URL path "'.concat(e,'" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (').concat(t,").")),e}}function B(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&"/"!==r?null:e.slice(n)||"/"}function z(e,t,n,r){return"Cannot include a '".concat(e,"' character in a manually specified `to.").concat(t,"` field [").concat(JSON.stringify(r),"]. Please separate it out to the `to.").concat(n,'` field. Alternatively you may provide the full path as a string in and the router will parse it for you.')}function U(e){return e.filter((e,t)=>0===t||e.route.path&&e.route.path.length>0)}function V(e){let t=U(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function H(e,t,n){let r,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];"string"===typeof e?r=A(e):(r=(0,o.A)({},e),m(!r.pathname||!r.pathname.includes("?"),z("?","pathname","search",r)),m(!r.pathname||!r.pathname.includes("#"),z("#","pathname","hash",r)),m(!r.search||!r.search.includes("#"),z("#","search","hash",r)));let i,s=""===e||""===r.pathname,l=s?"/":r.pathname;if(null==l)i=n;else{let e=t.length-1;if(!a&&l.startsWith("..")){let t=l.split("/");for(;".."===t[0];)t.shift(),e-=1;r.pathname=t.join("/")}i=e>=0?t[e]:"/"}let c=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/",{pathname:n,search:r="",hash:o=""}="string"===typeof e?A(e):e,a=n?n.startsWith("/")?n:function(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(e=>{".."===e?n.length>1&&n.pop():"."!==e&&n.push(e)}),n.length>1?n.join("/"):"/"}(n,t):t;return{pathname:a,search:Q(r),hash:G(o)}}(r,i),u=l&&"/"!==l&&l.endsWith("/"),d=(s||"."===l)&&n.endsWith("/");return c.pathname.endsWith("/")||!u&&!d||(c.pathname+="/"),c}var W=e=>e.join("/").replace(/\/\/+/g,"/"),Y=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Q=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",G=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";function _(e){return null!=e&&"number"===typeof e.status&&"string"===typeof e.statusText&&"boolean"===typeof e.internal&&"data"in e}var X=["POST","PUT","PATCH","DELETE"],K=(new Set(X),["GET",...X]);new Set(K),Symbol("ResetLoaderData");var J=a.createContext(null);J.displayName="DataRouter";var q=a.createContext(null);q.displayName="DataRouterState";var Z=a.createContext({isTransitioning:!1});Z.displayName="ViewTransition";var $=a.createContext(new Map);$.displayName="Fetchers";var ee=a.createContext(null);ee.displayName="Await";var te=a.createContext(null);te.displayName="Navigation";var ne=a.createContext(null);ne.displayName="Location";var re=a.createContext({outlet:null,matches:[],isDataRoute:!1});re.displayName="Route";var oe=a.createContext(null);oe.displayName="RouteError";var ae=!0;function ie(){return null!=a.useContext(ne)}function se(){return m(ie(),"useLocation() may be used only in the context of a component."),a.useContext(ne).location}var le="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function ce(e){a.useContext(te).static||a.useLayoutEffect(e)}function ue(){let{isDataRoute:e}=a.useContext(re);return e?function(){let{router:e}=be("useNavigate"),t=Se("useNavigate"),n=a.useRef(!1);ce(()=>{n.current=!0});let r=a.useCallback(async function(r){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};h(n.current,le),n.current&&("number"===typeof r?e.navigate(r):await e.navigate(r,(0,o.A)({fromRouteId:t},a)))},[e,t]);return r}():function(){m(ie(),"useNavigate() may be used only in the context of a component.");let e=a.useContext(J),{basename:t,navigator:n}=a.useContext(te),{matches:r}=a.useContext(re),{pathname:o}=se(),i=JSON.stringify(V(r)),s=a.useRef(!1);ce(()=>{s.current=!0});let l=a.useCallback(function(r){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(h(s.current,le),!s.current)return;if("number"===typeof r)return void n.go(r);let l=H(r,JSON.parse(i),o,"path"===a.relative);null==e&&"/"!==t&&(l.pathname="/"===l.pathname?t:W([t,l.pathname])),(a.replace?n.replace:n.push)(l,a.state,a)},[t,n,i,o,e]);return l}()}var de=a.createContext(null);function pe(e){let{relative:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{matches:n}=a.useContext(re),{pathname:r}=se(),o=JSON.stringify(V(n));return a.useMemo(()=>H(e,JSON.parse(o),r,"path"===t),[e,o,r,t])}function fe(e,t,n,r){m(ie(),"useRoutes() may be used only in the context of a component.");let{navigator:i}=a.useContext(te),{matches:s}=a.useContext(re),l=s[s.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",p=l&&l.route;if(ae){let e=p&&p.path||"";Ce(u,!p||e.endsWith("*")||e.endsWith("*?"),'You rendered descendant (or called `useRoutes()`) at "'.concat(u,'" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won\'t match anymore and therefore the child routes will never render.\n\nPlease change the parent to .'))}let f,g=se();if(t){var y;let e="string"===typeof t?A(t):t;m("/"===d||(null===(y=e.pathname)||void 0===y?void 0:y.startsWith(d)),'When overriding the location using `` or `useRoutes(routes, location)`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "'.concat(d,'" but pathname "').concat(e.pathname,'" was given in the `location` prop.')),f=e}else f=g;let v=f.pathname||"/",b=v;if("/"!==d){let e=d.replace(/^\//,"").split("/");b="/"+v.replace(/^\//,"").split("/").slice(e.length).join("/")}let w=S(e,{pathname:b});ae&&(h(p||null!=w,'No routes matched location "'.concat(f.pathname).concat(f.search).concat(f.hash,'" ')),h(null==w||void 0!==w[w.length-1].route.element||void 0!==w[w.length-1].route.Component||void 0!==w[w.length-1].route.lazy,'Matched leaf route at location "'.concat(f.pathname).concat(f.search).concat(f.hash,'" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.')));let k=ve(w&&w.map(e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:W([d,i.encodeLocation?i.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?d:W([d,i.encodeLocation?i.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])})),s,n,r);return t&&k?a.createElement(ne.Provider,{value:{location:(0,o.A)({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:"POP"}},k):k}function me(){let e=ke(),t=_(e)?"".concat(e.status," ").concat(e.statusText):e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r},s=null;return ae&&(console.error("Error handled by React Router default ErrorBoundary:",e),s=a.createElement(a.Fragment,null,a.createElement("p",null,"\ud83d\udcbf Hey developer \ud83d\udc4b"),a.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",a.createElement("code",{style:i},"ErrorBoundary")," or"," ",a.createElement("code",{style:i},"errorElement")," prop on your route."))),a.createElement(a.Fragment,null,a.createElement("h2",null,"Unexpected Application Error!"),a.createElement("h3",{style:{fontStyle:"italic"}},t),n?a.createElement("pre",{style:o},n):null,s)}var he=a.createElement(me,null),ge=class extends a.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:void 0!==e.error?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return void 0!==this.state.error?a.createElement(re.Provider,{value:this.props.routeContext},a.createElement(oe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function ye(e){let{routeContext:t,match:n,children:r}=e,o=a.useContext(J);return o&&o.static&&o.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=n.route.id),a.createElement(re.Provider,{value:t},r)}function ve(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(null==e){if(!n)return null;if(n.errors)e=n.matches;else{if(0!==t.length||n.initialized||!(n.matches.length>0))return null;e=n.matches}}let r=e,o=null===n||void 0===n?void 0:n.errors;if(null!=o){let e=r.findIndex(e=>e.route.id&&void 0!==(null===o||void 0===o?void 0:o[e.route.id]));m(e>=0,"Could not find a matching route for errors on route IDs: ".concat(Object.keys(o).join(","))),r=r.slice(0,Math.min(r.length,e+1))}let i=!1,s=-1;if(n)for(let a=0;a=0?r.slice(0,s+1):[r[0]];break}}}return r.reduceRight((e,l,c)=>{let u,d=!1,p=null,f=null;n&&(u=o&&l.route.id?o[l.route.id]:void 0,p=l.route.errorElement||he,i&&(s<0&&0===c?(Ce("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,f=null):s===c&&(d=!0,f=l.route.hydrateFallbackElement||null)));let m=t.concat(r.slice(0,c+1)),h=()=>{let t;return t=u?p:d?f:l.route.Component?a.createElement(l.route.Component,null):l.route.element?l.route.element:e,a.createElement(ye,{match:l,routeContext:{outlet:e,matches:m,isDataRoute:null!=n},children:t})};return n&&(l.route.ErrorBoundary||l.route.errorElement||0===c)?a.createElement(ge,{location:n.location,revalidation:n.revalidation,component:p,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0}}):h()},null)}function Ae(e){return"".concat(e," must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.")}function be(e){let t=a.useContext(J);return m(t,Ae(e)),t}function we(e){let t=a.useContext(q);return m(t,Ae(e)),t}function Se(e){let t=function(e){let t=a.useContext(re);return m(t,Ae(e)),t}(e),n=t.matches[t.matches.length-1];return m(n.route.id,"".concat(e,' can only be used on routes that contain a unique "id"')),n.route.id}function ke(){var e;let t=a.useContext(oe),n=we("useRouteError"),r=Se("useRouteError");return void 0!==t?t:null===(e=n.errors)||void 0===e?void 0:e[r]}var xe={};function Ce(e,t,n){t||xe[e]||(xe[e]=!0,h(!1,n))}a.memo(function(e){let{routes:t,future:n,state:r}=e;return fe(t,void 0,r,n)});function Ee(e){let{to:t,replace:n,state:r,relative:o}=e;m(ie()," may be used only in the context of a component.");let{static:i}=a.useContext(te);h(!i," must not be used on the initial render in a . This is a no-op, but you should modify your code so the is only ever rendered in response to some user interaction or state change.");let{matches:s}=a.useContext(re),{pathname:l}=se(),c=ue(),u=H(t,V(s),l,"path"===o),d=JSON.stringify(u);return a.useEffect(()=>{c(JSON.parse(d),{replace:n,state:r,relative:o})},[c,d,o,n,r]),null}function Te(e){return function(e){let t=a.useContext(re).outlet;return t?a.createElement(de.Provider,{value:e},t):t}(e.context)}function Ne(e){m(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function Pe(e){let{basename:t="/",children:n=null,location:r,navigationType:o="POP",navigator:i,static:s=!1}=e;m(!ie(),"You cannot render a inside another . You should never have more than one in your app.");let l=t.replace(/^\/*/,"/"),c=a.useMemo(()=>({basename:l,navigator:i,static:s,future:{}}),[l,i,s]);"string"===typeof r&&(r=A(r));let{pathname:u="/",search:d="",hash:p="",state:f=null,key:g="default"}=r,y=a.useMemo(()=>{let e=B(u,l);return null==e?null:{location:{pathname:e,search:d,hash:p,state:f,key:g},navigationType:o}},[l,u,d,p,f,g,o]);return h(null!=y,' is not able to match the URL "').concat(u).concat(d).concat(p,"\" because it does not start with the basename, so the won't render anything.")),null==y?null:a.createElement(te.Provider,{value:c},a.createElement(ne.Provider,{children:n,value:y}))}function Me(e){let{children:t,location:n}=e;return fe(Re(t),n)}a.Component;function Re(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=[];return a.Children.forEach(e,(e,r)=>{if(!a.isValidElement(e))return;let o=[...t,r];if(e.type===a.Fragment)return void n.push.apply(n,Re(e.props.children,o));m(e.type===Ne,"[".concat("string"===typeof e.type?e.type:e.type.name,"] is not a component. All component children of must be a or ")),m(!e.props.index||!e.props.children,"An index route cannot have child routes.");let i={id:e.props.id||o.join("-"),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:!0===e.props.hasErrorBoundary||null!=e.props.ErrorBoundary||null!=e.props.errorElement,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(i.children=Re(e.props.children,o)),n.push(i)}),n}var Oe="get",je="application/x-www-form-urlencoded";function Le(e){return null!=e&&"string"===typeof e.tagName}function Ie(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return new URLSearchParams("string"===typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}var De=null;var Fe=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Be(e){return null==e||Fe.has(e)?e:(h(!1,'"'.concat(e,'" is not a valid `encType` for `
`/`` and will default to "').concat(je,'"')),null)}function ze(e,t){let n,r,o,a,i;if(Le(s=e)&&"form"===s.tagName.toLowerCase()){let i=e.getAttribute("action");r=i?B(i,t):null,n=e.getAttribute("method")||Oe,o=Be(e.getAttribute("enctype"))||je,a=new FormData(e)}else if(function(e){return Le(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return Le(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let i=e.form;if(null==i)throw new Error('Cannot submit a