ubk.erp.webpack 1.2.8 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +90 -0
  2. package/dist/Api/api.d.ts +43 -0
  3. package/dist/Layout/ExpenseDashboard/AddExpense/AddExpense.d.ts +5 -0
  4. package/dist/Layout/ExpenseDashboard/AddExpense/AddExpenseEdit.d.ts +5 -0
  5. package/dist/Layout/ExpenseDashboard/AddExpense/index.d.ts +1 -0
  6. package/dist/Layout/ExpenseDashboard/ExpenseHead/ExpenseHead.d.ts +5 -0
  7. package/dist/Layout/ExpenseDashboard/ExpenseHead/ExpenseHeadEdit.d.ts +5 -0
  8. package/dist/Layout/ExpenseDashboard/ExpenseHead/index.d.ts +1 -0
  9. package/dist/Layout/ExpenseDashboard/SearchExpense/SearchExpense.d.ts +5 -0
  10. package/dist/Layout/ExpenseDashboard/SearchExpense/index.d.ts +1 -0
  11. package/dist/Layout/ExpenseDashboard/index.d.ts +3 -0
  12. package/dist/Layout/IncomeDashboard/AddIncome/AddIncome.d.ts +5 -0
  13. package/dist/Layout/IncomeDashboard/AddIncome/AddIncomeEdit.d.ts +5 -0
  14. package/dist/Layout/IncomeDashboard/AddIncome/index.d.ts +1 -0
  15. package/dist/Layout/IncomeDashboard/IncomeHead/IncomeHead.d.ts +5 -0
  16. package/dist/Layout/IncomeDashboard/IncomeHead/IncomeHeadEdit.d.ts +5 -0
  17. package/dist/Layout/IncomeDashboard/IncomeHead/index.d.ts +1 -0
  18. package/dist/Layout/IncomeDashboard/SearchIncome/SearchIncome.d.ts +5 -0
  19. package/dist/Layout/IncomeDashboard/SearchIncome/index.d.ts +1 -0
  20. package/dist/Layout/IncomeDashboard/index.d.ts +3 -0
  21. package/dist/Layout/StudentInformation/AssignStudentSubject/AssignStudentSubject.d.ts +5 -0
  22. package/dist/Layout/StudentInformation/AssignStudentSubject/index.d.ts +1 -0
  23. package/dist/Layout/StudentInformation/MedicalReport/MedicalReport.d.ts +5 -0
  24. package/dist/Layout/StudentInformation/MedicalReport/index.d.ts +1 -0
  25. package/dist/Layout/StudentInformation/StudentLoginCredential/StudentLoginCredential.d.ts +5 -0
  26. package/dist/Layout/StudentInformation/StudentLoginCredential/index.d.ts +1 -0
  27. package/dist/Layout/StudentInformation/index.d.ts +3 -0
  28. package/dist/Layout/homeworks/AddHomework copy.d.ts +5 -0
  29. package/dist/Layout/homeworks/AddHomework.d.ts +5 -0
  30. package/dist/Layout/homeworks/Edit/HomeWorkEdit.d.ts +5 -0
  31. package/dist/Layout/homeworks/SubmissionDetails.d.ts +5 -0
  32. package/dist/index.cjs +12 -12
  33. package/dist/index.d.ts +11 -0
  34. package/dist/index.js +11996 -8893
  35. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1,19 +1,19 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("antd"),H=require("swr"),w=require("react-hot-toast"),i=require("react"),nt=require("swr/mutation"),Z=require("@ant-design/icons"),ae=require("dayjs"),nl=require("react-dom/server"),xa=require("react-to-print"),Xi=require("react-select"),Zi=require("react-barcode"),sl=()=>e.jsxs(n.Card,{style:{borderRadius:16},children:[e.jsx(n.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),F=({width:t,height:a,display:s,justifyContent:r,alignItems:o,flexDirection:l,gap:d,style:c,children:g,...f})=>{const u={width:t,height:a,display:s,justifyContent:r,alignItems:o,flexDirection:l,gap:d,...c};return e.jsx("div",{style:u,...f,children:g})},ke=({variant:t,fontWeight:a,style:s,children:r,...o})=>{const l=a==="bold"?700:a==="light"?300:a;return t==="h1"?e.jsx(n.Typography.Title,{level:1,style:{fontWeight:l,...s},...o,children:r}):t==="h2"?e.jsx(n.Typography.Title,{level:2,style:{fontWeight:l,...s},...o,children:r}):t==="h3"?e.jsx(n.Typography.Title,{level:3,style:{fontWeight:l,...s},...o,children:r}):t==="h4"?e.jsx(n.Typography.Title,{level:4,style:{fontWeight:l,...s},...o,children:r}):t==="h5"?e.jsx(n.Typography.Title,{level:5,style:{fontWeight:l,...s},...o,children:r}):e.jsx(n.Typography.Text,{style:{fontWeight:l,...s},...o,children:r})};function eo({title:t="",icon:a="",path:s="",onClick:r}){const o=()=>{if(r){r(s);return}typeof window<"u"&&typeof s=="string"&&s.length>0&&window.location.assign(s)};return e.jsxs(n.Card,{hoverable:!0,onClick:o,style:{borderRadius:12,overflow:"hidden",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.10)"},bodyStyle:{padding:0,cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"stretch"},children:[e.jsx(F,{width:"100%",display:"flex",justifyContent:"center",alignItems:"center",style:{padding:"10px 12px",minHeight:80},children:e.jsx("img",{src:a,alt:"",style:{width:45,height:50,objectFit:"contain"}})}),e.jsx(F,{style:{padding:"0 12px"},children:e.jsx(n.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(F,{style:{padding:"10px 10px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:35},children:e.jsx(ke,{variant:"button",fontWeight:"bold",style:{fontSize:12},children:t})})]})}function to(t,a){return function(){return t.apply(a,arguments)}}const{toString:rl}=Object.prototype,{getPrototypeOf:Wn}=Object,{iterator:Hn,toStringTag:ao}=Symbol,Kn=(t=>a=>{const s=rl.call(a);return t[s]||(t[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),St=t=>(t=t.toLowerCase(),a=>Kn(a)===t),Gn=t=>a=>typeof a===t,{isArray:ba}=Array,ya=Gn("undefined");function Va(t){return t!==null&&!ya(t)&&t.constructor!==null&&!ya(t.constructor)&&ot(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const no=St("ArrayBuffer");function il(t){let a;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?a=ArrayBuffer.isView(t):a=t&&t.buffer&&no(t.buffer),a}const ol=Gn("string"),ot=Gn("function"),so=Gn("number"),Wa=t=>t!==null&&typeof t=="object",ll=t=>t===!0||t===!1,Tn=t=>{if(Kn(t)!=="object")return!1;const a=Wn(t);return(a===null||a===Object.prototype||Object.getPrototypeOf(a)===null)&&!(ao in t)&&!(Hn in t)},dl=t=>{if(!Wa(t)||Va(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},cl=St("Date"),ul=St("File"),pl=t=>!!(t&&typeof t.uri<"u"),ml=t=>t&&typeof t.getParts<"u",fl=St("Blob"),yl=St("FileList"),hl=t=>Wa(t)&&ot(t.pipe);function gl(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const cr=gl(),ur=typeof cr.FormData<"u"?cr.FormData:void 0,xl=t=>{if(!t)return!1;if(ur&&t instanceof ur)return!0;const a=Wn(t);if(!a||a===Object.prototype||!ot(t.append))return!1;const s=Kn(t);return s==="formdata"||s==="object"&&ot(t.toString)&&t.toString()==="[object FormData]"},bl=St("URLSearchParams"),[jl,Sl,vl,_l]=["ReadableStream","Request","Response","Headers"].map(St),wl=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ha(t,a,{allOwnKeys:s=!1}={}){if(t===null||typeof t>"u")return;let r,o;if(typeof t!="object"&&(t=[t]),ba(t))for(r=0,o=t.length;r<o;r++)a.call(null,t[r],r,t);else{if(Va(t))return;const l=s?Object.getOwnPropertyNames(t):Object.keys(t),d=l.length;let c;for(r=0;r<d;r++)c=l[r],a.call(null,t[c],c,t)}}function ro(t,a){if(Va(t))return null;a=a.toLowerCase();const s=Object.keys(t);let r=s.length,o;for(;r-- >0;)if(o=s[r],a===o.toLowerCase())return o;return null}const Vt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,io=t=>!ya(t)&&t!==Vt;function Us(){const{caseless:t,skipUndefined:a}=io(this)&&this||{},s={},r=(o,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const d=t&&ro(s,l)||l;Tn(s[d])&&Tn(o)?s[d]=Us(s[d],o):Tn(o)?s[d]=Us({},o):ba(o)?s[d]=o.slice():(!a||!ya(o))&&(s[d]=o)};for(let o=0,l=arguments.length;o<l;o++)arguments[o]&&Ha(arguments[o],r);return s}const Cl=(t,a,s,{allOwnKeys:r}={})=>(Ha(a,(o,l)=>{s&&ot(o)?Object.defineProperty(t,l,{value:to(o,s),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,l,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),Al=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Tl=(t,a,s,r)=>{t.prototype=Object.create(a.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:a.prototype}),s&&Object.assign(t.prototype,s)},Rl=(t,a,s,r)=>{let o,l,d;const c={};if(a=a||{},t==null)return a;do{for(o=Object.getOwnPropertyNames(t),l=o.length;l-- >0;)d=o[l],(!r||r(d,t,a))&&!c[d]&&(a[d]=t[d],c[d]=!0);t=s!==!1&&Wn(t)}while(t&&(!s||s(t,a))&&t!==Object.prototype);return a},Dl=(t,a,s)=>{t=String(t),(s===void 0||s>t.length)&&(s=t.length),s-=a.length;const r=t.indexOf(a,s);return r!==-1&&r===s},Il=t=>{if(!t)return null;if(ba(t))return t;let a=t.length;if(!so(a))return null;const s=new Array(a);for(;a-- >0;)s[a]=t[a];return s},kl=(t=>a=>t&&a instanceof t)(typeof Uint8Array<"u"&&Wn(Uint8Array)),Pl=(t,a)=>{const r=(t&&t[Hn]).call(t);let o;for(;(o=r.next())&&!o.done;){const l=o.value;a.call(t,l[0],l[1])}},Ol=(t,a)=>{let s;const r=[];for(;(s=t.exec(a))!==null;)r.push(s);return r},Ml=St("HTMLFormElement"),El=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(s,r,o){return r.toUpperCase()+o}),pr=(({hasOwnProperty:t})=>(a,s)=>t.call(a,s))(Object.prototype),Fl=St("RegExp"),oo=(t,a)=>{const s=Object.getOwnPropertyDescriptors(t),r={};Ha(s,(o,l)=>{let d;(d=a(o,l,t))!==!1&&(r[l]=d||o)}),Object.defineProperties(t,r)},$l=t=>{oo(t,(a,s)=>{if(ot(t)&&["arguments","caller","callee"].indexOf(s)!==-1)return!1;const r=t[s];if(ot(r)){if(a.enumerable=!1,"writable"in a){a.writable=!1;return}a.set||(a.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")})}})},Ul=(t,a)=>{const s={},r=o=>{o.forEach(l=>{s[l]=!0})};return ba(t)?r(t):r(String(t).split(a)),s},Nl=()=>{},Ll=(t,a)=>t!=null&&Number.isFinite(t=+t)?t:a;function Bl(t){return!!(t&&ot(t.append)&&t[ao]==="FormData"&&t[Hn])}const ql=t=>{const a=new Array(10),s=(r,o)=>{if(Wa(r)){if(a.indexOf(r)>=0)return;if(Va(r))return r;if(!("toJSON"in r)){a[o]=r;const l=ba(r)?[]:{};return Ha(r,(d,c)=>{const g=s(d,o+1);!ya(g)&&(l[c]=g)}),a[o]=void 0,l}}return r};return s(t,0)},zl=St("AsyncFunction"),Yl=t=>t&&(Wa(t)||ot(t))&&ot(t.then)&&ot(t.catch),lo=((t,a)=>t?setImmediate:a?((s,r)=>(Vt.addEventListener("message",({source:o,data:l})=>{o===Vt&&l===s&&r.length&&r.shift()()},!1),o=>{r.push(o),Vt.postMessage(s,"*")}))(`axios@${Math.random()}`,[]):s=>setTimeout(s))(typeof setImmediate=="function",ot(Vt.postMessage)),Vl=typeof queueMicrotask<"u"?queueMicrotask.bind(Vt):typeof process<"u"&&process.nextTick||lo,Wl=t=>t!=null&&ot(t[Hn]),J={isArray:ba,isArrayBuffer:no,isBuffer:Va,isFormData:xl,isArrayBufferView:il,isString:ol,isNumber:so,isBoolean:ll,isObject:Wa,isPlainObject:Tn,isEmptyObject:dl,isReadableStream:jl,isRequest:Sl,isResponse:vl,isHeaders:_l,isUndefined:ya,isDate:cl,isFile:ul,isReactNativeBlob:pl,isReactNative:ml,isBlob:fl,isRegExp:Fl,isFunction:ot,isStream:hl,isURLSearchParams:bl,isTypedArray:kl,isFileList:yl,forEach:Ha,merge:Us,extend:Cl,trim:wl,stripBOM:Al,inherits:Tl,toFlatObject:Rl,kindOf:Kn,kindOfTest:St,endsWith:Dl,toArray:Il,forEachEntry:Pl,matchAll:Ol,isHTMLForm:Ml,hasOwnProperty:pr,hasOwnProp:pr,reduceDescriptors:oo,freezeMethods:$l,toObjectSet:Ul,toCamelCase:El,noop:Nl,toFiniteNumber:Ll,findKey:ro,global:Vt,isContextDefined:io,isSpecCompliantForm:Bl,toJSONObject:ql,isAsyncFn:zl,isThenable:Yl,setImmediate:lo,asap:Vl,isIterable:Wl};let ve=class co extends Error{static from(a,s,r,o,l,d){const c=new co(a.message,s||a.code,r,o,l);return c.cause=a,c.name=a.name,a.status!=null&&c.status==null&&(c.status=a.status),d&&Object.assign(c,d),c}constructor(a,s,r,o,l){super(a),Object.defineProperty(this,"message",{value:a,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,s&&(this.code=s),r&&(this.config=r),o&&(this.request=o),l&&(this.response=l,this.status=l.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:J.toJSONObject(this.config),code:this.code,status:this.status}}};ve.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";ve.ERR_BAD_OPTION="ERR_BAD_OPTION";ve.ECONNABORTED="ECONNABORTED";ve.ETIMEDOUT="ETIMEDOUT";ve.ERR_NETWORK="ERR_NETWORK";ve.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";ve.ERR_DEPRECATED="ERR_DEPRECATED";ve.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";ve.ERR_BAD_REQUEST="ERR_BAD_REQUEST";ve.ERR_CANCELED="ERR_CANCELED";ve.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";ve.ERR_INVALID_URL="ERR_INVALID_URL";ve.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const Hl=null;function Ns(t){return J.isPlainObject(t)||J.isArray(t)}function uo(t){return J.endsWith(t,"[]")?t.slice(0,-2):t}function ds(t,a,s){return t?t.concat(a).map(function(o,l){return o=uo(o),!s&&l?"["+o+"]":o}).join(s?".":""):a}function Kl(t){return J.isArray(t)&&!t.some(Ns)}const Gl=J.toFlatObject(J,{},null,function(a){return/^is[A-Z]/.test(a)});function Jn(t,a,s){if(!J.isObject(t))throw new TypeError("target must be an object");a=a||new FormData,s=J.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,T){return!J.isUndefined(T[x])});const r=s.metaTokens,o=s.visitor||p,l=s.dots,d=s.indexes,c=s.Blob||typeof Blob<"u"&&Blob,g=s.maxDepth===void 0?100:s.maxDepth,f=c&&J.isSpecCompliantForm(a);if(!J.isFunction(o))throw new TypeError("visitor must be a function");function u(m){if(m===null)return"";if(J.isDate(m))return m.toISOString();if(J.isBoolean(m))return m.toString();if(!f&&J.isBlob(m))throw new ve("Blob is not supported. Use a Buffer instead.");return J.isArrayBuffer(m)||J.isTypedArray(m)?f&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function p(m,x,T){let I=m;if(J.isReactNative(a)&&J.isReactNativeBlob(m))return a.append(ds(T,x,l),u(m)),!1;if(m&&!T&&typeof m=="object"){if(J.endsWith(x,"{}"))x=r?x:x.slice(0,-2),m=JSON.stringify(m);else if(J.isArray(m)&&Kl(m)||(J.isFileList(m)||J.endsWith(x,"[]"))&&(I=J.toArray(m)))return x=uo(x),I.forEach(function(C,b){!(J.isUndefined(C)||C===null)&&a.append(d===!0?ds([x],b,l):d===null?x:x+"[]",u(C))}),!1}return Ns(m)?!0:(a.append(ds(T,x,l),u(m)),!1)}const _=[],v=Object.assign(Gl,{defaultVisitor:p,convertValue:u,isVisitable:Ns});function h(m,x,T=0){if(!J.isUndefined(m)){if(T>g)throw new ve("Object is too deeply nested ("+T+" levels). Max depth: "+g,ve.ERR_FORM_DATA_DEPTH_EXCEEDED);if(_.indexOf(m)!==-1)throw Error("Circular reference detected in "+x.join("."));_.push(m),J.forEach(m,function(k,C){(!(J.isUndefined(k)||k===null)&&o.call(a,k,J.isString(C)?C.trim():C,x,v))===!0&&h(k,x?x.concat(C):[C],T+1)}),_.pop()}}if(!J.isObject(t))throw new TypeError("data must be an object");return h(t),a}function mr(t){const a={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(r){return a[r]})}function Ys(t,a){this._pairs=[],t&&Jn(t,this,a)}const po=Ys.prototype;po.append=function(a,s){this._pairs.push([a,s])};po.toString=function(a){const s=a?function(r){return a.call(this,r,mr)}:mr;return this._pairs.map(function(o){return s(o[0])+"="+s(o[1])},"").join("&")};function Jl(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function mo(t,a,s){if(!a)return t;const r=s&&s.encode||Jl,o=J.isFunction(s)?{serialize:s}:s,l=o&&o.serialize;let d;if(l?d=l(a,o):d=J.isURLSearchParams(a)?a.toString():new Ys(a,o).toString(r),d){const c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class fr{constructor(){this.handlers=[]}use(a,s,r){return this.handlers.push({fulfilled:a,rejected:s,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(a){this.handlers[a]&&(this.handlers[a]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(a){J.forEach(this.handlers,function(r){r!==null&&a(r)})}}const Vs={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Ql=typeof URLSearchParams<"u"?URLSearchParams:Ys,Xl=typeof FormData<"u"?FormData:null,Zl=typeof Blob<"u"?Blob:null,ed={isBrowser:!0,classes:{URLSearchParams:Ql,FormData:Xl,Blob:Zl},protocols:["http","https","file","blob","url","data"]},Ws=typeof window<"u"&&typeof document<"u",Ls=typeof navigator=="object"&&navigator||void 0,td=Ws&&(!Ls||["ReactNative","NativeScript","NS"].indexOf(Ls.product)<0),ad=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",nd=Ws&&window.location.href||"http://localhost",sd=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ws,hasStandardBrowserEnv:td,hasStandardBrowserWebWorkerEnv:ad,navigator:Ls,origin:nd},Symbol.toStringTag,{value:"Module"})),Ze={...sd,...ed};function rd(t,a){return Jn(t,new Ze.classes.URLSearchParams,{visitor:function(s,r,o,l){return Ze.isNode&&J.isBuffer(s)?(this.append(r,s.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...a})}function id(t){return J.matchAll(/\w+|\[(\w*)]/g,t).map(a=>a[0]==="[]"?"":a[1]||a[0])}function od(t){const a={},s=Object.keys(t);let r;const o=s.length;let l;for(r=0;r<o;r++)l=s[r],a[l]=t[l];return a}function fo(t){function a(s,r,o,l){let d=s[l++];if(d==="__proto__")return!0;const c=Number.isFinite(+d),g=l>=s.length;return d=!d&&J.isArray(o)?o.length:d,g?(J.hasOwnProp(o,d)?o[d]=J.isArray(o[d])?o[d].concat(r):[o[d],r]:o[d]=r,!c):((!o[d]||!J.isObject(o[d]))&&(o[d]=[]),a(s,r,o[d],l)&&J.isArray(o[d])&&(o[d]=od(o[d])),!c)}if(J.isFormData(t)&&J.isFunction(t.entries)){const s={};return J.forEachEntry(t,(r,o)=>{a(id(r),o,s,0)}),s}return null}const ea=(t,a)=>t!=null&&J.hasOwnProp(t,a)?t[a]:void 0;function ld(t,a,s){if(J.isString(t))try{return(a||JSON.parse)(t),J.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(s||JSON.stringify)(t)}const Ka={transitional:Vs,adapter:["xhr","http","fetch"],transformRequest:[function(a,s){const r=s.getContentType()||"",o=r.indexOf("application/json")>-1,l=J.isObject(a);if(l&&J.isHTMLForm(a)&&(a=new FormData(a)),J.isFormData(a))return o?JSON.stringify(fo(a)):a;if(J.isArrayBuffer(a)||J.isBuffer(a)||J.isStream(a)||J.isFile(a)||J.isBlob(a)||J.isReadableStream(a))return a;if(J.isArrayBufferView(a))return a.buffer;if(J.isURLSearchParams(a))return s.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),a.toString();let c;if(l){const g=ea(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return rd(a,g).toString();if((c=J.isFileList(a))||r.indexOf("multipart/form-data")>-1){const f=ea(this,"env"),u=f&&f.FormData;return Jn(c?{"files[]":a}:a,u&&new u,g)}}return l||o?(s.setContentType("application/json",!1),ld(a)):a}],transformResponse:[function(a){const s=ea(this,"transitional")||Ka.transitional,r=s&&s.forcedJSONParsing,o=ea(this,"responseType"),l=o==="json";if(J.isResponse(a)||J.isReadableStream(a))return a;if(a&&J.isString(a)&&(r&&!o||l)){const c=!(s&&s.silentJSONParsing)&&l;try{return JSON.parse(a,ea(this,"parseReviver"))}catch(g){if(c)throw g.name==="SyntaxError"?ve.from(g,ve.ERR_BAD_RESPONSE,this,null,ea(this,"response")):g}}return a}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ze.classes.FormData,Blob:Ze.classes.Blob},validateStatus:function(a){return a>=200&&a<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};J.forEach(["delete","get","head","post","put","patch"],t=>{Ka.headers[t]={}});const dd=J.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),cd=t=>{const a={};let s,r,o;return t&&t.split(`
2
- `).forEach(function(d){o=d.indexOf(":"),s=d.substring(0,o).trim().toLowerCase(),r=d.substring(o+1).trim(),!(!s||a[s]&&dd[s])&&(s==="set-cookie"?a[s]?a[s].push(r):a[s]=[r]:a[s]=a[s]?a[s]+", "+r:r)}),a},yr=Symbol("internals"),ud=/[^\x09\x20-\x7E\x80-\xFF]/g;function pd(t){let a=0,s=t.length;for(;a<s;){const r=t.charCodeAt(a);if(r!==9&&r!==32)break;a+=1}for(;s>a;){const r=t.charCodeAt(s-1);if(r!==9&&r!==32)break;s-=1}return a===0&&s===t.length?t:t.slice(a,s)}function _a(t){return t&&String(t).trim().toLowerCase()}function md(t){return pd(t.replace(ud,""))}function Rn(t){return t===!1||t==null?t:J.isArray(t)?t.map(Rn):md(String(t))}function fd(t){const a=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=s.exec(t);)a[r[1]]=r[2];return a}const yd=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function cs(t,a,s,r,o){if(J.isFunction(r))return r.call(this,a,s);if(o&&(a=s),!!J.isString(a)){if(J.isString(r))return a.indexOf(r)!==-1;if(J.isRegExp(r))return r.test(a)}}function hd(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(a,s,r)=>s.toUpperCase()+r)}function gd(t,a){const s=J.toCamelCase(" "+a);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+s,{value:function(o,l,d){return this[r].call(this,a,o,l,d)},configurable:!0})})}let lt=class{constructor(a){a&&this.set(a)}set(a,s,r){const o=this;function l(c,g,f){const u=_a(g);if(!u)throw new Error("header name must be a non-empty string");const p=J.findKey(o,u);(!p||o[p]===void 0||f===!0||f===void 0&&o[p]!==!1)&&(o[p||g]=Rn(c))}const d=(c,g)=>J.forEach(c,(f,u)=>l(f,u,g));if(J.isPlainObject(a)||a instanceof this.constructor)d(a,s);else if(J.isString(a)&&(a=a.trim())&&!yd(a))d(cd(a),s);else if(J.isObject(a)&&J.isIterable(a)){let c={},g,f;for(const u of a){if(!J.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[f=u[0]]=(g=c[f])?J.isArray(g)?[...g,u[1]]:[g,u[1]]:u[1]}d(c,s)}else a!=null&&l(s,a,r);return this}get(a,s){if(a=_a(a),a){const r=J.findKey(this,a);if(r){const o=this[r];if(!s)return o;if(s===!0)return fd(o);if(J.isFunction(s))return s.call(this,o,r);if(J.isRegExp(s))return s.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(a,s){if(a=_a(a),a){const r=J.findKey(this,a);return!!(r&&this[r]!==void 0&&(!s||cs(this,this[r],r,s)))}return!1}delete(a,s){const r=this;let o=!1;function l(d){if(d=_a(d),d){const c=J.findKey(r,d);c&&(!s||cs(r,r[c],c,s))&&(delete r[c],o=!0)}}return J.isArray(a)?a.forEach(l):l(a),o}clear(a){const s=Object.keys(this);let r=s.length,o=!1;for(;r--;){const l=s[r];(!a||cs(this,this[l],l,a,!0))&&(delete this[l],o=!0)}return o}normalize(a){const s=this,r={};return J.forEach(this,(o,l)=>{const d=J.findKey(r,l);if(d){s[d]=Rn(o),delete s[l];return}const c=a?hd(l):String(l).trim();c!==l&&delete s[l],s[c]=Rn(o),r[c]=!0}),this}concat(...a){return this.constructor.concat(this,...a)}toJSON(a){const s=Object.create(null);return J.forEach(this,(r,o)=>{r!=null&&r!==!1&&(s[o]=a&&J.isArray(r)?r.join(", "):r)}),s}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([a,s])=>a+": "+s).join(`
3
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(a){return a instanceof this?a:new this(a)}static concat(a,...s){const r=new this(a);return s.forEach(o=>r.set(o)),r}static accessor(a){const r=(this[yr]=this[yr]={accessors:{}}).accessors,o=this.prototype;function l(d){const c=_a(d);r[c]||(gd(o,d),r[c]=!0)}return J.isArray(a)?a.forEach(l):l(a),this}};lt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);J.reduceDescriptors(lt.prototype,({value:t},a)=>{let s=a[0].toUpperCase()+a.slice(1);return{get:()=>t,set(r){this[s]=r}}});J.freezeMethods(lt);function us(t,a){const s=this||Ka,r=a||s,o=lt.from(r.headers);let l=r.data;return J.forEach(t,function(c){l=c.call(s,l,o.normalize(),a?a.status:void 0)}),o.normalize(),l}function yo(t){return!!(t&&t.__CANCEL__)}let Ga=class extends ve{constructor(a,s,r){super(a??"canceled",ve.ERR_CANCELED,s,r),this.name="CanceledError",this.__CANCEL__=!0}};function ho(t,a,s){const r=s.config.validateStatus;!s.status||!r||r(s.status)?t(s):a(new ve("Request failed with status code "+s.status,[ve.ERR_BAD_REQUEST,ve.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function xd(t){const a=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return a&&a[1]||""}function bd(t,a){t=t||10;const s=new Array(t),r=new Array(t);let o=0,l=0,d;return a=a!==void 0?a:1e3,function(g){const f=Date.now(),u=r[l];d||(d=f),s[o]=g,r[o]=f;let p=l,_=0;for(;p!==o;)_+=s[p++],p=p%t;if(o=(o+1)%t,o===l&&(l=(l+1)%t),f-d<a)return;const v=u&&f-u;return v?Math.round(_*1e3/v):void 0}}function jd(t,a){let s=0,r=1e3/a,o,l;const d=(f,u=Date.now())=>{s=u,o=null,l&&(clearTimeout(l),l=null),t(...f)};return[(...f)=>{const u=Date.now(),p=u-s;p>=r?d(f,u):(o=f,l||(l=setTimeout(()=>{l=null,d(o)},r-p)))},()=>o&&d(o)]}const Yn=(t,a,s=3)=>{let r=0;const o=bd(50,250);return jd(l=>{const d=l.loaded,c=l.lengthComputable?l.total:void 0,g=c!=null?Math.min(d,c):d,f=Math.max(0,g-r),u=o(f);r=Math.max(r,g);const p={loaded:g,total:c,progress:c?g/c:void 0,bytes:f,rate:u||void 0,estimated:u&&c?(c-g)/u:void 0,event:l,lengthComputable:c!=null,[a?"download":"upload"]:!0};t(p)},s)},hr=(t,a)=>{const s=t!=null;return[r=>a[0]({lengthComputable:s,total:t,loaded:r}),a[1]]},gr=t=>(...a)=>J.asap(()=>t(...a)),Sd=Ze.hasStandardBrowserEnv?((t,a)=>s=>(s=new URL(s,Ze.origin),t.protocol===s.protocol&&t.host===s.host&&(a||t.port===s.port)))(new URL(Ze.origin),Ze.navigator&&/(msie|trident)/i.test(Ze.navigator.userAgent)):()=>!0,vd=Ze.hasStandardBrowserEnv?{write(t,a,s,r,o,l,d){if(typeof document>"u")return;const c=[`${t}=${encodeURIComponent(a)}`];J.isNumber(s)&&c.push(`expires=${new Date(s).toUTCString()}`),J.isString(r)&&c.push(`path=${r}`),J.isString(o)&&c.push(`domain=${o}`),l===!0&&c.push("secure"),J.isString(d)&&c.push(`SameSite=${d}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;const a=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return a?decodeURIComponent(a[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function _d(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function wd(t,a){return a?t.replace(/\/?\/$/,"")+"/"+a.replace(/^\/+/,""):t}function go(t,a,s){let r=!_d(a);return t&&(r||s===!1)?wd(t,a):a}const xr=t=>t instanceof lt?{...t}:t;function Gt(t,a){a=a||{};const s=Object.create(null);Object.defineProperty(s,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(f,u,p,_){return J.isPlainObject(f)&&J.isPlainObject(u)?J.merge.call({caseless:_},f,u):J.isPlainObject(u)?J.merge({},u):J.isArray(u)?u.slice():u}function o(f,u,p,_){if(J.isUndefined(u)){if(!J.isUndefined(f))return r(void 0,f,p,_)}else return r(f,u,p,_)}function l(f,u){if(!J.isUndefined(u))return r(void 0,u)}function d(f,u){if(J.isUndefined(u)){if(!J.isUndefined(f))return r(void 0,f)}else return r(void 0,u)}function c(f,u,p){if(J.hasOwnProp(a,p))return r(f,u);if(J.hasOwnProp(t,p))return r(void 0,f)}const g={url:l,method:l,data:l,baseURL:d,transformRequest:d,transformResponse:d,paramsSerializer:d,timeout:d,timeoutMessage:d,withCredentials:d,withXSRFToken:d,adapter:d,responseType:d,xsrfCookieName:d,xsrfHeaderName:d,onUploadProgress:d,onDownloadProgress:d,decompress:d,maxContentLength:d,maxBodyLength:d,beforeRedirect:d,transport:d,httpAgent:d,httpsAgent:d,cancelToken:d,socketPath:d,allowedSocketPaths:d,responseEncoding:d,validateStatus:c,headers:(f,u,p)=>o(xr(f),xr(u),p,!0)};return J.forEach(Object.keys({...t,...a}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const p=J.hasOwnProp(g,u)?g[u]:o,_=J.hasOwnProp(t,u)?t[u]:void 0,v=J.hasOwnProp(a,u)?a[u]:void 0,h=p(_,v,u);J.isUndefined(h)&&p!==c||(s[u]=h)}),s}const xo=t=>{const a=Gt({},t),s=_=>J.hasOwnProp(a,_)?a[_]:void 0,r=s("data");let o=s("withXSRFToken");const l=s("xsrfHeaderName"),d=s("xsrfCookieName");let c=s("headers");const g=s("auth"),f=s("baseURL"),u=s("allowAbsoluteUrls"),p=s("url");if(a.headers=c=lt.from(c),a.url=mo(go(f,p,u),t.params,t.paramsSerializer),g&&c.set("Authorization","Basic "+btoa((g.username||"")+":"+(g.password?unescape(encodeURIComponent(g.password)):""))),J.isFormData(r)){if(Ze.hasStandardBrowserEnv||Ze.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(J.isFunction(r.getHeaders)){const _=r.getHeaders(),v=["content-type","content-length"];Object.entries(_).forEach(([h,m])=>{v.includes(h.toLowerCase())&&c.set(h,m)})}}if(Ze.hasStandardBrowserEnv&&(J.isFunction(o)&&(o=o(a)),o===!0||o==null&&Sd(a.url))){const v=l&&d&&vd.read(d);v&&c.set(l,v)}return a},Cd=typeof XMLHttpRequest<"u",Ad=Cd&&function(t){return new Promise(function(s,r){const o=xo(t);let l=o.data;const d=lt.from(o.headers).normalize();let{responseType:c,onUploadProgress:g,onDownloadProgress:f}=o,u,p,_,v,h;function m(){v&&v(),h&&h(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function T(){if(!x)return;const k=lt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),b={data:!c||c==="text"||c==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:k,config:t,request:x};ho(function(S){s(S),m()},function(S){r(S),m()},b),x=null}"onloadend"in x?x.onloadend=T:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(T)},x.onabort=function(){x&&(r(new ve("Request aborted",ve.ECONNABORTED,t,x)),x=null)},x.onerror=function(C){const b=C&&C.message?C.message:"Network Error",y=new ve(b,ve.ERR_NETWORK,t,x);y.event=C||null,r(y),x=null},x.ontimeout=function(){let C=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const b=o.transitional||Vs;o.timeoutErrorMessage&&(C=o.timeoutErrorMessage),r(new ve(C,b.clarifyTimeoutError?ve.ETIMEDOUT:ve.ECONNABORTED,t,x)),x=null},l===void 0&&d.setContentType(null),"setRequestHeader"in x&&J.forEach(d.toJSON(),function(C,b){x.setRequestHeader(b,C)}),J.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),c&&c!=="json"&&(x.responseType=o.responseType),f&&([_,h]=Yn(f,!0),x.addEventListener("progress",_)),g&&x.upload&&([p,v]=Yn(g),x.upload.addEventListener("progress",p),x.upload.addEventListener("loadend",v)),(o.cancelToken||o.signal)&&(u=k=>{x&&(r(!k||k.type?new Ga(null,t,x):k),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const I=xd(o.url);if(I&&Ze.protocols.indexOf(I)===-1){r(new ve("Unsupported protocol "+I+":",ve.ERR_BAD_REQUEST,t));return}x.send(l||null)})},Td=(t,a)=>{const{length:s}=t=t?t.filter(Boolean):[];if(a||s){let r=new AbortController,o;const l=function(f){if(!o){o=!0,c();const u=f instanceof Error?f:this.reason;r.abort(u instanceof ve?u:new Ga(u instanceof Error?u.message:u))}};let d=a&&setTimeout(()=>{d=null,l(new ve(`timeout of ${a}ms exceeded`,ve.ETIMEDOUT))},a);const c=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(f=>{f.unsubscribe?f.unsubscribe(l):f.removeEventListener("abort",l)}),t=null)};t.forEach(f=>f.addEventListener("abort",l));const{signal:g}=r;return g.unsubscribe=()=>J.asap(c),g}},Rd=function*(t,a){let s=t.byteLength;if(s<a){yield t;return}let r=0,o;for(;r<s;)o=r+a,yield t.slice(r,o),r=o},Dd=async function*(t,a){for await(const s of Id(t))yield*Rd(s,a)},Id=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const a=t.getReader();try{for(;;){const{done:s,value:r}=await a.read();if(s)break;yield r}}finally{await a.cancel()}},br=(t,a,s,r)=>{const o=Dd(t,a);let l=0,d,c=g=>{d||(d=!0,r&&r(g))};return new ReadableStream({async pull(g){try{const{done:f,value:u}=await o.next();if(f){c(),g.close();return}let p=u.byteLength;if(s){let _=l+=p;s(_)}g.enqueue(new Uint8Array(u))}catch(f){throw c(f),f}},cancel(g){return c(g),o.return()}},{highWaterMark:2})},jr=64*1024,{isFunction:dn}=J,kd=(({Request:t,Response:a})=>({Request:t,Response:a}))(J.global),{ReadableStream:Sr,TextEncoder:vr}=J.global,_r=(t,...a)=>{try{return!!t(...a)}catch{return!1}},Pd=t=>{t=J.merge.call({skipUndefined:!0},kd,t);const{fetch:a,Request:s,Response:r}=t,o=a?dn(a):typeof fetch=="function",l=dn(s),d=dn(r);if(!o)return!1;const c=o&&dn(Sr),g=o&&(typeof vr=="function"?(h=>m=>h.encode(m))(new vr):async h=>new Uint8Array(await new s(h).arrayBuffer())),f=l&&c&&_r(()=>{let h=!1;const m=new s(Ze.origin,{body:new Sr,method:"POST",get duplex(){return h=!0,"half"}}),x=m.headers.has("Content-Type");return m.body!=null&&m.body.cancel(),h&&!x}),u=d&&c&&_r(()=>J.isReadableStream(new r("").body)),p={stream:u&&(h=>h.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!p[h]&&(p[h]=(m,x)=>{let T=m&&m[h];if(T)return T.call(m);throw new ve(`Response type '${h}' is not supported`,ve.ERR_NOT_SUPPORT,x)})});const _=async h=>{if(h==null)return 0;if(J.isBlob(h))return h.size;if(J.isSpecCompliantForm(h))return(await new s(Ze.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(J.isArrayBufferView(h)||J.isArrayBuffer(h))return h.byteLength;if(J.isURLSearchParams(h)&&(h=h+""),J.isString(h))return(await g(h)).byteLength},v=async(h,m)=>{const x=J.toFiniteNumber(h.getContentLength());return x??_(m)};return async h=>{let{url:m,method:x,data:T,signal:I,cancelToken:k,timeout:C,onDownloadProgress:b,onUploadProgress:y,responseType:S,headers:A,withCredentials:R="same-origin",fetchOptions:z}=xo(h),U=a||fetch;S=S?(S+"").toLowerCase():"text";let j=Td([I,k&&k.toAbortSignal()],C),O=null;const M=j&&j.unsubscribe&&(()=>{j.unsubscribe()});let $;try{if(y&&f&&x!=="get"&&x!=="head"&&($=await v(A,T))!==0){let D=new s(m,{method:"POST",body:T,duplex:"half"}),L;if(J.isFormData(T)&&(L=D.headers.get("content-type"))&&A.setContentType(L),D.body){const[B,W]=hr($,Yn(gr(y)));T=br(D.body,jr,B,W)}}J.isString(R)||(R=R?"include":"omit");const E=l&&"credentials"in s.prototype;if(J.isFormData(T)){const D=A.getContentType();D&&/^multipart\/form-data/i.test(D)&&!/boundary=/i.test(D)&&A.delete("content-type")}const N={...z,signal:j,method:x.toUpperCase(),headers:A.normalize().toJSON(),body:T,duplex:"half",credentials:E?R:void 0};O=l&&new s(m,N);let V=await(l?U(O,z):U(m,N));const q=u&&(S==="stream"||S==="response");if(u&&(b||q&&M)){const D={};["status","statusText","headers"].forEach(se=>{D[se]=V[se]});const L=J.toFiniteNumber(V.headers.get("content-length")),[B,W]=b&&hr(L,Yn(gr(b),!0))||[];V=new r(br(V.body,jr,B,()=>{W&&W(),M&&M()}),D)}S=S||"text";let P=await p[J.findKey(p,S)||"text"](V,h);return!q&&M&&M(),await new Promise((D,L)=>{ho(D,L,{data:P,headers:lt.from(V.headers),status:V.status,statusText:V.statusText,config:h,request:O})})}catch(E){throw M&&M(),E&&E.name==="TypeError"&&/Load failed|fetch/i.test(E.message)?Object.assign(new ve("Network Error",ve.ERR_NETWORK,h,O,E&&E.response),{cause:E.cause||E}):ve.from(E,E&&E.code,h,O,E&&E.response)}}},Od=new Map,bo=t=>{let a=t&&t.env||{};const{fetch:s,Request:r,Response:o}=a,l=[r,o,s];let d=l.length,c=d,g,f,u=Od;for(;c--;)g=l[c],f=u.get(g),f===void 0&&u.set(g,f=c?new Map:Pd(a)),u=f;return f};bo();const Hs={http:Hl,xhr:Ad,fetch:{get:bo}};J.forEach(Hs,(t,a)=>{if(t){try{Object.defineProperty(t,"name",{value:a})}catch{}Object.defineProperty(t,"adapterName",{value:a})}});const wr=t=>`- ${t}`,Md=t=>J.isFunction(t)||t===null||t===!1;function Ed(t,a){t=J.isArray(t)?t:[t];const{length:s}=t;let r,o;const l={};for(let d=0;d<s;d++){r=t[d];let c;if(o=r,!Md(r)&&(o=Hs[(c=String(r)).toLowerCase()],o===void 0))throw new ve(`Unknown adapter '${c}'`);if(o&&(J.isFunction(o)||(o=o.get(a))))break;l[c||"#"+d]=o}if(!o){const d=Object.entries(l).map(([g,f])=>`adapter ${g} `+(f===!1?"is not supported by the environment":"is not available in the build"));let c=s?d.length>1?`since :
4
- `+d.map(wr).join(`
5
- `):" "+wr(d[0]):"as no adapter specified";throw new ve("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return o}const jo={getAdapter:Ed,adapters:Hs};function ps(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Ga(null,t)}function Cr(t){return ps(t),t.headers=lt.from(t.headers),t.data=us.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),jo.getAdapter(t.adapter||Ka.adapter,t)(t).then(function(r){return ps(t),r.data=us.call(t,t.transformResponse,r),r.headers=lt.from(r.headers),r},function(r){return yo(r)||(ps(t),r&&r.response&&(r.response.data=us.call(t,t.transformResponse,r.response),r.response.headers=lt.from(r.response.headers))),Promise.reject(r)})}const So="1.15.2",Qn={};["object","boolean","number","function","string","symbol"].forEach((t,a)=>{Qn[t]=function(r){return typeof r===t||"a"+(a<1?"n ":" ")+t}});const Ar={};Qn.transitional=function(a,s,r){function o(l,d){return"[Axios v"+So+"] Transitional option '"+l+"'"+d+(r?". "+r:"")}return(l,d,c)=>{if(a===!1)throw new ve(o(d," has been removed"+(s?" in "+s:"")),ve.ERR_DEPRECATED);return s&&!Ar[d]&&(Ar[d]=!0,console.warn(o(d," has been deprecated since v"+s+" and will be removed in the near future"))),a?a(l,d,c):!0}};Qn.spelling=function(a){return(s,r)=>(console.warn(`${r} is likely a misspelling of ${a}`),!0)};function Fd(t,a,s){if(typeof t!="object")throw new ve("options must be an object",ve.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let o=r.length;for(;o-- >0;){const l=r[o],d=Object.prototype.hasOwnProperty.call(a,l)?a[l]:void 0;if(d){const c=t[l],g=c===void 0||d(c,l,t);if(g!==!0)throw new ve("option "+l+" must be "+g,ve.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new ve("Unknown option "+l,ve.ERR_BAD_OPTION)}}const Dn={assertOptions:Fd,validators:Qn},ht=Dn.validators;let Wt=class{constructor(a){this.defaults=a||{},this.interceptors={request:new fr,response:new fr}}async request(a,s){try{return await this._request(a,s)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const l=(()=>{if(!o.stack)return"";const d=o.stack.indexOf(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("antd"),W=require("swr"),_=require("react-hot-toast"),i=require("react"),tt=require("swr/mutation"),te=require("@ant-design/icons"),ee=require("dayjs"),vl=require("react-dom/server"),xa=require("react-to-print"),uo=require("react-select"),po=require("react-barcode"),wl=()=>e.jsxs(n.Card,{style:{borderRadius:16},children:[e.jsx(n.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),A=({width:t,height:a,display:s,justifyContent:r,alignItems:o,flexDirection:l,gap:d,style:c,children:y,...h})=>{const u={width:t,height:a,display:s,justifyContent:r,alignItems:o,flexDirection:l,gap:d,...c};return e.jsx("div",{style:u,...h,children:y})},Se=({variant:t,fontWeight:a,style:s,children:r,...o})=>{const l=a==="bold"?700:a==="light"?300:a;return t==="h1"?e.jsx(n.Typography.Title,{level:1,style:{fontWeight:l,...s},...o,children:r}):t==="h2"?e.jsx(n.Typography.Title,{level:2,style:{fontWeight:l,...s},...o,children:r}):t==="h3"?e.jsx(n.Typography.Title,{level:3,style:{fontWeight:l,...s},...o,children:r}):t==="h4"?e.jsx(n.Typography.Title,{level:4,style:{fontWeight:l,...s},...o,children:r}):t==="h5"?e.jsx(n.Typography.Title,{level:5,style:{fontWeight:l,...s},...o,children:r}):e.jsx(n.Typography.Text,{style:{fontWeight:l,...s},...o,children:r})};function mo({title:t="",icon:a="",path:s="",onClick:r}){const o=()=>{if(r){r(s);return}typeof window<"u"&&typeof s=="string"&&s.length>0&&window.location.assign(s)};return e.jsxs(n.Card,{hoverable:!0,onClick:o,style:{borderRadius:12,overflow:"hidden",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.10)"},bodyStyle:{padding:0,cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"stretch"},children:[e.jsx(A,{width:"100%",display:"flex",justifyContent:"center",alignItems:"center",style:{padding:"10px 12px",minHeight:80},children:e.jsx("img",{src:a,alt:"",style:{width:45,height:50,objectFit:"contain"}})}),e.jsx(A,{style:{padding:"0 12px"},children:e.jsx(n.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(A,{style:{padding:"10px 10px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:35},children:e.jsx(Se,{variant:"button",fontWeight:"bold",style:{fontSize:12},children:t})})]})}function ho(t,a){return function(){return t.apply(a,arguments)}}const{toString:_l}=Object.prototype,{getPrototypeOf:Hn}=Object,{iterator:Kn,toStringTag:fo}=Symbol,Gn=(t=>a=>{const s=_l.call(a);return t[s]||(t[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),_t=t=>(t=t.toLowerCase(),a=>Gn(a)===t),Jn=t=>a=>typeof a===t,{isArray:ba}=Array,fa=Jn("undefined");function Wa(t){return t!==null&&!fa(t)&&t.constructor!==null&&!fa(t.constructor)&&ct(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const yo=_t("ArrayBuffer");function Cl(t){let a;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?a=ArrayBuffer.isView(t):a=t&&t.buffer&&yo(t.buffer),a}const Al=Jn("string"),ct=Jn("function"),go=Jn("number"),Ha=t=>t!==null&&typeof t=="object",Dl=t=>t===!0||t===!1,Tn=t=>{if(Gn(t)!=="object")return!1;const a=Hn(t);return(a===null||a===Object.prototype||Object.getPrototypeOf(a)===null)&&!(fo in t)&&!(Kn in t)},Tl=t=>{if(!Ha(t)||Wa(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Rl=_t("Date"),Il=_t("File"),kl=t=>!!(t&&typeof t.uri<"u"),Pl=t=>t&&typeof t.getParts<"u",Ol=_t("Blob"),Ml=_t("FileList"),El=t=>Ha(t)&&ct(t.pipe);function Fl(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const fr=Fl(),yr=typeof fr.FormData<"u"?fr.FormData:void 0,$l=t=>{if(!t)return!1;if(yr&&t instanceof yr)return!0;const a=Hn(t);if(!a||a===Object.prototype||!ct(t.append))return!1;const s=Gn(t);return s==="formdata"||s==="object"&&ct(t.toString)&&t.toString()==="[object FormData]"},Ul=_t("URLSearchParams"),[Nl,Ll,Bl,ql]=["ReadableStream","Request","Response","Headers"].map(_t),zl=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ka(t,a,{allOwnKeys:s=!1}={}){if(t===null||typeof t>"u")return;let r,o;if(typeof t!="object"&&(t=[t]),ba(t))for(r=0,o=t.length;r<o;r++)a.call(null,t[r],r,t);else{if(Wa(t))return;const l=s?Object.getOwnPropertyNames(t):Object.keys(t),d=l.length;let c;for(r=0;r<d;r++)c=l[r],a.call(null,t[c],c,t)}}function xo(t,a){if(Wa(t))return null;a=a.toLowerCase();const s=Object.keys(t);let r=s.length,o;for(;r-- >0;)if(o=s[r],a===o.toLowerCase())return o;return null}const Ht=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,bo=t=>!fa(t)&&t!==Ht;function Ls(){const{caseless:t,skipUndefined:a}=bo(this)&&this||{},s={},r=(o,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const d=t&&xo(s,l)||l;Tn(s[d])&&Tn(o)?s[d]=Ls(s[d],o):Tn(o)?s[d]=Ls({},o):ba(o)?s[d]=o.slice():(!a||!fa(o))&&(s[d]=o)};for(let o=0,l=arguments.length;o<l;o++)arguments[o]&&Ka(arguments[o],r);return s}const Yl=(t,a,s,{allOwnKeys:r}={})=>(Ka(a,(o,l)=>{s&&ct(o)?Object.defineProperty(t,l,{value:ho(o,s),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,l,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),Vl=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Wl=(t,a,s,r)=>{t.prototype=Object.create(a.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:a.prototype}),s&&Object.assign(t.prototype,s)},Hl=(t,a,s,r)=>{let o,l,d;const c={};if(a=a||{},t==null)return a;do{for(o=Object.getOwnPropertyNames(t),l=o.length;l-- >0;)d=o[l],(!r||r(d,t,a))&&!c[d]&&(a[d]=t[d],c[d]=!0);t=s!==!1&&Hn(t)}while(t&&(!s||s(t,a))&&t!==Object.prototype);return a},Kl=(t,a,s)=>{t=String(t),(s===void 0||s>t.length)&&(s=t.length),s-=a.length;const r=t.indexOf(a,s);return r!==-1&&r===s},Gl=t=>{if(!t)return null;if(ba(t))return t;let a=t.length;if(!go(a))return null;const s=new Array(a);for(;a-- >0;)s[a]=t[a];return s},Jl=(t=>a=>t&&a instanceof t)(typeof Uint8Array<"u"&&Hn(Uint8Array)),Ql=(t,a)=>{const r=(t&&t[Kn]).call(t);let o;for(;(o=r.next())&&!o.done;){const l=o.value;a.call(t,l[0],l[1])}},Xl=(t,a)=>{let s;const r=[];for(;(s=t.exec(a))!==null;)r.push(s);return r},Zl=_t("HTMLFormElement"),ed=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(s,r,o){return r.toUpperCase()+o}),gr=(({hasOwnProperty:t})=>(a,s)=>t.call(a,s))(Object.prototype),td=_t("RegExp"),jo=(t,a)=>{const s=Object.getOwnPropertyDescriptors(t),r={};Ka(s,(o,l)=>{let d;(d=a(o,l,t))!==!1&&(r[l]=d||o)}),Object.defineProperties(t,r)},ad=t=>{jo(t,(a,s)=>{if(ct(t)&&["arguments","caller","callee"].indexOf(s)!==-1)return!1;const r=t[s];if(ct(r)){if(a.enumerable=!1,"writable"in a){a.writable=!1;return}a.set||(a.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")})}})},nd=(t,a)=>{const s={},r=o=>{o.forEach(l=>{s[l]=!0})};return ba(t)?r(t):r(String(t).split(a)),s},sd=()=>{},rd=(t,a)=>t!=null&&Number.isFinite(t=+t)?t:a;function id(t){return!!(t&&ct(t.append)&&t[fo]==="FormData"&&t[Kn])}const od=t=>{const a=new Array(10),s=(r,o)=>{if(Ha(r)){if(a.indexOf(r)>=0)return;if(Wa(r))return r;if(!("toJSON"in r)){a[o]=r;const l=ba(r)?[]:{};return Ka(r,(d,c)=>{const y=s(d,o+1);!fa(y)&&(l[c]=y)}),a[o]=void 0,l}}return r};return s(t,0)},ld=_t("AsyncFunction"),dd=t=>t&&(Ha(t)||ct(t))&&ct(t.then)&&ct(t.catch),So=((t,a)=>t?setImmediate:a?((s,r)=>(Ht.addEventListener("message",({source:o,data:l})=>{o===Ht&&l===s&&r.length&&r.shift()()},!1),o=>{r.push(o),Ht.postMessage(s,"*")}))(`axios@${Math.random()}`,[]):s=>setTimeout(s))(typeof setImmediate=="function",ct(Ht.postMessage)),cd=typeof queueMicrotask<"u"?queueMicrotask.bind(Ht):typeof process<"u"&&process.nextTick||So,ud=t=>t!=null&&ct(t[Kn]),Z={isArray:ba,isArrayBuffer:yo,isBuffer:Wa,isFormData:$l,isArrayBufferView:Cl,isString:Al,isNumber:go,isBoolean:Dl,isObject:Ha,isPlainObject:Tn,isEmptyObject:Tl,isReadableStream:Nl,isRequest:Ll,isResponse:Bl,isHeaders:ql,isUndefined:fa,isDate:Rl,isFile:Il,isReactNativeBlob:kl,isReactNative:Pl,isBlob:Ol,isRegExp:td,isFunction:ct,isStream:El,isURLSearchParams:Ul,isTypedArray:Jl,isFileList:Ml,forEach:Ka,merge:Ls,extend:Yl,trim:zl,stripBOM:Vl,inherits:Wl,toFlatObject:Hl,kindOf:Gn,kindOfTest:_t,endsWith:Kl,toArray:Gl,forEachEntry:Ql,matchAll:Xl,isHTMLForm:Zl,hasOwnProperty:gr,hasOwnProp:gr,reduceDescriptors:jo,freezeMethods:ad,toObjectSet:nd,toCamelCase:ed,noop:sd,toFiniteNumber:rd,findKey:xo,global:Ht,isContextDefined:bo,isSpecCompliantForm:id,toJSONObject:od,isAsyncFn:ld,isThenable:dd,setImmediate:So,asap:cd,isIterable:ud};let Ae=class vo extends Error{static from(a,s,r,o,l,d){const c=new vo(a.message,s||a.code,r,o,l);return c.cause=a,c.name=a.name,a.status!=null&&c.status==null&&(c.status=a.status),d&&Object.assign(c,d),c}constructor(a,s,r,o,l){super(a),Object.defineProperty(this,"message",{value:a,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,s&&(this.code=s),r&&(this.config=r),o&&(this.request=o),l&&(this.response=l,this.status=l.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Z.toJSONObject(this.config),code:this.code,status:this.status}}};Ae.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";Ae.ERR_BAD_OPTION="ERR_BAD_OPTION";Ae.ECONNABORTED="ECONNABORTED";Ae.ETIMEDOUT="ETIMEDOUT";Ae.ERR_NETWORK="ERR_NETWORK";Ae.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";Ae.ERR_DEPRECATED="ERR_DEPRECATED";Ae.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";Ae.ERR_BAD_REQUEST="ERR_BAD_REQUEST";Ae.ERR_CANCELED="ERR_CANCELED";Ae.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";Ae.ERR_INVALID_URL="ERR_INVALID_URL";Ae.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const pd=null;function Bs(t){return Z.isPlainObject(t)||Z.isArray(t)}function wo(t){return Z.endsWith(t,"[]")?t.slice(0,-2):t}function cs(t,a,s){return t?t.concat(a).map(function(o,l){return o=wo(o),!s&&l?"["+o+"]":o}).join(s?".":""):a}function md(t){return Z.isArray(t)&&!t.some(Bs)}const hd=Z.toFlatObject(Z,{},null,function(a){return/^is[A-Z]/.test(a)});function Qn(t,a,s){if(!Z.isObject(t))throw new TypeError("target must be an object");a=a||new FormData,s=Z.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(j,D){return!Z.isUndefined(D[j])});const r=s.metaTokens,o=s.visitor||p,l=s.dots,d=s.indexes,c=s.Blob||typeof Blob<"u"&&Blob,y=s.maxDepth===void 0?100:s.maxDepth,h=c&&Z.isSpecCompliantForm(a);if(!Z.isFunction(o))throw new TypeError("visitor must be a function");function u(m){if(m===null)return"";if(Z.isDate(m))return m.toISOString();if(Z.isBoolean(m))return m.toString();if(!h&&Z.isBlob(m))throw new Ae("Blob is not supported. Use a Buffer instead.");return Z.isArrayBuffer(m)||Z.isTypedArray(m)?h&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function p(m,j,D){let I=m;if(Z.isReactNative(a)&&Z.isReactNativeBlob(m))return a.append(cs(D,j,l),u(m)),!1;if(m&&!D&&typeof m=="object"){if(Z.endsWith(j,"{}"))j=r?j:j.slice(0,-2),m=JSON.stringify(m);else if(Z.isArray(m)&&md(m)||(Z.isFileList(m)||Z.endsWith(j,"[]"))&&(I=Z.toArray(m)))return j=wo(j),I.forEach(function(S,x){!(Z.isUndefined(S)||S===null)&&a.append(d===!0?cs([j],x,l):d===null?j:j+"[]",u(S))}),!1}return Bs(m)?!0:(a.append(cs(D,j,l),u(m)),!1)}const w=[],v=Object.assign(hd,{defaultVisitor:p,convertValue:u,isVisitable:Bs});function b(m,j,D=0){if(!Z.isUndefined(m)){if(D>y)throw new Ae("Object is too deeply nested ("+D+" levels). Max depth: "+y,Ae.ERR_FORM_DATA_DEPTH_EXCEEDED);if(w.indexOf(m)!==-1)throw Error("Circular reference detected in "+j.join("."));w.push(m),Z.forEach(m,function(k,S){(!(Z.isUndefined(k)||k===null)&&o.call(a,k,Z.isString(S)?S.trim():S,j,v))===!0&&b(k,j?j.concat(S):[S],D+1)}),w.pop()}}if(!Z.isObject(t))throw new TypeError("data must be an object");return b(t),a}function xr(t){const a={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(r){return a[r]})}function Hs(t,a){this._pairs=[],t&&Qn(t,this,a)}const _o=Hs.prototype;_o.append=function(a,s){this._pairs.push([a,s])};_o.toString=function(a){const s=a?function(r){return a.call(this,r,xr)}:xr;return this._pairs.map(function(o){return s(o[0])+"="+s(o[1])},"").join("&")};function fd(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Co(t,a,s){if(!a)return t;const r=s&&s.encode||fd,o=Z.isFunction(s)?{serialize:s}:s,l=o&&o.serialize;let d;if(l?d=l(a,o):d=Z.isURLSearchParams(a)?a.toString():new Hs(a,o).toString(r),d){const c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class br{constructor(){this.handlers=[]}use(a,s,r){return this.handlers.push({fulfilled:a,rejected:s,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(a){this.handlers[a]&&(this.handlers[a]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(a){Z.forEach(this.handlers,function(r){r!==null&&a(r)})}}const Ks={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},yd=typeof URLSearchParams<"u"?URLSearchParams:Hs,gd=typeof FormData<"u"?FormData:null,xd=typeof Blob<"u"?Blob:null,bd={isBrowser:!0,classes:{URLSearchParams:yd,FormData:gd,Blob:xd},protocols:["http","https","file","blob","url","data"]},Gs=typeof window<"u"&&typeof document<"u",qs=typeof navigator=="object"&&navigator||void 0,jd=Gs&&(!qs||["ReactNative","NativeScript","NS"].indexOf(qs.product)<0),Sd=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",vd=Gs&&window.location.href||"http://localhost",wd=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Gs,hasStandardBrowserEnv:jd,hasStandardBrowserWebWorkerEnv:Sd,navigator:qs,origin:vd},Symbol.toStringTag,{value:"Module"})),nt={...wd,...bd};function _d(t,a){return Qn(t,new nt.classes.URLSearchParams,{visitor:function(s,r,o,l){return nt.isNode&&Z.isBuffer(s)?(this.append(r,s.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...a})}function Cd(t){return Z.matchAll(/\w+|\[(\w*)]/g,t).map(a=>a[0]==="[]"?"":a[1]||a[0])}function Ad(t){const a={},s=Object.keys(t);let r;const o=s.length;let l;for(r=0;r<o;r++)l=s[r],a[l]=t[l];return a}function Ao(t){function a(s,r,o,l){let d=s[l++];if(d==="__proto__")return!0;const c=Number.isFinite(+d),y=l>=s.length;return d=!d&&Z.isArray(o)?o.length:d,y?(Z.hasOwnProp(o,d)?o[d]=Z.isArray(o[d])?o[d].concat(r):[o[d],r]:o[d]=r,!c):((!o[d]||!Z.isObject(o[d]))&&(o[d]=[]),a(s,r,o[d],l)&&Z.isArray(o[d])&&(o[d]=Ad(o[d])),!c)}if(Z.isFormData(t)&&Z.isFunction(t.entries)){const s={};return Z.forEachEntry(t,(r,o)=>{a(Cd(r),o,s,0)}),s}return null}const ea=(t,a)=>t!=null&&Z.hasOwnProp(t,a)?t[a]:void 0;function Dd(t,a,s){if(Z.isString(t))try{return(a||JSON.parse)(t),Z.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(s||JSON.stringify)(t)}const Ga={transitional:Ks,adapter:["xhr","http","fetch"],transformRequest:[function(a,s){const r=s.getContentType()||"",o=r.indexOf("application/json")>-1,l=Z.isObject(a);if(l&&Z.isHTMLForm(a)&&(a=new FormData(a)),Z.isFormData(a))return o?JSON.stringify(Ao(a)):a;if(Z.isArrayBuffer(a)||Z.isBuffer(a)||Z.isStream(a)||Z.isFile(a)||Z.isBlob(a)||Z.isReadableStream(a))return a;if(Z.isArrayBufferView(a))return a.buffer;if(Z.isURLSearchParams(a))return s.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),a.toString();let c;if(l){const y=ea(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return _d(a,y).toString();if((c=Z.isFileList(a))||r.indexOf("multipart/form-data")>-1){const h=ea(this,"env"),u=h&&h.FormData;return Qn(c?{"files[]":a}:a,u&&new u,y)}}return l||o?(s.setContentType("application/json",!1),Dd(a)):a}],transformResponse:[function(a){const s=ea(this,"transitional")||Ga.transitional,r=s&&s.forcedJSONParsing,o=ea(this,"responseType"),l=o==="json";if(Z.isResponse(a)||Z.isReadableStream(a))return a;if(a&&Z.isString(a)&&(r&&!o||l)){const c=!(s&&s.silentJSONParsing)&&l;try{return JSON.parse(a,ea(this,"parseReviver"))}catch(y){if(c)throw y.name==="SyntaxError"?Ae.from(y,Ae.ERR_BAD_RESPONSE,this,null,ea(this,"response")):y}}return a}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:nt.classes.FormData,Blob:nt.classes.Blob},validateStatus:function(a){return a>=200&&a<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Z.forEach(["delete","get","head","post","put","patch"],t=>{Ga.headers[t]={}});const Td=Z.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Rd=t=>{const a={};let s,r,o;return t&&t.split(`
2
+ `).forEach(function(d){o=d.indexOf(":"),s=d.substring(0,o).trim().toLowerCase(),r=d.substring(o+1).trim(),!(!s||a[s]&&Td[s])&&(s==="set-cookie"?a[s]?a[s].push(r):a[s]=[r]:a[s]=a[s]?a[s]+", "+r:r)}),a},jr=Symbol("internals"),Id=/[^\x09\x20-\x7E\x80-\xFF]/g;function kd(t){let a=0,s=t.length;for(;a<s;){const r=t.charCodeAt(a);if(r!==9&&r!==32)break;a+=1}for(;s>a;){const r=t.charCodeAt(s-1);if(r!==9&&r!==32)break;s-=1}return a===0&&s===t.length?t:t.slice(a,s)}function wa(t){return t&&String(t).trim().toLowerCase()}function Pd(t){return kd(t.replace(Id,""))}function Rn(t){return t===!1||t==null?t:Z.isArray(t)?t.map(Rn):Pd(String(t))}function Od(t){const a=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=s.exec(t);)a[r[1]]=r[2];return a}const Md=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function us(t,a,s,r,o){if(Z.isFunction(r))return r.call(this,a,s);if(o&&(a=s),!!Z.isString(a)){if(Z.isString(r))return a.indexOf(r)!==-1;if(Z.isRegExp(r))return r.test(a)}}function Ed(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(a,s,r)=>s.toUpperCase()+r)}function Fd(t,a){const s=Z.toCamelCase(" "+a);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+s,{value:function(o,l,d){return this[r].call(this,a,o,l,d)},configurable:!0})})}let ut=class{constructor(a){a&&this.set(a)}set(a,s,r){const o=this;function l(c,y,h){const u=wa(y);if(!u)throw new Error("header name must be a non-empty string");const p=Z.findKey(o,u);(!p||o[p]===void 0||h===!0||h===void 0&&o[p]!==!1)&&(o[p||y]=Rn(c))}const d=(c,y)=>Z.forEach(c,(h,u)=>l(h,u,y));if(Z.isPlainObject(a)||a instanceof this.constructor)d(a,s);else if(Z.isString(a)&&(a=a.trim())&&!Md(a))d(Rd(a),s);else if(Z.isObject(a)&&Z.isIterable(a)){let c={},y,h;for(const u of a){if(!Z.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[h=u[0]]=(y=c[h])?Z.isArray(y)?[...y,u[1]]:[y,u[1]]:u[1]}d(c,s)}else a!=null&&l(s,a,r);return this}get(a,s){if(a=wa(a),a){const r=Z.findKey(this,a);if(r){const o=this[r];if(!s)return o;if(s===!0)return Od(o);if(Z.isFunction(s))return s.call(this,o,r);if(Z.isRegExp(s))return s.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(a,s){if(a=wa(a),a){const r=Z.findKey(this,a);return!!(r&&this[r]!==void 0&&(!s||us(this,this[r],r,s)))}return!1}delete(a,s){const r=this;let o=!1;function l(d){if(d=wa(d),d){const c=Z.findKey(r,d);c&&(!s||us(r,r[c],c,s))&&(delete r[c],o=!0)}}return Z.isArray(a)?a.forEach(l):l(a),o}clear(a){const s=Object.keys(this);let r=s.length,o=!1;for(;r--;){const l=s[r];(!a||us(this,this[l],l,a,!0))&&(delete this[l],o=!0)}return o}normalize(a){const s=this,r={};return Z.forEach(this,(o,l)=>{const d=Z.findKey(r,l);if(d){s[d]=Rn(o),delete s[l];return}const c=a?Ed(l):String(l).trim();c!==l&&delete s[l],s[c]=Rn(o),r[c]=!0}),this}concat(...a){return this.constructor.concat(this,...a)}toJSON(a){const s=Object.create(null);return Z.forEach(this,(r,o)=>{r!=null&&r!==!1&&(s[o]=a&&Z.isArray(r)?r.join(", "):r)}),s}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([a,s])=>a+": "+s).join(`
3
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(a){return a instanceof this?a:new this(a)}static concat(a,...s){const r=new this(a);return s.forEach(o=>r.set(o)),r}static accessor(a){const r=(this[jr]=this[jr]={accessors:{}}).accessors,o=this.prototype;function l(d){const c=wa(d);r[c]||(Fd(o,d),r[c]=!0)}return Z.isArray(a)?a.forEach(l):l(a),this}};ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Z.reduceDescriptors(ut.prototype,({value:t},a)=>{let s=a[0].toUpperCase()+a.slice(1);return{get:()=>t,set(r){this[s]=r}}});Z.freezeMethods(ut);function ps(t,a){const s=this||Ga,r=a||s,o=ut.from(r.headers);let l=r.data;return Z.forEach(t,function(c){l=c.call(s,l,o.normalize(),a?a.status:void 0)}),o.normalize(),l}function Do(t){return!!(t&&t.__CANCEL__)}let Ja=class extends Ae{constructor(a,s,r){super(a??"canceled",Ae.ERR_CANCELED,s,r),this.name="CanceledError",this.__CANCEL__=!0}};function To(t,a,s){const r=s.config.validateStatus;!s.status||!r||r(s.status)?t(s):a(new Ae("Request failed with status code "+s.status,[Ae.ERR_BAD_REQUEST,Ae.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function $d(t){const a=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return a&&a[1]||""}function Ud(t,a){t=t||10;const s=new Array(t),r=new Array(t);let o=0,l=0,d;return a=a!==void 0?a:1e3,function(y){const h=Date.now(),u=r[l];d||(d=h),s[o]=y,r[o]=h;let p=l,w=0;for(;p!==o;)w+=s[p++],p=p%t;if(o=(o+1)%t,o===l&&(l=(l+1)%t),h-d<a)return;const v=u&&h-u;return v?Math.round(w*1e3/v):void 0}}function Nd(t,a){let s=0,r=1e3/a,o,l;const d=(h,u=Date.now())=>{s=u,o=null,l&&(clearTimeout(l),l=null),t(...h)};return[(...h)=>{const u=Date.now(),p=u-s;p>=r?d(h,u):(o=h,l||(l=setTimeout(()=>{l=null,d(o)},r-p)))},()=>o&&d(o)]}const Vn=(t,a,s=3)=>{let r=0;const o=Ud(50,250);return Nd(l=>{const d=l.loaded,c=l.lengthComputable?l.total:void 0,y=c!=null?Math.min(d,c):d,h=Math.max(0,y-r),u=o(h);r=Math.max(r,y);const p={loaded:y,total:c,progress:c?y/c:void 0,bytes:h,rate:u||void 0,estimated:u&&c?(c-y)/u:void 0,event:l,lengthComputable:c!=null,[a?"download":"upload"]:!0};t(p)},s)},Sr=(t,a)=>{const s=t!=null;return[r=>a[0]({lengthComputable:s,total:t,loaded:r}),a[1]]},vr=t=>(...a)=>Z.asap(()=>t(...a)),Ld=nt.hasStandardBrowserEnv?((t,a)=>s=>(s=new URL(s,nt.origin),t.protocol===s.protocol&&t.host===s.host&&(a||t.port===s.port)))(new URL(nt.origin),nt.navigator&&/(msie|trident)/i.test(nt.navigator.userAgent)):()=>!0,Bd=nt.hasStandardBrowserEnv?{write(t,a,s,r,o,l,d){if(typeof document>"u")return;const c=[`${t}=${encodeURIComponent(a)}`];Z.isNumber(s)&&c.push(`expires=${new Date(s).toUTCString()}`),Z.isString(r)&&c.push(`path=${r}`),Z.isString(o)&&c.push(`domain=${o}`),l===!0&&c.push("secure"),Z.isString(d)&&c.push(`SameSite=${d}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;const a=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return a?decodeURIComponent(a[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function qd(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function zd(t,a){return a?t.replace(/\/?\/$/,"")+"/"+a.replace(/^\/+/,""):t}function Ro(t,a,s){let r=!qd(a);return t&&(r||s===!1)?zd(t,a):a}const wr=t=>t instanceof ut?{...t}:t;function Qt(t,a){a=a||{};const s=Object.create(null);Object.defineProperty(s,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(h,u,p,w){return Z.isPlainObject(h)&&Z.isPlainObject(u)?Z.merge.call({caseless:w},h,u):Z.isPlainObject(u)?Z.merge({},u):Z.isArray(u)?u.slice():u}function o(h,u,p,w){if(Z.isUndefined(u)){if(!Z.isUndefined(h))return r(void 0,h,p,w)}else return r(h,u,p,w)}function l(h,u){if(!Z.isUndefined(u))return r(void 0,u)}function d(h,u){if(Z.isUndefined(u)){if(!Z.isUndefined(h))return r(void 0,h)}else return r(void 0,u)}function c(h,u,p){if(Z.hasOwnProp(a,p))return r(h,u);if(Z.hasOwnProp(t,p))return r(void 0,h)}const y={url:l,method:l,data:l,baseURL:d,transformRequest:d,transformResponse:d,paramsSerializer:d,timeout:d,timeoutMessage:d,withCredentials:d,withXSRFToken:d,adapter:d,responseType:d,xsrfCookieName:d,xsrfHeaderName:d,onUploadProgress:d,onDownloadProgress:d,decompress:d,maxContentLength:d,maxBodyLength:d,beforeRedirect:d,transport:d,httpAgent:d,httpsAgent:d,cancelToken:d,socketPath:d,allowedSocketPaths:d,responseEncoding:d,validateStatus:c,headers:(h,u,p)=>o(wr(h),wr(u),p,!0)};return Z.forEach(Object.keys({...t,...a}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const p=Z.hasOwnProp(y,u)?y[u]:o,w=Z.hasOwnProp(t,u)?t[u]:void 0,v=Z.hasOwnProp(a,u)?a[u]:void 0,b=p(w,v,u);Z.isUndefined(b)&&p!==c||(s[u]=b)}),s}const Io=t=>{const a=Qt({},t),s=w=>Z.hasOwnProp(a,w)?a[w]:void 0,r=s("data");let o=s("withXSRFToken");const l=s("xsrfHeaderName"),d=s("xsrfCookieName");let c=s("headers");const y=s("auth"),h=s("baseURL"),u=s("allowAbsoluteUrls"),p=s("url");if(a.headers=c=ut.from(c),a.url=Co(Ro(h,p,u),t.params,t.paramsSerializer),y&&c.set("Authorization","Basic "+btoa((y.username||"")+":"+(y.password?unescape(encodeURIComponent(y.password)):""))),Z.isFormData(r)){if(nt.hasStandardBrowserEnv||nt.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(Z.isFunction(r.getHeaders)){const w=r.getHeaders(),v=["content-type","content-length"];Object.entries(w).forEach(([b,m])=>{v.includes(b.toLowerCase())&&c.set(b,m)})}}if(nt.hasStandardBrowserEnv&&(Z.isFunction(o)&&(o=o(a)),o===!0||o==null&&Ld(a.url))){const v=l&&d&&Bd.read(d);v&&c.set(l,v)}return a},Yd=typeof XMLHttpRequest<"u",Vd=Yd&&function(t){return new Promise(function(s,r){const o=Io(t);let l=o.data;const d=ut.from(o.headers).normalize();let{responseType:c,onUploadProgress:y,onDownloadProgress:h}=o,u,p,w,v,b;function m(){v&&v(),b&&b(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let j=new XMLHttpRequest;j.open(o.method.toUpperCase(),o.url,!0),j.timeout=o.timeout;function D(){if(!j)return;const k=ut.from("getAllResponseHeaders"in j&&j.getAllResponseHeaders()),x={data:!c||c==="text"||c==="json"?j.responseText:j.response,status:j.status,statusText:j.statusText,headers:k,config:t,request:j};To(function(C){s(C),m()},function(C){r(C),m()},x),j=null}"onloadend"in j?j.onloadend=D:j.onreadystatechange=function(){!j||j.readyState!==4||j.status===0&&!(j.responseURL&&j.responseURL.indexOf("file:")===0)||setTimeout(D)},j.onabort=function(){j&&(r(new Ae("Request aborted",Ae.ECONNABORTED,t,j)),j=null)},j.onerror=function(S){const x=S&&S.message?S.message:"Network Error",g=new Ae(x,Ae.ERR_NETWORK,t,j);g.event=S||null,r(g),j=null},j.ontimeout=function(){let S=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const x=o.transitional||Ks;o.timeoutErrorMessage&&(S=o.timeoutErrorMessage),r(new Ae(S,x.clarifyTimeoutError?Ae.ETIMEDOUT:Ae.ECONNABORTED,t,j)),j=null},l===void 0&&d.setContentType(null),"setRequestHeader"in j&&Z.forEach(d.toJSON(),function(S,x){j.setRequestHeader(x,S)}),Z.isUndefined(o.withCredentials)||(j.withCredentials=!!o.withCredentials),c&&c!=="json"&&(j.responseType=o.responseType),h&&([w,b]=Vn(h,!0),j.addEventListener("progress",w)),y&&j.upload&&([p,v]=Vn(y),j.upload.addEventListener("progress",p),j.upload.addEventListener("loadend",v)),(o.cancelToken||o.signal)&&(u=k=>{j&&(r(!k||k.type?new Ja(null,t,j):k),j.abort(),j=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const I=$d(o.url);if(I&&nt.protocols.indexOf(I)===-1){r(new Ae("Unsupported protocol "+I+":",Ae.ERR_BAD_REQUEST,t));return}j.send(l||null)})},Wd=(t,a)=>{const{length:s}=t=t?t.filter(Boolean):[];if(a||s){let r=new AbortController,o;const l=function(h){if(!o){o=!0,c();const u=h instanceof Error?h:this.reason;r.abort(u instanceof Ae?u:new Ja(u instanceof Error?u.message:u))}};let d=a&&setTimeout(()=>{d=null,l(new Ae(`timeout of ${a}ms exceeded`,Ae.ETIMEDOUT))},a);const c=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(h=>{h.unsubscribe?h.unsubscribe(l):h.removeEventListener("abort",l)}),t=null)};t.forEach(h=>h.addEventListener("abort",l));const{signal:y}=r;return y.unsubscribe=()=>Z.asap(c),y}},Hd=function*(t,a){let s=t.byteLength;if(s<a){yield t;return}let r=0,o;for(;r<s;)o=r+a,yield t.slice(r,o),r=o},Kd=async function*(t,a){for await(const s of Gd(t))yield*Hd(s,a)},Gd=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const a=t.getReader();try{for(;;){const{done:s,value:r}=await a.read();if(s)break;yield r}}finally{await a.cancel()}},_r=(t,a,s,r)=>{const o=Kd(t,a);let l=0,d,c=y=>{d||(d=!0,r&&r(y))};return new ReadableStream({async pull(y){try{const{done:h,value:u}=await o.next();if(h){c(),y.close();return}let p=u.byteLength;if(s){let w=l+=p;s(w)}y.enqueue(new Uint8Array(u))}catch(h){throw c(h),h}},cancel(y){return c(y),o.return()}},{highWaterMark:2})},Cr=64*1024,{isFunction:cn}=Z,Jd=(({Request:t,Response:a})=>({Request:t,Response:a}))(Z.global),{ReadableStream:Ar,TextEncoder:Dr}=Z.global,Tr=(t,...a)=>{try{return!!t(...a)}catch{return!1}},Qd=t=>{t=Z.merge.call({skipUndefined:!0},Jd,t);const{fetch:a,Request:s,Response:r}=t,o=a?cn(a):typeof fetch=="function",l=cn(s),d=cn(r);if(!o)return!1;const c=o&&cn(Ar),y=o&&(typeof Dr=="function"?(b=>m=>b.encode(m))(new Dr):async b=>new Uint8Array(await new s(b).arrayBuffer())),h=l&&c&&Tr(()=>{let b=!1;const m=new s(nt.origin,{body:new Ar,method:"POST",get duplex(){return b=!0,"half"}}),j=m.headers.has("Content-Type");return m.body!=null&&m.body.cancel(),b&&!j}),u=d&&c&&Tr(()=>Z.isReadableStream(new r("").body)),p={stream:u&&(b=>b.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(b=>{!p[b]&&(p[b]=(m,j)=>{let D=m&&m[b];if(D)return D.call(m);throw new Ae(`Response type '${b}' is not supported`,Ae.ERR_NOT_SUPPORT,j)})});const w=async b=>{if(b==null)return 0;if(Z.isBlob(b))return b.size;if(Z.isSpecCompliantForm(b))return(await new s(nt.origin,{method:"POST",body:b}).arrayBuffer()).byteLength;if(Z.isArrayBufferView(b)||Z.isArrayBuffer(b))return b.byteLength;if(Z.isURLSearchParams(b)&&(b=b+""),Z.isString(b))return(await y(b)).byteLength},v=async(b,m)=>{const j=Z.toFiniteNumber(b.getContentLength());return j??w(m)};return async b=>{let{url:m,method:j,data:D,signal:I,cancelToken:k,timeout:S,onDownloadProgress:x,onUploadProgress:g,responseType:C,headers:T,withCredentials:R="same-origin",fetchOptions:L}=Io(b),N=a||fetch;C=C?(C+"").toLowerCase():"text";let f=Wd([I,k&&k.toAbortSignal()],S),P=null;const O=f&&f.unsubscribe&&(()=>{f.unsubscribe()});let $;try{if(g&&h&&j!=="get"&&j!=="head"&&($=await v(T,D))!==0){let M=new s(m,{method:"POST",body:D,duplex:"half"}),B;if(Z.isFormData(D)&&(B=M.headers.get("content-type"))&&T.setContentType(B),M.body){const[z,G]=Sr($,Vn(vr(g)));D=_r(M.body,Cr,z,G)}}Z.isString(R)||(R=R?"include":"omit");const F=l&&"credentials"in s.prototype;if(Z.isFormData(D)){const M=T.getContentType();M&&/^multipart\/form-data/i.test(M)&&!/boundary=/i.test(M)&&T.delete("content-type")}const U={...L,signal:f,method:j.toUpperCase(),headers:T.normalize().toJSON(),body:D,duplex:"half",credentials:F?R:void 0};P=l&&new s(m,U);let V=await(l?N(P,L):N(m,U));const q=u&&(C==="stream"||C==="response");if(u&&(x||q&&O)){const M={};["status","statusText","headers"].forEach(re=>{M[re]=V[re]});const B=Z.toFiniteNumber(V.headers.get("content-length")),[z,G]=x&&Sr(B,Vn(vr(x),!0))||[];V=new r(_r(V.body,Cr,z,()=>{G&&G(),O&&O()}),M)}C=C||"text";let E=await p[Z.findKey(p,C)||"text"](V,b);return!q&&O&&O(),await new Promise((M,B)=>{To(M,B,{data:E,headers:ut.from(V.headers),status:V.status,statusText:V.statusText,config:b,request:P})})}catch(F){throw O&&O(),F&&F.name==="TypeError"&&/Load failed|fetch/i.test(F.message)?Object.assign(new Ae("Network Error",Ae.ERR_NETWORK,b,P,F&&F.response),{cause:F.cause||F}):Ae.from(F,F&&F.code,b,P,F&&F.response)}}},Xd=new Map,ko=t=>{let a=t&&t.env||{};const{fetch:s,Request:r,Response:o}=a,l=[r,o,s];let d=l.length,c=d,y,h,u=Xd;for(;c--;)y=l[c],h=u.get(y),h===void 0&&u.set(y,h=c?new Map:Qd(a)),u=h;return h};ko();const Js={http:pd,xhr:Vd,fetch:{get:ko}};Z.forEach(Js,(t,a)=>{if(t){try{Object.defineProperty(t,"name",{value:a})}catch{}Object.defineProperty(t,"adapterName",{value:a})}});const Rr=t=>`- ${t}`,Zd=t=>Z.isFunction(t)||t===null||t===!1;function ec(t,a){t=Z.isArray(t)?t:[t];const{length:s}=t;let r,o;const l={};for(let d=0;d<s;d++){r=t[d];let c;if(o=r,!Zd(r)&&(o=Js[(c=String(r)).toLowerCase()],o===void 0))throw new Ae(`Unknown adapter '${c}'`);if(o&&(Z.isFunction(o)||(o=o.get(a))))break;l[c||"#"+d]=o}if(!o){const d=Object.entries(l).map(([y,h])=>`adapter ${y} `+(h===!1?"is not supported by the environment":"is not available in the build"));let c=s?d.length>1?`since :
4
+ `+d.map(Rr).join(`
5
+ `):" "+Rr(d[0]):"as no adapter specified";throw new Ae("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return o}const Po={getAdapter:ec,adapters:Js};function ms(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Ja(null,t)}function Ir(t){return ms(t),t.headers=ut.from(t.headers),t.data=ps.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Po.getAdapter(t.adapter||Ga.adapter,t)(t).then(function(r){return ms(t),r.data=ps.call(t,t.transformResponse,r),r.headers=ut.from(r.headers),r},function(r){return Do(r)||(ms(t),r&&r.response&&(r.response.data=ps.call(t,t.transformResponse,r.response),r.response.headers=ut.from(r.response.headers))),Promise.reject(r)})}const Oo="1.15.2",Xn={};["object","boolean","number","function","string","symbol"].forEach((t,a)=>{Xn[t]=function(r){return typeof r===t||"a"+(a<1?"n ":" ")+t}});const kr={};Xn.transitional=function(a,s,r){function o(l,d){return"[Axios v"+Oo+"] Transitional option '"+l+"'"+d+(r?". "+r:"")}return(l,d,c)=>{if(a===!1)throw new Ae(o(d," has been removed"+(s?" in "+s:"")),Ae.ERR_DEPRECATED);return s&&!kr[d]&&(kr[d]=!0,console.warn(o(d," has been deprecated since v"+s+" and will be removed in the near future"))),a?a(l,d,c):!0}};Xn.spelling=function(a){return(s,r)=>(console.warn(`${r} is likely a misspelling of ${a}`),!0)};function tc(t,a,s){if(typeof t!="object")throw new Ae("options must be an object",Ae.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let o=r.length;for(;o-- >0;){const l=r[o],d=Object.prototype.hasOwnProperty.call(a,l)?a[l]:void 0;if(d){const c=t[l],y=c===void 0||d(c,l,t);if(y!==!0)throw new Ae("option "+l+" must be "+y,Ae.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new Ae("Unknown option "+l,Ae.ERR_BAD_OPTION)}}const In={assertOptions:tc,validators:Xn},bt=In.validators;let Kt=class{constructor(a){this.defaults=a||{},this.interceptors={request:new br,response:new br}}async request(a,s){try{return await this._request(a,s)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const l=(()=>{if(!o.stack)return"";const d=o.stack.indexOf(`
6
6
  `);return d===-1?"":o.stack.slice(d+1)})();try{if(!r.stack)r.stack=l;else if(l){const d=l.indexOf(`
7
7
  `),c=d===-1?-1:l.indexOf(`
8
- `,d+1),g=c===-1?"":l.slice(c+1);String(r.stack).endsWith(g)||(r.stack+=`
9
- `+l)}}catch{}}throw r}}_request(a,s){typeof a=="string"?(s=s||{},s.url=a):s=a||{},s=Gt(this.defaults,s);const{transitional:r,paramsSerializer:o,headers:l}=s;r!==void 0&&Dn.assertOptions(r,{silentJSONParsing:ht.transitional(ht.boolean),forcedJSONParsing:ht.transitional(ht.boolean),clarifyTimeoutError:ht.transitional(ht.boolean),legacyInterceptorReqResOrdering:ht.transitional(ht.boolean)},!1),o!=null&&(J.isFunction(o)?s.paramsSerializer={serialize:o}:Dn.assertOptions(o,{encode:ht.function,serialize:ht.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),Dn.assertOptions(s,{baseUrl:ht.spelling("baseURL"),withXsrfToken:ht.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let d=l&&J.merge(l.common,l[s.method]);l&&J.forEach(["delete","get","head","post","put","patch","common"],h=>{delete l[h]}),s.headers=lt.concat(d,l);const c=[];let g=!0;this.interceptors.request.forEach(function(m){if(typeof m.runWhen=="function"&&m.runWhen(s)===!1)return;g=g&&m.synchronous;const x=s.transitional||Vs;x&&x.legacyInterceptorReqResOrdering?c.unshift(m.fulfilled,m.rejected):c.push(m.fulfilled,m.rejected)});const f=[];this.interceptors.response.forEach(function(m){f.push(m.fulfilled,m.rejected)});let u,p=0,_;if(!g){const h=[Cr.bind(this),void 0];for(h.unshift(...c),h.push(...f),_=h.length,u=Promise.resolve(s);p<_;)u=u.then(h[p++],h[p++]);return u}_=c.length;let v=s;for(;p<_;){const h=c[p++],m=c[p++];try{v=h(v)}catch(x){m.call(this,x);break}}try{u=Cr.call(this,v)}catch(h){return Promise.reject(h)}for(p=0,_=f.length;p<_;)u=u.then(f[p++],f[p++]);return u}getUri(a){a=Gt(this.defaults,a);const s=go(a.baseURL,a.url,a.allowAbsoluteUrls);return mo(s,a.params,a.paramsSerializer)}};J.forEach(["delete","get","head","options"],function(a){Wt.prototype[a]=function(s,r){return this.request(Gt(r||{},{method:a,url:s,data:(r||{}).data}))}});J.forEach(["post","put","patch"],function(a){function s(r){return function(l,d,c){return this.request(Gt(c||{},{method:a,headers:r?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}Wt.prototype[a]=s(),Wt.prototype[a+"Form"]=s(!0)});let $d=class vo{constructor(a){if(typeof a!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(l){s=l});const r=this;this.promise.then(o=>{if(!r._listeners)return;let l=r._listeners.length;for(;l-- >0;)r._listeners[l](o);r._listeners=null}),this.promise.then=o=>{let l;const d=new Promise(c=>{r.subscribe(c),l=c}).then(o);return d.cancel=function(){r.unsubscribe(l)},d},a(function(l,d,c){r.reason||(r.reason=new Ga(l,d,c),s(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(a){if(this.reason){a(this.reason);return}this._listeners?this._listeners.push(a):this._listeners=[a]}unsubscribe(a){if(!this._listeners)return;const s=this._listeners.indexOf(a);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const a=new AbortController,s=r=>{a.abort(r)};return this.subscribe(s),a.signal.unsubscribe=()=>this.unsubscribe(s),a.signal}static source(){let a;return{token:new vo(function(o){a=o}),cancel:a}}};function Ud(t){return function(s){return t.apply(null,s)}}function Nd(t){return J.isObject(t)&&t.isAxiosError===!0}const Bs={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Bs).forEach(([t,a])=>{Bs[a]=t});function _o(t){const a=new Wt(t),s=to(Wt.prototype.request,a);return J.extend(s,Wt.prototype,a,{allOwnKeys:!0}),J.extend(s,a,null,{allOwnKeys:!0}),s.create=function(o){return _o(Gt(t,o))},s}const Ne=_o(Ka);Ne.Axios=Wt;Ne.CanceledError=Ga;Ne.CancelToken=$d;Ne.isCancel=yo;Ne.VERSION=So;Ne.toFormData=Jn;Ne.AxiosError=ve;Ne.Cancel=Ne.CanceledError;Ne.all=function(a){return Promise.all(a)};Ne.spread=Ud;Ne.isAxiosError=Nd;Ne.mergeConfig=Gt;Ne.AxiosHeaders=lt;Ne.formToJSON=t=>fo(J.isHTMLForm(t)?new FormData(t):t);Ne.getAdapter=jo.getAdapter;Ne.HttpStatusCode=Bs;Ne.default=Ne;const{Axios:gg,AxiosError:xg,CanceledError:bg,isCancel:jg,CancelToken:Sg,VERSION:vg,all:_g,Cancel:wg,isAxiosError:Cg,spread:Ag,toFormData:Tg,AxiosHeaders:Rg,HttpStatusCode:Dg,formToJSON:Ig,getAdapter:kg,mergeConfig:Pg}=Ne,Ld=()=>new Promise(t=>setTimeout(()=>t(),800));let qs=null;const Bd=t=>{qs=t,vt.defaults.baseURL=Ks()},Ks=()=>qs||"https://npmapi.ubkerp.com/",vt=Ne.create({baseURL:Ks()}),et=()=>Ks(),$e=async(t,a,s)=>{const r=await vt.post(t,a,{headers:{Authorization:s}});if(console.log("ddddfdfdfd",r.data?.Status),r.data?.Status=="Success")return r?.data?.data||r?.data;throw new Error(r.data?.msg)},X=async(t,a)=>{try{let r=t;if(!t.includes("session_id")){const l=t.includes("?")?"&":"?";r=`${t}${l}session_id=1`}return(await vt.get(r,{headers:{Authorization:a}})).data}catch(s){throw s.response?.status===401&&console.error("401 Unauthorized"),s}},qd=async(t,a)=>{const s=await vt.post(t,"",{headers:{Authorization:a}});if(s.data?.Status=="Success")return s?.data?.data||s?.data;throw new Error(s.data?.msg)},Xn=async(t,a,s)=>{try{const r=await vt.post(t,a,{headers:{Authorization:s,"Content-Type":"application/json"}});return r.data?.Status==="Success"?r.data:(w.error(r.data?.msg||"Unable to issue library book",{duration:2e3}),!1)}catch(r){throw w.error(r.response?.data?.msg||r.response?.data?.message||"Request failed",{duration:2e3}),r}},qa=async(t,a,s)=>{const r=a?.arg;return(await vt.post(t,r,{headers:{Authorization:s}}))?.data},Ht=async(t,a,s)=>{const r=a?.arg,o=t.includes("?")?"&":"?";return(await vt.get(t+o,{params:r,headers:{Authorization:s}}))?.data},zd="api/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",Gs=async(t,a,s)=>{const r=a?.arg,o=t.includes("?")?"&":"?",l=await vt.get(t+o,{params:r,headers:{Authorization:s}});if(console.log("ddddfdfdfd",l.data?.Status),l.data?.Status=="Success")return l?.data?.data||l?.data;throw new Error(l.data?.msg)},Xe=async(t,a,s)=>(await Ld(),(await vt.post(t,a,{headers:{Authorization:s}}))?.data),Ja=async(t,a,s)=>(await vt.post(t,a,{headers:{Authorization:s}})).data,Ye=async(t,a,s)=>(await vt.delete(`${t}/${a}`,{headers:{Authorization:s}})).data,Yd="api/report/LibraryRenewalReport/renewalHistory",Vd="api/report/LibraryRenewalReport/renewalFineReport",Wd="api/report/LibraryRenewalReport/currentlyRenewedBooks",Hd="api/report/LibraryRenewalReport/upcomingRenewalDue",Kd="api/report/LibraryRenewalReport/overdueRenewalReport",Gd="api/report/LibraryRenewalReport/renewalLimitReport",Jd="api/report/LibraryRenewalReport/renewalStatusReport",Qd="api/report/LibraryRenewalReport/studentWiseReport",Xd="api/report/LibraryRenewalReport/bookWiseReport",Zd="api/report/LibraryRenewalReport/classWiseReport",ec="api/report/LibraryRenewalReport/staffWiseReport",tc="api/report/LibraryRenewalReport/renewalStatisticsByDate",ac="/sample_templates/route_upload.xlsx",nc="/sample_templates/student_transport_upload.xlsx",sc=({token:t,menu:a})=>{const{isLoading:s,data:r}=H(t?["api/sdk/Menus",t]:null,([l,d])=>qd(l,d)),o=r?.find(l=>l.path===a)?.sub_menu??[];return console.log("menuData",r),e.jsx(n.Row,{gutter:[16,16],children:o?.map((l,d)=>l.dashboard_show==="YES"?e.jsx(n.Col,{xs:24,md:8,lg:8,children:e.jsx(F,{children:e.jsx(eo,{icon:`${et()}icons/frontoffice/${l.icons}`,title:l.submenu_name,path:l.menu_key})})},`${d}office001`):null)})};function wo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Je={},ms,Tr;function rc(){return Tr||(Tr=1,ms=function t(a,s){if(a===s)return!0;if(a&&s&&typeof a=="object"&&typeof s=="object"){if(a.constructor!==s.constructor)return!1;var r,o,l;if(Array.isArray(a)){if(r=a.length,r!=s.length)return!1;for(o=r;o--!==0;)if(!t(a[o],s[o]))return!1;return!0}if(a.constructor===RegExp)return a.source===s.source&&a.flags===s.flags;if(a.valueOf!==Object.prototype.valueOf)return a.valueOf()===s.valueOf();if(a.toString!==Object.prototype.toString)return a.toString()===s.toString();if(l=Object.keys(a),r=l.length,r!==Object.keys(s).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(s,l[o]))return!1;for(o=r;o--!==0;){var d=l[o];if(!t(a[d],s[d]))return!1}return!0}return a!==a&&s!==s}),ms}var cn={exports:{}},un={exports:{}},De={};var Rr;function ic(){if(Rr)return De;Rr=1;var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,r=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,g=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,p=t?Symbol.for("react.suspense"):60113,_=t?Symbol.for("react.suspense_list"):60120,v=t?Symbol.for("react.memo"):60115,h=t?Symbol.for("react.lazy"):60116,m=t?Symbol.for("react.block"):60121,x=t?Symbol.for("react.fundamental"):60117,T=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function k(b){if(typeof b=="object"&&b!==null){var y=b.$$typeof;switch(y){case a:switch(b=b.type,b){case g:case f:case r:case l:case o:case p:return b;default:switch(b=b&&b.$$typeof,b){case c:case u:case h:case v:case d:return b;default:return y}}case s:return y}}}function C(b){return k(b)===f}return De.AsyncMode=g,De.ConcurrentMode=f,De.ContextConsumer=c,De.ContextProvider=d,De.Element=a,De.ForwardRef=u,De.Fragment=r,De.Lazy=h,De.Memo=v,De.Portal=s,De.Profiler=l,De.StrictMode=o,De.Suspense=p,De.isAsyncMode=function(b){return C(b)||k(b)===g},De.isConcurrentMode=C,De.isContextConsumer=function(b){return k(b)===c},De.isContextProvider=function(b){return k(b)===d},De.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===a},De.isForwardRef=function(b){return k(b)===u},De.isFragment=function(b){return k(b)===r},De.isLazy=function(b){return k(b)===h},De.isMemo=function(b){return k(b)===v},De.isPortal=function(b){return k(b)===s},De.isProfiler=function(b){return k(b)===l},De.isStrictMode=function(b){return k(b)===o},De.isSuspense=function(b){return k(b)===p},De.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===r||b===f||b===l||b===o||b===p||b===_||typeof b=="object"&&b!==null&&(b.$$typeof===h||b.$$typeof===v||b.$$typeof===d||b.$$typeof===c||b.$$typeof===u||b.$$typeof===x||b.$$typeof===T||b.$$typeof===I||b.$$typeof===m)},De.typeOf=k,De}var Ie={};var Dr;function oc(){return Dr||(Dr=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,r=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,g=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,p=t?Symbol.for("react.suspense"):60113,_=t?Symbol.for("react.suspense_list"):60120,v=t?Symbol.for("react.memo"):60115,h=t?Symbol.for("react.lazy"):60116,m=t?Symbol.for("react.block"):60121,x=t?Symbol.for("react.fundamental"):60117,T=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function k(oe){return typeof oe=="string"||typeof oe=="function"||oe===r||oe===f||oe===l||oe===o||oe===p||oe===_||typeof oe=="object"&&oe!==null&&(oe.$$typeof===h||oe.$$typeof===v||oe.$$typeof===d||oe.$$typeof===c||oe.$$typeof===u||oe.$$typeof===x||oe.$$typeof===T||oe.$$typeof===I||oe.$$typeof===m)}function C(oe){if(typeof oe=="object"&&oe!==null){var le=oe.$$typeof;switch(le){case a:var G=oe.type;switch(G){case g:case f:case r:case l:case o:case p:return G;default:var de=G&&G.$$typeof;switch(de){case c:case u:case h:case v:case d:return de;default:return le}}case s:return le}}}var b=g,y=f,S=c,A=d,R=a,z=u,U=r,j=h,O=v,M=s,$=l,E=o,N=p,V=!1;function q(oe){return V||(V=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),P(oe)||C(oe)===g}function P(oe){return C(oe)===f}function D(oe){return C(oe)===c}function L(oe){return C(oe)===d}function B(oe){return typeof oe=="object"&&oe!==null&&oe.$$typeof===a}function W(oe){return C(oe)===u}function se(oe){return C(oe)===r}function Q(oe){return C(oe)===h}function K(oe){return C(oe)===v}function te(oe){return C(oe)===s}function ie(oe){return C(oe)===l}function pe(oe){return C(oe)===o}function _e(oe){return C(oe)===p}Ie.AsyncMode=b,Ie.ConcurrentMode=y,Ie.ContextConsumer=S,Ie.ContextProvider=A,Ie.Element=R,Ie.ForwardRef=z,Ie.Fragment=U,Ie.Lazy=j,Ie.Memo=O,Ie.Portal=M,Ie.Profiler=$,Ie.StrictMode=E,Ie.Suspense=N,Ie.isAsyncMode=q,Ie.isConcurrentMode=P,Ie.isContextConsumer=D,Ie.isContextProvider=L,Ie.isElement=B,Ie.isForwardRef=W,Ie.isFragment=se,Ie.isLazy=Q,Ie.isMemo=K,Ie.isPortal=te,Ie.isProfiler=ie,Ie.isStrictMode=pe,Ie.isSuspense=_e,Ie.isValidElementType=k,Ie.typeOf=C})()),Ie}var Ir;function Co(){return Ir||(Ir=1,process.env.NODE_ENV==="production"?un.exports=ic():un.exports=oc()),un.exports}var fs,kr;function lc(){if(kr)return fs;kr=1;var t=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function r(l){if(l==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(l)}function o(){try{if(!Object.assign)return!1;var l=new String("abc");if(l[5]="de",Object.getOwnPropertyNames(l)[0]==="5")return!1;for(var d={},c=0;c<10;c++)d["_"+String.fromCharCode(c)]=c;var g=Object.getOwnPropertyNames(d).map(function(u){return d[u]});if(g.join("")!=="0123456789")return!1;var f={};return"abcdefghijklmnopqrst".split("").forEach(function(u){f[u]=u}),Object.keys(Object.assign({},f)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return fs=o()?Object.assign:function(l,d){for(var c,g=r(l),f,u=1;u<arguments.length;u++){c=Object(arguments[u]);for(var p in c)a.call(c,p)&&(g[p]=c[p]);if(t){f=t(c);for(var _=0;_<f.length;_++)s.call(c,f[_])&&(g[f[_]]=c[f[_]])}}return g},fs}var ys,Pr;function Js(){if(Pr)return ys;Pr=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ys=t,ys}var hs,Or;function Ao(){return Or||(Or=1,hs=Function.call.bind(Object.prototype.hasOwnProperty)),hs}var gs,Mr;function dc(){if(Mr)return gs;Mr=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var a=Js(),s={},r=Ao();t=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function o(l,d,c,g,f){if(process.env.NODE_ENV!=="production"){for(var u in l)if(r(l,u)){var p;try{if(typeof l[u]!="function"){var _=Error((g||"React class")+": "+c+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw _.name="Invariant Violation",_}p=l[u](d,u,g,c,null,a)}catch(h){p=h}if(p&&!(p instanceof Error)&&t((g||"React class")+": type specification of "+c+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof p+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),p instanceof Error&&!(p.message in s)){s[p.message]=!0;var v=f?f():"";t("Failed "+c+" type: "+p.message+(v??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(s={})},gs=o,gs}var xs,Er;function cc(){if(Er)return xs;Er=1;var t=Co(),a=lc(),s=Js(),r=Ao(),o=dc(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(c){var g="Warning: "+c;typeof console<"u"&&console.error(g);try{throw new Error(g)}catch{}});function d(){return null}return xs=function(c,g){var f=typeof Symbol=="function"&&Symbol.iterator,u="@@iterator";function p(P){var D=P&&(f&&P[f]||P[u]);if(typeof D=="function")return D}var _="<<anonymous>>",v={array:T("array"),bigint:T("bigint"),bool:T("boolean"),func:T("function"),number:T("number"),object:T("object"),string:T("string"),symbol:T("symbol"),any:I(),arrayOf:k,element:C(),elementType:b(),instanceOf:y,node:z(),objectOf:A,oneOf:S,oneOfType:R,shape:j,exact:O};function h(P,D){return P===D?P!==0||1/P===1/D:P!==P&&D!==D}function m(P,D){this.message=P,this.data=D&&typeof D=="object"?D:{},this.stack=""}m.prototype=Error.prototype;function x(P){if(process.env.NODE_ENV!=="production")var D={},L=0;function B(se,Q,K,te,ie,pe,_e){if(te=te||_,pe=pe||K,_e!==s){if(g){var oe=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw oe.name="Invariant Violation",oe}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var le=te+":"+K;!D[le]&&L<3&&(l("You are manually calling a React.PropTypes validation function for the `"+pe+"` prop on `"+te+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),D[le]=!0,L++)}}return Q[K]==null?se?Q[K]===null?new m("The "+ie+" `"+pe+"` is marked as required "+("in `"+te+"`, but its value is `null`.")):new m("The "+ie+" `"+pe+"` is marked as required in "+("`"+te+"`, but its value is `undefined`.")):null:P(Q,K,te,ie,pe)}var W=B.bind(null,!1);return W.isRequired=B.bind(null,!0),W}function T(P){function D(L,B,W,se,Q,K){var te=L[B],ie=E(te);if(ie!==P){var pe=N(te);return new m("Invalid "+se+" `"+Q+"` of type "+("`"+pe+"` supplied to `"+W+"`, expected ")+("`"+P+"`."),{expectedType:P})}return null}return x(D)}function I(){return x(d)}function k(P){function D(L,B,W,se,Q){if(typeof P!="function")return new m("Property `"+Q+"` of component `"+W+"` has invalid PropType notation inside arrayOf.");var K=L[B];if(!Array.isArray(K)){var te=E(K);return new m("Invalid "+se+" `"+Q+"` of type "+("`"+te+"` supplied to `"+W+"`, expected an array."))}for(var ie=0;ie<K.length;ie++){var pe=P(K,ie,W,se,Q+"["+ie+"]",s);if(pe instanceof Error)return pe}return null}return x(D)}function C(){function P(D,L,B,W,se){var Q=D[L];if(!c(Q)){var K=E(Q);return new m("Invalid "+W+" `"+se+"` of type "+("`"+K+"` supplied to `"+B+"`, expected a single ReactElement."))}return null}return x(P)}function b(){function P(D,L,B,W,se){var Q=D[L];if(!t.isValidElementType(Q)){var K=E(Q);return new m("Invalid "+W+" `"+se+"` of type "+("`"+K+"` supplied to `"+B+"`, expected a single ReactElement type."))}return null}return x(P)}function y(P){function D(L,B,W,se,Q){if(!(L[B]instanceof P)){var K=P.name||_,te=q(L[B]);return new m("Invalid "+se+" `"+Q+"` of type "+("`"+te+"` supplied to `"+W+"`, expected ")+("instance of `"+K+"`."))}return null}return x(D)}function S(P){if(!Array.isArray(P))return process.env.NODE_ENV!=="production"&&(arguments.length>1?l("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):l("Invalid argument supplied to oneOf, expected an array.")),d;function D(L,B,W,se,Q){for(var K=L[B],te=0;te<P.length;te++)if(h(K,P[te]))return null;var ie=JSON.stringify(P,function(_e,oe){var le=N(oe);return le==="symbol"?String(oe):oe});return new m("Invalid "+se+" `"+Q+"` of value `"+String(K)+"` "+("supplied to `"+W+"`, expected one of "+ie+"."))}return x(D)}function A(P){function D(L,B,W,se,Q){if(typeof P!="function")return new m("Property `"+Q+"` of component `"+W+"` has invalid PropType notation inside objectOf.");var K=L[B],te=E(K);if(te!=="object")return new m("Invalid "+se+" `"+Q+"` of type "+("`"+te+"` supplied to `"+W+"`, expected an object."));for(var ie in K)if(r(K,ie)){var pe=P(K,ie,W,se,Q+"."+ie,s);if(pe instanceof Error)return pe}return null}return x(D)}function R(P){if(!Array.isArray(P))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var D=0;D<P.length;D++){var L=P[D];if(typeof L!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+V(L)+" at index "+D+"."),d}function B(W,se,Q,K,te){for(var ie=[],pe=0;pe<P.length;pe++){var _e=P[pe],oe=_e(W,se,Q,K,te,s);if(oe==null)return null;oe.data&&r(oe.data,"expectedType")&&ie.push(oe.data.expectedType)}var le=ie.length>0?", expected one of type ["+ie.join(", ")+"]":"";return new m("Invalid "+K+" `"+te+"` supplied to "+("`"+Q+"`"+le+"."))}return x(B)}function z(){function P(D,L,B,W,se){return M(D[L])?null:new m("Invalid "+W+" `"+se+"` supplied to "+("`"+B+"`, expected a ReactNode."))}return x(P)}function U(P,D,L,B,W){return new m((P||"React class")+": "+D+" type `"+L+"."+B+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+W+"`.")}function j(P){function D(L,B,W,se,Q){var K=L[B],te=E(K);if(te!=="object")return new m("Invalid "+se+" `"+Q+"` of type `"+te+"` "+("supplied to `"+W+"`, expected `object`."));for(var ie in P){var pe=P[ie];if(typeof pe!="function")return U(W,se,Q,ie,N(pe));var _e=pe(K,ie,W,se,Q+"."+ie,s);if(_e)return _e}return null}return x(D)}function O(P){function D(L,B,W,se,Q){var K=L[B],te=E(K);if(te!=="object")return new m("Invalid "+se+" `"+Q+"` of type `"+te+"` "+("supplied to `"+W+"`, expected `object`."));var ie=a({},L[B],P);for(var pe in ie){var _e=P[pe];if(r(P,pe)&&typeof _e!="function")return U(W,se,Q,pe,N(_e));if(!_e)return new m("Invalid "+se+" `"+Q+"` key `"+pe+"` supplied to `"+W+"`.\nBad object: "+JSON.stringify(L[B],null," ")+`
10
- Valid keys: `+JSON.stringify(Object.keys(P),null," "));var oe=_e(K,pe,W,se,Q+"."+pe,s);if(oe)return oe}return null}return x(D)}function M(P){switch(typeof P){case"number":case"string":case"undefined":return!0;case"boolean":return!P;case"object":if(Array.isArray(P))return P.every(M);if(P===null||c(P))return!0;var D=p(P);if(D){var L=D.call(P),B;if(D!==P.entries){for(;!(B=L.next()).done;)if(!M(B.value))return!1}else for(;!(B=L.next()).done;){var W=B.value;if(W&&!M(W[1]))return!1}}else return!1;return!0;default:return!1}}function $(P,D){return P==="symbol"?!0:D?D["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&D instanceof Symbol:!1}function E(P){var D=typeof P;return Array.isArray(P)?"array":P instanceof RegExp?"object":$(D,P)?"symbol":D}function N(P){if(typeof P>"u"||P===null)return""+P;var D=E(P);if(D==="object"){if(P instanceof Date)return"date";if(P instanceof RegExp)return"regexp"}return D}function V(P){var D=N(P);switch(D){case"array":case"object":return"an "+D;case"boolean":case"date":case"regexp":return"a "+D;default:return D}}function q(P){return!P.constructor||!P.constructor.name?_:P.constructor.name}return v.checkPropTypes=o,v.resetWarningCache=o.resetWarningCache,v.PropTypes=v,v},xs}var bs,Fr;function uc(){if(Fr)return bs;Fr=1;var t=Js();function a(){}function s(){}return s.resetWarningCache=a,bs=function(){function r(d,c,g,f,u,p){if(p!==t){var _=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw _.name="Invariant Violation",_}}r.isRequired=r;function o(){return r}var l={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:s,resetWarningCache:a};return l.PropTypes=l,l},bs}var $r;function To(){if($r)return cn.exports;if($r=1,process.env.NODE_ENV!=="production"){var t=Co(),a=!0;cn.exports=cc()(t.isElement,a)}else cn.exports=uc()();return cn.exports}var Ur;function pc(){if(Ur)return Je;Ur=1;var t=Je&&Je.__extends||(function(){var v=function(h,m){return v=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,T){x.__proto__=T}||function(x,T){for(var I in T)Object.prototype.hasOwnProperty.call(T,I)&&(x[I]=T[I])},v(h,m)};return function(h,m){if(typeof m!="function"&&m!==null)throw new TypeError("Class extends value "+String(m)+" is not a constructor or null");v(h,m);function x(){this.constructor=h}h.prototype=m===null?Object.create(m):(x.prototype=m.prototype,new x)}})(),a=Je&&Je.__assign||function(){return a=Object.assign||function(v){for(var h,m=1,x=arguments.length;m<x;m++){h=arguments[m];for(var T in h)Object.prototype.hasOwnProperty.call(h,T)&&(v[T]=h[T])}return v},a.apply(this,arguments)},s=Je&&Je.__createBinding||(Object.create?(function(v,h,m,x){x===void 0&&(x=m);var T=Object.getOwnPropertyDescriptor(h,m);(!T||("get"in T?!h.__esModule:T.writable||T.configurable))&&(T={enumerable:!0,get:function(){return h[m]}}),Object.defineProperty(v,x,T)}):(function(v,h,m,x){x===void 0&&(x=m),v[x]=h[m]})),r=Je&&Je.__setModuleDefault||(Object.create?(function(v,h){Object.defineProperty(v,"default",{enumerable:!0,value:h})}):function(v,h){v.default=h}),o=Je&&Je.__importStar||function(v){if(v&&v.__esModule)return v;var h={};if(v!=null)for(var m in v)m!=="default"&&Object.prototype.hasOwnProperty.call(v,m)&&s(h,v,m);return r(h,v),h},l=Je&&Je.__rest||function(v,h){var m={};for(var x in v)Object.prototype.hasOwnProperty.call(v,x)&&h.indexOf(x)<0&&(m[x]=v[x]);if(v!=null&&typeof Object.getOwnPropertySymbols=="function")for(var T=0,x=Object.getOwnPropertySymbols(v);T<x.length;T++)h.indexOf(x[T])<0&&Object.prototype.propertyIsEnumerable.call(v,x[T])&&(m[x[T]]=v[x[T]]);return m},d=Je&&Je.__importDefault||function(v){return v&&v.__esModule?v:{default:v}};Object.defineProperty(Je,"__esModule",{value:!0});var c=o(i),g=d(rc()),f=o(To());function u(v){return v&&v.replace(/&nbsp;|\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function p(v){var h=document.createTextNode("");v.appendChild(h);var m=document.activeElement===v;if(h!==null&&h.nodeValue!==null&&m){var x=window.getSelection();if(x!==null){var T=document.createRange();T.setStart(h,h.nodeValue.length),T.collapse(!0),x.removeAllRanges(),x.addRange(T)}v instanceof HTMLElement&&v.focus()}}var _=(function(v){t(h,v);function h(){var m=v!==null&&v.apply(this,arguments)||this;return m.lastHtml=m.props.html,m.el=typeof m.props.innerRef=="function"?{current:null}:c.createRef(),m.getEl=function(){return(m.props.innerRef&&typeof m.props.innerRef!="function"?m.props.innerRef:m.el).current},m.emitChange=function(x){var T=m.getEl();if(T){var I=T.innerHTML;if(m.props.onChange&&I!==m.lastHtml){var k=Object.assign({},x,{target:{value:I}});m.props.onChange(k)}m.lastHtml=I}},m}return h.prototype.render=function(){var m=this,x=this.props,T=x.tagName,I=x.html,k=x.innerRef,C=l(x,["tagName","html","innerRef"]);return c.createElement(T||"div",a(a({},C),{ref:typeof k=="function"?function(b){k(b),m.el.current=b}:k||this.el,onInput:this.emitChange,onBlur:this.props.onBlur||this.emitChange,onKeyUp:this.props.onKeyUp||this.emitChange,onKeyDown:this.props.onKeyDown||this.emitChange,contentEditable:!this.props.disabled,dangerouslySetInnerHTML:{__html:I}}),this.props.children)},h.prototype.shouldComponentUpdate=function(m){var x=this.props,T=this.getEl();return!T||u(m.html)!==u(T.innerHTML)?!0:x.disabled!==m.disabled||x.tagName!==m.tagName||x.className!==m.className||x.innerRef!==m.innerRef||x.placeholder!==m.placeholder||!(0,g.default)(x.style,m.style)},h.prototype.componentDidUpdate=function(){var m=this.getEl();m&&(this.props.html!==m.innerHTML&&(m.innerHTML=this.props.html),this.lastHtml=this.props.html,p(m))},h.propTypes={html:f.string.isRequired,onChange:f.func,disabled:f.bool,tagName:f.string,className:f.string,style:f.object,innerRef:f.oneOfType([f.object,f.func])},h})(c.Component);return Je.default=_,Je}var mc=pc();const Ro=wo(mc),fc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},yc={width:"100%",minHeight:40,padding:"8px 0",fontSize:"14px",color:"#222",background:"transparent",border:0,borderTop:0,borderLeft:0,borderRight:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",outline:"none",transition:"border-color 0.2s ease"},Y=i.forwardRef(({style:t,onFocus:a,onBlur:s,...r},o)=>{const[l,d]=i.useState(!1);return e.jsxs("div",{className:"",style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:fc,children:r.label}),e.jsx("input",{placeholder:r.placeholder||r.label,...r,ref:o,onFocus:c=>{d(!0),a?.(c)},onBlur:c=>{d(!1),s?.(c)},style:{...yc,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})}),Nr=[{value:"01",label:"January"},{value:"02",label:"February"},{value:"03",label:"March"},{value:"04",label:"April"},{value:"05",label:"May"},{value:"06",label:"June"},{value:"07",label:"July"},{value:"08",label:"August"},{value:"09",label:"September"},{value:"10",label:"October"},{value:"11",label:"November"},{value:"12",label:"December"}];function Qs(t){const a=ae().year(),s=[];for(let r=a;r>=a-t;r--)s.push({label:String(r),value:r});return s}function Qe(t){switch(t){case"late":return e.jsx("span",{className:"label label-late",children:"L"});case"present":return e.jsx("span",{className:"label label-success",children:"P"});case"absent":return e.jsx("span",{className:"label label-danger",children:"A"});case"P":return e.jsx("span",{className:"monthlyLabel label-success",children:"P"});case"A":return e.jsx("span",{className:"monthlyLabel label-danger",children:"A"});case"L":return e.jsx("span",{className:"monthlyLabel label-late",children:"L"});case"W":return e.jsx("span",{className:"monthlyLabel sunday",children:"W"});case"H":return e.jsx("span",{className:"monthlyLabel holiday",children:"H"});default:return e.jsx("span",{className:"label",children:t})}}function Xs(t){const a=ae().year(),s=ae().month();return t<a?Nr:Nr.slice(0,s+1)}function Lr(t,a){switch(t){case"sunday":return e.jsx("span",{className:"monthlyLabel sunday",children:a});case"holiday":return e.jsx("span",{className:"monthlyLabel holiday",children:a});default:return e.jsx("span",{className:"monthlyLabel",children:a})}}function hc(){return[{label:"One Time (During Admission)",value:"one_time"},{label:"One Time",value:"one_time_without_admission"},{label:"Monthly",value:"monthly"},{label:"Quarterly",value:"quarterly"},{label:"Half Yearly",value:"half_yearly"},{label:"Yearly",value:"yearly"}]}const Do=t=>{switch(t){case"paid":return e.jsx("div",{style:{background:"#3cb371",color:"white",textAlign:"center"},children:"PAID"});case"due":return e.jsx("div",{style:{background:"red",color:"white",textAlign:"center"},children:"DUE"});case"partially_paid":return e.jsx("div",{style:{background:"#ff8d00",color:"white",textAlign:"center"},children:"Partially Paid"});case"Present":return e.jsx(n.Tag,{color:"success",children:"Present"});case"Absent":return e.jsx(n.Tag,{color:"error",children:"Absent"});case"NO Attendance":return e.jsx(n.Tag,{color:"error",children:"No Attendance"});case"one_time":return"ONETIME";case"monthly":return"MONTHLY";case"half_yearly":return"HALF YEARLY";case"quarterly":return"QUARTERLY";default:return""}},_t=t=>{const a=JSON.parse(localStorage.getItem("genrall_settings"));return console.log("amount______",t),e.jsxs(e.Fragment,{children:[a?.currency_icon," ",Number(t||0).toLocaleString("en-IN")]})};var wa={},Ca={},ut={},Aa={},ta={},Br;function gc(){if(Br)return ta;Br=1;var t=ta&&ta.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(ta,"__esModule",{value:!0});const a=t(i),s=nl,r=["string","number","boolean"];function o({header:l,body:d}){const c=a.default.createElement("tr",null,l.map(f=>a.default.createElement("th",{key:f},f))),g=d.map((f,u)=>Array.isArray(f)?a.default.createElement("tr",{key:u},f.map((p,_)=>a.default.createElement("th",{key:_}," ",p," "))):f!==null&&typeof f=="object"?a.default.createElement("tr",{key:u},Object.entries(f).map(([p,_],v)=>typeof _=="object"?(console.error(`typeof ${p} is incorrect, only accept ${r.join(", ")} `),a.default.createElement("th",{key:v})):a.default.createElement("th",{key:v},a.default.createElement(a.default.Fragment,null,_)))):(console.error(`
8
+ `,d+1),y=c===-1?"":l.slice(c+1);String(r.stack).endsWith(y)||(r.stack+=`
9
+ `+l)}}catch{}}throw r}}_request(a,s){typeof a=="string"?(s=s||{},s.url=a):s=a||{},s=Qt(this.defaults,s);const{transitional:r,paramsSerializer:o,headers:l}=s;r!==void 0&&In.assertOptions(r,{silentJSONParsing:bt.transitional(bt.boolean),forcedJSONParsing:bt.transitional(bt.boolean),clarifyTimeoutError:bt.transitional(bt.boolean),legacyInterceptorReqResOrdering:bt.transitional(bt.boolean)},!1),o!=null&&(Z.isFunction(o)?s.paramsSerializer={serialize:o}:In.assertOptions(o,{encode:bt.function,serialize:bt.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),In.assertOptions(s,{baseUrl:bt.spelling("baseURL"),withXsrfToken:bt.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let d=l&&Z.merge(l.common,l[s.method]);l&&Z.forEach(["delete","get","head","post","put","patch","common"],b=>{delete l[b]}),s.headers=ut.concat(d,l);const c=[];let y=!0;this.interceptors.request.forEach(function(m){if(typeof m.runWhen=="function"&&m.runWhen(s)===!1)return;y=y&&m.synchronous;const j=s.transitional||Ks;j&&j.legacyInterceptorReqResOrdering?c.unshift(m.fulfilled,m.rejected):c.push(m.fulfilled,m.rejected)});const h=[];this.interceptors.response.forEach(function(m){h.push(m.fulfilled,m.rejected)});let u,p=0,w;if(!y){const b=[Ir.bind(this),void 0];for(b.unshift(...c),b.push(...h),w=b.length,u=Promise.resolve(s);p<w;)u=u.then(b[p++],b[p++]);return u}w=c.length;let v=s;for(;p<w;){const b=c[p++],m=c[p++];try{v=b(v)}catch(j){m.call(this,j);break}}try{u=Ir.call(this,v)}catch(b){return Promise.reject(b)}for(p=0,w=h.length;p<w;)u=u.then(h[p++],h[p++]);return u}getUri(a){a=Qt(this.defaults,a);const s=Ro(a.baseURL,a.url,a.allowAbsoluteUrls);return Co(s,a.params,a.paramsSerializer)}};Z.forEach(["delete","get","head","options"],function(a){Kt.prototype[a]=function(s,r){return this.request(Qt(r||{},{method:a,url:s,data:(r||{}).data}))}});Z.forEach(["post","put","patch"],function(a){function s(r){return function(l,d,c){return this.request(Qt(c||{},{method:a,headers:r?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}Kt.prototype[a]=s(),Kt.prototype[a+"Form"]=s(!0)});let ac=class Mo{constructor(a){if(typeof a!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(l){s=l});const r=this;this.promise.then(o=>{if(!r._listeners)return;let l=r._listeners.length;for(;l-- >0;)r._listeners[l](o);r._listeners=null}),this.promise.then=o=>{let l;const d=new Promise(c=>{r.subscribe(c),l=c}).then(o);return d.cancel=function(){r.unsubscribe(l)},d},a(function(l,d,c){r.reason||(r.reason=new Ja(l,d,c),s(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(a){if(this.reason){a(this.reason);return}this._listeners?this._listeners.push(a):this._listeners=[a]}unsubscribe(a){if(!this._listeners)return;const s=this._listeners.indexOf(a);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const a=new AbortController,s=r=>{a.abort(r)};return this.subscribe(s),a.signal.unsubscribe=()=>this.unsubscribe(s),a.signal}static source(){let a;return{token:new Mo(function(o){a=o}),cancel:a}}};function nc(t){return function(s){return t.apply(null,s)}}function sc(t){return Z.isObject(t)&&t.isAxiosError===!0}const zs={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(zs).forEach(([t,a])=>{zs[a]=t});function Eo(t){const a=new Kt(t),s=ho(Kt.prototype.request,a);return Z.extend(s,Kt.prototype,a,{allOwnKeys:!0}),Z.extend(s,a,null,{allOwnKeys:!0}),s.create=function(o){return Eo(Qt(t,o))},s}const We=Eo(Ga);We.Axios=Kt;We.CanceledError=Ja;We.CancelToken=ac;We.isCancel=Do;We.VERSION=Oo;We.toFormData=Qn;We.AxiosError=Ae;We.Cancel=We.CanceledError;We.all=function(a){return Promise.all(a)};We.spread=nc;We.isAxiosError=sc;We.mergeConfig=Qt;We.AxiosHeaders=ut;We.formToJSON=t=>Ao(Z.isHTMLForm(t)?new FormData(t):t);We.getAdapter=Po.getAdapter;We.HttpStatusCode=zs;We.default=We;const{Axios:Rx,AxiosError:Ix,CanceledError:kx,isCancel:Px,CancelToken:Ox,VERSION:Mx,all:Ex,Cancel:Fx,isAxiosError:$x,spread:Ux,toFormData:Nx,AxiosHeaders:Lx,HttpStatusCode:Bx,formToJSON:qx,getAdapter:zx,mergeConfig:Yx}=We,rc=()=>new Promise(t=>setTimeout(()=>t(),800));let Ys=null;const ic=t=>{Ys=t,Ct.defaults.baseURL=Qs()},Qs=()=>Ys||"https://npmapi.ubkerp.com/",Ct=We.create({baseURL:Qs()}),He=()=>Qs(),Ee=async(t,a,s)=>{const r=await Ct.post(t,a,{headers:{Authorization:s}});if(console.log("ddddfdfdfd",r.data?.Status),r.data?.Status=="Success")return r?.data?.data||r?.data;throw new Error(r.data?.msg)},H=async(t,a)=>{try{let r=t;if(!t.includes("session_id")){const l=t.includes("?")?"&":"?";r=`${t}${l}session_id=1`}return(await Ct.get(r,{headers:{Authorization:a}})).data}catch(s){throw s.response?.status===401&&console.error("401 Unauthorized"),s}},oc=async(t,a)=>{const s=await Ct.post(t,"",{headers:{Authorization:a}});if(s.data?.Status=="Success")return s?.data?.data||s?.data;throw new Error(s.data?.msg)},Zn=async(t,a,s)=>{try{const r=await Ct.post(t,a,{headers:{Authorization:s,"Content-Type":"application/json"}});return r.data?.Status==="Success"?r.data:(_.error(r.data?.msg||"Unable to issue library book",{duration:2e3}),!1)}catch(r){throw _.error(r.response?.data?.msg||r.response?.data?.message||"Request failed",{duration:2e3}),r}},za=async(t,a,s)=>{const r=a?.arg;return(await Ct.post(t,r,{headers:{Authorization:s}}))?.data},Gt=async(t,a,s)=>{const r=a?.arg,o=t.includes("?")?"&":"?";return(await Ct.get(t+o,{params:r,headers:{Authorization:s}}))?.data},lc="api/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",Xs=async(t,a,s)=>{const r=a?.arg,o=t.includes("?")?"&":"?",l=await Ct.get(t+o,{params:r,headers:{Authorization:s}});if(console.log("ddddfdfdfd",l.data?.Status),l.data?.Status=="Success")return l?.data?.data||l?.data;throw new Error(l.data?.msg)},Be=async(t,a,s)=>(await rc(),(await Ct.post(t,a,{headers:{Authorization:s}}))?.data),Qa=async(t,a,s)=>(await Ct.post(t,a,{headers:{Authorization:s}})).data,qe=async(t,a,s)=>(await Ct.delete(`${t}/${a}`,{headers:{Authorization:s}})).data,dc="api/report/LibraryRenewalReport/renewalHistory",cc="api/report/LibraryRenewalReport/renewalFineReport",uc="api/report/LibraryRenewalReport/currentlyRenewedBooks",pc="api/report/LibraryRenewalReport/upcomingRenewalDue",mc="api/report/LibraryRenewalReport/overdueRenewalReport",hc="api/report/LibraryRenewalReport/renewalLimitReport",fc="api/report/LibraryRenewalReport/renewalStatusReport",yc="api/report/LibraryRenewalReport/studentWiseReport",gc="api/report/LibraryRenewalReport/bookWiseReport",xc="api/report/LibraryRenewalReport/classWiseReport",bc="api/report/LibraryRenewalReport/staffWiseReport",jc="api/report/LibraryRenewalReport/renewalStatisticsByDate",Sc="/sample_templates/route_upload.xlsx",Zs="api/branchapi/academy/classdropdownlist",er="api/branchapi/academy/sectionoftheClass",vc="/sample_templates/student_transport_upload.xlsx",wc="api/branchapi/income/incomeTableList",_c="api/branchapi/income/addincome",Cc="api/branchapi/income/editincome",Ac="api/branchapi/income/deleteincome",Fo="api/branchapi/income/incomeheadDropdown",Dc="api/branchapi/income/incomeheadTableList",Tc="api/branchapi/income/addincomehead",Rc="api/branchapi/income/editincomehead",Ic="api/branchapi/income/deleteincomehead",kc="api/branchapi/income/incomeShowdata",Pc="api/branchapi/income/incomeheadShowdata",Oc="api/branchapi/income/searchincomebydates",Mc="api/branchapi/expense/expenseTableList",Ec="api/branchapi/expense/addexpense",Fc="api/branchapi/expense/editexpense",$c="api/branchapi/expense/deleteExpense",$o="api/branchapi/expense/expenseheadDropdown",Uc="api/branchapi/expense/expenseheadTableList",Nc="api/branchapi/expense/addexpensehead",Lc="api/branchapi/expense/editexpensehead",Bc="api/branchapi/expense/deleteexpensehead",qc="api/branchapi/expense/expenseShowdata",zc="api/branchapi/expense/expenseheadShowdata",Yc="api/branchapi/expense/searchexpensebydates",Uo="api/accounts/vendor/vendorlist",Vc="api/student/studentDetails/studentLoginCredentialList",No="/branchapi/student/studentlist",Lo="api/branchapi/student/studentsearchbyKeywords",Bo="api/branchapi/student/studentsearchbyClassSection",Wc="/branchapi/student/addStudentMedicineDetails",Hc="/branchapi/student/StudentMedicineDetails",qo="/branchapi/academy/getstudentClasssubjectByStudentId",Kc="/branchapi/academy/removeAssignStudentSubject",Vs="/branchapi/feesCollection/extraCurricularActivitiesFess",Gc="/branchapi/academy/unAssigneStudentSubject",Jc=({token:t,menu:a})=>{const{isLoading:s,data:r}=W(t?["api/sdk/Menus",t]:null,([l,d])=>oc(l,d)),o=r?.find(l=>l.path===a)?.sub_menu??[];return console.log("menuData",r),e.jsx(n.Row,{gutter:[16,16],children:o?.map((l,d)=>l.dashboard_show==="YES"?e.jsx(n.Col,{xs:24,md:8,lg:8,children:e.jsx(A,{children:e.jsx(mo,{icon:`${He()}icons/frontoffice/${l.icons}`,title:l.submenu_name,path:l.menu_key})})},`${d}office001`):null)})};function zo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ze={},hs,Pr;function Qc(){return Pr||(Pr=1,hs=function t(a,s){if(a===s)return!0;if(a&&s&&typeof a=="object"&&typeof s=="object"){if(a.constructor!==s.constructor)return!1;var r,o,l;if(Array.isArray(a)){if(r=a.length,r!=s.length)return!1;for(o=r;o--!==0;)if(!t(a[o],s[o]))return!1;return!0}if(a.constructor===RegExp)return a.source===s.source&&a.flags===s.flags;if(a.valueOf!==Object.prototype.valueOf)return a.valueOf()===s.valueOf();if(a.toString!==Object.prototype.toString)return a.toString()===s.toString();if(l=Object.keys(a),r=l.length,r!==Object.keys(s).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(s,l[o]))return!1;for(o=r;o--!==0;){var d=l[o];if(!t(a[d],s[d]))return!1}return!0}return a!==a&&s!==s}),hs}var un={exports:{}},pn={exports:{}},Pe={};var Or;function Xc(){if(Or)return Pe;Or=1;var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,r=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,y=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,p=t?Symbol.for("react.suspense"):60113,w=t?Symbol.for("react.suspense_list"):60120,v=t?Symbol.for("react.memo"):60115,b=t?Symbol.for("react.lazy"):60116,m=t?Symbol.for("react.block"):60121,j=t?Symbol.for("react.fundamental"):60117,D=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function k(x){if(typeof x=="object"&&x!==null){var g=x.$$typeof;switch(g){case a:switch(x=x.type,x){case y:case h:case r:case l:case o:case p:return x;default:switch(x=x&&x.$$typeof,x){case c:case u:case b:case v:case d:return x;default:return g}}case s:return g}}}function S(x){return k(x)===h}return Pe.AsyncMode=y,Pe.ConcurrentMode=h,Pe.ContextConsumer=c,Pe.ContextProvider=d,Pe.Element=a,Pe.ForwardRef=u,Pe.Fragment=r,Pe.Lazy=b,Pe.Memo=v,Pe.Portal=s,Pe.Profiler=l,Pe.StrictMode=o,Pe.Suspense=p,Pe.isAsyncMode=function(x){return S(x)||k(x)===y},Pe.isConcurrentMode=S,Pe.isContextConsumer=function(x){return k(x)===c},Pe.isContextProvider=function(x){return k(x)===d},Pe.isElement=function(x){return typeof x=="object"&&x!==null&&x.$$typeof===a},Pe.isForwardRef=function(x){return k(x)===u},Pe.isFragment=function(x){return k(x)===r},Pe.isLazy=function(x){return k(x)===b},Pe.isMemo=function(x){return k(x)===v},Pe.isPortal=function(x){return k(x)===s},Pe.isProfiler=function(x){return k(x)===l},Pe.isStrictMode=function(x){return k(x)===o},Pe.isSuspense=function(x){return k(x)===p},Pe.isValidElementType=function(x){return typeof x=="string"||typeof x=="function"||x===r||x===h||x===l||x===o||x===p||x===w||typeof x=="object"&&x!==null&&(x.$$typeof===b||x.$$typeof===v||x.$$typeof===d||x.$$typeof===c||x.$$typeof===u||x.$$typeof===j||x.$$typeof===D||x.$$typeof===I||x.$$typeof===m)},Pe.typeOf=k,Pe}var Oe={};var Mr;function Zc(){return Mr||(Mr=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,r=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,y=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,p=t?Symbol.for("react.suspense"):60113,w=t?Symbol.for("react.suspense_list"):60120,v=t?Symbol.for("react.memo"):60115,b=t?Symbol.for("react.lazy"):60116,m=t?Symbol.for("react.block"):60121,j=t?Symbol.for("react.fundamental"):60117,D=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function k(le){return typeof le=="string"||typeof le=="function"||le===r||le===h||le===l||le===o||le===p||le===w||typeof le=="object"&&le!==null&&(le.$$typeof===b||le.$$typeof===v||le.$$typeof===d||le.$$typeof===c||le.$$typeof===u||le.$$typeof===j||le.$$typeof===D||le.$$typeof===I||le.$$typeof===m)}function S(le){if(typeof le=="object"&&le!==null){var de=le.$$typeof;switch(de){case a:var Q=le.type;switch(Q){case y:case h:case r:case l:case o:case p:return Q;default:var ce=Q&&Q.$$typeof;switch(ce){case c:case u:case b:case v:case d:return ce;default:return de}}case s:return de}}}var x=y,g=h,C=c,T=d,R=a,L=u,N=r,f=b,P=v,O=s,$=l,F=o,U=p,V=!1;function q(le){return V||(V=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),E(le)||S(le)===y}function E(le){return S(le)===h}function M(le){return S(le)===c}function B(le){return S(le)===d}function z(le){return typeof le=="object"&&le!==null&&le.$$typeof===a}function G(le){return S(le)===u}function re(le){return S(le)===r}function K(le){return S(le)===b}function J(le){return S(le)===v}function ae(le){return S(le)===s}function oe(le){return S(le)===l}function pe(le){return S(le)===o}function _e(le){return S(le)===p}Oe.AsyncMode=x,Oe.ConcurrentMode=g,Oe.ContextConsumer=C,Oe.ContextProvider=T,Oe.Element=R,Oe.ForwardRef=L,Oe.Fragment=N,Oe.Lazy=f,Oe.Memo=P,Oe.Portal=O,Oe.Profiler=$,Oe.StrictMode=F,Oe.Suspense=U,Oe.isAsyncMode=q,Oe.isConcurrentMode=E,Oe.isContextConsumer=M,Oe.isContextProvider=B,Oe.isElement=z,Oe.isForwardRef=G,Oe.isFragment=re,Oe.isLazy=K,Oe.isMemo=J,Oe.isPortal=ae,Oe.isProfiler=oe,Oe.isStrictMode=pe,Oe.isSuspense=_e,Oe.isValidElementType=k,Oe.typeOf=S})()),Oe}var Er;function Yo(){return Er||(Er=1,process.env.NODE_ENV==="production"?pn.exports=Xc():pn.exports=Zc()),pn.exports}var fs,Fr;function eu(){if(Fr)return fs;Fr=1;var t=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function r(l){if(l==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(l)}function o(){try{if(!Object.assign)return!1;var l=new String("abc");if(l[5]="de",Object.getOwnPropertyNames(l)[0]==="5")return!1;for(var d={},c=0;c<10;c++)d["_"+String.fromCharCode(c)]=c;var y=Object.getOwnPropertyNames(d).map(function(u){return d[u]});if(y.join("")!=="0123456789")return!1;var h={};return"abcdefghijklmnopqrst".split("").forEach(function(u){h[u]=u}),Object.keys(Object.assign({},h)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return fs=o()?Object.assign:function(l,d){for(var c,y=r(l),h,u=1;u<arguments.length;u++){c=Object(arguments[u]);for(var p in c)a.call(c,p)&&(y[p]=c[p]);if(t){h=t(c);for(var w=0;w<h.length;w++)s.call(c,h[w])&&(y[h[w]]=c[h[w]])}}return y},fs}var ys,$r;function tr(){if($r)return ys;$r=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ys=t,ys}var gs,Ur;function Vo(){return Ur||(Ur=1,gs=Function.call.bind(Object.prototype.hasOwnProperty)),gs}var xs,Nr;function tu(){if(Nr)return xs;Nr=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var a=tr(),s={},r=Vo();t=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function o(l,d,c,y,h){if(process.env.NODE_ENV!=="production"){for(var u in l)if(r(l,u)){var p;try{if(typeof l[u]!="function"){var w=Error((y||"React class")+": "+c+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw w.name="Invariant Violation",w}p=l[u](d,u,y,c,null,a)}catch(b){p=b}if(p&&!(p instanceof Error)&&t((y||"React class")+": type specification of "+c+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof p+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),p instanceof Error&&!(p.message in s)){s[p.message]=!0;var v=h?h():"";t("Failed "+c+" type: "+p.message+(v??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(s={})},xs=o,xs}var bs,Lr;function au(){if(Lr)return bs;Lr=1;var t=Yo(),a=eu(),s=tr(),r=Vo(),o=tu(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(c){var y="Warning: "+c;typeof console<"u"&&console.error(y);try{throw new Error(y)}catch{}});function d(){return null}return bs=function(c,y){var h=typeof Symbol=="function"&&Symbol.iterator,u="@@iterator";function p(E){var M=E&&(h&&E[h]||E[u]);if(typeof M=="function")return M}var w="<<anonymous>>",v={array:D("array"),bigint:D("bigint"),bool:D("boolean"),func:D("function"),number:D("number"),object:D("object"),string:D("string"),symbol:D("symbol"),any:I(),arrayOf:k,element:S(),elementType:x(),instanceOf:g,node:L(),objectOf:T,oneOf:C,oneOfType:R,shape:f,exact:P};function b(E,M){return E===M?E!==0||1/E===1/M:E!==E&&M!==M}function m(E,M){this.message=E,this.data=M&&typeof M=="object"?M:{},this.stack=""}m.prototype=Error.prototype;function j(E){if(process.env.NODE_ENV!=="production")var M={},B=0;function z(re,K,J,ae,oe,pe,_e){if(ae=ae||w,pe=pe||J,_e!==s){if(y){var le=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw le.name="Invariant Violation",le}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var de=ae+":"+J;!M[de]&&B<3&&(l("You are manually calling a React.PropTypes validation function for the `"+pe+"` prop on `"+ae+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),M[de]=!0,B++)}}return K[J]==null?re?K[J]===null?new m("The "+oe+" `"+pe+"` is marked as required "+("in `"+ae+"`, but its value is `null`.")):new m("The "+oe+" `"+pe+"` is marked as required in "+("`"+ae+"`, but its value is `undefined`.")):null:E(K,J,ae,oe,pe)}var G=z.bind(null,!1);return G.isRequired=z.bind(null,!0),G}function D(E){function M(B,z,G,re,K,J){var ae=B[z],oe=F(ae);if(oe!==E){var pe=U(ae);return new m("Invalid "+re+" `"+K+"` of type "+("`"+pe+"` supplied to `"+G+"`, expected ")+("`"+E+"`."),{expectedType:E})}return null}return j(M)}function I(){return j(d)}function k(E){function M(B,z,G,re,K){if(typeof E!="function")return new m("Property `"+K+"` of component `"+G+"` has invalid PropType notation inside arrayOf.");var J=B[z];if(!Array.isArray(J)){var ae=F(J);return new m("Invalid "+re+" `"+K+"` of type "+("`"+ae+"` supplied to `"+G+"`, expected an array."))}for(var oe=0;oe<J.length;oe++){var pe=E(J,oe,G,re,K+"["+oe+"]",s);if(pe instanceof Error)return pe}return null}return j(M)}function S(){function E(M,B,z,G,re){var K=M[B];if(!c(K)){var J=F(K);return new m("Invalid "+G+" `"+re+"` of type "+("`"+J+"` supplied to `"+z+"`, expected a single ReactElement."))}return null}return j(E)}function x(){function E(M,B,z,G,re){var K=M[B];if(!t.isValidElementType(K)){var J=F(K);return new m("Invalid "+G+" `"+re+"` of type "+("`"+J+"` supplied to `"+z+"`, expected a single ReactElement type."))}return null}return j(E)}function g(E){function M(B,z,G,re,K){if(!(B[z]instanceof E)){var J=E.name||w,ae=q(B[z]);return new m("Invalid "+re+" `"+K+"` of type "+("`"+ae+"` supplied to `"+G+"`, expected ")+("instance of `"+J+"`."))}return null}return j(M)}function C(E){if(!Array.isArray(E))return process.env.NODE_ENV!=="production"&&(arguments.length>1?l("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):l("Invalid argument supplied to oneOf, expected an array.")),d;function M(B,z,G,re,K){for(var J=B[z],ae=0;ae<E.length;ae++)if(b(J,E[ae]))return null;var oe=JSON.stringify(E,function(_e,le){var de=U(le);return de==="symbol"?String(le):le});return new m("Invalid "+re+" `"+K+"` of value `"+String(J)+"` "+("supplied to `"+G+"`, expected one of "+oe+"."))}return j(M)}function T(E){function M(B,z,G,re,K){if(typeof E!="function")return new m("Property `"+K+"` of component `"+G+"` has invalid PropType notation inside objectOf.");var J=B[z],ae=F(J);if(ae!=="object")return new m("Invalid "+re+" `"+K+"` of type "+("`"+ae+"` supplied to `"+G+"`, expected an object."));for(var oe in J)if(r(J,oe)){var pe=E(J,oe,G,re,K+"."+oe,s);if(pe instanceof Error)return pe}return null}return j(M)}function R(E){if(!Array.isArray(E))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var M=0;M<E.length;M++){var B=E[M];if(typeof B!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+V(B)+" at index "+M+"."),d}function z(G,re,K,J,ae){for(var oe=[],pe=0;pe<E.length;pe++){var _e=E[pe],le=_e(G,re,K,J,ae,s);if(le==null)return null;le.data&&r(le.data,"expectedType")&&oe.push(le.data.expectedType)}var de=oe.length>0?", expected one of type ["+oe.join(", ")+"]":"";return new m("Invalid "+J+" `"+ae+"` supplied to "+("`"+K+"`"+de+"."))}return j(z)}function L(){function E(M,B,z,G,re){return O(M[B])?null:new m("Invalid "+G+" `"+re+"` supplied to "+("`"+z+"`, expected a ReactNode."))}return j(E)}function N(E,M,B,z,G){return new m((E||"React class")+": "+M+" type `"+B+"."+z+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+G+"`.")}function f(E){function M(B,z,G,re,K){var J=B[z],ae=F(J);if(ae!=="object")return new m("Invalid "+re+" `"+K+"` of type `"+ae+"` "+("supplied to `"+G+"`, expected `object`."));for(var oe in E){var pe=E[oe];if(typeof pe!="function")return N(G,re,K,oe,U(pe));var _e=pe(J,oe,G,re,K+"."+oe,s);if(_e)return _e}return null}return j(M)}function P(E){function M(B,z,G,re,K){var J=B[z],ae=F(J);if(ae!=="object")return new m("Invalid "+re+" `"+K+"` of type `"+ae+"` "+("supplied to `"+G+"`, expected `object`."));var oe=a({},B[z],E);for(var pe in oe){var _e=E[pe];if(r(E,pe)&&typeof _e!="function")return N(G,re,K,pe,U(_e));if(!_e)return new m("Invalid "+re+" `"+K+"` key `"+pe+"` supplied to `"+G+"`.\nBad object: "+JSON.stringify(B[z],null," ")+`
10
+ Valid keys: `+JSON.stringify(Object.keys(E),null," "));var le=_e(J,pe,G,re,K+"."+pe,s);if(le)return le}return null}return j(M)}function O(E){switch(typeof E){case"number":case"string":case"undefined":return!0;case"boolean":return!E;case"object":if(Array.isArray(E))return E.every(O);if(E===null||c(E))return!0;var M=p(E);if(M){var B=M.call(E),z;if(M!==E.entries){for(;!(z=B.next()).done;)if(!O(z.value))return!1}else for(;!(z=B.next()).done;){var G=z.value;if(G&&!O(G[1]))return!1}}else return!1;return!0;default:return!1}}function $(E,M){return E==="symbol"?!0:M?M["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&M instanceof Symbol:!1}function F(E){var M=typeof E;return Array.isArray(E)?"array":E instanceof RegExp?"object":$(M,E)?"symbol":M}function U(E){if(typeof E>"u"||E===null)return""+E;var M=F(E);if(M==="object"){if(E instanceof Date)return"date";if(E instanceof RegExp)return"regexp"}return M}function V(E){var M=U(E);switch(M){case"array":case"object":return"an "+M;case"boolean":case"date":case"regexp":return"a "+M;default:return M}}function q(E){return!E.constructor||!E.constructor.name?w:E.constructor.name}return v.checkPropTypes=o,v.resetWarningCache=o.resetWarningCache,v.PropTypes=v,v},bs}var js,Br;function nu(){if(Br)return js;Br=1;var t=tr();function a(){}function s(){}return s.resetWarningCache=a,js=function(){function r(d,c,y,h,u,p){if(p!==t){var w=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw w.name="Invariant Violation",w}}r.isRequired=r;function o(){return r}var l={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:s,resetWarningCache:a};return l.PropTypes=l,l},js}var qr;function Wo(){if(qr)return un.exports;if(qr=1,process.env.NODE_ENV!=="production"){var t=Yo(),a=!0;un.exports=au()(t.isElement,a)}else un.exports=nu()();return un.exports}var zr;function su(){if(zr)return Ze;zr=1;var t=Ze&&Ze.__extends||(function(){var v=function(b,m){return v=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(j,D){j.__proto__=D}||function(j,D){for(var I in D)Object.prototype.hasOwnProperty.call(D,I)&&(j[I]=D[I])},v(b,m)};return function(b,m){if(typeof m!="function"&&m!==null)throw new TypeError("Class extends value "+String(m)+" is not a constructor or null");v(b,m);function j(){this.constructor=b}b.prototype=m===null?Object.create(m):(j.prototype=m.prototype,new j)}})(),a=Ze&&Ze.__assign||function(){return a=Object.assign||function(v){for(var b,m=1,j=arguments.length;m<j;m++){b=arguments[m];for(var D in b)Object.prototype.hasOwnProperty.call(b,D)&&(v[D]=b[D])}return v},a.apply(this,arguments)},s=Ze&&Ze.__createBinding||(Object.create?(function(v,b,m,j){j===void 0&&(j=m);var D=Object.getOwnPropertyDescriptor(b,m);(!D||("get"in D?!b.__esModule:D.writable||D.configurable))&&(D={enumerable:!0,get:function(){return b[m]}}),Object.defineProperty(v,j,D)}):(function(v,b,m,j){j===void 0&&(j=m),v[j]=b[m]})),r=Ze&&Ze.__setModuleDefault||(Object.create?(function(v,b){Object.defineProperty(v,"default",{enumerable:!0,value:b})}):function(v,b){v.default=b}),o=Ze&&Ze.__importStar||function(v){if(v&&v.__esModule)return v;var b={};if(v!=null)for(var m in v)m!=="default"&&Object.prototype.hasOwnProperty.call(v,m)&&s(b,v,m);return r(b,v),b},l=Ze&&Ze.__rest||function(v,b){var m={};for(var j in v)Object.prototype.hasOwnProperty.call(v,j)&&b.indexOf(j)<0&&(m[j]=v[j]);if(v!=null&&typeof Object.getOwnPropertySymbols=="function")for(var D=0,j=Object.getOwnPropertySymbols(v);D<j.length;D++)b.indexOf(j[D])<0&&Object.prototype.propertyIsEnumerable.call(v,j[D])&&(m[j[D]]=v[j[D]]);return m},d=Ze&&Ze.__importDefault||function(v){return v&&v.__esModule?v:{default:v}};Object.defineProperty(Ze,"__esModule",{value:!0});var c=o(i),y=d(Qc()),h=o(Wo());function u(v){return v&&v.replace(/&nbsp;|\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function p(v){var b=document.createTextNode("");v.appendChild(b);var m=document.activeElement===v;if(b!==null&&b.nodeValue!==null&&m){var j=window.getSelection();if(j!==null){var D=document.createRange();D.setStart(b,b.nodeValue.length),D.collapse(!0),j.removeAllRanges(),j.addRange(D)}v instanceof HTMLElement&&v.focus()}}var w=(function(v){t(b,v);function b(){var m=v!==null&&v.apply(this,arguments)||this;return m.lastHtml=m.props.html,m.el=typeof m.props.innerRef=="function"?{current:null}:c.createRef(),m.getEl=function(){return(m.props.innerRef&&typeof m.props.innerRef!="function"?m.props.innerRef:m.el).current},m.emitChange=function(j){var D=m.getEl();if(D){var I=D.innerHTML;if(m.props.onChange&&I!==m.lastHtml){var k=Object.assign({},j,{target:{value:I}});m.props.onChange(k)}m.lastHtml=I}},m}return b.prototype.render=function(){var m=this,j=this.props,D=j.tagName,I=j.html,k=j.innerRef,S=l(j,["tagName","html","innerRef"]);return c.createElement(D||"div",a(a({},S),{ref:typeof k=="function"?function(x){k(x),m.el.current=x}:k||this.el,onInput:this.emitChange,onBlur:this.props.onBlur||this.emitChange,onKeyUp:this.props.onKeyUp||this.emitChange,onKeyDown:this.props.onKeyDown||this.emitChange,contentEditable:!this.props.disabled,dangerouslySetInnerHTML:{__html:I}}),this.props.children)},b.prototype.shouldComponentUpdate=function(m){var j=this.props,D=this.getEl();return!D||u(m.html)!==u(D.innerHTML)?!0:j.disabled!==m.disabled||j.tagName!==m.tagName||j.className!==m.className||j.innerRef!==m.innerRef||j.placeholder!==m.placeholder||!(0,y.default)(j.style,m.style)},b.prototype.componentDidUpdate=function(){var m=this.getEl();m&&(this.props.html!==m.innerHTML&&(m.innerHTML=this.props.html),this.lastHtml=this.props.html,p(m))},b.propTypes={html:h.string.isRequired,onChange:h.func,disabled:h.bool,tagName:h.string,className:h.string,style:h.object,innerRef:h.oneOfType([h.object,h.func])},b})(c.Component);return Ze.default=w,Ze}var ru=su();const Ho=zo(ru),iu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ou={width:"100%",minHeight:40,padding:"8px 0",fontSize:"14px",color:"#222",background:"transparent",border:0,borderTop:0,borderLeft:0,borderRight:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",outline:"none",transition:"border-color 0.2s ease"},Y=i.forwardRef(({style:t,onFocus:a,onBlur:s,...r},o)=>{const[l,d]=i.useState(!1);return e.jsxs("div",{className:"",style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:iu,children:r.label}),e.jsx("input",{placeholder:r.placeholder||r.label,...r,ref:o,onFocus:c=>{d(!0),a?.(c)},onBlur:c=>{d(!1),s?.(c)},style:{...ou,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})}),Yr=[{value:"01",label:"January"},{value:"02",label:"February"},{value:"03",label:"March"},{value:"04",label:"April"},{value:"05",label:"May"},{value:"06",label:"June"},{value:"07",label:"July"},{value:"08",label:"August"},{value:"09",label:"September"},{value:"10",label:"October"},{value:"11",label:"November"},{value:"12",label:"December"}];function ar(t){const a=ee().year(),s=[];for(let r=a;r>=a-t;r--)s.push({label:String(r),value:r});return s}function et(t){switch(t){case"late":return e.jsx("span",{className:"label label-late",children:"L"});case"present":return e.jsx("span",{className:"label label-success",children:"P"});case"absent":return e.jsx("span",{className:"label label-danger",children:"A"});case"P":return e.jsx("span",{className:"monthlyLabel label-success",children:"P"});case"A":return e.jsx("span",{className:"monthlyLabel label-danger",children:"A"});case"L":return e.jsx("span",{className:"monthlyLabel label-late",children:"L"});case"W":return e.jsx("span",{className:"monthlyLabel sunday",children:"W"});case"H":return e.jsx("span",{className:"monthlyLabel holiday",children:"H"});default:return e.jsx("span",{className:"label",children:t})}}function nr(t){const a=ee().year(),s=ee().month();return t<a?Yr:Yr.slice(0,s+1)}function Vr(t,a){switch(t){case"sunday":return e.jsx("span",{className:"monthlyLabel sunday",children:a});case"holiday":return e.jsx("span",{className:"monthlyLabel holiday",children:a});default:return e.jsx("span",{className:"monthlyLabel",children:a})}}function lu(){return[{label:"One Time (During Admission)",value:"one_time"},{label:"One Time",value:"one_time_without_admission"},{label:"Monthly",value:"monthly"},{label:"Quarterly",value:"quarterly"},{label:"Half Yearly",value:"half_yearly"},{label:"Yearly",value:"yearly"}]}const Ko=t=>{switch(t){case"paid":return e.jsx("div",{style:{background:"#3cb371",color:"white",textAlign:"center"},children:"PAID"});case"due":return e.jsx("div",{style:{background:"red",color:"white",textAlign:"center"},children:"DUE"});case"partially_paid":return e.jsx("div",{style:{background:"#ff8d00",color:"white",textAlign:"center"},children:"Partially Paid"});case"Present":return e.jsx(n.Tag,{color:"success",children:"Present"});case"Absent":return e.jsx(n.Tag,{color:"error",children:"Absent"});case"NO Attendance":return e.jsx(n.Tag,{color:"error",children:"No Attendance"});case"one_time":return"ONETIME";case"monthly":return"MONTHLY";case"half_yearly":return"HALF YEARLY";case"quarterly":return"QUARTERLY";default:return""}},Tt=t=>{const a=JSON.parse(localStorage.getItem("genrall_settings"));return console.log("amount______",t),e.jsxs(e.Fragment,{children:[a?.currency_icon," ",Number(t||0).toLocaleString("en-IN")]})};var _a={},Ca={},ht={},Aa={},ta={},Wr;function du(){if(Wr)return ta;Wr=1;var t=ta&&ta.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(ta,"__esModule",{value:!0});const a=t(i),s=vl,r=["string","number","boolean"];function o({header:l,body:d}){const c=a.default.createElement("tr",null,l.map(h=>a.default.createElement("th",{key:h},h))),y=d.map((h,u)=>Array.isArray(h)?a.default.createElement("tr",{key:u},h.map((p,w)=>a.default.createElement("th",{key:w}," ",p," "))):h!==null&&typeof h=="object"?a.default.createElement("tr",{key:u},Object.entries(h).map(([p,w],v)=>typeof w=="object"?(console.error(`typeof ${p} is incorrect, only accept ${r.join(", ")} `),a.default.createElement("th",{key:v})):a.default.createElement("th",{key:v},a.default.createElement(a.default.Fragment,null,w)))):(console.error(`
11
11
  data structure is incorrect,
12
12
  data structure type ->
13
13
  " type data = Array<{ [key: string]: string | number | boolean }>
14
14
  or
15
15
  type data = Array<(string | number | boolean)[]>"
16
- `),null));return(0,s.renderToString)(a.default.createElement("table",null,a.default.createElement("tbody",null,c,g)))}return ta.default=o,ta}var qr;function xc(){return qr||(qr=1,(function(t){var a=Aa&&Aa.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(t,"__esModule",{value:!0}),t.createTable=t.template=t.uri=t.format=t.base64=void 0;function s(l){return window.btoa(unescape(encodeURIComponent(l)))}t.base64=s;function r(l,d){return l.replace(/{(\w+)}/g,(c,g)=>d[g])}t.format=r,t.uri="data:application/vnd.ms-excel;base64,",t.template='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>{table}</body></html>';var o=gc();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return a(o).default}})})(Aa)),Aa}var zr;function Io(){if(zr)return ut;zr=1;var t=ut&&ut.__createBinding||(Object.create?(function(f,u,p,_){_===void 0&&(_=p);var v=Object.getOwnPropertyDescriptor(u,p);(!v||("get"in v?!u.__esModule:v.writable||v.configurable))&&(v={enumerable:!0,get:function(){return u[p]}}),Object.defineProperty(f,_,v)}):(function(f,u,p,_){_===void 0&&(_=p),f[_]=u[p]})),a=ut&&ut.__setModuleDefault||(Object.create?(function(f,u){Object.defineProperty(f,"default",{enumerable:!0,value:u})}):function(f,u){f.default=u}),s=ut&&ut.__importStar||function(f){if(f&&f.__esModule)return f;var u={};if(f!=null)for(var p in f)p!=="default"&&Object.prototype.hasOwnProperty.call(f,p)&&t(u,f,p);return a(u,f),u};Object.defineProperty(ut,"__esModule",{value:!0}),ut.downloadExcel=ut.excel=void 0;const r=s(xc());function o(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function l(f,u){const p=window.document.createElement("a");return p.href=r.uri+r.base64(r.format(r.template,u)),p.download=f,document.body.appendChild(p),p.click(),document.body.removeChild(p),!0}function d(f,u){if(f)return f.cloneNode(!0).outerHTML;if(u)return r.createTable(u);console.error("currentTableRef or tablePayload does not exist")}function c({fileName:f,sheet:u,tablePayload:p},_){if(!o())return!1;const v=d(_,p);return l(f,{worksheet:u||"Worksheet",table:v})}ut.downloadExcel=c;function g({currentTableRef:f,filename:u,sheet:p}){function _(){if(!o())return!1;const v=d(f),h=`${u}.xls`;return l(h,{worksheet:p||"Worksheet",table:v})}return{onDownload:_}}return ut.excel=g,ut}var Yr;function bc(){if(Yr)return Ca;Yr=1,Object.defineProperty(Ca,"__esModule",{value:!0}),Ca.useDownloadExcel=void 0;const t=i,a=Io();function s({currentTableRef:r,filename:o,sheet:l}){const[d,c]=(0,t.useState)({});return(0,t.useEffect)(()=>{c({currentTableRef:r,filename:o,sheet:l})},[r,o,l]),(0,t.useMemo)(()=>(0,a.excel)(d),[d])}return Ca.useDownloadExcel=s,Ca}var Vr;function jc(){return Vr||(Vr=1,(function(t){var a=wa&&wa.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(t,"__esModule",{value:!0}),t.downloadExcel=t.useDownloadExcel=t.DownloadTableExcel=void 0;const s=a(i),r=bc();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return r.useDownloadExcel}});const o=Io();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return o.downloadExcel}});const l=({currentTableRef:d,filename:c,sheet:g,children:f})=>{const{onDownload:u}=(0,r.useDownloadExcel)({currentTableRef:d,filename:c,sheet:g});return s.default.createElement("span",{onClick:u},f)};t.DownloadTableExcel=l})(wa)),wa}var ko=jc();const xt=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:a}=t.data;t?.tableRef;const s=new Date().getTime(),r=xa.useReactToPrint({content:()=>a.current});return e.jsx(e.Fragment,{children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(n.Row,{gutter:8,children:[e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",icon:e.jsx(Z.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(n.Col,{children:e.jsx(ko.DownloadTableExcel,{filename:s,sheet:"users",currentTableRef:a.current,children:e.jsx(n.Button,{type:"text",icon:e.jsx(Z.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},It=t=>{const{tableRef:a}=t;return new Date().getTime(),e.jsx(e.Fragment,{children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},Jt=i.createContext(),Sc=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),Me=t=>{const{columns:a,action:s,DrawerUpdate:r,editDesign:o,newData:l,Loading:d,error:c,deleteTodoMutation:g,open:f,ActionView:u,viewDetails:p,myType:_,type:v,urlkey:h,columnstype:m,rowSelection:x}=t.data,T=Sc(),[I,k]=i.useState(!1),[C,b]=i.useState(null),[y,S]=i.useState("false"),[A,R]=i.useState(!1),[z,U]=i.useState(!1),[j,O]=i.useState(),[M,$]=i.useState(""),E=()=>k(!1),N=ne=>{S(ne),k(!0)},[V,q]=i.useState(),[P,D]=i.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),L=i.useRef(null),B=(ne,me)=>{t.parentCallback?.(ne,me),D({rowsPerPage:me,page:ne})},W=(ne,me)=>{b(me),R(!0),O(ne)},se=(ne,me)=>{b(me),U(!0),O(ne)},Q=t?.data?.onNavigate??t?.onNavigate,K=(ne,me)=>{if(typeof Q=="function"){Q(ne,me);return}typeof window<"u"&&typeof ne=="string"&&ne.length>0&&window.location.assign(ne)},te=ne=>{if(v==="staff"){K(`/HumanResourceDashboard/StaffFullInformation?id=${ne.fk_staffID}`,ne);return}K(`/StudentInformation/StudentFullInformation?id=${ne.id}`,ne)},ie=(ne,me)=>{q(ne),r?.(me)},pe=async(ne,me,he,Te)=>{r?.(!0),he!==""&&((await Te({id:ne,admission_no:me,ec_no:he}))?.Status==="Success"?n.message.success("Ec No updated successfully"):n.message.error("Failed to Update Ec No."))},_e=()=>e.jsx(Jt.Provider,{value:V,children:o}),{trigger:oe}=nt("branchapi/staff/updateStaffPassword",qa),{trigger:le}=nt("branchapi/Student/updateEcNo",qa),{trigger:G}=nt(h,(ne,me)=>qa("student/studentDetails/editStudentLogInCredential",me)),de=async ne=>{ne.preventDefault(),R(!1);try{(await oe({staff_id:j,new_passwod:ne.target.password.value}))?.Status==="Success"?n.message.success("Password updated successfully"):n.message.error("Failed to update password")}catch{n.message.error("Failed to update password")}},Ae=async ne=>{ne.preventDefault(),U(!1);try{(await G({edit_id:C?.edit_id,new_passwod:ne.target.password.value,username:ne.target.username.value,branch_id:JSON.parse(localStorage.getItem("genrall_settings"))?.fk_branchID}))?.Status==="Success"?n.message.success("Password updated successfully"):n.message.error("Failed to update password")}catch(me){n.message.error(me?.response?.data?.msg??"Failed to update password")}},Ee=(Array.isArray(a)?a:[]).some(ne=>ne?.fixed==="left"),Pe=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:m==="antd"&&Ee?"left":void 0,sorter:(ne,me)=>(ne.__serialNumber??0)-(me.__serialNumber??0),render:ne=>ne},...m==="antd"?a:(Array.isArray(a)?a:[]).map(ne=>({title:ne.name,dataIndex:ne.selector,key:ne.selector,sorter:ne.sorter||(ne.sortable?(me,he)=>{const Te=me[ne.selector]??"",Re=he[ne.selector]??"";return typeof Te=="number"&&typeof Re=="number"?Te-Re:String(Te).localeCompare(String(Re))}:!1),render:(me,he)=>{switch(ne.selector){case"my_staff":return he.staff_id!=="0"?he.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(n.Image,{width:50,src:`undefined/branch/gallery/${he.gallery_cat_logo}`});case"file01":return he.documents?e.jsx("div",{onClick:()=>N(`undefined/branch/frontoffice/${he.documents}`),style:{textDecoration:"underline",color:"blue",cursor:"pointer"},children:"view file"}):"Not Uploaded";case"amount":case"fine_amount":case"basic_pay":case"net_amount":return _t(me);case"full_name":return e.jsx("span",{onClick:()=>te(he),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:me||`${he.firstname} ${he.lastname}`});case"extra_curricular_activity":return me==="Yes"?"Extra Subject":"Fees Master";case"is_active":return me==="yes"?e.jsx("span",{className:"label label-success",children:"Active"}):e.jsx("span",{className:"label label-danger",children:"Inactive"});case"steps":return he?.current_status==="Active"?e.jsx(n.Progress,{percent:he.steps==="1"?30:he.steps==="2"?70:100,steps:3}):e.jsx("span",{className:"label label-success",children:he?.current_status});case"Password":return e.jsx("span",{onClick:()=>W(he.id,he),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return e.jsx("span",{onClick:()=>se(he.id,he),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return e.jsx(n.Tag,{onClick:()=>p?.(he.id),color:me==="paid"?"#66aa18":me==="partially_paid"?"#ff5722":"#DC143C",children:me==="paid"?"Paid":me==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return hc().find(Te=>Te.value===me)?.label;case"status":return e.jsx("span",{onClick:()=>p?.(he?.fk_staffID,he?.total_leave),className:`label ${me==="due"?"label-danger":"label-success"}`,style:{cursor:"pointer"},children:me==="due"?"Due":"Paid"});case"subject_type_1":return e.jsxs(e.Fragment,{children:[he.is_theory==="yes"&&"Theory, ",he.is_practical==="yes"&&"Practical"]});case"ec_no":return e.jsx(Ro,{html:he.ec_no,onBlur:Te=>pe(he.id,he.admission_no,Te.target.innerHTML,le)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(n.Button,{type:"primary",icon:e.jsx(Z.SendOutlined,{}),size:"small",onClick:()=>ie(he.id,!0,ne.name),children:ne.name});case"Button":return e.jsx(n.Tag,{color:"cyan",onClick:()=>p?.(he),children:ne.name});default:return me}}})),...s?[{title:"Action",key:"action",render:(ne,me)=>{const he=me?.current_status==="Promoted",Te=()=>{if(_=="sameAddUpdate"){ie(me,!0);return}if(_?.type==="examEdit"){_.editFunc(me.id);return}ie(me.id||me,!0)},Re=()=>{if(_==="student_result"){p?.(me);return}if(_==="student"){p?.(me.id,me.class_id);return}p?.(me.id)},bt=()=>{g?.(me?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[u?.[0]?.status&&e.jsx(n.Button,{icon:e.jsx(Z.EditOutlined,{}),size:"small",disabled:he,onClick:Te}),u?.[1]?.status&&e.jsx(n.Button,{icon:e.jsx(Z.DeleteOutlined,{}),size:"small",danger:!0,disabled:he,onClick:bt}),u?.[2]?.status&&e.jsx(n.Button,{icon:e.jsx(Z.EyeOutlined,{}),size:"small",onClick:Re})]})}}]:[]],ze=i.useMemo(()=>l?Array.isArray(l?.data)?l.data:Array.isArray(l)?l:[]:[],[l]),Fe=i.useMemo(()=>{const ne=M.trim().toLowerCase();return ne?ze.filter(me=>Object.values(me??{}).some(he=>String(he??"").toLowerCase().includes(ne))):ze},[ze,M]),tt=!!t.parentCallback,Ke=M?Fe.length:l?.pagination?.total_rows??Fe.length,Ue=(P.page-1)*P.rowsPerPage,Ge=tt?Fe:Fe.slice(Ue,Ue+P.rowsPerPage),dt=i.useMemo(()=>(Ge??[]).map((ne,me)=>({...ne??{},__serialNumber:Ue+me+1})),[Ue,Ge]),fe=Ke===0?0:Math.min(Ue+1,Ke),xe=Ke===0?0:Math.min(Ue+Ge.length,Ke);let ge;return d?ge=e.jsx("p",{children:"Loading..."}):c?ge=e.jsx("p",{children:c.message}):Ge.length?ge=e.jsx(n.Table,{dataSource:dt,columns:Pe,size:"small",bordered:!0,pagination:!1,rowSelection:x,rowKey:(ne,me)=>ne?.id??ne?._id??me,scroll:{x:"max-content"}}):ge=e.jsx(n.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(n.Drawer,{open:f,placement:"right",onClose:()=>r?.(!1),width:720,children:_e()}),e.jsx(n.Modal,{title:"Update Password",open:A,onCancel:()=>R(!1),footer:null,children:e.jsx("form",{onSubmit:de,children:e.jsxs(F,{children:[e.jsx(F,{style:{marginBottom:12},children:e.jsx(Y,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(F,{style:{marginTop:16},children:e.jsx(n.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(n.Modal,{title:" Update Credential",open:z,onCancel:()=>U(!1),footer:null,children:e.jsx("form",{onSubmit:Ae,children:e.jsxs(F,{children:[e.jsx(F,{style:{marginBottom:12},children:e.jsx(Y,{type:"text",label:"User Name",name:"username",required:"required",value:C?.username?C?.username:"",onChange:ne=>b({...C,username:ne.target.value})})}),e.jsx(F,{style:{marginBottom:12},children:e.jsx(Y,{label:"Password",name:"password",required:"required",value:C?.password?C?.password:"",onChange:ne=>b({...C,password:ne.target.value})})}),e.jsx(F,{style:{marginTop:16},children:e.jsx(n.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(n.Modal,{open:I,onCancel:E,footer:null,centered:!0,width:"80%",className:T.modal,children:e.jsxs("div",{style:{position:"relative"},className:T.img,children:[e.jsx(n.Image,{src:y,alt:"",style:{width:"100%"},preview:!1}),e.jsx(n.Button,{type:"text",icon:e.jsx(Z.CloseOutlined,{}),onClick:E,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),e.jsxs(n.Card,{bodyStyle:{padding:16,background:"#f7f7fa"},children:[e.jsx("style",{children:`
16
+ `),null));return(0,s.renderToString)(a.default.createElement("table",null,a.default.createElement("tbody",null,c,y)))}return ta.default=o,ta}var Hr;function cu(){return Hr||(Hr=1,(function(t){var a=Aa&&Aa.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(t,"__esModule",{value:!0}),t.createTable=t.template=t.uri=t.format=t.base64=void 0;function s(l){return window.btoa(unescape(encodeURIComponent(l)))}t.base64=s;function r(l,d){return l.replace(/{(\w+)}/g,(c,y)=>d[y])}t.format=r,t.uri="data:application/vnd.ms-excel;base64,",t.template='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>{table}</body></html>';var o=du();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return a(o).default}})})(Aa)),Aa}var Kr;function Go(){if(Kr)return ht;Kr=1;var t=ht&&ht.__createBinding||(Object.create?(function(h,u,p,w){w===void 0&&(w=p);var v=Object.getOwnPropertyDescriptor(u,p);(!v||("get"in v?!u.__esModule:v.writable||v.configurable))&&(v={enumerable:!0,get:function(){return u[p]}}),Object.defineProperty(h,w,v)}):(function(h,u,p,w){w===void 0&&(w=p),h[w]=u[p]})),a=ht&&ht.__setModuleDefault||(Object.create?(function(h,u){Object.defineProperty(h,"default",{enumerable:!0,value:u})}):function(h,u){h.default=u}),s=ht&&ht.__importStar||function(h){if(h&&h.__esModule)return h;var u={};if(h!=null)for(var p in h)p!=="default"&&Object.prototype.hasOwnProperty.call(h,p)&&t(u,h,p);return a(u,h),u};Object.defineProperty(ht,"__esModule",{value:!0}),ht.downloadExcel=ht.excel=void 0;const r=s(cu());function o(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function l(h,u){const p=window.document.createElement("a");return p.href=r.uri+r.base64(r.format(r.template,u)),p.download=h,document.body.appendChild(p),p.click(),document.body.removeChild(p),!0}function d(h,u){if(h)return h.cloneNode(!0).outerHTML;if(u)return r.createTable(u);console.error("currentTableRef or tablePayload does not exist")}function c({fileName:h,sheet:u,tablePayload:p},w){if(!o())return!1;const v=d(w,p);return l(h,{worksheet:u||"Worksheet",table:v})}ht.downloadExcel=c;function y({currentTableRef:h,filename:u,sheet:p}){function w(){if(!o())return!1;const v=d(h),b=`${u}.xls`;return l(b,{worksheet:p||"Worksheet",table:v})}return{onDownload:w}}return ht.excel=y,ht}var Gr;function uu(){if(Gr)return Ca;Gr=1,Object.defineProperty(Ca,"__esModule",{value:!0}),Ca.useDownloadExcel=void 0;const t=i,a=Go();function s({currentTableRef:r,filename:o,sheet:l}){const[d,c]=(0,t.useState)({});return(0,t.useEffect)(()=>{c({currentTableRef:r,filename:o,sheet:l})},[r,o,l]),(0,t.useMemo)(()=>(0,a.excel)(d),[d])}return Ca.useDownloadExcel=s,Ca}var Jr;function pu(){return Jr||(Jr=1,(function(t){var a=_a&&_a.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(t,"__esModule",{value:!0}),t.downloadExcel=t.useDownloadExcel=t.DownloadTableExcel=void 0;const s=a(i),r=uu();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return r.useDownloadExcel}});const o=Go();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return o.downloadExcel}});const l=({currentTableRef:d,filename:c,sheet:y,children:h})=>{const{onDownload:u}=(0,r.useDownloadExcel)({currentTableRef:d,filename:c,sheet:y});return s.default.createElement("span",{onClick:u},h)};t.DownloadTableExcel=l})(_a)),_a}var Jo=pu();const St=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:a}=t.data;t?.tableRef;const s=new Date().getTime(),r=xa.useReactToPrint({content:()=>a.current});return e.jsx(e.Fragment,{children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(n.Row,{gutter:8,children:[e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",icon:e.jsx(te.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(n.Col,{children:e.jsx(Jo.DownloadTableExcel,{filename:s,sheet:"users",currentTableRef:a.current,children:e.jsx(n.Button,{type:"text",icon:e.jsx(te.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},Ot=t=>{const{tableRef:a}=t;return new Date().getTime(),e.jsx(e.Fragment,{children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},At=i.createContext(),mu=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),Re=t=>{const{columns:a,action:s,DrawerUpdate:r,editDesign:o,newData:l,Loading:d,error:c,deleteTodoMutation:y,open:h,ActionView:u,viewDetails:p,myType:w,type:v,urlkey:b,columnstype:m,rowSelection:j}=t.data,D=mu(),[I,k]=i.useState(!1),[S,x]=i.useState(null),[g,C]=i.useState("false"),[T,R]=i.useState(!1),[L,N]=i.useState(!1),[f,P]=i.useState(),[O,$]=i.useState(""),F=()=>k(!1),U=se=>{C(se),k(!0)},[V,q]=i.useState(),[E,M]=i.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),B=i.useRef(null),z=(se,me)=>{t.parentCallback?.(se,me),M({rowsPerPage:me,page:se})},G=(se,me)=>{x(me),R(!0),P(se)},re=(se,me)=>{x(me),N(!0),P(se)},K=t?.data?.onNavigate??t?.onNavigate,J=(se,me)=>{if(typeof K=="function"){K(se,me);return}typeof window<"u"&&typeof se=="string"&&se.length>0&&window.location.assign(se)},ae=se=>{if(v==="staff"){J(`/HumanResourceDashboard/StaffFullInformation?id=${se.fk_staffID}`,se);return}J(`/StudentInformation/StudentFullInformation?id=${se.id}`,se)},oe=(se,me)=>{q(se),r?.(me)},pe=async(se,me,ge,ie)=>{r?.(!0),ge!==""&&((await ie({id:se,admission_no:me,ec_no:ge}))?.Status==="Success"?n.message.success("Ec No updated successfully"):n.message.error("Failed to Update Ec No."))},_e=()=>e.jsx(At.Provider,{value:V,children:o}),{trigger:le}=tt("branchapi/staff/updateStaffPassword",za),{trigger:de}=tt("branchapi/Student/updateEcNo",za),{trigger:Q}=tt(b,(se,me)=>za("student/studentDetails/editStudentLogInCredential",me)),ce=async se=>{se.preventDefault(),R(!1);try{(await le({staff_id:f,new_passwod:se.target.password.value}))?.Status==="Success"?n.message.success("Password updated successfully"):n.message.error("Failed to update password")}catch{n.message.error("Failed to update password")}},Te=async se=>{se.preventDefault(),N(!1);try{(await Q({edit_id:S?.edit_id,new_passwod:se.target.password.value,username:se.target.username.value,branch_id:JSON.parse(localStorage.getItem("genrall_settings"))?.fk_branchID}))?.Status==="Success"?n.message.success("Password updated successfully"):n.message.error("Failed to update password")}catch(me){n.message.error(me?.response?.data?.msg??"Failed to update password")}},$e=(Array.isArray(a)?a:[]).some(se=>se?.fixed==="left"),ke=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:m==="antd"&&$e?"left":void 0,sorter:(se,me)=>(se.__serialNumber??0)-(me.__serialNumber??0),render:se=>se},...m==="antd"?a:(Array.isArray(a)?a:[]).map(se=>({title:se.name,dataIndex:se.selector,key:se.selector,sorter:se.sorter||(se.sortable?(me,ge)=>{const ie=me[se.selector]??"",ye=ge[se.selector]??"";return typeof ie=="number"&&typeof ye=="number"?ie-ye:String(ie).localeCompare(String(ye))}:!1),render:(me,ge)=>{switch(se.selector){case"my_staff":return ge.staff_id!=="0"?ge.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(n.Image,{width:50,src:`undefined/branch/gallery/${ge.gallery_cat_logo}`});case"file01":return ge.documents?e.jsx("div",{onClick:()=>U(`undefined/branch/frontoffice/${ge.documents}`),style:{textDecoration:"underline",color:"blue",cursor:"pointer"},children:"view file"}):"Not Uploaded";case"amount":case"fine_amount":case"basic_pay":case"net_amount":return Tt(me);case"full_name":return e.jsx("span",{onClick:()=>ae(ge),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:me||`${ge.firstname} ${ge.lastname}`});case"extra_curricular_activity":return me==="Yes"?"Extra Subject":"Fees Master";case"is_active":return me==="yes"?e.jsx("span",{className:"label label-success",children:"Active"}):e.jsx("span",{className:"label label-danger",children:"Inactive"});case"steps":return ge?.current_status==="Active"?e.jsx(n.Progress,{percent:ge.steps==="1"?30:ge.steps==="2"?70:100,steps:3}):e.jsx("span",{className:"label label-success",children:ge?.current_status});case"Password":return e.jsx("span",{onClick:()=>G(ge.id,ge),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return e.jsx("span",{onClick:()=>re(ge.id,ge),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return e.jsx(n.Tag,{onClick:()=>p?.(ge.id),color:me==="paid"?"#66aa18":me==="partially_paid"?"#ff5722":"#DC143C",children:me==="paid"?"Paid":me==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return lu().find(ie=>ie.value===me)?.label;case"status":return e.jsx("span",{onClick:()=>p?.(ge?.fk_staffID,ge?.total_leave),className:`label ${me==="due"?"label-danger":"label-success"}`,style:{cursor:"pointer"},children:me==="due"?"Due":"Paid"});case"subject_type_1":return e.jsxs(e.Fragment,{children:[ge.is_theory==="yes"&&"Theory, ",ge.is_practical==="yes"&&"Practical"]});case"ec_no":return e.jsx(Ho,{html:ge.ec_no,onBlur:ie=>pe(ge.id,ge.admission_no,ie.target.innerHTML,de)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(n.Button,{type:"primary",icon:e.jsx(te.SendOutlined,{}),size:"small",onClick:()=>oe(ge.id,!0,se.name),children:se.name});case"Button":return e.jsx(n.Tag,{color:"cyan",onClick:()=>p?.(ge),children:se.name});default:return typeof se.render=="function"?se.render(me,ge):me}}})),...s?[{title:"Action",key:"action",render:(se,me)=>{const ge=me?.current_status==="Promoted",ie=()=>{if(w=="sameAddUpdate"){oe(me,!0);return}if(w?.type==="examEdit"){w.editFunc(me.id);return}oe(me.id||me,!0)},ye=()=>{if(w==="student_result"){p?.(me);return}if(w==="student"){p?.(me.id,me.class_id);return}p?.(me.id)},Ye=()=>{y?.(me?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[u?.[0]?.status&&e.jsx(n.Button,{icon:e.jsx(te.EditOutlined,{}),size:"small",disabled:ge,onClick:ie}),u?.[1]?.status&&e.jsx(n.Button,{icon:e.jsx(te.DeleteOutlined,{}),size:"small",danger:!0,disabled:ge,onClick:Ye}),u?.[2]?.status&&e.jsx(n.Button,{icon:e.jsx(te.EyeOutlined,{}),size:"small",onClick:ye})]})}}]:[]],Ve=i.useMemo(()=>l?Array.isArray(l?.data)?l.data:Array.isArray(l)?l:[]:[],[l]),Le=i.useMemo(()=>{const se=O.trim().toLowerCase();return se?Ve.filter(me=>Object.values(me??{}).some(ge=>String(ge??"").toLowerCase().includes(se))):Ve},[Ve,O]),at=!!t.parentCallback,Ge=O?Le.length:l?.pagination?.total_rows??Le.length,Fe=(E.page-1)*E.rowsPerPage,Je=at?Le:Le.slice(Fe,Fe+E.rowsPerPage),rt=i.useMemo(()=>(Je??[]).map((se,me)=>({...se??{},__serialNumber:Fe+me+1})),[Fe,Je]),fe=Ge===0?0:Math.min(Fe+1,Ge),je=Ge===0?0:Math.min(Fe+Je.length,Ge);let be;return d?be=e.jsx("p",{children:"Loading..."}):c?be=e.jsx("p",{children:c.message}):Je.length?be=e.jsx(n.Table,{dataSource:rt,columns:ke,size:"small",bordered:!0,pagination:!1,rowSelection:j,rowKey:(se,me)=>se?.id??se?._id??me,scroll:{x:"max-content"}}):be=e.jsx(n.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(n.Drawer,{open:h,placement:"right",onClose:()=>r?.(!1),width:720,children:_e()}),e.jsx(n.Modal,{title:"Update Password",open:T,onCancel:()=>R(!1),footer:null,children:e.jsx("form",{onSubmit:ce,children:e.jsxs(A,{children:[e.jsx(A,{style:{marginBottom:12},children:e.jsx(Y,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(A,{style:{marginTop:16},children:e.jsx(n.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(n.Modal,{title:" Update Credential",open:L,onCancel:()=>N(!1),footer:null,children:e.jsx("form",{onSubmit:Te,children:e.jsxs(A,{children:[e.jsx(A,{style:{marginBottom:12},children:e.jsx(Y,{type:"text",label:"User Name",name:"username",required:"required",value:S?.username?S?.username:"",onChange:se=>x({...S,username:se.target.value})})}),e.jsx(A,{style:{marginBottom:12},children:e.jsx(Y,{label:"Password",name:"password",required:"required",value:S?.password?S?.password:"",onChange:se=>x({...S,password:se.target.value})})}),e.jsx(A,{style:{marginTop:16},children:e.jsx(n.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(n.Modal,{open:I,onCancel:F,footer:null,centered:!0,width:"80%",className:D.modal,children:e.jsxs("div",{style:{position:"relative"},className:D.img,children:[e.jsx(n.Image,{src:g,alt:"",style:{width:"100%"},preview:!1}),e.jsx(n.Button,{type:"text",icon:e.jsx(te.CloseOutlined,{}),onClick:F,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),e.jsxs(n.Card,{bodyStyle:{padding:16,background:"#f7f7fa"},children:[e.jsx("style",{children:`
17
17
  .ubk-table-shell .ant-table-wrapper {
18
18
  background: #fff;
19
19
  border: 1px solid #e7e8f2;
@@ -56,6 +56,6 @@ Valid keys: `+JSON.stringify(Object.keys(P),null," "));var oe=_e(K,pe,W,se,Q+".
56
56
  .ubk-table-shell .ant-pagination .ant-pagination-next button:hover {
57
57
  color: #8f99ff;
58
58
  }
59
- `}),e.jsx(F,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(xt,{data:{tableRef:L}})})}),e.jsxs("div",{className:"ubk-table-shell",ref:L,style:{marginTop:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,flexWrap:"wrap",marginBottom:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"#222"},children:[e.jsx("span",{children:"Show"}),e.jsx(n.Select,{size:"small",value:P.rowsPerPage,onChange:ne=>B(1,ne),options:[10,25,50,100].map(ne=>({label:ne,value:ne})),style:{width:72}}),e.jsx("span",{children:"entries"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:12,color:"#222"},children:"Search:"}),e.jsx(n.Input,{size:"small",allowClear:!0,value:M,onChange:ne=>{$(ne.target.value),D(me=>({...me,page:1}))},placeholder:"Enter search keyword",prefix:e.jsx(Z.SearchOutlined,{style:{color:"#a3a8cf"}}),style:{width:220,borderWidth:"0 0 1px 0",borderRadius:0,background:"transparent"}})]})]}),e.jsx("div",{className:"print-only",children:e.jsx(It,{})}),ge]}),l&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,marginTop:16,flexWrap:"wrap"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:`Showing ${fe} to ${xe} of ${Ke} entries`}),e.jsx(n.Pagination,{current:P.page,pageSize:P.rowsPerPage,total:Ke||0,showSizeChanger:!1,onChange:B})]})]})]})},vc=({token:t,type:a})=>{const[s,r]=i.useState({page:1,rowsPerPage:10}),o="api/branchapi/frontoffice/enquirytablelist",l=o.includes("?")?o.endsWith("?")||o.endsWith("&")?"":"&":"?",d=`${o}${l}page=${s.page}&per_page=${s.rowsPerPage}`,{isLoading:c,data:g,error:f}=H(t?[d,t]:null,([I,k])=>X(I,k)),[u,p]=i.useState(!1),_=(I,k)=>{r({page:I,rowsPerPage:parseInt(k)})},v=async I=>{},h=I=>{console.log("dsdsdsdsd",I),p(I)},m=()=>{},x=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],T=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(I,k)=>I.name.localeCompare(k.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(I,k)=>(I.contact||"").localeCompare(k.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(I,k)=>(I.description||"").localeCompare(k.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(I,k)=>(I.source_name||"").localeCompare(k.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(I,k)=>new Date(I.date)-new Date(k.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(I,k)=>new Date(I.follow_up_date)-new Date(k.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Me,{parentCallback:_,data:{newData:g,columns:T,action:!0,Loading:c,error:f,open:u,viewDetails:m,deleteTodoMutation:v,DrawerUpdate:h,ActionView:x}})})};var _c=To();const js=wo(_c),Po=()=>{};class Zs extends i.Component{state={value:this.props.value||this.props.defaultValue||""};selectRef=null;setSelectRef=a=>{this.selectRef=a};componentDidUpdate(a){a.value!==this.props.value&&this.setState({value:this.props.value})}onChange=(a,s)=>{this.props.onChange(a,s),this.setState({value:a})};getValue=()=>{const{value:a}=this.state;return a?Array.isArray(a)?a.length?"valid":"":typeof a=="object"?a.value||"":a:""};render(){const{SelectComponent:a,required:s,...r}=this.props;console.log("sdsdsfsdddddddd",{...r});const{isDisabled:o}=this.props,l=!o;return e.jsxs("div",{children:[e.jsx(a,{...r,ref:this.setSelectRef,onChange:this.onChange}),l&&e.jsx("input",{tabIndex:-1,autoComplete:"off",style:{opacity:0,width:"100%",height:0,display:"block"},value:this.getValue(),onChange:Po,onFocus:()=>this.selectRef.focus(),required:s})]})}}Zs.defaultProps={onChange:Po};Zs.protoTypes={selectComponent:js.func.isRequired,onChange:js.func,required:js.bool};const wc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Cc={menuPortal:t=>({...t,zIndex:9999}),control:(t,a)=>({...t,minHeight:40,height:40,fontSize:"14px",border:"none",borderBottom:`1px solid ${a.isFocused?"#222":"#d9d9d9"}`,borderRadius:0,boxShadow:"none",backgroundColor:"transparent",transition:"border-color 0.2s ease","&:hover":{border:"none",borderBottom:`1px solid ${a.isFocused?"#222":"#a8a8a8"}`}}),valueContainer:t=>({...t,height:40,padding:"0 0",display:"flex",alignItems:"center"}),input:t=>({...t,margin:0,padding:0}),indicatorSeparator:()=>({display:"none"}),indicatorsContainer:t=>({...t,height:40}),dropdownIndicator:(t,a)=>({...t,padding:"0 0 0 8px",color:a.isFocused?"#222":"#b5b5b5"}),singleValue:t=>({...t,color:"#222",marginLeft:0}),placeholder:t=>({...t,color:"#9f9f9f",marginLeft:0}),option:(t,a)=>({...t,fontSize:"14px",backgroundColor:a.isFocused?"#f8f8f8":"#fff",color:"#222",cursor:"pointer"})},Oo=t=>e.jsx(Xi.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),Ac=t=>e.jsx(Zs,{...t,SelectComponent:Xi,components:{Input:Oo},options:t.options}),ee=i.forwardRef(({...t},a)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:wc,children:t?.label}),e.jsx(Ac,{components:{Input:Oo},menuPortalTarget:document.body,styles:Cc,className:"input-cont",...t,ref:a})]})),Tc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Rc={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Dc=(t,a,s)=>a?t>ae(s).endOf("day")||t<ae(a).endOf("day"):!1,Le=i.forwardRef(function(a,s){const{...r}=a;return e.jsxs("div",{className:"form-group",children:[r.Desplay&&e.jsx("label",{className:`labelfont ${r.classnme?r.classnme:""}`,style:Tc,children:r.Desplay}),e.jsx(n.DatePicker,{...r,style:{...Rc,...r.style||{}},className:"form-group",disabledDate:o=>Dc(o,r.sessionStart||r.minDate?.subtract(1,"day").format("YYYY-MM-DD"),r.sessionEnd||r.maxDate?.format("YYYY-MM-DD")),required:!0,ref:s})]})}),Ic={minWidth:160,height:36,padding:"0 28px",border:"none",borderRadius:999,background:"linear-gradient(90deg, #f59b1c 0%, #ef3e7b 100%)",color:"#fff",fontSize:14,fontWeight:700,textTransform:"uppercase",cursor:"pointer",boxShadow:"none"},re=i.forwardRef(({error:t,success:a,disabled:s,style:r,...o},l)=>e.jsx("div",{className:"form-group",style:{marginBottom:0},children:e.jsx("input",{...o,ref:l,disabled:s,style:{...Ic,opacity:s?.7:1,cursor:s?"not-allowed":"pointer",...r||{}}})})),kc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Pc={width:"100%",minHeight:80,padding:"8px 0",fontSize:"14px",color:"#222",background:"transparent",border:0,borderTop:0,borderLeft:0,borderRight:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",outline:"none",resize:"vertical",transition:"border-color 0.2s ease"},wt=({style:t,onFocus:a,onBlur:s,...r})=>{const[o,l]=i.useState(!1);return e.jsxs("div",{style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:kc,children:r.label}),e.jsx("textarea",{placeholder:r.placeholder||r.label,...r,onFocus:d=>{l(!0),a?.(d)},onBlur:d=>{l(!1),s?.(d)},style:{...Pc,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})},Ve=t=>({optimisticData:a=>[...a.data,t],populateCache:(a,s)=>[...s.data,a]}),Be=t=>({optimisticData:a=>a.data.filter(s=>s.id!==t),populateCache:(a,s)=>s.data.filter(r=>r.id!==t)}),Oc=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Mc="api/branchapi/Frontoffice/visitorbookShowdata",Ec="api/branchapi/Frontoffice/purposedropdown";function Fc({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Jt),o=Mc.replace(/\?.*$/,""),{isLoading:l,data:d}=H(s&&r?[o,r,s]:null,([m,x,T])=>Ja(m,{id:x},T)),{isLoading:c,data:g}=H(s?[Ec,s]:null,([m,x])=>X(m,x)),f=i.useMemo(()=>Oc(g),[g]),u=d?.data?.[0],[p,_]=i.useState({purpose:void 0,name:"",phone:"",id_card:"",number_of_person:1,date:null,in_time:null,out_time:null,note:"",address:"",image:""});i.useEffect(()=>{u&&_({purpose:u?.purpose,name:u?.name||"",phone:u?.contact||"",id_card:u?.id_proof||"",number_of_person:u?.no_of_pepple||1,date:u?.date?ae(u.date):null,in_time:u?.in_time?ae(u.in_time,"h:mm a"):null,out_time:u?.out_time?ae(u.out_time,"h:mm a"):null,note:u?.note||"",address:u?.address||"",image:u?.image||""})},[u]);const v=(m,x)=>{_(T=>({...T,[m]:x}))},h=`${et()}/branchapi/frontoffice/uploadfrontofficeDocument`;return l||c?e.jsx(F,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(F,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:m=>a(m,r),children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Visitor"})}),e.jsx(F,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(ee,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",allowSelectAll:!1,value:p.purpose,onChange:m=>v("purpose",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0,value:p.name,onChange:m=>v("name",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"phone",type:"text",label:"Phone No.",required:!0,value:p.phone,onChange:m=>v("phone",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"id_card",type:"text",label:"ID Card",value:p.id_card,onChange:m=>v("id_card",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"number_of_person",type:"number",label:"Number of Person",value:p.number_of_person,onChange:m=>v("number_of_person",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Le,{format:"YYYY-MM-DD",value:p.date,Desplay:"Date",id:"date",name:"date",required:!0,onChange:m=>v("date",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(F,{children:[e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:p.in_time,onChange:m=>v("in_time",m),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:p.in_time?p.in_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(F,{children:[e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:p.out_time,onChange:m=>v("out_time",m),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time",value:p.out_time?p.out_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:p.note,onChange:m=>v("note",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(wt,{type:"text",label:"Address",name:"address",rows:3,required:!0,value:p.address,onChange:m=>v("address",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(F,{children:[e.jsx(n.Upload,{action:h,headers:{Authorization:s},maxCount:1,onChange:m=>{if(m.file.status==="removed"&&v("image",""),m.file.status==="done"){const x=m.file.response?.data??m.file.response?.file??"";v("image",String(x??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:p.image?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:p.image||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(F,{children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; }"})]})}const $c=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},aa="api/branchapi/Frontoffice/visitortablelist",Uc="api/branchapi/Frontoffice/purposedropdown",Nc="api/branchapi/frontoffice/addvisitors",Lc="api/branchapi/frontoffice/editvisitorsdata",Bc="api/branchapi/frontoffice/deletevisitors",qc=`${et()}/branchapi/frontoffice/uploadfrontofficeDocument`;function zc({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,g]=i.useState(""),[f,u]=i.useState("03:30 PM"),p=(j,O)=>{s({page:j,rowsPerPage:Number.parseInt(O,10)})},_=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],v=i.useMemo(()=>{const j=aa.includes("?")?aa.endsWith("?")||aa.endsWith("&")?"":"&":"?";return`${aa}${j}page=${a.page}&per_page=${a.rowsPerPage}`},[aa,a.page,a.rowsPerPage]),{isLoading:h,error:m,data:x,mutate:T}=H(t?[v,t]:null,([j,O])=>X(j,O)),{isLoading:I,data:k}=H(t?[Uc,t]:null,([j,O])=>X(j,O)),C=i.useMemo(()=>$c(k),[k]),b=async(j,O)=>{try{await T($e(j,O,t),Ve(O)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},y=async j=>{try{await T(Ye(Bc,j,t),Be(j)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},S=async(j,O,M)=>{try{const $=await Xe(j,O,t);T($),Array.isArray($?.data)&&T(`${aa.replace(/\?.*$/,"")}?id=${M}`,$),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},A=async(j,O)=>{j.preventDefault();const M=new FormData(j.target);await S(Lc,M,O),j.target.reset(),d(""),o(!1)},R=async j=>{if(j.preventDefault(),!j.target?.date?.value)w.error("Select required dates"),j.target?.date?.focus(),g("textDanger");else{const O=new FormData(j.target);await b(Nc,O),j.target.reset(),g(""),d(""),u("03:30 PM")}},z=j=>{o(j)},U=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Address",selector:"address",sortable:!0},{id:"5",name:"In Time",selector:"in_time",sortable:!0},{id:"6",name:"Out Time",selector:"out_time",sortable:!0}],[]);return e.jsxs("div",{children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Visitor"})}),e.jsx(F,{p:3,children:e.jsx("form",{onSubmit:R,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(ee,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",required:!0,allowSelectAll:!1})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone No.",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"id_card",type:"text",label:"ID Card"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{defaultValue:1,name:"number_of_person",type:"number",label:"Number of Person"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Le,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(F,{children:[e.jsx(n.TimePicker,{defaultValue:ae("2022-04-17T15:30","h:mm a"),id:"in_time",use12Hours:!0,format:"h:mm a",onChange:(j,O)=>u(O),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:f,readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(wt,{type:"text",label:"Address*",name:"address",rows:3,required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(F,{children:[e.jsx(n.Upload,{action:qc,headers:{Authorization:t},maxCount:1,onChange:j=>{if(j.file.status==="removed"&&d(""),j.file.status==="done"){const O=j.file.response?.data??j.file.response?.file??"";d(String(O??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:l?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(F,{children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Visitor List"})}),e.jsx(F,{pt:3,children:e.jsx(Me,{parentCallback:p,data:{newData:x,columns:U,action:!0,ActionView:_,Loading:h,error:m,editDesign:e.jsx(Fc,{data:{handleUpdate:A,token:t}}),deleteTodoMutation:y,open:r,DrawerUpdate:z,viewDetails:""}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Yc="api/branchapi/frontoffice/generalcallsShowdata",Vc=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}];function Wc({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Jt),o=Yc.replace(/\?.*$/,""),{isLoading:l,data:d}=H(s&&r?[o,r,s]:null,([p,_,v])=>Ja(p,{id:_},v)),c=d?.data?.[0],[g,f]=i.useState({name:"",phone:"",description:"",date:null,next_follow_up_date:null,call_duration:"",note:"",call_type:""});i.useEffect(()=>{c&&f({name:c?.name||"",phone:c?.contact||"",description:c?.description||"",date:c?.date?ae(c.date):null,next_follow_up_date:c?.follow_up_date?ae(c.follow_up_date):null,call_duration:c?.call_dureation||"",note:c?.note||"",call_type:c?.call_type||""})},[c]);const u=(p,_)=>{f(v=>({...v,[p]:_}))};return l?e.jsx(F,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(F,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,r),children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Call Log"})}),e.jsx(F,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0,value:g.name,onChange:p=>u("name",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",value:g.phone,onChange:p=>u("phone",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",value:g.description,onChange:p=>u("description",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Le,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Le,{format:"YYYY-MM-DD",value:g.next_follow_up_date,Desplay:"Next Follow Up Date",id:"fdate",name:"next_follow_up_date",onChange:p=>u("next_follow_up_date",p)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"call_duration",type:"text",label:"Call Duration",value:g.call_duration,onChange:p=>u("call_duration",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:g.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(ee,{options:Vc,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:g.call_type?{value:g.call_type,label:g.call_type}:null,onChange:p=>u("call_type",p?.value||"")})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(F,{children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const na="api/branchapi/frontoffice/generalcalltablelist",Hc="api/branchapi/frontoffice/addgenaralcalls",Kc="api/branchapi/frontoffice/editgeneralcall",Gc="api/branchapi/frontoffice/deletegeneralcall",Jc=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}],Qc=[{key:"all",label:"All Calls"},{key:"Incoming",label:"Incoming"},{key:"Outgoing",label:"Outgoing"}];function Xc({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,g]=i.useState(""),[f,u]=i.useState("all"),[p,_]=i.useState(""),v=i.useRef(null),h=(j,O)=>{s({page:j,rowsPerPage:Number.parseInt(O,10)})},m=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],x=i.useMemo(()=>{const j=na.includes("?")?na.endsWith("?")||na.endsWith("&")?"":"&":"?",O=new URLSearchParams;return O.set("page",String(a.page)),O.set("per_page",String(a.rowsPerPage)),f!=="all"&&O.set("call_type",f),`${na}${j}${O.toString()}`},[na,a.page,a.rowsPerPage,f]),{isLoading:T,error:I,data:k,mutate:C}=H(t?[x,t]:null,([j,O])=>X(j,O)),b=async(j,O)=>{try{await C($e(j,O,t),Ve(O)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},y=async j=>{try{await C(Ye(Gc,j,t),Be(j)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},S=async(j,O,M)=>{try{const $=await Xe(j,O,t);C($),Array.isArray($?.data)&&C(`${na.replace(/\?.*$/,"")}?id=${M}`,$),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},A=async(j,O)=>{j.preventDefault();const M=new FormData(j.target);await S(Kc,M,O),j.target.reset(),d(""),o(!1)},R=async j=>{if(j.preventDefault(),!j.target?.date?.value)w.error("Select required dates"),j.target?.date?.focus(),g("textDanger");else{const O=new FormData(j.target);await b(Hc,O),j.target.reset(),g(""),d(""),_("")}},z=j=>{o(j)},U=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Phone",selector:"contact",sortable:!0},{id:"3",name:"Description",selector:"description",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Follow Up Date",selector:"follow_up_date",sortable:!0},{id:"6",name:"Call Duration",selector:"call_dureation",sortable:!0}],[]);return e.jsxs(F,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Phone Call Log"})}),e.jsx(F,{p:3,children:e.jsx("form",{onSubmit:R,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Le,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Le,{format:"YYYY-MM-DD",Desplay:"Next Follow Up Date",id:"fdate",name:"follow_up_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"call_dureation",type:"text",label:"Call Duration"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(ee,{options:Jc,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:p?{value:p,label:p}:null,onChange:j=>_(j?.value||"")})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(F,{children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Phone Call Log List"})}),e.jsxs(F,{pt:3,children:[e.jsx(n.Tabs,{activeKey:f,onChange:u,items:Qc}),e.jsx(xt,{data:{tableRef:v}}),e.jsx(Me,{parentCallback:h,data:{newData:k,columns:U,action:!0,ActionView:m,Loading:T,error:I,editDesign:e.jsx(Wc,{data:{handleUpdate:A,token:t}}),deleteTodoMutation:y,open:r,DrawerUpdate:z,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Zc="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function eu({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Jt),o=Zc.replace(/\?.*$/,""),{isLoading:l,data:d}=H(s&&r?[o,r,s]:null,([p,_,v])=>Ja(p,{id:_},v)),c=d?.data?.[0],[g,f]=i.useState({to_title:"",refernce:"",address:"",note:"",from_title:"",date:null,image:""});i.useEffect(()=>{c&&f({to_title:c?.to_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",from_title:c?.from_title||"",date:c?.date?ae(c.date):null,image:c?.image||""})},[c]);const u=(p,_)=>{f(v=>({...v,[p]:_}))};return l?e.jsx(F,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(F,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,r),children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Dispatch"})}),e.jsx(F,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"title",type:"text",label:"To Title *",required:!0,value:g.to_title,onChange:p=>u("to_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"refernce",type:"text",label:"Reference No",value:g.refernce,onChange:p=>u("refernce",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"address",type:"text",label:"Address",required:!0,value:g.address,onChange:p=>u("address",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:g.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"from_title",type:"text",label:"From Title",required:!0,value:g.from_title,onChange:p=>u("from_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Le,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(F,{children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const sa="api/branchapi/frontoffice/postaldispatchtablelist",tu="api/branchapi/frontoffice/addpostaldispatch",au="api/branchapi/frontoffice/editpostaldispatch",nu="api/branchapi/frontoffice/deletepostalreceivedispatch";function su({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,g]=i.useState(""),f=i.useRef(null),u=(A,R)=>{s({page:A,rowsPerPage:Number.parseInt(R,10)})},p=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],_=i.useMemo(()=>{const A=sa.includes("?")?sa.endsWith("?")||sa.endsWith("&")?"":"&":"?";return`${sa}${A}page=${a.page}&per_page=${a.rowsPerPage}`},[sa,a.page,a.rowsPerPage]),{isLoading:v,error:h,data:m,mutate:x}=H(t?[_,t]:null,([A,R])=>X(A,R)),T=async(A,R)=>{try{await x($e(A,R,t),Ve(R)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},I=async A=>{try{await x(Ye(nu,A,t),Be(A)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},k=async(A,R,z)=>{try{const U=await Xe(A,R,t);x(U),Array.isArray(U?.data)&&x(`${sa.replace(/\?.*$/,"")}?id=${z}`,U),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},C=async(A,R)=>{A.preventDefault();const z=new FormData(A.target);await k(au,z,R),A.target.reset(),d(""),o(!1)},b=async A=>{if(A.preventDefault(),!A.target?.date?.value)w.error("Select required dates"),A.target?.date?.focus(),g("textDanger");else{const R=new FormData(A.target);await T(tu,R),A.target.reset(),g(""),d("")}},y=A=>{o(A)},S=i.useMemo(()=>[{id:"1",name:"To Title",selector:"to_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"From Title",selector:"from_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(F,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Dispatch"})}),e.jsx(F,{p:3,children:e.jsx("form",{onSubmit:b,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{required:!0,name:"title",type:"text",label:"To Title *"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{required:!0,name:"from_title",type:"text",label:"From Title"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Le,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(F,{children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Dispatch List"})}),e.jsxs(F,{pt:3,children:[e.jsx(xt,{data:{tableRef:f}}),e.jsx(Me,{parentCallback:u,data:{newData:m,columns:S,action:!0,ActionView:p,Loading:v,error:h,editDesign:e.jsx(eu,{data:{handleUpdate:C,token:t}}),deleteTodoMutation:I,open:r,DrawerUpdate:y,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const ru="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function iu({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Jt),o=ru.replace(/\?.*$/,""),{isLoading:l,data:d}=H(s&&r?[o,r,s]:null,([p,_,v])=>Ja(p,{id:_},v)),c=d?.data?.[0],[g,f]=i.useState({from_title:"",refernce:"",address:"",note:"",title:"",date:null,image:""});i.useEffect(()=>{c&&f({from_title:c?.from_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",title:c?.to_title||"",date:c?.date?ae(c.date):null,image:c?.image||""})},[c]);const u=(p,_)=>{f(v=>({...v,[p]:_}))};return l?e.jsx(F,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(F,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,r),children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Receive"})}),e.jsx(F,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"from_title",type:"text",label:"From Title *",required:!0,value:g.from_title,onChange:p=>u("from_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"refernce",type:"text",label:"Reference No",required:!0,value:g.refernce,onChange:p=>u("refernce",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"address",type:"text",label:"Address",required:!0,value:g.address,onChange:p=>u("address",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:g.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"title",type:"text",label:"To Title",required:!0,value:g.title,onChange:p=>u("title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Le,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(F,{children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const ra="api/branchapi/frontoffice/postalrecivetablelist",ou="api/branchapi/frontoffice/addpostalrecive",lu="api/branchapi/frontoffice/editpostalrecive",du="api/branchapi/frontoffice/deletepostalreceivedispatch";function cu({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,g]=i.useState(""),f=i.useRef(null),u=(A,R)=>{s({page:A,rowsPerPage:Number.parseInt(R,10)})},p=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],_=i.useMemo(()=>{const A=ra.includes("?")?ra.endsWith("?")||ra.endsWith("&")?"":"&":"?";return`${ra}${A}page=${a.page}&per_page=${a.rowsPerPage}`},[ra,a.page,a.rowsPerPage]),{isLoading:v,error:h,data:m,mutate:x}=H(t?[_,t]:null,([A,R])=>X(A,R)),T=async(A,R)=>{try{await x($e(A,R,t),Ve(R)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},I=async A=>{try{await x(Ye(du,A,t),Be(A)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},k=async(A,R,z)=>{try{const U=await Xe(A,R,t);x(U),Array.isArray(U?.data)&&x(`${ra.replace(/\?.*$/,"")}?id=${z}`,U),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},C=async(A,R)=>{A.preventDefault();const z=new FormData(A.target);await k(lu,z,R),A.target.reset(),d(""),o(!1)},b=async A=>{if(A.preventDefault(),!A.target?.date?.value)w.error("Select required dates"),A.target?.date?.focus(),g("textDanger");else{const R=new FormData(A.target);await T(ou,R),A.target.reset(),g(""),d("")}},y=A=>{o(A)},S=i.useMemo(()=>[{id:"1",name:"From Title",selector:"from_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"To Title",selector:"to_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(F,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Receive"})}),e.jsx(F,{p:3,children:e.jsx("form",{onSubmit:b,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{required:!0,name:"from_title",type:"text",label:"From Title *"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{required:!0,name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{required:!0,name:"title",type:"text",label:"To Title"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Le,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(F,{children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Receive List"})}),e.jsxs(F,{pt:3,children:[e.jsx(xt,{data:{tableRef:f}}),e.jsx(Me,{parentCallback:u,data:{newData:m,columns:S,action:!0,ActionView:p,Loading:v,error:h,editDesign:e.jsx(iu,{data:{handleUpdate:C,token:t}}),deleteTodoMutation:I,open:r,DrawerUpdate:y,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const uu="api/branchapi/frontoffice/complaintShowdata",pu="api/branchapi/frontoffice/complainttypedropdown",mu=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function fu({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Jt),o=uu.replace(/\?.*$/,""),{isLoading:l,data:d}=H(s&&r?[o,r,s]:null,([m,x,T])=>Ja(m,{id:x},T)),{isLoading:c,data:g}=H(s?[pu,s]:null,([m,x])=>X(m,x)),f=i.useMemo(()=>mu(g).map(x=>({value:x?.value??x?.id??x?.complaint_type??"",label:x?.complaint_type??x?.label??""})),[g]),u=d?.data?.[0],[p,_]=i.useState({complain_type:"",complain_by_name:"",phone:"",date:null,description:"",action_token:"",assigned:"",note:"",file:""});i.useEffect(()=>{u&&_({complain_type:u?.complaint_type??"",complain_by_name:u?.name??"",phone:u?.contact??"",date:u?.date?ae(u.date):null,description:u?.description??"",action_token:u?.action_taken??"",assigned:u?.assigned??"",note:u?.note??"",file:u?.image??""})},[u]);const v=(m,x)=>{_(T=>({...T,[m]:x}))},h=i.useMemo(()=>f.find(m=>m.value===p.complain_type)||null,[f,p.complain_type]);return l||c?e.jsx(F,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsx(F,{pt:4,pb:1,style:{width:550},children:e.jsxs("form",{onSubmit:m=>a(m,r),children:[e.jsx("input",{type:"hidden",name:"id",value:r??""}),e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Complaint"})}),e.jsx(F,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(ee,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",allowSelectAll:!1,value:h,onChange:m=>v("complain_type",m?.value??"")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0,value:p.complain_by_name,onChange:m=>v("complain_by_name",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{10}",value:p.phone,onChange:m=>v("phone",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Le,{format:"YYYY-MM-DD",value:p.date,Desplay:"Enquiry Date",id:"date",name:"date",onChange:m=>v("date",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",value:p.description,onChange:m=>v("description",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"action_token",type:"text",label:"Action Taken",value:p.action_token,onChange:m=>v("action_token",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"assigned",type:"text",label:"Assigned",value:p.assigned,onChange:m=>v("assigned",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:p.note,onChange:m=>v("note",m.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(F,{children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})]})})}const ia="api/branchapi/frontoffice/complainttablelist",yu="api/branchapi/frontoffice/complainttypedropdown",hu="api/branchapi/frontoffice/addcomplaint",gu="api/branchapi/frontoffice/editcomplaint",xu="api/branchapi/frontoffice/deletecomplaint",bu=[{key:"all",label:"All Complaints"},{key:"pending",label:"Pending"},{key:"resolved",label:"Resolved"}];function ju({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,g]=i.useState(""),[f,u]=i.useState("all"),p=i.useRef(null),_=(O,M)=>{s({page:O,rowsPerPage:Number.parseInt(M,10)})},v=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],h=i.useMemo(()=>{const O=ia.includes("?")?ia.endsWith("?")||ia.endsWith("&")?"":"&":"?",M=new URLSearchParams;return M.set("page",String(a.page)),M.set("per_page",String(a.rowsPerPage)),f!=="all"&&M.set("status",f),`${ia}${O}${M.toString()}`},[ia,a.page,a.rowsPerPage,f]),{isLoading:m,error:x,data:T,mutate:I}=H(t?[h,t]:null,([O,M])=>X(O,M)),{isLoading:k,data:C}=H(t?[yu,t]:null,([O,M])=>X(O,M)),b=i.useMemo(()=>{const O=C?.data??C??[];return Array.isArray(O)?O:Array.isArray(O?.data)?O.data:[]},[C]),y=async(O,M)=>{try{await I($e(O,M,t),Ve(M)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},S=async O=>{try{await I(Ye(xu,O,t),Be(O)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},A=async(O,M,$)=>{try{const E=await Xe(O,M,t);I(E),Array.isArray(E?.data)&&I(`${ia.replace(/\?.*$/,"")}?id=${$}`,E),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},R=async(O,M)=>{O.preventDefault();const $=new FormData(O.target);await A(gu,$,M),O.target.reset(),d(""),o(!1)},z=async O=>{if(O.preventDefault(),!O.target?.date?.value)w.error("Select required dates"),O.target?.date?.focus(),g("textDanger");else{const M=new FormData(O.target);await y(hu,M),O.target.reset(),g(""),d("")}},U=O=>{o(O)},j=i.useMemo(()=>[{id:"1",name:"Complain Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Name",selector:"name",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Action Taken",selector:"action_taken",sortable:!0},{id:"6",name:"Assigned",selector:"assigned",sortable:!0}],[]);return e.jsxs(F,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Complaint"})}),e.jsx(F,{p:3,children:e.jsx("form",{onSubmit:z,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(ee,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",required:!0,allowSelectAll:!1})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Le,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Complain Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"action_token",type:"text",label:"Action Taken"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"assigned",type:"text",label:"Assigned"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx("input",{type:"hidden",name:"file",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(F,{children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Complaint List"})}),e.jsxs(F,{pt:3,children:[e.jsx(n.Tabs,{activeKey:f,onChange:u,items:bu}),e.jsx(xt,{data:{tableRef:p}}),e.jsx(Me,{parentCallback:_,data:{newData:T,columns:j,action:!0,ActionView:v,Loading:m,error:x,editDesign:e.jsx(fu,{data:{handleUpdate:R,token:t}}),deleteTodoMutation:S,open:r,DrawerUpdate:U,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Vn="api/branchapi/Frontoffice/purposetablelist",Mo="api/branchapi/Frontoffice/complaint_typetablelist",Eo="api/branchapi/Frontoffice/sourcetablelist",Fo="api/branchapi/Frontoffice/referencetablelist",pa=[{key:"purpose",label:"Purpose"},{key:"complainType",label:"Complain Type"},{key:"source",label:"Source"},{key:"reference",label:"Reference"}],Wr={purpose:[{id:"1",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],complainType:[{id:"1",name:"Complaint Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],source:[{id:"1",name:"Source",selector:"source",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],reference:[{id:"1",name:"Reference",selector:"reference",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}]};function Su({token:t}){const[a,s]=i.useState("purpose"),[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),c=i.useRef(null),g=(R,z)=>{o({page:R,rowsPerPage:Number.parseInt(z,10)})},f=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],u=()=>{switch(a){case"purpose":return Vn;case"complainType":return Mo;case"source":return Eo;case"reference":return Fo;default:return Vn}},p=()=>{switch(a){case"purpose":return"api/branchapi/frontoffice/addvisitors_purpose";case"complainType":return"api/branchapi/frontoffice/addcomplaint_type";case"source":return"api/branchapi/frontoffice/addsource";case"reference":return"api/branchapi/frontoffice/addreference";default:return"api/branchapi/frontoffice/addvisitors_purpose"}},_=R=>{switch(a){case"purpose":return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:R};case"complainType":return{url:"api/branchapi/frontoffice/deletecomplaint_type",id:R};case"source":return{url:"api/branchapi/frontoffice/deletesource",id:R};case"reference":return{url:"api/branchapi/frontoffice/deletereference",id:R};default:return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:R}}},v=i.useMemo(()=>{const R=u(),z=R.includes("?")?R.endsWith("?")||R.endsWith("&")?"":"&":"?";return`${R}${z}page=${r.page}&per_page=${r.rowsPerPage}`},[a,r.page,r.rowsPerPage]),{isLoading:h,error:m,data:x,mutate:T}=H(t?[v,t]:null,([R,z])=>X(R,z)),I=async(R,z)=>{try{await T($e(R,z,t),Ve(z)),w.success("Success! Added new item.")}catch{w.error("Failed to add the new item.")}},k=async R=>{const{url:z,id:U}=_(R);try{await T(Ye(z,U,t),Be(U)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},C=async(R,z,U)=>{try{const j=await Xe(R,z,t);T(j),Array.isArray(j?.data)&&T(`${u().replace(/\?.*$/,"")}?id=${U}`,j),w.success("Success! Updated item.")}catch{w.error("Failed to update the item.")}},b=async(R,z)=>{R.preventDefault();const U=new FormData(R.target),j=p();await C(j,U,z),R.target.reset(),d(!1)},y=async R=>{R.preventDefault();const z=new FormData(R.target),U=p();await I(U,z),R.target.reset()},S=R=>{d(R)},A=i.useMemo(()=>Wr[a]||Wr.purpose,[a]);return e.jsx(F,{pt:5,pb:1,children:e.jsx(n.Row,{gutter:[16,16],children:e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Setup Front Office"})}),e.jsxs(F,{p:3,children:[e.jsx(n.Tabs,{activeKey:a,onChange:R=>{s(R),o({page:1,rowsPerPage:10})},items:pa}),e.jsxs(n.Row,{gutter:[16,16],mt:3,children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx("form",{onSubmit:y,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Add ",pa.find(R=>R.key===a)?.label]})}),e.jsx(F,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(F,{children:e.jsx(Y,{required:!0,name:"name",type:"text",label:pa.find(R=>R.key===a)?.label+" *"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(F,{children:e.jsx(Y,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(F,{children:e.jsx(re,{type:"submit",value:"Add",color:"primary"})})})})]})})]})})}),e.jsx(n.Col,{xs:24,md:16,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:[pa.find(R=>R.key===a)?.label," List"]})}),e.jsxs(F,{pt:3,children:[e.jsx(xt,{data:{tableRef:c}}),e.jsx(Me,{parentCallback:g,data:{newData:x,columns:A,action:!0,ActionView:f,Loading:h,error:m,editDesign:e.jsx(vu,{data:{handleUpdate:b,token:t,activeTab:a}}),deleteTodoMutation:k,open:l,DrawerUpdate:S,viewDetails:""}})]})]})})]})]})]})})})})}function vu({data:t}){const{handleUpdate:a,token:s,activeTab:r}=t||{},o=i.useContext(Jt),d=(v=>{switch(v){case"purpose":return Vn;case"complainType":return Mo;case"source":return Eo;case"reference":return Fo;default:return Vn}})(r).replace(/\?.*$/,""),{isLoading:c,data:g}=H(s&&o?[d,o,s]:null,([v,h,m])=>getDataById(v,{id:h},m)),f=g?.data?.[0],[u,p]=i.useState({name:"",description:""});i.useEffect(()=>{f&&p({name:f?.visitors_purpose||f?.complaint_type||f?.source||f?.reference||"",description:f?.description||""})},[f]);const _=(v,h)=>{p(m=>({...m,[v]:h}))};return c?e.jsx(F,{pt:4,pb:1,style:{width:350},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(F,{pt:4,pb:1,style:{width:350},children:[e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Edit ",pa.find(v=>v.key===r)?.label]})}),e.jsx(F,{p:3,children:e.jsx("form",{onSubmit:v=>a(v,o),children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(F,{children:e.jsx(Y,{type:"text",value:o,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,children:e.jsx(F,{children:e.jsx(Y,{name:"name",type:"text",label:pa.find(v=>v.key===r)?.label+" *",required:!0,value:u.name,onChange:v=>_("name",v.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(F,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",value:u.description,onChange:v=>_("description",v.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(F,{children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})})})]})})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const _u="api/branchapi/Student/studentGatePass",Ta="api/branchapi/Student/studentGatePassList";function wu({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:25}),[r,o]=i.useState(!1),l=i.useRef(null),d=(k,C)=>{s({page:k,rowsPerPage:Number.parseInt(C,10)})},c=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],{data:g,mutate:f}=H(t?[_u,t]:null,([k,C])=>X(k,C)),u=i.useMemo(()=>{const k=Ta.includes("?")?Ta.endsWith("?")||Ta.endsWith("&")?"":"&":"?";return`${Ta}${k}page=${a.page}&per_page=${a.rowsPerPage}`},[Ta,a.page,a.rowsPerPage]),{isLoading:p,error:_,data:v,mutate:h}=H(t?[u,t]:null,([k,C])=>X(k,C)),m=async k=>{const C="api/branchapi/frontoffice/deletevisitors";try{await h(deleteData(C,k,t),Be(k)),w.success("Success! Deleted item.")}catch{w.error("Failed to delete the item.")}},x=k=>{o(k)},T=()=>{},I=[{title:"Name",dataIndex:"lastname",key:"lastname",render:(k,C)=>`${C?.lastname||""} ${C?.firstname||""}`.trim()},{title:"Class",dataIndex:"class_name",key:"class_name",render:(k,C)=>`${C?.class_name||""}-${C?.section_name||""}`},{title:"Father Name",dataIndex:"father_name",key:"father_name"},{title:"Authorized Persons",dataIndex:"authorized_persons_fullname",key:"authorized_persons_fullname"},{title:"Relation",dataIndex:"authorized_persons_relation",key:"authorized_persons_relation"},{title:"Generated Date",dataIndex:"genrated_date_time",key:"genrated_date_time"},{title:"Return Date",dataIndex:"expected_return_date_time",key:"expected_return_date_time"},{title:"Reason",dataIndex:"reason",key:"reason"},{title:"Action",key:"action",render:(k,C)=>e.jsx(n.Tag,{color:C?.status==="Generated"?"green":"blue",children:C?.status||"Pending"})},{title:"Print",key:"print",render:(k,C)=>e.jsx(Z.PrinterOutlined,{style:{color:"#3892ee",cursor:"pointer"},onClick:()=>window.print()})}];return e.jsx(F,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Today Gate Pass"})}),e.jsx(F,{pt:3,children:e.jsx(n.List,{grid:{column:4,gutter:16},dataSource:g?.data||[],style:{padding:0},renderItem:k=>e.jsx(n.List.Item,{style:{padding:0},children:e.jsx(n.Card,{size:"small",style:{marginBottom:8,width:"100%"},children:e.jsxs(F,{children:[e.jsxs(n.Typography.Text,{strong:!0,children:[k?.lastname," ",k?.firstname]}),e.jsx("br",{}),e.jsxs(n.Typography.Text,{type:"secondary",children:[k?.class_name,"-",k?.section_name]}),e.jsx("br",{}),e.jsxs(n.Typography.Text,{type:"secondary",children:["Return: ",k?.expected_return_date_time]}),e.jsx("br",{}),e.jsx(re,{type:"button",value:"Print",color:"primary",size:"small",onClick:()=>window.print(),style:{marginTop:4}})]})})})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Gate Pass List"})}),e.jsxs(F,{pt:3,children:[e.jsx(xt,{data:{tableRef:l}}),e.jsx(Me,{parentCallback:d,data:{newData:v,columns:I,action:!1,ActionView:c,Loading:p,error:_,editDesign:"",deleteTodoMutation:m,open:r,DrawerUpdate:x,viewDetails:T}})]})]})})]})})}const mt=({id:t,funcName:a,disabled:s=!1})=>{const r="Data",[o,l]=i.useState(!1),d=()=>{l(!0),a(t),n.message.success(`${r} deleted successfully!`)},c=()=>{n.message.info(`Deletion of ${r} cancelled`)};return e.jsx(n.Popconfirm,{title:`Delete ${r}?`,description:`Are you sure you want to delete ${r}?`,onConfirm:d,onCancel:c,okText:"Yes",cancelText:"No",disabled:s||o,children:e.jsx(n.Button,{danger:!0,disabled:s,loading:o,icon:e.jsx(Z.DeleteOutlined,{}),size:"small"})})},Hr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Cu({token:t,sampleTemplateUrl:a=ac}){const[s,r]=i.useState({pagination:{current:1,pageSize:10}}),[o,l]=i.useState(!1),[d,c]=i.useState(null),[g,f]=i.useState(null),[u,p]=i.useState(!1),[_,v]=i.useState([]),h=`api/branchapi/Transport/routeTableList?page=${s.pagination.current}&per_page=${s.pagination.pageSize}`,m="api/branchapi/Transport/addroute",x="api/branchapi/Transport/editroute",T="api/branchapi/Transport/deleteroute",I=void 0,{isLoading:k,data:C,error:b,mutate:y}=H(t?[h,t]:null,([q,P])=>X(q,P)),S=i.useMemo(()=>!C?.data||Array.isArray(C.data)?[]:C.data?.rows||[],[C]),A=C?.data?.pagination?.total_rows||C?.pagination?.total_rows||0,R=async(q,P)=>{try{await y($e(q,P,t),Ve(P)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},z=q=>{q.preventDefault();const P=new FormData(q.target);R(m,P),q.target.reset()},U=(q,P)=>{r(D=>({...D,pagination:{current:q,pageSize:parseInt(P,10)}}))},j=async q=>{try{await y(Ye(T,q,t),Be(q)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},O=q=>{c(q),l(!0)},M=async q=>{try{const P=await Xe(x,q,t);y(P),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),c(null)}catch{w.error("Failed to update the item.",{duration:1e3})}},$=async q=>{q.preventDefault();const P=new FormData(q.target);P.append("id",d?.id),M(P)},E=async()=>{if(!g){w.error("Please select an Excel file to upload.",{duration:1e3});return}p(!0),v([]);try{const q=new FormData;q.append("file",g);const D=await(await fetch(`${I}`,{method:"POST",headers:{Authorization:t},body:q})).json();if(D.Status==="Success"){const L=D.data?.rows||[];v(L);const B=D.data?.success_count||0,W=D.data?.failed_count||0;w.success(D.message||`Route bulk upload completed. ${B} succeeded, ${W} failed.`,{duration:1e3}),B>0&&y()}else w.error(D.message||"Failed to upload routes.",{duration:1e3})}catch(q){w.error(q?.message||"Something went wrong.",{duration:1e3})}finally{p(!1),f(null)}},N=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(q,P)=>(q.route_title||"").localeCompare(P.route_title||"")}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(q,P)=>Number(q.fare||0)-Number(P.fare||0)}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(q,P)=>(q.note||"").localeCompare(P.note||"")}},{title:"Action",key:"action",render:(q,P)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>O(P),style:{padding:2}}),e.jsx(mt,{id:P?.id,funcName:j})]})}],V=d?.route_title?`Edit ${d.route_title}`:"Edit Route";return e.jsxs(F,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ke,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Upload Routes"})}),e.jsxs(F,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:q=>(f(q),!1),children:e.jsx(n.Button,{icon:e.jsx(Z.UploadOutlined,{}),disabled:u,children:g?g.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(n.Button,{type:"primary",onClick:E,disabled:u||!g,loading:u,children:u?"Uploading...":"Upload Routes"})})})]}),_.length>0&&e.jsxs(F,{mt:3,children:[e.jsx(ke,{level:5,children:"Upload Results"}),e.jsx(n.Table,{dataSource:_.map((q,P)=>({...q,key:P})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Title",dataIndex:"title"},{title:"Status",dataIndex:"status",render:q=>e.jsx("span",{style:{color:q==="Success"?"green":"red",fontWeight:500},children:q})},{title:"Message",dataIndex:"message"}]})]}),a&&e.jsx(F,{mt:2,children:e.jsx("a",{href:a,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ke,{level:5,style:{margin:0,color:"#fff"},children:"Add Route"})}),e.jsx(F,{p:3,children:e.jsx("form",{onSubmit:z,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(F,{children:e.jsx(Y,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(F,{children:e.jsx(Y,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(F,{children:e.jsx(Y,{type:"text",name:"note",label:"Note"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(F,{children:[e.jsx(re,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",style:Hr,children:"Cancel"})]})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ke,{level:5,style:{margin:0,color:"#fff"},children:"Route List"})}),e.jsx(F,{p:3,children:e.jsx(Me,{parentCallback:U,data:{newData:{data:S,pagination:{total_rows:A}},columns:N,columnstype:"antd",action:!1,Loading:k,error:b,deleteTodoMutation:j}})})]})})]}),e.jsx(n.Drawer,{open:o,title:V,placement:"right",width:420,onClose:()=>{l(!1),c(null)},children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"title",label:"Title",defaultValue:d?.route_title||"",required:"required"}),e.jsx(Y,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:d?.fare||"",required:"required"}),e.jsx(Y,{type:"text",name:"note",label:"Note",defaultValue:d?.note||""}),e.jsx("div",{style:{display:"none"},children:e.jsx(Y,{type:"text",name:"no_of_vehicle",label:"Note"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),c(null)},style:Hr,children:"Cancel"})]})]})})})]})}const Kr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Au({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),c=`api/branchapi/Transport/vehiclesTableList?page=${a.page}&per_page=${a.rowsPerPage}`,g="api/branchapi/Transport/addvehicles",f="api/branchapi/Transport/editvehicle",u="api/branchapi/Transport/deletevehicle",{isLoading:p,data:_,error:v,mutate:h}=H(t?[c,t]:null,([A,R])=>X(A,R)),m=async(A,R)=>{try{await h($e(A,R,t),Ve(R)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},x=A=>{A.preventDefault();const R=new FormData(A.target);m(g,R),A.target.reset()},T=async A=>{try{await h(Ye(u,A,t),Be(A)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},I=A=>{d(A),o(!0)},k=async A=>{try{await Xe(f,A,t),await h(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{w.error("Failed to update the item.",{duration:1e3})}},C=async A=>{A.preventDefault();const R=new FormData(A.target);R.append("id",l?.id),k(R)},b=(A,R)=>{s({page:A,rowsPerPage:parseInt(R,10)})},y=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(A,R)=>A.vehicle_no.localeCompare(R.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(A,R)=>A.vehicle_model.localeCompare(R.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(A,R)=>A.seating_capacity-R.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(A,R)=>A.manufacture_year-R.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(A,R)=>A.gps_url.localeCompare(R.gps_url)},render:(A,R)=>e.jsx("span",{title:R?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:R?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(A,R)=>A.note.localeCompare(R.note)}},{title:"Action",key:"action",render:(A,R)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>I(R),style:{padding:2}}),e.jsx(mt,{id:R?.id,funcName:T})]})}],S=l?.vehicle_no?`Edit ${l.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:r,title:S,placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"number",label:"Vehicle Number",defaultValue:l?.vehicle_no||"",required:"required"}),e.jsx(Y,{type:"text",name:"model",label:"Vehicle Model",defaultValue:l?.vehicle_model||""}),e.jsx(Y,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:l?.manufacture_year||""}),e.jsx(Y,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:l?.seating_capacity||""}),e.jsx(Y,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:l?.gps_url||""}),e.jsx(Y,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Kr,children:"Cancel"})]})]})})}),e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(F,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(F,{px:3,pb:2,children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"number",label:"Vehicle Number",required:"required"}),e.jsx(Y,{type:"text",name:"model",label:"Vehicle Model"}),e.jsx(Y,{type:"number",name:"manufacture_year",label:"Manufacture Year"}),e.jsx(Y,{type:"number",name:"seating_capacity",label:"Max Seating Capacity"}),e.jsx(Y,{type:"text",name:"gps_url",label:"Gps Url"}),e.jsx(Y,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(re,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",style:Kr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(F,{children:e.jsx(Me,{parentCallback:b,data:{newData:_,columns:y,columnstype:"antd",action:!1,Loading:p,error:v,deleteTodoMutation:T}})})]})})]})})]})}const Tu={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Gr=({dataIndex:t,title:a,record:s,children:r,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});function Ru({token:t}){const[a,s]=i.useState(!1),[r,o]=i.useState({pagination:{current:1,pageSize:50}}),[l,d]=i.useState(null),[c,g]=i.useState([]),f="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleDropdown",p="api/branchapi/Transport/getchechkedVehicleData",_="api/branchapi/Transport/assignedVehicleTable",v="api/branchapi/transport/assignvehicle",h="api/branchapi/Transport/deleteassignvehicle",m=l?`${p}?route_id=${l}`:null,{isLoading:x,data:T,mutate:I}=H(t?[`${_}?page=${r.pagination.current}&per_page=${r.pagination.pageSize}`,t]:null,([D,L])=>X(D,L)),{data:k}=H(t&&f?[f,t]:null,([D,L])=>X(D,L)),{data:C}=H(t&&u?[u,t]:null,([D,L])=>X(D,L)),b=t&&m?[m,t]:null,{isLoading:y,data:S}=H(b,([D,L])=>X(D,L)),{Status:A="Failed",pagination:{total_rows:R=0}={}}=T||{},{data:z=[]}=A==="Success"?T:{},U=i.useMemo(()=>{const D=k?.data??k??[];return Array.isArray(D)?D:[]},[k]),j=i.useMemo(()=>{const D=C?.data??C??[];return(Array.isArray(D)?D:[]).map(B=>{if(B==null)return null;if(typeof B=="string"||typeof B=="number")return{label:String(B),value:B};const W=B.value??B.vehicle_id??B.id??B.vehicleID,se=B.label??B.vehicle_name??B.vehicle_no??B.vehicle_number??B.name??String(W??"");return W==null||se===""?null:{label:String(se),value:W}}).filter(Boolean)},[C]),O=i.useMemo(()=>{const D=S?.data??S??[];return(Array.isArray(D)?D:[]).map(B=>B?.value??B?.vehicle_id??B?.id??B).filter(B=>B!=null)},[S]);i.useEffect(()=>{g(O)},[O,a]);const M=async(D,L,B)=>{try{await I($e(D,L,t),Ve(L)),m&&H.mutate(b),s(W=>!W),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(W){w.error(W?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},$=D=>{D.preventDefault();const L=new FormData;L.append("route_id",l??""),c.length?c.forEach(B=>L.append("vehicle_ids[]",B)):L.append("vehicle_ids[]",""),M(v,L)},E=D=>{o(L=>({...L,pagination:{current:D,pageSize:L.pagination.pageSize}}))},N=async D=>{try{await I(Ye(h,D,t),Be(D)),m&&H.mutate(b),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},V=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(D,L,B)=>e.jsx(e.Fragment,{children:L.children.map((W,se,Q)=>e.jsx("span",{children:`${W.vehicle_name} ${se+1===Q.length?"":","}`},`${se}vehicle001`))})},{title:"Action",render:(D,L,B)=>e.jsx(e.Fragment,{children:e.jsx(mt,{id:L?.route_id,funcName:N})})}],q=D=>{const L=["route_id","index"];for(let B=0;B<L.length;B++)if(D[L[B]])return D[L[B]]},P=D=>{const{children:L=[]}=D||{},B=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:W=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:W=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:W=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:W=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:W=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:W=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:W=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(n.Table,{components:{body:{cell:Gr}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:B,rowKey:W=>q(W)+"cell01",dataSource:L,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(F,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(F,{px:3,pb:2,children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:D=>{d(D?.value??null),s(L=>!L)}})}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:{display:"block",marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Vehicles"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:8,maxHeight:140,overflow:"auto"},children:e.jsx(n.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:j,value:c,onChange:D=>g(D),disabled:!l||y})},`check001${a}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(re,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),g([]),s(D=>!D)},style:Tu,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(F,{style:{padding:"10px 16px"},children:e.jsx(n.Table,{components:{body:{cell:Gr}},columns:V,bordered:!0,rowKey:D=>q(D),dataSource:Array.isArray(z)?z:[],loading:x,expandable:{expandedRowRender:P,childrenColumnName:"changed"},pagination:{current:r.pagination.current,pageSize:r.pagination.pageSize,total:R,showSizeChanger:!0,onChange:E,onShowSizeChange:(D,L)=>{o(B=>({...B,pagination:{current:1,pageSize:L}}))},showTotal:(D,L)=>`${L[0]}-${L[1]} of ${D} items`}})})]})})]})})]})}const Jr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ss=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},oa=(t,a,s)=>{if(a==null||a==="")return null;const r=t.find(o=>String(o.value)===String(a));return r||(s?{label:String(s),value:a}:{label:String(a),value:a})},Du=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Iu=t=>{if(t==null||t===""||t==="null"||t==="undefined")return"";if(Array.isArray(t))return t.filter(s=>s!=null&&s!==""&&String(s).toLowerCase()!=="null"&&String(s).toLowerCase()!=="undefined").join(", ");const a=String(t).trim();return!a||a.toLowerCase()==="null"||a.toLowerCase()==="undefined"?"":a};function ku({token:t,assignmentId:a,studentName:s,onClose:r,onSuccess:o}){const l="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",c="api/branchapi/Transport/getrouteDropdown",g="api/branchapi/Transport/getvehicleListByRouteIdwithCount",f="api/branchapi/Transport/getStoppageDropdown",u="api/branchapi/Transport/routeShowdata",[p,_]=i.useState(null),[v,h]=i.useState(null),[m,x]=i.useState(null),[T,I]=i.useState(ae()),[k,C]=i.useState(""),[b,y]=i.useState(0),[S,A]=i.useState(0),{data:R,isLoading:z}=H(t&&a?[`${l}?id=${a}`,t]:null,([G,de])=>X(G,de)),U=i.useMemo(()=>{if(!R||R?.Status&&R.Status!=="Success")return null;const G=R?.data??R;return Array.isArray(G)?G[0]??null:G},[R]);i.useEffect(()=>{const G=U?.fk_route_id??U?.route_id;G!=null&&_(G),U?.vehicle_id!=null&&h(U.vehicle_id),U?.stop_id!=null&&x(U.stop_id),I(U?.start_date?ae(U.start_date):ae()),C(Iu(U?.service_push))},[U]);const j=t&&p?`${g}?route_id=${p}`:null,O=t&&p?`${u}?id=${p}`:null,M=t&&p?`${f}?route_id=${p}`:null,{data:$}=H(t&&c?[c,t]:null,([G,de])=>X(G,de)),{data:E,isLoading:N}=H(j?[j,t]:null,([G,de])=>X(G,de)),{data:V,isLoading:q}=H(M?[M,t]:null,([G,de])=>X(G,de)),{data:P}=H(O?[O,t]:null,([G,de])=>X(G,de)),D=i.useMemo(()=>Ss($),[$]),L=i.useMemo(()=>Ss(E),[E]),B=i.useMemo(()=>Ss(V),[V]),W=R?.data[0]?.rootCost,se=Du(),Q=s||[U?.firstname,U?.lastname].filter(Boolean).join(" ")||"",K=(G,de)=>{switch(de){case"route_id":_(G?.value??null),h(null),x(null),y(Ae=>Ae+1),A(Ae=>Ae+1);break;case"vehicle_id":h(G?.value??null),x(null),A(Ae=>Ae+1);break;case"stop_id":x(G?.value??null);break}},te=async G=>{if(G.preventDefault(),!p||!v||!m){w.error("Please select Route, Vehicle and Stop",{duration:1200});return}const de=new FormData;de.append("id",String(a)),de.append("student_id",String(U?.fk_student_id??U?.student_id??"")),de.append("fk_route_id",String(p)),de.append("vehicle_id",String(v)),de.append("stop_id",String(m)),de.append("rootCost",String(W??"")),de.append("start_date",T?.isValid?.()?T.format("YYYY-MM-DD"):ae().format("YYYY-MM-DD")),de.append("puse_service",String(k??""));try{await Xe(d,de,t),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o?.(),r?.()}catch(Ae){w.error(Ae?.message??"Failed to update the item.",{duration:1e3})}};if(z||!(U&&!z&&(!p||!N&&!q)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(n.Spin,{})});if(!U)return e.jsxs("div",{style:{padding:"8px 0"},children:[e.jsx("p",{style:{color:"#666",fontSize:14,marginBottom:16},children:"Unable to load assignment details. Please try again."}),e.jsx(n.Button,{type:"text",onClick:r,style:Jr,children:"Close"})]});const pe=U.fk_route_id??U.route_id,_e=oa(D,pe,U.route_title),oe=oa(L,U.vehicle_id,U.vehicle_name??U.vehicle_no),le=oa(B,U.stop_id,U.stop_name??U.stoppage_name);return e.jsx("form",{onSubmit:te,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"title",label:"Student",defaultValue:Q,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:U.fk_student_id??U.student_id??""}),e.jsx(ee,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:oa(D,p,_e?.label)??null,onChange:G=>K(G,"route_id")}),e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:oa(L,v,oe?.label)??null,onChange:G=>K(G,"vehicle_id")},`edit-vehicle-${b}`),e.jsx(ee,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:oa(B,m,le?.label)??null,onChange:G=>K(G,"stop_id")},`edit-stop-${S}`),e.jsx(Y,{type:"text",label:"Route Cost",value:W!=null?`${se}${W}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:W??""}),e.jsx(Le,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:T,onChange:G=>I(G)}),e.jsx(Y,{type:"text",label:"Pause Service",value:k,onChange:G=>C(G?.target?.value??""),placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:r,style:Jr,children:"Cancel"})]})]})},`edit-${a}-${b}`)}const Qr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Pu=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Ra=t=>Pu(t),Ou=t=>t||"",Mu=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Eu=t=>{const a=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return a==="page"||a==="sendpage"?"page":"drawer"},Fu=(t,a)=>{const s=a||"/TransportDashboard/EditAssignStudentTransport?id={id}",r=t?.id??"",o=encodeURIComponent(String(r));if(s.includes("{id}"))return s.replaceAll("{id}",o);if(s.includes(":id"))return s.replace(":id",o);try{const d=new URL(s,"http://localhost");if(d.searchParams.has("id"))return d.searchParams.set("id",String(r)),`${d.pathname}${d.search}${d.hash}`}catch{}const l=s.includes("?")?"&":"?";return`${s}${l}id=${o}`};function $u({token:t,editType:a,onNavigate:s,editPagePath:r,sampleTemplateUrl:o=nc}){const d=Eu(a)==="drawer",c="api/branchapi/academy/classdropdownlist",g="api/branchapi/academy/sectionoftheClass",f="api/branchapi/Transport/routeStudentList",u="api/branchapi/Transport/getrouteDropdown",p="api/branchapi/Transport/getvehicleListByRouteIdwithCount",_="api/branchapi/Transport/getStoppageDropdown",v="api/branchapi/Transport/routeShowdata",h="api/branchapi/Transport/assignTransportRoutesStudent",m="api/branchapi/transport/removeStudentTransport",x="api/branchapi/transport/assignTransportRoutesStudentBulk",[T,I]=i.useState(null),[k,C]=i.useState(!1),[b,y]=i.useState(!1),[S,A]=i.useState(null),[R,z]=i.useState(null),[U,j]=i.useState(null),[O,M]=i.useState(null),[$,E]=i.useState(!1),[N,V]=i.useState(!1),[q,P]=i.useState({page:1,rowsPerPage:50}),[D,L]=i.useState(null),[B,W]=i.useState(!1),[se,Q]=i.useState(null),[K,te]=i.useState(null),[ie,pe]=i.useState(null),[_e,oe]=i.useState(null),[le,G]=i.useState(null),[de,Ae]=i.useState(null),[Ee,Pe]=i.useState(null),[ze,Fe]=i.useState(ae()),[tt,Ke]=i.useState(""),[Ue,Ge]=i.useState(null),[dt,fe]=i.useState(!1),[xe,ge]=i.useState([]),ne=(ye,Se)=>{const He=ye?.value??null;switch(Se){case"class_id":pe(He),oe(null),L(He?`${g}?class_id=${encodeURIComponent(String(He))}`:null),C(Tt=>!Tt);break;case"route_id":G(He),Ae(null),Pe(null),te(He),z(He?`${p}?route_id=${encodeURIComponent(String(He))}`:null),j(He?`${v}?id=${encodeURIComponent(String(He))}`:null),M(null),E(Tt=>!Tt),V(Tt=>!Tt);break;case"vehicle_id":Ae(He),Pe(null),M(le?`${_}?route_id=${encodeURIComponent(String(le))}`:null),V(Tt=>!Tt);break;case"stop_id":Pe(He);break}},me=ye=>{if(d){A(ye),y(!0);return}const Se=Fu(ye,r);if(typeof s=="function"){s(Se,ye);return}typeof window<"u"&&Se&&window.location.assign(Se)},he=()=>{y(!1),A(null)},Te=S?`Edit — ${S.firstname??""} ${S.lastname??""}`.trim():"Edit Student Transport",{data:Re}=H(t&&c?[c,t]:null,([ye,Se])=>X(ye,Se)),{data:bt}=H(t&&D?[D,t]:null,([ye,Se])=>X(ye,Se)),{data:zt}=H(t&&R?[R,t]:null,([ye,Se])=>X(ye,Se)),{data:Pt}=H(t&&O?[O,t]:null,([ye,Se])=>X(ye,Se)),{data:At}=H(t&&U?[U,t]:null,([ye,Se])=>X(ye,Se)),{data:Xt}=H(t&&u?[u,t]:null,([ye,Se])=>X(ye,Se)),Zt=t&&T?`${T}&page=${q.page}&per_page=${q.rowsPerPage}`:null,{isLoading:ue,error:je,data:st,mutate:yt}=H(Zt?[Zt,t]:null,([ye,Se])=>X(ye,Se)),nn=i.useMemo(()=>Ra(Re),[Re]),sn=i.useMemo(()=>Ra(bt),[bt]),rn=i.useMemo(()=>Ra(zt),[zt]),on=i.useMemo(()=>Ra(Pt),[Pt]),ln=i.useMemo(()=>Ra(Xt),[Xt]),ce=At?.data?.[0]?.fare??At?.data?.fare??At?.fare??At?.data?.data?.[0]?.fare??At?.data?.data?.fare;i.useEffect(()=>{ce==null||ce===""||Ke(String(ce))},[ce]);const be=async ye=>{try{await yt(Ye(m,ye,t),Be(ye)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},Oe=async()=>{if(!Ue){w.error("Please select an Excel file to upload.",{duration:1e3});return}fe(!0),ge([]);try{const ye=new FormData;ye.append("file",Ue);const He=await(await fetch(`${x}`,{method:"POST",headers:{Authorization:t},body:ye})).json();if(He.Status==="Success"){const Tt=He.data?.rows||[];ge(Tt);const dr=He.data?.success_count||0,al=He.data?.failed_count||0;w.success(He.message||`Transport bulk upload completed. ${dr} succeeded, ${al} failed.`,{duration:1e3}),dr>0&&yt()}else w.error(He.message||"Failed to upload student transport assignments.",{duration:1e3})}catch(ye){w.error(ye?.message||"Something went wrong.",{duration:1e3})}finally{fe(!1),Ge(null)}},We=[{title:"Route Status",key:"route_status",render:(ye,Se)=>Se.fk_route_id?e.jsx("span",{children:Se.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(ye,Se)=>Ou(Se.start_date)},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Roll No",dataIndex:"roll_no",key:"roll_no"},{title:"Name",key:"name",render:(ye,Se)=>`${Se.firstname} ${Se.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(ye,Se)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:Se.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(mt,{id:Se?.id,funcName:be}),e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>me(Se),style:{padding:2}})]}):e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.PlusOutlined,{}),onClick:()=>os(Se.student_id),style:{padding:2}})})}],at=async(ye,Se)=>{try{await yt($e(ye,Se,t),Ve(Se)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),W(!1),ls()}catch{w.error("Failed to add the new item.",{duration:1e3})}},ct=ye=>{if(ye.preventDefault(),!ie||!_e){w.error("Please select Class and Section",{duration:1200});return}I(`${f}?cID=${encodeURIComponent(String(ie))}&sID=${encodeURIComponent(String(_e))}`),P(Se=>({...Se,page:1}))},is=(ye,Se)=>{P({page:ye,rowsPerPage:parseInt(Se,10)})},os=ye=>{Q(ye),W(!0)},va=ye=>{if(ye.preventDefault(),!se){w.error("Student is required",{duration:1200});return}if(!le||!de||!Ee){w.error("Please select Route, Vehicle and Stop",{duration:1300});return}const Se=new FormData;Se.append("student_id",String(se)),Se.append("fk_route_id",String(le)),Se.append("vehicle_id",String(de)),Se.append("stop_id",String(Ee)),Se.append("start_date",ze?.isValid?.()?ze.format("YYYY-MM-DD"):ae().format("YYYY-MM-DD")),Se.append("rootCost",String(tt??"")),at(h,Se)},ls=()=>{W(!1),z(null),j(null),M(null),te(null),G(null),Ae(null),Pe(null),Fe(ae()),Ke(""),E(ye=>!ye),V(ye=>!ye)},tl=Mu();return e.jsxs(F,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ke,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Assign Students to Transport"})}),e.jsxs(F,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:ye=>(Ge(ye),!1),children:e.jsx(n.Button,{icon:e.jsx(Z.UploadOutlined,{}),disabled:dt,children:Ue?Ue.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(n.Button,{type:"primary",onClick:Oe,disabled:dt||!Ue,loading:dt,children:dt?"Uploading...":"Upload Students"})})})]}),o&&e.jsx(F,{mt:2,children:e.jsx("a",{href:o,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})}),xe.length>0&&e.jsxs(F,{mt:3,children:[e.jsx(ke,{level:5,children:"Upload Results"}),e.jsx(n.Table,{dataSource:xe.map((ye,Se)=>({...ye,key:Se})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Student ID",dataIndex:"student_id"},{title:"Status",dataIndex:"status",render:ye=>e.jsx("span",{style:{color:ye==="Success"?"green":"red",fontWeight:500},children:ye})},{title:"Message",dataIndex:"message"}]})]})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ke,{level:5,style:{margin:0,color:"#fff"},children:"Search Students"})}),e.jsx(F,{p:3,children:e.jsx("form",{onSubmit:ct,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(F,{children:e.jsx(ee,{options:nn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:ye=>ne(ye,"class_id"),required:!0,allowSelectAll:!1,value:nn.find(ye=>String(ye.value)===String(ie))??null})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(F,{children:e.jsx(ee,{options:sn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:sn.find(ye=>String(ye.value)===String(_e))??null,onChange:ye=>oe(ye?.value??null)},`section1${k}`)})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(F,{display:"flex",alignItems:"center",height:"100%",mt:2,children:[e.jsx(re,{type:"submit",value:"Search",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{I(null),L(null),pe(null),oe(null),C(ye=>!ye)},style:Qr,children:"Cancel"})]})})]})})})]})}),T&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ke,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(F,{p:3,children:e.jsx(Me,{parentCallback:is,data:{newData:st,columns:We,columnstype:"antd",action:!1,Loading:ue,error:je,deleteTodoMutation:be,pageController:q}})})]})})]}),e.jsx(n.Drawer,{open:b,title:Te,placement:"right",width:420,destroyOnClose:!0,onClose:he,children:S?.id&&e.jsx(ku,{token:t,assignmentId:S.id,studentName:`${S.firstname??""} ${S.lastname??""}`.trim(),onClose:he,onSuccess:()=>yt()})}),e.jsx(n.Modal,{open:B,title:"Assign Student to Transport",onCancel:ls,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:va,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(ee,{options:ln,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:ln.find(ye=>String(ye.value)===String(le))??null,onChange:ye=>ne(ye,"route_id")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(ee,{options:rn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:rn.find(ye=>String(ye.value)===String(de))??null,onChange:ye=>ne(ye,"vehicle_id")},`vehicle001${$}`)})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(ee,{options:on,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:on.find(ye=>String(ye.value)===String(Ee))??null,onChange:ye=>ne(ye,"stop_id")},`stop001${N}`)})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Le,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:ze,onChange:ye=>Fe(ye)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(F,{children:e.jsx(Y,{type:"text",name:"rootCost",label:"Route Cost",value:tt,onChange:ye=>Ke(ye?.target?.value??"")})})}),e.jsx(n.Col,{xs:24,children:e.jsxs(F,{display:"flex",alignItems:"center",gap:12,children:[e.jsx(re,{type:"submit",value:String(tt??"").trim()?`${tl}${tt} — Assign`:"Assign",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:ls,style:Qr,children:"Cancel"})]})})]})})})]})}const Xr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},pn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function Uu({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,g]=i.useState(""),[f,u]=i.useState(""),[p,_]=i.useState(""),[v,h]=i.useState(!1),m=`api/branchapi/Transport/getdriverTable?page=${a.page}&per_page=${a.rowsPerPage}`,x="api/branchapi/Transport/add_driver",T="api/branchapi/Transport/edit_driver",I="api/branchapi/Transport/deletedriver",k="api/branchapi/staff/uploadDocuments",C=i.useMemo(()=>String(k).startsWith("http")?k:`${et()??""}${String(k).replace(/^\/+/,"")}`,[k]),b=et()??"",{isLoading:y,data:S,error:A,mutate:R}=H(t?[m,t]:null,([q,P])=>X(q,P)),z=async(q,P)=>{try{await $e(q,P,t),await R(),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),g("")}catch(D){w.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},U=q=>{q.preventDefault();const P=new FormData(q.target);z(x,P),q.target.reset()},j=async q=>{try{await R(Ye(I,q,t),Be(q)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}},O=q=>{d(q),g(q?.image??""),o(!0)},M=async q=>{try{await Xe(T,q,t),await R(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),g("")}catch(P){w.error(P?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},$=q=>{q.preventDefault();const P=new FormData(q.target);P.append("id",l?.id??""),M(P)},E=(q,P)=>{s({page:q,rowsPerPage:parseInt(P,10)})},N=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(q,P)=>String(q?.name??"").localeCompare(String(P?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(q,P)=>String(q?.Driver_licence??"").localeCompare(String(P?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(q,P)=>Number(q?.contact_number??0)-Number(P?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(q,P)=>String(q?.address??"").localeCompare(String(P?.address??""))}},{title:"Image",key:"image",width:100,render:(q,P)=>{const D=P?.image?`${b}staff/document/${P.image}`:"";return D?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(n.Image,{width:80,src:D,preview:{visible:!1,onVisibleChange:()=>{h(!0),u(D),_(P?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(q,P)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>O(P),style:{padding:2}}),e.jsx(mt,{id:P?.id,funcName:j})]})}],V=l?.name?`Edit ${l.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:r,title:V,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{o(!1),d(null),g("")},children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"name",label:"Driver Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:l?.Driver_licence??"",required:"required"}),e.jsx(Y,{type:"number",name:"contact_number",label:"Driver Contact",defaultValue:l?.contact_number??"",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:pn,children:"Address"}),e.jsx(n.Input.TextArea,{name:"address",defaultValue:l?.address??"",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:pn,children:"Image"}),e.jsx(n.Upload,{maxCount:1,action:C,headers:t?{Authorization:t}:void 0,onChange:q=>{if(q?.file?.status!=="done")return;const P=q?.file?.response,D=P?.data??P?.filename??P?.file??P?.path??"";D&&g(String(D))},children:e.jsx(n.Button,{icon:e.jsx(Z.UploadOutlined,{}),disabled:!C,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),g("")},style:Xr,children:"Cancel"})]})]})})}),e.jsx(n.Modal,{zIndex:9999,open:v,title:p,footer:null,onCancel:()=>h(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:f})}),e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(F,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(F,{px:3,pb:2,children:e.jsx("form",{onSubmit:U,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Driver Name",required:"required"}),e.jsx(Y,{type:"text",name:"Driver_licence",label:"Driver Licence",required:"required"}),e.jsx(Y,{type:"number",name:"contact_number",label:"Driver Contact",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:pn,children:"Address"}),e.jsx(n.Input.TextArea,{name:"address",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:pn,children:"Image"}),e.jsx(n.Upload,{maxCount:1,action:C,headers:t?{Authorization:t}:void 0,onChange:q=>{if(q?.file?.status!=="done")return;const P=q?.file?.response,D=P?.data??P?.filename??P?.file??P?.path??"";D&&g(String(D))},children:e.jsx(n.Button,{icon:e.jsx(Z.UploadOutlined,{}),disabled:!C,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(re,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",onClick:()=>g(""),style:Xr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(F,{children:e.jsx(Me,{parentCallback:E,data:{newData:S,columns:N,columnstype:"antd",action:!1,Loading:y,error:A,deleteTodoMutation:j}})})]})})]})})]})}const Zr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},la={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},mn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},ei=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],fn=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Nu({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(!1),[c,g]=i.useState(null),[f,u]=i.useState(null),[p,_]=i.useState(null),[v,h]=i.useState(null),[m,x]=i.useState(ae()),[T,I]=i.useState(ae()),[k,C]=i.useState("pick"),[b,y]=i.useState(!1),[S,A]=i.useState(null),[R,z]=i.useState(null),[U,j]=i.useState(!1),[O,M]=i.useState(null),[$,E]=i.useState(null),[N,V]=i.useState(null),[q,P]=i.useState(null),[D,L]=i.useState(ae()),[B,W]=i.useState(ae()),[se,Q]=i.useState("pick"),K=`api/branchapi/Transport/assignRouteTimeList?page=${a.page}&per_page=${a.rowsPerPage}`,te="api/branchapi/Transport/assignRouteTime",ie="api/branchapi/Transport/editAssignRouteTime",pe="api/branchapi/Transport/deleteAssignRouteTime",_e="api/branchapi/Transport/driverDropdown",oe="api/branchapi/transport/routeTimetableShowdata",le="api/branchapi/Transport/getrouteDropdown",G="api/branchapi/Transport/getvehicleDropdown",{isLoading:de,data:Ae,error:Ee,mutate:Pe}=H(t?[K,t]:null,([ue,je])=>X(ue,je)),{data:ze}=H(t&&le?[le,t]:null,([ue,je])=>X(ue,je)),{data:Fe}=H(t&&_e?[_e,t]:null,([ue,je])=>X(ue,je)),tt=i.useMemo(()=>c?`${G}?route_id=${c}`:null,[c,G]),{data:Ke}=H(t&&tt?[tt,t]:null,([ue,je])=>X(ue,je)),Ue=i.useMemo(()=>fn(ze),[ze]),Ge=i.useMemo(()=>fn(Fe),[Fe]),dt=i.useMemo(()=>fn(Ke),[Ke]),fe=(ue,je)=>{s({page:ue,rowsPerPage:parseInt(je,10)})},xe=async ue=>{ue.preventDefault();const je=new FormData(ue.target);je.set("route_id",f?.value??c??""),je.set("driver_id",p?.value??""),je.set("vehicle_id",v?.value??""),je.set("start_time",m?m.format("h:mm a"):""),je.set("drop_time",T?T.format("h:mm a"):""),je.set("type",k);try{await $e(te,je,t),await Pe(),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),ue.target.reset(),g(null),u(null),_(null),h(null),d(st=>!st),x(ae()),I(ae()),C("pick"),o(st=>!st)}catch(st){w.error(st?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},ge=async ue=>{try{await Ye(pe,ue,t),await Pe(),w.success("Success! Deleted item.",{duration:1e3})}catch(je){w.error(je?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ne=ue=>{A(ue),y(!0);const je=ue?.id??ue?.route_time_id??ue?.routeId??null;z(je);const st=ue?.route_id??ue?.routeId??ue?.fk_route_id;M(st??null),E(Ue.find(yt=>yt?.value===(st??ue?.route_id))??null),V(Ge.find(yt=>yt?.value===(ue?.driver_id??ue?.driverId))??null),P(null),j(yt=>!yt),L(ue?.start_time?ae(ue.start_time,["h:mm a","HH:mm"]):ae()),W(ue?.drop_time?ae(ue.drop_time,["h:mm a","HH:mm"]):ae()),Q(ue?.type??"pick")},me=i.useMemo(()=>{if(!R)return null;const ue=String(oe).includes("?")?"&":"?";return`${oe}${ue}id=${encodeURIComponent(String(R))}`},[R,oe]),{data:he,isLoading:Te}=H(t&&me?[me,t]:null,([ue,je])=>X(ue,je)),Re=i.useMemo(()=>{const ue=he?.data??he;return Array.isArray(ue)?ue[0]??null:Array.isArray(ue?.data)?ue.data[0]??null:ue??null},[he]),bt=i.useMemo(()=>O?`${G}?route_id=${O}`:null,[O,G]),{data:zt}=H(t&&bt?[bt,t]:null,([ue,je])=>X(ue,je)),Pt=i.useMemo(()=>fn(zt),[zt]);i.useEffect(()=>{if(!Re)return;const ue=Re?.route_id??Re?.fk_route_id??Re?.routeId;M(ue??null),E(Ue.find(je=>je?.value===ue)??null),V(Ge.find(je=>je?.value===Re?.driver_id)??null),P(null),L(Re?.start_time?ae(Re.start_time,["h:mm a","HH:mm"]):ae()),W(Re?.drop_time?ae(Re.drop_time,["h:mm a","HH:mm"]):ae()),Q(Re?.type??"pick"),j(je=>!je)},[Ge,Re,Ue]),i.useEffect(()=>{if(!Re)return;const ue=Re?.vehicle_id??Re?.vehicleId;ue&&P(Pt.find(je=>je?.value===ue)??null)},[Re,Pt]);const At=async ue=>{if(ue.preventDefault(),!R)return;const je=new FormData(ue.target);je.set("id",String(R)),je.set("route_id",$?.value??O??""),je.set("driver_id",N?.value??""),je.set("vehicle_id",q?.value??""),je.set("start_time",D?D.format("h:mm a"):""),je.set("drop_time",B?B.format("h:mm a"):""),je.set("type",se);try{await Xe(ie,je,t),await Pe(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),y(!1),A(null)}catch(st){w.error(st?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Xt=[{title:"Route Name",dataIndex:"route_title",key:"route_title"},{title:"Driver Name",dataIndex:"driver_name",key:"driver_name"},{title:"Vehicle Name",dataIndex:"vehicle_name",key:"vehicle_name"},{title:"Start Time",dataIndex:"start_time",key:"start_time"},{title:"End Time",dataIndex:"drop_time",key:"drop_time"},{title:"Type",dataIndex:"type",key:"type"},{title:"Action",key:"action",render:(ue,je)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>ne(je),style:{padding:2}}),e.jsx(mt,{id:je?.id??je?.routeId??je?.route_time_id,funcName:ge})]})}],Zt=S?.route_title?`Edit ${S.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:b,title:Zt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{y(!1),A(null),z(null),M(null),E(null),V(null),P(null)},children:e.jsx("form",{onSubmit:At,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:Te?.6:1},children:[e.jsx(ee,{options:Ue,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:$,onChange:ue=>{M(ue?.value??null),E(ue??null),P(null),j(je=>!je)}}),e.jsx(ee,{options:Ge,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:N,onChange:ue=>V(ue??null)}),e.jsx(ee,{options:Pt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:q,onChange:ue=>P(ue??null)},`edit-vehicle-${U}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Start Time"}),e.jsx(n.TimePicker,{value:D,onChange:ue=>L(ue),use12Hours:!0,format:"h:mm a",allowClear:!1,style:mn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Drop Time"}),e.jsx(n.TimePicker,{value:B,onChange:ue=>W(ue),use12Hours:!0,format:"h:mm a",allowClear:!1,style:mn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(n.Radio.Group,{options:ei,optionType:"button",buttonStyle:"solid",value:se,onChange:ue=>Q(ue.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{y(!1),A(null)},style:Zr,children:"Cancel"})]})]})})}),e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(F,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(F,{px:3,pb:2,children:e.jsx("form",{onSubmit:xe,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:Ue,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:f,onChange:ue=>{g(ue?.value??null),u(ue??null),h(null),d(je=>!je)},allowSelectAll:!1,required:!0}),e.jsx(ee,{options:Ge,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:p,onChange:ue=>_(ue??null),allowSelectAll:!1,required:!0}),e.jsx(ee,{options:dt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:v,onChange:ue=>h(ue??null),allowSelectAll:!1,required:!0},`vehicle-${l}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Start Time"}),e.jsx(n.TimePicker,{value:m,onChange:ue=>x(ue),use12Hours:!0,format:"h:mm a",allowClear:!1,style:mn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Drop Time"}),e.jsx(n.TimePicker,{value:T,onChange:ue=>I(ue),use12Hours:!0,format:"h:mm a",allowClear:!1,style:mn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(n.Radio.Group,{options:ei,optionType:"button",buttonStyle:"solid",value:k,onChange:ue=>C(ue.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(re,{type:"submit",value:"Add",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",onClick:()=>{g(null),u(null),_(null),h(null),d(ue=>!ue),x(ae()),I(ae()),C("pick"),o(ue=>!ue)},style:Zr,children:"Cancel"})]})]})},`form-${r}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(F,{children:e.jsx(Me,{parentCallback:fe,data:{newData:Ae,columns:Xt,columnstype:"antd",action:!1,Loading:de,error:Ee,deleteTodoMutation:ge}})})]})})]})})]})}const Lu={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ti={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ai={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},ni=({dataIndex:t,title:a,record:s,children:r,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});let si=2;function Bu({token:t}){const[a,s]=i.useState([]),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,g]=i.useState({pagination:{current:1,pageSize:50}}),{isLoading:f,data:u,mutate:p}=H(t?[`api/branchapi/transport/getrouteStoppageData?page=${c.pagination.current}&per_page=${c.pagination.pageSize}`,t]:null,([M,$])=>X(M,$)),{Status:_="Failed",pagination:{total_rows:v=0}={}}=u||{},{data:h=[]}=_==="Success"?u:{},{data:m}=H(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([M,$])=>X(M,$)),x=i.useMemo(()=>{const M=m?.data??m??[];if(Array.isArray(M))return M;if(M&&typeof M=="object"){if(Array.isArray(M?.data))return M.data;if(Array.isArray(M?.data?.data))return M.data.data}return[]},[m]),{data:T}=H(t&&r?["api/branchapi/transport/getrouteStoppageData?route_id="+r,t]:null,([M,$])=>X(M,$)),{Status:I="Failed"}=T||{},k=async(M,$)=>{try{await p($e(M,$,t),Ve($)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{w.error("Failed to add the new item.",{duration:1e3})}},C=M=>M?typeof M=="string"?M:M?.isValid?.()?M.format("h:mm a"):"":"",b=(M,$=[])=>{const E=(Array.isArray(M)?M:[]).map(q=>({id:q?.id??"",name:String(q?.stop_name??q?.name??"").trim(),pickTime:C(q?.pickup_time??q?.pickTime??q?.pickupTime),drop_time:C(q?.drop_time??q?.dropTime)})),N=E.filter(q=>q?.id!=null&&String(q.id).trim()!==""),V=E.filter(q=>!(q?.id!=null&&String(q.id).trim()!==""));return{route_id:r??"",edit_stoppage:N,add_stoppage:V,delete_stoppage:Array.isArray($)?$:[]}},y=M=>{M.preventDefault();const $="/api/branchapi/transport/addstoppageToRoute",E=b(a,l);k($,E)},S=()=>{s(M=>[...Array.isArray(M)?M:[],{idKey:si++,stop_name:"",pickup_time:ae().format("h:mm a"),drop_time:ae().format("h:mm a")}])},A=M=>{if(a.length===1)return;const $=a[M];$?.id!=null&&String($.id).trim()!==""&&!$?.idKey&&d(E=>{const N=Array.isArray(E)?E:[];return N.some(q=>String(q)===String($.id))?N:[...N,$.id]}),s(E=>{const N=[...E];return N.splice(M,1),N})},R=M=>{g($=>({...$,pagination:{current:M,pageSize:$.pagination.pageSize}}))},z=async M=>{const $="/api/branchapi/Transport/deletevehicle";try{await p(Ye($,M,t),Be(M)),w.success("Success! Deleted item.",{duration:1e3})}catch{w.error("Failed to delete the item.",{duration:1e3})}};i.useEffect(()=>{if(I==="Success"){const M=Array.isArray(T?.data)?T.data:[];M.length>0?(s(M),d([])):r&&(s([{idKey:si++,stop_name:"",pickup_time:ae().format("h:mm a"),drop_time:ae().format("h:mm a")}]),d([]))}},[I,T,r]);const U=M=>{const{children:$=[]}=M||{},E=[{title:"Stop Name",dataIndex:"stop_name",onCell:N=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:N=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:N=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(n.Table,{components:{body:{cell:ni}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:E,rowKey:N=>j(N)+"cell01",dataSource:$,pagination:!1})})})},j=M=>{const $=["id","index"];for(let E=0;E<$.length;E++)if(M[$[E]])return M[$[E]]},O=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(M,$,E)=>e.jsx(e.Fragment,{children:(Array.isArray($.children)?$.children:[]).map((N,V,q)=>e.jsx("span",{children:`${N.stop_name} ${V+1===q.length?"":","}`},`${V}vehicle001`))})},{title:"Action",render:(M,$,E)=>e.jsx(e.Fragment,{children:e.jsx(mt,{id:$?.route_id,funcName:z})})}];return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(F,{pt:5,pb:1,children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(F,{px:3,pb:2,children:e.jsxs("form",{onSubmit:y,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(ee,{options:x,value:x.find(M=>String(M.value)===String(r))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:M=>{o(M?.value??null),s([]),d([])},allowSelectAll:!1,required:!0})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",gap:12},children:r&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer",marginBottom:8},title:"Add Row",onClick:S,children:e.jsx(Z.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(re,{type:"submit",value:"Add",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{o(null),s([]),d([])},style:Lu,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:a.length>0&&a.map((M,$)=>{const E=M.pickup_time?ae(M.pickup_time,"h:mm a"):null,N=M.drop_time?ae(M.drop_time,"h:mm a"):null;return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr)) auto",gap:16,alignItems:"end",marginBottom:12},children:[e.jsxs("div",{children:[e.jsx(Y,{value:M.stop_name??"",type:"text",name:`stoppage[${$}][name]`,label:"Place Name*",required:"required",onChange:V=>{const q=V?.target?.value??"";s(P=>{const D=[...P];return D[$]={...D[$]??{},stop_name:q},D})}}),M?.id!=null&&String(M.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${$}][id]`,value:String(M.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ti,children:"Pick Time"}),e.jsx(n.TimePicker,{value:E,use12Hours:!0,format:"h:mm a",name:`stoppage[${$}][pickTime]`,allowClear:!1,style:ai,onChange:V=>{const q=V?V.format("h:mm a"):"";s(P=>{const D=[...P];return D[$]={...D[$]??{},pickup_time:q},D})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ti,children:"Drop Time"}),e.jsx(n.TimePicker,{value:N,use12Hours:!0,format:"h:mm a",name:`stoppage[${$}][drop_time]`,allowClear:!1,style:ai,onChange:V=>{const q=V?V.format("h:mm a"):"";s(P=>{const D=[...P];return D[$]={...D[$]??{},drop_time:q},D})}})]}),e.jsx("div",{style:{marginBottom:8},children:a.length>1&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer"},onClick:()=>A($),children:e.jsx(Z.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},M.idKey?M.idKey+"exp":M.id+"exp")})})]})}),e.jsx(F,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(F,{style:{padding:"10px 16px"},children:e.jsx(n.Table,{components:{body:{cell:ni}},columns:O,bordered:!0,size:"small",rowKey:M=>j(M),dataSource:h,loading:f,expandable:{expandedRowRender:U,childrenColumnName:"changed"},pagination:{current:c.pagination.current,pageSize:c.pagination.pageSize,total:v,showSizeChanger:!0,onChange:R,onShowSizeChange:(M,$)=>{g(E=>({...E,pagination:{current:1,pageSize:$}}))},showTotal:(M,$)=>`${$[0]}-${$[1]} of ${M} items`}})})]})]})}const qu=(t,a)=>{const s=String(t??"").replace(/\/+$/,""),r=String(a).replace(/^\/+/,"");return`${s}/${r}`};function zu({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState(null),[o,l]=i.useState(null),[d,c]=i.useState(null),[g,f]=i.useState(null),[u,p]=i.useState(null),[_,v]=i.useState(null),[h,m]=i.useState(null),x="api/branchapi/library/bookCategorydropdown",T="api/branchapi/academy/classdropdownlist",I="api/branchapi/Academy/getClassSubjectdropdown",k="api/branchapi/library/addBook",C="api/branchapi/library/uploadcsv",{data:b}=H(a?[x,a]:null,([j,O])=>X(j,O)),{data:y}=H(a&&T?[T,a]:null,([j,O])=>X(j,O)),{data:S}=H(a&&I?[I,a]:null,([j,O])=>X(j,O)),A=i.useMemo(()=>qu(et(),C),[C]),R=async j=>{j.preventDefault();const O=new FormData(j.target);O.set("cat_id",u?.value??""),O.set("class_id",_?.value??""),O.set("subject_id",h?.value??"");try{await $e(k,O,a),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),j.target.reset(),p(null),v(null),m(null)}catch(M){w.error(M?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},z=async j=>{if(j.preventDefault(),!s){w.error("Please select a CSV file.",{duration:1e3});return}const O=new FormData;O.append("file",s),O.append("cat_id",o?.value??""),O.append("class_id",d?.value??""),O.append("subject_id",g?.value??"");try{const M=await Ne.post(A,O,{headers:{Authorization:a,"Content-type":"multipart/form-data"}});M?.data?.Status==="Failed"?w.error(String(M?.data?.msg??"Upload failed."),{duration:1e3}):(w.success(String(M?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),r(null),j.target.reset(),l(null),c(null),f(null))}catch(M){w.error(M?.response?.data?.msg??"Upload failed.",{duration:1e3})}},U=()=>{fetch("/books.csv").then(j=>{j.blob().then(O=>{const M=window.URL.createObjectURL(O);let $=document.createElement("a");$.href=M,$.download="/books.csv",$.click()})})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:e.jsx(n.Button,{type:"link",icon:e.jsx(Z.DownloadOutlined,{}),onClick:U,children:"Download Sample"}),children:[e.jsx(n.Divider,{children:"Information"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:16},children:"1. Your CSV data should be in the format below. The first line of your CSV file should be the column headers as in the table example. Also make sure that your file is UTF-8 to avoid unnecessary encoding problems."}),e.jsx("form",{onSubmit:z,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:o,onChange:j=>l(j??null)}),e.jsx(ee,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:d,onChange:j=>c(j??null)}),e.jsx(ee,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:g,onChange:j=>f(j??null)}),e.jsx(Y,{type:"file",label:"Upload CSV",name:"csv",accept:".csv",onChange:j=>r(j.target.files?.[0]??null),required:!0}),e.jsx(re,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Book"}),children:e.jsx("form",{onSubmit:R,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",label:"Book Name",name:"title",required:!0}),e.jsx(Y,{type:"text",label:"Author",name:"author",required:!0}),e.jsx(Y,{type:"text",label:"Publication",name:"publisher"}),e.jsx(Y,{type:"number",label:"Qty",name:"quantity",required:!0}),e.jsx(Y,{type:"number",label:"Book Price",name:"price",required:!0}),e.jsx(Y,{type:"number",label:"Fine Per Day",name:"fine",required:!0}),e.jsx(Y,{type:"text",label:"Barcode",name:"barcode"}),e.jsx(ee,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:u,onChange:j=>p(j??null)}),e.jsx(ee,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:_,onChange:j=>v(j??null)}),e.jsx(ee,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:h,onChange:j=>m(j??null)}),e.jsx(re,{type:"submit",value:"Save",color:"primary"})]})})})]})}const vs={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},_s=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Yu({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState([]),[o,l]=i.useState([]),d=i.useRef(),c={selectedRowKeys:s,onChange:(te,ie)=>{r(te),l(ie)}},g=xa.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),f=()=>{if(!(typeof window>"u")){if(!o.length){w.error("Select at least one book to print.",{duration:1e3});return}if(!d.current){w.error("Nothing to print.",{duration:1e3});return}g?.()}},[u,p]=i.useState(!1),[_,v]=i.useState(null),[h,m]=i.useState(null),[x,T]=i.useState(null),[I,k]=i.useState(null),[C,b]=i.useState({page:1,rowsPerPage:10}),y=(te,ie)=>{b({page:te,rowsPerPage:parseInt(ie,10)})},S="api/branchapi/library/booktable",A="api/branchapi/library/deletebooks",R="api/branchapi/library/editbook",z=`${S}?page=${C.page}&per_page=${C.rowsPerPage}`,{isLoading:U,error:j,data:O,mutate:M}=H(a?[z,a]:null,([te,ie])=>X(te,ie)),$="api/branchapi/library/bookCategorydropdown",E="api/branchapi/academy/classdropdownlist",N="api/branchapi/Academy/getClassSubjectdropdown",{data:V}=H(a?[$,a]:null,([te,ie])=>X(te,ie)),{data:q}=H(a&&E?[E,a]:null,([te,ie])=>X(te,ie)),{data:P}=H(a&&N?[N,a]:null,([te,ie])=>X(te,ie)),D=i.useMemo(()=>_s(V),[V]),L=i.useMemo(()=>_s(q),[q]),B=i.useMemo(()=>_s(P),[P]),W=async te=>{try{await Ye(A,te,a),await M(),w.success("Success! Deleted item.",{duration:1e3})}catch(ie){w.error(ie?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},se=te=>{v(te??null);const ie=te?.cat_id??te?.fk_cat_id??te?.category_id,pe=te?.class_id??te?.fk_class_id,_e=te?.subject_id??te?.fk_subject_id;m(D.find(oe=>oe?.value===ie)??null),T(L.find(oe=>oe?.value===pe)??null),k(B.find(oe=>oe?.value===_e)??null),p(!0)},Q=async te=>{te.preventDefault();const ie=_?.id??_?.book_id??_?._id;if(!ie)return;const pe=new FormData(te.target);pe.set("id",String(ie)),pe.set("cat_id",h?.value??""),pe.set("class_id",x?.value??""),pe.set("subject_id",I?.value??"");try{await Xe(R,pe,a),await M(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),p(!1),v(null)}catch(_e){w.error(_e?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},K=i.useMemo(()=>[{title:"Name",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Publisher",dataIndex:"publish",key:"publish",width:160,responsive:["lg"]},{title:"Author",dataIndex:"author",key:"author",width:160,responsive:["lg"]},{title:"Class",dataIndex:"class_name",key:"class_name",width:140,responsive:["xl"]},{title:"Subject",dataIndex:"subject_name",key:"subject_name",width:160,responsive:["xl"]},{title:"Avl Qty",dataIndex:"available_qty",key:"available_qty",width:90},{title:"Book Price",dataIndex:"perunitcost",key:"perunitcost",width:120,responsive:["xl"]},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",width:120,responsive:["xl"]},{title:"Category",dataIndex:"cat_name",key:"cat_name",width:160,responsive:["xl"]},{title:"Action",key:"action",width:140,fixed:"right",render:(te,ie)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>se(ie),style:{padding:2}}),e.jsx(n.Button,{type:"text",size:"small",danger:!0,onClick:()=>W(ie?.id??ie?.book_id??ie?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[D,L,W,B]);return e.jsxs("div",{style:{},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:u,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{p(!1),v(null)},children:e.jsx("form",{onSubmit:Q,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Y,{label:"Book Name",name:"title",defaultValue:_?.book_title??"",required:!0}),e.jsx(Y,{label:"Author",name:"author",defaultValue:_?.author??"",required:!0}),e.jsx(Y,{label:"Publication",name:"publish",defaultValue:_?.publish??""}),e.jsx(Y,{label:"Qty",name:"quantity",type:"number",defaultValue:_?.quantity??""}),e.jsx(Y,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:_?.perunitcost??""}),e.jsx(Y,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:_?.fine_amount??""}),e.jsx(Y,{label:"Barcode",name:"barcode",defaultValue:_?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:vs,children:"Category"}),e.jsx(ee,{options:D,value:h,onChange:te=>m(te??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:vs,children:"Class"}),e.jsx(ee,{options:L,value:x,onChange:te=>T(te??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:vs,children:"Subject"}),e.jsx(ee,{options:B,value:I,onChange:te=>k(te??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{p(!1),v(null)},children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:o.length>0?e.jsxs(n.Button,{type:"primary",onClick:f,children:["Print Barcode (",o.length,")"]}):null,children:e.jsx(Me,{parentCallback:y,data:{newData:O,columns:K,columnstype:"antd",action:!1,Loading:U,error:j,rowSelection:c}})}),e.jsx("div",{style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"},children:e.jsx("div",{ref:d,style:{padding:"20px"},children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-start"},children:o.map((te,ie)=>e.jsxs("div",{style:{margin:"10px",textAlign:"center",border:"1px dashed black",padding:"10px",borderRadius:"5px",width:"fit-content"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:"bold",maxWidth:"200px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:te.book_title}),e.jsx(Zi,{value:te.barcode?String(te.barcode):String(te.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},ie))})})})]})}const Vu=(t,a)=>{const s=String(t??"").replace(/\/+$/,""),r=String(a).replace(/^\/+/,"");return`${s}/${r}`},Ot=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},yn=t=>ae(t).add(1,"month").format("YYYY-MM-DD"),Wu=i.forwardRef(({token:t,onReturn:a},s)=>{const r=t??localStorage.getItem("authToken")??"",[o,l]=i.useState("issue"),d=o==="return",[c,g]=i.useState(!1),[f,u]=i.useState(!1),[p,_]=i.useState(null),[v,h]=i.useState([]),[m,x]=i.useState([]),[T,I]=i.useState([]),[k,C]=i.useState(0),[b,y]=i.useState(!1),[S,A]=i.useState(null),[R,z]=i.useState(null),[U,j]=i.useState(null),[O,M]=i.useState(!1),[$,E]=i.useState("Cash"),[N,V]=i.useState(""),[q,P]=i.useState(""),[D,L]=i.useState(0),[B,W]=i.useState("NO_FINE"),se=i.useRef(null),[Q]=n.Form.useForm(),[K]=n.Form.useForm(),te="api/branchapi/library/bookCategorydropdown",ie="api/branchapi/academy/classdropdownlist",pe="api/branchapi/Academy/getClassSubjectdropdown",{data:_e}=H(r?[te,r]:null,([ce,be])=>X(ce,be)),{data:oe}=H(r&&ie?[ie,r]:null,([ce,be])=>X(ce,be)),{data:le}=H(r&&pe?[pe,r]:null,([ce,be])=>X(ce,be)),G=i.useMemo(()=>Ot(_e),[_e]),de=i.useMemo(()=>Ot(oe),[oe]),Ae=i.useMemo(()=>Ot(le),[le]),Ee="api/branchapi/library/studentsearchByNameID",Pe="api/branchapi/library/booksearchBybookname",ze="api/branchapi/library/issuedBookList",Fe="api/branchapi/library/issueLibrarybook",tt="api/branchapi/library/returnedLibrarybook",{trigger:Ke,data:Ue}=nt(Ee,(ce,be)=>Ht(ce,be,r)),{trigger:Ge,data:dt}=nt(Pe,(ce,be)=>Ht(ce,be,r)),{trigger:fe,data:xe}=nt(ze,(ce,be)=>Ht(ce,be,r)),{trigger:ge}=nt(d?tt:Fe,(ce,be)=>Xn(ce,be,r)),ne=i.useMemo(()=>Ot(Ue),[Ue]),me=i.useMemo(()=>Ot(dt),[dt]),he=i.useMemo(()=>Ot(xe),[xe]),Te=ce=>{const be=yn(ae());h(Oe=>Oe.some(We=>String(We?.id)===String(ce?.id))?Oe:[...Oe,{...ce,return_date:ce?.return_date?ce.return_date:be}])},Re=async()=>{console.log("Reloading IssueReturn..."),w.success("Success",{duration:1e3}),x([]),I([]),C(0),W("FINE_PAY_LATER"),await fe({id:p?.student_id})};i.useImperativeHandle(s,()=>({reloadPayLater:Re}));const bt=ce=>{h(be=>be.filter(Oe=>String(Oe?.id)!==String(ce)))},zt=async ce=>{if(r){if(!ce){_(null);return}c||await Ke({id:ce})}},Pt=async({search:ce})=>{if(!r||!c)return;const be=await Ke({id:ce}),Oe=Ot(be);Oe.length===1&&(_(Oe[0]),await fe({id:Oe[0]?.student_id}),Q.resetFields())},At=async(ce,be)=>{_(be??null),h([]),x([]),I([]),C(0),W("NO_FINE"),L(0),be?.student_id&&await fe({id:be.student_id}),Q.resetFields()},Xt=async ce=>{r&&ce&&(f||await Ge({book:ce}))},Zt=async({search_book:ce})=>{if(!r||!f)return;const be=await Ge({book:ce,catID:S?.value??"",sID:U?.value??"",cID:R?.value??""}),Oe=Ot(be);Oe.length&&(Te(Oe[0]),K.resetFields())},ue=(ce,be)=>{Te(be),K.resetFields()},je=async()=>{if(!p?.member_id){w.error("Select a student first.",{duration:1e3});return}if(!v.length){w.error("Select at least one book.",{duration:1e3});return}const ce=await ge({member_id:p.member_id,fine:!1,books:v});ce?.Status==="Success"&&(w.success(String(ce?.msg??"Success"),{duration:1e3}),h([]),_(null),x([]),I([]),C(0))},st=async()=>{if(!p?.member_id){w.error("Select a student first.",{duration:1e3});return}if(!T.length){w.error("Select at least one book to return.",{duration:1e3});return}if(Number(k)>0){W("FINE_PAID"),M(!0);return}const ce=await ge({member_id:p.member_id,collection_type:"NO_FINE",amount:0,books:JSON.stringify(T)});ce?.Status==="Success"?(w.success(String(ce?.msg??"Success"),{duration:1e3}),x([]),I([]),C(0),await fe({id:p?.student_id})):w.error(String(ce?.msg??"Failed"),{duration:1e3})},yt=async()=>{if(!p?.member_id)return;const ce=Math.max(0,Number(k)-Number(D||0)),be={member_id:p.member_id,collection_type:B,amount:B==="FINE_PAID"?ce:0,payment_type:$,notes:N,attchement:q,discount:D||0,books:JSON.stringify(T)},Oe=await ge(be);M(!1),Oe?.Status==="Success"?(w.success(String(Oe?.msg??"Success"),{duration:1e3}),x([]),I([]),C(0),L(0),V(""),P(""),W("NO_FINE"),await fe({id:p?.student_id})):w.error(String(Oe?.msg??"Failed"),{duration:1e3})},nn=async()=>{if(!p?.member_id){w.error("Select a student first.",{duration:1e3});return}if(!T.length){w.error("Select at least one book to return.",{duration:1e3});return}const ce={member_id:p.member_id,collection_type:"FINE_PAY_LATER",amount:0,books:JSON.stringify(T)};a(ce)},sn=i.useMemo(()=>Vu(et(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),rn=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Author",dataIndex:"author",key:"author",width:180,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(ce,be)=>e.jsx(Le,{defaultValue:ae(be?.return_date||ae().add(30,"day")),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(Oe,We)=>{h(at=>at.map(ct=>String(ct?.id)===String(be?.id)?{...ct,return_date:We}:ct))}})},{title:"Action",key:"action",width:120,fixed:"right",render:(ce,be)=>e.jsx(n.Button,{type:"text",danger:!0,onClick:()=>bt(be?.id),children:"Remove"})}],on={selectedRowKeys:m,onChange:(ce,be)=>{x(ce),I(be);const Oe=(be??[]).reduce((We,at)=>We+Number(at?.totalfine??0),0);C(Oe)},onSelect:(ce,be,Oe)=>{if(be){const We=Oe.map(at=>({...at,return_date:at?.return_date?at.return_date:yn(at?.issue_date||ae())}));I(We)}},onSelectAll:(ce,be)=>{if(ce){const Oe=be.map(We=>({...We,return_date:We?.return_date?We.return_date:yn(We?.issue_date||ae())}));I(Oe)}}},ln=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Issue Date",dataIndex:"issue_date",key:"issue_date",width:140,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(ce,be)=>{const We=T.find(ct=>String(ct?.id)===String(be?.id))?.return_date||be?.return_date,at=yn(be?.issue_date||ae());return e.jsx(Le,{defaultValue:ae(We||at),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(ct,is)=>{I(os=>os.map(va=>String(va?.id)===String(be?.id)?{...va,return_date:is}:va))}})}},{title:"Days",key:"days",width:100,render:(ce,be)=>{const We=T.find(ct=>String(ct?.id)===String(be?.id))?.return_date||be?.return_date,at=be?.issue_date;if(at&&We){const ct=ae(We).diff(ae(at),"day");return ct>=0?ct:0}return"-"}},{title:"Due Date",dataIndex:"due_date",key:"due_date",width:140,responsive:["lg"]},{title:"Fine",dataIndex:"totalfine",key:"totalfine",width:120,fixed:"right",render:ce=>e.jsxs("span",{children:["₹ ",ce]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:O,onCancel:()=>M(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(n.Radio.Group,{value:$,onChange:ce=>E(ce.target.value),options:[{label:"Cash",value:"Cash"},{label:"UPI",value:"UPI"},{label:"DD",value:"DD"},{label:"Bank",value:"Bank"},{label:"Internet Banking",value:"Internet Banking"},{label:"Cheque",value:"Cheque"}]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Note"}),e.jsx(n.Input.TextArea,{rows:3,value:N,onChange:ce=>V(ce.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(n.Upload,{action:sn,headers:{Authorization:r},maxCount:1,onChange:ce=>{if(ce.file.status==="done"){const be=ce.file.response?.data??ce.file.response?.file??"";P(String(be??""))}},children:e.jsx(n.Button,{icon:e.jsx(Z.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(n.Input,{type:"number",value:D,onChange:ce=>L(ce.target.value),placeholder:"0"})]}),e.jsxs(n.Button,{type:"primary",onClick:yt,children:["Collect ₹",Math.max(0,Number(k)-Number(D||0))]}),e.jsx(n.Button,{onClick:()=>M(!1),children:"Cancel"})]})}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:10,children:e.jsx(n.Radio.Group,{value:o,onChange:ce=>{const be=ce.target.value;l(be),h([]),x([]),I([]),C(0),W("NO_FINE"),L(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"},{label:"Renewal",value:"Renewal"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(n.Col,{xs:24,md:14,children:e.jsx(n.Form,{form:Q,onFinish:Pt,layout:"vertical",children:e.jsx(n.Form.Item,{name:"search",label:"Search Student",children:e.jsx(n.Space.Compact,{style:{width:"100%"},children:c?e.jsx(n.Input,{autoFocus:!0,addonBefore:e.jsxs(n.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:c,onChange:ce=>g(ce.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(n.AutoComplete,{options:ne,onSelect:At,onSearch:zt,style:{width:"100%"},allowClear:!0,children:e.jsx(n.Input,{addonBefore:e.jsxs(n.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:c,onChange:ce=>g(ce.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),p?e.jsxs(e.Fragment,{children:[e.jsx(n.Divider,{}),e.jsxs(n.Row,{gutter:[12,12],children:[e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Name:"})," ",p?.value??""]}),e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Card No:"})," ",p?.library_card_no??""]}),e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Member ID:"})," ",p?.member_id??""]})]})]}):null,e.jsx(n.Divider,{}),d?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:760},children:e.jsx(n.Table,{dataSource:he,columns:ln,rowSelection:on,pagination:!1,rowKey:ce=>ce?.id??ce?.issue_id??ce?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(n.Divider,{}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs(n.Typography.Text,{strong:!0,children:["Total Fine: ₹",k]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx(n.Button,{type:"primary",onClick:st,disabled:!T.length,children:k>0?`Pay Now ₹ ${Math.max(0,Number(k)-Number(D||0))}`:"Return Selected"}),k>0?e.jsx(n.Button,{onClick:nn,disabled:!T.length,children:"Pay Later"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:18,children:e.jsx(n.Form,{form:K,onFinish:Zt,layout:"vertical",children:e.jsx(n.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(n.Space.Compact,{style:{width:"100%"},children:f?e.jsx(n.Input,{autoFocus:!0,disabled:!p,addonBefore:e.jsxs(n.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:f,onChange:ce=>u(ce.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(n.AutoComplete,{disabled:!p,options:me,onSelect:ue,onSearch:Xt,style:{width:"100%"},allowClear:!0,children:e.jsx(n.Input,{addonBefore:e.jsxs(n.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:f,onChange:ce=>u(ce.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(n.Button,{style:{width:"100%"},icon:e.jsx(Z.FilterOutlined,{}),onClick:()=>y(!0),children:"Filter"})})]}),e.jsx(n.Drawer,{open:b,onClose:()=>y(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{label:"Category",options:G,value:S,onChange:ce=>A(ce??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(ee,{label:"Class",options:de,value:R,onChange:ce=>z(ce??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(ee,{label:"Subjects",options:Ae,value:U,onChange:ce=>j(ce??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(n.Button,{type:"primary",onClick:()=>y(!1),children:"Apply"})]})}),e.jsx(n.Divider,{}),e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:720},children:e.jsx(n.Table,{dataSource:v,columns:rn,pagination:!1,rowKey:ce=>ce?.id??ce?.book_id??ce?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"button",value:"Issue",onClick:je})})]})]}),e.jsx("div",{ref:se,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}),ri=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Hu({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState({page:1,rowsPerPage:10}),[o,l]=i.useState(null),[d,c]=i.useState(null),[g,f]=i.useState(!1),[u,p]=i.useState(!1),[_,v]=i.useState(null),[h,m]=i.useState(!1),x="api/branchapi/academy/classdropdownlist",T="api/branchapi/academy/sectionoftheClass",I="api/branchapi/library/studenttableForLibrary",k="api/branchapi/library/addmembershipforStudent",C="api/branchapi/library/removemembershipforStudent",b=i.useMemo(()=>{if(!o?.value)return null;const P=T.includes("?")?"&":"?";return`${T}${P}class_id=${encodeURIComponent(String(o.value))}`},[T,o?.value]),y=i.useMemo(()=>{if(!o?.value||!d?.value)return null;const P=I.includes("?")?"&":"?";return`${I}${P}cID=${encodeURIComponent(String(o.value))}&sID=${encodeURIComponent(String(d.value))}&page=${s.page}&per_page=${s.rowsPerPage}`},[s.page,s.rowsPerPage,o?.value,d?.value,I]),{data:S}=H(a&&x?[x,a]:null,([P,D])=>X(P,D)),{data:A}=H(a&&b?[b,a]:null,([P,D])=>X(P,D)),{isLoading:R,error:z,data:U,mutate:j}=H(a&&y?[y,a]:null,([P,D])=>X(P,D)),O=i.useMemo(()=>ri(S),[S]),M=i.useMemo(()=>ri(A),[A]),$=(P,D)=>{r({page:P,rowsPerPage:parseInt(D,10)})},E=P=>{const D=P?.id??P?.student_id??P?.member_id;v(D??null),p(!0),m(L=>!L)},N=async P=>{if(P.preventDefault(),!_)return;const D=new FormData(P.target);D.set("id",String(_));try{await $e(k,D,a),w.success("Success! Added member.",{duration:1e3,icon:"🎉"}),p(!1),v(null),await j()}catch(L){w.error(L?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},V=async P=>{try{await Ye(C,P,a),w.success("Success! Removed member.",{duration:1e3}),await j()}catch(D){w.error(D?.response?.data?.msg??"Failed to remove member.",{duration:1e3})}},q=i.useMemo(()=>[{title:"Library Card No",dataIndex:"library_card_no",key:"library_card_no",width:180,ellipsis:!0,fixed:"left"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:140,responsive:["sm"]},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,responsive:["lg"]},{title:"First Name",dataIndex:"firstname",key:"firstname",width:140,responsive:["sm"]},{title:"Last Name",dataIndex:"lastname",key:"lastname",width:140,responsive:["lg"]},{title:"Class",dataIndex:"class",key:"class",width:120,responsive:["xl"]},{title:"Section",dataIndex:"section",key:"section",width:120,responsive:["xl"]},{title:"Mobile",dataIndex:"mobileno",key:"mobileno",width:140,responsive:["lg"]},{title:"Action",key:"action",width:80,fixed:"right",render:(P,D)=>(console.log("data______________",D),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:D?.library_card_no==null?e.jsx(n.Button,{type:"primary",size:"small",icon:e.jsx(Z.UserAddOutlined,{}),onClick:()=>E(D)}):e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{}),onClick:()=>V(D?.id??D?.student_id??D?.member_id)})}))}],[V]);return e.jsxs("div",{style:{},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:u,title:"Add Member",onCancel:()=>{p(!1),v(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Y,{type:"text",label:"Library Card Number",name:"library_num",required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Add",color:"primary"})})]})},`add-${h}`)}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Student"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(ee,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:o,onChange:P=>{l(P??null),c(null),f(D=>!D)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(ee,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:P=>c(P??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${g}`),e.jsx(re,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!o?.value||!d?.value){w.error("Select class and section.",{duration:1e3});return}r(P=>({...P,page:1}))}})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Me,{parentCallback:$,data:{newData:U,columns:q,columnstype:"antd",action:!1,Loading:R,error:z}})})]})}function Ku({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState({page:1,rowsPerPage:10}),[o]=n.Form.useForm(),[l]=n.Form.useForm(),[d,c]=i.useState(!1),[g,f]=i.useState(null),u="api/branchapi/library/BookCategorytable",p="api/branchapi/library/addBookCategory",_="api/branchapi/library/editBookCategory",v="api/branchapi/library/deleteBookCategory",h=i.useMemo(()=>{const z=u.includes("?")?"&":"?";return`${u}${z}page=${s.page}&per_page=${s.rowsPerPage}`},[u,s.page,s.rowsPerPage]),{isLoading:m,error:x,data:T,mutate:I}=H(a&&h?[h,a]:null,([z,U])=>X(z,U)),k=(z,U)=>{r({page:z,rowsPerPage:parseInt(U,10)})},C=async z=>{const U=new FormData;U.set("title",z?.title??"");try{await $e(p,U,a),w.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),o.resetFields(),await I()}catch(j){w.error(j?.response?.data?.msg??j?.message??"Failed to add category.",{duration:1e3})}},b=z=>{f(z??null),l.setFieldsValue({title:z?.name??""}),c(!0)},y=()=>{c(!1),f(null),l.resetFields()},S=async z=>{const U=g?.id??g?.category_id??g?.cat_id;if(!U){w.error("Missing category id.",{duration:1e3});return}const j=new FormData;j.set("id",String(U)),j.set("title",z?.title??"");try{await Xe(_,j,a),w.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),y(),await I()}catch(O){w.error(O?.response?.data?.msg??O?.message??"Failed to update category.",{duration:1e3})}},A=async z=>{const U=z?.id??z?.category_id??z?.cat_id;if(!U){w.error("Missing category id.",{duration:1e3});return}try{await Ye(v,U,a),w.success("Success! Deleted category.",{duration:1e3}),await I()}catch(j){w.error(j?.response?.data?.msg??j?.message??"Failed to delete category.",{duration:1e3})}},R=i.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(z,U)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>b(U)}),e.jsx(n.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>A(U),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[A]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:d,title:"Edit Category",onCancel:y,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:l,layout:"vertical",onFinish:S,children:[e.jsx(n.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(n.Input,{placeholder:"Enter category name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:y,children:"Cancel"}),e.jsx(re,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,lg:8,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:C,children:[e.jsx(n.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(n.Input,{placeholder:"Enter category name"})}),e.jsx(re,{type:"submit",value:"Add",color:"primary"})]})})}),e.jsx(n.Col,{xs:24,lg:16,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:e.jsx(Me,{parentCallback:k,data:{newData:T,columns:R,columnstype:"antd",action:!1,Loading:m,error:x}})})})]})]})}const ws=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Gu({token:t}){const[a,s]=i.useState([ae().format("YYYY-MM-DD"),ae().format("YYYY-MM-DD")]),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,g]=i.useState(null),[f,u]=i.useState(!1),[p,_]=i.useState(!1),v="api/branchapi/academy/classdropdownlist",h="api/branchapi/academy/sectionoftheClass",m="api/branchapi/library/memberDropdown",x="api/report/libraryReport/libraryReport",T=i.useMemo(()=>{if(!r?.value)return null;const E=h.includes("?")?"&":"?";return`${h}${E}class_id=${encodeURIComponent(String(r.value))}`},[h,r?.value]),I=i.useMemo(()=>{if(!r?.value)return null;const E=m.includes("?")?"&":"?",N=`${m}${E}class=${encodeURIComponent(String(r.value))}`;return l?.value?`${N}&section=${encodeURIComponent(String(l.value))}`:N},[m,r?.value,l?.value]),{isLoading:k,error:C,data:b,mutate:y}=H(t&&v?[v,t]:null,([E,N])=>X(E,N)),{data:S}=H(t&&T?[T,t]:null,([E,N])=>X(E,N)),{data:A}=H(t&&I?[I,t]:null,([E,N])=>X(E,N)),R=i.useMemo(()=>ws(b),[b]),z=i.useMemo(()=>ws(S),[S]),U=i.useMemo(()=>ws(A),[A]),{trigger:j,data:O}=nt(x,(E,N)=>Gs(E,N,t));i.useEffect(()=>{(async()=>{_(!0);try{await j({duration:a})}finally{_(!1)}})()},[]);const M=async()=>{_(!0);try{await j({duration:a,class:r?.value??"",section:l?.value??"",student_id:c?.value??""})}finally{_(!1)}},$=[{title:"Name",dataIndex:"full_name",render:(E,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(E,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(E,N)=>e.jsxs(n.Typography.Text,{style:{fontSize:12},children:[N?.class??"","(",N?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(E,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.book_title??""})},{title:"Issue Date",key:"date",render:(E,N,V)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.issue_date??""})},{title:"Due Return Date",key:"date",render:(E,N,V)=>e.jsx(n.Tag,{color:"orange",children:N?.return_date??""})},{title:"Return Date",key:"date",render:(E,N,V)=>N?.retured_by_user?e.jsx(n.Tag,{color:"green",children:N?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(E,N,V)=>String(N?.is_returned??"")==="1"?e.jsx(n.Tag,{color:"green",children:"Return"}):e.jsx(n.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:(E,N,V)=>{const q=N?.late_fine?Number(N.late_fine):0;return q?e.jsx(n.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:q}):null}}];return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[e.jsxs(n.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Duration"}),e.jsx(n.DatePicker.RangePicker,{style:{width:"100%"},value:[ae(a[0],"YYYY-MM-DD"),ae(a[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(E,N)=>{Array.isArray(N)&&N.length===2&&s([N[0],N[1]])}})]})}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(ee,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:r,onChange:E=>{o(E??null),d(null),g(null),u(N=>!N)},allowSelectAll:!1})}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(ee,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:l,onChange:E=>{d(E??null),g(null)},allowSelectAll:!1},`section1${f}`)}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:E=>g(E??null),allowSelectAll:!1})}),e.jsx(n.Col,{xs:24,md:1,children:e.jsx(n.Button,{type:"primary",icon:e.jsx(Z.SearchOutlined,{}),onClick:M,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(n.Table,{columns:$,pagination:!1,dataSource:Array.isArray(O?.data)?O.data:[],size:"small",rowKey:(E,N)=>E?.id??E?.issue_id??E?.fees_receipt_id??N,loading:p,scroll:{x:"max-content"},summary:E=>{const N=E.reduce((q,P)=>q+Number(P?.late_fine??0),0),V=E.reduce((q,P)=>q+Number(P?.is_returned??0),0);return e.jsxs(n.Table.Summary.Row,{children:[e.jsx(n.Table.Summary.Cell,{colSpan:4,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",E.length]})}),e.jsx(n.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(E.length-V)]})}),e.jsx(n.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",V]})}),e.jsx(n.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",N.toLocaleString("en-IN")]})})]})}})})]})]})}const ii=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],oi=[{key:"renewalHistory",label:"Renewal History"},{key:"renewalFineReport",label:"Renewal + Fine"},{key:"currentlyRenewedBooks",label:"Currently Renewed"},{key:"upcomingRenewalDue",label:"Upcoming Due"},{key:"overdueRenewalReport",label:"Overdue"},{key:"renewalLimitReport",label:"Renewal Limit"},{key:"renewalStatusReport",label:"Renewal Status"},{key:"studentWiseReport",label:"Student-wise"},{key:"bookWiseReport",label:"Book-wise"},{key:"classWiseReport",label:"Class-wise"},{key:"staffWiseReport",label:"Staff-wise"},{key:"renewalStatisticsByDate",label:"Statistics by Date"}];function Ju({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState("renewalHistory"),[o,l]=i.useState("This Month"),[d,c]=i.useState(""),[g,f]=i.useState(""),[u,p]=i.useState(7),[_,v]=i.useState(1),[h,m]=i.useState(20),[x,T]=i.useState(""),[I,k]=i.useState("DESC"),C=i.useRef(null),b=N=>{const V=new URLSearchParams;return["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(s)&&(V.set("date_range",o),o==="Custom"&&d&&g&&(V.set("from_date",d),V.set("to_date",g))),["renewalHistory","renewalFineReport","currentlyRenewedBooks","upcomingRenewalDue","overdueRenewalReport","renewalLimitReport","renewalStatusReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport"].includes(s)&&(V.set("page",String(_)),V.set("per_page",String(h))),s==="upcomingRenewalDue"&&V.set("days_ahead",String(u)),x&&V.set("sort_by",x),I&&V.set("sort_dir",I),`${N}?${V.toString()}`},y=i.useMemo(()=>{switch(s){case"renewalHistory":return b(Yd);case"renewalFineReport":return b(Vd);case"currentlyRenewedBooks":return b(Wd);case"upcomingRenewalDue":return b(Hd);case"overdueRenewalReport":return b(Kd);case"renewalLimitReport":return b(Gd);case"renewalStatusReport":return b(Jd);case"studentWiseReport":return b(Qd);case"bookWiseReport":return b(Xd);case"classWiseReport":return b(Zd);case"staffWiseReport":return b(ec);case"renewalStatisticsByDate":return b(tc);default:return null}},[s,o,d,g,u,_,h]),{data:S,isLoading:A}=H(a?[y,a]:null,([N,V])=>X(N,V)),R=S?.data||{},z=R?.rows||[],U=R?.pagination||{},j=N=>{r(N),v(1),m(20)},O=()=>{v(1)},M=()=>{switch(s){case"renewalHistory":case"renewalFineReport":return[{title:"Renewal ID",dataIndex:"renewal_id",key:"renewal_id"},{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Renewal No",dataIndex:"renewal_no",key:"renewal_no"},{title:"Old Due Date",dataIndex:"old_due_date",key:"old_due_date"},{title:"New Due Date",dataIndex:"new_due_date",key:"new_due_date"},{title:"Renewal Date",dataIndex:"renewal_date",key:"renewal_date"},{title:"Status",dataIndex:"status",key:"status",render:N=>e.jsx(n.Tag,{color:N==="renewed"?"green":"red",children:N})},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",render:N=>N??"-"},{title:"Paid Amount",dataIndex:"paid_amount",key:"paid_amount",render:N=>N??"-"},{title:"Due Amount",dataIndex:"due_amount",key:"due_amount",render:N=>N??"-"},{title:"Fine Status",dataIndex:"fine_payment_status",key:"fine_payment_status",render:N=>N?e.jsx(n.Tag,{color:N==="paid"?"green":N==="partial"?"orange":"red",children:N}):"-"}];case"currentlyRenewedBooks":case"upcomingRenewalDue":case"overdueRenewalReport":case"renewalLimitReport":case"renewalStatusReport":return[{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Due Date",dataIndex:"return_date",key:"return_date"},{title:"Renewal Count",dataIndex:"renewal_count",key:"renewal_count"},{title:"Max Renewal",dataIndex:"maximum_renewal",key:"maximum_renewal"},{title:"Days Remaining",dataIndex:"days_remaining",key:"days_remaining",render:N=>N??"-"},{title:"Overdue Days",dataIndex:"overdue_days",key:"overdue_days",render:N=>N??"-"},{title:"Fine",dataIndex:"fine_amount",key:"fine_amount",render:N=>N??"-"},{title:"Due",dataIndex:"due_amount",key:"due_amount",render:N=>N??"-"},{title:"Can Renew",dataIndex:"can_renew",key:"can_renew",render:N=>e.jsx(n.Tag,{color:N?"green":"red",children:N?"Yes":"No"})},{title:"Reasons",dataIndex:"reasons",key:"reasons",render:N=>Array.isArray(N)?N.join("; "):"-"}];case"studentWiseReport":return[{title:"Student ID",dataIndex:"student_id",key:"student_id"},{title:"Student Name",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Books",dataIndex:"unique_books_renewed",key:"unique_books_renewed"},{title:"First Renewal",dataIndex:"first_renewal_date",key:"first_renewal_date"},{title:"Last Renewal",dataIndex:"last_renewal_date",key:"last_renewal_date"}];case"bookWiseReport":return[{title:"Book ID",dataIndex:"book_id",key:"book_id"},{title:"Title",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Category",dataIndex:"category",key:"category"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"classWiseReport":return[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"staffWiseReport":return[{title:"Staff",dataIndex:"renewed_by",key:"renewed_by"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];case"renewalStatisticsByDate":return[{title:"Period",dataIndex:"period",key:"period"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];default:return[]}},$=["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(s),E=i.useMemo(()=>M(),[s]);return e.jsx(F,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,padding:"4px 8px",color:"#fff",display:"inline-block"}}),e.jsxs(F,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],mb:3,children:[$&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(ee,{options:ii,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:ii.find(N=>N.value===o)||null,onChange:N=>l(N?.value||"This Month")})}),o==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Le,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:N=>c(N?N.format("YYYY-MM-DD"):"")})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Le,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:N=>f(N?N.format("YYYY-MM-DD"):"")})})]})]}),s==="upcomingRenewalDue"&&e.jsx(n.Col,{xs:24,md:6,children:e.jsx(ee,{options:[{label:"7 Days",value:7},{label:"14 Days",value:14},{label:"30 Days",value:30}],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Days Ahead",allowSelectAll:!1,value:{label:u+" Days",value:u},onChange:N=>p(N?.value||7)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(F,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(re,{type:"button",value:"Search",color:"primary",onClick:O})})})]}),e.jsx(n.Tabs,{activeKey:s,onChange:j,items:oi})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:oi.find(N=>N.key===s)?.label||"Report"})}),e.jsxs(F,{p:3,children:[e.jsx(xt,{data:{tableRef:C}}),A?e.jsx(F,{py:8,textAlign:"center",children:e.jsx(n.Typography.Text,{type:"secondary",children:"Loading report data..."})}):e.jsx(n.Table,{size:"small",dataSource:z,columns:E,loading:A,pagination:!1,bordered:!0,rowKey:N=>N.renewal_id||N.id||JSON.stringify(N),ref:C}),z.length>0&&e.jsx(n.Pagination,{current:_,pageSize:h,total:U.total_rows||z.length,onChange:(N,V)=>{v(N),m(V)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const Zn=t=>t??localStorage.getItem("authToken")??"",Qu=(t,a)=>{const s=String(t??""),r=String(a);return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},qe={upload:"api/branchapi/frontoffice/uploadfrontofficeDocument",academy:{classes:"api/branchapi/academy/classdropdownlist",sections:"api/branchapi/academy/sectionoftheClass"},student:{dropdown:"api/branchapi/student/studentDropdown"},vendor:{list:"api/accounts/vendor/vendorTable",add:"api/accounts/vendor/addvendor",edit:"api/accounts/vendor/editVendor",remove:"api/accounts/vendor/removecategory",dropdown:"api/accounts/vendor/vendorlist"},category:{list:"api/accounts/category/fetchcategorytable",add:"api/accounts/category/addcategory",edit:"api/accounts/category/editcategory",remove:"api/accounts/category/removecategory",dropdown:"api/accounts/category/categoryDropdown"},subCategory:{list:"api/accounts/category/fetchsubcategorytable",add:"api/accounts/category/addsubcategory",edit:"api/accounts/category/editsubcategory",remove:"api/accounts/category/removesubcategory",dropdown:"api/accounts/category/subcategoryDropdown"},unit:{list:"api/accounts/category/fetchunit",add:"api/accounts/category/addunit",edit:"api/accounts/category/editunit",remove:"api/accounts/category/removeunit",dropdown:"api/accounts/category/unitDropdown"},product:{list:"api/accounts/product/fetchproducttable",add:"api/accounts/product/addproduct",edit:"api/accounts/product/editproduct",remove:"api/accounts/product/removeproduct",dropdown:"api/accounts/product/productdropdown",search:"api/accounts/product/searchproductbyNameandBarcode",addStock:"api/accounts/product/addStock",sellProduct:"api/accounts/product/sellproduct",sellReports:"api/accounts/product/getstoreSellReports"},report:{stock:"api/report/StoreReport/stock_report"}},Xu=()=>Qu(et(),qe.upload),Zu=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return X(l,Zn(r))},Qa=async(t,a,s)=>$e(t,a,Zn(s)),ja=async(t,a,s)=>Xe(t,a,Zn(s)),Xa=async(t,a,s)=>Ye(t,a,Zn(s)),ep=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ha=({token:t,value:a,onChange:s})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:Xu(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=ep(o?.file?.response);l&&s?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},In=qe.vendor,Za=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>H(r&&t?[t,a,s,r]:null,([l,d,c,g])=>Zu({baseUrl:l,page:d,perPage:c},g)),tp=({token:t,page:a=1,perPage:s=10})=>Za({baseUrl:In.list,page:a,perPage:s,token:t}),ap={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},li=[{name:"name",label:"Name*",required:!0,type:"text"},{name:"email",label:"Email*",required:!0,type:"text"},{name:"address",label:"Address*",required:!0,type:"text"},{name:"phone",label:"Phone*",required:!0,type:"number"},{name:"business_name",label:"Brand Name*",required:!0,type:"text"},{name:"acc_number",label:"Account Number",required:!1,type:"text"},{name:"ifsc_code",label:"IFSC Code",required:!1,type:"text"},{name:"acc_holder_name",label:"Account Holder Name",required:!1,type:"text"},{name:"gst_number",label:"GST Number",required:!1,type:"text"},{name:"cin_num",label:"CIN Number",required:!1,type:"text"},{name:"upi_id",label:"UPI ID",required:!1,type:"text"}];function np({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,g]=i.useState(""),{isLoading:f,error:u,data:p,mutate:_}=tp({token:t,page:a.page,perPage:a.rowsPerPage}),v=async C=>{try{await _(Qa(In.add,C,t),Ve(C)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(b){w.error(b?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},h=C=>{C.preventDefault();const b=new FormData(C.target);c&&b.set("image",c),v(b),C.target.reset(),g("")},m=(C,b)=>{s({page:C,rowsPerPage:parseInt(b,10)})},x=async C=>{try{await _(Xa(In.remove,C,t),Be(C)),w.success("Success! Deleted item.",{duration:1e3})}catch(b){w.error(b?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},T=C=>{d(C),o(!0),g("")},I=async C=>{C.preventDefault();const b=new FormData(C.target);b.set("id",String(l?.id??"")),c&&b.set("image",c);try{await ja(In.edit,b,t),await _(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),g("")}catch(y){w.error(y?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},k=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Email",dataIndex:"email",key:"email",ellipsis:!0,responsive:["md"]},{title:"Address",dataIndex:"address",key:"address",ellipsis:!0,responsive:["lg"]},{title:"Phone",dataIndex:"phone",key:"phone",ellipsis:!0,responsive:["md"]},{title:"Branch Name",dataIndex:"business_name",key:"business_name",ellipsis:!0,responsive:["lg"]},{title:"Account Holder",dataIndex:"acc_holder_name",key:"acc_holder_name",ellipsis:!0,responsive:["xl"]},{title:"Account Number",dataIndex:"acc_number",key:"acc_number",ellipsis:!0,responsive:["xl"]},{title:"UPI ID",dataIndex:"upi_id",key:"upi_id",ellipsis:!0,responsive:["xl"]},{title:"Action",key:"action",width:100,fixed:"right",render:(C,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>T(b),style:{padding:2}}),e.jsx(mt,{id:b?.id,funcName:x})]})}],[x]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Vendor",placement:"right",width:520,onClose:()=>{o(!1),d(null),g("")},children:e.jsx("form",{onSubmit:I,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[li.map(C=>e.jsx(Y,{type:C.type,name:C.name,label:C.label,defaultValue:l?.[C.name]??"",required:C.required?"required":void 0},C.name)),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ha,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),g("")},style:ap,children:"Cancel"})]})]})})}),e.jsxs(F,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(F,{px:3,pb:2,children:e.jsx("form",{onSubmit:h,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[li.map(C=>e.jsx(Y,{type:C.type,name:C.name,label:C.label,required:C.required?"required":void 0},C.name)),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ha,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(F,{pt:3,children:e.jsx(Me,{parentCallback:m,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:f,error:u}})})]})]})]})}const sp=({token:t})=>e.jsx(np,{token:t}),kn=qe.product,di=qe.vendor.dropdown,ci=qe.category.dropdown,rp=qe.subCategory.dropdown,ui=qe.unit.dropdown,$o=({token:t,page:a=1,perPage:s=10})=>Za({baseUrl:kn.list,page:a,perPage:s,token:t}),ip=({token:t})=>H(t&&di?[di,t]:null,([s,r])=>X(s,r)),op=({token:t})=>H(t&&ci?[ci,t]:null,([s,r])=>X(s,r)),lp=({token:t})=>H(t&&ui?[ui,t]:null,([s,r])=>X(s,r)),dp=({token:t,categoryId:a})=>{const s=t&&a?`${rp}?category_id=${encodeURIComponent(String(a))}`:null;return H(s?[s,t]:null,([o,l])=>X(o,l))},hn=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},cp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function up({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,g]=i.useState(""),[f,u]=i.useState(""),[p,_]=i.useState(""),[v,h]=i.useState(""),[m,x]=i.useState(""),{isLoading:T,error:I,data:k,mutate:C}=$o({token:t,page:a.page,perPage:a.rowsPerPage}),{data:b}=ip({token:t}),{data:y}=op({token:t}),{data:S}=lp({token:t}),{data:A}=dp({token:t,categoryId:f}),R=i.useMemo(()=>hn(b),[b]),z=i.useMemo(()=>hn(y),[y]),U=i.useMemo(()=>hn(S),[S]),j=i.useMemo(()=>hn(A),[A]),O=async P=>{try{await C(Qa(kn.add,P,t),Ve(P)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){w.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},M=P=>{P.preventDefault();const D=new FormData(P.target);f&&D.set("fk_categoryID",String(f)),p&&D.set("fk_sub_categoryID",String(p)),v&&D.set("vendor_id",String(v)),m&&D.set("unit",String(m)),c&&D.set("image",c),O(D),P.target.reset(),g(""),u(""),_(""),h(""),x("")},$=(P,D)=>{s({page:P,rowsPerPage:parseInt(D,10)})},E=async P=>{try{await C(Xa(kn.remove,P,t),Be(P)),w.success("Success! Deleted item.",{duration:1e3})}catch(D){w.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},N=P=>{d(P),o(!0),g(""),u(P?.fk_categoryID??P?.category_id??""),_(P?.fk_sub_categoryID??P?.sub_category_id??""),h(P?.vendor_id??""),x(P?.unit??P?.unit_id??"")},V=async P=>{P.preventDefault();const D=new FormData(P.target);D.set("id",String(l?.id??"")),f&&D.set("fk_categoryID",String(f)),p&&D.set("fk_sub_categoryID",String(p)),v&&D.set("vendor_id",String(v)),m&&D.set("unit",String(m)),c&&D.set("image",c);try{await ja(kn.edit,D,t),await C(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),g("")}catch(L){w.error(L?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},q=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,responsive:["lg"]},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",ellipsis:!0,width:100,responsive:["md"]},{title:"Unit",dataIndex:"unit_name",key:"unit_name",ellipsis:!0,width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",ellipsis:!0,width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["xl"]},{title:"Hsn Code",dataIndex:"hsn_code",key:"hsn_code",ellipsis:!0,responsive:["xl"]},{title:"Action",key:"action",width:100,fixed:"right",render:(P,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>N(D),style:{padding:2}}),e.jsx(mt,{id:D?.id,funcName:E})]})}],[E]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Product",placement:"right",width:520,onClose:()=>{o(!1),d(null),g("")},children:e.jsx("form",{onSubmit:V,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx(Y,{type:"text",name:"name",label:"Product Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(ee,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:P=>{const D=P?.value??"";u(D),_("")},defaultValue:f?z.find(P=>String(P?.value)===String(f)):null}),e.jsx(ee,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:P=>_(P?.value??""),defaultValue:p?j.find(P=>String(P?.value)===String(p)):null}),e.jsx(Y,{type:"text",name:"barcode",label:"Barcode",defaultValue:l?.barcode??""}),e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:P=>x(P?.value??""),defaultValue:m?U.find(P=>String(P?.value)===String(m)):null}),e.jsx(Y,{type:"number",name:"quantity",label:"Quantity*",defaultValue:l?.quantity??"",required:"required"}),e.jsx(Y,{type:"number",name:"price",label:"Price*",defaultValue:l?.price??"",required:"required"}),e.jsx(ee,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:P=>h(P?.value??""),defaultValue:v?R.find(P=>String(P?.value)===String(v)):null}),e.jsx(Y,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:l?.hsn_code??""}),e.jsx(wt,{type:"text",label:"Description",name:"description",rows:3,defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ha,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),g("")},style:cp,children:"Cancel"})]})]})})}),e.jsxs(F,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(F,{px:3,pb:2,children:e.jsx("form",{onSubmit:M,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Product Name*",required:"required"}),e.jsx(ee,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:P=>{const D=P?.value??"";u(D),_("")}}),e.jsx(ee,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:P=>_(P?.value??"")},`subcat_${f}`),e.jsx(Y,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:P=>x(P?.value??"")}),e.jsx(Y,{type:"number",name:"quantity",label:"Quantity*",required:"required"}),e.jsx(Y,{type:"number",name:"price",label:"Price*",required:"required"}),e.jsx(ee,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:P=>h(P?.value??"")}),e.jsx(Y,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(wt,{type:"text",label:"Description",name:"description",rows:3}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ha,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(F,{pt:3,children:e.jsx(Me,{parentCallback:$,data:{newData:k,columns:q,columnstype:"antd",action:!1,Loading:T,error:I}})})]})]})]})}const pp=({token:t})=>e.jsx(up,{token:t}),Pn=qe.category,mp=({token:t,page:a=1,perPage:s=10})=>Za({baseUrl:Pn.list,page:a,perPage:s,token:t}),fp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function yp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:g,data:f,mutate:u}=mp({token:t,page:a.page,perPage:a.rowsPerPage}),p=async I=>{try{await u(Qa(Pn.add,I,t),Ve(I)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(k){w.error(k?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},_=I=>{I.preventDefault();const k=new FormData(I.target);p(k),I.target.reset()},v=(I,k)=>{s({page:I,rowsPerPage:parseInt(k,10)})},h=async I=>{try{await u(Xa(Pn.remove,I,t),Be(I)),w.success("Success! Deleted item.",{duration:1e3})}catch(k){w.error(k?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},m=I=>{d(I),o(!0)},x=async I=>{I.preventDefault();const k=new FormData(I.target);k.set("id",String(l?.id??""));try{await ja(Pn.edit,k,t),await u(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(C){w.error(C?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},T=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(I,k)=>String(I?.name??"").localeCompare(String(k?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(I,k)=>String(I?.description??"").localeCompare(String(k?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(I,k)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>m(k),style:{padding:2}}),e.jsx(mt,{id:k?.id,funcName:h})]})}],[h]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Category",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"name",label:"Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:fp,children:"Cancel"})]})]})})}),e.jsxs(F,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(F,{px:3,pb:2,children:e.jsx("form",{onSubmit:_,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(F,{pt:3,children:e.jsx(Me,{parentCallback:v,data:{newData:f,columns:T,columnstype:"antd",action:!1,Loading:c,error:g}})})]})]})]})}const hp=({token:t})=>e.jsx(yp,{token:t}),On=qe.subCategory,pi=qe.category.dropdown,gp=({token:t,page:a=1,perPage:s=10})=>Za({baseUrl:On.list,page:a,perPage:s,token:t}),xp=({token:t})=>H(t&&pi?[pi,t]:null,([s,r])=>X(s,r)),bp=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},jp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Sp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,g]=i.useState(""),{isLoading:f,error:u,data:p,mutate:_}=gp({token:t,page:a.page,perPage:a.rowsPerPage}),{data:v}=xp({token:t}),h=i.useMemo(()=>bp(v),[v]),m=async y=>{try{await _(Qa(On.add,y,t),Ve(y)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(S){w.error(S?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},x=y=>{y.preventDefault();const S=new FormData(y.target);S.set("status","active"),S.set("img",c||""),m(S),y.target.reset(),g("")},T=(y,S)=>{s({page:y,rowsPerPage:parseInt(S,10)})},I=async y=>{try{await _(Xa(On.remove,y,t),Be(y)),w.success("Success! Deleted item.",{duration:1e3})}catch(S){w.error(S?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},k=y=>{d(y),o(!0)},C=async y=>{y.preventDefault();const S=new FormData(y.target);S.set("id",String(l?.id??"")),c&&S.set("img",c);try{await ja(On.edit,S,t),await _(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),g("")}catch(A){w.error(A?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},b=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(y,S)=>String(y?.name??"").localeCompare(String(S?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(y,S)=>String(y?.description??"").localeCompare(String(S?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(y,S)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>k(S),style:{padding:2}}),e.jsx(mt,{id:S?.id,funcName:I})]})}],[I]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Sub Category",placement:"right",width:420,onClose:()=>{o(!1),d(null),g("")},children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:l?.category_id?h.find(y=>String(y?.value)===String(l.category_id)):null,allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"text",name:"name",label:"Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ha,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),g("")},style:jp,children:"Cancel"})]})]})})}),e.jsxs(F,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(F,{px:3,pb:2,children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ha,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(F,{pt:3,children:e.jsx(Me,{parentCallback:T,data:{newData:p,columns:b,columnstype:"antd",action:!1,Loading:f,error:u}})})]})]})]})}const vp=({token:t})=>e.jsx(Sp,{token:t}),Cs=qe.product,_p=qe.academy.classes,wp=qe.academy.sections,Cp=qe.student.dropdown;function Da(t){const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]}function gn(t,a){const s=Math.trunc(Number(t)||1),r=Math.max(1,s);return!Number.isFinite(Number(a))||Number(a)<=0?r:Math.min(r,Math.trunc(Number(a)))}function rt(t){return String(t??"")}function Ap({token:t}){const[a,s]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,g]=i.useState(!1),[f,u]=i.useState(""),[p,_]=i.useState([]),[v,h]=i.useState({}),[m,x]=i.useState({}),[T,I]=i.useState(!1),[k,C]=i.useState(""),[b,y]=i.useState(0),[S,A]=i.useState(""),[R,z]=i.useState(ae()),[U,j]=i.useState([]),O={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},M=!!(a&&r&&l),{data:$}=H(t?[_p,t]:null,([fe,xe])=>X(fe,xe)),E=i.useMemo(()=>Da($),[$]),N=t&&a?`${wp}?class_id=${encodeURIComponent(String(a))}`:null,{data:V}=H(N?[N,t]:null,([fe,xe])=>X(fe,xe)),q=i.useMemo(()=>Da(V),[V]),P=t&&a&&r?`${Cp}?class=${encodeURIComponent(String(a))}&section=${encodeURIComponent(String(r))}`:null,{data:D}=H(P?[P,t]:null,([fe,xe])=>X(fe,xe)),L=i.useMemo(()=>Da(D),[D]),B=M?`${Cs.list}?page=1&per_page=10000`:null,{data:W,isLoading:se}=H(t&&B?[B,t]:null,([fe,xe])=>X(fe,xe),{revalidateOnFocus:!1}),Q=i.useMemo(()=>Da(W),[W]),K=i.useMemo(()=>{const fe=new Map;return(Array.isArray(Q)?Q:[]).forEach(xe=>{fe.set(rt(xe?.id),xe)}),fe},[Q]),te=i.useMemo(()=>{const fe=Object.entries(m||{});return fe.length===0?[]:fe.map(([xe,ge])=>{const ne=K.get(rt(xe));return ne?{id:ne?.id,name:ne?.name,barcode:ne?.barcode,stock:Number(ne?.quantity||0),price:Number(ne?.price||0),quantity:gn(ge,Number(ne?.quantity||0))}:null}).filter(Boolean)},[m,K]),ie=i.useMemo(()=>new Set(te.map(fe=>rt(fe?.id))),[te]),pe=i.useMemo(()=>(Array.isArray(te)?te:[]).reduce((xe,ge)=>xe+Number(ge?.price||0)*Number(ge?.quantity||1),0),[te]),_e=i.useMemo(()=>{const fe=Number(b||0);return!Number.isFinite(fe)||fe<=0?0:Math.min(fe,pe)},[b,pe]),oe=i.useMemo(()=>Math.max(0,pe-_e),[_e,pe]),le=i.useMemo(()=>(Array.isArray(Q)?Q:[]).slice(0,30).map(fe=>({value:rt(fe?.id),label:`${fe?.name??""}${fe?.barcode?` • ${fe.barcode}`:""}${fe?.quantity!==void 0&&fe?.quantity!==null?` • Stock: ${fe.quantity}`:""}`,product:fe})),[Q]),{trigger:G}=nt(t&&M?Cs.search:null,(fe,{arg:xe})=>Ht(fe,{arg:xe},t));i.useEffect(()=>{if(!M){_([]);return}const fe=String(f||"").trim();if(fe.length<2){_(le);return}let xe=!0;const ge=setTimeout(async()=>{let ne=[];try{if(G){const he=await G({search:fe});ne=Da(he)}}catch{ne=[]}if(!Array.isArray(ne)||ne.length===0){const he=fe.toLowerCase();ne=(Array.isArray(Q)?Q:[]).filter(Te=>{const Re=String(Te?.name??"").toLowerCase(),bt=String(Te?.barcode??"").toLowerCase();return Re.includes(he)||bt.includes(he)}).slice(0,30)}const me=ne.slice(0,30).map(he=>({value:rt(he?.id),label:`${he?.name??""}${he?.barcode?` • ${he.barcode}`:""}${he?.quantity!==void 0&&he?.quantity!==null?` • Stock: ${he.quantity}`:""}`,product:he}));xe&&_(me)},250);return()=>{xe=!1,clearTimeout(ge)}},[le,M,G,Q,f]),i.useEffect(()=>{x({}),h({}),u(""),_([]),I(!1),C(""),y(0),A(""),z(ae()),j([])},[a,r,l]);const de=i.useCallback((fe,xe=1)=>{const ge=fe?.id;if(!ge)return;const ne=Number(fe?.quantity||0);if(ne<=0){w.error("Out of stock.",{duration:1e3});return}const me=gn(xe,ne);x(he=>{const Te=he||{};return Object.prototype.hasOwnProperty.call(Te,rt(ge))?(w.error("Product already added.",{duration:1e3}),Te):{...Te,[rt(ge)]:me}})},[x]),Ae=i.useCallback((fe,xe,ge)=>{x(ne=>{const me=ne||{},he=rt(fe);return Object.prototype.hasOwnProperty.call(me,he)?{...me,[he]:gn(xe,ge)}:me})},[]),Ee=i.useCallback(fe=>{x(xe=>{const ge=xe||{},ne=rt(fe);if(!Object.prototype.hasOwnProperty.call(ge,ne))return ge;const me={...ge};return delete me[ne],me})},[]),Pe=i.useCallback((fe,xe,ge)=>{h(ne=>({...ne||{},[rt(fe)]:gn(xe,ge)}))},[]),ze=i.useCallback((fe,xe)=>{xe?.product&&de(xe.product,1),u(""),_(le)},[de,le]),Fe=i.useCallback(fe=>{if(fe.key!=="Enter")return;fe.preventDefault();const xe=Array.isArray(p)&&p.length>0?p[0]:null;if(xe?.product){de(xe.product,1),u(""),_(le);return}const ge=String(f||"").trim().toLowerCase();if(ge.length===0)return;const ne=(Array.isArray(Q)?Q:[]).find(me=>{const he=String(me?.name??"").toLowerCase(),Te=String(me?.barcode??"").toLowerCase();return he.includes(ge)||Te.includes(ge)});ne&&(de(ne,1),u(""),_(le))},[de,le,Q,p,f]),tt=()=>{if(!t){w.error("Missing token.",{duration:1e3});return}if(!a){w.error("Select class.",{duration:1e3});return}if(!r){w.error("Select section.",{duration:1e3});return}if(!l){w.error("Select student.",{duration:1e3});return}if(!te||te.length===0){w.error("Add at least one product.",{duration:1e3});return}I(!0)},{trigger:Ke,isMutating:Ue}=nt(t?Cs.sellProduct:null,(fe,{arg:xe})=>Xn(fe,{arg:xe},t)),Ge=async()=>{if(!k){w.error("Select payment type.",{duration:1e3});return}const fe=(Array.isArray(te)?te:[]).map(ge=>({id:ge?.id,quantity:Number(ge?.quantity||1),price:Number(ge?.price||0),total_price:Number(ge?.total_price||0),fk_vendor_id:ge?.fk_vendor_id||"",fk_categoryID:ge?.fk_categoryID||"",name:ge?.name||"",class_id:ge?.class_id||"",fk_sub_categoryID:ge?.fk_sub_categoryID||"",description:ge?.description||"",min_quantity:Number(ge?.min_quantity||0),storecategory:Number(ge?.storecategory||0),barcode:ge?.barcode||""})),xe={amount:pe,class:a,section:r,student_id:l,payment_type:k,discount:_e,notes:S||"",receipt_date:R?ae(R).format("YYYY-MM-DD"):"",product:JSON.stringify(fe),total_payable_amount:pe,attchement:U[0]?.originFileObj||""};try{const ne=Array.isArray(U)&&U.length>0&&U[0]?.originFileObj?(()=>{const he=new FormData;return Object.entries(xe).forEach(([Te,Re])=>{if(Te==="products"){he.append("product",JSON.stringify(Re));return}he.append(Te,String(Re??""))}),he.append("attachment",U[0].originFileObj),he})():xe,me=await Ke(ne);me?.Status==="Success"?(w.success("Success! Product sold.",{duration:1e3}),I(!1),x({}),h({}),u(""),_(le),C(""),y(0),A(""),z(ae()),j([])):w.error(me?.msg??"Failed to submit.",{duration:1e3})}catch{w.error("Failed to submit.",{duration:1e3})}},dt=i.useMemo(()=>[{title:"Product Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:160},{title:"Stock",dataIndex:"quantity",key:"quantity",width:110},{title:"Price",dataIndex:"price",key:"price",width:120},{title:"Quantity",key:"quantity",width:160,render:(fe,xe)=>{const ge=rt(xe?.id),ne=Number(xe?.quantity||0),me=ie.has(ge),he=(me?m?.[ge]:v?.[ge])??1;return e.jsx(n.InputNumber,{min:1,max:Number.isFinite(ne)&&ne>0?ne:void 0,value:he,onChange:Te=>{me?Ae(ge,Te,ne):Pe(ge,Te,ne)},disabled:ne<=0})}},{title:"Amount",key:"amount",width:140,render:(fe,xe)=>{const ge=rt(xe?.id),ne=(ie.has(ge)?m?.[ge]:v?.[ge])??1;return Number(xe?.price||0)*Number(ne||1)}},{title:"Action",key:"action",width:120,render:(fe,xe)=>{const ge=rt(xe?.id),ne=Number(xe?.quantity||0),me=ie.has(ge),he=(me?m?.[ge]:v?.[ge])??1;return me?e.jsx(n.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(Z.DeleteOutlined,{}),onClick:()=>Ee(ge),style:{padding:2}}):e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.PlusOutlined,{}),disabled:ne<=0,onClick:()=>de(xe,he),style:{padding:2}})}}],[de,ie,m,v,Ee,Pe,Ae]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(F,{pt:5,pb:2,children:[e.jsxs(F,{style:{padding:"12px 16px"},children:[e.jsx(F,{children:"Sell Product"}),e.jsx(n.Card,{style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(ee,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:fe=>{const xe=fe?.value??"";s(xe),o(""),d(""),g(ge=>!ge)}}),e.jsx(ee,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:fe=>{const xe=fe?.value??"";o(xe),d("")}},`section_${c}`),e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:fe=>d(fe?.value??"")})]})})]}),e.jsx("div",{style:{padding:"0 16px"},children:e.jsxs(n.Card,{style:{borderRadius:16,marginTop:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(260px, 520px) 1fr",gap:12,alignItems:"center",marginBottom:12},children:[e.jsx(F,{style:{marginTop:12},children:"Product Section"}),e.jsx(n.AutoComplete,{value:f,options:p,onSearch:u,onFocus:()=>{M&&String(f||"").trim().length<2&&_(le)},onSelect:ze,disabled:!M,children:e.jsx(n.Input,{placeholder:"Search by product name or barcode",onKeyDown:Fe,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",_t(pe)]})]}),e.jsx(n.Table,{rowKey:fe=>rt(fe?.id),columns:dt,dataSource:Q,loading:se,size:"small",bordered:!0,pagination:{pageSize:50,showSizeChanger:!0,pageSizeOptions:[25,50,100,200]},scroll:{x:"max-content"}}),e.jsxs("div",{style:{position:"sticky",bottom:0,background:"#fff",paddingTop:12,marginTop:12,borderTop:"1px solid #f0f0f0"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Selected Items"}),e.jsx("span",{children:te.length})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700,marginTop:6},children:[e.jsx("span",{children:"Total Amount"}),e.jsx("span",{children:_t(pe)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(re,{type:"button",value:"Submit",disabled:!M||te.length===0,onClick:tt,style:{flex:1,minWidth:140}}),e.jsx(n.Button,{type:"text",style:O,onClick:()=>{x({}),h({}),u(""),_(le)},disabled:te.length===0,children:"Clear"})]})]})]})})]}),e.jsx(n.Modal,{open:T,title:"Payment",onCancel:()=>I(!1),onOk:Ge,confirmLoading:Ue,okText:"Submit",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Payment Type"}),e.jsx(n.Select,{value:k||void 0,onChange:C,placeholder:"Select payment type",style:{width:"100%"},options:[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"Bank",label:"Bank"},{value:"Cheque",label:"Cheque"},{value:"DD",label:"DD"},{value:"Internet Banking",label:"Internet Banking"}]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Receipt Date"}),e.jsx(n.DatePicker,{value:R,onChange:fe=>z(fe),style:{width:"100%"},format:"YYYY-MM-DD"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Discount"}),e.jsx(n.InputNumber,{min:0,max:pe,value:b,onChange:fe=>y(Number(fe||0)),style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Attachment"}),e.jsx(n.Upload,{fileList:U,beforeUpload:()=>!1,onChange:({fileList:fe})=>j((fe||[]).slice(-1)),maxCount:1,children:e.jsx(n.Button,{icon:e.jsx(Z.UploadOutlined,{}),children:"Upload"})})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Notes"}),e.jsx(n.Input.TextArea,{value:S,onChange:fe=>A(fe.target.value),rows:3})]}),e.jsx(n.Card,{style:{borderRadius:12,background:"#fafcff"},children:e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Total Amount"}),e.jsx("span",{children:_t(pe)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:_t(_e)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Net Amount"}),e.jsx("span",{children:_t(oe)})]})]})})]})})]})}const Tp=({token:t})=>e.jsx(Ap,{token:t}),Mn=qe.unit,Rp=({token:t,page:a=1,perPage:s=10})=>Za({baseUrl:Mn.list,page:a,perPage:s,token:t}),Dp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Ip({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:g,data:f,mutate:u}=Rp({token:t,page:a.page,perPage:a.rowsPerPage}),p=async I=>{try{await u(Qa(Mn.add,I,t),Ve(I)),w.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(k){w.error(k?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},_=I=>{I.preventDefault();const k=new FormData(I.target);p(k),I.target.reset()},v=(I,k)=>{s({page:I,rowsPerPage:parseInt(k,10)})},h=async I=>{try{await u(Xa(Mn.remove,I,t),Be(I)),w.success("Success! Deleted item.",{duration:1e3})}catch(k){w.error(k?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},m=I=>{d(I),o(!0)},x=async I=>{I.preventDefault();const k=new FormData(I.target);k.set("id",String(l?.id??""));try{await ja(Mn.edit,k,t),await u(),w.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(C){w.error(C?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},T=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(I,k)=>String(I?.name??"").localeCompare(String(k?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(I,k)=>String(I?.description??"").localeCompare(String(k?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(I,k)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>m(k),style:{padding:2}}),e.jsx(mt,{id:k?.id,funcName:h})]})}],[h]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Unit",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"name",label:"Unit Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Dp,children:"Cancel"})]})]})})}),e.jsxs(F,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(F,{px:3,pb:2,children:e.jsx("form",{onSubmit:_,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Unit Name*",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ke,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(F,{pt:3,children:e.jsx(Me,{parentCallback:v,data:{newData:f,columns:T,columnstype:"antd",action:!1,Loading:c,error:g}})})]})]})]})}const kp=({token:t})=>e.jsx(Ip,{token:t}),Pp=qe.product.sellReports,Op=qe.academy.classes,Mp=qe.academy.sections,Ep=qe.student.dropdown,mi=t=>{const a=Number(t??0);return Number.isFinite(a)?a.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function Fp({token:t}){const a=i.useRef(null),[s,r]=i.useState(null),[o,l]=i.useState(""),[d,c]=i.useState(""),[g,f]=i.useState(""),[u,p]=i.useState(!1),_=j=>{const O=j?.data?.data??j?.data??j??[];return Array.isArray(O)?O:Array.isArray(O?.data)?O.data:[]},{data:v}=H(t?[Op,t]:null,([j,O])=>X(j,O)),h=i.useMemo(()=>_(v),[v]),m=t&&o?`${Mp}?class_id=${encodeURIComponent(String(o))}`:null,{data:x}=H(m?[m,t]:null,([j,O])=>X(j,O)),T=i.useMemo(()=>_(x),[x]),I=t&&o&&d?`${Ep}?class=${encodeURIComponent(String(o))}&section=${encodeURIComponent(String(d))}`:null,{data:k}=H(I?[I,t]:null,([j,O])=>X(j,O)),C=i.useMemo(()=>_(k),[k]),{trigger:b,isMutating:y,data:S}=nt(Pp,(j,{arg:O})=>Gs(j,{arg:O},t));i.useEffect(()=>{const O=new Date().toISOString().slice(0,10);b({duration:[O,O]})},[b]);const A=i.useMemo(()=>{const j=S?.data??S??[];return Array.isArray(j)?j:[]},[S]),R=j=>{const O=Array.isArray(j?.product_details)?j.product_details:[];return O.length===0?null:e.jsx(n.Table,{size:"small",bordered:!0,pagination:!1,rowKey:M=>`${j?.receipt_id??"r"}_${M?.product_name??M?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:M=>mi(M)}],dataSource:O})},z=[{title:"Receipt No",dataIndex:"receipt_no",key:"receipt_no"},{title:"Date",dataIndex:"receipt_date",key:"receipt_date"},{title:"Amount",dataIndex:"receipt_amount",key:"receipt_amount",render:j=>mi(j)}],U=async()=>{if(!s||s.length!==2)return;const[j,O]=s;await b({duration:[j.format("YYYY-MM-DD"),O.format("YYYY-MM-DD")],class:o||"",section:d||"",student_id:g||""})};return e.jsx("div",{children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,lg:8,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Filters"}),style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Duration"}),e.jsx(n.DatePicker.RangePicker,{value:s,onChange:r,style:{width:"100%"}})]}),e.jsx(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:j=>{const O=j?.value??"";l(O),c(""),f(""),p(M=>!M)}}),e.jsx(ee,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:j=>{const O=j?.value??"";c(O),f("")}},`section_${u}`),e.jsx(ee,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:j=>f(j?.value??"")}),e.jsx(re,{type:"button",value:y?"Searching...":"Search",disabled:y,onClick:U,style:{width:"100%"}})]})})}),e.jsx(n.Col,{xs:24,lg:16,children:e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Sell Reports"}),e.jsx(xt,{data:{tableRef:a}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(It,{})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:y,rowKey:j=>String(j?.receipt_id??j?.receipt_no??Math.random()),columns:z,expandable:{expandedRowRender:R},dataSource:A,pagination:{pageSize:20}})]})})})]})})}const $p=({token:t})=>e.jsx(Fp,{token:t}),Up=qe.product;function Np({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState([]),[l,d]=i.useState([]),[c,g]=i.useState(!1),[f,u]=i.useState(!1),[p,_]=i.useState(null),[v,h]=i.useState(0),[m,x]=i.useState(null),[T,I]=i.useState(""),k=i.useRef(null),C=xa.useReactToPrint({contentRef:k,documentTitle:"Stock Barcodes"}),{isLoading:b,error:y,data:S,mutate:A}=$o({token:t,page:a.page,perPage:a.rowsPerPage}),R=($,E)=>{s({page:$,rowsPerPage:parseInt(E,10)})},z={selectedRowKeys:r,onChange:($,E)=>{o($),d(E)}},U=$=>{_($),h(Number($?.quantity??0)),x(null),I(""),g(!0)},j=()=>{g(!1),_(null),h(0),x(null),I("")},O=async()=>{if(!p?.id)return;u(!0);const $=new FormData;$.append("product_id",String(p.id)),$.append("qty",String(v??0)),m&&$.append("tran_date",m.format("YYYY-MM-DD")),T&&$.append("remarks",T);try{const E=await ja(Up.addStock,$,t);E?.Status==="Success"?(w.success("Success! Updated quantity.",{duration:1e3}),j(),await A()):w.error(E?.msg??"Failed to update quantity.",{duration:1e3})}catch{w.error("Failed to update quantity.",{duration:1e3})}finally{u(!1)}},M=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",width:100},{title:"Unit",dataIndex:"unit_name",key:"unit_name",width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["lg"]},{title:"Action",key:"action",width:160,fixed:"right",render:($,E)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(n.Button,{size:"small",onClick:()=>U(E),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:p?.name?`Update Stock: ${p.name}`:"Update Stock",open:c,onCancel:j,onOk:O,okButtonProps:{loading:f},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Quantity"}),e.jsx(n.InputNumber,{min:0,style:{width:"100%"},value:v,onChange:$=>h($??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{style:{width:"100%"},value:m,onChange:x})]}),e.jsx(wt,{label:"Remarks",name:"remarks",rows:3,value:T,onChange:$=>I($.target.value)})]})}),e.jsxs(F,{pt:5,pb:2,children:[e.jsxs(F,{children:["Manage Stock",e.jsx(re,{type:"button",value:"Print Barcodes",disabled:!l||l.length===0,onClick:()=>C?.(),style:{minWidth:170}})]}),e.jsx(F,{style:{padding:"12px 16px"},children:e.jsx(n.Card,{style:{borderRadius:16},children:e.jsx(Me,{parentCallback:R,data:{newData:S,columns:M,columnstype:"antd",action:!1,Loading:b,error:y,rowSelection:z}})})})]}),e.jsx("div",{style:{position:"absolute",left:-1e4,top:0},children:e.jsx("div",{ref:k,children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,padding:24},children:(Array.isArray(l)?l:[]).map($=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:$?.name??""}),e.jsx(Zi,{value:String($?.barcode??$?.id??""),height:50,width:1.6,displayValue:!0})]},$?.id??$?.barcode??$?.name))})})})]})}const Lp=({token:t})=>e.jsx(Np,{token:t}),Bp=qe.report.stock,qp=qe.product.dropdown,zp=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Yp({token:t}){const a=i.useRef(null),[s,r]=i.useState(null),[o,l]=i.useState(""),{data:d}=H(t?[qp,t]:null,([h,m])=>X(h,m)),c=i.useMemo(()=>zp(d),[d]),{trigger:g,isMutating:f,data:u}=nt(Bp,(h,{arg:m})=>Gs(h,{arg:m},t));i.useEffect(()=>{const m=new Date().toISOString().slice(0,10);g({duration:[m,m]})},[g]);const p=i.useMemo(()=>{const h=u?.data??u??[];return(Array.isArray(h)?h:[]).flatMap(x=>(Array.isArray(x?.ledger)?x.ledger:[]).map((T,I)=>({key:`${x.product_id??x.product_name??"p"}-${I}`,date:T?.date,product:x?.product_name,opening:T?.opening,inward:T?.inward,outward:T?.outward,closing:T?.closing})))},[u]),_=[{title:"Date",dataIndex:"date",key:"date"},{title:"Product",dataIndex:"product",key:"product"},{title:"Opening",dataIndex:"opening",key:"opening"},{title:"Inward",dataIndex:"inward",key:"inward"},{title:"Outward",dataIndex:"outward",key:"outward"},{title:"Closing",dataIndex:"closing",key:"closing",render:h=>e.jsx("span",{style:{color:Number(h)<0?"red":"green"},children:h})}],v=async()=>{if(!s||s.length!==2)return;const[h,m]=s;await g({duration:[h.format("YYYY-MM-DD"),m.format("YYYY-MM-DD")],product_id:o||""})};return e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Stock Report"}),style:{borderRadius:16},children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",marginBottom:16,flexWrap:"wrap"},children:[e.jsx(n.DatePicker.RangePicker,{value:s,onChange:r}),e.jsxs("select",{value:o,onChange:h=>l(h.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),c.map(h=>e.jsx("option",{value:String(h?.value??""),children:String(h?.label??"")},String(h?.value??h?.id??h?.label)))]}),e.jsx(n.Button,{type:"primary",onClick:v,loading:f,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(xt,{data:{tableRef:a}})})]}),e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(It,{})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:f,rowKey:"key",columns:_,dataSource:p,pagination:{pageSize:50}})]})]})}const Vp=({token:t})=>e.jsx(Yp,{token:t}),fi=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],Rt={total_packages:124,total_downloads:45892,active_packages:118,deprecated_packages:6,pending_approval:3,published_this_month:12,published_this_week:4,packages_needing_update:8,packages_with_issues:2},yi=[{npm_id:"NPM-001",package_name:"@ubk/erp-core",version:"1.2.1",description:"Core ERP utilities and shared types",author:"UBK Infotech",repository:"https://github.com/ubk/erp-core",license:"MIT",status:"published",created_at:"2024-01-15",updated_at:"2025-06-20"},{npm_id:"NPM-002",package_name:"@ubk/erp-components",version:"2.0.0",description:"Reusable Ant Design ERP component library",author:"UBK Infotech",repository:"https://github.com/ubk/erp-components",license:"ISC",status:"published",created_at:"2024-03-10",updated_at:"2025-08-01"},{npm_id:"NPM-003",package_name:"@ubk/erp-api-client",version:"0.9.5",description:"Axios-based API client for UBK ERP backends",author:"UBK Infotech",repository:"https://github.com/ubk/erp-api-client",license:"MIT",status:"draft",created_at:"2025-05-22",updated_at:"2025-07-14"},{npm_id:"NPM-004",package_name:"@ubk/erp-hooks",version:"1.1.0",description:"Custom React hooks for ERP workflows",author:"UBK Infotech",repository:"https://github.com/ubk/erp-hooks",license:"MIT",status:"published",created_at:"2024-08-05",updated_at:"2025-04-30"},{npm_id:"NPM-005",package_name:"@ubk/erp-utils",version:"3.2.1",description:"Utility functions for date, currency, and validation",author:"UBK Infotech",repository:"https://github.com/ubk/erp-utils",license:"ISC",status:"deprecated",created_at:"2023-11-20",updated_at:"2025-02-10"}],hi=[{key:"dashboard",label:"Dashboard"},{key:"allPackages",label:"All Packages"},{key:"published",label:"Published"},{key:"draft",label:"Draft"},{key:"deprecated",label:"Deprecated"},{key:"pendingApproval",label:"Pending Approval"}];function Wp(){const[t,a]=i.useState("dashboard"),[s,r]=i.useState("This Month"),[o,l]=i.useState(""),[d,c]=i.useState(""),[g,f]=i.useState(1),[u,p]=i.useState(10),[_,v]=i.useState(""),h=i.useRef(null),m=["dashboard","allPackages","published","draft","deprecated","pendingApproval"].includes(t),x=i.useMemo(()=>{if(!_.trim())return yi;const b=_.toLowerCase();return yi.filter(y=>Object.values(y).some(S=>String(S??"").toLowerCase().includes(b)))},[_]),T=i.useMemo(()=>{const b=(g-1)*u;return x.slice(b,b+u)},[x,g,u]),I=()=>{f(1)},k=()=>{const b=[{title:"Total Packages",value:Rt.total_packages,icon:e.jsx(Z.FileTextOutlined,{}),color:"#1976d2"},{title:"Total Downloads",value:Rt.total_downloads.toLocaleString(),icon:e.jsx(Z.StarOutlined,{}),color:"#2e7d32"},{title:"Active Packages",value:Rt.active_packages,icon:e.jsx(Z.CheckCircleOutlined,{}),color:"#0288d1"},{title:"Deprecated",value:Rt.deprecated_packages,icon:e.jsx(Z.CloseCircleOutlined,{}),color:"#d32f2f"},{title:"Pending Approval",value:Rt.pending_approval,icon:e.jsx(Z.ClockCircleOutlined,{}),color:"#ed6c02"},{title:"Published This Month",value:Rt.published_this_month,icon:e.jsx(Z.CalendarOutlined,{}),color:"#9c27b0"},{title:"Published This Week",value:Rt.published_this_week,icon:e.jsx(Z.SyncOutlined,{}),color:"#455a64"},{title:"Needs Update",value:Rt.packages_needing_update,icon:e.jsx(Z.CodeOutlined,{}),color:"#c62828"},{title:"With Issues",value:Rt.packages_with_issues,icon:e.jsx(Z.CloseCircleOutlined,{}),color:"#f57c00"}];return e.jsx(n.Row,{gutter:[16,16],children:b.map((y,S)=>e.jsx(n.Col,{xs:24,sm:12,md:8,lg:6,children:e.jsxs(n.Card,{style:{display:"flex",alignItems:"center",padding:16,borderLeft:`6px solid ${y.color}`,transition:"0.2s",cursor:"default"},bodyStyle:{display:"flex",alignItems:"center",width:"100%"},children:[e.jsx(F,{style:{width:48,height:48,borderRadius:"50%",backgroundColor:`${y.color}15`,color:y.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,marginRight:16,flexShrink:0},children:y.icon}),e.jsxs(F,{children:[e.jsx(n.Typography.Text,{type:"secondary",style:{fontSize:12,fontWeight:500},children:y.title}),e.jsx("div",{style:{fontSize:22,fontWeight:700,marginTop:4},children:y.value})]})]})},S))})},C=()=>{const b=[{title:"NPM ID",dataIndex:"npm_id",key:"npm_id",width:100},{title:"Package Name",dataIndex:"package_name",key:"package_name",ellipsis:!0},{title:"Version",dataIndex:"version",key:"version",width:100},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,responsive:["md"]},{title:"Author",dataIndex:"author",key:"author",width:140,responsive:["lg"]},{title:"License",dataIndex:"license",key:"license",width:100},{title:"Status",dataIndex:"status",key:"status",width:120,render:y=>{let S="default";return y==="published"?S="green":y==="draft"?S="orange":y==="deprecated"?S="red":y==="pending"&&(S="blue"),e.jsx(n.Tag,{color:S,children:y.toUpperCase()})}},{title:"Created Date",dataIndex:"created_at",key:"created_at",width:120,responsive:["lg"]},{title:"Updated Date",dataIndex:"updated_at",key:"updated_at",width:120,responsive:["lg"]},{title:"Actions",key:"action",width:120,fixed:"right",render:(y,S)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer",fontSize:13},children:"View"})}];return t==="dashboard"?[]:b};return e.jsx(F,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"NPM Package Report"})}),e.jsxs(F,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],mb:3,children:[m&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(ee,{options:fi,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:fi.find(b=>b.value===s)||null,onChange:b=>r(b?.value||"This Month")})}),s==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Le,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:b=>l(b?b.format("YYYY-MM-DD"):"")})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Le,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:b=>c(b?b.format("YYYY-MM-DD"):"")})})]})]}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(F,{display:"flex",alignItems:"center",height:"100%",mt:t==="dashboard"?0:2,children:e.jsx(re,{type:"button",value:"Search",color:"primary",onClick:I})})})]}),e.jsx(n.Tabs,{activeKey:t,onChange:a,items:hi})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(F,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:hi.find(b=>b.key===t)?.label||"Report"})}),e.jsxs(F,{p:3,children:[t!=="dashboard"&&e.jsx(xt,{data:{tableRef:h}}),t==="dashboard"?k():e.jsx(n.Table,{size:"small",dataSource:T,columns:C(),loading:!1,pagination:!1,bordered:!0,rowKey:b=>b.npm_id||b.package_name||Math.random(),ref:h}),t!=="dashboard"&&x.length>0&&e.jsx(n.Pagination,{current:g,pageSize:u,total:x.length,onChange:(b,y)=>{f(b),p(y)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const es=t=>t??localStorage.getItem("authToken")??"",er=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Ce={upload:"api/branchapi/frontoffice/uploadfrontofficeDocument",roleDropdown:"api/Branch/getRoledropdownforBranch",staff:{list:"api/branchapi/staff/stafflist",searchByRole:"api/branchapi/staff/staffsearchbyRole",searchByKeywords:"api/branchapi/staff/staffsearchbyKeywords",deactivate:"api/branchapi/staff/staff_deactive",basicById:"api/branchapi/staff/getbasicdetailsbyID",experienceById:"api/branchapi/staff/getworkexperencebyID",payrollById:"api/branchapi/staff/getpayrollbyID",lastEmpNo:"api/branchapi/staff/getLastStaffEMPnumber",addBasic:"api/branchapi/staff/addstaffbasicdetails",editBasic:"api/branchapi/staff/editstaffbasicdetails",addExperience:"api/branchapi/staff/addstaffExperience",editExperience:"api/branchapi/staff/editstaffExperience",addPayroll:"api/branchapi/staff/addstaffpayroll",editPayroll:"api/branchapi/staff/editstaffpayroll",uploadProfile:"api/branchapi/staff/uploadstaffProfilepicture",uploadDocuments:"api/branchapi/staff/uploadDocuments"},master:{shift:{dropdown:"api/branchapi/generalSettings/shiftDropdown",table:"api/branchapi/generalSettings/shiftTable",add:"api/branchapi/generalSettings/shiftTable",add:"api/branchapi/generalSettings/addshift",edit:"api/branchapi/generalSettings/addshift",edit:"api/branchapi/generalSettings/editshift",remove:"api/branchapi/generalSettings/deleteshift",show:"api/branchapi/generalSettings/shiftShowdata"},department:{dropdown:"api/branchapi/humanResource/departmentDropdown",table:"api/branchapi/humanResource/departmenttypeTable",add:"api/branchapi/humanResource/adddepartment",edit:"api/branchapi/humanResource/editdepartment",remove:"api/branchapi/humanResource/deletedepartment",show:"api/branchapi/humanResource/departmentShowdata"},designation:{dropdown:"api/branchapi/humanResource/designationDropdown",table:"api/branchapi/humanResource/designationTable",add:"api/branchapi/humanResource/adddesignation",edit:"api/branchapi/humanResource/editdesignation",remove:"api/branchapi/humanResource/deletedesignation",show:"api/branchapi/humanResource/designationShowdata"},leaveType:{dropdown:"api/branchapi/humanResource/leavetypeDropdown",table:"api/branchapi/humanResource/LeavetypeTable",add:"api/branchapi/humanResource/addleavetype",edit:"api/branchapi/humanResource/editleavetype",remove:"api/branchapi/humanResource/deleteleavetype",show:"api/branchapi/humanResource/leavetypeShowdata"}},leave:{table:"api/branchapi/humanResource/LeaveTable",apply:"api/branchapi/humanResource/applyLeave",requestTable:"api/branchapi/humanResource/leaverequestTable",approveRequest:"api/branchapi/humanResource/approveleaveRequest"},attendance:{staffListForAttendance:"api/staff/attendence/stafflistforAttendence",staffDropdownByRole:"api/staff/attendence/getStaffDropDownByRoleId",addAttendanceToStaffByBranch:"api/staff/attendence/addattendencetoStaffbyBranch",manualAttendance:"api/staff/attendence/staffMenualAttendance",staffShiftByStaffId:"api/branchapi/staff/getStaffShiftByStaffId",dailyAttendance:"api/staff/attendence/dailyAttendance",dailyAttendanceMultipleShift:"api/staff/attendence/dailyAttendanceMultipleShift"},attendanceReport:{monthlyStaffReport:"api/AttendenceReport/staffmonthlyAttendenceReport_new",staffAttendanceList:"api/AttendenceReport/staffAttendanceList",overallStaffReport:"api/staff/attendence/getAlloverAttendenceReportofStaff"},payroll:{monthlyGraph:"api/branchapi/reportGraph/monthlyPayroleReportgraph",staffPayrollByStaffId:"api/branchapi/humanResource/getStaffPayroleByStaffID",generatePayslip:"api/branchapi/humanResource/generatePayslip",payrollByRole:"api/branchapi/humanResource/getpayrolebyRole",monthlyReport:"api/branchapi/humanResource/monthlyPayRolereport"}},Uo=()=>er(et(),Ce.upload),Hp=()=>er(et(),Ce.staff.uploadProfile),Kp=()=>er(et(),Ce.staff.uploadDocuments),Gp=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return X(l,es(r))},Ct=async(t,a,s)=>$e(t,a,es(s)),Lt=async(t,a,s)=>Xe(t,a,es(s)),en=async(t,a,s)=>Ye(t,a,es(s)),Kt=Ce.staff,Jp=Ce.master.shift.dropdown,Qp=Ce.master.department.dropdown,Xp=Ce.master.designation.dropdown,Zp=Ce.roleDropdown,xn=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},em=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Ia={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},gi={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function tm({token:t,mode:a,staffId:s,initialValues:r,onSubmitted:o}){const l=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))}catch{return null}},[]),d=String(l?.multiple_shift??"").toLowerCase()==="yes",[c,g]=i.useState(r?.roleValue??null),[f,u]=i.useState(r?.departmentValue??null),[p,_]=i.useState(r?.designationValue??null),[v,h]=i.useState(r?.genderValue??null),[m,x]=i.useState(r?.shiftValue??(d?[]:null)),[T,I]=i.useState(r?.dob?ae(r.dob):null),[k,C]=i.useState(r?.doj?ae(r.doj):null),[b,y]=i.useState(r?.file??""),{data:S}=H(t?[Jp,t]:null,([V,q])=>X(V,q)),{data:A}=H(t?[Qp,t]:null,([V,q])=>X(V,q)),{data:R}=H(t?[Xp,t]:null,([V,q])=>X(V,q)),{data:z}=H(t?[Zp,t]:null,([V,q])=>X(V,q)),{data:U}=H(t?[Kt.lastEmpNo,t]:null,([V,q])=>X(V,q)),j=i.useMemo(()=>xn(S),[S]),O=i.useMemo(()=>xn(A),[A]),M=i.useMemo(()=>xn(R),[R]),$=i.useMemo(()=>xn(z),[z]),E=i.useMemo(()=>{const V=U?.data?.emp_number??U?.emp_number??U?.data??"";return String(V??"")},[U]),N=async V=>{V.preventDefault();const q=new FormData(V.target);q.set("role",c?.value??c??""),q.set("department",f?.value??f??""),q.set("designation",p?.value??p??""),q.set("gender",v?.value??v??""),q.set("dob",T?T.format("YYYY-MM-DD"):""),q.set("doj",k?k.format("YYYY-MM-DD"):""),d?(q.delete("shift_id"),(Array.isArray(m)?m:[]).forEach(D=>{q.append("shift_id[]",D?.value??D??"")})):q.set("shift_id",m?.value??m??""),b&&q.set("file",b);try{const P=a==="edit"&&s,D=P?Kt.editBasic:Kt.addBasic;P&&q.set("staff_id",String(s));const L=P?await Lt(D,q,t):await Ct(D,q,t),B=L?.ID??L?.id??s??null;w.success("Success!",{duration:1e3}),o?.({staffId:B,basic:{roleValue:c,departmentValue:f,designationValue:p,genderValue:v,shiftValue:m,dob:T,doj:k,file:b}})}catch(P){w.error(P?.response?.data?.msg??P?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"number",name:"emp_number",label:"EMP No",defaultValue:r?.emp_number??E,required:!0}),e.jsx(Y,{type:"text",name:"f_name",label:"First Name",defaultValue:r?.f_name??"",required:!0}),e.jsx(Y,{type:"text",name:"l_name",label:"Last Name",defaultValue:r?.l_name??"",required:!0}),e.jsx(Y,{type:"text",name:"pan_no",label:"PAN",defaultValue:r?.pan_no??""}),e.jsx(Y,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:r?.adhar_no??""}),e.jsx(ee,{label:"Role",options:$,value:c,onChange:V=>g(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Department",options:O,value:f,onChange:V=>u(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Designation",options:M,value:p,onChange:V=>_(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Gender",options:[{value:"Male",label:"Male"},{value:"Female",label:"Female"},{value:"Other",label:"Other"}],value:v,onChange:V=>h(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"text",name:"email",label:"Email",defaultValue:r?.email??""}),e.jsxs("div",{children:[e.jsx("div",{style:Ia,children:"DOB"}),e.jsx(n.DatePicker,{value:T,onChange:V=>I(V),style:gi,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:Ia,children:"DOJ"}),e.jsx(n.DatePicker,{value:k,onChange:V=>C(V),style:gi,placeholder:"Select DOJ"})]}),e.jsx(Y,{type:"text",name:"bloodGroup",label:"Blood Group",defaultValue:r?.bloodGroup??""}),e.jsx(Y,{type:"text",name:"contact_no",label:"Contact No",defaultValue:r?.contact_no??"",required:!0}),e.jsx(Y,{type:"text",name:"education",label:"Education",defaultValue:r?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:Ia,children:"Shift"}),e.jsx(ee,{options:j,value:m,onChange:V=>x(V??(d?[]:null)),isMulti:d,closeMenuOnSelect:!d,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:Ia,children:"Profile Picture"}),e.jsx(n.Upload,{maxCount:1,action:Hp(),headers:t?{Authorization:t}:void 0,onChange:V=>{if(V?.file?.status==="done"){const q=em(V?.file?.response);q&&y(q)}V?.file?.status==="removed"&&y("")},children:e.jsx(n.Button,{type:"link",style:{paddingLeft:0},children:b?"Change":"Upload"})})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:Ia,children:"Address"}),e.jsx("textarea",{name:"address",rows:3,defaultValue:r?.address??"",placeholder:"Address",style:{width:"100%",resize:"vertical",padding:10,border:"1px solid #d9d9d9",borderRadius:8,outline:"none"}})]}),e.jsx("div",{style:{gridColumn:"1 / -1",display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Save & Next",color:"primary"})})]})})}const bn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},xi={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},am=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",bi=t=>{if(!t)return null;const a=ae(t);return a.isValid()?a:null};function nm({token:t,mode:a,staffId:s,initialRows:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(()=>(Array.isArray(r)&&r.length?r:[{name:"",from:null,to:null,image:""}]).map(h=>({name:h?.name??"",from:bi(h?.from),to:bi(h?.to),image:h?.image??""}))),g=i.useMemo(()=>t?{Authorization:t}:void 0,[t]),f=(v,h)=>{c(m=>m.map((x,T)=>T===v?{...x,...h}:x))},u=()=>c(v=>[...v,{name:"",from:null,to:null,image:""}]),p=v=>c(h=>h.length<=1?h:h.filter((m,x)=>x!==v)),_=async v=>{if(v.preventDefault(),!s){w.error("Missing staff id.",{duration:1e3});return}const h=new FormData;h.append("staff_id",String(s)),d.forEach((m,x)=>{h.append(`experience[${x}][name]`,String(m?.name??"")),h.append(`experience[${x}][from]`,m?.from?m.from.format("YYYY-MM-DD"):""),h.append(`experience[${x}][to]`,m?.to?m.to.format("YYYY-MM-DD"):""),h.append(`experience[${x}][image]`,String(m?.image??""))});try{const m=a==="edit",x=m?Kt.editExperience:Kt.addExperience,T=m?await Lt(x,h,t):await Ct(x,h,t);w.success("Success!",{duration:1e3}),o?.({experience:d,result:T})}catch(m){w.error(m?.response?.data?.msg??m?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:_,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[d.map((v,h)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end",border:"1px solid #eee",borderRadius:12,padding:14},children:[e.jsxs("div",{children:[e.jsx("div",{style:bn,children:"Name"}),e.jsx("input",{value:v.name,onChange:m=>f(h,{name:m.target.value}),placeholder:"Company / School",style:{width:"100%",height:40,border:"none",borderBottom:"1px solid #d9d9d9",outline:"none",background:"transparent"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:bn,children:"From"}),e.jsx(n.DatePicker,{value:v.from,onChange:m=>f(h,{from:m}),style:xi})]}),e.jsxs("div",{children:[e.jsx("div",{style:bn,children:"To"}),e.jsx(n.DatePicker,{value:v.to,onChange:m=>f(h,{to:m}),style:xi})]}),e.jsxs("div",{children:[e.jsx("div",{style:bn,children:"Document"}),e.jsx(n.Upload,{maxCount:1,action:Kp(),headers:g,onChange:m=>{if(m?.file?.status==="done"){const x=am(m?.file?.response);x&&f(h,{image:x})}m?.file?.status==="removed"&&f(h,{image:""})},children:e.jsx(n.Button,{icon:e.jsx(Z.UploadOutlined,{}),children:"Upload"})}),!!v.image&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:v.image})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:e.jsx(n.Button,{type:"text",icon:e.jsx(Z.DeleteOutlined,{}),danger:!0,onClick:()=>p(h),disabled:d.length<=1})})]},`exp-${h}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(n.Button,{icon:e.jsx(Z.PlusOutlined,{}),onClick:u,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(n.Button,{onClick:l,children:"Back"}),e.jsx(re,{type:"submit",value:"Save & Next",color:"primary"})]})]})]})})}const ji=(t,a=[])=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){const s=a.length?a:["allowances","Allowances","dedection","Dedection","deductions","Deductions"],r=[t];t?.data&&typeof t.data=="object"&&r.push(t.data);for(const l of r)for(const d of s){const c=l?.[d]??l?.[d.toLowerCase()]??l?.[d.toUpperCase()];if(Array.isArray(c)&&c.length>0)return c}const o=t?.data;if(Array.isArray(o)&&o.length>0)return o}return[]},ka=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function sm({token:t,mode:a,staffId:s,initialValues:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(r?.type??"Permanent"),[g,f]=i.useState(r?.salary_type??ka[0]?.value),[u,p]=i.useState(Number(r?.amount??0)),[_,v]=i.useState(Number(r?.basic_pay)),[h,m]=i.useState(r?.declarationPERyear??""),{data:x}=H(t?[zd,t]:null,([y,S])=>X(y,S),{revalidateOnFocus:!1}),T=i.useMemo(()=>ji(x,["allowances","Allowances"]),[x]),I=i.useMemo(()=>ji(x,["dedection","Dedection","deductions","Deductions"]),[x]),k=i.useMemo(()=>{const y=Number(_||0),S=(Array.isArray(T)?T:[]).map(j=>{const O=j?.amount_type??j?.amountType??j?.type??"",M=Number(j?.Amount??j?.amount??0),E=String(O).trim().toLowerCase()==="flat"?M:Number(y)/100*Number(M||0);return{...j,value:Number.isFinite(E)?E:0}}),A=(Array.isArray(I)?I:[]).map(j=>{const O=j?.amount_type??j?.amountType??j?.type??"",M=Number(j?.Amount??j?.amount??0),E=String(O).trim().toLowerCase()==="flat"?M:Number(y)/100*Number(M||0);return{...j,value:Number.isFinite(E)?E:0}}),R=S.reduce((j,O)=>j+Number(O?.value||0),0),z=A.reduce((j,O)=>j+Number(O?.value||0),0),U=Math.max(0,Number(y)+R-z);return{allowances:S,deductions:A,netAmount:U}},[T,I,_]),C=async y=>{if(y.preventDefault(),!s){w.error("Missing staff id.",{duration:1e3});return}const S=new FormData;S.append("staff_id",String(s)),S.append("type",d),d==="Nonpermanent"?(S.append("salary_type",g??""),S.append("amount",String(u||"")),S.append("Allowances",JSON.stringify([])),S.append("Dedection",JSON.stringify([]))):(S.append("basic_pay",String(_||"")),S.append("declarationPERyear",String(h??"")),S.append("Allowances",JSON.stringify(k.allowances||[])),S.append("Dedection",JSON.stringify(k.deductions||[])),S.append("amount",String(k.netAmount||0)));try{const A=a==="edit",R=A?Kt.editPayroll:Kt.addPayroll,z=A?await Lt(R,S,t):await Ct(R,S,t);o?.({payroll:{staffType:d,salaryType:g,amount:u,basicPay:_,declaration:h},result:z})}catch(A){w.error(A?.response?.data?.msg??A?.message??"Failed.",{duration:1e3})}},b=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(y,S)=>`${S?.Amount??""} / ${S?.amount_type??""}`},{title:"Value",dataIndex:"value",key:"value",width:120}],[]);return e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:d==="Nonpermanent"?"Non Permanent":"Permanent",value:d},onChange:y=>c(y?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),d==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(ee,{label:"Type",options:ka,value:ka.find(y=>y.value===g)??ka[0],onChange:y=>f(y?.value??ka[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"number",label:"Amount",value:u,onChange:y=>p(Number(y.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{type:"number",label:"Basic Pay",value:_,onChange:y=>v(Number(y.target.value||0)),required:!0}),e.jsx(Y,{type:"text",label:"IT Declarations/Year",value:h,onChange:y=>m(y.target.value)}),e.jsx(Y,{type:"number",label:"Net Amount",value:k.netAmount,disabled:!0})]})]}),d==="Permanent"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Allowances"}),children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(y,S)=>`${y?.title??"a"}-${S}`,columns:b,dataSource:k.allowances,pagination:!1})}),e.jsx(n.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Deductions"}),children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(y,S)=>`${y?.title??"d"}-${S}`,columns:b,dataSource:k.deductions,pagination:!1})})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:e.jsx(re,{type:"submit",value:"Finish",color:"primary"})})]})})}const rm=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function im({token:t,mode:a="add",staffId:s,onFinished:r}){const[o,l]=i.useState(0),[d,c]=i.useState(s??null),[g,f]=i.useState(null),[u,p]=i.useState(null),[_,v]=i.useState(null),h=a==="edit"?s??d:null,m=i.useMemo(()=>h?`${Ce.staff.basicById}?staff_id=${encodeURIComponent(String(h))}`:null,[h]),x=i.useMemo(()=>h?`${Ce.staff.experienceById}?staff_id=${encodeURIComponent(String(h))}`:null,[h]),T=i.useMemo(()=>h?`${Ce.staff.payrollById}?staff_id=${encodeURIComponent(String(h))}`:null,[h]),{data:I}=H(t&&m?[m,t]:null,([R,z])=>X(R,z)),{data:k}=H(t&&x?[x,t]:null,([R,z])=>X(R,z)),{data:C}=H(t&&T?[T,t]:null,([R,z])=>X(R,z)),b=i.useMemo(()=>{const R=rm(I)[0]??I?.data??I??null;return R?{emp_number:R?.emp_number??R?.empNo??"",f_name:R?.f_name??R?.firstname??R?.first_name??"",l_name:R?.l_name??R?.lastname??R?.last_name??"",pan_no:R?.pan_no??"",adhar_no:R?.adhar_no??"",email:R?.email??"",dob:R?.dob??"",doj:R?.doj??"",bloodGroup:R?.bloodGroup??R?.blood_group??"",contact_no:R?.contact_no??R?.phone??"",education:R?.education??"",address:R?.address??"",file:R?.file??R?.profile_picture??""}:null},[I]),y=i.useMemo(()=>{const R=k?.data??k??null;return(Array.isArray(R?.experience)?R.experience:Array.isArray(R)?R:[]).map(U=>({name:U?.name??"",from:U?.from??"",to:U?.to??"",image:U?.image??""}))},[k]),S=i.useMemo(()=>{const R=C?.data??C??null;return R?{type:R?.type??"Permanent",salary_type:R?.salary_type??"",amount:R?.amount??"",basic_pay:R?.basic_pay??"",declarationPERyear:R?.declarationPERyear??""}:null},[C]),A=i.useMemo(()=>[{title:"Basic"},{title:"Experience"},{title:"Payroll"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:a==="edit"?"Edit Staff":"Add Staff"}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(n.Steps,{current:o,items:A}),o===0&&e.jsx(tm,{token:t,mode:a,staffId:h,initialValues:b,onSubmitted:({staffId:R})=>{R&&c(R),l(1)}}),o===1&&e.jsx(nm,{token:t,mode:a,staffId:h??d,initialRows:y,onBack:()=>l(0),onSubmitted:()=>l(2)}),o===2&&e.jsx(sm,{token:t,mode:a,staffId:h??d,initialValues:S,onBack:()=>l(1),onSubmitted:()=>{w.success("Completed.",{duration:1e3}),r?.({staffId:h??d}),l(0),a!=="edit"&&(c(null),f(null),p(null),v(null))}})]})})]})}function om({token:t}){return e.jsx(im,{token:t,mode:"add"})}const lm=({token:t})=>e.jsx(om,{token:t}),jn=Ce.staff,dm=Ce.roleDropdown,cm=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},um=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function pm({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(""),[l,d]=i.useState(""),{data:c}=H(t?[dm,t]:null,([T,I])=>X(T,I)),g=i.useMemo(()=>cm(c),[c]),f=i.useMemo(()=>{const T=a.page,I=a.rowsPerPage,k=r&&!l?`${jn.searchByRole}?role_id=${encodeURIComponent(String(r))}`:l?`${jn.searchByKeywords}?key=${encodeURIComponent(String(l))}`:jn.list,C=k.includes("?")?"&":"?";return`${k}${C}page=${encodeURIComponent(String(T))}&per_page=${encodeURIComponent(String(I))}`},[a.page,a.rowsPerPage,l,r]),{isLoading:u,error:p,data:_,mutate:v}=H(t?[f,t]:null,([T,I])=>X(T,I)),h=i.useMemo(()=>um(_),[_]),m=async T=>{const I=T?.id??T?.fk_staffID??T?.staff_id;if(I)try{await en(jn.deactivate,I,t),w.success("Success! Staff deactivated.",{duration:1e3}),await v()}catch(k){w.error(k?.response?.data?.msg??k?.message??"Failed to deactivate staff.",{duration:1e3})}},x=i.useMemo(()=>[{title:"Name",key:"name",ellipsis:!0,render:(T,I)=>`${I?.firstname??I?.first_name??""} ${I?.lastname??I?.last_name??""}`.trim()||I?.name||""},{title:"Role",dataIndex:"role_name",key:"role_name",ellipsis:!0,responsive:["md"]},{title:"Phone",dataIndex:"phone",key:"phone",ellipsis:!0,responsive:["md"]},{title:"Email",dataIndex:"email",key:"email",ellipsis:!0,responsive:["lg"]},{title:"Status",dataIndex:"status",key:"status",width:120,responsive:["lg"]},{title:"Action",key:"action",width:90,fixed:"right",render:(T,I)=>e.jsx(n.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(Z.DeleteOutlined,{}),onClick:()=>m(I),style:{padding:2}})}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20,alignItems:"start"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:3,style:{margin:0},children:"Filters"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:[{value:"",label:"All Roles"},...g],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:T=>{o(T?.value??""),s(I=>({...I,page:1}))}}),e.jsx(Y,{type:"text",label:"Keyword",value:l,onChange:T=>d(T.target.value),placeholder:"Search by keywords"}),e.jsx(re,{type:"button",value:"Refresh",onClick:()=>v()})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:7,style:{margin:0},children:"Staff Directory"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:u,rowKey:T=>String(T?.id??T?.fk_staffID??T?.staff_id??Math.random()),columns:x,dataSource:h,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(T,I)=>s({page:T,rowsPerPage:I}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]})}const mm=({token:t})=>e.jsx(pm,{token:t}),fm=Ce.attendance,ym=Ce.roleDropdown,Si=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Sn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},vi={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function hm({token:t,open:a,onClose:s,roleId:r,onSaved:o}){const[l,d]=i.useState(null),[c,g]=i.useState(""),[f,u]=i.useState(ae()),[p,_]=i.useState(ae()),[v,h]=i.useState(ae()),m=i.useMemo(()=>r?`${Ce.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(r))}`:null,[r]),{data:x}=H(t&&m?[m,t]:null,([y,S])=>X(y,S)),T=i.useMemo(()=>Si(x),[x]),{trigger:I,data:k}=nt(t?Ce.attendance.staffShiftByStaffId:null,(y,{arg:S})=>Ht(y,{arg:S},t)),C=i.useMemo(()=>Si(k),[k]),b=async()=>{if(!l?.value){w.error("Select staff.",{duration:1e3});return}if(!c){w.error("Select shift.",{duration:1e3});return}const y=new FormData;y.set("staffID",String(l.value)),y.set("shift_id",String(c)),y.set("attendance_date",f?f.format("YYYY-MM-DD"):""),y.set("intime",p?p.format("h:mm a"):""),y.set("outime",v?v.format("h:mm a"):"");try{await Ct(Ce.attendance.manualAttendance,y,t),w.success("Success!",{duration:1e3}),o?.(),s?.(),d(null),g(""),u(ae()),_(ae()),h(ae())}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed.",{duration:1e3})}};return e.jsx(n.Modal,{open:a,onCancel:s,footer:null,destroyOnClose:!0,title:"Attendance",width:620,children:e.jsx(n.Card,{children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{label:"Staff",options:T,value:l,onChange:async y=>{if(d(y??null),g(""),y?.value&&I)try{await I({staff_id:y.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:Sn,children:"Shift"}),e.jsx(n.Radio.Group,{value:c,onChange:y=>g(y.target.value),style:{display:"grid",gap:8},children:C.map(y=>e.jsx(n.Radio,{value:y?.value,children:y?.label??y?.name??y?.title??String(y?.value??"")},String(y?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:Sn,children:"Date"}),e.jsx(n.DatePicker,{value:f,onChange:y=>y&&u(y),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:Sn,children:"Start Time"}),e.jsx(n.TimePicker,{value:p,onChange:y=>y&&_(y),use12Hours:!0,format:"h:mm a",style:vi})]}),e.jsxs("div",{children:[e.jsx("div",{style:Sn,children:"End Time"}),e.jsx(n.TimePicker,{value:v,onChange:y=>y&&h(y),use12Hours:!0,format:"h:mm a",style:vi})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(n.Button,{onClick:s,children:"Cancel"}),e.jsx(re,{type:"button",value:"Save",color:"primary",onClick:b})]})]})})})}const gm=({tableRef:t,excelDisabled:a})=>{const s=new Date().getTime(),r=xa.useReactToPrint({content:()=>t?.current});return e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(n.Row,{gutter:8,children:[e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",icon:e.jsx(Z.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(n.Col,{children:a?e.jsx(n.Button,{type:"text",icon:e.jsx(Z.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>w.error("You must save attendance before download",{duration:2e3})}):e.jsx(ko.DownloadTableExcel,{filename:s,sheet:"users",currentTableRef:t?.current,children:e.jsx(n.Button,{type:"text",icon:e.jsx(Z.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},xm=(t,a)=>{const s=t?.data?.data??t?.data??t??null;return s?a==="student"?Array.isArray(s?.student)?s.student:[]:Array.isArray(s?.staff)?s.staff:[]:[]},bm=t=>{const a=t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.total??t?.total_rows,s=Number(a);return Number.isFinite(s)&&s>=0?s:0},jm=(t,a)=>{const s=t?.data?.data??t?.data??t??null;return s?a==="student"?{sunday:String(s?.sunday??"").toLowerCase()==="yes",holiday:String(s?.holiday??"").toLowerCase()==="yes"}:{sunday:!!s?.sunday,holiday:!!s?.holiday}:{sunday:!1,holiday:!1}};function Sm({token:t,url:a,columns:s,reload:r,setReload:o,saveBtnRef:l,setSaveBtnDisabled:d,date:c,type:g="staff"}){const f=i.useRef(null),[u,p]=i.useState({page:0,rowsPerPage:10}),[_,v]=i.useState(!1),[h,m]=i.useState(!1),[x,T]=i.useState(null),[I,k]=i.useState([]),[C,b]=i.useState({sunday:!1,holiday:!1}),[y,S]=i.useState(!0);i.useEffect(()=>{p(U=>({...U,page:0}))},[a]),i.useEffect(()=>{let U=!0;return(async()=>{if(!(!t||!a)){v(!0);try{const O=String(a).includes("?")?"&":"?",M=`${a}${O}page=${u.page+1}&per_page=${u.rowsPerPage}`,$=await X(M,t);if(!U)return;T($),$?.Status==="Success"?(d?.(!1),k(xm($,g)),b(jm($,g))):(d?.(!0),k([]),b({sunday:!1,holiday:!1}))}catch{if(!U)return;d?.(!0),k([])}finally{U&&v(!1)}}})(),()=>{U=!1}},[u.page,u.rowsPerPage,r,d,t,g,a]);const A=i.useMemo(()=>bm(x),[x]);i.useEffect(()=>{const U=(Array.isArray(I)?I:[]).find(j=>j?.attendence_type_id===null);S(!!U)},[I]);const R=async()=>{if(t){m(!0);try{if(g==="staff"){const U=(Array.isArray(I)?I:[]).map(j=>({staff_id:j?.staff_id,attendence_type_id:j?.attendence_type_id?j.attendence_type_id:"1",in_time:j?.intime,out_time:j?.outtime,date:c}));await Ct(Ce.attendance.addAttendanceToStaffByBranch,U,t),w.success("Attendance saved successfully",{duration:2e3}),o?.(j=>!j)}else w.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(U){w.error(U?.response?.data?.msg??U?.message??"Failed required dates",{duration:2e3})}finally{m(!1)}}},z=i.useMemo(()=>(Array.isArray(s)?s:[]).map(j=>j?.selector==="attendence_type_id"?{title:j?.name??"Attendance",dataIndex:j.selector,key:j.selector,render:O=>O==null||O===""?e.jsx(n.Tag,{color:"orange",children:"Not Set"}):String(O)==="1"?e.jsx(n.Tag,{color:"green",children:"Present"}):String(O)==="4"?e.jsx(n.Tag,{color:"red",children:"Absent"}):String(O)==="3"?e.jsx(n.Tag,{color:"orange",children:"Late"}):e.jsx(n.Tag,{children:String(O)})}:j?.selector==="snum"?{title:j?.name??"Sl",key:j.selector,render:(O,M,$)=>$+1}:{title:j?.name??j?.selector,dataIndex:j?.selector,key:j?.selector}),[s]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{children:[e.jsx(gm,{tableRef:f,excelDisabled:y}),e.jsx(n.Modal,{open:h,footer:null,closable:!1,centered:!0,children:e.jsxs("div",{style:{display:"grid",placeItems:"center",gap:12,padding:12},children:[e.jsx(n.Spin,{size:"large"}),e.jsx("div",{children:"Please wait..."})]})}),C.sunday?e.jsx("div",{style:{textAlign:"center",fontWeight:600,padding:"16px 0"},children:"Weekly Off"}):C.holiday?e.jsx("div",{style:{textAlign:"center",padding:"16px 0"},children:e.jsx("div",{style:{fontWeight:700,marginBottom:6},children:"Holiday"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:f,children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(U,j)=>String(U?.id??U?.staff_id??j),columns:z,dataSource:I,loading:_,pagination:{current:u.page+1,pageSize:u.rowsPerPage,total:A,showSizeChanger:!0,onChange:(U,j)=>p({page:U-1,rowsPerPage:j})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:R,ref:l,style:{display:"none"},children:"hidden"})]})]})]})}const vm=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},_m={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function wm({token:t}){const[a,s]=i.useState(""),[r,o]=i.useState(ae().format("YYYY-MM-DD")),[l,d]=i.useState(!1),[c,g]=i.useState(null),[f,u]=i.useState(!1),[p,_]=i.useState(!0),[v,h]=i.useState(!1),m=i.useRef(null),{data:x}=H(t?[ym,t]:null,([k,C])=>X(k,C)),T=i.useMemo(()=>vm(x),[x]),I=i.useMemo(()=>[{id:"1",name:"Staff Id",selector:"employee_id",sortable:!0},{id:"2",name:"Name",selector:"full_name",sortable:!0},{id:"4",name:"Contact",selector:"contact_no",sortable:!0},{id:"3",name:"Attendance",selector:"attendence_type_id",sortable:!0},{id:"5",name:"In Time",selector:"intime",sortable:!0},{id:"6",name:"Out Time",selector:"outtime",sortable:!0}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,onChange:k=>s(k?.value??""),required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{defaultValue:ae(),onChange:k=>k&&o(k.format("YYYY-MM-DD")),style:_m,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"button",value:"Search",color:"primary",onClick:()=>{!a||!r||(g(`${fm.staffListForAttendance}?role=${encodeURIComponent(String(a))}&date=${encodeURIComponent(String(r))}`),d(k=>!k))}})})]})}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap",marginBottom:12},children:[e.jsx(n.Button,{size:"small",type:f?"primary":"default",onClick:()=>u(k=>!k),children:f?"Marked":"Mark As Holiday"}),e.jsx(n.Button,{size:"small",type:"default",disabled:p,onClick:()=>h(!0),children:"Give Attendance"})]}),c?e.jsx(Sm,{token:t,url:c,columns:I,reload:l,setReload:d,saveBtnRef:m,setSaveBtnDisabled:_,date:r,type:"staff",holidayChecked:f}):null]}),e.jsx(hm,{token:t,open:v,onClose:()=>h(!1),roleId:a,onSaved:()=>d(k=>!k)})]})}const Cm=({token:t})=>e.jsx(wm,{token:t}),_i=Ce.attendanceReport.monthlyStaffReport,Am=Ce.roleDropdown,Tm=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Rm({token:t}){const a=i.useRef(null),[s,r]=i.useState(!1),[o,l]=i.useState([]),[d,c]=i.useState({role:"",rolllabel:"",year:"",month:""}),g=i.useMemo(()=>Qs(5),[]),{data:f}=H(t?[Am,t]:null,([U,j])=>X(U,j)),u=i.useMemo(()=>Tm(f),[f]),[p,_]=i.useState([]),[v,h]=i.useState(1),[m,x]=i.useState(!1),[T,I]=i.useState(!1),[k,C]=i.useState(null),b=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:y}=nt(t&&_i?`${_i}?page=${v}&per_page=3`:null,(U,{arg:j})=>Ht(U,{arg:j},t),{onSuccess:U=>{x(!1);const j=Array.isArray(U)?U:[];j.length>0&&_(O=>[...O||[],...j]),j.length>1?h(O=>O+1):I(!1)},onError:()=>{x(!1),I(!1)}});i.useEffect(()=>{T&&y&&k&&y(k)},[T,v,k,y]);const S=i.useMemo(()=>{const U=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(j,O)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:O?.full_name??""})}];return Array.isArray(p)&&p.length>0&&((p[0]?.monthly_data??[]).forEach((O,M)=>{U.push({title:M+1,align:"center",key:String(M+1),render:($,E)=>{const N=E?.monthly_data?.[M]?.[0]?.data?.[0]??{},V=N?.intime??"",q=N?.outtime??"",P=N?.attendance_type??"";return e.jsx(n.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",V]}),e.jsxs("div",{children:["Out Time ",q]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:Qe(P)})})}})}),U.push({title:"Total",key:"Total",render:(O,M)=>{const $=M?.monthly_data??[],E=$.filter(V=>V?.[0]?.data?.[0]?.attendance_type==="A").length,N=$.filter(V=>V?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",E," P : ",N]})})}})),U},[p]),A=i.useMemo(()=>[{label:"Present",el:Qe("P")},{label:"Absent",el:Qe("A")},{label:"Leave",el:Qe("L")},{label:"Weekly Off",el:Qe("W")},{label:"Holiday",el:Qe("H")}],[]),R=i.useMemo(()=>d.month?o.find(U=>U?.value==d.month)?.label??d.month??"--":"--",[d.month,o]),z=async U=>{if(U.preventDefault(),!d.role||!d.year||!d.month)return;h(1),x(!0),_([]);const j={session:b,year:d.year,month:d.month,day:"01",role:d.role};C(j),I(!0),await y?.(j)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{className:"d-print-none",title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Attendance Report"}),children:e.jsx("form",{onSubmit:z,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:U=>c(j=>({...j,role:U?.value??"",rolllabel:U?.label??""}))}),e.jsx(ee,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:U=>{const j=Xs(U?.value);l(j),r(O=>!O),c(O=>({...O,year:U?.label??""}))}}),e.jsx(ee,{options:o,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:U=>c(j=>({...j,month:U?.value??""}))},`month-${s}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Monthly Attendance Report"}),children:e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(It,{})}),e.jsxs("div",{style:{border:"1px solid #ddd",borderRadius:8,padding:16,marginBottom:24,backgroundColor:"#f8f9fa"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:12,alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:18,fontWeight:600,marginBottom:6},children:"Staff Attendance Summary"}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:10,fontSize:13},children:[e.jsxs("div",{children:["Role: ",e.jsx("span",{style:{fontWeight:700},children:d.rolllabel||"--"})]}),e.jsxs("div",{children:["Year: ",e.jsx("span",{style:{fontWeight:700},children:d.year||"--"})]}),e.jsxs("div",{children:["Month: ",e.jsx("span",{style:{fontWeight:700},children:R})]})]})]}),e.jsx("div",{className:"d-print-none",style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(xt,{data:{tableRef:a}})})]}),e.jsx("div",{style:{marginTop:14,paddingTop:14,borderTop:"1px solid #e0e0e0"},children:e.jsx("div",{style:{display:"flex",justifyContent:"center",flexWrap:"wrap",gap:12,fontSize:12},children:A.map(U=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("div",{children:[U.label," :"]}),e.jsx("div",{children:U.el})]},U.label))})})]}),e.jsx(n.Skeleton,{active:!0,loading:m,paragraph:{rows:10},children:e.jsx(n.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:S,dataSource:p,pagination:!1,scroll:{x:"max-content"},rowKey:(U,j)=>String(U?.staff_id??U?.id??j)})})]})})]})}const Dm=({token:t})=>e.jsx(Rm,{token:t}),wi=Ce.payroll,Im=Ce.roleDropdown,km=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Pm=t=>t?.data?.data??t?.data??t??[];function Om({token:t,receiptDetailsPath:a="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:s}){const[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,g]=i.useState([]),[f,u]=i.useState({role:"",roleLabel:"",year:"",month:""}),[p,_]=i.useState(null),v=S=>{if(!S)return;if(typeof s=="function"){s(S);return}const A=`${a}?id=${encodeURIComponent(String(S))}`;typeof window<"u"&&window?.location&&(window.location.href=A)},{data:h}=H(t?[Im,t]:null,([S,A])=>X(S,A)),m=i.useMemo(()=>km(h),[h]),x=i.useMemo(()=>Qs(5),[]),{isLoading:T,error:I,data:k}=H(t&&p?[p,t]:null,([S,A])=>X(S,A)),C=i.useMemo(()=>{const S=Pm(k);return Array.isArray(S)?S:[]},[k]),b=i.useMemo(()=>{const S=k?.pagination?.total_rows??k?.data?.pagination?.total_rows??k?.total??k?.total_rows,A=Number(S);return Number.isFinite(A)&&A>=0?A:C.length},[k,C.length]),y=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(S,A,R)=>R+1},{title:"Name",dataIndex:"full_name",key:"full_name",ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Mobile No",dataIndex:"contact_no",key:"contact_no",width:140,responsive:["md"]},{title:"Status",dataIndex:"status",key:"status",width:120,align:"center",render:(S,A)=>{const R=A?.id??A?.staff_id??A?.staffId;return e.jsx(n.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{v(R)},children:Do(A?.status)})}}],[]);return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll"}),children:[e.jsx("form",{onSubmit:S=>{if(S.preventDefault(),!f.role||!f.year||!f.month)return;const A=`${wi.payrollByRole}?page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.rowsPerPage))}&role=${encodeURIComponent(String(f.role))}&year=${encodeURIComponent(String(f.year))}&month=${encodeURIComponent(String(f.month))}`;_(A)},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",marginBottom:14,padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:S=>u(A=>({...A,role:S?.value??"",roleLabel:S?.label??""}))}),e.jsx(ee,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:S=>{const A=Xs(S?.value);g(A),d(R=>!R),u(R=>({...R,year:S?.label??"",month:""}))}}),e.jsx(ee,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:S=>u(A=>({...A,month:S?.value??""}))},`month-${l}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Search",color:"primary",onClick:()=>o(S=>({...S,page:1}))})})]})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:T,rowKey:(S,A)=>String(S?.id??S?.staff_id??A),columns:y,dataSource:C,pagination:{current:r.page,pageSize:r.rowsPerPage,total:b,showSizeChanger:!0,onChange:(S,A)=>{o({page:S,rowsPerPage:A}),!(!f.role||!f.year||!f.month)&&_(`${wi.payrollByRole}?page=${encodeURIComponent(String(S))}&per_page=${encodeURIComponent(String(A))}&role=${encodeURIComponent(String(f.role))}&year=${encodeURIComponent(String(f.year))}&month=${encodeURIComponent(String(f.month))}`)}},scroll:{x:"max-content"}})]})})}const Mm=({token:t})=>e.jsx(Om,{token:t}),No=Ce.leave,Sa=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>H(r&&t?[t,a,s,r]:null,([l,d,c,g])=>Gp({baseUrl:l,page:d,perPage:c},g)),Em=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:No.requestTable,page:a,perPage:s}),Fm=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},$m=(t,a)=>{const s=new FormData;return Object.entries(t??{}).forEach(([r,o])=>{o!=null&&s.append(r,String(o))}),s.set("status",a),s};function Um({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),{isLoading:r,error:o,data:l,mutate:d}=Em({token:t,page:a.page,perPage:a.rowsPerPage}),c=i.useMemo(()=>Fm(l),[l]),g=async(u,p)=>{try{const _=$m(u,p),v=await Lt(No.approveRequest,_,t);v?.Status==="Success"?w.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):w.error(v?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(_){w.error(_?.response?.data?.msg??_?.message??"Failed to update request.",{duration:1e3})}},f=i.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(u,p)=>p?.full_name??p?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(u,p)=>p?.leave_from??p?.from_date??""},{title:"To",key:"leave_to",width:120,render:(u,p)=>p?.leave_to??p?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(u,p)=>p?.leavetype??p?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(u,p)=>p?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(u,p)=>p?.employee_remark??p?.reason??""},{title:"View",key:"document_file",width:140,render:(u,p)=>{const _=p?.document_file;return _?e.jsx(n.Button,{size:"small",onClick:()=>window.open(_,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(u,p)=>{const _=String(p?.status??"").toLowerCase();return _==="approved"?e.jsx(n.Tag,{color:"green",children:"Approved"}):_==="declined"?e.jsx(n.Tag,{color:"red",children:"Declined"}):e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10},children:[e.jsx(n.Button,{type:"text",size:"small",onClick:()=>g(p,"approved"),icon:e.jsx(Z.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(n.Button,{type:"text",size:"small",onClick:()=>g(p,"declined"),icon:e.jsx(Z.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Approve Leave Requests"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:r,rowKey:(u,p)=>String(u?.id??u?.leave_id??p),columns:f,dataSource:c,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(u,p)=>s({page:u,rowsPerPage:p}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Nm=({token:t})=>e.jsx(Um,{token:t}),Lm=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Bm=({token:t,value:a,onChange:s})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:Uo(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=Lm(o?.file?.response);l&&s?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})},Lo=Ce.leave,qm=Ce.master.leaveType.dropdown,zm=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:Lo.table,page:a,perPage:s}),Ym=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},As={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Vm({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c]=n.Form.useForm(),{isLoading:g,error:f,data:u,mutate:p}=zm({token:t,page:a.page,perPage:a.rowsPerPage}),{data:_}=H(t?[qm,t]:null,([C,b])=>X(C,b)),v=i.useMemo(()=>Ym(_),[_]),h=(C,b)=>s({page:C,rowsPerPage:parseInt(b,10)}),m=()=>{d(""),c.resetFields(),c.setFieldsValue({apply_date:ae()}),o(!0)},x=()=>{o(!1),d(""),c.resetFields()},T=async C=>{const b=new FormData;b.set("apply_date",C?.apply_date?C.apply_date.format("YYYY-MM-DD"):""),b.set("leave_type",C?.leave_type?.value??C?.leave_type??""),b.set("from_date",C?.from_date?C.from_date.format("YYYY-MM-DD"):""),b.set("to_date",C?.to_date?C.to_date.format("YYYY-MM-DD"):""),b.set("reason",C?.reason??""),l&&b.set("file",l);try{await Ct(Lo.apply,b,t),w.success("Success! Leave request submitted.",{duration:1e3}),x(),await p()}catch(y){w.error(y?.response?.data?.msg??y?.message??"Failed to submit leave request.",{duration:1e3})}},I=i.useMemo(()=>{const C=u?.data??u??[];return Array.isArray(C)?C:Array.isArray(C?.data)?C.data:[]},[u]),k=i.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(C,b)=>b?.leavetype??b?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(C,b)=>b?.date??b?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(C,b)=>b?.leave_from??b?.from_date??""},{title:"To",key:"leave_to",width:130,render:(C,b)=>b?.leave_to??b?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(C,b)=>b?.employee_remark??"",ellipsis:!0,responsive:["md"]}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:r,title:"Add Leave Request",onCancel:x,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:c,layout:"vertical",onFinish:T,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"apply_date",rules:[{required:!0,message:"Select date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{style:As})]})}),e.jsx(n.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(ee,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Leave Type",allowSelectAll:!1})}),e.jsx(n.Form.Item,{name:"from_date",rules:[{required:!0,message:"Select from date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From"}),e.jsx(n.DatePicker,{style:As})]})}),e.jsx(n.Form.Item,{name:"to_date",rules:[{required:!0,message:"Select to date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To"}),e.jsx(n.DatePicker,{style:As})]})}),e.jsx(n.Form.Item,{name:"reason",rules:[{required:!0,message:"Enter reason"}],children:e.jsx(Y,{type:"text",label:"Reason",placeholder:"Reason"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:22},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(Bm,{token:t,value:l,onChange:d})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx(n.Button,{onClick:x,children:"Cancel"}),e.jsx(re,{type:"submit",value:"Save",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Apply Leave"}),extra:e.jsx(re,{type:"button",value:"Add Leave Request",onClick:m})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Leave Requests"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:g,rowKey:(C,b)=>String(C?.id??C?.leave_id??b),columns:k,dataSource:I,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(C,b)=>h(C,b),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Wm=({token:t})=>e.jsx(Vm,{token:t}),En=Ce.master.leaveType,Hm=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:En.table,page:a,perPage:s});function Km({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:f,error:u,data:p,mutate:_}=Hm({token:t,page:a.page,perPage:a.rowsPerPage}),v=(C,b)=>{s({page:C,rowsPerPage:parseInt(b,10)})},h=async C=>{const b=new FormData;b.set("title",C?.title??"");try{await _(Ct(En.add,b,t),Ve(b)),w.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(y){w.error(y?.response?.data?.msg??y?.message??"Failed to add leave type.",{duration:1e3})}},m=C=>{g(C??null),o.setFieldsValue({title:C?.leave_type_name??C?.name??""}),d(!0)},x=()=>{d(!1),g(null),o.resetFields()},T=async C=>{const b=c?.id??c?.leave_type_id;if(!b){w.error("Missing leave type id.",{duration:1e3});return}const y=new FormData;y.set("id",String(b)),y.set("title",C?.title??"");try{await Lt(En.edit,y,t),await _(),w.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),x()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to update leave type.",{duration:1e3})}},I=async C=>{const b=C?.id??C?.leave_type_id;if(b)try{await _(en(En.remove,b,t),Be(b)),w.success("Success! Deleted leave type.",{duration:1e3})}catch(y){w.error(y?.response?.data?.msg??y?.message??"Failed to delete leave type.",{duration:1e3})}},k=i.useMemo(()=>[{title:"Name",dataIndex:"type",key:"type",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(C,b)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>m(b)}),e.jsx(n.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>I(b),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Leave Type",onCancel:x,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:T,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:x,children:"Cancel"}),e.jsx(re,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Leave Type"}),children:e.jsxs(n.Form,{form:r,layout:"vertical",onFinish:h,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(re,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Leave Type List"}),children:e.jsx(Me,{parentCallback:v,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:f,error:u}})})]})}const Gm=({token:t})=>e.jsx(Km,{token:t}),Fn=Ce.master.department,Jm=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:Fn.table,page:a,perPage:s});function Qm({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:f,error:u,data:p,mutate:_}=Jm({token:t,page:a.page,perPage:a.rowsPerPage}),v=(C,b)=>{s({page:C,rowsPerPage:parseInt(b,10)})},h=async C=>{const b=new FormData;b.set("title",C?.title??"");try{await _(Ct(Fn.add,b,t),Ve(b)),w.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(y){w.error(y?.response?.data?.msg??y?.message??"Failed to add department.",{duration:1e3})}},m=C=>{g(C??null),o.setFieldsValue({title:C?.department_name??C?.name??""}),d(!0)},x=()=>{d(!1),g(null),o.resetFields()},T=async C=>{const b=c?.id??c?.department_id;if(!b){w.error("Missing department id.",{duration:1e3});return}const y=new FormData;y.set("id",String(b)),y.set("title",C?.title??"");try{await Lt(Fn.edit,y,t),await _(),w.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),x()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to update department.",{duration:1e3})}},I=async C=>{const b=C?.id??C?.department_id;if(b)try{await _(en(Fn.remove,b,t),Be(b)),w.success("Success! Deleted department.",{duration:1e3})}catch(y){w.error(y?.response?.data?.msg??y?.message??"Failed to delete department.",{duration:1e3})}},k=i.useMemo(()=>[{title:"Name",dataIndex:"department_name",key:"department_name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(C,b)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>m(b)}),e.jsx(n.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>I(b),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Department",onCancel:x,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:T,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:x,children:"Cancel"}),e.jsx(re,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Department"}),children:e.jsxs(n.Form,{form:r,layout:"vertical",onFinish:h,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(re,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Department List"}),children:e.jsx(Me,{parentCallback:v,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:f,error:u}})})]})}const Xm=({token:t})=>e.jsx(Qm,{token:t}),$n=Ce.master.designation,Zm=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:$n.table,page:a,perPage:s});function ef({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:f,error:u,data:p,mutate:_}=Zm({token:t,page:a.page,perPage:a.rowsPerPage}),v=(C,b)=>{s({page:C,rowsPerPage:parseInt(b,10)})},h=async C=>{const b=new FormData;b.set("title",C?.title??"");try{await _(Ct($n.add,b,t),Ve(b)),w.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(y){w.error(y?.response?.data?.msg??y?.message??"Failed to add designation.",{duration:1e3})}},m=C=>{g(C??null),o.setFieldsValue({title:C?.designation??""}),d(!0)},x=()=>{d(!1),g(null),o.resetFields()},T=async C=>{const b=c?.id??c?.designation_id;if(!b){w.error("Missing designation id.",{duration:1e3});return}const y=new FormData;y.set("id",String(b)),y.set("title",C?.title??"");try{await Lt($n.edit,y,t),await _(),w.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),x()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to update designation.",{duration:1e3})}},I=async C=>{const b=C?.id??C?.designation_id;if(b)try{await _(en($n.remove,b,t),Be(b)),w.success("Success! Deleted designation.",{duration:1e3})}catch(y){w.error(y?.response?.data?.msg??y?.message??"Failed to delete designation.",{duration:1e3})}},k=i.useMemo(()=>[{title:"Name",dataIndex:"designation",key:"designation",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(C,b)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>m(b)}),e.jsx(n.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>I(b),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Designation",onCancel:x,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:T,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:x,children:"Cancel"}),e.jsx(re,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Designation"}),children:e.jsxs(n.Form,{form:r,layout:"vertical",onFinish:h,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(re,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Designation List"}),children:e.jsx(Me,{parentCallback:v,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:f,error:u}})})]})}const tf=({token:t})=>e.jsx(ef,{token:t}),Un=Ce.master.shift,af=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:Un.table,page:a,perPage:s}),it="hh:mm A",da=t=>{const a=String(t??"");if(!a)return null;const s=ae(a,[it,"HH:mm","HH:mm:ss"],!0);return s.isValid()?s:null},ca=t=>t?t.format(it):"",gt={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function nf({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:f,error:u,data:p,mutate:_}=af({token:t,page:a.page,perPage:a.rowsPerPage}),v=(y,S)=>{s({page:y,rowsPerPage:parseInt(S,10)})},h=(y,S)=>{const A=new FormData;return S&&A.set("id",String(S)),A.set("name",y?.name??""),A.set("start_time",ca(y?.start_time)),A.set("end_time",ca(y?.end_time)),A.set("shift_start_from",ca(y?.shift_start_from)),A.set("shift_start_to",ca(y?.shift_start_to)),A.set("shift_end_from",ca(y?.shift_end_from)),A.set("shift_end_to",ca(y?.shift_end_to)),A},m=async y=>{try{const S=h(y);await _(Ct(Un.add,S,t),Ve(S)),w.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to add shift.",{duration:1e3})}},x=y=>{g(y??null),o.setFieldsValue({name:y?.shift_name??y?.name??"",start_time:da(y?.start_time),end_time:da(y?.end_time),shift_start_from:da(y?.shift_start_from),shift_start_to:da(y?.shift_start_to),shift_end_from:da(y?.shift_end_from),shift_end_to:da(y?.shift_end_to)}),d(!0)},T=()=>{d(!1),g(null),o.resetFields()},I=async y=>{const S=c?.id??c?.shift_id;if(!S){w.error("Missing shift id.",{duration:1e3});return}try{const A=h(y,S);await Lt(Un.edit,A,t),await _(),w.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),T()}catch(A){w.error(A?.response?.data?.msg??A?.message??"Failed to update shift.",{duration:1e3})}},k=async y=>{const S=y?.id??y?.shift_id;if(S)try{await _(en(Un.remove,S,t),Be(S)),w.success("Success! Deleted shift.",{duration:1e3})}catch(A){w.error(A?.response?.data?.msg??A?.message??"Failed to delete shift.",{duration:1e3})}},C=i.useMemo(()=>[{title:"Name",dataIndex:"shift_name",key:"shift_name",ellipsis:!0,fixed:"left",width:160},{title:"Start Time",dataIndex:"start_time",key:"start_time",width:120},{title:"End Time",dataIndex:"end_time",key:"end_time",width:120},{title:"Start From",dataIndex:"shift_start_from",key:"shift_start_from",width:120,responsive:["md"]},{title:"Start To",dataIndex:"shift_start_to",key:"shift_start_to",width:120,responsive:["md"]},{title:"End From",dataIndex:"shift_end_from",key:"shift_end_from",width:120,responsive:["md"]},{title:"End To",dataIndex:"shift_end_to",key:"shift_end_to",width:120,responsive:["md"]},{title:"Action",key:"action",width:110,fixed:"right",render:(y,S)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>x(S)}),e.jsx(n.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>k(S),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[]),b=[{required:!0,message:"Select time"}];return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Shift",onCancel:T,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:I,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(n.Form.Item,{name:"start_time",label:"Start Time",rules:b,children:e.jsx(n.TimePicker,{format:it,use12Hours:!0,style:gt})}),e.jsx(n.Form.Item,{name:"end_time",label:"End Time",rules:b,children:e.jsx(n.TimePicker,{format:it,use12Hours:!0,style:gt})}),e.jsx(n.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(n.TimePicker,{format:it,use12Hours:!0,style:gt})}),e.jsx(n.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(n.TimePicker,{format:it,use12Hours:!0,style:gt})}),e.jsx(n.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(n.TimePicker,{format:it,use12Hours:!0,style:gt})}),e.jsx(n.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(n.TimePicker,{format:it,use12Hours:!0,style:gt})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:T,children:"Cancel"}),e.jsx(re,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Shift"}),children:e.jsx(n.Form,{form:r,layout:"vertical",onFinish:m,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(n.Form.Item,{name:"start_time",label:"Start Time",rules:b,children:e.jsx(n.TimePicker,{format:it,use12Hours:!0,style:gt})}),e.jsx(n.Form.Item,{name:"end_time",label:"End Time",rules:b,children:e.jsx(n.TimePicker,{format:it,use12Hours:!0,style:gt})}),e.jsx(n.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(n.TimePicker,{format:it,use12Hours:!0,style:gt})}),e.jsx(n.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(n.TimePicker,{format:it,use12Hours:!0,style:gt})}),e.jsx(n.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(n.TimePicker,{format:it,use12Hours:!0,style:gt})}),e.jsx(n.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(n.TimePicker,{format:it,use12Hours:!0,style:gt})}),e.jsx(re,{type:"submit",value:"Save",color:"primary"})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Shift List"}),children:e.jsx(Me,{parentCallback:v,data:{newData:p,columns:C,columnstype:"antd",action:!1,Loading:f,error:u}})})]})}const sf=({token:t})=>e.jsx(nf,{token:t}),Ci=Ce.attendance;function rf({data:t}){return t?e.jsx("div",{style:{margin:15,fontSize:13,padding:10},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{}),(t?.shifts??[]).map((a,s)=>e.jsx("th",{colSpan:"2",style:{border:"1px solid #000",paddingLeft:10},children:a?.shift_name??""},`${s}heading1`))]}),e.jsxs("tr",{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Sl.No"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Teacher's Name"}),(t?.shifts??[]).map((a,s)=>e.jsxs(i.Fragment,{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"In Time"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Out Time"})]},`${s}heading2`))]})]}),e.jsx("tbody",{children:(t?.data??[]).map((a,s)=>e.jsxs("tr",{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:s+1})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:`${a?.name??""} ${a?.surname??""}`.trim()})}),(t?.shifts??[]).map((r,o)=>e.jsxs(i.Fragment,{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a?.attendance_data?(a.attendance_data?.[r?.office_shift_id]?.checkintime??"").toUpperCase():""})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a?.attendance_data?(a.attendance_data?.[r?.office_shift_id]?.checkouttime??"").toUpperCase():""})})]},`${o}cells${s}`))]},`${s}row`))})]})}):null}const of=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},lf=t=>{const a=String(t??"").toLowerCase();return a==="present"?e.jsx(n.Tag,{color:"green",children:"Present"}):a==="absent"?e.jsx(n.Tag,{color:"red",children:"Absent"}):a==="leave"?e.jsx(n.Tag,{color:"orange",children:"Leave"}):e.jsx(n.Tag,{children:t??""})};function df({token:t}){const[a,s]=i.useState(ae()),[r,o]=i.useState(!1),[l,d]=i.useState(0),c=i.useMemo(()=>`${r?Ci.dailyAttendanceMultipleShift:Ci.dailyAttendance}?attendance_date=${encodeURIComponent(a.format("YYYY-MM-DD"))}`,[a,r,l]),{isLoading:g,error:f,data:u}=H(t?[c,t]:null,([m,x])=>X(m,x)),p=i.useMemo(()=>of(u),[u]),_=i.useMemo(()=>r?u?.data?.data??u?.data??u??null:null,[u,r]),v=xa.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),h=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(m,x,T)=>T+1},{title:"Name",key:"name",render:(m,x)=>`${x?.name??""} ${x?.surname??""}`.trim(),ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(m,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[lf(x?.attendance),x?.late_time?e.jsx(n.Tag,{color:"red",children:"L"}):null]})},{title:"In Time",key:"intime",width:120,render:(m,x)=>x?.attendance_data?.[0]?.intime??""},{title:"Out Time",key:"outtime",width:120,render:(m,x)=>x?.attendance_data?.[0]?.outtime??""},{title:"Late",key:"late",width:100,render:(m,x)=>x?.late_time?e.jsx(n.Tag,{color:"red",children:x.late_time}):""}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Daily Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:a,onChange:m=>m&&s(m),style:{width:"100%"},allowClear:!1})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:22},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222"},children:"Multiple Shift"}),e.jsx(n.Switch,{checked:r,onChange:o})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"button",value:"Search",onClick:()=>d(m=>m+1)})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(Z.PrinterOutlined,{style:{color:"#5080f8",fontSize:18,cursor:"pointer"},onClick:v}),children:e.jsxs("div",{id:"ubk-hr-daily-attendance-print",children:[e.jsx("div",{className:"print-only",children:e.jsx(It,{})}),r?e.jsx(rf,{data:_}):e.jsx(n.Table,{bordered:!0,size:"small",loading:g,rowKey:(m,x)=>String(m?.id??m?.staff_id??x),columns:h,dataSource:p,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const cf=({token:t})=>e.jsx(df,{token:t}),Ai=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},uf=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"";function pf({token:t,staffId:a}){const[s,r]=i.useState(!1),[o,l]=i.useState(null),[d,c]=i.useState({value:"Cash",label:"Cash"}),[g,f]=i.useState(""),[u,p]=i.useState(""),_=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),v=R=>{const z=Number(R??0),U=Number.isFinite(z)?z.toLocaleString("en-IN"):"0";return`${_?`${_} `:""}${U}`},h=i.useMemo(()=>a?`${Ce.staff.basicById}?staff_id=${encodeURIComponent(String(a))}`:null,[a]),m=i.useMemo(()=>a?`${Ce.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(a))}`:null,[a]),{data:x}=H(t&&h?[h,t]:null,([R,z])=>X(R,z)),{data:T,isLoading:I,mutate:k}=H(t&&m?[m,t]:null,([R,z])=>X(R,z)),C=i.useMemo(()=>Ai(x)[0]??x?.data??x??null,[x]),b=i.useMemo(()=>Ai(T),[T]),y=i.useMemo(()=>[{title:"Month",dataIndex:"month",key:"month",width:120,align:"center"},{title:"Basic Salary",dataIndex:"basic_salary",key:"basic_salary",width:140,align:"center",render:(R,z)=>e.jsx("div",{style:{fontSize:11},children:_t(z?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(R,z)=>e.jsx("div",{style:{fontSize:11},children:_t(z?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(R,z)=>e.jsx("div",{style:{fontSize:11},children:_t(z?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(R,z)=>e.jsx("div",{style:{fontSize:11},children:_t(z?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(R,z)=>e.jsx("div",{style:{cursor:z?.status==="due"?"pointer":"default"},onClick:()=>{z?.status==="due"&&(l(z),r(!0))},children:Do(z?.status)})}],[]),S=i.useMemo(()=>[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"DD",label:"DD"},{value:"Bank",label:"Bank"},{value:"Internet Banking",label:"Internet Banking"},{value:"Cheque",label:"Cheque"}],[]),A=async()=>{if(!o)return;const R={...o,staff_id:a,payment_type:d?.value??"",notes:g,attchement:u};try{await $e(Ce.payroll.generatePayslip,{arg:R},t),w.success("Success!",{duration:1e3}),r(!1),l(null),f(""),p(""),await k()}catch(z){w.error(z?.response?.data?.msg??z?.message??"Failed.",{duration:1e3})}};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx("div",{style:{fontSize:13,color:"#444"},children:C?`${C?.f_name??C?.firstname??""} ${C?.l_name??C?.lastname??""}`.trim():""}),e.jsx(n.Table,{bordered:!0,size:"small",loading:I,rowKey:(R,z)=>String(R?.id??`${R?.month}-${z}`),columns:y,dataSource:b,pagination:{pageSize:12},scroll:{x:"max-content"}})]})}),e.jsx(n.Modal,{open:s,onCancel:()=>{r(!1),l(null)},footer:null,destroyOnClose:!0,title:"Payment Options",width:640,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{label:"Pay",options:S,value:d,onChange:R=>c(R??S[0]),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Note"}),e.jsx(n.Input.TextArea,{rows:4,placeholder:"Note",value:g,onChange:R=>f(R.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(n.Upload,{maxCount:1,action:Uo(),headers:t?{Authorization:t}:void 0,onChange:R=>{if(R?.file?.status==="done"){const z=uf(R?.file?.response);z&&p(z)}R?.file?.status==="removed"&&p("")},children:e.jsx(n.Button,{icon:e.jsx(Z.UploadOutlined,{}),children:"Upload"})}),!!u&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:u})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(n.Button,{onClick:()=>r(!1),children:"Cancel"}),e.jsx(re,{type:"button",value:o?.Total_Payable_Amount?`Pay ${v(o.Total_Payable_Amount)}`:"Pay",onClick:A})]})]})})]})}function mf({token:t,staffId:a}){const s=i.useMemo(()=>{if(a!=null&&String(a).trim()!=="")return a;if(typeof window>"u")return null;const r=new URLSearchParams(window.location.search).get("id");return r||null},[a]);return s?e.jsx(pf,{token:t,staffId:s}):e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsx("div",{style:{fontSize:13,color:"#666"},children:"Missing staff id."})})}function Bt({onAdd:t,onExport:a,onPrint:s,onDownload:r,onFilter:o,onRefresh:l,actions:d}){const c=i.useMemo(()=>[{key:"add",title:"Add",icon:e.jsx(Z.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(Z.FileExcelOutlined,{}),onClick:a},{key:"print",title:"Print",icon:e.jsx(Z.PrinterOutlined,{}),onClick:s},{key:"download",title:"Download",icon:e.jsx(Z.DownloadOutlined,{}),onClick:r},{key:"filter",title:"Filter",icon:e.jsx(Z.FilterOutlined,{}),onClick:o},{key:"refresh",title:"Refresh",icon:e.jsx(Z.ReloadOutlined,{}),onClick:l}],[t,a,s,r,o,l]),g=i.useMemo(()=>{const f=Array.isArray(d)&&d.length?new Set(d):null;return f?c.filter(u=>f.has(u.key)):c},[c,d]);return e.jsx(n.Space,{size:8,children:g.map(f=>e.jsx(n.Tooltip,{title:f.title,children:e.jsx(n.Button,{type:"text",icon:f.icon,onClick:f.onClick,disabled:!f.onClick})},f.key))})}const tr=t=>t??localStorage.getItem("authToken")??"",Dt={dashboard:{monthlyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentmonthlyReportgraph",weeklyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentweeklyReportgraph"},dropdowns:{classes:"api/branchapi/academy/classdropdownlist",sectionsByClass:"api/branchapi/academy/sectionoftheClass",sessions:"api/branchapi/generalSettings/sessiondropdown"},studentAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass",save:"api/studentAttendace/addattendencebyBranch",emergencyLeave:"api/StudentAttendace/emergency_leave"},dailyAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass"},monthlyReport:{table:"api/branchapi/student/studentmonthlyAttendence",byStudent:"api/branchapi/student/getStududentMonthlyByIdUrlnew"},yearlyReport:{table:"api/branchapi/student/studentyearlyAttendenceReport"}},Ft=async(t,a)=>X(t,tr(a)),ff=async(t,a,s)=>$e(t,a,tr(s)),yf=async(t,a,s)=>qa(t,{arg:a},tr(s)),za=(t,a)=>{const s=new URLSearchParams;Object.entries(a??{}).forEach(([o,l])=>{l==null||l===""||s.set(o,String(l))});const r=t.includes("?")?"&":"?";return`${t}${r}${s.toString()}`},Ti=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}},hf=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Bo=(t,a)=>{const s=t?.data?.data??t?.data??t??{},r=a?s?.[a]:s;return Array.isArray(r)?r:Array.isArray(s?.student)?s.student:Array.isArray(s?.staff)?s.staff:Array.isArray(s?.data)?s.data:[]},gf=t=>Array.isArray(t?.monthly_data)?t.monthly_data:Array.isArray(t?.month_data)?t.month_data:[],xf=t=>{const a={present:0,absent:0,late:0,leave:0};return(Array.isArray(t)?t:[]).forEach(s=>{if(Array.isArray(s?.monthly_data)||Array.isArray(s?.month_data)){gf(s).forEach(o=>{const l=o?.[0]?.data?.[0]??o?.data?.[0]??o??{},d=String(l?.attendance_type??l?.attendence_type_id??"").toUpperCase();(d==="P"||d==="1")&&(a.present+=1),(d==="A"||d==="4")&&(a.absent+=1),(d==="L"||d==="3")&&(a.late+=1),(d==="LEAVE"||d==="2")&&(a.leave+=1)});return}const r=String(s?.attendance_type??s?.attendence_type_id??"").toUpperCase();(r==="P"||r==="1")&&(a.present+=1),(r==="A"||r==="4")&&(a.absent+=1),(r==="L"||r==="3")&&(a.late+=1),(r==="LEAVE"||r==="2")&&(a.leave+=1)}),a},ar=(t,a)=>{const{data:s,isLoading:r,error:o}=H(a&&t?[t,a]:null,([l,d])=>Ft(l,d));return{isLoading:r,error:o,data:s,options:i.useMemo(()=>hf(s),[s])}},ts=t=>ar(Dt.dropdowns.classes,t),as=(t,a)=>{const s=t?`${Dt.dropdowns.sectionsByClass}?class_id=${encodeURIComponent(String(t))}`:null;return ar(s,a)},bf=t=>ar(Dt.dropdowns.sessions,t),nr=t=>{const a=String(t??"").toUpperCase();return Qe(a==="1"||a==="P"||a==="PRESENT"?"P":a==="4"||a==="A"||a==="ABSENT"?"A":a==="3"||a==="L"||a==="LATE"?"L":a==="2"||a==="LEAVE"?"LEAVE":a==="W"?"W":a==="H"?"H":a||"-")},qo=(t,a,s)=>{const r=new Blob([t],{type:a}),o=URL.createObjectURL(r),l=document.createElement("a");l.href=o,l.download=s,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(o)},Ri=t=>String(t??"").replace(/"/g,'""'),jf=({rows:t,columns:a,fileName:s})=>{const r=Array.isArray(a)?a:[],o=Array.isArray(t)?t:[],l=r.map(c=>`"${Ri(c?.title??c?.name??c?.key??c?.dataIndex)}"`).join(","),d=o.map((c,g)=>r.map(f=>{const u=f?.dataIndex??f?.selector??f?.key,p=u==="sl"?g+1:c?.[u];return`"${Ri(p)}"`}).join(",")).join(`
60
- `);qo([l,d].filter(Boolean).join(`
61
- `),"text/csv;charset=utf-8;",s)},Sf=({value:t,fileName:a})=>{qo(JSON.stringify(t??null,null,2),"application/json;charset=utf-8;",a)};function zo({summary:t}){const a=[{key:"present",label:"Present",color:"#52c41a"},{key:"absent",label:"Absent",color:"#ff4d4f"},{key:"late",label:"Late",color:"#fa8c16"},{key:"leave",label:"Leave",color:"#1677ff"}];return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(170px, 1fr))",gap:16},children:a.map(s=>e.jsxs(n.Card,{size:"small",styles:{body:{padding:16}},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:8},children:s.label}),e.jsx("div",{style:{fontSize:24,fontWeight:700,color:s.color},children:t?.[s.key]??0})]},s.key))})}function ga({summary:t,title:a="Attendance Overview"}){const s=i.useMemo(()=>[{key:"present",label:"Present",value:Number(t?.present??0),color:"#52c41a"},{key:"absent",label:"Absent",value:Number(t?.absent??0),color:"#ff4d4f"},{key:"late",label:"Late",value:Number(t?.late??0),color:"#fa8c16"},{key:"leave",label:"Leave",value:Number(t?.leave??0),color:"#1677ff"}],[t]),r=Math.max(...s.map(o=>o.value),1);return e.jsx(n.Card,{size:"small",title:a,children:e.jsx("div",{style:{display:"grid",gap:12},children:s.map(o=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"100px 1fr 50px",gap:12,alignItems:"center"},children:[e.jsx("div",{style:{fontSize:12,color:"#444"},children:o.label}),e.jsx("div",{style:{height:12,background:"#f0f0f0",borderRadius:999},children:e.jsx("div",{style:{width:`${o.value/r*100}%`,height:"100%",background:o.color,borderRadius:999}})}),e.jsx("div",{style:{fontSize:12,fontWeight:600,textAlign:"right"},children:o.value})]},o.key))})})}function vf(){const t=[{label:"Present",node:Qe("P")},{label:"Absent",node:Qe("A")},{label:"Late",node:Qe("L")},{label:"Weekly Off",node:Qe("W")},{label:"Holiday",node:Qe("H")}];return e.jsx(n.Space,{wrap:!0,size:[12,8],children:t.map(a=>e.jsxs(n.Space,{size:6,children:[e.jsx("span",{style:{fontSize:12,color:"#555"},children:a.label}),a.node]},a.label))})}function $t({items:t}){const a=Array.isArray(t)?t.filter(s=>s?.value):[];return a.length?e.jsx(n.Space,{wrap:!0,size:[8,8],children:a.map(s=>e.jsxs(n.Tag,{color:"blue",children:[s.label,": ",s.value]},s.label))}):null}function ns({title:t,subtitle:a,printRef:s,exportRows:r,exportColumns:o,onRefresh:l,onAdd:d,filterSection:c,summary:g,chartContent:f,reportTitle:u,reportExtra:p,children:_,fileBaseName:v="attendance"}){const h=xa.useReactToPrint({content:()=>s?.current});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsxs("div",{children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:t}),a?e.jsx(n.Typography.Text,{type:"secondary",style:{display:"block",marginTop:4},children:a}):null]}),extra:e.jsx(Bt,{actions:["add","export","print","download","refresh"],onAdd:d,onExport:()=>jf({rows:r,columns:o,fileName:`${v}.csv`}),onPrint:h,onDownload:()=>Sf({value:r,fileName:`${v}.json`}),onRefresh:l}),children:c}),e.jsx(zo,{summary:g}),f===!1?null:f||e.jsx(ga,{summary:g}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:u}),extra:p,children:_})]})}const _f=[{label:"Present",value:"1"},{label:"Absent",value:"4"},{label:"Late",value:"3"},{label:"Leave",value:"2"}];function wf({rows:t,loading:a,sunday:s,holiday:r,holidayTitle:o,onChangeRows:l,onEmergency:d}){const c=(f,u)=>{const p=(Array.isArray(t)?t:[]).map((_,v)=>(_?.student_session_id??_?.student_id??_?.id??v)===f?{..._,...u}:_);l?.(p)},g=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(f,u,p)=>p+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(f,u)=>u?.full_name??u?.student_name??u?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:180,render:(f,u,p)=>{const _=u?.student_session_id??u?.student_id??u?.id??p;return e.jsx(n.Select,{size:"small",style:{width:"100%"},options:_f,value:String(f??"1"),onChange:v=>c(_,{attendence_type_id:v})})}},{title:"Date",dataIndex:"date",key:"date",width:120,render:f=>f?ae(f).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120},{title:"Emergency Leave",key:"emergency_leave",width:140,render:(f,u)=>e.jsx(n.Tag,{color:"orange",style:{cursor:"pointer"},icon:e.jsx(Z.ClockCircleOutlined,{}),onClick:()=>d?.(u),children:"E.L"})}],[d,t]);return s?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):r?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:o||"--"})]}):e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(f,u)=>String(f?.student_session_id??f?.student_id??f?.id??u),columns:g,dataSource:Array.isArray(t)?t:[],loading:a,pagination:{pageSize:25},scroll:{x:"max-content"}})}function Cf({rows:t,loading:a,sunday:s,holiday:r,holidayTitle:o}){const l=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(d,c,g)=>g+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(d,c)=>c?.full_name??c?.student_name??c?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:120,render:d=>nr(d)},{title:"Date",dataIndex:"date",key:"date",width:120,render:d=>d?ae(d).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120}],[]);return s?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):r?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:o||"--"})]}):e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(d,c)=>String(d?.student_session_id??d?.student_id??d?.id??c),columns:l,dataSource:Array.isArray(t)?t:[],loading:a,pagination:{pageSize:25},scroll:{x:"max-content"}})}function Af({data:t,loading:a,onViewStudent:s}){const r=t?.data??t??{},o=Array.isArray(r?.studentAttendance)?r.studentAttendance:Array.isArray(r)?r:[],l=Array.isArray(r?.monthly_holiday)?r.monthly_holiday:[],d=Array.isArray(r?.dateSun)?r.dateSun:[],c=Number(r?.totalDaysMonth??0),g=i.useMemo(()=>{const f=[{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,fixed:"left"},{title:"Name",key:"student_name",width:180,fixed:"left",render:(u,p)=>e.jsx(n.Button,{type:"link",style:{padding:0},onClick:()=>s?.(p),children:p?.student_name??p?.full_name??"--"})}];return[...new Array(c).keys()].forEach(u=>{f.push({title:String(u+1),key:`day-${u+1}`,width:52,align:"center",render:(p,_)=>{const h=_?.[`${_?.student_id}_${o.indexOf(_)}`]?.[u]??{},m=h?.attendance_date,x=l.find(T=>T?.date===m);return d.includes(m)?Lr("sunday","W"):x?Lr("holiday","H"):nr(h?.attendence_type_id)}})}),f.push({title:"Total",key:"total",width:140,fixed:"right",render:(u,p)=>{let _=0,v=0,h=0;return[...new Array(c).keys()].forEach(m=>{const x=p?.[`${p?.student_id}_${o.indexOf(p)}`]?.[m]??{},T=String(x?.attendence_type_id??"");T==="1"&&(_+=1),T==="4"&&(v+=1),T==="3"&&(h+=1)}),e.jsxs("span",{children:["P: ",_," A: ",v," L: ",h]})}}),f},[l,s,o,d,c]);return e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(f,u)=>String(f?.student_id??u),columns:g,dataSource:o,loading:a,pagination:{pageSize:20},scroll:{x:"max-content"},locale:{emptyText:e.jsx(n.Empty,{description:"No monthly report found"})}})}function Tf({open:t,onClose:a,loading:s,data:r,studentName:o}){const l=Array.isArray(r?.data?.report)?r.data.report:[],d=[{title:"Date",dataIndex:"attendance_date",key:"attendance_date",render:c=>c?ae(c).format("DD-MM-YYYY"):"--"},{title:"Status",key:"status",render:(c,g)=>nr(g?.attendence_type_id??g?.attendance_type)},{title:"In Time",dataIndex:"intime",key:"intime"},{title:"Out Time",dataIndex:"outtime",key:"outtime"},{title:"Remark",dataIndex:"remark",key:"remark"}];return e.jsx(n.Modal,{open:t,onCancel:a,footer:null,width:900,title:`Monthly Details${o?` - ${o}`:""}`,children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(c,g)=>String(c?.attendance_date??g),columns:d,dataSource:l,loading:s,pagination:{pageSize:20},scroll:{x:"max-content"}})})}function Rf({open:t,onClose:a,onSubmit:s,loading:r}){const[o,l]=n.Modal.useModal(),[d,c]=i.useState(null),[g,f]=i.useState(""),u=async()=>{if(!d){await o.warning({title:"Select time"});return}await s?.({outtime:d.format("h:mm a"),message:g}),c(null),f("")};return e.jsxs(e.Fragment,{children:[l,e.jsx(n.Modal,{title:"Emergency Leave",open:t,onCancel:a,onOk:u,confirmLoading:r,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Select Time"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:d,onChange:c,style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Purpose"}),e.jsx(n.Input.TextArea,{rows:4,value:g,onChange:p=>f(p.target.value)})]})]})})]})}const Yo=t=>xf(t),Di=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a.reduce((s,r)=>({present:s.present+Number(r?.present??r?.Present??r?.total_present??0),absent:s.absent+Number(r?.absent??r?.Absent??r?.total_absent??0),late:s.late+Number(r?.late??r?.Late??0),leave:s.leave+Number(r?.leave??r?.Leave??0)}),{present:0,absent:0,late:0,leave:0}):{present:Number(a?.present??a?.Present??a?.total_present??0),absent:Number(a?.absent??a?.Absent??a?.total_absent??0),late:Number(a?.late??a?.Late??0),leave:Number(a?.leave??a?.Leave??0)}};function Df({token:t}){const{data:a}=H(t?[Dt.dashboard.monthlyGraph,t]:null,([l,d])=>Ft(l,d)),{data:s}=H(t?[Dt.dashboard.weeklyGraph,t]:null,([l,d])=>Ft(l,d)),r=i.useMemo(()=>Di(a),[a]),o=i.useMemo(()=>Di(s),[s]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsxs(n.Card,{children:[e.jsx(n.Typography.Title,{level:4,style:{marginTop:0},children:"Attendance Dashboard"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:0},children:"Student attendance overview with monthly and weekly analytics migrated from the ERP dashboard."})]}),e.jsx(zo,{summary:r}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20},children:[e.jsx(ga,{summary:r,title:"Monthly Attendance Chart"}),e.jsx(ga,{summary:o,title:"Weekly Attendance Chart"})]})]})}const Ts=Dt.studentAttendance,If={width:"100%",height:40};function kf({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[g,f]=i.useState(""),[u,p]=i.useState(""),[_,v]=i.useState(""),[h,m]=i.useState(ae()),[x,T]=i.useState(0),[I,k]=i.useState([]),[C,b]=i.useState(!1),[y,S]=i.useState(null),[A,R]=i.useState(!1),[z,U]=i.useState(!1),j=ts(t),O=as(s,t),M=i.useMemo(()=>!s||!d||x===0?null:za(Ts.list,{cID:s,sID:d,batch_id:u,date:h.format("YYYY-MM-DD")}),[u,s,h,x,d]),{data:$,isLoading:E,mutate:N}=H(t&&M?[M,t]:null,([K,te])=>Ft(K,te));i.useEffect(()=>{k(Bo($,"student"))},[$]);const V=$?.data?.data??$?.data??$??{},q=!!V?.sunday,P=!!V?.holiday?.holiday,D=V?.holiday?.title??"",L=i.useMemo(()=>Yo(I),[I]),B=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),W=async()=>{if(I.length)try{U(!0),await ff(Ts.save,{attendenceData:I,date:h.format("YYYY-MM-DD"),holiday:C?"YES":"NO"},t),w.success("Student attendance saved."),N?.()}catch(K){w.error(K?.message??"Failed to save attendance.")}finally{U(!1)}},se=async({outtime:K,message:te})=>{if(y?.attendence_id)try{R(!0),await yf(Ts.emergencyLeave,{outtime:K,message:te,id:y.attendence_id},t),w.success("Emergency leave updated."),S(null),N?.()}catch(ie){w.error(ie?.message??"Failed to update emergency leave.")}finally{R(!1)}},Q=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(ee,{options:j.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:K=>{r(K?.value??""),l(K?.label??""),c(""),f(""),p(""),v("")},required:!0}),e.jsx(ee,{options:O.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:K=>{c(K?.value??""),f(K?.label??""),p(""),v("")},required:!0},`section-${s}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:h,onChange:K=>K&&m(K),style:If,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"button",value:"Search",color:"primary",onClick:()=>T(K=>K+1)})})]}),e.jsx($t,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Date",value:h.format("DD-MM-YYYY")}]})]});return e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{}),e.jsx(ns,{title:"Student Attendance",printRef:a,exportRows:I,exportColumns:B,onRefresh:()=>N?.(),filterSection:Q,summary:L,chartContent:!1,reportTitle:"Student Attendance List",reportExtra:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(n.Button,{size:"small",type:C?"primary":"default",onClick:()=>b(K=>!K),children:C?"Marked":"Mark As Holiday"}),e.jsx(n.Button,{size:"small",type:"primary",onClick:W,loading:z,disabled:!I.length,children:"Save Attendance"})]}),fileBaseName:"student-attendance",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(It,{}),e.jsx(n.Typography.Title,{level:5,children:"Student Attendance"}),e.jsx(n.Card,{size:"small",style:{marginBottom:12},children:e.jsx($t,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Date",value:h.format("DD-MM-YYYY")}]})})]}),e.jsx(wf,{rows:I,loading:E,sunday:q,holiday:P,holidayTitle:D,onChangeRows:k,onEmergency:S})]})}),e.jsx(Rf,{open:!!y,onClose:()=>S(null),onSubmit:se,loading:A})]})}const Pf=Dt.dailyAttendance,Of={width:"100%",height:40};function Mf({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[g,f]=i.useState(""),[u,p]=i.useState(""),[_,v]=i.useState(ae()),[h,m]=i.useState(0),x=ts(t),T=as(s,t),I=i.useMemo(()=>!s||!d||h===0?null:za(Pf.list,{cID:s,sID:d,batch_id:u,date:_.format("YYYY-MM-DD")}),[u,s,_,h,d]),{data:k,isLoading:C,mutate:b}=H(t&&I?[I,t]:null,([M,$])=>Ft(M,$)),y=i.useMemo(()=>Bo(k,"student"),[k]),S=k?.data?.data??k?.data??k??{},A=!!S?.sunday,R=!!S?.holiday?.holiday,z=S?.holiday?.title??"",U=i.useMemo(()=>Yo(y),[y]),j=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),O=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(ee,{options:x.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{r(M?.value??""),l(M?.label??""),c(""),f(""),p(""),setBatchLabel("")},required:!0}),e.jsx(ee,{options:T.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{c(M?.value??""),f(M?.label??""),p(""),setBatchLabel("")},required:!0},`section-${s}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:_,onChange:M=>M&&v(M),style:Of,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"button",value:"Search",color:"primary",onClick:()=>m(M=>M+1)})})]}),e.jsx($t,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Date",value:_.format("DD-MM-YYYY")}]})]});return e.jsx(ns,{title:"Daily Attendance",subtitle:"Read-only daily attendance enquiry migrated from ERP AttendanceDashboard.",printRef:a,exportRows:y,exportColumns:j,onRefresh:()=>b?.(),filterSection:O,summary:U,chartContent:e.jsx(ga,{summary:U,title:"Daily Attendance Overview"}),reportTitle:"Daily Attendance List",fileBaseName:"daily-attendance",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(It,{}),e.jsx($t,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Date",value:_.format("DD-MM-YYYY")}]})]}),e.jsx(Cf,{rows:y,loading:C,sunday:A,holiday:R,holidayTitle:z})]})})}const Ii=Dt.monthlyReport,Ef=t=>{const a=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],s=Number(t?.totalDaysMonth??0),r={present:0,absent:0,late:0,leave:0};return a.forEach((o,l)=>{[...new Array(s).keys()].forEach(d=>{const c=o?.[`${o?.student_id}_${l}`]?.[d]??{},g=String(c?.attendence_type_id??"");g==="1"&&(r.present+=1),g==="4"&&(r.absent+=1),g==="3"&&(r.late+=1),g==="2"&&(r.leave+=1)})}),r},Ff=t=>{const a=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],s=Number(t?.totalDaysMonth??0);return a.map((r,o)=>{let l=0,d=0,c=0;return[...new Array(s).keys()].forEach(g=>{const f=r?.[`${r?.student_id}_${o}`]?.[g]??{},u=String(f?.attendence_type_id??"");u==="1"&&(l+=1),u==="4"&&(d+=1),u==="3"&&(c+=1)}),{roll_no:r?.roll_no??"",student_name:r?.student_name??r?.full_name??"",present:l,absent:d,late:c}})};function $f({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[g,f]=i.useState(""),[u,p]=i.useState(""),[_,v]=i.useState(""),[h,m]=i.useState(String(new Date().getFullYear())),[x,T]=i.useState(String(new Date().getMonth()+1).padStart(2,"0")),[I,k]=i.useState(0),[C,b]=i.useState(null),y=ts(t),S=as(s,t),A=i.useMemo(()=>Xs(Number(h)),[h]),R=i.useMemo(()=>Qs(10),[]),z=i.useMemo(()=>!s||!d||!h||!x||I===0?null:za(Ii.table,{session:Ti(),class_id:s,section_id:d,year:h,month:x,batch_id:u}),[u,s,x,I,d,h]),{data:U,isLoading:j,mutate:O}=H(t&&z?[z,t]:null,([L,B])=>Ft(L,B)),M=U?.data?.data??U?.data??U??{},$=i.useMemo(()=>Ef(M),[M]),E=i.useMemo(()=>Ff(M),[M]),N=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Name",dataIndex:"student_name"},{title:"Present",dataIndex:"present"},{title:"Absent",dataIndex:"absent"},{title:"Late",dataIndex:"late"}],[]),V=i.useMemo(()=>C?.student_id?za(Ii.byStudent,{student_id:C.student_id,month:x,year:h,session:Ti()}):null,[x,C,h]),{data:q,isLoading:P}=H(t&&V?[V,t]:null,([L,B])=>Ft(L,B)),D=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(ee,{options:y.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:L=>{r(L?.value??""),l(L?.label??""),c(""),f(""),p(""),v("")},required:!0}),e.jsx(ee,{options:S.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:L=>{c(L?.value??""),f(L?.label??""),p(""),v("")},required:!0},`section-${s}`),e.jsx(ee,{options:R,label:"Year",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:R.find(L=>String(L?.value)===String(h))??null,onChange:L=>m(String(L?.value??"")),required:!0}),e.jsx(ee,{options:A,label:"Month",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:A.find(L=>String(L?.value)===String(x))??null,onChange:L=>T(String(L?.value??"").padStart(2,"0")),required:!0},`month-${h}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"button",value:"Search",color:"primary",onClick:()=>k(L=>L+1)})})]}),e.jsx($t,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Month",value:A.find(L=>String(L?.value)===String(x))?.label??x},{label:"Year",value:h}]}),e.jsx(vf,{})]});return e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Monthly Report",subtitle:"Monthly class-wise attendance matrix and student drilldown.",printRef:a,exportRows:E,exportColumns:N,onRefresh:()=>O?.(),filterSection:D,summary:$,chartContent:e.jsx(ga,{summary:$,title:"Monthly Attendance Summary"}),reportTitle:"Monthly Attendance Table",fileBaseName:"monthly-attendance-report",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(It,{}),e.jsx($t,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Month",value:A.find(L=>String(L?.value)===String(x))?.label??x},{label:"Year",value:h}]})]}),e.jsx(Af,{data:M,loading:j,onViewStudent:b})]})}),e.jsx(Tf,{open:!!C,onClose:()=>b(null),loading:P,data:q,studentName:C?.student_name??C?.full_name})]})}const Uf=Dt.yearlyReport,Nf=t=>{const a=t?.data?.data??t?.data??t??{};return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:Array.isArray(a?.students)?a.students:Array.isArray(a?.report)?a.report:[]},Lf=t=>(Array.isArray(t)?t:[]).reduce((a,s)=>({present:a.present+Number(s?.singleStudentPresentData??s?.present??0),absent:a.absent+Number(s?.singleStudentAbsentData??s?.absent??0),late:a.late+Number(s?.late??0),leave:a.leave+Number(s?.leave??0)}),{present:0,absent:0,late:0,leave:0});function Bf({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[g,f]=i.useState(""),[u,p]=i.useState(""),[_,v]=i.useState(""),[h,m]=i.useState(""),[x,T]=i.useState(""),[I,k]=i.useState(0),C=ts(t),b=as(s,t),y=bf(t),S=i.useMemo(()=>!s||!d||I===0?null:za(Uf.table,{class_id:s,section_id:d,session_id:u,batch_id:h}),[h,s,I,d,u]),{data:A,isLoading:R,mutate:z}=H(t&&S?[S,t]:null,([E,N])=>Ft(E,N)),U=i.useMemo(()=>Nf(A),[A]),j=i.useMemo(()=>Lf(U),[U]),O=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Present",dataIndex:"singleStudentPresentData"},{title:"Absent",dataIndex:"singleStudentAbsentData"}],[]),M=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(E,N,V)=>V+1},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",dataIndex:"full_name",key:"full_name"},{title:"Total Present",dataIndex:"singleStudentPresentData",key:"singleStudentPresentData",width:130},{title:"Total Absent",dataIndex:"singleStudentAbsentData",key:"singleStudentAbsentData",width:130}],[]),$=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(ee,{options:C.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{r(E?.value??""),l(E?.label??""),c(""),f(""),m(""),T("")},required:!0}),e.jsx(ee,{options:b.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{c(E?.value??""),f(E?.label??""),m(""),T("")},required:!0},`section-${s}`),e.jsx(ee,{options:y.options,label:"Session",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{p(E?.value??""),v(E?.label??"")},required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"button",value:"Search",color:"primary",onClick:()=>k(E=>E+1)})})]}),e.jsx($t,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Session",value:_}]})]});return e.jsx(ns,{title:"Yearly Report",subtitle:"Yearly attendance summary migrated from ERP AttendanceDashboard.",printRef:a,exportRows:U,exportColumns:O,onRefresh:()=>z?.(),filterSection:$,summary:j,chartContent:e.jsx(ga,{summary:j,title:"Yearly Attendance Summary"}),reportTitle:"Yearly Attendance List",fileBaseName:"yearly-attendance-report",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(It,{}),e.jsx($t,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Session",value:_}]})]}),e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(E,N)=>String(E?.student_id??E?.id??N),columns:M,dataSource:U,loading:R,pagination:{pageSize:25},scroll:{x:"max-content"}})]})})}function qf(){return null}const ss=t=>t??localStorage.getItem("authToken")??"",zf=(t,a)=>{const s=String(t??""),r=String(a);return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Vo=()=>JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",we={uploadNotes:"api/branchapi/Academy/uploadNotes",master:{classes:{dropdown:"api/branchapi/academy/classdropdownlist",table:"api/branchapi/academy/classestableList",add:"api/branchapi/academy/addclasses",edit:"api/branchapi/academy/editclass",remove:"api/branchapi/academy/deleteclass",show:"api/branchapi/academy/classShowdata"},sections:{list:"api/branchapi/academy/sectionlist",table:"api/branchapi/academy/sectiontableList",add:"api/branchapi/academy/addsections",edit:"api/branchapi/academy/editsection",remove:"api/branchapi/academy/deletesection",show:"api/branchapi/academy/sectionShowdata",byClass:"api/branchapi/academy/sectionoftheClass"},subjects:{dropdown:"api/branchapi/Academy/getClassSubjectdropdown",byClassLabelValue:"api/branchapi/Academy/getSubjectsbyClassaslablevalue",table:"api/branchapi/academy/subjecttableList",add:"api/branchapi/academy/addsubjects",edit:"api/branchapi/academy/editsubject",remove:"api/branchapi/academy/deletesubject",show:"api/branchapi/academy/subjectShowdata"},holidays:{table:"api/branchapi/academy/holidayList",add:"api/branchapi/academy/addholidays",edit:"api/branchapi/academy/editholidays",remove:"api/branchapi/academy/deleteholiday",show:"api/branchapi/academy/getByIdholidays"}},assignSubjects:{assign:"api/branchapi/Academy/assign_class_subjects",list:"api/branchapi/academy/getSubjectsbyClass",update:"api/branchapi/academy/updateAssignSubject",editByClass:"api/branchapi/academy/editSubjectsbyClass"},assignByClass:{teacherDropdown:"api/branchapi/topics/getTeacherDropdown",classWithSection:"api/branchapi/academy/getClasswithSection",assignedSubjectsOfTeacher:"api/branchapi/academy/getassignedSubjectsofTeacher",subjectsOfTeacherByTeacherId:"api/branchapi/academy/getSubjectsofTeacherbyTeacherID",assignClassToTeacher:"api/branchapi/academy/assignClasstoTeacher",deleteTeacherSub:"api/branchapi/academy/deleteTeacherSub"},promoteStudents:{searchByClassSection:"api/branchapi/student/currentSessionStudentlist",sessionDropdown:"api/branchapi/generalSettings/sessiondropdown",promote:"api/branchapi/student/promotestudent"},timeGroup:{table:"api/branchapi/academy/getTimeGroupTable",add:"api/branchapi/academy/addTimeGroup",edit:"api/branchapi/academy/editTimeGroup",remove:"api/branchapi/academy/deleteTimeGroup",show:"api/branchapi/academy/getTimeGroupDataById",dropdown:"api/branchapi/academy/getTimeGroupDropDown"},assignTimeGroup:{classIdByTimeGroup:"api/branchapi/academy/getClassIdByTimeGroup",table:"api/branchapi/academy/getAssignedTimeGroupTable",show:"api/branchapi/academy/getAssignedTimeGroupDataById",assign:"api/branchapi/academy/assignTimeGroup"},timetable:{save:"api/timetable/save",byClassSection:"api/timetable/class",teacherTimetable:"api/timetable/teacher/",teachersBySubject:"api/branchapi/Academy/gettechersSubject"},notes:{table:"api/branchapi/Academy/getNotesTable",add:"api/branchapi/Academy/addNotes"},syllabus:{table:"api/branchapi/Academy/getsyllabusTable",add:"api/branchapi/Academy/addsyllabus",edit:"api/branchapi/Academy/editsyllabus"},transferCertificate:{studentList:"api/branchapi/student/getstudenttransferCertificateList",addData:"api/branchapi/academy/addtransferCertificatedata",view:"api/branchapi/academy/gettransferCertificateUrl"},coscholastic:{table:"api/branchapi/academy/getcoscholastic",addSkill:"api/branchapi/academy/add_coscholastic_skill",deleteSkill:"api/branchapi/academy/deleteCoscholastic",categoryDropdown:"api/branchapi/academy/coscholastic_categorydropdown",addCategory:"api/branchapi/academy/addcoscholastic_category",deleteCategory:"api/branchapi/academy/coscholasticCategoryDelete"}},Yf=()=>zf(et(),we.uploadNotes),Vf=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return X(l,ss(r))},jt=async(t,a,s,{includeSession:r=!1}={})=>{const o=a instanceof FormData?a:new FormData;return r&&!o.has("session_id")&&o.append("session_id",Vo()),$e(t,o,ss(s))},Ut=async(t,a,s,{includeSession:r=!1}={})=>{const o=a instanceof FormData?a:new FormData;return r&&!o.has("session_id")&&o.append("session_id",Vo()),Xe(t,o,ss(s))},Nt=async(t,a,s)=>Ye(t,a,ss(s)),Nn=we.master.sections,tn=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>H(r&&t?[t,a,s,r]:null,([l,d,c,g])=>Vf({baseUrl:l,page:d,perPage:c},g)),Wf=({token:t,page:a=1,perPage:s=10})=>tn({token:t,baseUrl:Nn.table,page:a,perPage:s}),Hf=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Kf({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),{data:g,isLoading:f,mutate:u}=Wf({token:t,page:a.page,perPage:a.perPage}),p=i.useMemo(()=>Hf(g),[g]),_=i.useMemo(()=>g?.pagination?.total_rows??g?.pagination?.total??p.length??0,[g,p]),v=async I=>{I.preventDefault();const k=new FormData(I.target);try{await jt(Nn.add,k,t),w.success("Success! Added new item.",{duration:1e3}),I.target.reset(),u()}catch(C){w.error(C?.response?.data?.msg??C?.message??"Failed to add the new item.",{duration:1500})}},h=async I=>{try{await Nt(Nn.remove,I,t),w.success("Success! Deleted item.",{duration:1e3}),u()}catch(k){w.error(k?.response?.data?.msg??k?.message??"Failed to delete the item.",{duration:1500})}},m=I=>{d(I),o(!0),c.setFieldsValue({section:I?.section??""})},x=async I=>{const k=new FormData;k.append("id",String(l?.id??"")),k.append("section",I.section??"");try{await Ut(Nn.edit,k,t),w.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),u()}catch(C){w.error(C?.response?.data?.msg??C?.message??"Failed to update the item.",{duration:1500})}},T=i.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(I,k)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>m(k)}),e.jsx(n.Popconfirm,{title:"Delete this section?",onConfirm:()=>h(k?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Section",open:r,onClose:()=>{o(!1),d(null)},width:420,children:e.jsxs(n.Form,{form:c,layout:"vertical",onFinish:x,children:[e.jsx(n.Form.Item,{label:"Section Name",name:"section",rules:[{required:!0,message:"Section Name is required"}],children:e.jsx(n.Input,{placeholder:"Section Name"})}),e.jsxs(n.Space,{children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Section"}),children:e.jsx("form",{onSubmit:v,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"section",label:"Section Name",required:!0}),e.jsx(re,{type:"submit",value:"Submit",color:"primary"})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Section List"}),extra:e.jsx(n.Space,{}),children:e.jsx(n.Table,{rowKey:I=>I.id,columns:T,dataSource:p,loading:f,pagination:{current:a.page,pageSize:a.perPage,total:_,showSizeChanger:!0,onChange:(I,k)=>s({page:I,perPage:k})}})})]})}function Gf({token:t}){return e.jsx(Kf,{token:t})}const Ua=we.master.classes,Jf=({token:t,page:a=1,perPage:s=10})=>tn({token:t,baseUrl:Ua.table,page:a,perPage:s}),Qf=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Xf=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function Zf({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),{data:f}=H(t?[we.master.sections.list,t]:null,([A,R])=>X(A,R)),u=i.useMemo(()=>Xf(f),[f]),p=i.useMemo(()=>u.map(A=>({label:A.label??A.section??String(A.value??""),value:String(A.value??A.id??"")})),[u]),{data:_,isLoading:v,mutate:h}=Jf({token:t,page:a.page,perPage:a.perPage}),m=i.useMemo(()=>Qf(_),[_]),x=i.useMemo(()=>_?.pagination?.total_rows??_?.pagination?.total??m.length??0,[_,m]),{data:T}=H(t&&l?[`${Ua.show}?id=${encodeURIComponent(String(l))}`,t]:null,([A,R])=>X(A,R)),I=i.useMemo(()=>{const A=T?.data??T;return Array.isArray(A)?A:Array.isArray(A?.data)?A.data:A?[A]:[]},[T]),k=A=>{const R=A?.id??A?.class_id;R&&(d(R),o(!0))};i.useEffect(()=>{if(!r||!I.length)return;const A=I[0],R=I.map(j=>j?.section_id??j?.fk_sectionId??j?.sectionId??j?.section).filter(j=>j!=null&&String(j).trim()!=="").map(j=>String(j)),z=Array.isArray(A?.section_ids)?A.section_ids.map(j=>String(j)):typeof A?.section_ids=="string"?A.section_ids.split(",").map(j=>j.trim()).filter(Boolean):Array.isArray(A?.section)?A.section.map(j=>String(j)):[],U=R.length?R:z;g.setFieldsValue({name:A?.class??A?.name??"",section:U})},[r,I,g]);const C=async A=>{const R=new FormData;R.append("name",A.name??""),(A.section??[]).forEach(z=>R.append("section[]",String(z)));try{await jt(Ua.add,R,t),w.success("Success! Added new item.",{duration:1e3}),c.resetFields(),h()}catch(z){w.error(z?.response?.data?.msg??z?.message??"Failed to add the new item.",{duration:1500})}},b=async A=>{const R=new FormData;R.append("id",String(l??"")),R.append("name",A.name??""),(A.section??[]).forEach(z=>R.append("section[]",String(z)));try{await Ut(Ua.edit,R,t),w.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),h()}catch(z){w.error(z?.response?.data?.msg??z?.message??"Failed to update the item.",{duration:1500})}},y=async A=>{try{await Nt(Ua.remove,A,t),w.success("Success! Deleted item.",{duration:1e3}),h()}catch(R){w.error(R?.response?.data?.msg??R?.message??"Failed to delete the item.",{duration:1500})}},S=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(A,R)=>A??R?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:A=>A??""},{title:"Actions",key:"actions",width:120,render:(A,R)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>k(R)}),e.jsx(n.Popconfirm,{title:"Delete this class?",onConfirm:()=>y(R?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Class",open:r,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:b,children:[e.jsx(n.Form.Item,{label:"Class",name:"name",rules:[{required:!0,message:"Class is required"}],children:e.jsx(n.Input,{placeholder:"Class"})}),e.jsx(n.Form.Item,{label:"Sections",name:"section",rules:[{required:!0,message:"Please select at least one section"}],children:e.jsx(n.Checkbox.Group,{options:p})}),e.jsxs(n.Space,{children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Class"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:C,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",label:"Class",rules:[{required:!0,message:"Class is required"}],children:e.jsx(n.Input,{placeholder:"Class"})}),e.jsx(n.Form.Item,{name:"section",label:"Sections",rules:[{required:!0,message:"Select at least one section"}],children:e.jsx(n.Checkbox.Group,{options:p})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Class List"}),children:e.jsx(n.Table,{rowKey:A=>A.id,columns:S,dataSource:m,loading:v,pagination:{current:a.page,pageSize:a.perPage,total:x,showSizeChanger:!0,onChange:(A,R)=>s({page:A,perPage:R})}})})]})}function ey({token:t}){return e.jsx(Zf,{token:t})}const Na=we.master.subjects,ty=({token:t,page:a=1,perPage:s=10})=>tn({token:t,baseUrl:Na.table,page:a,perPage:s}),ay=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},ki=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],Pi=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function ny({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),{data:f,isLoading:u,mutate:p}=ty({token:t,page:a.page,perPage:a.perPage}),_=i.useMemo(()=>ay(f),[f]),v=i.useMemo(()=>f?.pagination?.total_rows??f?.pagination?.total??_.length??0,[f,_]),{data:h}=H(t&&l?[`${Na.show}?id=${encodeURIComponent(String(l))}`,t]:null,([b,y])=>X(b,y)),m=i.useMemo(()=>{const b=h?.data??h;return Array.isArray(b)?b[0]:b??null},[h]);i.useEffect(()=>{r&&m&&g.setFieldsValue({name:m?.name??"",subject_type:m?.subject_type??m?.type??"",type:"",subject_types:Array.isArray(m?.subject_types)?m.subject_types:typeof m?.subject_types=="string"?m.subject_types.split(",").map(b=>b.trim()).filter(Boolean):[],code:m?.code??""})},[r,m,g]);const x=async b=>{const y=b?.type??b?.subject_type??"",S={name:b?.name??"",subject_type:y,type:y,subject_types:Array.isArray(b?.subject_types)?b.subject_types:[],code:b?.code??""};try{await $e(Na.add,S,t),w.success("Success! Added new item.",{duration:1e3}),c.resetFields(),p()}catch(A){w.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},T=async b=>{const y=new FormData,S=b?.type??b?.subject_type??"";y.append("id",String(l??"")),y.append("name",b.name??""),y.append("subject_type",b.subject_type??""),y.append("subject_type",S),y.append("type",S),y.append("code",b.code??"");try{await Ut(Na.edit,y,t),w.success("Success! Updated item.",{duration:1e3}),w.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(A){w.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},I=async b=>{try{await Nt(Na.remove,b,t),w.success("Success! Deleted item.",{duration:1e3}),p()}catch(y){w.error(y?.response?.data?.msg??y?.message??"Failed to delete the item.",{duration:1500})}},k=b=>{const y=b?.id;y&&(d(y),o(!0))},C=i.useMemo(()=>[{title:"Subject Name",dataIndex:"name",key:"name"},{title:"Subject",dataIndex:"subject_type",key:"subject_type"},{title:"Subject Code",dataIndex:"code",key:"code"},{title:"Subject Type",key:"subject_types",render:(b,y)=>{const S=[],A=y?.subject_types;Array.isArray(A)?A.forEach(O=>{const M=String(O??"").trim();M&&S.push(M)}):typeof A=="string"&&A.split(",").map(O=>O.trim()).filter(Boolean).forEach(O=>S.push(O));const R=["yes","1","true"].includes(String(y?.is_practical??"").toLowerCase()),z=["yes","1","true"].includes(String(y?.is_theory??"").toLowerCase());R&&S.push("Practical"),z&&S.push("Theory");const U=S.map(O=>String(O??"").trim()).filter(Boolean).map(O=>O.toLowerCase()==="practical"?"Practical":O.toLowerCase()==="theory"?"Theory":O),j=Array.from(new Set(U));return j.length?j.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(b,y)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>k(y)}),e.jsx(n.Popconfirm,{title:"Delete this subject?",onConfirm:()=>I(y?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Subject",open:r,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:T,children:[e.jsx(n.Form.Item,{label:"Subject Name",name:"name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(Y,{placeholder:"Subject Name"})}),e.jsx(n.Form.Item,{label:"Subject",name:"subject_type",rules:[{required:!0,message:"Select subject category"}],children:e.jsx(n.Radio.Group,{options:Pi})}),e.jsx(n.Form.Item,{label:"Subject Type",name:"subject_types",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(n.Checkbox.Group,{options:ki})}),e.jsx(n.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(Y,{placeholder:"Subject Code"})}),e.jsxs(n.Space,{children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Subject"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",label:"Subject Name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(Y,{placeholder:"Subject Name"})}),e.jsx(n.Form.Item,{name:"subject_type",label:"Subject",rules:[{required:!0,message:"Select subject"}],children:e.jsx(n.Radio.Group,{options:Pi})}),e.jsx(n.Form.Item,{name:"subject_types",label:"Subject Type",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(n.Checkbox.Group,{options:ki})}),e.jsx(n.Form.Item,{name:"code",label:"Subject Code",children:e.jsx(Y,{placeholder:"Subject Code"})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Subject List"}),children:e.jsx(n.Table,{rowKey:b=>b.id,columns:C,dataSource:_,loading:u,pagination:{current:a.page,pageSize:a.perPage,total:v,showSizeChanger:!0,onChange:(b,y)=>s({page:b,perPage:y})}})})]})}function sy({token:t}){return e.jsx(ny,{token:t})}const La=we.master.holidays,ry=({token:t,page:a=1,perPage:s=10})=>tn({token:t,baseUrl:La.table,page:a,perPage:s}),iy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},vn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function oy({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),{data:f,isLoading:u,mutate:p}=ry({token:t,page:a.page,perPage:a.perPage}),_=i.useMemo(()=>iy(f),[f]),v=i.useMemo(()=>f?.pagination?.total_rows??f?.pagination?.total??_.length??0,[f,_]),{data:h}=H(t&&l?[`${La.show}?id=${encodeURIComponent(String(l))}`,t]:null,([b,y])=>X(b,y)),m=i.useMemo(()=>{const b=h?.data??h;return Array.isArray(b)?b[0]:b??null},[h]);i.useEffect(()=>{r&&m&&g.setFieldsValue({title:m?.holiday_title??"",description:m?.holiday_description??"",from:m?.start_date?ae(m.start_date):null,to:m?.end_date?ae(m.end_date):null})},[r,m,g]);const x=async b=>{const y=new FormData;y.append("title",b.title??""),y.append("description",b.description??""),y.append("from",b.from?ae(b.from).format("YYYY-MM-DD"):""),y.append("to",b.to?ae(b.to).format("YYYY-MM-DD"):"");try{await jt(La.add,y,t,{includeSession:!0}),w.success("Success! Added new item.",{duration:1e3}),c.resetFields(),p()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to add the new item.",{duration:1500})}},T=async b=>{const y=new FormData;y.append("id",String(l??"")),y.append("title",b.title??""),y.append("description",b.description??""),y.append("from",b.from?ae(b.from).format("YYYY-MM-DD"):""),y.append("to",b.to?ae(b.to).format("YYYY-MM-DD"):"");try{await Ut(La.edit,y,t,{includeSession:!0}),w.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to update the item.",{duration:1500})}},I=async b=>{try{await Nt(La.remove,b,t),w.success("Success! Deleted item.",{duration:1e3}),p()}catch(y){w.error(y?.response?.data?.msg??y?.message??"Failed to delete the item.",{duration:1500})}},k=b=>{const y=b?.id;y&&(d(y),o(!0))},C=i.useMemo(()=>[{title:"Holiday Title",dataIndex:"holiday_title",key:"holiday_title"},{title:"Holiday Description",dataIndex:"holiday_description",key:"holiday_description"},{title:"Start From",dataIndex:"start_date",key:"start_date"},{title:"End At",dataIndex:"end_date",key:"end_date"},{title:"Actions",key:"actions",width:120,render:(b,y)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>k(y)}),e.jsx(n.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>I(y?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Holiday",open:r,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:T,children:[e.jsx(n.Form.Item,{label:"Holiday Title",name:"title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(Y,{placeholder:"Holiday Title"})}),e.jsx(n.Form.Item,{label:"Holiday Description",name:"description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(Y,{placeholder:"Holiday Description"})}),e.jsx(n.Form.Item,{label:"Start From",name:"from",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:vn})}),e.jsx(n.Form.Item,{label:"End At",name:"to",rules:[{required:!0,message:"End date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:vn})}),e.jsxs(n.Space,{children:[e.jsx(re,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Holidays"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"title",label:"Holiday Title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(Y,{placeholder:"Holiday Title"})}),e.jsx(n.Form.Item,{name:"description",label:"Holiday Description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(wt,{placeholder:"Holiday Description"})}),e.jsx(n.Form.Item,{name:"from",label:"Start From",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:vn})}),e.jsx(n.Form.Item,{name:"to",label:"End At",rules:[{required:!0,message:"End date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:vn})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Holidays List"}),children:e.jsx(n.Table,{rowKey:b=>b.id,columns:C,dataSource:_,loading:u,pagination:{current:a.page,pageSize:a.perPage,total:v,showSizeChanger:!0,onChange:(b,y)=>s({page:b,perPage:y})}})})]})}function ly({token:t}){return e.jsx(oy,{token:t})}const Ln=we.assignSubjects,dy=({token:t,page:a=1,perPage:s=50})=>tn({token:t,baseUrl:Ln.list,page:a,perPage:s}),Oi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],cy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function uy({token:t}){const[a,s]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,g]=i.useState(!1),[f,u]=i.useState(!1),[p,_]=i.useState(null),[v,h]=i.useState([]),{data:m}=H(t?[we.master.classes.dropdown,t]:null,([M,$])=>X(M,$)),{data:x}=H(t?[we.master.subjects.dropdown,t]:null,([M,$])=>X(M,$)),T=i.useMemo(()=>Oi(m),[m]),I=i.useMemo(()=>Oi(x),[x]),k=i.useMemo(()=>I.map(M=>({label:M.label??M.subject??String(M.value??""),value:M.value??M.id})),[I]),{data:C,isLoading:b,mutate:y}=dy({token:t,page:a.page,perPage:a.perPage}),S=i.useMemo(()=>cy(C),[C]),A=i.useMemo(()=>C?.pagination?.total_rows??C?.pagination?.total??S.length??0,[C,S]),{data:R}=H(t&&p?[`${Ln.editByClass}?class_id=${encodeURIComponent(String(p))}`,t]:null,([M,$])=>X(M,$));i.useEffect(()=>{if(!f)return;const M=R?.data??R,$=Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[];h($.map(E=>E.subject_id).filter(Boolean))},[f,R]);const z=async M=>{if(M.preventDefault(),!r?.value){w.error("Please select class",{duration:1200});return}if(!l.length){w.error("Please select subjects",{duration:1200});return}const $=new FormData;$.append("class_id",String(r.value)),l.forEach(E=>$.append("subject[]",String(E)));try{g(!0),await Ut(Ln.assign,$,t),w.success("Success! Updated item.",{duration:1e3}),o(null),d([]),y()}catch(E){w.error(E?.response?.data?.msg??E?.message??"Failed to update the item.",{duration:1500})}finally{g(!1)}},U=M=>{M&&(_(M),u(!0))},j=async()=>{if(!p)return;if(!v.length){w.error("Please select subjects",{duration:1200});return}const M=new FormData;M.append("class_id",String(p)),v.forEach($=>M.append("subject[]",String($)));try{await Ut(Ln.update,M,t),w.success("Success! Updated item.",{duration:1e3}),u(!1),_(null),y()}catch($){w.error($?.response?.data?.msg??$?.message??"Failed to update the item.",{duration:1500})}},O=i.useMemo(()=>[{title:"Class",dataIndex:"class",align:"center",width:"15%"},{title:"Subject",dataIndex:"subject_name",width:"70%",render:(M,$)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:($?.subject_name??M??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(M,$)=>e.jsx(n.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>U($?.class_id)})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Assigned Subjects",open:f,onClose:()=>{u(!1),_(null)},width:520,extra:e.jsxs(n.Space,{children:[e.jsx(n.Button,{onClick:()=>u(!1),children:"Cancel"}),e.jsx(n.Button,{type:"primary",onClick:j,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:T.find(M=>String(M.value)===String(p))??null,onChange:()=>{},isDisabled:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(n.Checkbox.Group,{options:k,value:v,onChange:h})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Subject"}),children:e.jsx("form",{onSubmit:z,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:r,onChange:M=>o(M??null)}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(n.Checkbox.Group,{options:k,value:l,onChange:d})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:c?"Please Wait..":"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assigned Subject List"}),children:e.jsx(n.Table,{rowKey:M=>M.id,columns:O,dataSource:S,loading:b,pagination:{current:a.page,pageSize:a.perPage,total:A,showSizeChanger:!0,onChange:(M,$)=>s({page:M,perPage:$})}})})]})}function py({token:t}){return e.jsx(uy,{token:t})}const ua=we.assignByClass,Wo=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(typeof t?.data?.Status=="string"&&Array.isArray(t?.data?.data))return t.data.data;if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Pa=t=>Wo(t),my=t=>Wo(t),Oa=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function fy({token:t}){const[a,s]=i.useState(null),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,g]=i.useState("No"),[f,u]=i.useState([]),[p,_]=i.useState([]),[v,h]=i.useState(null),[m,x]=i.useState(null),[T,I]=i.useState(!1),[k,C]=i.useState(""),{data:b}=H(t?[ua.teacherDropdown,t]:null,([le,G])=>X(le,G)),{data:y}=H(t?[we.master.classes.dropdown,t]:null,([le,G])=>X(le,G)),{data:S}=H(t&&m?[m,t]:null,([le,G])=>X(le,G)),{data:A}=H(t&&v?[v,t]:null,([le,G])=>X(le,G)),R=i.useMemo(()=>Pa(b),[b]),z=i.useMemo(()=>Pa(y),[y]),U=i.useMemo(()=>Pa(S),[S]),j=i.useMemo(()=>Pa(A),[A]),{data:O}=H(t&&a&&r&&l?[`${ua.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(a))}&class_id=${encodeURIComponent(String(r))}&section_id=${encodeURIComponent(String(l))}`,t]:null,([le,G])=>X(le,G)),M=O?.data??O??null;i.useEffect(()=>{M&&(u(Array.isArray(M?.subject_ids)?M.subject_ids:[]),g(M?.isClassTeacher||"No"),_([]))},[M]);const{data:$}=H(t?[ua.classWithSection,t]:null,([le,G])=>X(le,G)),E=i.useMemo(()=>Pa($),[$]),[N,V]=i.useState(null),[q,P]=i.useState({page:1,perPage:25});i.useEffect(()=>{N||E?.[0]&&V(`${E[0].class_id}val${E[0].section_id}`)},[E,N]);const D=i.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),L=i.useMemo(()=>{if(!N)return null;const[le,G]=String(N).split("val");if(!le||!G)return null;const de=q.page??1,Ae=q.perPage??25;return`${ua.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(de))}&per_page=${encodeURIComponent(String(Ae))}&session_id=${encodeURIComponent(String(D))}&class_id=${encodeURIComponent(String(le))}&section_id=${encodeURIComponent(String(G))}`},[N,q.page,q.perPage,D]),{data:B,isLoading:W,mutate:se}=H(t&&L?[L,t]:null,([le,G])=>X(le,G),{revalidateOnFocus:!1}),Q=i.useMemo(()=>my(B),[B]),K=i.useMemo(()=>{const le=B?.pagination??B?.data?.pagination??B?.data?.data?.pagination;return le?.total_rows??le?.total??Q.length??0},[B,Q]),te=async le=>{if(le.preventDefault(),C(""),!a||!r||!l){w.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(f)||f.length===0){C("error"),w.error("Please Select Subject",{duration:1200});return}const G=new FormData;G.append("teacher_id",String(a)),G.append("class_id",String(r)),G.append("section_id",String(l)),G.append("isClassTeacher",String(c??"No")),Oa(f).forEach(de=>G.append("subject_ids[]",String(de))),Oa(p).forEach(de=>G.append("delete_subject[]",String(de)));try{await jt(ua.assignClassToTeacher,G,t,{includeSession:!0}),w.success("Success! Added new item.",{duration:1e3}),C(""),se()}catch(de){w.error(de?.response?.data?.msg??de?.message??"Failed to add the new item.",{duration:1500})}},ie=async le=>{try{await Nt(ua.deleteTeacherSub,le,t),w.success("Success! Deleted item.",{duration:1e3}),se()}catch(G){w.error(G?.response?.data?.msg??G?.message??"Failed to delete the item.",{duration:1500})}},pe=le=>{const G=Array.isArray(le?.child)?le.child:[],de=[{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Subject Code",dataIndex:"code",key:"code",align:"center"},{title:"Action",key:"action",align:"center",render:(Ae,Ee)=>e.jsx(n.Popconfirm,{title:"Delete this subject?",onConfirm:()=>ie(Ee?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(n.Table,{columns:de,bordered:!0,size:"small",dataSource:G,pagination:!1,rowKey:Ae=>Ae.id})})},_e=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(le,G)=>e.jsxs("div",{children:[G.teacher_name,G.classTeacher==="Yes"?e.jsx("span",{style:{fontWeight:700},children:" (Class Teacher)"}):null]})}],oe=i.useMemo(()=>(E??[]).map(le=>({label:le.label??`${le.class_name??""} ${le.section_name??""}`.trim(),key:`${le.class_id}val${le.section_id}`,children:e.jsx(n.Table,{size:"small",columns:_e,bordered:!0,dataSource:Array.isArray(Q)?Q:[],loading:W,rowKey:G=>G.id,expandable:{expandedRowRender:pe},pagination:{current:q.page,pageSize:q.perPage,total:K,showSizeChanger:!0,onChange:(G,de)=>P({page:G,perPage:de})}})})),[E,q.page,q.perPage,Q,W,K]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(320px, 380px) 1fr",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign by Class"}),children:e.jsx("form",{onSubmit:te,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:R.find(le=>String(le.value)===String(a))??null,onChange:le=>s(le?.value??null)}),e.jsx(ee,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:z.find(le=>String(le.value)===String(r))??null,onChange:le=>{const G=le?.value??null;o(G),d(null),h(G?`${we.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(G))}`:null),x(G?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(G))}`:null),I(de=>!de)}}),e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:U.find(le=>String(le.value)===String(l))??null,onChange:le=>d(le?.value??null)},`section_${T}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Is Class Teacher?"}),(()=>{const le=[{label:"Yes",value:"Yes"},{label:"No",value:"No"}];return e.jsx(ee,{style:{width:"100%"},options:le,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:le.find(G=>String(G.value)===String(c??"No"))??le[1],onChange:G=>g(G?.value??"No")})})()]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subject"}),e.jsx(ee,{isMulti:!0,style:{width:"100%"},placeholder:"select Subject",options:j,value:(j??[]).filter(le=>Oa(f).some(G=>String(G)===String(le.value))),onChange:(le,G)=>{const Ae=(Array.isArray(le)?le:[]).map(Fe=>Fe?.value).filter(Fe=>Fe!=null&&Fe!=="");u(Ae);const Ee=Array.isArray(M?.subject_ids)?M.subject_ids.map(String):[],Pe=G?.removedValue?.value,ze=G?.option?.value;(G?.action==="remove-value"||G?.action==="pop-value")&&Pe!=null&&Ee.includes(String(Pe))&&_(Fe=>Array.from(new Set([...Oa(Fe).map(String),String(Pe)]))),G?.action==="select-option"&&ze!=null&&Ee.includes(String(ze))&&_(Fe=>Oa(Fe).filter(tt=>String(tt)!==String(ze)))}},`subjects_${T}`),k?e.jsx("div",{style:{color:"#ff4d4f",marginTop:6,fontSize:12},children:"Please select subject"}):null]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Teacher List"}),children:e.jsx(n.Tabs,{activeKey:N??void 0,onChange:le=>{V(le),P(G=>({...G,page:1}))},items:oe,type:"card",size:"small"})})]})]})}function yy({token:t}){return e.jsx(fy,{token:t})}const Ma=we.timeGroup,hy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Mt={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function _n(t){if(!t)return null;const a=ae(String(t),["h:mm a","HH:mm:ss","HH:mm"],!0);return a.isValid()?a:null}function Et(t){return t?ae(t).format("h:mm a"):""}function gy({token:t}){const[a,s]=i.useState({page:1,perPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),f=`${Ma.table}?page=${encodeURIComponent(String(a.page))}&per_page=${encodeURIComponent(String(a.perPage))}`,{data:u,isLoading:p,mutate:_}=H(t?[f,t]:null,([y,S])=>X(y,S)),v=i.useMemo(()=>hy(u),[u]),h=i.useMemo(()=>u?.pagination?.total_rows??u?.pagination?.total??v.length??0,[u,v]),{data:m}=H(t&&l?[`${Ma.show}?id=${encodeURIComponent(String(l))}`,t]:null,([y,S])=>X(y,S)),x=i.useMemo(()=>{const y=m?.data??m;return Array.isArray(y)?y[0]:y??null},[m]);i.useEffect(()=>{r&&x&&g.setFieldsValue({title:x?.title??"",start_time_from:_n(x?.start_time_from),start_time_to:_n(x?.start_time_to),end_time_from:_n(x?.end_time_from),end_time_to:_n(x?.end_time_to)})},[r,x,g]);const T=async y=>{const S=new FormData;S.append("title",y.title??""),S.append("start_time_from",Et(y.start_time_from)),S.append("start_time_to",Et(y.start_time_to)),S.append("end_time_from",Et(y.end_time_from)),S.append("end_time_to",Et(y.end_time_to));try{await jt(Ma.add,S,t),w.success("Success! Added new item.",{duration:1e3}),c.resetFields(),_()}catch(A){w.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},I=async y=>{const S=new FormData;S.append("id",String(l??"")),S.append("title",y.title??""),S.append("start_time_from",Et(y.start_time_from)),S.append("start_time_to",Et(y.start_time_to)),S.append("end_time_from",Et(y.end_time_from)),S.append("end_time_to",Et(y.end_time_to));try{await Ut(Ma.edit,S,t),w.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),_()}catch(A){w.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},k=async y=>{try{await Nt(Ma.remove,y,t),w.success("Success! Deleted item.",{duration:1e3}),_()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to delete the item.",{duration:1500})}},C=y=>{y?.id&&(d(y.id),o(!0))},b=i.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:120,render:(y,S)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>C(S)}),e.jsx(n.Popconfirm,{title:"Delete this time group?",onConfirm:()=>k(S?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Time Group",open:r,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:I,children:[e.jsx(n.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Mt})}),e.jsx(n.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Mt})}),e.jsx(n.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Mt})}),e.jsx(n.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Mt})}),e.jsxs(n.Space,{children:[e.jsx(re,{type:"submit",value:"Submit",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Create Time Group"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:T,initialValues:{},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Mt})}),e.jsx(n.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Mt})}),e.jsx(n.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Mt})}),e.jsx(n.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Mt})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Time Group List"}),children:e.jsx(n.Table,{rowKey:y=>y.id,columns:b,dataSource:v,loading:p,pagination:{current:a.page,pageSize:a.perPage,total:h,showSizeChanger:!0,onChange:(y,S)=>s({page:y,perPage:S})}})})]})}function xy({token:t}){return e.jsx(gy,{token:t})}const Ea=we.assignTimeGroup,by=we.timeGroup.dropdown,jy=we.master.classes.dropdown,Mi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Sy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function vy({token:t}){const[a,s]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,g]=i.useState(""),[f,u]=i.useState(""),[p,_]=i.useState(null),[v,h]=i.useState(!1),[m,x]=i.useState(!1),[T,I]=i.useState(null),[k,C]=i.useState([]),[b,y]=i.useState(""),[S,A]=i.useState(""),{data:R}=H(t?[by,t]:null,([Q,K])=>X(Q,K)),{data:z}=H(t?[jy,t]:null,([Q,K])=>X(Q,K)),U=i.useMemo(()=>Mi(R?.data??R),[R]),j=i.useMemo(()=>Mi(z),[z]),{data:O}=H(t&&p?[p,t]:null,([Q,K])=>X(Q,K));i.useEffect(()=>{const Q=Array.isArray(O?.data)?O.data.map(K=>K.fk_classId):[];Q.length&&d(Q)},[O]);const M=`${Ea.table}?page=${encodeURIComponent(String(a.page))}&per_page=${encodeURIComponent(String(a.perPage))}`,{data:$,isLoading:E,mutate:N}=H(t?[M,t]:null,([Q,K])=>X(Q,K)),V=i.useMemo(()=>Sy($),[$]),q=i.useMemo(()=>$?.pagination?.total_rows??$?.pagination?.total??V.length??0,[$,V]),{data:P}=H(t&&T?[`${Ea.show}?id=${encodeURIComponent(String(T))}`,t]:null,([Q,K])=>X(Q,K)),D=P?.data??P??null;i.useEffect(()=>{if(!m||!D)return;const Q=Array.isArray(D?.class_ids)?D.class_ids:[];C(Q);const K=Array.isArray(U)?U.find(te=>String(te.value)===String(D?.timegroup_id)):null;K&&A(`${K.start_time_from} -> ${K.end_time_from}`)},[m,D,U]);const L=async Q=>{if(Q.preventDefault(),g(""),!r?.value){w.error("Select Time Group",{duration:1200});return}if(!l.length){g("error"),w.error("Please Select Classes",{duration:1200});return}const K=new FormData;K.append("timegroup_id",String(r.value)),l.forEach(te=>K.append("class_ids[]",String(te)));try{await jt(Ea.assign,K,t),w.success("Success! Added new item.",{duration:1e3}),d([]),o(null),u(""),N()}catch(te){w.error(te?.response?.data?.msg??te?.message??"Failed to add the new item.",{duration:1500})}},B=async()=>{if(y(""),!T)return;if(!k.length){y("error"),w.error("Please Select Classes",{duration:1200});return}const Q=new FormData;Q.append("id",String(T)),Q.append("timegroup_id",String(D?.timegroup_id??"")),k.forEach(K=>Q.append("class_ids[]",String(K)));try{await Ut(Ea.assign,Q,t),w.success("Success! Updated item.",{duration:1e3}),x(!1),I(null),N()}catch(K){w.error(K?.response?.data?.msg??K?.message??"Failed to update the item.",{duration:1500})}},W=Q=>{Q&&(I(Q),x(!0))},se=i.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Class Names",dataIndex:"class_names",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:90,render:(Q,K)=>K?.class_names?e.jsx(n.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>W(K?.id)}):null}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Assigned Time Group",open:m,onClose:()=>{x(!1),I(null)},width:520,extra:e.jsxs(n.Space,{children:[e.jsx(n.Button,{onClick:()=>x(!1),children:"Cancel"}),e.jsx(n.Button,{type:"primary",onClick:B,children:"Submit"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:Array.isArray(U)?U:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:U.find(Q=>String(Q.value)===String(D?.timegroup_id))??null,onChange:()=>{},isDisabled:!0}),e.jsx("div",{style:{marginTop:4,fontSize:16},children:S}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(n.Select,{mode:"multiple",style:{width:"100%"},status:b,value:k,placeholder:"Select Classes",onChange:Q=>C(Q),options:Array.isArray(j)?j:[]})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Time Group"}),children:e.jsx("form",{onSubmit:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx(ee,{options:Array.isArray(U)?U:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:r,onChange:Q=>{o(Q??null),d([]),g(""),Q?.value?(_(`${Ea.classIdByTimeGroup}?id=${encodeURIComponent(String(Q.value))}`),u(`${Q.start_time_from} -> ${Q.end_time_from}`)):(_(null),u("")),h(K=>!K)}}),e.jsx("div",{style:{marginTop:6},children:f})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(ee,{mode:"multiple",style:{width:"100%"},status:c,value:l,placeholder:"Select Classes",onChange:Q=>d(Q),options:Array.isArray(j)?j:[]},`class_${v}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assigned Time group List"}),children:e.jsx(n.Table,{rowKey:Q=>Q.id,columns:se,dataSource:V,loading:E,pagination:{current:a.page,pageSize:a.perPage,total:q,showSizeChanger:!0,onChange:(Q,K)=>s({page:Q,perPage:K})}})})]})}function _y({token:t}){return e.jsx(vy,{token:t})}const zs=we.promoteStudents,wy=({token:t})=>H(t?[zs.sessionDropdown,t]:null,([a,s])=>X(a,s)),wn=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Cy=(t,a)=>{const s=t?.pagination??t?.data?.pagination??t?.data?.data?.pagination,r=s?.total_rows??s?.total??s?.totalItems;return Number.isFinite(Number(r))?Number(r):a};function Ay({token:t}){const[a]=n.Form.useForm(),[s,r]=i.useState({page:1,perPage:300}),[o,l]=i.useState({classId:null,sectionId:null}),[d,c]=i.useState({sessionId:null,classId:null}),[g,f]=i.useState(!1),[u,p]=i.useState([]),_=i.useMemo(()=>new Set(u),[u]),[v,h]=i.useState({}),[m,x]=i.useState({}),{data:T}=H(t?[we.master.classes.dropdown,t]:null,([B,W])=>X(B,W)),I=i.useMemo(()=>wn(T),[T]),k=i.useMemo(()=>o.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(o.classId))}`:null,[o.classId]),{data:C}=H(t&&k?[k,t]:null,([B,W])=>X(B,W)),b=i.useMemo(()=>wn(C),[C]),y=i.useMemo(()=>d.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:S}=H(t&&y?[y,t]:null,([B,W])=>X(B,W),{revalidateOnFocus:!1}),A=i.useMemo(()=>wn(S),[S]),{data:R}=wy({token:t}),z=i.useMemo(()=>wn(R),[R]),{trigger:U,data:j,isMutating:O}=nt(t?zs.searchByClassSection:null,(B,{arg:W})=>Ht(B,{arg:W},t)),M=i.useMemo(()=>{const B=j?.data?.data??j?.data??j??[];return Array.isArray(B)?B:Array.isArray(B?.data)?B.data:[]},[j]),$=i.useMemo(()=>Cy(j,M.length??0),[j,M.length]),E=i.useMemo(()=>{const B=new Map;return(Array.isArray(M)?M:[]).forEach(W=>{W?.id!==void 0&&W?.id!==null&&B.set(String(W.id),W)}),B},[M]),N=i.useCallback((B,W)=>{const se=String(B);x(Q=>({...Q,[se]:{...Q?.[se]??{},...W}}))},[]),V=i.useCallback((B,W)=>{const se=String(B),Q=W==="Leave";h(K=>({...K,[se]:Q}))},[]),q=B=>{const W=B?.class_id?.value??B?.class_id??null,se=B?.section_id?.value??B?.section_id??null;if(!W||!se){w.error("Please select Class and Section",{duration:1200});return}r(Q=>({...Q,page:1})),l({classId:W,sectionId:se}),p([]),h({}),x({})},P=async()=>{if(!d.sessionId||!d.classId){w.error("Please select Session and Class for promotion",{duration:1300});return}if(!Array.isArray(u)||u.length===0){w.error("Please select students to promote",{duration:1200});return}const B=u.map(K=>String(K)).map(K=>{const te=E.get(K)??{},ie=!!v?.[K],pe=m?.[K]??{},_e=String(pe.current_result??"Pass");if(ie){const G=String(pe.leave_date??"");return{student_id:K,current_result:_e,next_session_status:"Leave",leave_date:G}}const oe=String(pe.roll_no??te?.roll_no??""),le=String(pe.section_id??"");return{student_id:K,roll_no:oe,section_id:le,current_result:_e,next_session_status:"Continue"}});if(B.some(K=>K?.next_session_status==="Leave"&&!String(K?.leave_date??"").trim())){w.error("Leave date is required for Leave students.",{duration:1500});return}if(B.some(K=>K?.next_session_status==="Continue"&&!String(K?.section_id??"").trim())){w.error("Section is required for Continue students.",{duration:1500});return}const Q={class_id:String(d.classId),session_id:String(d.sessionId),students:B};try{const K=await Xe(zs.promote,Q,t);if(K?.Status&&String(K.Status)!=="success")throw new Error(K?.msg||"Failed to update");w.success("Success! Updated.",{duration:1e3});const te=Number(K?.success_count??0)+Number(K?.leave_count??0),ie=s.page===Math.ceil((Number($)||0)/s.perPage||1),pe=te>0&&te===M.length&&M.length===u.length,_e=ie&&pe&&s.page>1?s.page-1:s.page;r(oe=>({...oe,page:_e})),U?.({cID:o.classId,sID:o.sectionId,page:_e,per_page:s.perPage}),p([]),h({}),x({})}catch(K){w.error(K?.response?.data?.msg??K?.message??"Failed to update",{duration:1500})}},D=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:140},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:120,render:(B,W)=>{const se=String(W?.id??""),Q=_.has(se),K=!!v?.[se],ie=(m?.[se]??{}).roll_no??(K?"":W?.roll_no??"");return e.jsx(n.Input,{value:Q?ie:W?.roll_no,style:Q?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!Q||K,onChange:pe=>N(se,{roll_no:pe.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(B,W)=>`${W?.firstname??""} ${W?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(B,W)=>{const se=String(W?.id??""),Q=_.has(se),K=!!v?.[se],ie=(m?.[se]??{}).section_id??"",pe=Array.isArray(A)?A:[];return e.jsx(n.Select,{options:pe,placeholder:Q&&!K?"Select Section":"Section",disabled:!Q||K,value:Q&&!K&&ie||void 0,style:{width:"100%"},onChange:_e=>N(se,{section_id:_e})},`section_${se}_${g}_${K?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(B,W)=>{const se=String(W?.id??""),Q=_.has(se),K=m?.[se]??{},te=String(K.current_result??"Pass");return e.jsxs(n.Radio.Group,{value:te,disabled:!Q,buttonStyle:"solid",onChange:ie=>N(se,{current_result:ie.target.value}),children:[e.jsx(n.Radio.Button,{value:"Pass",children:"Pass"}),e.jsx(n.Radio.Button,{value:"Fail",children:"Fail"})]})}},{title:"Next Session Status",dataIndex:"next_session_status",key:"next_session_status",width:220,render:(B,W)=>{const se=String(W?.id??""),Q=_.has(se),K=!!v?.[se],te=m?.[se]??{},ie=String(te.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(n.Radio.Group,{value:K?"Leave":"Continue",disabled:!Q,buttonStyle:"solid",onChange:pe=>V(se,pe.target.value),children:[e.jsx(n.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(n.Radio.Button,{value:"Leave",children:"Leave"})]}),Q&&K&&e.jsx(n.DatePicker,{style:{width:"100%"},value:ie?ae(ie):null,onChange:pe=>N(se,{leave_date:pe?pe.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[V,v,m,_,g,A,N]),L=i.useMemo(()=>({selectedRowKeys:u,onChange:B=>p((Array.isArray(B)?B:[]).map(W=>String(W)))}),[u]);return i.useEffect(()=>{!o.classId||!o.sectionId||U&&U({cID:o.classId,sID:o.sectionId,page:s.page,per_page:s.perPage})},[s.page,s.perPage,U,o.classId,o.sectionId]),e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Promote Students"}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"class_id",label:"Class",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:B=>B,children:e.jsx(ee,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:B=>{const W=B?.value??null;a.setFieldValue("section_id",null),l({classId:W,sectionId:null})}})}),e.jsx(n.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:B=>B,children:e.jsx(ee,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Promote Students In Next Session"}),extra:e.jsx(Bt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(n.Typography.Text,{children:["Selected: ",u.length]}),e.jsx(n.Typography.Text,{type:"secondary",children:"Select students → set Continue/Leave → Save"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{label:"Session",options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:z.find(B=>String(B.value)===String(d.sessionId))??null,onChange:B=>c(W=>({...W,sessionId:B?.value??null}))}),e.jsx(ee,{label:"Class",options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:I.find(B=>String(B.value)===String(d.classId))??null,onChange:B=>{const W=B?.value??null;c(se=>({...se,classId:W})),f(se=>!se)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"button",value:"Save",color:"primary",onClick:P})})]}),e.jsx(n.Table,{rowKey:B=>String(B.id),rowSelection:L,columns:D,dataSource:M,loading:O,pagination:{current:s.page,pageSize:s.perPage,total:$,showSizeChanger:!0,onChange:(B,W)=>{r({page:B,perPage:W}),p([]),h({}),x({})}}})]})})]})}function Ty({token:t}){return e.jsx(Ay,{token:t})}const ma=we.coscholastic,Ry=({token:t})=>H(t?[ma.table,t]:null,([a,s])=>X(a,s),{revalidateOnFocus:!1}),Dy=({token:t})=>H(t?[ma.categoryDropdown,t]:null,([a,s])=>X(a,s),{revalidateOnFocus:!1}),Ei=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]};function Iy({token:t}){const[a,s]=i.useState(""),[r,o]=i.useState(null),[l,d]=i.useState(null),c=i.useRef(null),{data:g}=H(t?[we.master.classes.dropdown,t]:null,([S,A])=>X(S,A)),f=i.useMemo(()=>Ei(g),[g]),{data:u,isLoading:p,mutate:_}=Ry({token:t}),v=i.useMemo(()=>{const S=u?.data?.data??u?.data??u??[];return Array.isArray(S)?S:Array.isArray(S?.data)?S.data:[]},[u]),{data:h,mutate:m}=Dy({token:t}),x=i.useMemo(()=>Ei(h),[h]),T=i.useMemo(()=>(Array.isArray(x)?x:[]).map(S=>({value:S?.value??S?.id,label:S?.label??S?.title??""})),[x]),I=async()=>{const S=String(a??"").trim();if(!S){w.error("Please enter category title",{duration:1200});return}try{await $e(ma.addCategory,{title:S},t),w.success("Success! Added category.",{duration:1e3}),s(""),m()}catch(A){w.error(A?.response?.data?.msg??A?.message??"Failed to add category",{duration:1500})}},k=async S=>{try{await Nt(ma.deleteCategory,S,t),w.success("Success! Deleted category.",{duration:1e3}),m()}catch(A){w.error(A?.response?.data?.msg??A?.message??"Failed to delete category",{duration:1500})}},C=async S=>{if(S.preventDefault(),!r){w.error("Please select Category",{duration:1200});return}if(!l){w.error("Please select Class",{duration:1200});return}if(!S?.target?.skill?.value){w.error("Please enter Skill Name",{duration:1200});return}const R=new FormData(S.target);R.append("scholastic_catid",String(r)),R.append("class_id",String(l));try{await jt(ma.addSkill,R,t),w.success("Success! Added new item.",{duration:1e3}),S.target.reset(),d(null),_()}catch(z){w.error(z?.response?.data?.msg??z?.message??"Failed to add the new item.",{duration:1500})}},b=async S=>{try{await Nt(ma.deleteSkill,S,t),w.success("Success! Deleted item.",{duration:1e3}),_()}catch(A){w.error(A?.response?.data?.msg??A?.message??"Failed to delete the item.",{duration:1500})}},y=i.useMemo(()=>[{title:"Skill Category",dataIndex:"title",key:"title"},{title:"Class",dataIndex:"class",key:"class"},{title:"Skill Name",dataIndex:"skill",key:"skill"},{title:"Action",key:"action",width:90,render:(S,A)=>e.jsx(n.Popconfirm,{title:"Delete this skill?",onConfirm:()=>b(A?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Co Scholastic Area"}),children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Category"}),e.jsx(ee,{style:{width:"100%"},value:T.find(S=>String(S.value)===String(r))??null,placeholder:"Select Category",onChange:S=>o(S?.value??null),options:T}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:10},children:[e.jsx(Y,{placeholder:"New category",ref:c,value:a,onChange:S=>s(S.target.value)}),e.jsx(n.Button,{type:"text",icon:e.jsx(Z.PlusOutlined,{}),onClick:I}),e.jsx(n.Popconfirm,{title:"Delete selected category?",onConfirm:()=>{r&&(k(r),o(null))},children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{}),disabled:!r})})]})]}),e.jsx(ee,{label:"Class",options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:f.find(S=>String(S.value)===String(l))??null,onChange:S=>d(S?.value??null)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Skill Name"}),e.jsx(Y,{name:"skill",placeholder:"Skill Name"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Co Scholastic Area List"}),extra:e.jsx(Bt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(n.Table,{rowKey:S=>S.id,columns:y,dataSource:v,loading:p,pagination:!1})})]})}function ky({token:t}){return e.jsx(Iy,{token:t})}const Py=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Ho=({token:t,value:a,onChange:s})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:Yf(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=Py(o?.file?.response);l&&s?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})},Fi=we.notes,Oy=({token:t,url:a})=>H(t&&a?[a,t]:null,([s,r])=>X(s,r),{revalidateOnFocus:!1}),Cn=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},My=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r};function Ey({token:t}){const[a]=n.Form.useForm(),[s]=n.Form.useForm(),[r,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null,sectionId:null}),[c,g]=i.useState(!1),[f,u]=i.useState(""),{data:p}=H(t?[we.master.classes.dropdown,t]:null,([L,B])=>X(L,B)),_=i.useMemo(()=>Cn(p),[p]),v=i.useMemo(()=>l.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:h}=H(t&&v?[v,t]:null,([L,B])=>X(L,B)),m=i.useMemo(()=>Cn(h),[h]),x=i.useMemo(()=>!l.classId||!l.sectionId?null:`${Fi.table}?class_id=${encodeURIComponent(String(l.classId))}&section_id=${encodeURIComponent(String(l.sectionId))}&page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.perPage))}`,[l.classId,l.sectionId,r.page,r.perPage]),{data:T,isLoading:I,mutate:k}=Oy({token:t,url:x}),C=i.useMemo(()=>{const L=T?.data?.data??T?.data??T??[];return Array.isArray(L)?L:Array.isArray(L?.data)?L.data:[]},[T]),b=i.useMemo(()=>T?.pagination?.total_rows??T?.pagination?.total??C.length??0,[T,C.length]),[y,S]=i.useState(null),[A,R]=i.useState(null),[z,U]=i.useState(null),[j,O]=i.useState(!1),{data:M}=H(t&&z?[z,t]:null,([L,B])=>X(L,B),{revalidateOnFocus:!1}),$=i.useMemo(()=>Cn(M),[M]),{data:E}=H(t&&A?[A,t]:null,([L,B])=>X(L,B)),N=i.useMemo(()=>Cn(E),[E]),V=L=>{const B=L?.class_id?.value??null,W=L?.section_id?.value??null;!B||!W||(o(se=>({...se,page:1})),d({classId:B,sectionId:W}))},q=()=>{u(""),g(!0),S(null),R(null),U(null),O(L=>!L),s.resetFields()},P=async L=>{const B=L?.class_id?.value??null,W=L?.section_id?.value??null,se=L?.sub_id?.value??null,Q=L?.status?.value??"publish",K=L?.title??"",te=L?.remark??"";if(!B||!W||!se||!K||!te||!f){w.error("Please fill all fields",{duration:1200});return}const ie=new FormData;ie.append("class_id",String(B)),ie.append("section_id",String(W)),ie.append("sub_id",String(se)),ie.append("title",String(K)),ie.append("remark",String(te)),ie.append("status",String(Q)),ie.append("file",String(f));try{await jt(Fi.add,ie,t),w.success("Success! Added new item.",{duration:1e3}),g(!1),k()}catch(pe){w.error(pe?.response?.data?.msg??pe?.message??"Failed to add the new item.",{duration:1500})}},D=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",align:"center"},{title:"Remarks",dataIndex:"remark",key:"remark",align:"center"},{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Staff Name",dataIndex:"teacher_name",key:"teacher_name",align:"center"},{title:"Status",key:"status",align:"center",render:(L,B)=>{const W=String(B?.status??"").toLowerCase();return e.jsx(n.Tag,{color:W==="publish"?"green":"red",children:B?.status??"-"})}},{title:"File",key:"file",align:"center",render:(L,B)=>{const W=B?.file;if(!W)return"-";const se=My(et(),`/student/note/${W}`);return e.jsx("a",{href:se,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Date",dataIndex:"publish_date",key:"publish_date",align:"center"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:"Add Note",open:c,onCancel:()=>g(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(n.Form,{form:s,layout:"vertical",onFinish:P,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:L=>L,children:e.jsx(ee,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:L=>{const B=L?.value??null;S(B),s.setFieldValue("section_id",null),s.setFieldValue("sub_id",null),U(B?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(B))}`:null),R(B?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(B))}`:null),O(W=>!W)}},`class_${j}`)}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:L=>L,children:e.jsx(ee,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${j}_${y??"none"}`)}),e.jsx(n.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:L=>L,children:e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${j}_${A??"none"}`)}),e.jsx(n.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{label:"Remark",name:"remark",rules:[{required:!0,message:"Remark is required"}],children:e.jsx(Y,{placeholder:"Remark"})}),e.jsx(n.Form.Item,{label:"Status",name:"status",initialValue:{label:"Publish",value:"publish"},getValueFromEvent:L=>L,children:e.jsx(ee,{options:[{label:"Publish",value:"publish"},{label:"Unpublish",value:"unpublish"}],closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx(n.Form.Item,{label:"File",required:!0,children:e.jsx(Ho,{token:t,value:f,onChange:u})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(re,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>g(!1),children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Notes"}),e.jsx(Bt,{actions:["add","export","print","download","filter"],onAdd:q,onPrint:()=>window.print()})]}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:V,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:L=>L,children:e.jsx(ee,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:L=>{const B=L?.value??null;a.setFieldValue("section_id",null),d({classId:B,sectionId:null})}})}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:L=>L,children:e.jsx(ee,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Note List"}),children:e.jsx(n.Table,{rowKey:L=>L.id,columns:D,dataSource:C,loading:I,pagination:{current:r.page,pageSize:r.perPage,total:b,showSizeChanger:!0,onChange:(L,B)=>o({page:L,perPage:B})}})})]})}function Fy({token:t}){return e.jsx(Ey,{token:t})}const $y=({token:t})=>H(t?[we.promoteStudents.sessionDropdown,t]:null,([a,s])=>X(a,s),{revalidateOnFocus:!1}),$i=we.transferCertificate,Rs=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Uy={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Ny=(t,a)=>t.inputtype==="Select"?null:t.inputtype==="date"?ae():"",Ui=t=>[{name:"ncc_details",inputtype:"text",label:"Ncc Details",required:!1},{name:"extra_curricular_activites",inputtype:"text",label:"Games played or extra-curricular activities in which the pupil usually took part",required:!1},{name:"generalConduct",inputtype:"text",label:"General conduct",required:!1},{name:"qualified_class",inputtype:"Select",label:"Qualified class",required:!1},{name:"application_date",inputtype:"date",label:"Date of application for certificate",required:!1},{name:"issue_date",inputtype:"date",label:"Date of issue of certificate",required:!1},{name:"reason_of_leaving",inputtype:"text",label:"Reason for leaving the school",required:!1},{name:"otherRemarks",inputtype:"text",label:"Any other remarks",required:!1},{name:"student_id",inputtype:"hidden",label:"",required:!1,value:t},{name:"qualified_for_promotion",inputtype:"radio",label:"Qualified for promotion",required:!1},{name:"failed",inputtype:"radio",label:"Failed",required:!1},{name:"nationality",inputtype:"text",label:"Nationality",required:!1},{name:"checked_by",inputtype:"text",label:"Checked By",required:!1},{name:"checked_by_designation",inputtype:"text",label:"Checked By Designation",required:!1}],Ni=t=>[{name:"change_of_school",inputtype:"text",label:"Change of School",required:!1},{name:"character_remark",inputtype:"text",label:"Character",required:!1},{name:"generalConduct",inputtype:"text",label:"General conduct",required:!1},{name:"application_date",inputtype:"date",label:"Date of application for certificate",required:!1},{name:"issue_date",inputtype:"date",label:"Date of issue of certificate",required:!1},{name:"last_attendance",inputtype:"date",label:"Last Class Attendence",required:!1},{name:"otherRemarks",inputtype:"text",label:"Any other remarks",required:!1},{name:"student_id",inputtype:"hidden",label:"",required:!1,value:t},{name:"qualified_for_promotion",inputtype:"radio",label:"Qualified for promotion",required:!1}];function Ly({token:t,transferCertificateViewPath:a="/AcademicsDashboard/TransferCertificateView",onOpenTransferCertificateView:s}){const[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState({page:1,perPage:10}),[c,g]=i.useState({classId:null,sectionId:null,sessionId:null}),[f,u]=i.useState(null),[p,_]=i.useState(!1),{data:v}=H(t?[we.master.classes.dropdown,t]:null,([D,L])=>X(D,L)),h=i.useMemo(()=>Rs(v),[v]),{data:m}=H(t&&f?[f,t]:null,([D,L])=>X(D,L)),x=i.useMemo(()=>Rs(m),[m]),{data:T}=$y({token:t}),I=i.useMemo(()=>Rs(T),[T]),k=i.useMemo(()=>!c.classId||!c.sectionId||!c.sessionId?null:`${$i.studentList}?class_id=${encodeURIComponent(String(c.classId))}&section_id=${encodeURIComponent(String(c.sectionId))}&session_id=${encodeURIComponent(String(c.sessionId))}&page=${encodeURIComponent(String(l.page))}&per_page=${encodeURIComponent(String(l.perPage))}`,[c.classId,c.sectionId,c.sessionId,l.page,l.perPage]),{data:C,isLoading:b,mutate:y}=H(t&&k?[k,t]:null,([D,L])=>X(D,L),{revalidateOnFocus:!1,onSuccess:D=>{const L=D?.data?.data??D?.data??[];Array.isArray(L)&&L[0]?.transefer_certificate_id&&M(String(L[0].transefer_certificate_id))}}),S=i.useMemo(()=>{const D=C?.data?.data??C?.data??C??[];return Array.isArray(D)?D:Array.isArray(D?.data)?D.data:[]},[C]),A=i.useMemo(()=>C?.pagination?.total_rows??C?.pagination?.total??S.length??0,[C,S.length]),[R,z]=i.useState(!1),[U,j]=i.useState(null),[O,M]=i.useState("1"),$=D=>{j(D);const L=O==="1"?Ui(D):Ni(D),B={};L.forEach(W=>{B[W.name]=W.value??Ny(W)}),o.setFieldsValue(B),z(!0)},E=async D=>{if(!D)return;if(typeof s=="function")return s(D);const L=`${a}?id=${encodeURIComponent(String(D))}`;window.location.href=L},N=D=>{const L=D?.class_id?.value??null,B=D?.section_id?.value??null,W=D?.session_id?.value??null;if(!L||!B||!W){w.error("Please select Class, Section and Session",{duration:1200});return}d(se=>({...se,page:1})),g({classId:L,sectionId:B,sessionId:W})},V=async D=>{const L=new FormData;Object.entries(D??{}).forEach(([B,W])=>{if(W!=null){if(ae.isDayjs(W)){L.append(B,W.format("YYYY-MM-DD"));return}L.append(B,String(W))}});try{await jt($i.addData,L,t),w.success("Success! Added new item.",{duration:1e3}),z(!1),j(null),y()}catch(B){w.error(B?.response?.data?.msg??B?.message??"Failed to add the new item.",{duration:1500})}},q=i.useMemo(()=>O==="1"?Ui(U):Ni(U),[O,U]),P=i.useMemo(()=>[{title:"Admission no",dataIndex:"admission_no",key:"admission_no",align:"center"},{title:"Roll NO",dataIndex:"roll_no",key:"roll_no",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",align:"center"},{title:"Class",dataIndex:"class",key:"class",align:"center"},{title:"Section",dataIndex:"section",key:"section",align:"center"},{title:"Guardian Name",dataIndex:"guardian_name",key:"guardian_name",align:"center"},{title:"Mobile No",dataIndex:"mobileno",key:"mobileno",align:"center"},{title:"Action",key:"action",align:"center",width:80,render:(D,L)=>e.jsx(n.Button,{type:"text",icon:L?.transfer_certificate_data==="not_present"?e.jsx(Z.EyeOutlined,{}):e.jsx(Z.CheckOutlined,{}),onClick:()=>{L?.transfer_certificate_data==="not_present"?$(L?.id):E(L?.id)}})}],[O]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:"Transfer Certificate",open:R,onCancel:()=>z(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:V,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:q.map(D=>D.inputtype==="hidden"?e.jsx(n.Form.Item,{name:D.name,initialValue:D.value??"",style:{display:"none"},children:e.jsx("input",{type:"hidden"})},D.name):D.inputtype==="date"?e.jsx(n.Form.Item,{label:D.label,name:D.name,children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:Uy})},D.name):D.inputtype==="radio"?e.jsx(n.Form.Item,{label:D.label,name:D.name,children:e.jsx(n.Radio.Group,{options:[{label:"Yes",value:"Yes"},{label:"No",value:"No"}]})},D.name):D.inputtype==="Select"?e.jsx(n.Form.Item,{label:D.label,name:D.name,getValueFromEvent:L=>L,children:e.jsx(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})},D.name):e.jsx(n.Form.Item,{label:D.label,name:D.name,children:e.jsx(Y,{placeholder:D.label})},D.name))}),e.jsxs(n.Space,{style:{width:"100%",justifyContent:"flex-end"},children:[e.jsx(re,{type:"submit",value:"Submit",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>z(!1),children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Student History"}),children:e.jsx(n.Form,{form:r,layout:"vertical",onFinish:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:D=>D,children:e.jsx(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:D=>{const L=D?.value??null;u(L?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(L))}`:null),_(B=>!B),r.setFieldValue("section_id",null)}})}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:D=>D,children:e.jsx(ee,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${p}`)}),e.jsx(n.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:D=>D,children:e.jsx(ee,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Student List"}),extra:e.jsx(Bt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(n.Table,{rowKey:D=>D.id,columns:P,dataSource:S,loading:b,pagination:{current:l.page,pageSize:l.perPage,total:A,showSizeChanger:!0,onChange:(D,L)=>d({page:D,perPage:L})}})})]})}function By({token:t,transferCertificateViewPath:a,onOpenTransferCertificateView:s}){return e.jsx(Ly,{token:t,transferCertificateViewPath:a,onOpenTransferCertificateView:s})}const qy=({token:t,url:a})=>H(t&&a?[a,t]:null,([s,r])=>X(s,r),{revalidateOnFocus:!1}),Ds=we.syllabus,Li=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},zy=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r};function Yy({token:t}){const[a]=n.Form.useForm(),[s]=n.Form.useForm(),[r,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null}),[c,g]=i.useState(!1),[f,u]=i.useState(null),[p,_]=i.useState(""),{data:v}=H(t?[we.master.classes.dropdown,t]:null,([E,N])=>X(E,N)),h=i.useMemo(()=>Li(v),[v]),m=i.useMemo(()=>l.classId?`${Ds.table}?class_id=${encodeURIComponent(String(l.classId))}&page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.perPage))}`:null,[l.classId,r.page,r.perPage]),{data:x,isLoading:T,mutate:I}=qy({token:t,url:m}),k=i.useMemo(()=>{const E=x?.data?.data??x?.data??x??[];return Array.isArray(E)?E:Array.isArray(E?.data)?E.data:[]},[x]),C=i.useMemo(()=>x?.pagination?.total_rows??x?.pagination?.total??k.length??0,[x,k.length]),[b,y]=i.useState(null),[S,A]=i.useState(!1),{data:R}=H(t&&b?[b,t]:null,([E,N])=>X(E,N),{revalidateOnFocus:!1}),z=i.useMemo(()=>Li(R),[R]),U=E=>{const N=E?.class_id?.value??null;N&&(o(V=>({...V,page:1})),d({classId:N}))},j=()=>{u(null),_(""),y(null),A(E=>!E),s.resetFields(),g(!0)},O=E=>{u(E),_(E?.attchement??"");const N=E?.class_id;y(N?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),A(V=>!V),s.setFieldsValue({class_id:h.find(V=>String(V.value)===String(N))??null,sub_id:z.find(V=>String(V.value)===String(E?.sub_id??E?.subject_id))??(E?.sub_id||E?.subject_id?{label:E?.subject_title??"Subject",value:E?.sub_id??E?.subject_id}:null),title:E?.title??"",description:E?.description??""}),g(!0)},M=async E=>{const N=E?.class_id?.value??null,V=E?.sub_id?.value??null,q=E?.title??"",P=E?.description??"";if(!N||!V||!q||!P||!p){w.error("Please fill all fields",{duration:1200});return}const D=new FormData;D.append("class_id",String(N)),D.append("sub_id",String(V)),D.append("title",String(q)),D.append("description",String(P)),D.append("file",String(p));try{f?.id?(D.append("id",String(f.id)),await jt(Ds.edit,D,t),w.success("Success! Updated item.",{duration:1e3})):(await jt(Ds.add,D,t),w.success("Success! Added new item.",{duration:1e3})),g(!1),u(null),I()}catch(L){w.error(L?.response?.data?.msg??L?.message??"Failed to save",{duration:1500})}},$=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",align:"center"},{title:"Description",dataIndex:"description",key:"description",align:"center"},{title:"Subject",dataIndex:"subject_title",key:"subject_title",align:"center"},{title:"File",key:"file",align:"center",render:(E,N)=>{const V=N?.attchement;if(!V)return"-";const q=zy(et(),`uploads/student/note/${V}`);return e.jsx("a",{href:q,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:(E,N)=>e.jsx(n.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>O(N)})}],[z,h]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:f?"Edit Syllabus":"Add Syllabus",open:c,onCancel:()=>{g(!1),u(null),_("")},footer:null,width:820,destroyOnClose:!0,children:e.jsx(n.Form,{form:s,layout:"vertical",onFinish:M,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:E=>E,children:e.jsx(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{const N=E?.value??null;s.setFieldValue("sub_id",null),y(N?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),A(V=>!V)}},`class_${f?.id??"add"}_${S}`)}),e.jsx(n.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:E=>E,children:e.jsx(ee,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${f?.id??"add"}_${S}_${b??"none"}`)}),e.jsx(n.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{label:"Description",name:"description",rules:[{required:!0,message:"Description is required"}],children:e.jsx(wt,{placeholder:"Description"})}),e.jsx(n.Form.Item,{label:"File",required:!0,children:e.jsx(Ho,{token:t,value:p,onChange:_})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(re,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>g(!1),children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Syllabus"}),e.jsx(Bt,{actions:["add","export","print","download","filter"],onAdd:j,onPrint:()=>window.print()})]}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:U,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:E=>E,children:e.jsx(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Syllabus List"}),children:e.jsx(n.Table,{rowKey:E=>E.id,columns:$,dataSource:k,loading:T,pagination:{current:r.page,pageSize:r.perPage,total:C,showSizeChanger:!0,onChange:(E,N)=>o({page:E,perPage:N})}})})]})}function Vy({token:t}){return e.jsx(Yy,{token:t})}const rs=we.timetable,Bi=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},qi=t=>{if(!t)return"";const a=ae(t,"HH:mm:ss");return a.isValid()?a.format("h:mm a"):String(t)},Wy=t=>{const a=String(t).trim().toLowerCase();if(!a)return"default";let s=0;for(let o=0;o<a.length;o+=1)s=(s*31+a.charCodeAt(o))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[s%r.length]},zi=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Hy=t=>{const a=String(t||"");return a?a.charAt(0).toUpperCase()+a.slice(1):"-"};function Ky({token:t}){const[a,s]=i.useState(null),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,g]=i.useState(""),[f,u]=i.useState(""),{data:p}=H(t?[we.master.classes.dropdown,t]:null,([y,S])=>X(y,S)),_=i.useMemo(()=>Bi(p),[p]),{data:v}=H(t&&a?[a,t]:null,([y,S])=>X(y,S)),h=i.useMemo(()=>Bi(v),[v]),{data:m,isLoading:x}=H(t&&l?[l,t]:null,([y,S])=>X(y,S),{revalidateOnFocus:!1}),T=i.useMemo(()=>m?.days??m?.data?.days??m?.data?.data?.days??{},[m]),{dataSource:I,daySpanByFirstKey:k}=i.useMemo(()=>{const y=Object.entries(T||{}).slice().sort((R,z)=>zi.indexOf(String(R[0]).toLowerCase())-zi.indexOf(String(z[0]).toLowerCase())),S=new Map,A=[];for(const[R,z]of y){const U=(Array.isArray(z)?z:[]).slice().sort((O,M)=>Number(O?.order_no||0)-Number(M?.order_no||0)),j=U.length;for(let O=0;O<j;O+=1){const M=U[O],$=M?.id||`${R}-${M?.order_no}-${O}`;O===0&&S.set($,j),A.push({key:$,_dayKey:R,...M})}}return{dataSource:A,daySpanByFirstKey:S}},[T]),C=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(y,S)=>{const A=k.get(S.key);return A===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Z.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(n.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:Hy(y)})]}),props:{rowSpan:A}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:y=>e.jsx(n.Tag,{color:"#5080f8",style:{fontWeight:500},children:y})},{title:"Time",key:"time",width:180,render:(y,S)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Z.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(n.Typography.Text,{children:[qi(S?.time_from)," - ",qi(S?.time_to)]})]})},{title:"Subject",key:"subject",render:(y,S)=>{if(String(S?.is_break)==="1")return e.jsx(n.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const R=S?.subject_name||"-";return e.jsx(n.Tag,{color:Wy(R),style:{fontWeight:500},children:R})}},{title:"Teacher",key:"teacher",render:(y,S)=>{const A=String(S?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Z.UserOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:A?"-":S?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(y,S)=>{const A=String(S?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Z.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:A?"-":S?.room_no||"-"})]})}}],[k]),b=y=>{y.preventDefault();const S=y.target.class_id?.value,A=y.target.section_id?.value;if(!S||!A)return;const R=_.find(O=>String(O.value)===String(S)),z=h.find(O=>String(O.value)===String(A));g(R?.label||""),u(z?.label||"");const j=`${rs.byClassSection}/${S}/section/${A}`;d(j)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Class / Section Wise Timetable"}),extra:e.jsx(Bt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:b,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:y=>{s(`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(y?.value??""))}`),o(S=>!S)}}),e.jsx(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",allowSelectAll:!1,required:!0},`section_${r}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:c||f?`Timetable: ${c} ${f}`:"Timetable"}),children:e.jsx(n.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:I,columns:C,rowKey:"key",loading:x,scroll:{x:"max-content"}})})]})}const Gy=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Yi=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Jy=t=>{const a=String(t||"");return a?a.charAt(0).toUpperCase()+a.slice(1):"-"},Vi=t=>{if(!t)return"";const a=ae(t,"HH:mm:ss");return a.isValid()?a.format("h:mm a"):String(t)},Qy=t=>{const a=String(t).trim().toLowerCase();if(!a)return"default";let s=0;for(let o=0;o<a.length;o+=1)s=(s*31+a.charCodeAt(o))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[s%r.length]};function Xy({token:t}){const[a,s]=i.useState(null),[r,o]=i.useState(null),{data:l}=H(t?[we.assignByClass.teacherDropdown,t]:null,([v,h])=>X(v,h)),d=i.useMemo(()=>Gy(l),[l]),{data:c,isLoading:g}=H(t&&r?[r,t]:null,([v,h])=>X(v,h),{revalidateOnFocus:!1}),{dataSource:f,daySpanByFirstKey:u}=i.useMemo(()=>{const h=(Array.isArray(c?.data)&&c.data||Array.isArray(c?.data?.data)&&c.data.data||[]).slice().sort((I,k)=>{const C=Yi.indexOf(String(I?.day_name||"").toLowerCase()),b=Yi.indexOf(String(k?.day_name||"").toLowerCase());if(C!==b)return C-b;const y=Number(I?.order_no||0),S=Number(k?.order_no||0);return y!==S?y-S:String(I?.time_from||"").localeCompare(String(k?.time_from||""))}),m=new Map,x=[];let T=0;for(;T<h.length;){const I=String(h[T]?.day_name||"").toLowerCase();let k=T;for(;k<h.length&&String(h[k]?.day_name||"").toLowerCase()===I;)k+=1;const C=k-T;for(let b=T;b<k;b+=1){const y=h[b],S=y?.id||`${I}-${y?.order_no}-${b}`;b===T&&m.set(S,C),x.push({key:S,_dayKey:I,...y})}T=k}return{dataSource:x,daySpanByFirstKey:m}},[c]),p=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(v,h)=>{const m=u.get(h.key);return m===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Z.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(n.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:Jy(v)})]}),props:{rowSpan:m}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:v=>e.jsx(n.Tag,{color:"#5080f8",style:{fontWeight:500},children:v})},{title:"Time",key:"time",width:180,render:(v,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Z.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(n.Typography.Text,{children:[Vi(h?.time_from)," - ",Vi(h?.time_to)]})]})},{title:"Subject",key:"subject",render:(v,h)=>{if(String(h?.is_break)==="1")return e.jsx(n.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const x=h?.subject_name||"-";return e.jsx(n.Tag,{color:Qy(x),style:{fontWeight:500},children:x})}},{title:"Class",key:"class",width:160,render:(v,h)=>e.jsxs(n.Tag,{color:"purple",style:{fontWeight:500},children:[h?.class_name||h?.class_id||"-"," ",h?.section_name?`(${h.section_name})`:""]})},{title:"Room",key:"room_no",width:120,render:(v,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Z.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:h?.room_no||"-"})]})}],[u]),_=v=>{v.preventDefault();const h=v.target.teacher_id?.value;if(!h)return;s(h);const x=`${rs.teacherTimetable}${encodeURIComponent(String(h))}`;o(x)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Teacher Wise Timetable"}),extra:e.jsx(Bt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:_,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:d,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teacher",name:"teacher_id",allowSelectAll:!1,required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Timetable"}),children:e.jsx(n.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:f,columns:p,rowKey:"key",loading:g,scroll:{x:"max-content"}})})]})}function Wi(t){if(!t)return null;const a=String(t).trim().replaceAll(".",":");if(!a)return null;const s=a.toLowerCase(),r=s.includes("am")||s.includes("pm");let o=0,l=0,d=0;if(r){const g=s.replace(/\s+/g," ").match(/^(\d{1,2})\s*:\s*(\d{1,2})(?:\s*:\s*(\d{1,2}))?\s*(am|pm)$/i);if(!g)return null;o=Number.parseInt(g[1],10),l=Number.parseInt(g[2],10),d=Number.parseInt(g[3]||"0",10);const f=g[4].toLowerCase();f==="pm"&&o<12&&(o+=12),f==="am"&&o===12&&(o=0)}else{const c=a.split(":").map(g=>g.trim());if(c.length<2)return null;o=Number.parseInt(c[0],10),l=Number.parseInt(c[1],10),d=Number.parseInt(c[2]||"0",10)}return![o,l,d].every(c=>Number.isFinite(c))||o<0||o>23||l<0||l>59||d<0||d>59?null:ae().hour(o).minute(l).second(d).millisecond(0)}function Fa(t,a){const s=Number.parseInt(a,10);return!Number.isFinite(s)||s<=0||!t||!t.isValid?.()?null:t.add(s,"minute")}const Bn=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Ba={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},Zy=t=>{const a=Ba[String(t)];return a?a.charAt(0).toUpperCase()+a.slice(1):String(t)},eh=({token:t,classId:a,sectionId:s,subjectId:r,value:o,onChange:l,disabled:d})=>{const c=t&&a&&s&&r?`${rs.teachersBySubject}?subject_id=${encodeURIComponent(String(r))}&class_id=${encodeURIComponent(String(a))}&section_id=${encodeURIComponent(String(s))}`:null,{data:g,isLoading:f}=H(c?[c,t]:null,([p,_])=>X(p,_),{revalidateOnFocus:!1}),u=i.useMemo(()=>Bn(g?.data??g).map(_=>({value:_?.value??_?.id,label:_?.label??_?.name??_?.teacher_name??""})),[g]);return e.jsx(n.Select,{placeholder:d?"-":"Select Teacher",loading:f,disabled:d,style:{width:"100%"},options:u,value:o?String(o):void 0,onChange:p=>l?.(p),showSearch:!0,optionFilterProp:"label"})};function th({token:t}){const[a]=n.Form.useForm(),[s,r]=i.useState({classId:null,sectionId:null,dayKey:"1",daysEnabled:{0:!1,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0}}),[o,l]=i.useState({startTime:null,endTime:null,duration:40,interval:0,roomNo:"",tiffinEnabled:!1,tiffinAfterPeriod:3,tiffinDuration:20}),[d,c]=i.useState({0:[],1:[],2:[],3:[],4:[],5:[],6:[]}),[g,f]=i.useState(!1),u=i.useMemo(()=>t?we.master.classes.dropdown:null,[t]),{data:p}=H(u?[u,t]:null,([j,O])=>X(j,O)),_=i.useMemo(()=>Bn(p).map(j=>({value:j?.value??j?.id,label:j?.label??j?.title??""})),[p]),v=i.useMemo(()=>!t||!s.classId?null:`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(s.classId))}`,[s.classId,t]),{data:h}=H(v?[v,t]:null,([j,O])=>X(j,O)),m=i.useMemo(()=>Bn(h).map(j=>({value:j?.value??j?.id,label:j?.label??j?.title??""})),[h]),x=i.useMemo(()=>!t||!s.classId?null:`${we.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(s.classId))}`,[s.classId,t]),{data:T}=H(x?[x,t]:null,([j,O])=>X(j,O)),I=i.useMemo(()=>Bn(T).map(j=>({value:j?.value??j?.id,label:j?.label??j?.title??""})),[T]),k=i.useMemo(()=>Array.isArray(d?.[s.dayKey])?d[s.dayKey]:[],[s.dayKey,d]),C=i.useCallback((j,O,M)=>{c($=>{const E={...$},N=Array.isArray(E[j])?E[j].slice():[];return N[O]={...N[O]??{},...M},E[j]=N,E})},[]),b=i.useCallback((j,O)=>{c(M=>{const $={...M},E=Array.isArray($[j])?$[j].slice():[];return E.splice(O,1),$[j]=E.map((N,V)=>({...N,order_no:V+1})),$})},[]),y=i.useCallback(j=>{c(O=>{const M={...O},$=Array.isArray(M[j])?M[j].slice():[];let E=null,N=null;const V=$[$.length-1];if(V?.time_to){const q=Wi(V.time_to),P=Number.parseInt(o.interval,10)||0,D=Number.parseInt(o.duration,10)||0,L=Fa(q,P),B=D>0?Fa(L,D):null;E=L?.isValid?.()?L.format("HH:mm:ss"):null,N=B?.isValid?.()?B.format("HH:mm:ss"):null}return $.push({order_no:$.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:E,time_to:N,is_break:!1}),M[j]=$,M})},[o.duration,o.interval,o.roomNo]),S=i.useCallback(()=>{const j=o.startTime,O=o.endTime,M=Number.parseInt(o.duration,10),$=Number.parseInt(o.interval,10);if(!j||!j.isValid?.()){w.error("Start time is required",{duration:1500});return}if(!O||!O.isValid?.()){w.error("End time is required",{duration:1500});return}if(!O.isAfter(j)){w.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(M)||M<=0){w.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite($)||$<0){w.error("Interval must be 0 or more",{duration:1500});return}const E=()=>{const N=[];let V=j;for(let q=0;q<50;q+=1){const P=Fa(V,M);if(!P||!P.isValid?.()||P.isAfter(O))break;N.push({order_no:N.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:V.format("HH:mm:ss"),time_to:P.format("HH:mm:ss"),is_break:!1});const D=Fa(P,$);if(!D||!D.isValid?.()||D.isAfter(O)||D.isSame(O))break;V=D}if(o.tiffinEnabled){const q=Math.max(0,Number.parseInt(o.tiffinAfterPeriod,10)||0),P=Math.max(0,Number.parseInt(o.tiffinDuration,10)||0),D=Math.min(q,N.length);if(D>0&&P>0){const L=N[D-1],B=L?.time_to?Wi(L.time_to):null,W=B?Fa(B,P):null;B?.isValid?.()&&W?.isValid?.()&&!W.isAfter(O)&&N.splice(D,0,{order_no:D+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:B.format("HH:mm:ss"),time_to:W.format("HH:mm:ss"),is_break:!0})}}return N.map((q,P)=>({...q,order_no:P+1}))};c(N=>{const V={...N};return Object.keys(Ba).forEach(q=>{s.daysEnabled?.[q]&&(V[q]=E())}),V}),w.success("Generated schedule",{duration:1e3})},[o,s.daysEnabled]),A=i.useCallback(()=>{const j=localStorage.getItem("genrall_settings"),M=(j?JSON.parse(j):{})?.session_id??"1",$=s.classId,E=s.sectionId,N=Object.keys(Ba).map(V=>{const q=(Array.isArray(d?.[V])?d[V]:[]).map((P,D)=>({order_no:D+1,subject_id:P?.is_break?0:P?.subject_id??null,teacher_id:P?.is_break?0:P?.teacher_id??null,room_no:P?.room_no??"",time_from:P?.time_from??null,time_to:P?.time_to??null,is_break:P?.is_break?1:0}));return{day:Ba[V],class_id:$,section_id:E,session_id:M,args:q}});return{class_id:$,section_id:E,session_id:M,days:N}},[s.classId,s.sectionId,d]),R=i.useCallback(async()=>{if(!s.classId||!s.sectionId){w.error("Please select Class and Section",{duration:1500});return}const j=A(),O=Array.isArray(j?.days)?j.days:[];if(!O.some(E=>Array.isArray(E?.args)&&E.args.length>0)){w.error("No timetable rows to submit",{duration:1500});return}const $=E=>{const N=E?.is_break;return N===1||N==="1"||N===!0?!0:String(N??"").toLowerCase()==="true"};O.some(E=>(Array.isArray(E?.args)?E.args:[]).some(N=>String(N?.time_from??"").trim()&&String(N?.time_to??"").trim()?$(N)?!1:!String(N?.subject_id??"").trim()||!String(N?.teacher_id??"").trim():!0)),f(!0);try{const E=rs.save,N=E==="api/timetable/save"?"timetable/save":null,V=async D=>{const L=await Xn(D,j,t);if(L&&typeof L=="object")return L;throw new Error("No response from server")};let q;try{q=await V(E)}catch{q=await V(N)}const P=String(q?.msg??"");if(String(q?.Status)==="Success"){if(Array.isArray(q?.data)&&q.data.length===0&&P){w.error(P,{duration:3e3});return}w.success(P||"Weekly Time Table added successfully!",{duration:1200});return}w.error(P||"Failed to add time table",{duration:3e3})}catch(E){w.error(E?.response?.data?.msg??E?.message??"Failed to add time table",{duration:3e3})}finally{f(!1)}},[A,s.classId,s.sectionId,t]),z=i.useMemo(()=>[{title:"Period",dataIndex:"order_no",key:"order_no",width:80},{title:"Time From",dataIndex:"time_from",key:"time_from",width:120,render:j=>j?ae(j,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:j=>j?ae(j,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(j,O,M)=>e.jsx(n.Switch,{checked:!!O?.is_break,onChange:$=>{C(s.dayKey,M,{is_break:$,subject_id:$?"":O?.subject_id??"",teacher_id:$?"":O?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(j,O,M)=>e.jsx(n.Select,{placeholder:O?.is_break?"-":"Select Subject",disabled:!!O?.is_break,style:{width:"100%"},options:I,value:O?.subject_id?String(O.subject_id):void 0,onChange:$=>C(s.dayKey,M,{subject_id:$,teacher_id:""}),showSearch:!0,optionFilterProp:"label"})},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(j,O,M)=>e.jsx(eh,{token:t,classId:s.classId,sectionId:s.sectionId,subjectId:O?.subject_id,disabled:!!O?.is_break||!O?.subject_id,value:O?.teacher_id,onChange:$=>C(s.dayKey,M,{teacher_id:$})})},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(j,O,M)=>e.jsx(n.Input,{value:O?.room_no??"",onChange:$=>C(s.dayKey,M,{room_no:$.target.value})})},{title:"Action",key:"action",width:90,render:(j,O,M)=>e.jsx(n.Popconfirm,{title:"Delete this row?",onConfirm:()=>b(s.dayKey,M),children:e.jsx(n.Button,{danger:!0,type:"text",children:"Delete"})})}],[s.classId,s.dayKey,s.sectionId,b,I,t,C]),U=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Create Time Table"}),children:e.jsx(n.Form,{form:a,layout:"vertical",initialValues:{duration:o.duration,interval:o.interval,roomNo:o.roomNo,tiffinEnabled:o.tiffinEnabled,tiffinAfterPeriod:o.tiffinAfterPeriod,tiffinDuration:o.tiffinDuration},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",required:!0,children:e.jsx(n.Select,{placeholder:"Select Class",options:_,value:s.classId?String(s.classId):void 0,onChange:j=>{r(O=>({...O,classId:j,sectionId:null})),c({0:[],1:[],2:[],3:[],4:[],5:[],6:[]})},showSearch:!0,optionFilterProp:"label"})}),e.jsx(n.Form.Item,{label:"Section",required:!0,children:e.jsx(n.Select,{placeholder:"Select Section",options:m,value:s.sectionId?String(s.sectionId):void 0,onChange:j=>r(O=>({...O,sectionId:j})),disabled:!s.classId,showSearch:!0,optionFilterProp:"label"})}),e.jsx(n.Form.Item,{label:"Start Time",required:!0,children:e.jsx(n.TimePicker,{value:o.startTime,onChange:j=>l(O=>({...O,startTime:j})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"End Time",required:!0,children:e.jsx(n.TimePicker,{value:o.endTime,onChange:j=>l(O=>({...O,endTime:j})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Duration (min)",required:!0,children:e.jsx(n.InputNumber,{min:1,value:o.duration,onChange:j=>l(O=>({...O,duration:j})),style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Interval (min)",children:e.jsx(n.InputNumber,{min:0,value:o.interval,onChange:j=>l(O=>({...O,interval:j})),style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Room No",children:e.jsx(n.Input,{value:o.roomNo,onChange:j=>l(O=>({...O,roomNo:j.target.value}))})}),e.jsx(n.Form.Item,{label:"Tiffin Break",children:e.jsxs(n.Space,{children:[e.jsx(n.Switch,{checked:o.tiffinEnabled,onChange:j=>l(O=>({...O,tiffinEnabled:j}))}),e.jsx(n.Typography.Text,{type:"secondary",children:o.tiffinEnabled?"Enabled":"Disabled"})]})}),e.jsx(n.Form.Item,{label:"After Period",tooltip:"Insert break row after this period",style:{marginBottom:0},children:e.jsx(n.InputNumber,{min:1,value:o.tiffinAfterPeriod,onChange:j=>l(O=>({...O,tiffinAfterPeriod:j})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsx(n.Form.Item,{label:"Break Duration (min)",style:{marginBottom:0},children:e.jsx(n.InputNumber,{min:1,value:o.tiffinDuration,onChange:j=>l(O=>({...O,tiffinDuration:j})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(n.Button,{onClick:S,children:"Generate"}),e.jsx(n.Button,{type:"primary",loading:g,onClick:R,children:"Save"})]})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Edit Week"}),extra:e.jsxs(n.Space,{children:[e.jsx(n.Typography.Text,{type:"secondary",children:"Day"}),e.jsx(n.Select,{style:{width:160},value:s.dayKey,onChange:j=>r(O=>({...O,dayKey:j})),options:Object.keys(Ba).map(j=>({value:String(j),label:Zy(j)}))}),e.jsx(n.Button,{onClick:()=>y(s.dayKey),children:"Add Row"})]}),children:e.jsx(n.Table,{rowKey:(j,O)=>`${s.dayKey}_${O}`,columns:z,dataSource:k,pagination:!1,size:"middle",scroll:{x:"max-content"}})})]});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Typography.Title,{level:4,style:{margin:0},children:"Time Table"}),e.jsx(n.Tabs,{type:"card",items:[{key:"create",label:"Create",children:U},{key:"routine",label:"Routine",children:e.jsx(Ky,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(Xy,{token:t})}]})]})}function ah({token:t}){return e.jsx(th,{token:t})}function nh(){return null}const Qt=t=>t??localStorage.getItem("authToken")??"",sr=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},pt={organization:{get:"api/branchapi/generalSettings/getorganizationsettingsData",save:"api/branchapi/generalSettings/addorganizationSetting",currencyDropdown:"api/branchapi/generalSettings/currencyDropdown",countryCodeDropdown:"api/branchapi/generalSettings/contrycodeDropdown",timezoneDropdown:"api/branchapi/generalSettings/timezoneDropdown",boardsDropdown:"api/branchapi/generalSettings/getAffliatedBoardsDropDown",uploadLogo:"api/superAdmin/upload_logo",uploadSignature:"api/branchapi/generalSettings/upload_signature",uploadFirebaseJson:"api/branchapi/generalSettings/firebaseJsonUpload"},academicYear:{table:"api/branchapi/generalSettings/sessiontable",add:"api/branchapi/generalSettings/addsession",setActive:"api/branchapi/generalSettings/setsession",remove:"api/branchapi/generalSettings/deletesession"},feeReceiptSetting:{get:"api/branchapi/generalSettings/feesReceiptSettingData",save:"api/branchapi/generalSettings/feesReceiptSetting"},marksheetSetting:{templateTypes:"api/branchapi/GeneralSettings/getmarkssheetTemplate",classDropdown:"api/exam/exam/getClassforAssignMarksSheetType",assignedTable:"api/branchapi/GeneralSettings/getassign_templete",assign:"api/branchapi/GeneralSettings/assign_templete",remove:"api/branchapi/GeneralSettings/deleteTemplate"},legalPages:{get:"api/branchapi/generalSettings/getlegalpage",termsSave:"api/branchapi/generalSettings/terms",privacySave:"api/branchapi/generalSettings/privacy",aboutSave:"api/branchapi/generalSettings/about_us"},feesInfo:{get:"api/branchapi/generalSettings/getFeesInfo",save:"api/branchapi/generalSettings/addFeesInfo",statesDropdown:"api/superAdmin/states"},payrollSettings:{table:"api/branchapi/GeneralSettings/getsetting_allowances_dedection",add:"api/branchapi/GeneralSettings/addsetting_allowances_dedection",edit:"api/branchapi/GeneralSettings/updatesetting_allowances_dedection",remove:"api/branchapi/GeneralSettings/deletesetting_allowances_dedection",byId:"api/branchapi/GeneralSettings/getsetting_allowances_dedectionById"},paymentGateway:{get:"api/payment_gateway/PaymentProcess/getPaymentGatewayList",save:"api/payment_gateway/PaymentProcess"}},rr=t=>sr(et(),t),sh=()=>sr(et(),"uploads"),Ko=t=>sr(sh(),t),rh=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return X(l,Qt(r))},ih=async(t,a)=>X(t,Qt(a)),an=async(t,a,s)=>$e(t,a,Qt(s)),Go=async(t,a,s)=>Xe(t,a,Qt(s)),ir=async(t,a,s)=>Ye(t,a,Qt(s)),oh=async(t,a,s)=>Xn(t,{arg:a},Qt(s)),Jo=async(t,a,s)=>qa(t,{arg:a},Qt(s)),Qo=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>H(r&&t?[t,a,s,r]:null,([l,d,c,g])=>rh({baseUrl:l,page:d,perPage:c},g)),ft=({url:t,token:a})=>H(a&&t?[t,a]:null,([r,o])=>ih(r,o)),lh={border:"1px solid #d9d9d9",borderRadius:8,padding:12,minHeight:320,background:"#fff"};function dh({value:t,onChange:a,placeholder:s}){const[r,o]=i.useState(t??""),l=i.useMemo(()=>typeof t=="string"?t:r,[r,t]);return e.jsx("div",{style:lh,children:e.jsx(Ro,{html:l||"",onChange:d=>{const c=d?.target?.value??"";o(c),a?.(c)},style:{outline:"none",minHeight:280},placeholder:s})})}function qt({title:t,actions:a,children:s,headerExtra:r}){return e.jsx("div",{style:{display:"grid",gap:20},children:s})}const ch=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function or({token:t,title:a,fetchUrl:s,saveUrl:r,fieldName:o,initialHtmlFieldName:l}){const d=i.useRef(null),c=ft({url:s,token:t}),f=i.useMemo(()=>ch(c.data),[c.data])?.[l??o]??"",[u,p]=i.useState("");i.useEffect(()=>{p(typeof f=="string"?f:"")},[f]);const _=()=>p(typeof f=="string"?f:""),v=()=>{const x=new Blob([String(u??"")],{type:"text/html"}),T=URL.createObjectURL(x),I=document.createElement("a");I.href=T,I.download=`${String(a??"legal").toLowerCase().replaceAll(" ","-")}.html`,I.click(),URL.revokeObjectURL(T)},h=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(Z.SyncOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:_},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:v,disabled:!u}],[u,f]),m=async x=>{x.preventDefault();try{(await Jo(r,{[o]:u??""},t))?.Status==="Success"?w.success("Updated successfully.",{duration:1e3}):w.success("Updated.",{duration:1e3}),c.mutate?.()}catch(T){w.error(T?.response?.data?.msg??T?.message??"Failed to update.",{duration:1500})}};return c.isLoading&&!c.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(qt,{title:a,actions:h,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Editor"}),children:e.jsxs("form",{ref:d,onSubmit:m,children:[e.jsx(dh,{value:u,onChange:p,placeholder:`Enter ${a} content...`}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Update"})})]})})})]})}const uh=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ph=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:");function fa({token:t,value:a,onChange:s,action:r,accept:o,maxCount:l=1,previewUrl:d}){const c=i.useMemo(()=>{if(t)return{Authorization:t}},[t]),g=i.useMemo(()=>a?d||(ph(a)?a:""):"",[d,a]);return e.jsxs("div",{style:{display:"grid",gap:8},children:[g?e.jsx("img",{src:g,alt:"upload-preview",style:{width:88,height:88,objectFit:"cover",borderRadius:8,border:"1px solid #d9d9d9",background:"#fafafa"}}):null,e.jsx(n.Upload,{maxCount:l,action:r,accept:o,headers:c,onChange:f=>{if(f?.file?.status==="removed"&&s?.(""),f?.file?.status==="done"){const u=uh(f?.file?.response);u&&s?.(u)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})]})}const kt=pt.organization,Xo=()=>rr(kt.uploadLogo),Is=()=>rr(kt.uploadSignature),mh=()=>rr(kt.uploadFirebaseJson),fh=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],yh=({token:t})=>ft({url:kt.get,token:t}),hh=({token:t})=>ft({url:kt.currencyDropdown,token:t}),gh=({token:t})=>ft({url:kt.countryCodeDropdown,token:t}),xh=({token:t})=>ft({url:kt.timezoneDropdown,token:t}),bh=({token:t})=>ft({url:kt.boardsDropdown,token:t}),An=t=>fh(t?.data),Hi={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},jh=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].map(t=>({value:t,label:t})),Ki=[{value:"Yes",label:"Yes"},{value:"No",label:"No"}],Gi=[{value:"yes",label:"Yes"},{value:"no",label:"No"}],Sh=t=>{const a=t?.data;return Array.isArray(a?.data)?a.data[0]??null:Array.isArray(a)?a[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null},vh=t=>t?.data?.inout_setting?.[0]??t?.inout_setting?.[0]??null,_h=t=>t?.data?.notification_settings?.[0]??t?.notification_settings?.[0]??null;function wh({token:t}){const a=i.useRef(null),s=yh({token:t}),r=hh({token:t}),o=gh({token:t}),l=xh({token:t}),d=bh({token:t}),c=i.useMemo(()=>Sh(s.data),[s.data]),g=i.useMemo(()=>vh(s.data),[s.data]),f=i.useMemo(()=>_h(s.data),[s.data]),u=i.useMemo(()=>An(r),[r.data]),p=i.useMemo(()=>An(o),[o.data]),_=i.useMemo(()=>An(l),[l.data]),v=i.useMemo(()=>An(d),[d.data]),[h,m]=i.useState(null),[x,T]=i.useState(null),[I,k]=i.useState(null),[C,b]=i.useState(null),[y,S]=i.useState([]),[A,R]=i.useState("No"),[z,U]=i.useState("yes"),[j,O]=i.useState("no"),[M,$]=i.useState("Yes"),[E,N]=i.useState(""),[V,q]=i.useState(""),[P,D]=i.useState(null),[L,B]=i.useState(null),[W,se]=i.useState(null),[Q,K]=i.useState(null),te=()=>{const G=(()=>{try{const de=c?.weekly_off;if(!de)return[];const Ae=Array.isArray(de)?de:JSON.parse(de);return Array.isArray(Ae)?Ae.filter(Boolean).map(Ee=>({value:Ee,label:Ee})):[]}catch{return[]}})();S(G),m(u.find(de=>de?.value===c?.currency)??null),T(p.find(de=>de?.value===c?.country_code)??null),k(_.find(de=>de?.value===c?.time_zone)??null),b(v.find(de=>de?.value===c?.affliated_board_id)??null),N(c?.logo??""),q(c?.json_file??""),R(c?.attendance_salary_calculation??"No"),U(c?.salary_period??"yes"),O(c?.multiple_shift??"no"),$(c?.readmission_charges??"Yes"),D(g?.in_from?ae(g.in_from,"h:mm A"):null),B(g?.in_to?ae(g.in_to,"h:mm A"):null),se(g?.out_from?ae(g.out_from,"h:mm A"):null),K(g?.out_to?ae(g.out_to,"h:mm A"):null)};i.useEffect(()=>{c&&te()},[c,u,p,_,v]);const ie=()=>{a.current?.reset?.(),te()},pe=()=>{const G=new FormData(a.current??void 0),de=Object.fromEntries(G.entries());de.weekly_off_day=y.map(ze=>ze?.value).filter(Boolean);const Ae=new Blob([JSON.stringify(de,null,2)],{type:"application/json"}),Ee=URL.createObjectURL(Ae),Pe=document.createElement("a");Pe.href=Ee,Pe.download="organization-setting.json",Pe.click(),URL.revokeObjectURL(Ee)},_e=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(Z.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:ie},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:pe,disabled:!c}],[c,y]),oe=async G=>{G.preventDefault();try{const de=new FormData(G.target);de.set("currency",h?.value??""),de.set("code",x?.value??""),de.set("time_zone",I?.value??""),de.set("affliated_board_id",C?.value??""),de.set("board_name",C?.label??""),de.set("attendance_salary_calculation",A),de.set("salary_period",z),de.set("multiple_shift",j),de.set("readmission_charges",M),y.forEach(Pe=>{Pe?.value&&de.append("weekly_off_day[]",Pe.value)}),de.set("logo",E??""),de.set("json_file",V??""),de.set("server_key",f?.server_key??""),de.set("in_time_start",P?ae(P).format("h:mm A"):""),de.set("in_time_end",L?ae(L).format("h:mm A"):""),de.set("out_time_start",W?ae(W).format("h:mm A"):""),de.set("out_time_end",Q?ae(Q).format("h:mm A"):""),await an(kt.save,de,t);const Ee={...JSON.parse(localStorage.getItem("genrall_settings")??"null")??{},logo:E||c?.logo||"",affliated_board_id:C?.value??c?.affliated_board_id??"",board_name:C?.label??c?.board_name??"",multiple_shift:j??c?.multiple_shift??""};localStorage.setItem("genrall_settings",JSON.stringify(Ee)),w.success("Organization settings saved.",{duration:1e3}),s.mutate?.()}catch(de){w.error(de?.response?.data?.msg??de?.message??"Failed to save settings.",{duration:1500})}},le=A==="Yes";return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(qt,{title:"Organization",actions:_e,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Organization Details"}),children:e.jsxs("form",{ref:a,onSubmit:oe,children:[e.jsxs("div",{style:Hi,children:[e.jsx(Y,{type:"text",name:"name",label:"Organization Name*",required:!0,defaultValue:c?.name??""}),e.jsxs("div",{children:[e.jsx(ee,{label:"Currency*",options:u,value:h,onChange:G=>m(G)}),e.jsx("input",{type:"hidden",name:"currency",value:h?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Default Country Code*",options:p,value:x,onChange:G=>T(G)}),e.jsx("input",{type:"hidden",name:"code",value:x?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Time Zone*",options:_,value:I,onChange:G=>k(G)}),e.jsx("input",{type:"hidden",name:"time_zone",value:I?.value??""})]}),e.jsx(Y,{type:"text",name:"admission_prefix",label:"Receipt Prefix*",required:!0,defaultValue:c?.admission_prefix??""}),e.jsx(Y,{type:"number",name:"admission_start_number",label:"Admission Start Number*",required:!0,defaultValue:c?.admission_no_prefix??c?.admission_start_number??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Re-admission Charges"}),e.jsx(n.Radio.Group,{options:Ki,optionType:"button",buttonStyle:"solid",value:M,onChange:G=>$(G.target.value)}),e.jsx("input",{type:"hidden",name:"readmission_charges",value:M})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Weekly off Day",options:jh,isMulti:!0,value:y,onChange:G=>S(G??[])}),y.map(G=>e.jsx("input",{type:"hidden",name:"weekly_off_day[]",value:G.value},G.value))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time Start*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:P,onChange:G=>D(G),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_start",value:P?ae(P).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time End*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:L,onChange:G=>B(G),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_end",value:L?ae(L).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time Start*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:W,onChange:G=>se(G),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_start",value:W?ae(W).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time End*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:Q,onChange:G=>K(G),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_end",value:Q?ae(Q).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Period"}),e.jsx(n.Radio.Group,{options:Gi,optionType:"button",buttonStyle:"solid",value:z,onChange:G=>U(G.target.value)}),e.jsx("input",{type:"hidden",name:"salary_period",value:z})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Deduction"}),e.jsx(n.Radio.Group,{options:Ki,optionType:"button",buttonStyle:"solid",value:A,onChange:G=>R(G.target.value)}),e.jsx("input",{type:"hidden",name:"attendance_salary_calculation",value:A})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Multiple Shift"}),e.jsx(n.Radio.Group,{options:Gi,optionType:"button",buttonStyle:"solid",value:j,onChange:G=>O(G.target.value)}),e.jsx("input",{type:"hidden",name:"multiple_shift",value:j})]}),le?e.jsx(Y,{type:"number",name:"late_absent_day",label:"No of Late",defaultValue:c?.late_absent_day??""}):e.jsx("input",{type:"hidden",name:"late_absent_day",value:""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Hi,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Logo Upload"}),e.jsx(fa,{token:t,action:Xo(),value:E,accept:"image/*",onChange:G=>N(G)}),e.jsx("input",{type:"hidden",name:"logo",value:E??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Select Affiliated Board",options:v,value:C,onChange:G=>b(G)}),e.jsx("input",{type:"hidden",name:"affliated_board_id",value:C?.value??""}),e.jsx("input",{type:"hidden",name:"board_name",value:C?.label??""})]}),e.jsx(wt,{label:"Address",name:"address",rows:3,defaultValue:c?.location_name??c?.address??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Json for Notification"}),e.jsx(fa,{token:t,action:mh(),value:V,accept:".json",onChange:G=>q(G)}),e.jsx("input",{type:"hidden",name:"json_file",value:V??""})]})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Save",color:"primary"})})]})})})]})}function Ch({token:t}){return e.jsx(wh,{token:t})}const qn=pt.academicYear,Ah=({token:t,page:a=1,perPage:s=10})=>Qo({baseUrl:qn.table,token:t,page:a,perPage:s}),Th={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Rh=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[],Dh=(t,a=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??a;function Ih({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(()=>{const y=ae(),S=ae().add(1,"year");return`${y.format("YYYY")}-${S.format("YYYY")}`}),[c,g]=i.useState(ae()),[f,u]=i.useState(ae().add(1,"year")),{isLoading:p,data:_,mutate:v}=Ah({token:t,page:a.page,perPage:a.rowsPerPage}),h=i.useMemo(()=>Rh(_),[_]),m=i.useMemo(()=>Dh(_,h.length),[_,h.length]),x=async()=>{if(!l){w.error("Session name is required.");return}if(f&&c&&ae(f).isBefore(c)){w.error("End date must be after start date.");return}try{const y=new FormData;y.set("name",l),y.set("start_date",c?ae(c).format("YYYY-MM-DD"):""),y.set("end_date",f?ae(f).format("YYYY-MM-DD"):""),await an(qn.add,y,t),w.success("Academic year added.",{duration:1e3}),o(!1),v?.()}catch(y){w.error(y?.response?.data?.msg??y?.message??"Failed to add academic year.",{duration:1500})}},T=async y=>{try{const S=new FormData;S.set("session",String(y)),await Go(qn.setActive,S,t);const A=JSON.parse(localStorage.getItem("genrall_settings")??"null")??{};localStorage.setItem("genrall_settings",JSON.stringify({...A,session_id:String(y)})),w.success("Academic year activated.",{duration:1e3}),v?.()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to activate academic year.",{duration:1500})}},I=async y=>{try{await v(ir(qn.remove,y,t)),w.success("Academic year deleted.",{duration:1e3})}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to delete academic year.",{duration:1500})}},k=()=>{const y=new Blob([JSON.stringify(h,null,2)],{type:"application/json"}),S=URL.createObjectURL(y),A=document.createElement("a");A.href=S,A.download="academic-years.json",A.click(),URL.revokeObjectURL(S)},C=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(Z.PlusOutlined,{}),onClick:()=>o(!0)},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:()=>v?.()},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:k,disabled:h.length===0}],[h.length,v]),b=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name"},{title:"Start Date",dataIndex:"start_date",key:"start_date"},{title:"End Date",dataIndex:"end_date",key:"end_date"},{title:"Active",key:"active",render:(y,S)=>{const A=S.status==="Active";return e.jsxs("span",{children:[e.jsx(n.Popconfirm,{title:A?"Deactivate Academic Year?":"Activate Academic Year?",description:A?"Deactivate is not allowed. Activate another session to switch.":"This will set this year as the current academic session.",onConfirm:()=>{A?w.error("Deactivate is not allowed. Activate another session to switch."):T(S.id)},okText:"Yes",cancelText:"No",children:e.jsx(n.Switch,{checked:A})}),A&&e.jsx(n.Tag,{color:"green",style:{marginLeft:8},children:"Active"})]})}},{title:"Action",key:"action",render:(y,S)=>e.jsx(n.Popconfirm,{title:"Delete academic year?",description:"This will remove the session.",onConfirm:()=>I(S.id),okText:"Yes",cancelText:"No",children:e.jsx(n.Button,{type:"link",danger:!0,children:"Delete"})})}],[t,h.length]);return e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(qt,{title:"Academic Year",actions:C,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Sessions"}),children:e.jsx(n.Table,{rowKey:"id",dataSource:h,columns:b,loading:p,pagination:{current:a.page,pageSize:a.rowsPerPage,total:m,showSizeChanger:!0,onChange:(y,S)=>s({page:y,rowsPerPage:Number(S)})}})})}),e.jsx(n.Modal,{open:r,onCancel:()=>o(!1),footer:null,title:"Add Academic Year",children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:Th,children:[e.jsx(Y,{label:"Session Name*",value:l,onChange:y=>d(y.target.value)}),e.jsxs("div",{children:[e.jsx(Le,{Desplay:"Start Date*",value:c,onChange:y=>g(y),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:c?ae(c).format("YYYY-MM-DD"):""})]}),e.jsxs("div",{children:[e.jsx(Le,{Desplay:"End Date*",value:f,onChange:y=>u(y),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:f?ae(f).format("YYYY-MM-DD"):""})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(re,{value:"Submit",type:"button",onClick:x}),e.jsx(n.Button,{onClick:()=>o(!1),children:"Cancel"})]})]})})]})}function kh({token:t}){return e.jsx(Ih,{token:t})}const Zo=pt.feeReceiptSetting,Ph=({token:t})=>ft({url:Zo.get,token:t}),ks={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:16,alignItems:"start"},Oh=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function Mh({token:t}){const a=i.useRef(null),s=Ph({token:t}),r=i.useMemo(()=>Oh(s.data),[s.data]),[o,l]=i.useState(""),[d,c]=i.useState(!1),[g,f]=i.useState(!1),[u,p]=i.useState(!1),[_,v]=i.useState("0"),[h,m]=i.useState("0"),[x,T]=i.useState("0"),[I,k]=i.useState(!1),[C,b]=i.useState(!1),[y,S]=i.useState(""),[A,R]=i.useState(!1),z=()=>{l(r?.number_of_receipt??""),c(String(r?.roll_number??"0")==="1"),f(String(r?.address??"0")==="1"),p(String(r?.gardian_name??"0")==="1"),v(String(r?.authorized_signatory??"0")),m(String(r?.parent_signatory??"0")),T(String(r?.dynamic_qr_code_device??"0")),k(String(r?.sequence_payment??"0")==="1"),b(String(r?.previois_fees??"0")==="1"),S(r?.upfront_payment_months??"")};i.useEffect(()=>{r&&z()},[r]);const U=()=>{a.current?.reset?.(),z()},j=()=>{const $={number_of_receipt:o,rollnumber:d?1:0,address:g?1:0,gardianname:u?1:0,authorizedsignatory:_,parentsignatory:h,dynamic_qr_code_device:x,sequence_payment:I?1:0,previois_fees:C?1:0,upfront_payment_months:y},E=new Blob([JSON.stringify($,null,2)],{type:"application/json"}),N=URL.createObjectURL(E),V=document.createElement("a");V.href=N,V.download="fee-receipt-setting.json",V.click(),URL.revokeObjectURL(N)},O=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(Z.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:U},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:j,disabled:!r}],[r,o,d,g,u,_,h,x,I,C,y]),M=async $=>{$.preventDefault(),R(!0);try{const E=new FormData;E.set("number_of_receipt",String(o??"")),E.set("rollnumber",d?"1":"0"),E.set("address",g?"1":"0"),E.set("gardianname",u?"1":"0"),E.set("authorizedsignatory",String(_??"0")),E.set("parentsignatory",String(h??"0")),E.set("dynamic_qr_code_device",String(x??"0")),E.set("sequence_payment",I?"1":"0"),E.set("previois_fees",C?"1":"0"),E.set("upfront_payment_months",String(y??"")),await an(Zo.save,E,t),w.success("Fee receipt settings updated.",{duration:1e3}),s.mutate?.()}catch(E){w.error(E?.response?.data?.msg??E?.message??"Failed to update settings.",{duration:1500})}finally{R(!1)}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(qt,{title:"Fee Receipt Setting",actions:O,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Settings Form"}),children:e.jsxs("form",{ref:a,onSubmit:M,children:[e.jsxs("div",{style:ks,children:[e.jsx(Y,{type:"number",name:"number_of_receipt",label:"Number Of Receipt",value:o,onChange:$=>l($.target.value)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Roll Number"}),e.jsx(n.Checkbox,{checked:d,onChange:$=>c($.target.checked),children:"Show Roll Number in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Address"}),e.jsx(n.Checkbox,{checked:g,onChange:$=>f($.target.checked),children:"Show address in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Guardian Name"}),e.jsx(n.Checkbox,{checked:u,onChange:$=>p($.target.checked),children:"Show Guardian Name in Fees Receipt"})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:ks,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Authorized Signatory"}),e.jsxs(n.Radio.Group,{value:_,onChange:$=>v($.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Parent Signatory"}),e.jsxs(n.Radio.Group,{value:h,onChange:$=>m($.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Dynamic QR Code Device"}),e.jsxs(n.Radio.Group,{value:x,onChange:$=>T($.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:ks,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sequence Payment"}),e.jsx(n.Checkbox,{checked:I,onChange:$=>k($.target.checked),children:"Student can pay in sequence"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Previous Fees"}),e.jsx(n.Checkbox,{checked:C,onChange:$=>b($.target.checked),children:"Previous Fees Carry Over to Next Year"})]}),e.jsx(Y,{type:"number",name:"upfront_payment_months",label:"Max Advance Payment (Months)",value:y,onChange:$=>S($.target.value)})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:A?"Updating...":"Done",disabled:A})})]})})})]})}function Eh({token:t}){return e.jsx(Mh,{token:t})}const Ya=pt.marksheetSetting,Fh=({token:t})=>ft({url:Ya.templateTypes,token:t}),$h=({token:t})=>ft({url:Ya.classDropdown,token:t}),Uh=({token:t})=>ft({url:Ya.assignedTable,token:t}),Nh={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:20,alignItems:"end"},Ji=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],Lh=Array.from({length:12},(t,a)=>({value:String(a+1),label:`Design ${a+1}`})),Bh=t=>t?Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t)?t:[]:[];function qh({token:t}){const a=i.useRef(null),s=Fh({token:t}),r=$h({token:t}),o=Uh({token:t}),l=i.useMemo(()=>Ji(s.data),[s.data]),d=i.useMemo(()=>Ji(r.data),[r.data]),c=i.useMemo(()=>Bh(o.data),[o.data]),[g,f]=i.useState(null),[u,p]=i.useState(null),[_,v]=i.useState([]),h=()=>{a.current?.reset?.(),f(null),p(null),v([])},m=()=>{const C=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),b=URL.createObjectURL(C),y=document.createElement("a");y.href=b,y.download="marksheet-templates.json",y.click(),URL.revokeObjectURL(b)},x=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:h},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:m,disabled:c.length===0}],[c.length]),T=async C=>{if(C.preventDefault(),!g?.value){w.error("Select marksheet type.",{duration:1200});return}if(!u?.value){w.error("Select design.",{duration:1200});return}if(!_?.length){w.error("Select at least one class.",{duration:1200});return}try{const b=new FormData;b.set("temp_id",String(g.value)),b.set("ui_id",String(u.value)),_.forEach(y=>b.append("class_id[]",String(y))),await an(Ya.assign,b,t),w.success("Marksheet template assigned.",{duration:1e3}),o.mutate?.(),h()}catch(b){w.error(b?.response?.data?.msg??b?.message??"Failed to assign template.",{duration:1500})}},I=async C=>{try{await ir(Ya.remove,C,t),w.success("Template removed.",{duration:1e3}),o.mutate?.()}catch(b){w.error(b?.response?.data?.msg??b?.message??"Failed to remove template.",{duration:1500})}},k=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class"},{title:"Template Name",dataIndex:"name",key:"name"},{title:"Template Design",dataIndex:"ui_id",key:"ui_id"},{title:"Action",key:"action",render:(C,b)=>e.jsx(mt,{id:b?.id,funcName:I})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(qt,{title:"Marksheet Setting",actions:x,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Template"}),children:e.jsxs("form",{ref:a,onSubmit:T,children:[e.jsxs("div",{style:Nh,children:[e.jsxs("div",{children:[e.jsx(ee,{label:"Select Marksheet Type",options:l,value:g,onChange:C=>f(C)}),e.jsx("input",{type:"hidden",name:"temp_id",value:g?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Select Design",options:Lh,value:u,onChange:C=>p(C)}),e.jsx("input",{type:"hidden",name:"ui_id",value:u?.value??""})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:8},children:"Class"}),e.jsx(n.Checkbox.Group,{options:d,value:_,onChange:C=>v(C)})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Save"})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Marksheet List"}),children:e.jsx(n.Table,{size:"small",rowKey:"id",columns:k,dataSource:c,pagination:!1})})]})})]})}function zh({token:t}){return e.jsx(qh,{token:t})}const Ps={fetch:`${pt.legalPages.get}?page_name=terms`,save:pt.legalPages.termsSave,fieldName:"terms_data"};function Yh({token:t}){return e.jsx(or,{token:t,title:"Terms",fetchUrl:Ps.fetch,saveUrl:Ps.save,fieldName:Ps.fieldName})}function Vh({token:t}){return e.jsx(Yh,{token:t})}const Os={fetch:`${pt.legalPages.get}?page_name=privacy`,save:pt.legalPages.privacySave,fieldName:"privacy_data"};function Wh({token:t}){return e.jsx(or,{token:t,title:"Privacy",fetchUrl:Os.fetch,saveUrl:Os.save,fieldName:Os.fieldName})}function Hh({token:t}){return e.jsx(Wh,{token:t})}const Ms={fetch:`${pt.legalPages.get}?page_name=about_us`,save:pt.legalPages.aboutSave,fieldName:"about_data"};function Kh({token:t}){return e.jsx(or,{token:t,title:"About",fetchUrl:Ms.fetch,saveUrl:Ms.save,fieldName:Ms.fieldName})}function Gh({token:t}){return e.jsx(Kh,{token:t})}const lr=pt.feesInfo,Jh=({token:t})=>ft({url:lr.get,token:t}),Qh=({token:t})=>ft({url:lr.statesDropdown,token:t}),Es={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Xh=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null,Zh=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[]:[],eg=t=>t?Ko(`branch/logo/${t}`):"",Fs=t=>t?Ko(`branch/signature/${t}`):"";function tg({token:t}){const a=i.useRef(null),s=Jh({token:t}),r=Qh({token:t}),o=i.useMemo(()=>Xh(s.data),[s.data]),l=i.useMemo(()=>Zh(r.data),[r.data]),[d,c]=i.useState(null),[g,f]=i.useState(""),[u,p]=i.useState(""),[_,v]=i.useState(""),[h,m]=i.useState(""),x=y=>{const S=new FormData(y),A=Object.fromEntries(S.entries());return A.state_id=d?.value??"",A.fees_receipt_logo=g,A.manager_signature=u,A.principal_signature=_,A.stamp=h,A},T=()=>{c(l.find(y=>String(y?.value)===String(o?.state_id??""))??null),f(o?.fees_receipt_logo??""),p(o?.manager_signature??""),v(o?.principal_signature??""),m(o?.stamp??"")};i.useEffect(()=>{o&&T()},[o,l]);const I=()=>{a.current?.reset?.(),T()},k=()=>{const y=x(a.current),S=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),A=URL.createObjectURL(S),R=document.createElement("a");R.href=A,R.download="fees-info.json",R.click(),URL.revokeObjectURL(A)},C=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(Z.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:I},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:k,disabled:!o}],[o,d,g,u,_,h]),b=async y=>{y.preventDefault();try{const S=x(y.target);await oh(lr.save,S,t),w.success("Fees info saved.",{duration:1e3}),s.mutate?.()}catch(S){w.error(S?.response?.data?.msg??S?.message??"Failed to save fees info.",{duration:1500})}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(qt,{title:"Fees Info",actions:C,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"School Information"}),children:e.jsxs("form",{ref:a,onSubmit:b,children:[e.jsxs("div",{style:Es,children:[e.jsx(Y,{name:"Bussiness_name",label:"Business Name*",defaultValue:o?.name??"",required:!0}),e.jsx(Y,{name:"cin",label:"Sub Heading",defaultValue:o?.cin??""}),e.jsx(Y,{name:"school_no",type:"number",label:"School Number",defaultValue:o?.school_no??""}),e.jsx(Y,{name:"website",label:"Website",defaultValue:o?.website??""}),e.jsx(Y,{name:"school_Code",label:"School Code",defaultValue:o?.school_Code??""}),e.jsx(Y,{name:"offical_number",label:"Official Number",defaultValue:o?.offical_number??""}),e.jsx(Y,{name:"email_id",label:"Email",defaultValue:o?.email_id??""}),e.jsx(Y,{name:"receipt_prefix",label:"Receipt Prefix",defaultValue:o?.receipt_prefix??""}),e.jsx(Y,{name:"recipt_start_number",type:"number",label:"Receipt Start Number",defaultValue:o?.recipt_start_number??""}),e.jsxs("div",{children:[e.jsx(ee,{label:"State",options:l,value:d,onChange:c}),e.jsx("input",{type:"hidden",name:"state_id",value:d?.value??""})]}),e.jsx(Y,{name:"affiliation_no",label:"Affiliation Number",defaultValue:o?.affiliation_no??""}),e.jsx(Y,{name:"affiliation_desc",label:"Affiliation Description",defaultValue:o?.affiliation_desc??""}),e.jsx(Y,{name:"udise_code",label:"UDISE Code",defaultValue:o?.udise_code??""}),e.jsx(Y,{name:"color_code",label:"Primary Color",defaultValue:o?.color_code??""}),e.jsx(Y,{name:"fontcolor_code",label:"Font Color",defaultValue:o?.fontcolor_code??""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Es,children:[e.jsx(wt,{name:"Bussiness_address",rows:3,label:"Business Address",defaultValue:o?.Bussiness_address??o?.bussiness_address??""}),e.jsx(wt,{name:"note",rows:3,label:"Note",defaultValue:o?.note??""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Es,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Fees Receipt Logo"}),e.jsx(fa,{token:t,action:Xo(),value:g,previewUrl:eg(g),accept:"image/*",onChange:f}),e.jsx("input",{type:"hidden",name:"fees_receipt_logo",value:g})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Manager Signature"}),e.jsx(fa,{token:t,action:Is(),value:u,previewUrl:Fs(u),accept:"image/*",onChange:p}),e.jsx("input",{type:"hidden",name:"manager_signature",value:u})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Principal Signature"}),e.jsx(fa,{token:t,action:Is(),value:_,previewUrl:Fs(_),accept:"image/*",onChange:v}),e.jsx("input",{type:"hidden",name:"principal_signature",value:_})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Stamp"}),e.jsx(fa,{token:t,action:Is(),value:h,previewUrl:Fs(h),accept:"image/*",onChange:m}),e.jsx("input",{type:"hidden",name:"stamp",value:h})]})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Save"})})]})})})]})}function ag({token:t}){return e.jsx(tg,{token:t})}const zn=pt.payrollSettings,ng=({token:t,page:a=1,perPage:s=10})=>Qo({baseUrl:zn.table,token:t,page:a,perPage:s}),sg={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},$a=[{value:"Allowances",label:"Allowances"},{value:"Dedection",label:"Dedection"}],$s=[{value:"Flat",label:"Flat"},{value:"Percentage",label:"Percentage"}],rg=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],ig=(t,a=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??a;function og({token:t}){const a=i.useRef(null),s=i.useRef(null),[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,g]=i.useState(null),[f,u]=i.useState($a[0]),[p,_]=i.useState(null),[v,h]=i.useState(null),[m,x]=i.useState(null),T=ng({token:t,page:r.page,perPage:r.rowsPerPage}),I=i.useMemo(()=>rg(T.data),[T.data]),k=i.useMemo(()=>ig(T.data,I.length),[T.data,I.length]),C=async U=>{U.preventDefault();try{const j=new FormData(U.target);j.set("type",f?.value??""),j.set("amount_type",p?.value??""),await an(zn.add,j,t),w.success("Payroll setting added.",{duration:1e3}),T.mutate?.(),U.target.reset(),_(null),u($a[0])}catch(j){w.error(j?.response?.data?.msg??j?.message??"Failed to add payroll setting.",{duration:1500})}},b=U=>{g(U),h($a.find(j=>j.value===U?.type)??null),x($s.find(j=>j.value===U?.amount_type)??null),d(!0)},y=async U=>{U.preventDefault();try{const j=new FormData(U.target);j.set("id",String(c?.id??"")),j.set("type",v?.value??""),j.set("amount_type",m?.value??""),await Go(zn.edit,j,t),w.success("Payroll setting updated.",{duration:1e3}),d(!1),T.mutate?.()}catch(j){w.error(j?.response?.data?.msg??j?.message??"Failed to update payroll setting.",{duration:1500})}},S=async U=>{try{await ir(zn.remove,U,t),w.success("Payroll setting deleted.",{duration:1e3}),T.mutate?.()}catch(j){w.error(j?.response?.data?.msg??j?.message??"Failed to delete payroll setting.",{duration:1500})}},A=()=>{const U=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),j=URL.createObjectURL(U),O=document.createElement("a");O.href=j,O.download="payroll-settings.json",O.click(),URL.revokeObjectURL(j)},R=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(Z.PlusOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:()=>T.mutate?.()},{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:A,disabled:I.length===0}],[I.length]),z=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title"},{title:"Type",dataIndex:"type",key:"type"},{title:"Amount Type",dataIndex:"amount_type",key:"amount_type"},{title:"Amount",dataIndex:"Amount",key:"Amount"},{title:"Action",key:"action",render:(U,j)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(n.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>b(j)}),e.jsx(n.Popconfirm,{title:"Delete payroll setting?",onConfirm:()=>S(j.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(qt,{title:"Payroll Settings",actions:R,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"minmax(320px, 420px) 1fr"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Allowances / Deductions"}),children:e.jsxs("form",{ref:a,onSubmit:C,children:[e.jsxs("div",{style:sg,children:[e.jsx(Y,{name:"title",label:"Title",required:!0}),e.jsxs("div",{children:[e.jsx(ee,{label:"Type",options:$a,value:f,onChange:u}),e.jsx("input",{type:"hidden",name:"type",value:f?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Amount Type",options:$s,value:p,onChange:_}),e.jsx("input",{type:"hidden",name:"amount_type",value:p?.value??""})]}),e.jsx(Y,{name:"Amount",type:"number",label:"Amount",required:!0})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:20},children:e.jsx(re,{type:"submit",value:"Submit"})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Settings List"}),children:e.jsx(n.Table,{rowKey:"id",columns:z,dataSource:I,loading:T.isLoading,pagination:{current:r.page,pageSize:r.rowsPerPage,total:k,showSizeChanger:!0,onChange:(U,j)=>o({page:U,rowsPerPage:Number(j)})}})})]})}),e.jsx(n.Drawer,{open:l,onClose:()=>d(!1),title:"Edit Payroll Setting",width:420,children:e.jsx("form",{ref:s,onSubmit:y,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{name:"title",label:"Title",required:!0,defaultValue:c?.title??""}),e.jsxs("div",{children:[e.jsx(ee,{label:"Type",options:$a,value:v,onChange:h}),e.jsx("input",{type:"hidden",name:"type",value:v?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Amount Type",options:$s,value:m,onChange:x}),e.jsx("input",{type:"hidden",name:"amount_type",value:m?.value??""})]}),e.jsx(Y,{name:"Amount",type:"number",label:"Amount",required:!0,defaultValue:c?.Amount??""}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Update"})})]})})})]})}function lg({token:t}){return e.jsx(og,{token:t})}const el=pt.paymentGateway,dg=({token:t})=>ft({url:el.get,token:t}),cg=[{id:"Razorpay",title:"Razorpay",fields:["keyId","keySecret"]},{id:"PhonePe",title:"Pine Labs",fields:["merchantId","saltKey","saltIndex"]},{id:"Paytm",title:"HDFC",fields:["merchantId","merchantKey"]},{id:"SabPaisa",title:"SabPaisa",fields:["clientCode","transUserName","transUserPassword","authKey","authIV"]}],Yt={Razorpay:{keyId:"",keySecret:"",isActive:!0},PhonePe:{merchantId:"",saltKey:"",saltIndex:"1",isActive:!1},Paytm:{merchantId:"",merchantKey:"",isActive:!1},SabPaisa:{clientCode:"",transUserName:"",transUserPassword:"",authKey:"",authIV:"",isActive:!1}},Qi=t=>{const a=Array.isArray(t?.data)&&t.data[0]||Array.isArray(t?.data?.data)&&t.data.data[0]||Array.isArray(t)&&t[0]||null;if(!a?.data)return Yt;try{const s=JSON.parse(a.data||"{}"),r=s?.data&&typeof s.data=="object"?s.data:s;return{Razorpay:{...Yt.Razorpay,...r?.Razorpay??{}},PhonePe:{...Yt.PhonePe,...r?.PhonePe??r?.PineLab??r?.PineLabs??{}},Paytm:{...Yt.Paytm,...r?.Paytm??r?.HDFC??{}},SabPaisa:{...Yt.SabPaisa,...r?.SabPaisa??{}}}}catch{return Yt}};function ug({token:t}){const a=i.useRef(null),s=dg({token:t}),[r,o]=i.useState(Yt);i.useEffect(()=>{s.data&&o(Qi(s.data))},[s.data]);const l=(u,p,_)=>{o(v=>({...v,[u]:{...v[u],[p]:_}}))},d=()=>o(Qi(s.data)),c=()=>{const u=new Blob([JSON.stringify(r,null,2)],{type:"application/json"}),p=URL.createObjectURL(u),_=document.createElement("a");_.href=p,_.download="payment-gateway-settings.json",_.click(),URL.revokeObjectURL(p)},g=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(Z.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:d},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:c}],[r,s.data]),f=async u=>{u.preventDefault();try{await Jo(el.save,{data:r},t),w.success("Payment gateway settings saved.",{duration:1e3}),s.mutate?.()}catch(p){w.error(p?.response?.data?.msg??p?.message??"Failed to save gateway settings.",{duration:1500})}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(w.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(qt,{title:"Payment Gateway",actions:g,children:e.jsxs("form",{ref:a,onSubmit:f,style:{display:"grid",gap:20},children:[cg.map(u=>{const p=r[u.id]??{};return e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:u.title}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontSize:14,fontWeight:500},children:["Enable ",u.title]}),e.jsx(n.Switch,{checked:!!p.isActive,onChange:_=>l(u.id,"isActive",_)})]}),e.jsx(n.Divider,{style:{margin:0}}),e.jsx("div",{style:{display:"grid",gap:16,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:u.fields.map(_=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:_}),e.jsx(n.Input,{value:p[_]??"",type:_.toLowerCase().includes("secret")||_.toLowerCase().includes("password")?"password":"text",onChange:v=>l(u.id,_,v.target.value)})]},_))})]})},u.id)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(re,{type:"submit",value:"Save"})})]})})]})}function pg({token:t}){return e.jsx(ug,{token:t})}const mg=({routes:t=[],onNavigate:a})=>e.jsx(n.Row,{gutter:[16,16],children:t.map((s,r)=>e.jsx(n.Col,{xs:24,md:8,lg:8,children:e.jsx(F,{children:e.jsx(eo,{icon:s?.icon??"",title:s?.title??"",path:s?.path??"",onClick:a})})},`${r}route001`))});exports.About=Gh;exports.AcademicYear=kh;exports.Academics=qf;exports.AddBook=zu;exports.AddDriver=Uu;exports.AddStaff=lm;exports.AdmissionEnquiry=vc;exports.ApplyLeave=Wm;exports.AprroveLeaveRequest=Nm;exports.AssignByClass=yy;exports.AssignStudentToTransport=$u;exports.AssignSubjects=py;exports.AssignTimeGroup=_y;exports.AssignVehicles=Ru;exports.AttendanceDashboard=Df;exports.BookList=Yu;exports.BuySellProduct=Tp;exports.Category=hp;exports.Class=ey;exports.CoScholasticArea=ky;exports.Complain=ju;exports.CreateTimeGroup=xy;exports.DailyAttendance=Mf;exports.Department=Xm;exports.Designation=tf;exports.ErpDashboard=sl;exports.FeeReceiptSetting=Eh;exports.FeesInfo=ag;exports.GatePass=wu;exports.GeneralSetting=nh;exports.Holidays=ly;exports.IssueReturn=Wu;exports.LeaveType=Gm;exports.LibraryAssignStudent=Hu;exports.LibraryCategory=Ku;exports.LibraryRenewalReport=Ju;exports.LibraryReport=Gu;exports.ManageStock=Lp;exports.MarksheetSetting=zh;exports.MenuSubmenu=sc;exports.MonthlyReport=$f;exports.Notes=Fy;exports.NpmReport=Wp;exports.Organization=Ch;exports.PaymentGateway=pg;exports.Payroll=Mm;exports.PayrollReceiptDetails=mf;exports.PayrollSettings=lg;exports.PhoneCallLog=Xc;exports.PostalDispatch=su;exports.PostalReceive=cu;exports.Privacy=Hh;exports.Products=pp;exports.PromoteStudents=Ty;exports.RoutePage=mg;exports.RouteTimeTable=Nu;exports.Sections=Gf;exports.SellReports=$p;exports.SetupFrontOffice=Su;exports.Shift=sf;exports.StaffAttendance=Cm;exports.StaffAttendanceReport=Dm;exports.StaffDailyAttendance=cf;exports.StaffDirectory=mm;exports.StockReport=Vp;exports.Stoppage=Bu;exports.StudentAttendance=kf;exports.SubCategory=vp;exports.Subjects=sy;exports.Syllabus=Vy;exports.Terms=Vh;exports.TimeTable=ah;exports.TransferCertificate=By;exports.TransportRoutes=Cu;exports.TransportVehicles=Au;exports.Unit=kp;exports.Vendor=sp;exports.VisitorBook=zc;exports.YearlyReport=Bf;exports.setBaseUrl=Bd;
59
+ `}),e.jsx(A,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(St,{data:{tableRef:B}})})}),e.jsxs("div",{className:"ubk-table-shell",ref:B,style:{marginTop:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,flexWrap:"wrap",marginBottom:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"#222"},children:[e.jsx("span",{children:"Show"}),e.jsx(n.Select,{size:"small",value:E.rowsPerPage,onChange:se=>z(1,se),options:[10,25,50,100].map(se=>({label:se,value:se})),style:{width:72}}),e.jsx("span",{children:"entries"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:12,color:"#222"},children:"Search:"}),e.jsx(n.Input,{size:"small",allowClear:!0,value:O,onChange:se=>{$(se.target.value),M(me=>({...me,page:1}))},placeholder:"Enter search keyword",prefix:e.jsx(te.SearchOutlined,{style:{color:"#a3a8cf"}}),style:{width:220,borderWidth:"0 0 1px 0",borderRadius:0,background:"transparent"}})]})]}),e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),be]}),l&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,marginTop:16,flexWrap:"wrap"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:`Showing ${fe} to ${je} of ${Ge} entries`}),e.jsx(n.Pagination,{current:E.page,pageSize:E.rowsPerPage,total:Ge||0,showSizeChanger:!1,onChange:z})]})]})]})},hu=({token:t,type:a})=>{const[s,r]=i.useState({page:1,rowsPerPage:10}),o="api/branchapi/frontoffice/enquirytablelist",l=o.includes("?")?o.endsWith("?")||o.endsWith("&")?"":"&":"?",d=`${o}${l}page=${s.page}&per_page=${s.rowsPerPage}`,{isLoading:c,data:y,error:h}=W(t?[d,t]:null,([I,k])=>H(I,k)),[u,p]=i.useState(!1),w=(I,k)=>{r({page:I,rowsPerPage:parseInt(k)})},v=async I=>{},b=I=>{console.log("dsdsdsdsd",I),p(I)},m=()=>{},j=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],D=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(I,k)=>I.name.localeCompare(k.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(I,k)=>(I.contact||"").localeCompare(k.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(I,k)=>(I.description||"").localeCompare(k.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(I,k)=>(I.source_name||"").localeCompare(k.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(I,k)=>new Date(I.date)-new Date(k.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(I,k)=>new Date(I.follow_up_date)-new Date(k.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Re,{parentCallback:w,data:{newData:y,columns:D,action:!0,Loading:c,error:h,open:u,viewDetails:m,deleteTodoMutation:v,DrawerUpdate:b,ActionView:j}})})};var fu=Wo();const Ss=zo(fu),Qo=()=>{};class sr extends i.Component{state={value:this.props.value||this.props.defaultValue||""};selectRef=null;setSelectRef=a=>{this.selectRef=a};componentDidUpdate(a){a.value!==this.props.value&&this.setState({value:this.props.value})}onChange=(a,s)=>{this.props.onChange(a,s),this.setState({value:a})};getValue=()=>{const{value:a}=this.state;return a?Array.isArray(a)?a.length?"valid":"":typeof a=="object"?a.value||"":a:""};render(){const{SelectComponent:a,required:s,...r}=this.props;console.log("sdsdsfsdddddddd",{...r});const{isDisabled:o}=this.props,l=!o;return e.jsxs("div",{children:[e.jsx(a,{...r,ref:this.setSelectRef,onChange:this.onChange}),l&&e.jsx("input",{tabIndex:-1,autoComplete:"off",style:{opacity:0,width:"100%",height:0,display:"block"},value:this.getValue(),onChange:Qo,onFocus:()=>this.selectRef.focus(),required:s})]})}}sr.defaultProps={onChange:Qo};sr.protoTypes={selectComponent:Ss.func.isRequired,onChange:Ss.func,required:Ss.bool};const yu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},gu={menuPortal:t=>({...t,zIndex:9999}),control:(t,a)=>({...t,minHeight:40,height:40,fontSize:"14px",border:"none",borderBottom:`1px solid ${a.isFocused?"#222":"#d9d9d9"}`,borderRadius:0,boxShadow:"none",backgroundColor:"transparent",transition:"border-color 0.2s ease","&:hover":{border:"none",borderBottom:`1px solid ${a.isFocused?"#222":"#a8a8a8"}`}}),valueContainer:t=>({...t,height:40,padding:"0 0",display:"flex",alignItems:"center"}),input:t=>({...t,margin:0,padding:0}),indicatorSeparator:()=>({display:"none"}),indicatorsContainer:t=>({...t,height:40}),dropdownIndicator:(t,a)=>({...t,padding:"0 0 0 8px",color:a.isFocused?"#222":"#b5b5b5"}),singleValue:t=>({...t,color:"#222",marginLeft:0}),placeholder:t=>({...t,color:"#9f9f9f",marginLeft:0}),option:(t,a)=>({...t,fontSize:"14px",backgroundColor:a.isFocused?"#f8f8f8":"#fff",color:"#222",cursor:"pointer"})},Xo=t=>e.jsx(uo.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),xu=t=>e.jsx(sr,{...t,SelectComponent:uo,components:{Input:Xo},options:t.options}),X=i.forwardRef(({...t},a)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:yu,children:t?.label}),e.jsx(xu,{components:{Input:Xo},menuPortalTarget:document.body,styles:gu,className:"input-cont",...t,ref:a})]})),bu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ju={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Su=(t,a,s)=>a?t>ee(s).endOf("day")||t<ee(a).endOf("day"):!1,Me=i.forwardRef(function(a,s){const{...r}=a;return e.jsxs("div",{className:"form-group",children:[r.Desplay&&e.jsx("label",{className:`labelfont ${r.classnme?r.classnme:""}`,style:bu,children:r.Desplay}),e.jsx(n.DatePicker,{...r,style:{...ju,...r.style||{}},className:"form-group",disabledDate:o=>Su(o,r.sessionStart||r.minDate?.subtract(1,"day").format("YYYY-MM-DD"),r.sessionEnd||r.maxDate?.format("YYYY-MM-DD")),required:!0,ref:s})]})}),vu={minWidth:160,height:36,padding:"0 28px",border:"none",borderRadius:999,background:"linear-gradient(90deg, #f59b1c 0%, #ef3e7b 100%)",color:"#fff",fontSize:14,fontWeight:700,textTransform:"uppercase",cursor:"pointer",boxShadow:"none"},ne=i.forwardRef(({error:t,success:a,disabled:s,style:r,...o},l)=>e.jsx("div",{className:"form-group",style:{marginBottom:0},children:e.jsx("input",{...o,ref:l,disabled:s,style:{...vu,opacity:s?.7:1,cursor:s?"not-allowed":"pointer",...r||{}}})})),wu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},_u={width:"100%",minHeight:80,padding:"8px 0",fontSize:"14px",color:"#222",background:"transparent",border:0,borderTop:0,borderLeft:0,borderRight:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",outline:"none",resize:"vertical",transition:"border-color 0.2s ease"},st=({style:t,onFocus:a,onBlur:s,...r})=>{const[o,l]=i.useState(!1);return e.jsxs("div",{style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:wu,children:r.label}),e.jsx("textarea",{placeholder:r.placeholder||r.label,...r,onFocus:d=>{l(!0),a?.(d)},onBlur:d=>{l(!1),s?.(d)},style:{..._u,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})},ze=t=>({optimisticData:a=>[...a.data,t],populateCache:(a,s)=>[...s.data,a]}),Ne=t=>({optimisticData:a=>a.data.filter(s=>s.id!==t),populateCache:(a,s)=>s.data.filter(r=>r.id!==t)}),Cu=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Au="api/branchapi/Frontoffice/visitorbookShowdata",Du="api/branchapi/Frontoffice/purposedropdown";function Tu({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(At),o=Au.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&r?[o,r,s]:null,([m,j,D])=>Qa(m,{id:j},D)),{isLoading:c,data:y}=W(s?[Du,s]:null,([m,j])=>H(m,j)),h=i.useMemo(()=>Cu(y),[y]),u=d?.data?.[0],[p,w]=i.useState({purpose:void 0,name:"",phone:"",id_card:"",number_of_person:1,date:null,in_time:null,out_time:null,note:"",address:"",image:""});i.useEffect(()=>{u&&w({purpose:u?.purpose,name:u?.name||"",phone:u?.contact||"",id_card:u?.id_proof||"",number_of_person:u?.no_of_pepple||1,date:u?.date?ee(u.date):null,in_time:u?.in_time?ee(u.in_time,"h:mm a"):null,out_time:u?.out_time?ee(u.out_time,"h:mm a"):null,note:u?.note||"",address:u?.address||"",image:u?.image||""})},[u]);const v=(m,j)=>{w(D=>({...D,[m]:j}))},b=`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`;return l||c?e.jsx(A,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(A,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:m=>a(m,r),children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Visitor"})}),e.jsx(A,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",allowSelectAll:!1,value:p.purpose,onChange:m=>v("purpose",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0,value:p.name,onChange:m=>v("name",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"phone",type:"text",label:"Phone No.",required:!0,value:p.phone,onChange:m=>v("phone",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"id_card",type:"text",label:"ID Card",value:p.id_card,onChange:m=>v("id_card",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"number_of_person",type:"number",label:"Number of Person",value:p.number_of_person,onChange:m=>v("number_of_person",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:p.date,Desplay:"Date",id:"date",name:"date",required:!0,onChange:m=>v("date",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(A,{children:[e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:p.in_time,onChange:m=>v("in_time",m),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:p.in_time?p.in_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(A,{children:[e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:p.out_time,onChange:m=>v("out_time",m),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time",value:p.out_time?p.out_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:p.note,onChange:m=>v("note",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(st,{type:"text",label:"Address",name:"address",rows:3,required:!0,value:p.address,onChange:m=>v("address",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(A,{children:[e.jsx(n.Upload,{action:b,headers:{Authorization:s},maxCount:1,onChange:m=>{if(m.file.status==="removed"&&v("image",""),m.file.status==="done"){const j=m.file.response?.data??m.file.response?.file??"";v("image",String(j??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:p.image?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:p.image||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; }"})]})}const Ru=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},aa="api/branchapi/Frontoffice/visitortablelist",Iu="api/branchapi/Frontoffice/purposedropdown",ku="api/branchapi/frontoffice/addvisitors",Pu="api/branchapi/frontoffice/editvisitorsdata",Ou="api/branchapi/frontoffice/deletevisitors",Mu=`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`;function Eu({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,y]=i.useState(""),[h,u]=i.useState("03:30 PM"),p=(f,P)=>{s({page:f,rowsPerPage:Number.parseInt(P,10)})},w=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],v=i.useMemo(()=>{const f=aa.includes("?")?aa.endsWith("?")||aa.endsWith("&")?"":"&":"?";return`${aa}${f}page=${a.page}&per_page=${a.rowsPerPage}`},[aa,a.page,a.rowsPerPage]),{isLoading:b,error:m,data:j,mutate:D}=W(t?[v,t]:null,([f,P])=>H(f,P)),{isLoading:I,data:k}=W(t?[Iu,t]:null,([f,P])=>H(f,P)),S=i.useMemo(()=>Ru(k),[k]),x=async(f,P)=>{try{await D(Ee(f,P,t),ze(P)),_.success("Success! Added new item.")}catch{_.error("Failed to add the new item.")}},g=async f=>{try{await D(qe(Ou,f,t),Ne(f)),_.success("Success! Deleted item.")}catch{_.error("Failed to delete the item.")}},C=async(f,P,O)=>{try{const $=await Be(f,P,t);D($),Array.isArray($?.data)&&D(`${aa.replace(/\?.*$/,"")}?id=${O}`,$),_.success("Success! Updated item.")}catch{_.error("Failed to update the item.")}},T=async(f,P)=>{f.preventDefault();const O=new FormData(f.target);await C(Pu,O,P),f.target.reset(),d(""),o(!1)},R=async f=>{if(f.preventDefault(),!f.target?.date?.value)_.error("Select required dates"),f.target?.date?.focus(),y("textDanger");else{const P=new FormData(f.target);await x(ku,P),f.target.reset(),y(""),d(""),u("03:30 PM")}},L=f=>{o(f)},N=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Address",selector:"address",sortable:!0},{id:"5",name:"In Time",selector:"in_time",sortable:!0},{id:"6",name:"Out Time",selector:"out_time",sortable:!0}],[]);return e.jsxs("div",{children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Visitor"})}),e.jsx(A,{p:3,children:e.jsx("form",{onSubmit:R,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",required:!0,allowSelectAll:!1})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone No.",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"id_card",type:"text",label:"ID Card"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{defaultValue:1,name:"number_of_person",type:"number",label:"Number of Person"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ee(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>y("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(A,{children:[e.jsx(n.TimePicker,{defaultValue:ee("2022-04-17T15:30","h:mm a"),id:"in_time",use12Hours:!0,format:"h:mm a",onChange:(f,P)=>u(P),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:h,readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(st,{type:"text",label:"Address*",name:"address",rows:3,required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(A,{children:[e.jsx(n.Upload,{action:Mu,headers:{Authorization:t},maxCount:1,onChange:f=>{if(f.file.status==="removed"&&d(""),f.file.status==="done"){const P=f.file.response?.data??f.file.response?.file??"";d(String(P??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:l?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Visitor List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:p,data:{newData:j,columns:N,action:!0,ActionView:w,Loading:b,error:m,editDesign:e.jsx(Tu,{data:{handleUpdate:T,token:t}}),deleteTodoMutation:g,open:r,DrawerUpdate:L,viewDetails:""}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Fu="api/branchapi/frontoffice/generalcallsShowdata",$u=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}];function Uu({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(At),o=Fu.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&r?[o,r,s]:null,([p,w,v])=>Qa(p,{id:w},v)),c=d?.data?.[0],[y,h]=i.useState({name:"",phone:"",description:"",date:null,next_follow_up_date:null,call_duration:"",note:"",call_type:""});i.useEffect(()=>{c&&h({name:c?.name||"",phone:c?.contact||"",description:c?.description||"",date:c?.date?ee(c.date):null,next_follow_up_date:c?.follow_up_date?ee(c.follow_up_date):null,call_duration:c?.call_dureation||"",note:c?.note||"",call_type:c?.call_type||""})},[c]);const u=(p,w)=>{h(v=>({...v,[p]:w}))};return l?e.jsx(A,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(A,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,r),children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Call Log"})}),e.jsx(A,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0,value:y.name,onChange:p=>u("name",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",value:y.phone,onChange:p=>u("phone",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",value:y.description,onChange:p=>u("description",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:y.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:y.next_follow_up_date,Desplay:"Next Follow Up Date",id:"fdate",name:"next_follow_up_date",onChange:p=>u("next_follow_up_date",p)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"call_duration",type:"text",label:"Call Duration",value:y.call_duration,onChange:p=>u("call_duration",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:y.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{options:$u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:y.call_type?{value:y.call_type,label:y.call_type}:null,onChange:p=>u("call_type",p?.value||"")})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const na="api/branchapi/frontoffice/generalcalltablelist",Nu="api/branchapi/frontoffice/addgenaralcalls",Lu="api/branchapi/frontoffice/editgeneralcall",Bu="api/branchapi/frontoffice/deletegeneralcall",qu=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}],zu=[{key:"all",label:"All Calls"},{key:"Incoming",label:"Incoming"},{key:"Outgoing",label:"Outgoing"}];function Yu({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,y]=i.useState(""),[h,u]=i.useState("all"),[p,w]=i.useState(""),v=i.useRef(null),b=(f,P)=>{s({page:f,rowsPerPage:Number.parseInt(P,10)})},m=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],j=i.useMemo(()=>{const f=na.includes("?")?na.endsWith("?")||na.endsWith("&")?"":"&":"?",P=new URLSearchParams;return P.set("page",String(a.page)),P.set("per_page",String(a.rowsPerPage)),h!=="all"&&P.set("call_type",h),`${na}${f}${P.toString()}`},[na,a.page,a.rowsPerPage,h]),{isLoading:D,error:I,data:k,mutate:S}=W(t?[j,t]:null,([f,P])=>H(f,P)),x=async(f,P)=>{try{await S(Ee(f,P,t),ze(P)),_.success("Success! Added new item.")}catch{_.error("Failed to add the new item.")}},g=async f=>{try{await S(qe(Bu,f,t),Ne(f)),_.success("Success! Deleted item.")}catch{_.error("Failed to delete the item.")}},C=async(f,P,O)=>{try{const $=await Be(f,P,t);S($),Array.isArray($?.data)&&S(`${na.replace(/\?.*$/,"")}?id=${O}`,$),_.success("Success! Updated item.")}catch{_.error("Failed to update the item.")}},T=async(f,P)=>{f.preventDefault();const O=new FormData(f.target);await C(Lu,O,P),f.target.reset(),d(""),o(!1)},R=async f=>{if(f.preventDefault(),!f.target?.date?.value)_.error("Select required dates"),f.target?.date?.focus(),y("textDanger");else{const P=new FormData(f.target);await x(Nu,P),f.target.reset(),y(""),d(""),w("")}},L=f=>{o(f)},N=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Phone",selector:"contact",sortable:!0},{id:"3",name:"Description",selector:"description",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Follow Up Date",selector:"follow_up_date",sortable:!0},{id:"6",name:"Call Duration",selector:"call_dureation",sortable:!0}],[]);return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Phone Call Log"})}),e.jsx(A,{p:3,children:e.jsx("form",{onSubmit:R,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ee(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>y("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",Desplay:"Next Follow Up Date",id:"fdate",name:"follow_up_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"call_dureation",type:"text",label:"Call Duration"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{options:qu,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:p?{value:p,label:p}:null,onChange:f=>w(f?.value||"")})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Phone Call Log List"})}),e.jsxs(A,{pt:3,children:[e.jsx(n.Tabs,{activeKey:h,onChange:u,items:zu}),e.jsx(St,{data:{tableRef:v}}),e.jsx(Re,{parentCallback:b,data:{newData:k,columns:N,action:!0,ActionView:m,Loading:D,error:I,editDesign:e.jsx(Uu,{data:{handleUpdate:T,token:t}}),deleteTodoMutation:g,open:r,DrawerUpdate:L,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Vu="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function Wu({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(At),o=Vu.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&r?[o,r,s]:null,([p,w,v])=>Qa(p,{id:w},v)),c=d?.data?.[0],[y,h]=i.useState({to_title:"",refernce:"",address:"",note:"",from_title:"",date:null,image:""});i.useEffect(()=>{c&&h({to_title:c?.to_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",from_title:c?.from_title||"",date:c?.date?ee(c.date):null,image:c?.image||""})},[c]);const u=(p,w)=>{h(v=>({...v,[p]:w}))};return l?e.jsx(A,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(A,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,r),children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Dispatch"})}),e.jsx(A,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"title",type:"text",label:"To Title *",required:!0,value:y.to_title,onChange:p=>u("to_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"refernce",type:"text",label:"Reference No",value:y.refernce,onChange:p=>u("refernce",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"address",type:"text",label:"Address",required:!0,value:y.address,onChange:p=>u("address",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:y.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"from_title",type:"text",label:"From Title",required:!0,value:y.from_title,onChange:p=>u("from_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:y.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const sa="api/branchapi/frontoffice/postaldispatchtablelist",Hu="api/branchapi/frontoffice/addpostaldispatch",Ku="api/branchapi/frontoffice/editpostaldispatch",Gu="api/branchapi/frontoffice/deletepostalreceivedispatch";function Ju({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,y]=i.useState(""),h=i.useRef(null),u=(T,R)=>{s({page:T,rowsPerPage:Number.parseInt(R,10)})},p=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],w=i.useMemo(()=>{const T=sa.includes("?")?sa.endsWith("?")||sa.endsWith("&")?"":"&":"?";return`${sa}${T}page=${a.page}&per_page=${a.rowsPerPage}`},[sa,a.page,a.rowsPerPage]),{isLoading:v,error:b,data:m,mutate:j}=W(t?[w,t]:null,([T,R])=>H(T,R)),D=async(T,R)=>{try{await j(Ee(T,R,t),ze(R)),_.success("Success! Added new item.")}catch{_.error("Failed to add the new item.")}},I=async T=>{try{await j(qe(Gu,T,t),Ne(T)),_.success("Success! Deleted item.")}catch{_.error("Failed to delete the item.")}},k=async(T,R,L)=>{try{const N=await Be(T,R,t);j(N),Array.isArray(N?.data)&&j(`${sa.replace(/\?.*$/,"")}?id=${L}`,N),_.success("Success! Updated item.")}catch{_.error("Failed to update the item.")}},S=async(T,R)=>{T.preventDefault();const L=new FormData(T.target);await k(Ku,L,R),T.target.reset(),d(""),o(!1)},x=async T=>{if(T.preventDefault(),!T.target?.date?.value)_.error("Select required dates"),T.target?.date?.focus(),y("textDanger");else{const R=new FormData(T.target);await D(Hu,R),T.target.reset(),y(""),d("")}},g=T=>{o(T)},C=i.useMemo(()=>[{id:"1",name:"To Title",selector:"to_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"From Title",selector:"from_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Dispatch"})}),e.jsx(A,{p:3,children:e.jsx("form",{onSubmit:x,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{required:!0,name:"title",type:"text",label:"To Title *"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{required:!0,name:"from_title",type:"text",label:"From Title"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ee(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>y("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Dispatch List"})}),e.jsxs(A,{pt:3,children:[e.jsx(St,{data:{tableRef:h}}),e.jsx(Re,{parentCallback:u,data:{newData:m,columns:C,action:!0,ActionView:p,Loading:v,error:b,editDesign:e.jsx(Wu,{data:{handleUpdate:S,token:t}}),deleteTodoMutation:I,open:r,DrawerUpdate:g,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Qu="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function Xu({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(At),o=Qu.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&r?[o,r,s]:null,([p,w,v])=>Qa(p,{id:w},v)),c=d?.data?.[0],[y,h]=i.useState({from_title:"",refernce:"",address:"",note:"",title:"",date:null,image:""});i.useEffect(()=>{c&&h({from_title:c?.from_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",title:c?.to_title||"",date:c?.date?ee(c.date):null,image:c?.image||""})},[c]);const u=(p,w)=>{h(v=>({...v,[p]:w}))};return l?e.jsx(A,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(A,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,r),children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Receive"})}),e.jsx(A,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"from_title",type:"text",label:"From Title *",required:!0,value:y.from_title,onChange:p=>u("from_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"refernce",type:"text",label:"Reference No",required:!0,value:y.refernce,onChange:p=>u("refernce",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"address",type:"text",label:"Address",required:!0,value:y.address,onChange:p=>u("address",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:y.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"title",type:"text",label:"To Title",required:!0,value:y.title,onChange:p=>u("title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:y.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const ra="api/branchapi/frontoffice/postalrecivetablelist",Zu="api/branchapi/frontoffice/addpostalrecive",ep="api/branchapi/frontoffice/editpostalrecive",tp="api/branchapi/frontoffice/deletepostalreceivedispatch";function ap({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,y]=i.useState(""),h=i.useRef(null),u=(T,R)=>{s({page:T,rowsPerPage:Number.parseInt(R,10)})},p=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],w=i.useMemo(()=>{const T=ra.includes("?")?ra.endsWith("?")||ra.endsWith("&")?"":"&":"?";return`${ra}${T}page=${a.page}&per_page=${a.rowsPerPage}`},[ra,a.page,a.rowsPerPage]),{isLoading:v,error:b,data:m,mutate:j}=W(t?[w,t]:null,([T,R])=>H(T,R)),D=async(T,R)=>{try{await j(Ee(T,R,t),ze(R)),_.success("Success! Added new item.")}catch{_.error("Failed to add the new item.")}},I=async T=>{try{await j(qe(tp,T,t),Ne(T)),_.success("Success! Deleted item.")}catch{_.error("Failed to delete the item.")}},k=async(T,R,L)=>{try{const N=await Be(T,R,t);j(N),Array.isArray(N?.data)&&j(`${ra.replace(/\?.*$/,"")}?id=${L}`,N),_.success("Success! Updated item.")}catch{_.error("Failed to update the item.")}},S=async(T,R)=>{T.preventDefault();const L=new FormData(T.target);await k(ep,L,R),T.target.reset(),d(""),o(!1)},x=async T=>{if(T.preventDefault(),!T.target?.date?.value)_.error("Select required dates"),T.target?.date?.focus(),y("textDanger");else{const R=new FormData(T.target);await D(Zu,R),T.target.reset(),y(""),d("")}},g=T=>{o(T)},C=i.useMemo(()=>[{id:"1",name:"From Title",selector:"from_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"To Title",selector:"to_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Receive"})}),e.jsx(A,{p:3,children:e.jsx("form",{onSubmit:x,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{required:!0,name:"from_title",type:"text",label:"From Title *"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{required:!0,name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{required:!0,name:"title",type:"text",label:"To Title"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ee(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>y("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Receive List"})}),e.jsxs(A,{pt:3,children:[e.jsx(St,{data:{tableRef:h}}),e.jsx(Re,{parentCallback:u,data:{newData:m,columns:C,action:!0,ActionView:p,Loading:v,error:b,editDesign:e.jsx(Xu,{data:{handleUpdate:S,token:t}}),deleteTodoMutation:I,open:r,DrawerUpdate:g,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const np="api/branchapi/frontoffice/complaintShowdata",sp="api/branchapi/frontoffice/complainttypedropdown",rp=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function ip({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(At),o=np.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&r?[o,r,s]:null,([m,j,D])=>Qa(m,{id:j},D)),{isLoading:c,data:y}=W(s?[sp,s]:null,([m,j])=>H(m,j)),h=i.useMemo(()=>rp(y).map(j=>({value:j?.value??j?.id??j?.complaint_type??"",label:j?.complaint_type??j?.label??""})),[y]),u=d?.data?.[0],[p,w]=i.useState({complain_type:"",complain_by_name:"",phone:"",date:null,description:"",action_token:"",assigned:"",note:"",file:""});i.useEffect(()=>{u&&w({complain_type:u?.complaint_type??"",complain_by_name:u?.name??"",phone:u?.contact??"",date:u?.date?ee(u.date):null,description:u?.description??"",action_token:u?.action_taken??"",assigned:u?.assigned??"",note:u?.note??"",file:u?.image??""})},[u]);const v=(m,j)=>{w(D=>({...D,[m]:j}))},b=i.useMemo(()=>h.find(m=>m.value===p.complain_type)||null,[h,p.complain_type]);return l||c?e.jsx(A,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsx(A,{pt:4,pb:1,style:{width:550},children:e.jsxs("form",{onSubmit:m=>a(m,r),children:[e.jsx("input",{type:"hidden",name:"id",value:r??""}),e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Complaint"})}),e.jsx(A,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",allowSelectAll:!1,value:b,onChange:m=>v("complain_type",m?.value??"")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0,value:p.complain_by_name,onChange:m=>v("complain_by_name",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{10}",value:p.phone,onChange:m=>v("phone",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:p.date,Desplay:"Enquiry Date",id:"date",name:"date",onChange:m=>v("date",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",value:p.description,onChange:m=>v("description",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"action_token",type:"text",label:"Action Taken",value:p.action_token,onChange:m=>v("action_token",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"assigned",type:"text",label:"Assigned",value:p.assigned,onChange:m=>v("assigned",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:p.note,onChange:m=>v("note",m.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})]})})}const ia="api/branchapi/frontoffice/complainttablelist",op="api/branchapi/frontoffice/complainttypedropdown",lp="api/branchapi/frontoffice/addcomplaint",dp="api/branchapi/frontoffice/editcomplaint",cp="api/branchapi/frontoffice/deletecomplaint",up=[{key:"all",label:"All Complaints"},{key:"pending",label:"Pending"},{key:"resolved",label:"Resolved"}];function pp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,y]=i.useState(""),[h,u]=i.useState("all"),p=i.useRef(null),w=(P,O)=>{s({page:P,rowsPerPage:Number.parseInt(O,10)})},v=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],b=i.useMemo(()=>{const P=ia.includes("?")?ia.endsWith("?")||ia.endsWith("&")?"":"&":"?",O=new URLSearchParams;return O.set("page",String(a.page)),O.set("per_page",String(a.rowsPerPage)),h!=="all"&&O.set("status",h),`${ia}${P}${O.toString()}`},[ia,a.page,a.rowsPerPage,h]),{isLoading:m,error:j,data:D,mutate:I}=W(t?[b,t]:null,([P,O])=>H(P,O)),{isLoading:k,data:S}=W(t?[op,t]:null,([P,O])=>H(P,O)),x=i.useMemo(()=>{const P=S?.data??S??[];return Array.isArray(P)?P:Array.isArray(P?.data)?P.data:[]},[S]),g=async(P,O)=>{try{await I(Ee(P,O,t),ze(O)),_.success("Success! Added new item.")}catch{_.error("Failed to add the new item.")}},C=async P=>{try{await I(qe(cp,P,t),Ne(P)),_.success("Success! Deleted item.")}catch{_.error("Failed to delete the item.")}},T=async(P,O,$)=>{try{const F=await Be(P,O,t);I(F),Array.isArray(F?.data)&&I(`${ia.replace(/\?.*$/,"")}?id=${$}`,F),_.success("Success! Updated item.")}catch{_.error("Failed to update the item.")}},R=async(P,O)=>{P.preventDefault();const $=new FormData(P.target);await T(dp,$,O),P.target.reset(),d(""),o(!1)},L=async P=>{if(P.preventDefault(),!P.target?.date?.value)_.error("Select required dates"),P.target?.date?.focus(),y("textDanger");else{const O=new FormData(P.target);await g(lp,O),P.target.reset(),y(""),d("")}},N=P=>{o(P)},f=i.useMemo(()=>[{id:"1",name:"Complain Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Name",selector:"name",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Action Taken",selector:"action_taken",sortable:!0},{id:"6",name:"Assigned",selector:"assigned",sortable:!0}],[]);return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Complaint"})}),e.jsx(A,{p:3,children:e.jsx("form",{onSubmit:L,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",required:!0,allowSelectAll:!1})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ee(),Desplay:"Complain Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>y("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"action_token",type:"text",label:"Action Taken"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"assigned",type:"text",label:"Assigned"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx("input",{type:"hidden",name:"file",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Complaint List"})}),e.jsxs(A,{pt:3,children:[e.jsx(n.Tabs,{activeKey:h,onChange:u,items:up}),e.jsx(St,{data:{tableRef:p}}),e.jsx(Re,{parentCallback:w,data:{newData:D,columns:f,action:!0,ActionView:v,Loading:m,error:j,editDesign:e.jsx(ip,{data:{handleUpdate:R,token:t}}),deleteTodoMutation:C,open:r,DrawerUpdate:N,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Wn="api/branchapi/Frontoffice/purposetablelist",Zo="api/branchapi/Frontoffice/complaint_typetablelist",el="api/branchapi/Frontoffice/sourcetablelist",tl="api/branchapi/Frontoffice/referencetablelist",pa=[{key:"purpose",label:"Purpose"},{key:"complainType",label:"Complain Type"},{key:"source",label:"Source"},{key:"reference",label:"Reference"}],Qr={purpose:[{id:"1",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],complainType:[{id:"1",name:"Complaint Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],source:[{id:"1",name:"Source",selector:"source",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],reference:[{id:"1",name:"Reference",selector:"reference",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}]};function mp({token:t}){const[a,s]=i.useState("purpose"),[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),c=i.useRef(null),y=(R,L)=>{o({page:R,rowsPerPage:Number.parseInt(L,10)})},h=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],u=()=>{switch(a){case"purpose":return Wn;case"complainType":return Zo;case"source":return el;case"reference":return tl;default:return Wn}},p=()=>{switch(a){case"purpose":return"api/branchapi/frontoffice/addvisitors_purpose";case"complainType":return"api/branchapi/frontoffice/addcomplaint_type";case"source":return"api/branchapi/frontoffice/addsource";case"reference":return"api/branchapi/frontoffice/addreference";default:return"api/branchapi/frontoffice/addvisitors_purpose"}},w=R=>{switch(a){case"purpose":return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:R};case"complainType":return{url:"api/branchapi/frontoffice/deletecomplaint_type",id:R};case"source":return{url:"api/branchapi/frontoffice/deletesource",id:R};case"reference":return{url:"api/branchapi/frontoffice/deletereference",id:R};default:return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:R}}},v=i.useMemo(()=>{const R=u(),L=R.includes("?")?R.endsWith("?")||R.endsWith("&")?"":"&":"?";return`${R}${L}page=${r.page}&per_page=${r.rowsPerPage}`},[a,r.page,r.rowsPerPage]),{isLoading:b,error:m,data:j,mutate:D}=W(t?[v,t]:null,([R,L])=>H(R,L)),I=async(R,L)=>{try{await D(Ee(R,L,t),ze(L)),_.success("Success! Added new item.")}catch{_.error("Failed to add the new item.")}},k=async R=>{const{url:L,id:N}=w(R);try{await D(qe(L,N,t),Ne(N)),_.success("Success! Deleted item.")}catch{_.error("Failed to delete the item.")}},S=async(R,L,N)=>{try{const f=await Be(R,L,t);D(f),Array.isArray(f?.data)&&D(`${u().replace(/\?.*$/,"")}?id=${N}`,f),_.success("Success! Updated item.")}catch{_.error("Failed to update the item.")}},x=async(R,L)=>{R.preventDefault();const N=new FormData(R.target),f=p();await S(f,N,L),R.target.reset(),d(!1)},g=async R=>{R.preventDefault();const L=new FormData(R.target),N=p();await I(N,L),R.target.reset()},C=R=>{d(R)},T=i.useMemo(()=>Qr[a]||Qr.purpose,[a]);return e.jsx(A,{pt:5,pb:1,children:e.jsx(n.Row,{gutter:[16,16],children:e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Setup Front Office"})}),e.jsxs(A,{p:3,children:[e.jsx(n.Tabs,{activeKey:a,onChange:R=>{s(R),o({page:1,rowsPerPage:10})},items:pa}),e.jsxs(n.Row,{gutter:[16,16],mt:3,children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx("form",{onSubmit:g,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Add ",pa.find(R=>R.key===a)?.label]})}),e.jsx(A,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(A,{children:e.jsx(Y,{required:!0,name:"name",type:"text",label:pa.find(R=>R.key===a)?.label+" *"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(A,{children:e.jsx(Y,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Add",color:"primary"})})})})]})})]})})}),e.jsx(n.Col,{xs:24,md:16,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:[pa.find(R=>R.key===a)?.label," List"]})}),e.jsxs(A,{pt:3,children:[e.jsx(St,{data:{tableRef:c}}),e.jsx(Re,{parentCallback:y,data:{newData:j,columns:T,action:!0,ActionView:h,Loading:b,error:m,editDesign:e.jsx(hp,{data:{handleUpdate:x,token:t,activeTab:a}}),deleteTodoMutation:k,open:l,DrawerUpdate:C,viewDetails:""}})]})]})})]})]})]})})})})}function hp({data:t}){const{handleUpdate:a,token:s,activeTab:r}=t||{},o=i.useContext(At),d=(v=>{switch(v){case"purpose":return Wn;case"complainType":return Zo;case"source":return el;case"reference":return tl;default:return Wn}})(r).replace(/\?.*$/,""),{isLoading:c,data:y}=W(s&&o?[d,o,s]:null,([v,b,m])=>getDataById(v,{id:b},m)),h=y?.data?.[0],[u,p]=i.useState({name:"",description:""});i.useEffect(()=>{h&&p({name:h?.visitors_purpose||h?.complaint_type||h?.source||h?.reference||"",description:h?.description||""})},[h]);const w=(v,b)=>{p(m=>({...m,[v]:b}))};return c?e.jsx(A,{pt:4,pb:1,style:{width:350},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(A,{pt:4,pb:1,style:{width:350},children:[e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Edit ",pa.find(v=>v.key===r)?.label]})}),e.jsx(A,{p:3,children:e.jsx("form",{onSubmit:v=>a(v,o),children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(A,{children:e.jsx(Y,{type:"text",value:o,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,children:e.jsx(A,{children:e.jsx(Y,{name:"name",type:"text",label:pa.find(v=>v.key===r)?.label+" *",required:!0,value:u.name,onChange:v=>w("name",v.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(A,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",value:u.description,onChange:v=>w("description",v.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})]})})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const fp="api/branchapi/Student/studentGatePass",Da="api/branchapi/Student/studentGatePassList";function yp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:25}),[r,o]=i.useState(!1),l=i.useRef(null),d=(k,S)=>{s({page:k,rowsPerPage:Number.parseInt(S,10)})},c=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],{data:y,mutate:h}=W(t?[fp,t]:null,([k,S])=>H(k,S)),u=i.useMemo(()=>{const k=Da.includes("?")?Da.endsWith("?")||Da.endsWith("&")?"":"&":"?";return`${Da}${k}page=${a.page}&per_page=${a.rowsPerPage}`},[Da,a.page,a.rowsPerPage]),{isLoading:p,error:w,data:v,mutate:b}=W(t?[u,t]:null,([k,S])=>H(k,S)),m=async k=>{const S="api/branchapi/frontoffice/deletevisitors";try{await b(deleteData(S,k,t),Ne(k)),_.success("Success! Deleted item.")}catch{_.error("Failed to delete the item.")}},j=k=>{o(k)},D=()=>{},I=[{title:"Name",dataIndex:"lastname",key:"lastname",render:(k,S)=>`${S?.lastname||""} ${S?.firstname||""}`.trim()},{title:"Class",dataIndex:"class_name",key:"class_name",render:(k,S)=>`${S?.class_name||""}-${S?.section_name||""}`},{title:"Father Name",dataIndex:"father_name",key:"father_name"},{title:"Authorized Persons",dataIndex:"authorized_persons_fullname",key:"authorized_persons_fullname"},{title:"Relation",dataIndex:"authorized_persons_relation",key:"authorized_persons_relation"},{title:"Generated Date",dataIndex:"genrated_date_time",key:"genrated_date_time"},{title:"Return Date",dataIndex:"expected_return_date_time",key:"expected_return_date_time"},{title:"Reason",dataIndex:"reason",key:"reason"},{title:"Action",key:"action",render:(k,S)=>e.jsx(n.Tag,{color:S?.status==="Generated"?"green":"blue",children:S?.status||"Pending"})},{title:"Print",key:"print",render:(k,S)=>e.jsx(te.PrinterOutlined,{style:{color:"#3892ee",cursor:"pointer"},onClick:()=>window.print()})}];return e.jsx(A,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Today Gate Pass"})}),e.jsx(A,{pt:3,children:e.jsx(n.List,{grid:{column:4,gutter:16},dataSource:y?.data||[],style:{padding:0},renderItem:k=>e.jsx(n.List.Item,{style:{padding:0},children:e.jsx(n.Card,{size:"small",style:{marginBottom:8,width:"100%"},children:e.jsxs(A,{children:[e.jsxs(n.Typography.Text,{strong:!0,children:[k?.lastname," ",k?.firstname]}),e.jsx("br",{}),e.jsxs(n.Typography.Text,{type:"secondary",children:[k?.class_name,"-",k?.section_name]}),e.jsx("br",{}),e.jsxs(n.Typography.Text,{type:"secondary",children:["Return: ",k?.expected_return_date_time]}),e.jsx("br",{}),e.jsx(ne,{type:"button",value:"Print",color:"primary",size:"small",onClick:()=>window.print(),style:{marginTop:4}})]})})})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Gate Pass List"})}),e.jsxs(A,{pt:3,children:[e.jsx(St,{data:{tableRef:l}}),e.jsx(Re,{parentCallback:d,data:{newData:v,columns:I,action:!1,ActionView:c,Loading:p,error:w,editDesign:"",deleteTodoMutation:m,open:r,DrawerUpdate:j,viewDetails:D}})]})]})})]})})}const pt=({id:t,funcName:a,disabled:s=!1})=>{const r="Data",[o,l]=i.useState(!1),d=()=>{l(!0),a(t),n.message.success(`${r} deleted successfully!`)},c=()=>{n.message.info(`Deletion of ${r} cancelled`)};return e.jsx(n.Popconfirm,{title:`Delete ${r}?`,description:`Are you sure you want to delete ${r}?`,onConfirm:d,onCancel:c,okText:"Yes",cancelText:"No",disabled:s||o,children:e.jsx(n.Button,{danger:!0,disabled:s,loading:o,icon:e.jsx(te.DeleteOutlined,{}),size:"small"})})},Xr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function gp({token:t,sampleTemplateUrl:a=Sc}){const[s,r]=i.useState({pagination:{current:1,pageSize:10}}),[o,l]=i.useState(!1),[d,c]=i.useState(null),[y,h]=i.useState(null),[u,p]=i.useState(!1),[w,v]=i.useState([]),b=`api/branchapi/Transport/routeTableList?page=${s.pagination.current}&per_page=${s.pagination.pageSize}`,m="api/branchapi/Transport/addroute",j="api/branchapi/Transport/editroute",D="api/branchapi/Transport/deleteroute",I=void 0,{isLoading:k,data:S,error:x,mutate:g}=W(t?[b,t]:null,([q,E])=>H(q,E)),C=i.useMemo(()=>!S?.data||Array.isArray(S.data)?[]:S.data?.rows||[],[S]),T=S?.data?.pagination?.total_rows||S?.pagination?.total_rows||0,R=async(q,E)=>{try{await g(Ee(q,E,t),ze(E)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},L=q=>{q.preventDefault();const E=new FormData(q.target);R(m,E),q.target.reset()},N=(q,E)=>{r(M=>({...M,pagination:{current:q,pageSize:parseInt(E,10)}}))},f=async q=>{try{await g(qe(D,q,t),Ne(q)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},P=q=>{c(q),l(!0)},O=async q=>{try{const E=await Be(j,q,t);g(E),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),c(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},$=async q=>{q.preventDefault();const E=new FormData(q.target);E.append("id",d?.id),O(E)},F=async()=>{if(!y){_.error("Please select an Excel file to upload.",{duration:1e3});return}p(!0),v([]);try{const q=new FormData;q.append("file",y);const M=await(await fetch(`${I}`,{method:"POST",headers:{Authorization:t},body:q})).json();if(M.Status==="Success"){const B=M.data?.rows||[];v(B);const z=M.data?.success_count||0,G=M.data?.failed_count||0;_.success(M.message||`Route bulk upload completed. ${z} succeeded, ${G} failed.`,{duration:1e3}),z>0&&g()}else _.error(M.message||"Failed to upload routes.",{duration:1e3})}catch(q){_.error(q?.message||"Something went wrong.",{duration:1e3})}finally{p(!1),h(null)}},U=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(q,E)=>(q.route_title||"").localeCompare(E.route_title||"")}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(q,E)=>Number(q.fare||0)-Number(E.fare||0)}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(q,E)=>(q.note||"").localeCompare(E.note||"")}},{title:"Action",key:"action",render:(q,E)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>P(E),style:{padding:2}}),e.jsx(pt,{id:E?.id,funcName:f})]})}],V=d?.route_title?`Edit ${d.route_title}`:"Edit Route";return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Upload Routes"})}),e.jsxs(A,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:q=>(h(q),!1),children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),disabled:u,children:y?y.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(n.Button,{type:"primary",onClick:F,disabled:u||!y,loading:u,children:u?"Uploading...":"Upload Routes"})})})]}),w.length>0&&e.jsxs(A,{mt:3,children:[e.jsx(Se,{level:5,children:"Upload Results"}),e.jsx(n.Table,{dataSource:w.map((q,E)=>({...q,key:E})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Title",dataIndex:"title"},{title:"Status",dataIndex:"status",render:q=>e.jsx("span",{style:{color:q==="Success"?"green":"red",fontWeight:500},children:q})},{title:"Message",dataIndex:"message"}]})]}),a&&e.jsx(A,{mt:2,children:e.jsx("a",{href:a,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Add Route"})}),e.jsx(A,{p:3,children:e.jsx("form",{onSubmit:L,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(A,{children:e.jsx(Y,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(A,{children:e.jsx(Y,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(A,{children:e.jsx(Y,{type:"text",name:"note",label:"Note"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(A,{children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",style:Xr,children:"Cancel"})]})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Route List"})}),e.jsx(A,{p:3,children:e.jsx(Re,{parentCallback:N,data:{newData:{data:C,pagination:{total_rows:T}},columns:U,columnstype:"antd",action:!1,Loading:k,error:x,deleteTodoMutation:f}})})]})})]}),e.jsx(n.Drawer,{open:o,title:V,placement:"right",width:420,onClose:()=>{l(!1),c(null)},children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"title",label:"Title",defaultValue:d?.route_title||"",required:"required"}),e.jsx(Y,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:d?.fare||"",required:"required"}),e.jsx(Y,{type:"text",name:"note",label:"Note",defaultValue:d?.note||""}),e.jsx("div",{style:{display:"none"},children:e.jsx(Y,{type:"text",name:"no_of_vehicle",label:"Note"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),c(null)},style:Xr,children:"Cancel"})]})]})})})]})}const Zr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function xp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),c=`api/branchapi/Transport/vehiclesTableList?page=${a.page}&per_page=${a.rowsPerPage}`,y="api/branchapi/Transport/addvehicles",h="api/branchapi/Transport/editvehicle",u="api/branchapi/Transport/deletevehicle",{isLoading:p,data:w,error:v,mutate:b}=W(t?[c,t]:null,([T,R])=>H(T,R)),m=async(T,R)=>{try{await b(Ee(T,R,t),ze(R)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},j=T=>{T.preventDefault();const R=new FormData(T.target);m(y,R),T.target.reset()},D=async T=>{try{await b(qe(u,T,t),Ne(T)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},I=T=>{d(T),o(!0)},k=async T=>{try{await Be(h,T,t),await b(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},S=async T=>{T.preventDefault();const R=new FormData(T.target);R.append("id",l?.id),k(R)},x=(T,R)=>{s({page:T,rowsPerPage:parseInt(R,10)})},g=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(T,R)=>T.vehicle_no.localeCompare(R.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(T,R)=>T.vehicle_model.localeCompare(R.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(T,R)=>T.seating_capacity-R.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(T,R)=>T.manufacture_year-R.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(T,R)=>T.gps_url.localeCompare(R.gps_url)},render:(T,R)=>e.jsx("span",{title:R?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:R?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(T,R)=>T.note.localeCompare(R.note)}},{title:"Action",key:"action",render:(T,R)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>I(R),style:{padding:2}}),e.jsx(pt,{id:R?.id,funcName:D})]})}],C=l?.vehicle_no?`Edit ${l.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:r,title:C,placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:S,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"number",label:"Vehicle Number",defaultValue:l?.vehicle_no||"",required:"required"}),e.jsx(Y,{type:"text",name:"model",label:"Vehicle Model",defaultValue:l?.vehicle_model||""}),e.jsx(Y,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:l?.manufacture_year||""}),e.jsx(Y,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:l?.seating_capacity||""}),e.jsx(Y,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:l?.gps_url||""}),e.jsx(Y,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Zr,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(A,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(A,{px:3,pb:2,children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"number",label:"Vehicle Number",required:"required"}),e.jsx(Y,{type:"text",name:"model",label:"Vehicle Model"}),e.jsx(Y,{type:"number",name:"manufacture_year",label:"Manufacture Year"}),e.jsx(Y,{type:"number",name:"seating_capacity",label:"Max Seating Capacity"}),e.jsx(Y,{type:"text",name:"gps_url",label:"Gps Url"}),e.jsx(Y,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",style:Zr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(A,{children:e.jsx(Re,{parentCallback:x,data:{newData:w,columns:g,columnstype:"antd",action:!1,Loading:p,error:v,deleteTodoMutation:D}})})]})})]})})]})}const bp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ei=({dataIndex:t,title:a,record:s,children:r,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});function jp({token:t}){const[a,s]=i.useState(!1),[r,o]=i.useState({pagination:{current:1,pageSize:50}}),[l,d]=i.useState(null),[c,y]=i.useState([]),h="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleDropdown",p="api/branchapi/Transport/getchechkedVehicleData",w="api/branchapi/Transport/assignedVehicleTable",v="api/branchapi/transport/assignvehicle",b="api/branchapi/Transport/deleteassignvehicle",m=l?`${p}?route_id=${l}`:null,{isLoading:j,data:D,mutate:I}=W(t?[`${w}?page=${r.pagination.current}&per_page=${r.pagination.pageSize}`,t]:null,([M,B])=>H(M,B)),{data:k}=W(t&&h?[h,t]:null,([M,B])=>H(M,B)),{data:S}=W(t&&u?[u,t]:null,([M,B])=>H(M,B)),x=t&&m?[m,t]:null,{isLoading:g,data:C}=W(x,([M,B])=>H(M,B)),{Status:T="Failed",pagination:{total_rows:R=0}={}}=D||{},{data:L=[]}=T==="Success"?D:{},N=i.useMemo(()=>{const M=k?.data??k??[];return Array.isArray(M)?M:[]},[k]),f=i.useMemo(()=>{const M=S?.data??S??[];return(Array.isArray(M)?M:[]).map(z=>{if(z==null)return null;if(typeof z=="string"||typeof z=="number")return{label:String(z),value:z};const G=z.value??z.vehicle_id??z.id??z.vehicleID,re=z.label??z.vehicle_name??z.vehicle_no??z.vehicle_number??z.name??String(G??"");return G==null||re===""?null:{label:String(re),value:G}}).filter(Boolean)},[S]),P=i.useMemo(()=>{const M=C?.data??C??[];return(Array.isArray(M)?M:[]).map(z=>z?.value??z?.vehicle_id??z?.id??z).filter(z=>z!=null)},[C]);i.useEffect(()=>{y(P)},[P,a]);const O=async(M,B,z)=>{try{await I(Ee(M,B,t),ze(B)),m&&W.mutate(x),s(G=>!G),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(G){_.error(G?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},$=M=>{M.preventDefault();const B=new FormData;B.append("route_id",l??""),c.length?c.forEach(z=>B.append("vehicle_ids[]",z)):B.append("vehicle_ids[]",""),O(v,B)},F=M=>{o(B=>({...B,pagination:{current:M,pageSize:B.pagination.pageSize}}))},U=async M=>{try{await I(qe(b,M,t),Ne(M)),m&&W.mutate(x),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},V=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(M,B,z)=>e.jsx(e.Fragment,{children:B.children.map((G,re,K)=>e.jsx("span",{children:`${G.vehicle_name} ${re+1===K.length?"":","}`},`${re}vehicle001`))})},{title:"Action",render:(M,B,z)=>e.jsx(e.Fragment,{children:e.jsx(pt,{id:B?.route_id,funcName:U})})}],q=M=>{const B=["route_id","index"];for(let z=0;z<B.length;z++)if(M[B[z]])return M[B[z]]},E=M=>{const{children:B=[]}=M||{},z=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:G=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:G=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:G=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:G=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:G=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:G=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:G=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(n.Table,{components:{body:{cell:ei}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:z,rowKey:G=>q(G)+"cell01",dataSource:B,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(A,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(A,{px:3,pb:2,children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(X,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:M=>{d(M?.value??null),s(B=>!B)}})}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:{display:"block",marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Vehicles"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:8,maxHeight:140,overflow:"auto"},children:e.jsx(n.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:f,value:c,onChange:M=>y(M),disabled:!l||g})},`check001${a}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),y([]),s(M=>!M)},style:bp,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(A,{style:{padding:"10px 16px"},children:e.jsx(n.Table,{components:{body:{cell:ei}},columns:V,bordered:!0,rowKey:M=>q(M),dataSource:Array.isArray(L)?L:[],loading:j,expandable:{expandedRowRender:E,childrenColumnName:"changed"},pagination:{current:r.pagination.current,pageSize:r.pagination.pageSize,total:R,showSizeChanger:!0,onChange:F,onShowSizeChange:(M,B)=>{o(z=>({...z,pagination:{current:1,pageSize:B}}))},showTotal:(M,B)=>`${B[0]}-${B[1]} of ${M} items`}})})]})})]})})]})}const ti={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},vs=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},oa=(t,a,s)=>{if(a==null||a==="")return null;const r=t.find(o=>String(o.value)===String(a));return r||(s?{label:String(s),value:a}:{label:String(a),value:a})},Sp=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},vp=t=>{if(t==null||t===""||t==="null"||t==="undefined")return"";if(Array.isArray(t))return t.filter(s=>s!=null&&s!==""&&String(s).toLowerCase()!=="null"&&String(s).toLowerCase()!=="undefined").join(", ");const a=String(t).trim();return!a||a.toLowerCase()==="null"||a.toLowerCase()==="undefined"?"":a};function wp({token:t,assignmentId:a,studentName:s,onClose:r,onSuccess:o}){const l="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",c="api/branchapi/Transport/getrouteDropdown",y="api/branchapi/Transport/getvehicleListByRouteIdwithCount",h="api/branchapi/Transport/getStoppageDropdown",u="api/branchapi/Transport/routeShowdata",[p,w]=i.useState(null),[v,b]=i.useState(null),[m,j]=i.useState(null),[D,I]=i.useState(ee()),[k,S]=i.useState(""),[x,g]=i.useState(0),[C,T]=i.useState(0),{data:R,isLoading:L}=W(t&&a?[`${l}?id=${a}`,t]:null,([Q,ce])=>H(Q,ce)),N=i.useMemo(()=>{if(!R||R?.Status&&R.Status!=="Success")return null;const Q=R?.data??R;return Array.isArray(Q)?Q[0]??null:Q},[R]);i.useEffect(()=>{const Q=N?.fk_route_id??N?.route_id;Q!=null&&w(Q),N?.vehicle_id!=null&&b(N.vehicle_id),N?.stop_id!=null&&j(N.stop_id),I(N?.start_date?ee(N.start_date):ee()),S(vp(N?.service_push))},[N]);const f=t&&p?`${y}?route_id=${p}`:null,P=t&&p?`${u}?id=${p}`:null,O=t&&p?`${h}?route_id=${p}`:null,{data:$}=W(t&&c?[c,t]:null,([Q,ce])=>H(Q,ce)),{data:F,isLoading:U}=W(f?[f,t]:null,([Q,ce])=>H(Q,ce)),{data:V,isLoading:q}=W(O?[O,t]:null,([Q,ce])=>H(Q,ce)),{data:E}=W(P?[P,t]:null,([Q,ce])=>H(Q,ce)),M=i.useMemo(()=>vs($),[$]),B=i.useMemo(()=>vs(F),[F]),z=i.useMemo(()=>vs(V),[V]),G=R?.data[0]?.rootCost,re=Sp(),K=s||[N?.firstname,N?.lastname].filter(Boolean).join(" ")||"",J=(Q,ce)=>{switch(ce){case"route_id":w(Q?.value??null),b(null),j(null),g(Te=>Te+1),T(Te=>Te+1);break;case"vehicle_id":b(Q?.value??null),j(null),T(Te=>Te+1);break;case"stop_id":j(Q?.value??null);break}},ae=async Q=>{if(Q.preventDefault(),!p||!v||!m){_.error("Please select Route, Vehicle and Stop",{duration:1200});return}const ce=new FormData;ce.append("id",String(a)),ce.append("student_id",String(N?.fk_student_id??N?.student_id??"")),ce.append("fk_route_id",String(p)),ce.append("vehicle_id",String(v)),ce.append("stop_id",String(m)),ce.append("rootCost",String(G??"")),ce.append("start_date",D?.isValid?.()?D.format("YYYY-MM-DD"):ee().format("YYYY-MM-DD")),ce.append("puse_service",String(k??""));try{await Be(d,ce,t),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o?.(),r?.()}catch(Te){_.error(Te?.message??"Failed to update the item.",{duration:1e3})}};if(L||!(N&&!L&&(!p||!U&&!q)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(n.Spin,{})});if(!N)return e.jsxs("div",{style:{padding:"8px 0"},children:[e.jsx("p",{style:{color:"#666",fontSize:14,marginBottom:16},children:"Unable to load assignment details. Please try again."}),e.jsx(n.Button,{type:"text",onClick:r,style:ti,children:"Close"})]});const pe=N.fk_route_id??N.route_id,_e=oa(M,pe,N.route_title),le=oa(B,N.vehicle_id,N.vehicle_name??N.vehicle_no),de=oa(z,N.stop_id,N.stop_name??N.stoppage_name);return e.jsx("form",{onSubmit:ae,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"title",label:"Student",defaultValue:K,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:N.fk_student_id??N.student_id??""}),e.jsx(X,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:oa(M,p,_e?.label)??null,onChange:Q=>J(Q,"route_id")}),e.jsx(X,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:oa(B,v,le?.label)??null,onChange:Q=>J(Q,"vehicle_id")},`edit-vehicle-${x}`),e.jsx(X,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:oa(z,m,de?.label)??null,onChange:Q=>J(Q,"stop_id")},`edit-stop-${C}`),e.jsx(Y,{type:"text",label:"Route Cost",value:G!=null?`${re}${G}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:G??""}),e.jsx(Me,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:D,onChange:Q=>I(Q)}),e.jsx(Y,{type:"text",label:"Pause Service",value:k,onChange:Q=>S(Q?.target?.value??""),placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:r,style:ti,children:"Cancel"})]})]})},`edit-${a}-${x}`)}const ai={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},_p=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Ta=t=>_p(t),Cp=t=>t||"",Ap=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Dp=t=>{const a=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return a==="page"||a==="sendpage"?"page":"drawer"},Tp=(t,a)=>{const s=a||"/TransportDashboard/EditAssignStudentTransport?id={id}",r=t?.id??"",o=encodeURIComponent(String(r));if(s.includes("{id}"))return s.replaceAll("{id}",o);if(s.includes(":id"))return s.replace(":id",o);try{const d=new URL(s,"http://localhost");if(d.searchParams.has("id"))return d.searchParams.set("id",String(r)),`${d.pathname}${d.search}${d.hash}`}catch{}const l=s.includes("?")?"&":"?";return`${s}${l}id=${o}`};function Rp({token:t,editType:a,onNavigate:s,editPagePath:r,sampleTemplateUrl:o=vc}){const d=Dp(a)==="drawer",c="api/branchapi/academy/classdropdownlist",y="api/branchapi/academy/sectionoftheClass",h="api/branchapi/Transport/routeStudentList",u="api/branchapi/Transport/getrouteDropdown",p="api/branchapi/Transport/getvehicleListByRouteIdwithCount",w="api/branchapi/Transport/getStoppageDropdown",v="api/branchapi/Transport/routeShowdata",b="api/branchapi/Transport/assignTransportRoutesStudent",m="api/branchapi/transport/removeStudentTransport",j="api/branchapi/transport/assignTransportRoutesStudentBulk",[D,I]=i.useState(null),[k,S]=i.useState(!1),[x,g]=i.useState(!1),[C,T]=i.useState(null),[R,L]=i.useState(null),[N,f]=i.useState(null),[P,O]=i.useState(null),[$,F]=i.useState(!1),[U,V]=i.useState(!1),[q,E]=i.useState({page:1,rowsPerPage:50}),[M,B]=i.useState(null),[z,G]=i.useState(!1),[re,K]=i.useState(null),[J,ae]=i.useState(null),[oe,pe]=i.useState(null),[_e,le]=i.useState(null),[de,Q]=i.useState(null),[ce,Te]=i.useState(null),[$e,ke]=i.useState(null),[Ve,Le]=i.useState(ee()),[at,Ge]=i.useState(""),[Fe,Je]=i.useState(null),[rt,fe]=i.useState(!1),[je,be]=i.useState([]),se=(xe,Ce)=>{const Xe=xe?.value??null;switch(Ce){case"class_id":pe(Xe),le(null),B(Xe?`${y}?class_id=${encodeURIComponent(String(Xe))}`:null),S(It=>!It);break;case"route_id":Q(Xe),Te(null),ke(null),ae(Xe),L(Xe?`${p}?route_id=${encodeURIComponent(String(Xe))}`:null),f(Xe?`${v}?id=${encodeURIComponent(String(Xe))}`:null),O(null),F(It=>!It),V(It=>!It);break;case"vehicle_id":Te(Xe),ke(null),O(de?`${w}?route_id=${encodeURIComponent(String(de))}`:null),V(It=>!It);break;case"stop_id":ke(Xe);break}},me=xe=>{if(d){T(xe),g(!0);return}const Ce=Tp(xe,r);if(typeof s=="function"){s(Ce,xe);return}typeof window<"u"&&Ce&&window.location.assign(Ce)},ge=()=>{g(!1),T(null)},ie=C?`Edit — ${C.firstname??""} ${C.lastname??""}`.trim():"Edit Student Transport",{data:ye}=W(t&&c?[c,t]:null,([xe,Ce])=>H(xe,Ce)),{data:Ye}=W(t&&M?[M,t]:null,([xe,Ce])=>H(xe,Ce)),{data:vt}=W(t&&R?[R,t]:null,([xe,Ce])=>H(xe,Ce)),{data:Dt}=W(t&&P?[P,t]:null,([xe,Ce])=>H(xe,Ce)),{data:gt}=W(t&&N?[N,t]:null,([xe,Ce])=>H(xe,Ce)),{data:Et}=W(t&&u?[u,t]:null,([xe,Ce])=>H(xe,Ce)),Zt=t&&D?`${D}&page=${q.page}&per_page=${q.rowsPerPage}`:null,{isLoading:he,error:we,data:ot,mutate:xt}=W(Zt?[Zt,t]:null,([xe,Ce])=>H(xe,Ce)),sn=i.useMemo(()=>Ta(ye),[ye]),rn=i.useMemo(()=>Ta(Ye),[Ye]),on=i.useMemo(()=>Ta(vt),[vt]),ln=i.useMemo(()=>Ta(Dt),[Dt]),dn=i.useMemo(()=>Ta(Et),[Et]),ue=gt?.data?.[0]?.fare??gt?.data?.fare??gt?.fare??gt?.data?.data?.[0]?.fare??gt?.data?.data?.fare;i.useEffect(()=>{ue==null||ue===""||Ge(String(ue))},[ue]);const ve=async xe=>{try{await xt(qe(m,xe,t),Ne(xe)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},Ue=async()=>{if(!Fe){_.error("Please select an Excel file to upload.",{duration:1e3});return}fe(!0),be([]);try{const xe=new FormData;xe.append("file",Fe);const Xe=await(await fetch(`${j}`,{method:"POST",headers:{Authorization:t},body:xe})).json();if(Xe.Status==="Success"){const It=Xe.data?.rows||[];be(It);const hr=Xe.data?.success_count||0,Sl=Xe.data?.failed_count||0;_.success(Xe.message||`Transport bulk upload completed. ${hr} succeeded, ${Sl} failed.`,{duration:1e3}),hr>0&&xt()}else _.error(Xe.message||"Failed to upload student transport assignments.",{duration:1e3})}catch(xe){_.error(xe?.message||"Something went wrong.",{duration:1e3})}finally{fe(!1),Je(null)}},Qe=[{title:"Route Status",key:"route_status",render:(xe,Ce)=>Ce.fk_route_id?e.jsx("span",{children:Ce.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(xe,Ce)=>Cp(Ce.start_date)},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Roll No",dataIndex:"roll_no",key:"roll_no"},{title:"Name",key:"name",render:(xe,Ce)=>`${Ce.firstname} ${Ce.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(xe,Ce)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:Ce.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(pt,{id:Ce?.id,funcName:ve}),e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>me(Ce),style:{padding:2}})]}):e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.PlusOutlined,{}),onClick:()=>ls(Ce.student_id),style:{padding:2}})})}],it=async(xe,Ce)=>{try{await xt(Ee(xe,Ce,t),ze(Ce)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),G(!1),ds()}catch{_.error("Failed to add the new item.",{duration:1e3})}},mt=xe=>{if(xe.preventDefault(),!oe||!_e){_.error("Please select Class and Section",{duration:1200});return}I(`${h}?cID=${encodeURIComponent(String(oe))}&sID=${encodeURIComponent(String(_e))}`),E(Ce=>({...Ce,page:1}))},os=(xe,Ce)=>{E({page:xe,rowsPerPage:parseInt(Ce,10)})},ls=xe=>{K(xe),G(!0)},va=xe=>{if(xe.preventDefault(),!re){_.error("Student is required",{duration:1200});return}if(!de||!ce||!$e){_.error("Please select Route, Vehicle and Stop",{duration:1300});return}const Ce=new FormData;Ce.append("student_id",String(re)),Ce.append("fk_route_id",String(de)),Ce.append("vehicle_id",String(ce)),Ce.append("stop_id",String($e)),Ce.append("start_date",Ve?.isValid?.()?Ve.format("YYYY-MM-DD"):ee().format("YYYY-MM-DD")),Ce.append("rootCost",String(at??"")),it(b,Ce)},ds=()=>{G(!1),L(null),f(null),O(null),ae(null),Q(null),Te(null),ke(null),Le(ee()),Ge(""),F(xe=>!xe),V(xe=>!xe)},jl=Ap();return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Assign Students to Transport"})}),e.jsxs(A,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:xe=>(Je(xe),!1),children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),disabled:rt,children:Fe?Fe.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(n.Button,{type:"primary",onClick:Ue,disabled:rt||!Fe,loading:rt,children:rt?"Uploading...":"Upload Students"})})})]}),o&&e.jsx(A,{mt:2,children:e.jsx("a",{href:o,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})}),je.length>0&&e.jsxs(A,{mt:3,children:[e.jsx(Se,{level:5,children:"Upload Results"}),e.jsx(n.Table,{dataSource:je.map((xe,Ce)=>({...xe,key:Ce})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Student ID",dataIndex:"student_id"},{title:"Status",dataIndex:"status",render:xe=>e.jsx("span",{style:{color:xe==="Success"?"green":"red",fontWeight:500},children:xe})},{title:"Message",dataIndex:"message"}]})]})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Search Students"})}),e.jsx(A,{p:3,children:e.jsx("form",{onSubmit:mt,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(A,{children:e.jsx(X,{options:sn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:xe=>se(xe,"class_id"),required:!0,allowSelectAll:!1,value:sn.find(xe=>String(xe.value)===String(oe))??null})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(A,{children:e.jsx(X,{options:rn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:rn.find(xe=>String(xe.value)===String(_e))??null,onChange:xe=>le(xe?.value??null)},`section1${k}`)})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(A,{display:"flex",alignItems:"center",height:"100%",mt:2,children:[e.jsx(ne,{type:"submit",value:"Search",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{I(null),B(null),pe(null),le(null),S(xe=>!xe)},style:ai,children:"Cancel"})]})})]})})})]})}),D&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(A,{p:3,children:e.jsx(Re,{parentCallback:os,data:{newData:ot,columns:Qe,columnstype:"antd",action:!1,Loading:he,error:we,deleteTodoMutation:ve,pageController:q}})})]})})]}),e.jsx(n.Drawer,{open:x,title:ie,placement:"right",width:420,destroyOnClose:!0,onClose:ge,children:C?.id&&e.jsx(wp,{token:t,assignmentId:C.id,studentName:`${C.firstname??""} ${C.lastname??""}`.trim(),onClose:ge,onSuccess:()=>xt()})}),e.jsx(n.Modal,{open:z,title:"Assign Student to Transport",onCancel:ds,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:va,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{options:dn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:dn.find(xe=>String(xe.value)===String(de))??null,onChange:xe=>se(xe,"route_id")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{options:on,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:on.find(xe=>String(xe.value)===String(ce))??null,onChange:xe=>se(xe,"vehicle_id")},`vehicle001${$}`)})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{options:ln,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:ln.find(xe=>String(xe.value)===String($e))??null,onChange:xe=>se(xe,"stop_id")},`stop001${U}`)})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:Ve,onChange:xe=>Le(xe)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{type:"text",name:"rootCost",label:"Route Cost",value:at,onChange:xe=>Ge(xe?.target?.value??"")})})}),e.jsx(n.Col,{xs:24,children:e.jsxs(A,{display:"flex",alignItems:"center",gap:12,children:[e.jsx(ne,{type:"submit",value:String(at??"").trim()?`${jl}${at} — Assign`:"Assign",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:ds,style:ai,children:"Cancel"})]})})]})})})]})}const ni={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},mn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function Ip({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,y]=i.useState(""),[h,u]=i.useState(""),[p,w]=i.useState(""),[v,b]=i.useState(!1),m=`api/branchapi/Transport/getdriverTable?page=${a.page}&per_page=${a.rowsPerPage}`,j="api/branchapi/Transport/add_driver",D="api/branchapi/Transport/edit_driver",I="api/branchapi/Transport/deletedriver",k="api/branchapi/staff/uploadDocuments",S=i.useMemo(()=>String(k).startsWith("http")?k:`${He()??""}${String(k).replace(/^\/+/,"")}`,[k]),x=He()??"",{isLoading:g,data:C,error:T,mutate:R}=W(t?[m,t]:null,([q,E])=>H(q,E)),L=async(q,E)=>{try{await Ee(q,E,t),await R(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),y("")}catch(M){_.error(M?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},N=q=>{q.preventDefault();const E=new FormData(q.target);L(j,E),q.target.reset()},f=async q=>{try{await R(qe(I,q,t),Ne(q)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},P=q=>{d(q),y(q?.image??""),o(!0)},O=async q=>{try{await Be(D,q,t),await R(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),y("")}catch(E){_.error(E?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},$=q=>{q.preventDefault();const E=new FormData(q.target);E.append("id",l?.id??""),O(E)},F=(q,E)=>{s({page:q,rowsPerPage:parseInt(E,10)})},U=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(q,E)=>String(q?.name??"").localeCompare(String(E?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(q,E)=>String(q?.Driver_licence??"").localeCompare(String(E?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(q,E)=>Number(q?.contact_number??0)-Number(E?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(q,E)=>String(q?.address??"").localeCompare(String(E?.address??""))}},{title:"Image",key:"image",width:100,render:(q,E)=>{const M=E?.image?`${x}staff/document/${E.image}`:"";return M?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(n.Image,{width:80,src:M,preview:{visible:!1,onVisibleChange:()=>{b(!0),u(M),w(E?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(q,E)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>P(E),style:{padding:2}}),e.jsx(pt,{id:E?.id,funcName:f})]})}],V=l?.name?`Edit ${l.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:r,title:V,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{o(!1),d(null),y("")},children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"name",label:"Driver Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:l?.Driver_licence??"",required:"required"}),e.jsx(Y,{type:"number",name:"contact_number",label:"Driver Contact",defaultValue:l?.contact_number??"",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:mn,children:"Address"}),e.jsx(n.Input.TextArea,{name:"address",defaultValue:l?.address??"",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:mn,children:"Image"}),e.jsx(n.Upload,{maxCount:1,action:S,headers:t?{Authorization:t}:void 0,onChange:q=>{if(q?.file?.status!=="done")return;const E=q?.file?.response,M=E?.data??E?.filename??E?.file??E?.path??"";M&&y(String(M))},children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),disabled:!S,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),y("")},style:ni,children:"Cancel"})]})]})})}),e.jsx(n.Modal,{zIndex:9999,open:v,title:p,footer:null,onCancel:()=>b(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:h})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(A,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(A,{px:3,pb:2,children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Driver Name",required:"required"}),e.jsx(Y,{type:"text",name:"Driver_licence",label:"Driver Licence",required:"required"}),e.jsx(Y,{type:"number",name:"contact_number",label:"Driver Contact",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:mn,children:"Address"}),e.jsx(n.Input.TextArea,{name:"address",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:mn,children:"Image"}),e.jsx(n.Upload,{maxCount:1,action:S,headers:t?{Authorization:t}:void 0,onChange:q=>{if(q?.file?.status!=="done")return;const E=q?.file?.response,M=E?.data??E?.filename??E?.file??E?.path??"";M&&y(String(M))},children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),disabled:!S,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",onClick:()=>y(""),style:ni,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(A,{children:e.jsx(Re,{parentCallback:F,data:{newData:C,columns:U,columnstype:"antd",action:!1,Loading:g,error:T,deleteTodoMutation:f}})})]})})]})})]})}const si={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},la={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},hn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},ri=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],fn=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function kp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(!1),[c,y]=i.useState(null),[h,u]=i.useState(null),[p,w]=i.useState(null),[v,b]=i.useState(null),[m,j]=i.useState(ee()),[D,I]=i.useState(ee()),[k,S]=i.useState("pick"),[x,g]=i.useState(!1),[C,T]=i.useState(null),[R,L]=i.useState(null),[N,f]=i.useState(!1),[P,O]=i.useState(null),[$,F]=i.useState(null),[U,V]=i.useState(null),[q,E]=i.useState(null),[M,B]=i.useState(ee()),[z,G]=i.useState(ee()),[re,K]=i.useState("pick"),J=`api/branchapi/Transport/assignRouteTimeList?page=${a.page}&per_page=${a.rowsPerPage}`,ae="api/branchapi/Transport/assignRouteTime",oe="api/branchapi/Transport/editAssignRouteTime",pe="api/branchapi/Transport/deleteAssignRouteTime",_e="api/branchapi/Transport/driverDropdown",le="api/branchapi/transport/routeTimetableShowdata",de="api/branchapi/Transport/getrouteDropdown",Q="api/branchapi/Transport/getvehicleDropdown",{isLoading:ce,data:Te,error:$e,mutate:ke}=W(t?[J,t]:null,([he,we])=>H(he,we)),{data:Ve}=W(t&&de?[de,t]:null,([he,we])=>H(he,we)),{data:Le}=W(t&&_e?[_e,t]:null,([he,we])=>H(he,we)),at=i.useMemo(()=>c?`${Q}?route_id=${c}`:null,[c,Q]),{data:Ge}=W(t&&at?[at,t]:null,([he,we])=>H(he,we)),Fe=i.useMemo(()=>fn(Ve),[Ve]),Je=i.useMemo(()=>fn(Le),[Le]),rt=i.useMemo(()=>fn(Ge),[Ge]),fe=(he,we)=>{s({page:he,rowsPerPage:parseInt(we,10)})},je=async he=>{he.preventDefault();const we=new FormData(he.target);we.set("route_id",h?.value??c??""),we.set("driver_id",p?.value??""),we.set("vehicle_id",v?.value??""),we.set("start_time",m?m.format("h:mm a"):""),we.set("drop_time",D?D.format("h:mm a"):""),we.set("type",k);try{await Ee(ae,we,t),await ke(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),he.target.reset(),y(null),u(null),w(null),b(null),d(ot=>!ot),j(ee()),I(ee()),S("pick"),o(ot=>!ot)}catch(ot){_.error(ot?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},be=async he=>{try{await qe(pe,he,t),await ke(),_.success("Success! Deleted item.",{duration:1e3})}catch(we){_.error(we?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},se=he=>{T(he),g(!0);const we=he?.id??he?.route_time_id??he?.routeId??null;L(we);const ot=he?.route_id??he?.routeId??he?.fk_route_id;O(ot??null),F(Fe.find(xt=>xt?.value===(ot??he?.route_id))??null),V(Je.find(xt=>xt?.value===(he?.driver_id??he?.driverId))??null),E(null),f(xt=>!xt),B(he?.start_time?ee(he.start_time,["h:mm a","HH:mm"]):ee()),G(he?.drop_time?ee(he.drop_time,["h:mm a","HH:mm"]):ee()),K(he?.type??"pick")},me=i.useMemo(()=>{if(!R)return null;const he=String(le).includes("?")?"&":"?";return`${le}${he}id=${encodeURIComponent(String(R))}`},[R,le]),{data:ge,isLoading:ie}=W(t&&me?[me,t]:null,([he,we])=>H(he,we)),ye=i.useMemo(()=>{const he=ge?.data??ge;return Array.isArray(he)?he[0]??null:Array.isArray(he?.data)?he.data[0]??null:he??null},[ge]),Ye=i.useMemo(()=>P?`${Q}?route_id=${P}`:null,[P,Q]),{data:vt}=W(t&&Ye?[Ye,t]:null,([he,we])=>H(he,we)),Dt=i.useMemo(()=>fn(vt),[vt]);i.useEffect(()=>{if(!ye)return;const he=ye?.route_id??ye?.fk_route_id??ye?.routeId;O(he??null),F(Fe.find(we=>we?.value===he)??null),V(Je.find(we=>we?.value===ye?.driver_id)??null),E(null),B(ye?.start_time?ee(ye.start_time,["h:mm a","HH:mm"]):ee()),G(ye?.drop_time?ee(ye.drop_time,["h:mm a","HH:mm"]):ee()),K(ye?.type??"pick"),f(we=>!we)},[Je,ye,Fe]),i.useEffect(()=>{if(!ye)return;const he=ye?.vehicle_id??ye?.vehicleId;he&&E(Dt.find(we=>we?.value===he)??null)},[ye,Dt]);const gt=async he=>{if(he.preventDefault(),!R)return;const we=new FormData(he.target);we.set("id",String(R)),we.set("route_id",$?.value??P??""),we.set("driver_id",U?.value??""),we.set("vehicle_id",q?.value??""),we.set("start_time",M?M.format("h:mm a"):""),we.set("drop_time",z?z.format("h:mm a"):""),we.set("type",re);try{await Be(oe,we,t),await ke(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),g(!1),T(null)}catch(ot){_.error(ot?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Et=[{title:"Route Name",dataIndex:"route_title",key:"route_title"},{title:"Driver Name",dataIndex:"driver_name",key:"driver_name"},{title:"Vehicle Name",dataIndex:"vehicle_name",key:"vehicle_name"},{title:"Start Time",dataIndex:"start_time",key:"start_time"},{title:"End Time",dataIndex:"drop_time",key:"drop_time"},{title:"Type",dataIndex:"type",key:"type"},{title:"Action",key:"action",render:(he,we)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>se(we),style:{padding:2}}),e.jsx(pt,{id:we?.id??we?.routeId??we?.route_time_id,funcName:be})]})}],Zt=C?.route_title?`Edit ${C.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:x,title:Zt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{g(!1),T(null),L(null),O(null),F(null),V(null),E(null)},children:e.jsx("form",{onSubmit:gt,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:ie?.6:1},children:[e.jsx(X,{options:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:$,onChange:he=>{O(he?.value??null),F(he??null),E(null),f(we=>!we)}}),e.jsx(X,{options:Je,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:U,onChange:he=>V(he??null)}),e.jsx(X,{options:Dt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:q,onChange:he=>E(he??null)},`edit-vehicle-${N}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Start Time"}),e.jsx(n.TimePicker,{value:M,onChange:he=>B(he),use12Hours:!0,format:"h:mm a",allowClear:!1,style:hn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Drop Time"}),e.jsx(n.TimePicker,{value:z,onChange:he=>G(he),use12Hours:!0,format:"h:mm a",allowClear:!1,style:hn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(n.Radio.Group,{options:ri,optionType:"button",buttonStyle:"solid",value:re,onChange:he=>K(he.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{g(!1),T(null)},style:si,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(A,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(A,{px:3,pb:2,children:e.jsx("form",{onSubmit:je,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{options:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:h,onChange:he=>{y(he?.value??null),u(he??null),b(null),d(we=>!we)},allowSelectAll:!1,required:!0}),e.jsx(X,{options:Je,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:p,onChange:he=>w(he??null),allowSelectAll:!1,required:!0}),e.jsx(X,{options:rt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:v,onChange:he=>b(he??null),allowSelectAll:!1,required:!0},`vehicle-${l}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Start Time"}),e.jsx(n.TimePicker,{value:m,onChange:he=>j(he),use12Hours:!0,format:"h:mm a",allowClear:!1,style:hn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Drop Time"}),e.jsx(n.TimePicker,{value:D,onChange:he=>I(he),use12Hours:!0,format:"h:mm a",allowClear:!1,style:hn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(n.Radio.Group,{options:ri,optionType:"button",buttonStyle:"solid",value:k,onChange:he=>S(he.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Add",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",onClick:()=>{y(null),u(null),w(null),b(null),d(he=>!he),j(ee()),I(ee()),S("pick"),o(he=>!he)},style:si,children:"Cancel"})]})]})},`form-${r}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(A,{children:e.jsx(Re,{parentCallback:fe,data:{newData:Te,columns:Et,columnstype:"antd",action:!1,Loading:ce,error:$e,deleteTodoMutation:be}})})]})})]})})]})}const Pp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ii={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},oi={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},li=({dataIndex:t,title:a,record:s,children:r,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});let di=2;function Op({token:t}){const[a,s]=i.useState([]),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,y]=i.useState({pagination:{current:1,pageSize:50}}),{isLoading:h,data:u,mutate:p}=W(t?[`api/branchapi/transport/getrouteStoppageData?page=${c.pagination.current}&per_page=${c.pagination.pageSize}`,t]:null,([O,$])=>H(O,$)),{Status:w="Failed",pagination:{total_rows:v=0}={}}=u||{},{data:b=[]}=w==="Success"?u:{},{data:m}=W(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([O,$])=>H(O,$)),j=i.useMemo(()=>{const O=m?.data??m??[];if(Array.isArray(O))return O;if(O&&typeof O=="object"){if(Array.isArray(O?.data))return O.data;if(Array.isArray(O?.data?.data))return O.data.data}return[]},[m]),{data:D}=W(t&&r?["api/branchapi/transport/getrouteStoppageData?route_id="+r,t]:null,([O,$])=>H(O,$)),{Status:I="Failed"}=D||{},k=async(O,$)=>{try{await p(Ee(O,$,t),ze($)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},S=O=>O?typeof O=="string"?O:O?.isValid?.()?O.format("h:mm a"):"":"",x=(O,$=[])=>{const F=(Array.isArray(O)?O:[]).map(q=>({id:q?.id??"",name:String(q?.stop_name??q?.name??"").trim(),pickTime:S(q?.pickup_time??q?.pickTime??q?.pickupTime),drop_time:S(q?.drop_time??q?.dropTime)})),U=F.filter(q=>q?.id!=null&&String(q.id).trim()!==""),V=F.filter(q=>!(q?.id!=null&&String(q.id).trim()!==""));return{route_id:r??"",edit_stoppage:U,add_stoppage:V,delete_stoppage:Array.isArray($)?$:[]}},g=O=>{O.preventDefault();const $="/api/branchapi/transport/addstoppageToRoute",F=x(a,l);k($,F)},C=()=>{s(O=>[...Array.isArray(O)?O:[],{idKey:di++,stop_name:"",pickup_time:ee().format("h:mm a"),drop_time:ee().format("h:mm a")}])},T=O=>{if(a.length===1)return;const $=a[O];$?.id!=null&&String($.id).trim()!==""&&!$?.idKey&&d(F=>{const U=Array.isArray(F)?F:[];return U.some(q=>String(q)===String($.id))?U:[...U,$.id]}),s(F=>{const U=[...F];return U.splice(O,1),U})},R=O=>{y($=>({...$,pagination:{current:O,pageSize:$.pagination.pageSize}}))},L=async O=>{const $="/api/branchapi/Transport/deletevehicle";try{await p(qe($,O,t),Ne(O)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}};i.useEffect(()=>{if(I==="Success"){const O=Array.isArray(D?.data)?D.data:[];O.length>0?(s(O),d([])):r&&(s([{idKey:di++,stop_name:"",pickup_time:ee().format("h:mm a"),drop_time:ee().format("h:mm a")}]),d([]))}},[I,D,r]);const N=O=>{const{children:$=[]}=O||{},F=[{title:"Stop Name",dataIndex:"stop_name",onCell:U=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:U=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:U=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(n.Table,{components:{body:{cell:li}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:F,rowKey:U=>f(U)+"cell01",dataSource:$,pagination:!1})})})},f=O=>{const $=["id","index"];for(let F=0;F<$.length;F++)if(O[$[F]])return O[$[F]]},P=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(O,$,F)=>e.jsx(e.Fragment,{children:(Array.isArray($.children)?$.children:[]).map((U,V,q)=>e.jsx("span",{children:`${U.stop_name} ${V+1===q.length?"":","}`},`${V}vehicle001`))})},{title:"Action",render:(O,$,F)=>e.jsx(e.Fragment,{children:e.jsx(pt,{id:$?.route_id,funcName:L})})}];return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(A,{pt:5,pb:1,children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(A,{px:3,pb:2,children:e.jsxs("form",{onSubmit:g,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(X,{options:j,value:j.find(O=>String(O.value)===String(r))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:O=>{o(O?.value??null),s([]),d([])},allowSelectAll:!1,required:!0})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",gap:12},children:r&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer",marginBottom:8},title:"Add Row",onClick:C,children:e.jsx(te.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(ne,{type:"submit",value:"Add",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{o(null),s([]),d([])},style:Pp,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:a.length>0&&a.map((O,$)=>{const F=O.pickup_time?ee(O.pickup_time,"h:mm a"):null,U=O.drop_time?ee(O.drop_time,"h:mm a"):null;return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr)) auto",gap:16,alignItems:"end",marginBottom:12},children:[e.jsxs("div",{children:[e.jsx(Y,{value:O.stop_name??"",type:"text",name:`stoppage[${$}][name]`,label:"Place Name*",required:"required",onChange:V=>{const q=V?.target?.value??"";s(E=>{const M=[...E];return M[$]={...M[$]??{},stop_name:q},M})}}),O?.id!=null&&String(O.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${$}][id]`,value:String(O.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ii,children:"Pick Time"}),e.jsx(n.TimePicker,{value:F,use12Hours:!0,format:"h:mm a",name:`stoppage[${$}][pickTime]`,allowClear:!1,style:oi,onChange:V=>{const q=V?V.format("h:mm a"):"";s(E=>{const M=[...E];return M[$]={...M[$]??{},pickup_time:q},M})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ii,children:"Drop Time"}),e.jsx(n.TimePicker,{value:U,use12Hours:!0,format:"h:mm a",name:`stoppage[${$}][drop_time]`,allowClear:!1,style:oi,onChange:V=>{const q=V?V.format("h:mm a"):"";s(E=>{const M=[...E];return M[$]={...M[$]??{},drop_time:q},M})}})]}),e.jsx("div",{style:{marginBottom:8},children:a.length>1&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer"},onClick:()=>T($),children:e.jsx(te.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},O.idKey?O.idKey+"exp":O.id+"exp")})})]})}),e.jsx(A,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(A,{style:{padding:"10px 16px"},children:e.jsx(n.Table,{components:{body:{cell:li}},columns:P,bordered:!0,size:"small",rowKey:O=>f(O),dataSource:b,loading:h,expandable:{expandedRowRender:N,childrenColumnName:"changed"},pagination:{current:c.pagination.current,pageSize:c.pagination.pageSize,total:v,showSizeChanger:!0,onChange:R,onShowSizeChange:(O,$)=>{y(F=>({...F,pagination:{current:1,pageSize:$}}))},showTotal:(O,$)=>`${$[0]}-${$[1]} of ${O} items`}})})]})]})}const ci={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ra=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Mp({token:t}){const[a,s]=i.useState("api/branchapi/homeworks/gethomeworklistByClassSectionBranch?"),[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(null),[c,y]=i.useState(null),[h,u]=i.useState(null),[p,w]=i.useState(null),[v,b]=i.useState(!1),[m,j]=i.useState(null),[D,I]=i.useState(null),[k,S]=i.useState(null),[x,g]=i.useState(null),[C,T]=i.useState(null),[R,L]=i.useState(null),[N,f]=i.useState(!1),[P,O]=i.useState(""),[$,F]=i.useState(""),[U,V]=i.useState(""),q=(ie,ye)=>{const Ye=ie?.value??null;switch(ye){case"class_id":d(Ye),y(null),u(null);break;case"section_id":y(Ye);break;case"subject_id":u(Ye);break}},{data:E}=W(t?["api/branchapi/academy/classdropdownlist",t]:null,([ie,ye])=>H(ie,ye)),{data:M}=W(t&&C?[C,t]:null,([ie,ye])=>H(ie,ye)),{data:B}=W(t&&R?[R,t]:null,([ie,ye])=>H(ie,ye)),z=l?`api/branchapi/academy/sectionoftheClass?class_id=${l}`:null,{data:G}=W(t&&z?[z,t]:null,([ie,ye])=>H(ie,ye)),re=l?`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${l}`:null,{data:K}=W(t&&re?[re,t]:null,([ie,ye])=>H(ie,ye)),J=i.useMemo(()=>Ra(E),[E]),ae=i.useMemo(()=>Ra(M),[M]),oe=i.useMemo(()=>Ra(B),[B]),pe=i.useMemo(()=>Ra(G),[G]),_e=i.useMemo(()=>Ra(K),[K]),le=t&&a?`${a}class_id=${l||""}&subject_id=${h||""}&section_id=${c||""}&date=${p?.format("YYYY-MM-DD")||""}&page=${r.page}&per_page=${r.rowsPerPage}`:null,{isLoading:de,error:Q,data:ce,mutate:Te}=W(le?[le,t]:null,([ie,ye])=>H(ie,ye)),$e=async(ie,ye)=>{try{await Te(Ee(ie,ye,t),ze(ye)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),Fe()}catch(Ye){console.error(Ye),_.error("Failed to add the new item.",{duration:1e3})}},ke=async ie=>{try{await Te(qe("api/student/Homework/deleteHomework",ie,t),Ne(ie)),_.success("Success! Deleted item.",{duration:1e3})}catch(ye){console.error(ye),_.error("Failed to delete the item.",{duration:1e3})}},Ve=async ie=>{try{const ye=await Be("api/student/Homework/updateHomework",ie,t);Te(ye),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),Fe()}catch(ye){console.error(ye),_.error("Failed to update the item.",{duration:1e3})}},Le=ie=>{ie.preventDefault();const ye=new FormData(ie.target),Ye=ye.get("class_id")||l,vt=ye.get("section_id")||c,Dt=ye.get("subject_id")||h,gt=p?.format("YYYY-MM-DD");s(`api/branchapi/homeworks/gethomeworklistByClassSectionBranch?class_id=${Ye||""}&subject_id=${Dt||""}&section_id=${vt||""}${gt?`&date=${gt}`:""}&`),o(Et=>({...Et,page:1}))},at=ie=>{ie.preventDefault();const ye=new FormData(ie.target);$e("api/branchapi/homeworks/addHomework",ye),V("")},Ge=async(ie,ye)=>{ie.preventDefault();const Ye=new FormData(ie.target);Ye.append("id",ye),await Ve(Ye)},Fe=()=>{b(!1),j(null),I(null),S(null),g(null),T(null),L(null),V("")},Je=ie=>{j(ie);const ye=ie?.class_id??ie?.classId??null,Ye=ie?.section_id??ie?.sectionId??null,vt=ie?.subject_id??ie?.subjectId??null;I(ye),S(Ye),g(vt),ye?(T(`api/branchapi/academy/sectionoftheClass?class_id=${ye}`),L(`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${ye}`)):(T(null),L(null)),V(ie?.file||ie?.document||""),b(!0)},rt=ie=>{const ye=ie?.value??null;I(ye),S(null),g(null),ye?(T(`api/branchapi/academy/sectionoftheClass?class_id=${ye}`),L(`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${ye}`)):(T(null),L(null))},fe=ie=>{S(ie?.value??null)},je=ie=>{g(ie?.value??null)},be=(ie,ye)=>{o({page:ie,rowsPerPage:parseInt(ye,10)})},se=()=>{f(!1),O(""),F("")},me=(ie,ye)=>{if(!ie){_.error("No document found.",{duration:1e3});return}O(ie),F(ye||"Document"),f(!0)},ge=[{title:"Date",dataIndex:"homework_date",key:"homework_date"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Title",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0},{title:"Submission Date",dataIndex:"submit_date",key:"submit_date"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Subject",dataIndex:"subject",key:"subject"},{title:"Document",key:"document",render:(ie,ye)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer"},onClick:()=>me(ye?.document_url,ye?.document),children:"View"})},{title:"Action",key:"action",render:(ie,ye)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>Je(ye),style:{padding:2}}),e.jsx(pt,{id:ye?.id,funcName:ke})]})}];return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Search Homework"})}),e.jsx(A,{p:3,children:e.jsx("form",{onSubmit:Le,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(A,{children:e.jsx(X,{options:J,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,value:J.find(ie=>String(ie.value)===String(l))??null,onChange:ie=>q(ie,"class_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(A,{children:e.jsx(X,{options:pe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,value:pe.find(ie=>String(ie.value)===String(c))??null,onChange:ie=>q(ie,"section_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(A,{children:e.jsx(X,{options:_e,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"subject_id",placeholder:"Subject",allowSelectAll:!1,value:_e.find(ie=>String(ie.value)===String(h))??null,onChange:ie=>q(ie,"subject_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(A,{children:e.jsx(Me,{Desplay:"Date",format:"YYYY-MM-DD",allowClear:!1,value:p,onChange:ie=>w(ie)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(A,{children:[e.jsx(ne,{type:"submit",value:"Search",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{s("api/branchapi/homeworks/gethomeworklistByClassSectionBranch?"),d(null),y(null),u(null),w(null)},style:ci,children:"Cancel"})]})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Homework List"})}),e.jsx(A,{p:3,children:e.jsx(Re,{parentCallback:be,data:{newData:ce,columns:ge,columnstype:"antd",action:!1,Loading:de,error:Q,deleteTodoMutation:ke,pageController:r}})})]})})]}),e.jsx(n.Drawer,{open:v,title:m?"Edit Homework":"Add Homework",placement:"right",width:600,destroyOnClose:!0,onClose:Fe,children:e.jsx("form",{onSubmit:m?ie=>Ge(ie,m.id):at,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{options:J,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,placeholder:"Select Class",value:J.find(ie=>String(ie.value)===String(D))??null,onChange:rt})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{options:ae,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,placeholder:D?"Select Section":"Select Class First",value:ae.find(ie=>String(ie.value)===String(k))??null,onChange:fe,isDisabled:!D})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{options:oe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"sub_id",required:!0,allowSelectAll:!1,placeholder:D?"Select Subject":"Select Class First",value:oe.find(ie=>String(ie.value)===String(x))??null,onChange:je,isDisabled:!D})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ee(),Desplay:"From",name:"homew_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ee(),Desplay:"Deadline",name:"submission_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{type:"text",label:"Title",name:"title",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(st,{type:"text",label:"Description",name:"description",rows:3,required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(A,{children:[e.jsx(n.Upload,{action:"https://npmapi.ubkerp.com//SuperAdmin/uploadFile",headers:{Authorization:t},maxCount:1,onChange:ie=>{if(ie.file.status==="removed"&&V(""),ie.file.status==="done"){const ye=ie.file.response?.data??ie.file.response?.file??"";V(String(ye??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:U?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:U||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(A,{children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:Fe,style:ci,children:"Cancel"})]})})})})]})})}),e.jsx(n.Modal,{open:N,onCancel:se,footer:null,width:900,closable:!0,children:e.jsxs(A,{p:3,children:[e.jsx(A,{mb:2,children:e.jsx(Se,{level:5,children:$||"View Document"})}),P?P.match(/\.pdf(\?|#|$)/i)?e.jsx("iframe",{src:P,title:$||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:P,alt:$||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(Se,{children:"No document found"})]})}),e.jsx(A,{style:{position:"fixed",bottom:24,right:24,zIndex:1e3},children:e.jsx(n.Button,{type:"primary",size:"large",onClick:()=>{j(null),I(null),S(null),g(null),T(null),L(null),V(""),b(!0)},style:{borderRadius:"50%",width:56,height:56,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:24},children:"+"})})]})}const ws=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Ep({token:t}){const[a,s]=i.useState(!1),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,y]=i.useState({page:1,rowsPerPage:10}),[h,u]=i.useState(!1),[p,w]=i.useState(""),[v,b]=i.useState(""),[m,j]=i.useState({label:"",value:""}),[D,I]=i.useState({label:"",value:""}),[k,S]=i.useState({label:"",value:""}),[x,g]=i.useState(!1),[C,T]=i.useState(!1),{data:R}=W(t?["api/branchapi/academy/classdropdownlist",t]:null,([K,J])=>H(K,J)),{data:L}=W(t&&a?[a,t]:null,([K,J])=>H(K,J)),{data:N}=W(t&&(r||!0)?[r||"api/branchapi/academy/subjecttableList",t]:null,([K,J])=>H(K,J)),f=i.useMemo(()=>ws(R),[R]),P=i.useMemo(()=>ws(L),[L]),O=i.useMemo(()=>ws(N),[N]),$=t&&l?`${l}page=${c.page}&per_page=${c.rowsPerPage}`:null,{isLoading:F,error:U,data:V,mutate:q}=W($?[$,t]:null,([K,J])=>H(K,J)),E=(K,J)=>{switch(J){case"class_id":j(K||{label:"",value:""}),I({label:"",value:""}),S({label:"",value:""}),o(`/api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${K?.value??""}`),s(`/api/branchapi/academy/sectionoftheClass?class_id=${K?.value??""}`),g(ae=>!ae),T(ae=>!ae);break;case"section_id":I(K||{label:"",value:""});break;case"subject_id":S(K||{label:"",value:""});break}},M=async K=>{K.preventDefault();const J="/api/branchapi/homeworks/gethomeworklistByClassSectionBranch",ae=new URLSearchParams;m.value&&ae.append("class_id",String(m.value)),D.value&&ae.append("section_id",String(D.value)),k.value&&ae.append("subject_id",String(k.value));const oe=ae.toString(),pe=oe?`${J}?${oe}&`:`${J}?`;y(_e=>({..._e,page:1})),d(pe),await q()},B=(K,J)=>{y({page:K,rowsPerPage:parseInt(J,10)})},z=()=>{u(!1),w(""),b("")},G=(K,J)=>{w(K),b(J||"Document"),u(!0)},re=[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Subject",dataIndex:"subject",key:"subject"},{title:"Assign By",dataIndex:"staff_name",key:"staff_name"},{title:"Title",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0},{title:"Submission",dataIndex:"total_submission",key:"total_submission"},{title:"View Document",key:"document",render:(K,J)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer"},onClick:()=>G(J.document_url,J.document),children:"View"})}];return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Submission Details"})}),e.jsx(A,{p:3,children:e.jsx("form",{onSubmit:M,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(A,{children:e.jsx(X,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,value:f.find(K=>String(K.value)===String(m.value))??null,onChange:K=>E(K,"class_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(A,{children:e.jsx(X,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,value:P.find(K=>String(K.value)===String(D.value))??null,onChange:K=>I(K||{label:"",value:""})},`sections1${x}`)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(A,{children:e.jsx(X,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"subject_id",placeholder:"Subject",allowSelectAll:!1,value:O.find(K=>String(K.value)===String(k.value))??null,onChange:K=>S(K||{label:"",value:""})},`subjects1${C}`)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(A,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})})]})})})]})}),l&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Students List"})}),e.jsx(A,{p:3,children:e.jsx(Re,{parentCallback:B,data:{newData:V,columns:re,columnstype:"antd",action:!1,Loading:F,error:U,pageController:c}})})]})})]}),e.jsx(n.Modal,{open:h,onClose:z,footer:null,width:900,children:e.jsxs(A,{p:3,children:[e.jsxs(A,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[e.jsx(Se,{level:5,children:v||"View Document"}),e.jsx(ne,{type:"button",value:"Close",color:"primary",onClick:z})]}),p?p.match(/\.pdf(\?|#|$)/i)?e.jsx("iframe",{src:p,title:v||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:p,alt:v||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(Se,{children:"No document found"})]})})]})}const Fp=(t,a)=>{const s=String(t??"").replace(/\/+$/,""),r=String(a).replace(/^\/+/,"");return`${s}/${r}`};function $p({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState(null),[o,l]=i.useState(null),[d,c]=i.useState(null),[y,h]=i.useState(null),[u,p]=i.useState(null),[w,v]=i.useState(null),[b,m]=i.useState(null),j="api/branchapi/library/bookCategorydropdown",D="api/branchapi/academy/classdropdownlist",I="api/branchapi/Academy/getClassSubjectdropdown",k="api/branchapi/library/addBook",S="api/branchapi/library/uploadcsv",{data:x}=W(a?[j,a]:null,([f,P])=>H(f,P)),{data:g}=W(a&&D?[D,a]:null,([f,P])=>H(f,P)),{data:C}=W(a&&I?[I,a]:null,([f,P])=>H(f,P)),T=i.useMemo(()=>Fp(He(),S),[S]),R=async f=>{f.preventDefault();const P=new FormData(f.target);P.set("cat_id",u?.value??""),P.set("class_id",w?.value??""),P.set("subject_id",b?.value??"");try{await Ee(k,P,a),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),f.target.reset(),p(null),v(null),m(null)}catch(O){_.error(O?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},L=async f=>{if(f.preventDefault(),!s){_.error("Please select a CSV file.",{duration:1e3});return}const P=new FormData;P.append("file",s),P.append("cat_id",o?.value??""),P.append("class_id",d?.value??""),P.append("subject_id",y?.value??"");try{const O=await We.post(T,P,{headers:{Authorization:a,"Content-type":"multipart/form-data"}});O?.data?.Status==="Failed"?_.error(String(O?.data?.msg??"Upload failed."),{duration:1e3}):(_.success(String(O?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),r(null),f.target.reset(),l(null),c(null),h(null))}catch(O){_.error(O?.response?.data?.msg??"Upload failed.",{duration:1e3})}},N=()=>{fetch("/books.csv").then(f=>{f.blob().then(P=>{const O=window.URL.createObjectURL(P);let $=document.createElement("a");$.href=O,$.download="/books.csv",$.click()})})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:e.jsx(n.Button,{type:"link",icon:e.jsx(te.DownloadOutlined,{}),onClick:N,children:"Download Sample"}),children:[e.jsx(n.Divider,{children:"Information"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:16},children:"1. Your CSV data should be in the format below. The first line of your CSV file should be the column headers as in the table example. Also make sure that your file is UTF-8 to avoid unnecessary encoding problems."}),e.jsx("form",{onSubmit:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:o,onChange:f=>l(f??null)}),e.jsx(X,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:d,onChange:f=>c(f??null)}),e.jsx(X,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:y,onChange:f=>h(f??null)}),e.jsx(Y,{type:"file",label:"Upload CSV",name:"csv",accept:".csv",onChange:f=>r(f.target.files?.[0]??null),required:!0}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Book"}),children:e.jsx("form",{onSubmit:R,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",label:"Book Name",name:"title",required:!0}),e.jsx(Y,{type:"text",label:"Author",name:"author",required:!0}),e.jsx(Y,{type:"text",label:"Publication",name:"publisher"}),e.jsx(Y,{type:"number",label:"Qty",name:"quantity",required:!0}),e.jsx(Y,{type:"number",label:"Book Price",name:"price",required:!0}),e.jsx(Y,{type:"number",label:"Fine Per Day",name:"fine",required:!0}),e.jsx(Y,{type:"text",label:"Barcode",name:"barcode"}),e.jsx(X,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:u,onChange:f=>p(f??null)}),e.jsx(X,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:w,onChange:f=>v(f??null)}),e.jsx(X,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:b,onChange:f=>m(f??null)}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})})})]})}const _s={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Cs=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Up({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState([]),[o,l]=i.useState([]),d=i.useRef(),c={selectedRowKeys:s,onChange:(ae,oe)=>{r(ae),l(oe)}},y=xa.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),h=()=>{if(!(typeof window>"u")){if(!o.length){_.error("Select at least one book to print.",{duration:1e3});return}if(!d.current){_.error("Nothing to print.",{duration:1e3});return}y?.()}},[u,p]=i.useState(!1),[w,v]=i.useState(null),[b,m]=i.useState(null),[j,D]=i.useState(null),[I,k]=i.useState(null),[S,x]=i.useState({page:1,rowsPerPage:10}),g=(ae,oe)=>{x({page:ae,rowsPerPage:parseInt(oe,10)})},C="api/branchapi/library/booktable",T="api/branchapi/library/deletebooks",R="api/branchapi/library/editbook",L=`${C}?page=${S.page}&per_page=${S.rowsPerPage}`,{isLoading:N,error:f,data:P,mutate:O}=W(a?[L,a]:null,([ae,oe])=>H(ae,oe)),$="api/branchapi/library/bookCategorydropdown",F="api/branchapi/academy/classdropdownlist",U="api/branchapi/Academy/getClassSubjectdropdown",{data:V}=W(a?[$,a]:null,([ae,oe])=>H(ae,oe)),{data:q}=W(a&&F?[F,a]:null,([ae,oe])=>H(ae,oe)),{data:E}=W(a&&U?[U,a]:null,([ae,oe])=>H(ae,oe)),M=i.useMemo(()=>Cs(V),[V]),B=i.useMemo(()=>Cs(q),[q]),z=i.useMemo(()=>Cs(E),[E]),G=async ae=>{try{await qe(T,ae,a),await O(),_.success("Success! Deleted item.",{duration:1e3})}catch(oe){_.error(oe?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},re=ae=>{v(ae??null);const oe=ae?.cat_id??ae?.fk_cat_id??ae?.category_id,pe=ae?.class_id??ae?.fk_class_id,_e=ae?.subject_id??ae?.fk_subject_id;m(M.find(le=>le?.value===oe)??null),D(B.find(le=>le?.value===pe)??null),k(z.find(le=>le?.value===_e)??null),p(!0)},K=async ae=>{ae.preventDefault();const oe=w?.id??w?.book_id??w?._id;if(!oe)return;const pe=new FormData(ae.target);pe.set("id",String(oe)),pe.set("cat_id",b?.value??""),pe.set("class_id",j?.value??""),pe.set("subject_id",I?.value??"");try{await Be(R,pe,a),await O(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),p(!1),v(null)}catch(_e){_.error(_e?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},J=i.useMemo(()=>[{title:"Name",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Publisher",dataIndex:"publish",key:"publish",width:160,responsive:["lg"]},{title:"Author",dataIndex:"author",key:"author",width:160,responsive:["lg"]},{title:"Class",dataIndex:"class_name",key:"class_name",width:140,responsive:["xl"]},{title:"Subject",dataIndex:"subject_name",key:"subject_name",width:160,responsive:["xl"]},{title:"Avl Qty",dataIndex:"available_qty",key:"available_qty",width:90},{title:"Book Price",dataIndex:"perunitcost",key:"perunitcost",width:120,responsive:["xl"]},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",width:120,responsive:["xl"]},{title:"Category",dataIndex:"cat_name",key:"cat_name",width:160,responsive:["xl"]},{title:"Action",key:"action",width:140,fixed:"right",render:(ae,oe)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>re(oe),style:{padding:2}}),e.jsx(n.Button,{type:"text",size:"small",danger:!0,onClick:()=>G(oe?.id??oe?.book_id??oe?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[M,B,G,z]);return e.jsxs("div",{style:{},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:u,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{p(!1),v(null)},children:e.jsx("form",{onSubmit:K,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Y,{label:"Book Name",name:"title",defaultValue:w?.book_title??"",required:!0}),e.jsx(Y,{label:"Author",name:"author",defaultValue:w?.author??"",required:!0}),e.jsx(Y,{label:"Publication",name:"publish",defaultValue:w?.publish??""}),e.jsx(Y,{label:"Qty",name:"quantity",type:"number",defaultValue:w?.quantity??""}),e.jsx(Y,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:w?.perunitcost??""}),e.jsx(Y,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:w?.fine_amount??""}),e.jsx(Y,{label:"Barcode",name:"barcode",defaultValue:w?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:_s,children:"Category"}),e.jsx(X,{options:M,value:b,onChange:ae=>m(ae??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:_s,children:"Class"}),e.jsx(X,{options:B,value:j,onChange:ae=>D(ae??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:_s,children:"Subject"}),e.jsx(X,{options:z,value:I,onChange:ae=>k(ae??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{p(!1),v(null)},children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:o.length>0?e.jsxs(n.Button,{type:"primary",onClick:h,children:["Print Barcode (",o.length,")"]}):null,children:e.jsx(Re,{parentCallback:g,data:{newData:P,columns:J,columnstype:"antd",action:!1,Loading:N,error:f,rowSelection:c}})}),e.jsx("div",{style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"},children:e.jsx("div",{ref:d,style:{padding:"20px"},children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-start"},children:o.map((ae,oe)=>e.jsxs("div",{style:{margin:"10px",textAlign:"center",border:"1px dashed black",padding:"10px",borderRadius:"5px",width:"fit-content"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:"bold",maxWidth:"200px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:ae.book_title}),e.jsx(po,{value:ae.barcode?String(ae.barcode):String(ae.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},oe))})})})]})}const Np=(t,a)=>{const s=String(t??"").replace(/\/+$/,""),r=String(a).replace(/^\/+/,"");return`${s}/${r}`},Ft=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},yn=t=>ee(t).add(1,"month").format("YYYY-MM-DD"),Lp=i.forwardRef(({token:t,onReturn:a},s)=>{const r=t??localStorage.getItem("authToken")??"",[o,l]=i.useState("issue"),d=o==="return",[c,y]=i.useState(!1),[h,u]=i.useState(!1),[p,w]=i.useState(null),[v,b]=i.useState([]),[m,j]=i.useState([]),[D,I]=i.useState([]),[k,S]=i.useState(0),[x,g]=i.useState(!1),[C,T]=i.useState(null),[R,L]=i.useState(null),[N,f]=i.useState(null),[P,O]=i.useState(!1),[$,F]=i.useState("Cash"),[U,V]=i.useState(""),[q,E]=i.useState(""),[M,B]=i.useState(0),[z,G]=i.useState("NO_FINE"),re=i.useRef(null),[K]=n.Form.useForm(),[J]=n.Form.useForm(),ae="api/branchapi/library/bookCategorydropdown",oe="api/branchapi/academy/classdropdownlist",pe="api/branchapi/Academy/getClassSubjectdropdown",{data:_e}=W(r?[ae,r]:null,([ue,ve])=>H(ue,ve)),{data:le}=W(r&&oe?[oe,r]:null,([ue,ve])=>H(ue,ve)),{data:de}=W(r&&pe?[pe,r]:null,([ue,ve])=>H(ue,ve)),Q=i.useMemo(()=>Ft(_e),[_e]),ce=i.useMemo(()=>Ft(le),[le]),Te=i.useMemo(()=>Ft(de),[de]),$e="api/branchapi/library/studentsearchByNameID",ke="api/branchapi/library/booksearchBybookname",Ve="api/branchapi/library/issuedBookList",Le="api/branchapi/library/issueLibrarybook",at="api/branchapi/library/returnedLibrarybook",{trigger:Ge,data:Fe}=tt($e,(ue,ve)=>Gt(ue,ve,r)),{trigger:Je,data:rt}=tt(ke,(ue,ve)=>Gt(ue,ve,r)),{trigger:fe,data:je}=tt(Ve,(ue,ve)=>Gt(ue,ve,r)),{trigger:be}=tt(d?at:Le,(ue,ve)=>Zn(ue,ve,r)),se=i.useMemo(()=>Ft(Fe),[Fe]),me=i.useMemo(()=>Ft(rt),[rt]),ge=i.useMemo(()=>Ft(je),[je]),ie=ue=>{const ve=yn(ee());b(Ue=>Ue.some(Qe=>String(Qe?.id)===String(ue?.id))?Ue:[...Ue,{...ue,return_date:ue?.return_date?ue.return_date:ve}])},ye=async()=>{console.log("Reloading IssueReturn..."),_.success("Success",{duration:1e3}),j([]),I([]),S(0),G("FINE_PAY_LATER"),await fe({id:p?.student_id})};i.useImperativeHandle(s,()=>({reloadPayLater:ye}));const Ye=ue=>{b(ve=>ve.filter(Ue=>String(Ue?.id)!==String(ue)))},vt=async ue=>{if(r){if(!ue){w(null);return}c||await Ge({id:ue})}},Dt=async({search:ue})=>{if(!r||!c)return;const ve=await Ge({id:ue}),Ue=Ft(ve);Ue.length===1&&(w(Ue[0]),await fe({id:Ue[0]?.student_id}),K.resetFields())},gt=async(ue,ve)=>{w(ve??null),b([]),j([]),I([]),S(0),G("NO_FINE"),B(0),ve?.student_id&&await fe({id:ve.student_id}),K.resetFields()},Et=async ue=>{r&&ue&&(h||await Je({book:ue}))},Zt=async({search_book:ue})=>{if(!r||!h)return;const ve=await Je({book:ue,catID:C?.value??"",sID:N?.value??"",cID:R?.value??""}),Ue=Ft(ve);Ue.length&&(ie(Ue[0]),J.resetFields())},he=(ue,ve)=>{ie(ve),J.resetFields()},we=async()=>{if(!p?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!v.length){_.error("Select at least one book.",{duration:1e3});return}const ue=await be({member_id:p.member_id,fine:!1,books:v});ue?.Status==="Success"&&(_.success(String(ue?.msg??"Success"),{duration:1e3}),b([]),w(null),j([]),I([]),S(0))},ot=async()=>{if(!p?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!D.length){_.error("Select at least one book to return.",{duration:1e3});return}if(Number(k)>0){G("FINE_PAID"),O(!0);return}const ue=await be({member_id:p.member_id,collection_type:"NO_FINE",amount:0,books:JSON.stringify(D)});ue?.Status==="Success"?(_.success(String(ue?.msg??"Success"),{duration:1e3}),j([]),I([]),S(0),await fe({id:p?.student_id})):_.error(String(ue?.msg??"Failed"),{duration:1e3})},xt=async()=>{if(!p?.member_id)return;const ue=Math.max(0,Number(k)-Number(M||0)),ve={member_id:p.member_id,collection_type:z,amount:z==="FINE_PAID"?ue:0,payment_type:$,notes:U,attchement:q,discount:M||0,books:JSON.stringify(D)},Ue=await be(ve);O(!1),Ue?.Status==="Success"?(_.success(String(Ue?.msg??"Success"),{duration:1e3}),j([]),I([]),S(0),B(0),V(""),E(""),G("NO_FINE"),await fe({id:p?.student_id})):_.error(String(Ue?.msg??"Failed"),{duration:1e3})},sn=async()=>{if(!p?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!D.length){_.error("Select at least one book to return.",{duration:1e3});return}const ue={member_id:p.member_id,collection_type:"FINE_PAY_LATER",amount:0,books:JSON.stringify(D)};a(ue)},rn=i.useMemo(()=>Np(He(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),on=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Author",dataIndex:"author",key:"author",width:180,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(ue,ve)=>e.jsx(Me,{defaultValue:ee(ve?.return_date||ee().add(30,"day")),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(Ue,Qe)=>{b(it=>it.map(mt=>String(mt?.id)===String(ve?.id)?{...mt,return_date:Qe}:mt))}})},{title:"Action",key:"action",width:120,fixed:"right",render:(ue,ve)=>e.jsx(n.Button,{type:"text",danger:!0,onClick:()=>Ye(ve?.id),children:"Remove"})}],ln={selectedRowKeys:m,onChange:(ue,ve)=>{j(ue),I(ve);const Ue=(ve??[]).reduce((Qe,it)=>Qe+Number(it?.totalfine??0),0);S(Ue)},onSelect:(ue,ve,Ue)=>{if(ve){const Qe=Ue.map(it=>({...it,return_date:it?.return_date?it.return_date:yn(it?.issue_date||ee())}));I(Qe)}},onSelectAll:(ue,ve)=>{if(ue){const Ue=ve.map(Qe=>({...Qe,return_date:Qe?.return_date?Qe.return_date:yn(Qe?.issue_date||ee())}));I(Ue)}}},dn=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Issue Date",dataIndex:"issue_date",key:"issue_date",width:140,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(ue,ve)=>{const Qe=D.find(mt=>String(mt?.id)===String(ve?.id))?.return_date||ve?.return_date,it=yn(ve?.issue_date||ee());return e.jsx(Me,{defaultValue:ee(Qe||it),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(mt,os)=>{I(ls=>ls.map(va=>String(va?.id)===String(ve?.id)?{...va,return_date:os}:va))}})}},{title:"Days",key:"days",width:100,render:(ue,ve)=>{const Qe=D.find(mt=>String(mt?.id)===String(ve?.id))?.return_date||ve?.return_date,it=ve?.issue_date;if(it&&Qe){const mt=ee(Qe).diff(ee(it),"day");return mt>=0?mt:0}return"-"}},{title:"Due Date",dataIndex:"due_date",key:"due_date",width:140,responsive:["lg"]},{title:"Fine",dataIndex:"totalfine",key:"totalfine",width:120,fixed:"right",render:ue=>e.jsxs("span",{children:["₹ ",ue]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:P,onCancel:()=>O(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(n.Radio.Group,{value:$,onChange:ue=>F(ue.target.value),options:[{label:"Cash",value:"Cash"},{label:"UPI",value:"UPI"},{label:"DD",value:"DD"},{label:"Bank",value:"Bank"},{label:"Internet Banking",value:"Internet Banking"},{label:"Cheque",value:"Cheque"}]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Note"}),e.jsx(n.Input.TextArea,{rows:3,value:U,onChange:ue=>V(ue.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(n.Upload,{action:rn,headers:{Authorization:r},maxCount:1,onChange:ue=>{if(ue.file.status==="done"){const ve=ue.file.response?.data??ue.file.response?.file??"";E(String(ve??""))}},children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(n.Input,{type:"number",value:M,onChange:ue=>B(ue.target.value),placeholder:"0"})]}),e.jsxs(n.Button,{type:"primary",onClick:xt,children:["Collect ₹",Math.max(0,Number(k)-Number(M||0))]}),e.jsx(n.Button,{onClick:()=>O(!1),children:"Cancel"})]})}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:10,children:e.jsx(n.Radio.Group,{value:o,onChange:ue=>{const ve=ue.target.value;l(ve),b([]),j([]),I([]),S(0),G("NO_FINE"),B(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"},{label:"Renewal",value:"Renewal"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(n.Col,{xs:24,md:14,children:e.jsx(n.Form,{form:K,onFinish:Dt,layout:"vertical",children:e.jsx(n.Form.Item,{name:"search",label:"Search Student",children:e.jsx(n.Space.Compact,{style:{width:"100%"},children:c?e.jsx(n.Input,{autoFocus:!0,addonBefore:e.jsxs(n.Space,{children:[e.jsx(te.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:c,onChange:ue=>y(ue.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(n.AutoComplete,{options:se,onSelect:gt,onSearch:vt,style:{width:"100%"},allowClear:!0,children:e.jsx(n.Input,{addonBefore:e.jsxs(n.Space,{children:[e.jsx(te.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:c,onChange:ue=>y(ue.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),p?e.jsxs(e.Fragment,{children:[e.jsx(n.Divider,{}),e.jsxs(n.Row,{gutter:[12,12],children:[e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Name:"})," ",p?.value??""]}),e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Card No:"})," ",p?.library_card_no??""]}),e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Member ID:"})," ",p?.member_id??""]})]})]}):null,e.jsx(n.Divider,{}),d?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:760},children:e.jsx(n.Table,{dataSource:ge,columns:dn,rowSelection:ln,pagination:!1,rowKey:ue=>ue?.id??ue?.issue_id??ue?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(n.Divider,{}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs(n.Typography.Text,{strong:!0,children:["Total Fine: ₹",k]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx(n.Button,{type:"primary",onClick:ot,disabled:!D.length,children:k>0?`Pay Now ₹ ${Math.max(0,Number(k)-Number(M||0))}`:"Return Selected"}),k>0?e.jsx(n.Button,{onClick:sn,disabled:!D.length,children:"Pay Later"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:18,children:e.jsx(n.Form,{form:J,onFinish:Zt,layout:"vertical",children:e.jsx(n.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(n.Space.Compact,{style:{width:"100%"},children:h?e.jsx(n.Input,{autoFocus:!0,disabled:!p,addonBefore:e.jsxs(n.Space,{children:[e.jsx(te.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:h,onChange:ue=>u(ue.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(n.AutoComplete,{disabled:!p,options:me,onSelect:he,onSearch:Et,style:{width:"100%"},allowClear:!0,children:e.jsx(n.Input,{addonBefore:e.jsxs(n.Space,{children:[e.jsx(te.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:h,onChange:ue=>u(ue.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(n.Button,{style:{width:"100%"},icon:e.jsx(te.FilterOutlined,{}),onClick:()=>g(!0),children:"Filter"})})]}),e.jsx(n.Drawer,{open:x,onClose:()=>g(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(X,{label:"Category",options:Q,value:C,onChange:ue=>T(ue??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(X,{label:"Class",options:ce,value:R,onChange:ue=>L(ue??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(X,{label:"Subjects",options:Te,value:N,onChange:ue=>f(ue??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(n.Button,{type:"primary",onClick:()=>g(!1),children:"Apply"})]})}),e.jsx(n.Divider,{}),e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:720},children:e.jsx(n.Table,{dataSource:v,columns:on,pagination:!1,rowKey:ue=>ue?.id??ue?.book_id??ue?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Issue",onClick:we})})]})]}),e.jsx("div",{ref:re,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}),ui=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Bp({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState({page:1,rowsPerPage:10}),[o,l]=i.useState(null),[d,c]=i.useState(null),[y,h]=i.useState(!1),[u,p]=i.useState(!1),[w,v]=i.useState(null),[b,m]=i.useState(!1),j="api/branchapi/academy/classdropdownlist",D="api/branchapi/academy/sectionoftheClass",I="api/branchapi/library/studenttableForLibrary",k="api/branchapi/library/addmembershipforStudent",S="api/branchapi/library/removemembershipforStudent",x=i.useMemo(()=>{if(!o?.value)return null;const E=D.includes("?")?"&":"?";return`${D}${E}class_id=${encodeURIComponent(String(o.value))}`},[D,o?.value]),g=i.useMemo(()=>{if(!o?.value||!d?.value)return null;const E=I.includes("?")?"&":"?";return`${I}${E}cID=${encodeURIComponent(String(o.value))}&sID=${encodeURIComponent(String(d.value))}&page=${s.page}&per_page=${s.rowsPerPage}`},[s.page,s.rowsPerPage,o?.value,d?.value,I]),{data:C}=W(a&&j?[j,a]:null,([E,M])=>H(E,M)),{data:T}=W(a&&x?[x,a]:null,([E,M])=>H(E,M)),{isLoading:R,error:L,data:N,mutate:f}=W(a&&g?[g,a]:null,([E,M])=>H(E,M)),P=i.useMemo(()=>ui(C),[C]),O=i.useMemo(()=>ui(T),[T]),$=(E,M)=>{r({page:E,rowsPerPage:parseInt(M,10)})},F=E=>{const M=E?.id??E?.student_id??E?.member_id;v(M??null),p(!0),m(B=>!B)},U=async E=>{if(E.preventDefault(),!w)return;const M=new FormData(E.target);M.set("id",String(w));try{await Ee(k,M,a),_.success("Success! Added member.",{duration:1e3,icon:"🎉"}),p(!1),v(null),await f()}catch(B){_.error(B?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},V=async E=>{try{await qe(S,E,a),_.success("Success! Removed member.",{duration:1e3}),await f()}catch(M){_.error(M?.response?.data?.msg??"Failed to remove member.",{duration:1e3})}},q=i.useMemo(()=>[{title:"Library Card No",dataIndex:"library_card_no",key:"library_card_no",width:180,ellipsis:!0,fixed:"left"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:140,responsive:["sm"]},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,responsive:["lg"]},{title:"First Name",dataIndex:"firstname",key:"firstname",width:140,responsive:["sm"]},{title:"Last Name",dataIndex:"lastname",key:"lastname",width:140,responsive:["lg"]},{title:"Class",dataIndex:"class",key:"class",width:120,responsive:["xl"]},{title:"Section",dataIndex:"section",key:"section",width:120,responsive:["xl"]},{title:"Mobile",dataIndex:"mobileno",key:"mobileno",width:140,responsive:["lg"]},{title:"Action",key:"action",width:80,fixed:"right",render:(E,M)=>(console.log("data______________",M),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:M?.library_card_no==null?e.jsx(n.Button,{type:"primary",size:"small",icon:e.jsx(te.UserAddOutlined,{}),onClick:()=>F(M)}):e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(te.DeleteOutlined,{}),onClick:()=>V(M?.id??M?.student_id??M?.member_id)})}))}],[V]);return e.jsxs("div",{style:{},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:u,title:"Add Member",onCancel:()=>{p(!1),v(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:U,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Y,{type:"text",label:"Library Card Number",name:"library_num",required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Add",color:"primary"})})]})},`add-${b}`)}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Student"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(X,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:o,onChange:E=>{l(E??null),c(null),h(M=>!M)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(X,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:E=>c(E??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${y}`),e.jsx(ne,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!o?.value||!d?.value){_.error("Select class and section.",{duration:1e3});return}r(E=>({...E,page:1}))}})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Re,{parentCallback:$,data:{newData:N,columns:q,columnstype:"antd",action:!1,Loading:R,error:L}})})]})}function qp({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState({page:1,rowsPerPage:10}),[o]=n.Form.useForm(),[l]=n.Form.useForm(),[d,c]=i.useState(!1),[y,h]=i.useState(null),u="api/branchapi/library/BookCategorytable",p="api/branchapi/library/addBookCategory",w="api/branchapi/library/editBookCategory",v="api/branchapi/library/deleteBookCategory",b=i.useMemo(()=>{const L=u.includes("?")?"&":"?";return`${u}${L}page=${s.page}&per_page=${s.rowsPerPage}`},[u,s.page,s.rowsPerPage]),{isLoading:m,error:j,data:D,mutate:I}=W(a&&b?[b,a]:null,([L,N])=>H(L,N)),k=(L,N)=>{r({page:L,rowsPerPage:parseInt(N,10)})},S=async L=>{const N=new FormData;N.set("title",L?.title??"");try{await Ee(p,N,a),_.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),o.resetFields(),await I()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to add category.",{duration:1e3})}},x=L=>{h(L??null),l.setFieldsValue({title:L?.name??""}),c(!0)},g=()=>{c(!1),h(null),l.resetFields()},C=async L=>{const N=y?.id??y?.category_id??y?.cat_id;if(!N){_.error("Missing category id.",{duration:1e3});return}const f=new FormData;f.set("id",String(N)),f.set("title",L?.title??"");try{await Be(w,f,a),_.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),g(),await I()}catch(P){_.error(P?.response?.data?.msg??P?.message??"Failed to update category.",{duration:1e3})}},T=async L=>{const N=L?.id??L?.category_id??L?.cat_id;if(!N){_.error("Missing category id.",{duration:1e3});return}try{await qe(v,N,a),_.success("Success! Deleted category.",{duration:1e3}),await I()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to delete category.",{duration:1e3})}},R=i.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(L,N)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>x(N)}),e.jsx(n.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>T(N),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(te.DeleteOutlined,{})})})]})}],[T]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:d,title:"Edit Category",onCancel:g,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:l,layout:"vertical",onFinish:C,children:[e.jsx(n.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(n.Input,{placeholder:"Enter category name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:g,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,lg:8,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:S,children:[e.jsx(n.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(n.Input,{placeholder:"Enter category name"})}),e.jsx(ne,{type:"submit",value:"Add",color:"primary"})]})})}),e.jsx(n.Col,{xs:24,lg:16,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:e.jsx(Re,{parentCallback:k,data:{newData:D,columns:R,columnstype:"antd",action:!1,Loading:m,error:j}})})})]})]})}const As=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function zp({token:t}){const[a,s]=i.useState([ee().format("YYYY-MM-DD"),ee().format("YYYY-MM-DD")]),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,y]=i.useState(null),[h,u]=i.useState(!1),[p,w]=i.useState(!1),v="api/branchapi/academy/classdropdownlist",b="api/branchapi/academy/sectionoftheClass",m="api/branchapi/library/memberDropdown",j="api/report/libraryReport/libraryReport",D=i.useMemo(()=>{if(!r?.value)return null;const F=b.includes("?")?"&":"?";return`${b}${F}class_id=${encodeURIComponent(String(r.value))}`},[b,r?.value]),I=i.useMemo(()=>{if(!r?.value)return null;const F=m.includes("?")?"&":"?",U=`${m}${F}class=${encodeURIComponent(String(r.value))}`;return l?.value?`${U}&section=${encodeURIComponent(String(l.value))}`:U},[m,r?.value,l?.value]),{isLoading:k,error:S,data:x,mutate:g}=W(t&&v?[v,t]:null,([F,U])=>H(F,U)),{data:C}=W(t&&D?[D,t]:null,([F,U])=>H(F,U)),{data:T}=W(t&&I?[I,t]:null,([F,U])=>H(F,U)),R=i.useMemo(()=>As(x),[x]),L=i.useMemo(()=>As(C),[C]),N=i.useMemo(()=>As(T),[T]),{trigger:f,data:P}=tt(j,(F,U)=>Xs(F,U,t));i.useEffect(()=>{(async()=>{w(!0);try{await f({duration:a})}finally{w(!1)}})()},[]);const O=async()=>{w(!0);try{await f({duration:a,class:r?.value??"",section:l?.value??"",student_id:c?.value??""})}finally{w(!1)}},$=[{title:"Name",dataIndex:"full_name",render:(F,U)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:U?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(F,U)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:U?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(F,U)=>e.jsxs(n.Typography.Text,{style:{fontSize:12},children:[U?.class??"","(",U?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(F,U)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:U?.book_title??""})},{title:"Issue Date",key:"date",render:(F,U,V)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:U?.issue_date??""})},{title:"Due Return Date",key:"date",render:(F,U,V)=>e.jsx(n.Tag,{color:"orange",children:U?.return_date??""})},{title:"Return Date",key:"date",render:(F,U,V)=>U?.retured_by_user?e.jsx(n.Tag,{color:"green",children:U?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(F,U,V)=>String(U?.is_returned??"")==="1"?e.jsx(n.Tag,{color:"green",children:"Return"}):e.jsx(n.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:(F,U,V)=>{const q=U?.late_fine?Number(U.late_fine):0;return q?e.jsx(n.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:q}):null}}];return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[e.jsxs(n.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Duration"}),e.jsx(n.DatePicker.RangePicker,{style:{width:"100%"},value:[ee(a[0],"YYYY-MM-DD"),ee(a[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(F,U)=>{Array.isArray(U)&&U.length===2&&s([U[0],U[1]])}})]})}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(X,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:r,onChange:F=>{o(F??null),d(null),y(null),u(U=>!U)},allowSelectAll:!1})}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(X,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:l,onChange:F=>{d(F??null),y(null)},allowSelectAll:!1},`section1${h}`)}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(X,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:F=>y(F??null),allowSelectAll:!1})}),e.jsx(n.Col,{xs:24,md:1,children:e.jsx(n.Button,{type:"primary",icon:e.jsx(te.SearchOutlined,{}),onClick:O,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(n.Table,{columns:$,pagination:!1,dataSource:Array.isArray(P?.data)?P.data:[],size:"small",rowKey:(F,U)=>F?.id??F?.issue_id??F?.fees_receipt_id??U,loading:p,scroll:{x:"max-content"},summary:F=>{const U=F.reduce((q,E)=>q+Number(E?.late_fine??0),0),V=F.reduce((q,E)=>q+Number(E?.is_returned??0),0);return e.jsxs(n.Table.Summary.Row,{children:[e.jsx(n.Table.Summary.Cell,{colSpan:4,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",F.length]})}),e.jsx(n.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(F.length-V)]})}),e.jsx(n.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",V]})}),e.jsx(n.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",U.toLocaleString("en-IN")]})})]})}})})]})]})}const pi=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],mi=[{key:"renewalHistory",label:"Renewal History"},{key:"renewalFineReport",label:"Renewal + Fine"},{key:"currentlyRenewedBooks",label:"Currently Renewed"},{key:"upcomingRenewalDue",label:"Upcoming Due"},{key:"overdueRenewalReport",label:"Overdue"},{key:"renewalLimitReport",label:"Renewal Limit"},{key:"renewalStatusReport",label:"Renewal Status"},{key:"studentWiseReport",label:"Student-wise"},{key:"bookWiseReport",label:"Book-wise"},{key:"classWiseReport",label:"Class-wise"},{key:"staffWiseReport",label:"Staff-wise"},{key:"renewalStatisticsByDate",label:"Statistics by Date"}];function Yp({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState("renewalHistory"),[o,l]=i.useState("This Month"),[d,c]=i.useState(""),[y,h]=i.useState(""),[u,p]=i.useState(7),[w,v]=i.useState(1),[b,m]=i.useState(20),[j,D]=i.useState(""),[I,k]=i.useState("DESC"),S=i.useRef(null),x=U=>{const V=new URLSearchParams;return["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(s)&&(V.set("date_range",o),o==="Custom"&&d&&y&&(V.set("from_date",d),V.set("to_date",y))),["renewalHistory","renewalFineReport","currentlyRenewedBooks","upcomingRenewalDue","overdueRenewalReport","renewalLimitReport","renewalStatusReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport"].includes(s)&&(V.set("page",String(w)),V.set("per_page",String(b))),s==="upcomingRenewalDue"&&V.set("days_ahead",String(u)),j&&V.set("sort_by",j),I&&V.set("sort_dir",I),`${U}?${V.toString()}`},g=i.useMemo(()=>{switch(s){case"renewalHistory":return x(dc);case"renewalFineReport":return x(cc);case"currentlyRenewedBooks":return x(uc);case"upcomingRenewalDue":return x(pc);case"overdueRenewalReport":return x(mc);case"renewalLimitReport":return x(hc);case"renewalStatusReport":return x(fc);case"studentWiseReport":return x(yc);case"bookWiseReport":return x(gc);case"classWiseReport":return x(xc);case"staffWiseReport":return x(bc);case"renewalStatisticsByDate":return x(jc);default:return null}},[s,o,d,y,u,w,b]),{data:C,isLoading:T}=W(a?[g,a]:null,([U,V])=>H(U,V)),R=C?.data||{},L=R?.rows||[],N=R?.pagination||{},f=U=>{r(U),v(1),m(20)},P=()=>{v(1)},O=()=>{switch(s){case"renewalHistory":case"renewalFineReport":return[{title:"Renewal ID",dataIndex:"renewal_id",key:"renewal_id"},{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Renewal No",dataIndex:"renewal_no",key:"renewal_no"},{title:"Old Due Date",dataIndex:"old_due_date",key:"old_due_date"},{title:"New Due Date",dataIndex:"new_due_date",key:"new_due_date"},{title:"Renewal Date",dataIndex:"renewal_date",key:"renewal_date"},{title:"Status",dataIndex:"status",key:"status",render:U=>e.jsx(n.Tag,{color:U==="renewed"?"green":"red",children:U})},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",render:U=>U??"-"},{title:"Paid Amount",dataIndex:"paid_amount",key:"paid_amount",render:U=>U??"-"},{title:"Due Amount",dataIndex:"due_amount",key:"due_amount",render:U=>U??"-"},{title:"Fine Status",dataIndex:"fine_payment_status",key:"fine_payment_status",render:U=>U?e.jsx(n.Tag,{color:U==="paid"?"green":U==="partial"?"orange":"red",children:U}):"-"}];case"currentlyRenewedBooks":case"upcomingRenewalDue":case"overdueRenewalReport":case"renewalLimitReport":case"renewalStatusReport":return[{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Due Date",dataIndex:"return_date",key:"return_date"},{title:"Renewal Count",dataIndex:"renewal_count",key:"renewal_count"},{title:"Max Renewal",dataIndex:"maximum_renewal",key:"maximum_renewal"},{title:"Days Remaining",dataIndex:"days_remaining",key:"days_remaining",render:U=>U??"-"},{title:"Overdue Days",dataIndex:"overdue_days",key:"overdue_days",render:U=>U??"-"},{title:"Fine",dataIndex:"fine_amount",key:"fine_amount",render:U=>U??"-"},{title:"Due",dataIndex:"due_amount",key:"due_amount",render:U=>U??"-"},{title:"Can Renew",dataIndex:"can_renew",key:"can_renew",render:U=>e.jsx(n.Tag,{color:U?"green":"red",children:U?"Yes":"No"})},{title:"Reasons",dataIndex:"reasons",key:"reasons",render:U=>Array.isArray(U)?U.join("; "):"-"}];case"studentWiseReport":return[{title:"Student ID",dataIndex:"student_id",key:"student_id"},{title:"Student Name",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Books",dataIndex:"unique_books_renewed",key:"unique_books_renewed"},{title:"First Renewal",dataIndex:"first_renewal_date",key:"first_renewal_date"},{title:"Last Renewal",dataIndex:"last_renewal_date",key:"last_renewal_date"}];case"bookWiseReport":return[{title:"Book ID",dataIndex:"book_id",key:"book_id"},{title:"Title",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Category",dataIndex:"category",key:"category"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"classWiseReport":return[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"staffWiseReport":return[{title:"Staff",dataIndex:"renewed_by",key:"renewed_by"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];case"renewalStatisticsByDate":return[{title:"Period",dataIndex:"period",key:"period"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];default:return[]}},$=["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(s),F=i.useMemo(()=>O(),[s]);return e.jsx(A,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,padding:"4px 8px",color:"#fff",display:"inline-block"}}),e.jsxs(A,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],mb:3,children:[$&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(X,{options:pi,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:pi.find(U=>U.value===o)||null,onChange:U=>l(U?.value||"This Month")})}),o==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Me,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:U=>c(U?U.format("YYYY-MM-DD"):"")})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Me,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:U=>h(U?U.format("YYYY-MM-DD"):"")})})]})]}),s==="upcomingRenewalDue"&&e.jsx(n.Col,{xs:24,md:6,children:e.jsx(X,{options:[{label:"7 Days",value:7},{label:"14 Days",value:14},{label:"30 Days",value:30}],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Days Ahead",allowSelectAll:!1,value:{label:u+" Days",value:u},onChange:U=>p(U?.value||7)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(A,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:P})})})]}),e.jsx(n.Tabs,{activeKey:s,onChange:f,items:mi})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:mi.find(U=>U.key===s)?.label||"Report"})}),e.jsxs(A,{p:3,children:[e.jsx(St,{data:{tableRef:S}}),T?e.jsx(A,{py:8,textAlign:"center",children:e.jsx(n.Typography.Text,{type:"secondary",children:"Loading report data..."})}):e.jsx(n.Table,{size:"small",dataSource:L,columns:F,loading:T,pagination:!1,bordered:!0,rowKey:U=>U.renewal_id||U.id||JSON.stringify(U),ref:S}),L.length>0&&e.jsx(n.Pagination,{current:w,pageSize:b,total:N.total_rows||L.length,onChange:(U,V)=>{v(U),m(V)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const es=t=>t??localStorage.getItem("authToken")??"",Vp=(t,a)=>{const s=String(t??""),r=String(a);return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Ke={upload:"api/branchapi/frontoffice/uploadfrontofficeDocument",academy:{classes:"api/branchapi/academy/classdropdownlist",sections:"api/branchapi/academy/sectionoftheClass"},student:{dropdown:"api/branchapi/student/studentDropdown"},vendor:{list:"api/accounts/vendor/vendorTable",add:"api/accounts/vendor/addvendor",edit:"api/accounts/vendor/editVendor",remove:"api/accounts/vendor/removecategory",dropdown:"api/accounts/vendor/vendorlist"},category:{list:"api/accounts/category/fetchcategorytable",add:"api/accounts/category/addcategory",edit:"api/accounts/category/editcategory",remove:"api/accounts/category/removecategory",dropdown:"api/accounts/category/categoryDropdown"},subCategory:{list:"api/accounts/category/fetchsubcategorytable",add:"api/accounts/category/addsubcategory",edit:"api/accounts/category/editsubcategory",remove:"api/accounts/category/removesubcategory",dropdown:"api/accounts/category/subcategoryDropdown"},unit:{list:"api/accounts/category/fetchunit",add:"api/accounts/category/addunit",edit:"api/accounts/category/editunit",remove:"api/accounts/category/removeunit",dropdown:"api/accounts/category/unitDropdown"},product:{list:"api/accounts/product/fetchproducttable",add:"api/accounts/product/addproduct",edit:"api/accounts/product/editproduct",remove:"api/accounts/product/removeproduct",dropdown:"api/accounts/product/productdropdown",search:"api/accounts/product/searchproductbyNameandBarcode",addStock:"api/accounts/product/addStock",sellProduct:"api/accounts/product/sellproduct",sellReports:"api/accounts/product/getstoreSellReports"},report:{stock:"api/report/StoreReport/stock_report"}},Wp=()=>Vp(He(),Ke.upload),Hp=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return H(l,es(r))},Xa=async(t,a,s)=>Ee(t,a,es(s)),ja=async(t,a,s)=>Be(t,a,es(s)),Za=async(t,a,s)=>qe(t,a,es(s)),Kp=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ya=({token:t,value:a,onChange:s})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:Wp(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=Kp(o?.file?.response);l&&s?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},kn=Ke.vendor,en=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>W(r&&t?[t,a,s,r]:null,([l,d,c,y])=>Hp({baseUrl:l,page:d,perPage:c},y)),Gp=({token:t,page:a=1,perPage:s=10})=>en({baseUrl:kn.list,page:a,perPage:s,token:t}),Jp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},hi=[{name:"name",label:"Name*",required:!0,type:"text"},{name:"email",label:"Email*",required:!0,type:"text"},{name:"address",label:"Address*",required:!0,type:"text"},{name:"phone",label:"Phone*",required:!0,type:"number"},{name:"business_name",label:"Brand Name*",required:!0,type:"text"},{name:"acc_number",label:"Account Number",required:!1,type:"text"},{name:"ifsc_code",label:"IFSC Code",required:!1,type:"text"},{name:"acc_holder_name",label:"Account Holder Name",required:!1,type:"text"},{name:"gst_number",label:"GST Number",required:!1,type:"text"},{name:"cin_num",label:"CIN Number",required:!1,type:"text"},{name:"upi_id",label:"UPI ID",required:!1,type:"text"}];function Qp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,y]=i.useState(""),{isLoading:h,error:u,data:p,mutate:w}=Gp({token:t,page:a.page,perPage:a.rowsPerPage}),v=async S=>{try{await w(Xa(kn.add,S,t),ze(S)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(x){_.error(x?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},b=S=>{S.preventDefault();const x=new FormData(S.target);c&&x.set("image",c),v(x),S.target.reset(),y("")},m=(S,x)=>{s({page:S,rowsPerPage:parseInt(x,10)})},j=async S=>{try{await w(Za(kn.remove,S,t),Ne(S)),_.success("Success! Deleted item.",{duration:1e3})}catch(x){_.error(x?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},D=S=>{d(S),o(!0),y("")},I=async S=>{S.preventDefault();const x=new FormData(S.target);x.set("id",String(l?.id??"")),c&&x.set("image",c);try{await ja(kn.edit,x,t),await w(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),y("")}catch(g){_.error(g?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},k=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Email",dataIndex:"email",key:"email",ellipsis:!0,responsive:["md"]},{title:"Address",dataIndex:"address",key:"address",ellipsis:!0,responsive:["lg"]},{title:"Phone",dataIndex:"phone",key:"phone",ellipsis:!0,responsive:["md"]},{title:"Branch Name",dataIndex:"business_name",key:"business_name",ellipsis:!0,responsive:["lg"]},{title:"Account Holder",dataIndex:"acc_holder_name",key:"acc_holder_name",ellipsis:!0,responsive:["xl"]},{title:"Account Number",dataIndex:"acc_number",key:"acc_number",ellipsis:!0,responsive:["xl"]},{title:"UPI ID",dataIndex:"upi_id",key:"upi_id",ellipsis:!0,responsive:["xl"]},{title:"Action",key:"action",width:100,fixed:"right",render:(S,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>D(x),style:{padding:2}}),e.jsx(pt,{id:x?.id,funcName:j})]})}],[j]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Vendor",placement:"right",width:520,onClose:()=>{o(!1),d(null),y("")},children:e.jsx("form",{onSubmit:I,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[hi.map(S=>e.jsx(Y,{type:S.type,name:S.name,label:S.label,defaultValue:l?.[S.name]??"",required:S.required?"required":void 0},S.name)),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:y})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),y("")},style:Jp,children:"Cancel"})]})]})})}),e.jsxs(A,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(A,{px:3,pb:2,children:e.jsx("form",{onSubmit:b,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[hi.map(S=>e.jsx(Y,{type:S.type,name:S.name,label:S.label,required:S.required?"required":void 0},S.name)),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:y})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:m,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:h,error:u}})})]})]})]})}const Xp=({token:t})=>e.jsx(Qp,{token:t}),Pn=Ke.product,fi=Ke.vendor.dropdown,yi=Ke.category.dropdown,Zp=Ke.subCategory.dropdown,gi=Ke.unit.dropdown,al=({token:t,page:a=1,perPage:s=10})=>en({baseUrl:Pn.list,page:a,perPage:s,token:t}),em=({token:t})=>W(t&&fi?[fi,t]:null,([s,r])=>H(s,r)),tm=({token:t})=>W(t&&yi?[yi,t]:null,([s,r])=>H(s,r)),am=({token:t})=>W(t&&gi?[gi,t]:null,([s,r])=>H(s,r)),nm=({token:t,categoryId:a})=>{const s=t&&a?`${Zp}?category_id=${encodeURIComponent(String(a))}`:null;return W(s?[s,t]:null,([o,l])=>H(o,l))},gn=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},sm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function rm({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,y]=i.useState(""),[h,u]=i.useState(""),[p,w]=i.useState(""),[v,b]=i.useState(""),[m,j]=i.useState(""),{isLoading:D,error:I,data:k,mutate:S}=al({token:t,page:a.page,perPage:a.rowsPerPage}),{data:x}=em({token:t}),{data:g}=tm({token:t}),{data:C}=am({token:t}),{data:T}=nm({token:t,categoryId:h}),R=i.useMemo(()=>gn(x),[x]),L=i.useMemo(()=>gn(g),[g]),N=i.useMemo(()=>gn(C),[C]),f=i.useMemo(()=>gn(T),[T]),P=async E=>{try{await S(Xa(Pn.add,E,t),ze(E)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(M){_.error(M?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},O=E=>{E.preventDefault();const M=new FormData(E.target);h&&M.set("fk_categoryID",String(h)),p&&M.set("fk_sub_categoryID",String(p)),v&&M.set("vendor_id",String(v)),m&&M.set("unit",String(m)),c&&M.set("image",c),P(M),E.target.reset(),y(""),u(""),w(""),b(""),j("")},$=(E,M)=>{s({page:E,rowsPerPage:parseInt(M,10)})},F=async E=>{try{await S(Za(Pn.remove,E,t),Ne(E)),_.success("Success! Deleted item.",{duration:1e3})}catch(M){_.error(M?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},U=E=>{d(E),o(!0),y(""),u(E?.fk_categoryID??E?.category_id??""),w(E?.fk_sub_categoryID??E?.sub_category_id??""),b(E?.vendor_id??""),j(E?.unit??E?.unit_id??"")},V=async E=>{E.preventDefault();const M=new FormData(E.target);M.set("id",String(l?.id??"")),h&&M.set("fk_categoryID",String(h)),p&&M.set("fk_sub_categoryID",String(p)),v&&M.set("vendor_id",String(v)),m&&M.set("unit",String(m)),c&&M.set("image",c);try{await ja(Pn.edit,M,t),await S(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),y("")}catch(B){_.error(B?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},q=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,responsive:["lg"]},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",ellipsis:!0,width:100,responsive:["md"]},{title:"Unit",dataIndex:"unit_name",key:"unit_name",ellipsis:!0,width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",ellipsis:!0,width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["xl"]},{title:"Hsn Code",dataIndex:"hsn_code",key:"hsn_code",ellipsis:!0,responsive:["xl"]},{title:"Action",key:"action",width:100,fixed:"right",render:(E,M)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>U(M),style:{padding:2}}),e.jsx(pt,{id:M?.id,funcName:F})]})}],[F]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Product",placement:"right",width:520,onClose:()=>{o(!1),d(null),y("")},children:e.jsx("form",{onSubmit:V,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx(Y,{type:"text",name:"name",label:"Product Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(X,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:E=>{const M=E?.value??"";u(M),w("")},defaultValue:h?L.find(E=>String(E?.value)===String(h)):null}),e.jsx(X,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:E=>w(E?.value??""),defaultValue:p?f.find(E=>String(E?.value)===String(p)):null}),e.jsx(Y,{type:"text",name:"barcode",label:"Barcode",defaultValue:l?.barcode??""}),e.jsx(X,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:E=>j(E?.value??""),defaultValue:m?N.find(E=>String(E?.value)===String(m)):null}),e.jsx(Y,{type:"number",name:"quantity",label:"Quantity*",defaultValue:l?.quantity??"",required:"required"}),e.jsx(Y,{type:"number",name:"price",label:"Price*",defaultValue:l?.price??"",required:"required"}),e.jsx(X,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:E=>b(E?.value??""),defaultValue:v?R.find(E=>String(E?.value)===String(v)):null}),e.jsx(Y,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:l?.hsn_code??""}),e.jsx(st,{type:"text",label:"Description",name:"description",rows:3,defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:y})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),y("")},style:sm,children:"Cancel"})]})]})})}),e.jsxs(A,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(A,{px:3,pb:2,children:e.jsx("form",{onSubmit:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Product Name*",required:"required"}),e.jsx(X,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:E=>{const M=E?.value??"";u(M),w("")}}),e.jsx(X,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:E=>w(E?.value??"")},`subcat_${h}`),e.jsx(Y,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(X,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:E=>j(E?.value??"")}),e.jsx(Y,{type:"number",name:"quantity",label:"Quantity*",required:"required"}),e.jsx(Y,{type:"number",name:"price",label:"Price*",required:"required"}),e.jsx(X,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:E=>b(E?.value??"")}),e.jsx(Y,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(st,{type:"text",label:"Description",name:"description",rows:3}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:y})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:$,data:{newData:k,columns:q,columnstype:"antd",action:!1,Loading:D,error:I}})})]})]})]})}const im=({token:t})=>e.jsx(rm,{token:t}),On=Ke.category,om=({token:t,page:a=1,perPage:s=10})=>en({baseUrl:On.list,page:a,perPage:s,token:t}),lm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function dm({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:y,data:h,mutate:u}=om({token:t,page:a.page,perPage:a.rowsPerPage}),p=async I=>{try{await u(Xa(On.add,I,t),ze(I)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(k){_.error(k?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},w=I=>{I.preventDefault();const k=new FormData(I.target);p(k),I.target.reset()},v=(I,k)=>{s({page:I,rowsPerPage:parseInt(k,10)})},b=async I=>{try{await u(Za(On.remove,I,t),Ne(I)),_.success("Success! Deleted item.",{duration:1e3})}catch(k){_.error(k?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},m=I=>{d(I),o(!0)},j=async I=>{I.preventDefault();const k=new FormData(I.target);k.set("id",String(l?.id??""));try{await ja(On.edit,k,t),await u(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(S){_.error(S?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(I,k)=>String(I?.name??"").localeCompare(String(k?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(I,k)=>String(I?.description??"").localeCompare(String(k?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(I,k)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>m(k),style:{padding:2}}),e.jsx(pt,{id:k?.id,funcName:b})]})}],[b]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Category",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"name",label:"Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:lm,children:"Cancel"})]})]})})}),e.jsxs(A,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(A,{px:3,pb:2,children:e.jsx("form",{onSubmit:w,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:v,data:{newData:h,columns:D,columnstype:"antd",action:!1,Loading:c,error:y}})})]})]})]})}const cm=({token:t})=>e.jsx(dm,{token:t}),Mn=Ke.subCategory,xi=Ke.category.dropdown,um=({token:t,page:a=1,perPage:s=10})=>en({baseUrl:Mn.list,page:a,perPage:s,token:t}),pm=({token:t})=>W(t&&xi?[xi,t]:null,([s,r])=>H(s,r)),mm=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},hm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function fm({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,y]=i.useState(""),{isLoading:h,error:u,data:p,mutate:w}=um({token:t,page:a.page,perPage:a.rowsPerPage}),{data:v}=pm({token:t}),b=i.useMemo(()=>mm(v),[v]),m=async g=>{try{await w(Xa(Mn.add,g,t),ze(g)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(C){_.error(C?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},j=g=>{g.preventDefault();const C=new FormData(g.target);C.set("status","active"),C.set("img",c||""),m(C),g.target.reset(),y("")},D=(g,C)=>{s({page:g,rowsPerPage:parseInt(C,10)})},I=async g=>{try{await w(Za(Mn.remove,g,t),Ne(g)),_.success("Success! Deleted item.",{duration:1e3})}catch(C){_.error(C?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},k=g=>{d(g),o(!0)},S=async g=>{g.preventDefault();const C=new FormData(g.target);C.set("id",String(l?.id??"")),c&&C.set("img",c);try{await ja(Mn.edit,C,t),await w(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),y("")}catch(T){_.error(T?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},x=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(g,C)=>String(g?.name??"").localeCompare(String(C?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(g,C)=>String(g?.description??"").localeCompare(String(C?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(g,C)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>k(C),style:{padding:2}}),e.jsx(pt,{id:C?.id,funcName:I})]})}],[I]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Sub Category",placement:"right",width:420,onClose:()=>{o(!1),d(null),y("")},children:e.jsx("form",{onSubmit:S,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(X,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:l?.category_id?b.find(g=>String(g?.value)===String(l.category_id)):null,allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"text",name:"name",label:"Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:y})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),y("")},style:hm,children:"Cancel"})]})]})})}),e.jsxs(A,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(A,{px:3,pb:2,children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:y})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:D,data:{newData:p,columns:x,columnstype:"antd",action:!1,Loading:h,error:u}})})]})]})]})}const ym=({token:t})=>e.jsx(fm,{token:t}),Ds=Ke.product,gm=Ke.academy.classes,xm=Ke.academy.sections,bm=Ke.student.dropdown;function Ia(t){const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]}function xn(t,a){const s=Math.trunc(Number(t)||1),r=Math.max(1,s);return!Number.isFinite(Number(a))||Number(a)<=0?r:Math.min(r,Math.trunc(Number(a)))}function lt(t){return String(t??"")}function jm({token:t}){const[a,s]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,y]=i.useState(!1),[h,u]=i.useState(""),[p,w]=i.useState([]),[v,b]=i.useState({}),[m,j]=i.useState({}),[D,I]=i.useState(!1),[k,S]=i.useState(""),[x,g]=i.useState(0),[C,T]=i.useState(""),[R,L]=i.useState(ee()),[N,f]=i.useState([]),P={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},O=!!(a&&r&&l),{data:$}=W(t?[gm,t]:null,([fe,je])=>H(fe,je)),F=i.useMemo(()=>Ia($),[$]),U=t&&a?`${xm}?class_id=${encodeURIComponent(String(a))}`:null,{data:V}=W(U?[U,t]:null,([fe,je])=>H(fe,je)),q=i.useMemo(()=>Ia(V),[V]),E=t&&a&&r?`${bm}?class=${encodeURIComponent(String(a))}&section=${encodeURIComponent(String(r))}`:null,{data:M}=W(E?[E,t]:null,([fe,je])=>H(fe,je)),B=i.useMemo(()=>Ia(M),[M]),z=O?`${Ds.list}?page=1&per_page=10000`:null,{data:G,isLoading:re}=W(t&&z?[z,t]:null,([fe,je])=>H(fe,je),{revalidateOnFocus:!1}),K=i.useMemo(()=>Ia(G),[G]),J=i.useMemo(()=>{const fe=new Map;return(Array.isArray(K)?K:[]).forEach(je=>{fe.set(lt(je?.id),je)}),fe},[K]),ae=i.useMemo(()=>{const fe=Object.entries(m||{});return fe.length===0?[]:fe.map(([je,be])=>{const se=J.get(lt(je));return se?{id:se?.id,name:se?.name,barcode:se?.barcode,stock:Number(se?.quantity||0),price:Number(se?.price||0),quantity:xn(be,Number(se?.quantity||0))}:null}).filter(Boolean)},[m,J]),oe=i.useMemo(()=>new Set(ae.map(fe=>lt(fe?.id))),[ae]),pe=i.useMemo(()=>(Array.isArray(ae)?ae:[]).reduce((je,be)=>je+Number(be?.price||0)*Number(be?.quantity||1),0),[ae]),_e=i.useMemo(()=>{const fe=Number(x||0);return!Number.isFinite(fe)||fe<=0?0:Math.min(fe,pe)},[x,pe]),le=i.useMemo(()=>Math.max(0,pe-_e),[_e,pe]),de=i.useMemo(()=>(Array.isArray(K)?K:[]).slice(0,30).map(fe=>({value:lt(fe?.id),label:`${fe?.name??""}${fe?.barcode?` • ${fe.barcode}`:""}${fe?.quantity!==void 0&&fe?.quantity!==null?` • Stock: ${fe.quantity}`:""}`,product:fe})),[K]),{trigger:Q}=tt(t&&O?Ds.search:null,(fe,{arg:je})=>Gt(fe,{arg:je},t));i.useEffect(()=>{if(!O){w([]);return}const fe=String(h||"").trim();if(fe.length<2){w(de);return}let je=!0;const be=setTimeout(async()=>{let se=[];try{if(Q){const ge=await Q({search:fe});se=Ia(ge)}}catch{se=[]}if(!Array.isArray(se)||se.length===0){const ge=fe.toLowerCase();se=(Array.isArray(K)?K:[]).filter(ie=>{const ye=String(ie?.name??"").toLowerCase(),Ye=String(ie?.barcode??"").toLowerCase();return ye.includes(ge)||Ye.includes(ge)}).slice(0,30)}const me=se.slice(0,30).map(ge=>({value:lt(ge?.id),label:`${ge?.name??""}${ge?.barcode?` • ${ge.barcode}`:""}${ge?.quantity!==void 0&&ge?.quantity!==null?` • Stock: ${ge.quantity}`:""}`,product:ge}));je&&w(me)},250);return()=>{je=!1,clearTimeout(be)}},[de,O,Q,K,h]),i.useEffect(()=>{j({}),b({}),u(""),w([]),I(!1),S(""),g(0),T(""),L(ee()),f([])},[a,r,l]);const ce=i.useCallback((fe,je=1)=>{const be=fe?.id;if(!be)return;const se=Number(fe?.quantity||0);if(se<=0){_.error("Out of stock.",{duration:1e3});return}const me=xn(je,se);j(ge=>{const ie=ge||{};return Object.prototype.hasOwnProperty.call(ie,lt(be))?(_.error("Product already added.",{duration:1e3}),ie):{...ie,[lt(be)]:me}})},[j]),Te=i.useCallback((fe,je,be)=>{j(se=>{const me=se||{},ge=lt(fe);return Object.prototype.hasOwnProperty.call(me,ge)?{...me,[ge]:xn(je,be)}:me})},[]),$e=i.useCallback(fe=>{j(je=>{const be=je||{},se=lt(fe);if(!Object.prototype.hasOwnProperty.call(be,se))return be;const me={...be};return delete me[se],me})},[]),ke=i.useCallback((fe,je,be)=>{b(se=>({...se||{},[lt(fe)]:xn(je,be)}))},[]),Ve=i.useCallback((fe,je)=>{je?.product&&ce(je.product,1),u(""),w(de)},[ce,de]),Le=i.useCallback(fe=>{if(fe.key!=="Enter")return;fe.preventDefault();const je=Array.isArray(p)&&p.length>0?p[0]:null;if(je?.product){ce(je.product,1),u(""),w(de);return}const be=String(h||"").trim().toLowerCase();if(be.length===0)return;const se=(Array.isArray(K)?K:[]).find(me=>{const ge=String(me?.name??"").toLowerCase(),ie=String(me?.barcode??"").toLowerCase();return ge.includes(be)||ie.includes(be)});se&&(ce(se,1),u(""),w(de))},[ce,de,K,p,h]),at=()=>{if(!t){_.error("Missing token.",{duration:1e3});return}if(!a){_.error("Select class.",{duration:1e3});return}if(!r){_.error("Select section.",{duration:1e3});return}if(!l){_.error("Select student.",{duration:1e3});return}if(!ae||ae.length===0){_.error("Add at least one product.",{duration:1e3});return}I(!0)},{trigger:Ge,isMutating:Fe}=tt(t?Ds.sellProduct:null,(fe,{arg:je})=>Zn(fe,{arg:je},t)),Je=async()=>{if(!k){_.error("Select payment type.",{duration:1e3});return}const fe=(Array.isArray(ae)?ae:[]).map(be=>({id:be?.id,quantity:Number(be?.quantity||1),price:Number(be?.price||0),total_price:Number(be?.total_price||0),fk_vendor_id:be?.fk_vendor_id||"",fk_categoryID:be?.fk_categoryID||"",name:be?.name||"",class_id:be?.class_id||"",fk_sub_categoryID:be?.fk_sub_categoryID||"",description:be?.description||"",min_quantity:Number(be?.min_quantity||0),storecategory:Number(be?.storecategory||0),barcode:be?.barcode||""})),je={amount:pe,class:a,section:r,student_id:l,payment_type:k,discount:_e,notes:C||"",receipt_date:R?ee(R).format("YYYY-MM-DD"):"",product:JSON.stringify(fe),total_payable_amount:pe,attchement:N[0]?.originFileObj||""};try{const se=Array.isArray(N)&&N.length>0&&N[0]?.originFileObj?(()=>{const ge=new FormData;return Object.entries(je).forEach(([ie,ye])=>{if(ie==="products"){ge.append("product",JSON.stringify(ye));return}ge.append(ie,String(ye??""))}),ge.append("attachment",N[0].originFileObj),ge})():je,me=await Ge(se);me?.Status==="Success"?(_.success("Success! Product sold.",{duration:1e3}),I(!1),j({}),b({}),u(""),w(de),S(""),g(0),T(""),L(ee()),f([])):_.error(me?.msg??"Failed to submit.",{duration:1e3})}catch{_.error("Failed to submit.",{duration:1e3})}},rt=i.useMemo(()=>[{title:"Product Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:160},{title:"Stock",dataIndex:"quantity",key:"quantity",width:110},{title:"Price",dataIndex:"price",key:"price",width:120},{title:"Quantity",key:"quantity",width:160,render:(fe,je)=>{const be=lt(je?.id),se=Number(je?.quantity||0),me=oe.has(be),ge=(me?m?.[be]:v?.[be])??1;return e.jsx(n.InputNumber,{min:1,max:Number.isFinite(se)&&se>0?se:void 0,value:ge,onChange:ie=>{me?Te(be,ie,se):ke(be,ie,se)},disabled:se<=0})}},{title:"Amount",key:"amount",width:140,render:(fe,je)=>{const be=lt(je?.id),se=(oe.has(be)?m?.[be]:v?.[be])??1;return Number(je?.price||0)*Number(se||1)}},{title:"Action",key:"action",width:120,render:(fe,je)=>{const be=lt(je?.id),se=Number(je?.quantity||0),me=oe.has(be),ge=(me?m?.[be]:v?.[be])??1;return me?e.jsx(n.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(te.DeleteOutlined,{}),onClick:()=>$e(be),style:{padding:2}}):e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.PlusOutlined,{}),disabled:se<=0,onClick:()=>ce(je,ge),style:{padding:2}})}}],[ce,oe,m,v,$e,ke,Te]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(A,{pt:5,pb:2,children:[e.jsxs(A,{style:{padding:"12px 16px"},children:[e.jsx(A,{children:"Sell Product"}),e.jsx(n.Card,{style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(X,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:fe=>{const je=fe?.value??"";s(je),o(""),d(""),y(be=>!be)}}),e.jsx(X,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:fe=>{const je=fe?.value??"";o(je),d("")}},`section_${c}`),e.jsx(X,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:fe=>d(fe?.value??"")})]})})]}),e.jsx("div",{style:{padding:"0 16px"},children:e.jsxs(n.Card,{style:{borderRadius:16,marginTop:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(260px, 520px) 1fr",gap:12,alignItems:"center",marginBottom:12},children:[e.jsx(A,{style:{marginTop:12},children:"Product Section"}),e.jsx(n.AutoComplete,{value:h,options:p,onSearch:u,onFocus:()=>{O&&String(h||"").trim().length<2&&w(de)},onSelect:Ve,disabled:!O,children:e.jsx(n.Input,{placeholder:"Search by product name or barcode",onKeyDown:Le,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",Tt(pe)]})]}),e.jsx(n.Table,{rowKey:fe=>lt(fe?.id),columns:rt,dataSource:K,loading:re,size:"small",bordered:!0,pagination:{pageSize:50,showSizeChanger:!0,pageSizeOptions:[25,50,100,200]},scroll:{x:"max-content"}}),e.jsxs("div",{style:{position:"sticky",bottom:0,background:"#fff",paddingTop:12,marginTop:12,borderTop:"1px solid #f0f0f0"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Selected Items"}),e.jsx("span",{children:ae.length})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700,marginTop:6},children:[e.jsx("span",{children:"Total Amount"}),e.jsx("span",{children:Tt(pe)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(ne,{type:"button",value:"Submit",disabled:!O||ae.length===0,onClick:at,style:{flex:1,minWidth:140}}),e.jsx(n.Button,{type:"text",style:P,onClick:()=>{j({}),b({}),u(""),w(de)},disabled:ae.length===0,children:"Clear"})]})]})]})})]}),e.jsx(n.Modal,{open:D,title:"Payment",onCancel:()=>I(!1),onOk:Je,confirmLoading:Fe,okText:"Submit",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Payment Type"}),e.jsx(n.Select,{value:k||void 0,onChange:S,placeholder:"Select payment type",style:{width:"100%"},options:[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"Bank",label:"Bank"},{value:"Cheque",label:"Cheque"},{value:"DD",label:"DD"},{value:"Internet Banking",label:"Internet Banking"}]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Receipt Date"}),e.jsx(n.DatePicker,{value:R,onChange:fe=>L(fe),style:{width:"100%"},format:"YYYY-MM-DD"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Discount"}),e.jsx(n.InputNumber,{min:0,max:pe,value:x,onChange:fe=>g(Number(fe||0)),style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Attachment"}),e.jsx(n.Upload,{fileList:N,beforeUpload:()=>!1,onChange:({fileList:fe})=>f((fe||[]).slice(-1)),maxCount:1,children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),children:"Upload"})})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Notes"}),e.jsx(n.Input.TextArea,{value:C,onChange:fe=>T(fe.target.value),rows:3})]}),e.jsx(n.Card,{style:{borderRadius:12,background:"#fafcff"},children:e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Total Amount"}),e.jsx("span",{children:Tt(pe)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:Tt(_e)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Net Amount"}),e.jsx("span",{children:Tt(le)})]})]})})]})})]})}const Sm=({token:t})=>e.jsx(jm,{token:t}),En=Ke.unit,vm=({token:t,page:a=1,perPage:s=10})=>en({baseUrl:En.list,page:a,perPage:s,token:t}),wm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function _m({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:y,data:h,mutate:u}=vm({token:t,page:a.page,perPage:a.rowsPerPage}),p=async I=>{try{await u(Xa(En.add,I,t),ze(I)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(k){_.error(k?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},w=I=>{I.preventDefault();const k=new FormData(I.target);p(k),I.target.reset()},v=(I,k)=>{s({page:I,rowsPerPage:parseInt(k,10)})},b=async I=>{try{await u(Za(En.remove,I,t),Ne(I)),_.success("Success! Deleted item.",{duration:1e3})}catch(k){_.error(k?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},m=I=>{d(I),o(!0)},j=async I=>{I.preventDefault();const k=new FormData(I.target);k.set("id",String(l?.id??""));try{await ja(En.edit,k,t),await u(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(S){_.error(S?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(I,k)=>String(I?.name??"").localeCompare(String(k?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(I,k)=>String(I?.description??"").localeCompare(String(k?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(I,k)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>m(k),style:{padding:2}}),e.jsx(pt,{id:k?.id,funcName:b})]})}],[b]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Unit",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"name",label:"Unit Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:wm,children:"Cancel"})]})]})})}),e.jsxs(A,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(A,{px:3,pb:2,children:e.jsx("form",{onSubmit:w,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Unit Name*",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Se,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:v,data:{newData:h,columns:D,columnstype:"antd",action:!1,Loading:c,error:y}})})]})]})]})}const Cm=({token:t})=>e.jsx(_m,{token:t}),Am=Ke.product.sellReports,Dm=Ke.academy.classes,Tm=Ke.academy.sections,Rm=Ke.student.dropdown,bi=t=>{const a=Number(t??0);return Number.isFinite(a)?a.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function Im({token:t}){const a=i.useRef(null),[s,r]=i.useState(null),[o,l]=i.useState(""),[d,c]=i.useState(""),[y,h]=i.useState(""),[u,p]=i.useState(!1),w=f=>{const P=f?.data?.data??f?.data??f??[];return Array.isArray(P)?P:Array.isArray(P?.data)?P.data:[]},{data:v}=W(t?[Dm,t]:null,([f,P])=>H(f,P)),b=i.useMemo(()=>w(v),[v]),m=t&&o?`${Tm}?class_id=${encodeURIComponent(String(o))}`:null,{data:j}=W(m?[m,t]:null,([f,P])=>H(f,P)),D=i.useMemo(()=>w(j),[j]),I=t&&o&&d?`${Rm}?class=${encodeURIComponent(String(o))}&section=${encodeURIComponent(String(d))}`:null,{data:k}=W(I?[I,t]:null,([f,P])=>H(f,P)),S=i.useMemo(()=>w(k),[k]),{trigger:x,isMutating:g,data:C}=tt(Am,(f,{arg:P})=>Xs(f,{arg:P},t));i.useEffect(()=>{const P=new Date().toISOString().slice(0,10);x({duration:[P,P]})},[x]);const T=i.useMemo(()=>{const f=C?.data??C??[];return Array.isArray(f)?f:[]},[C]),R=f=>{const P=Array.isArray(f?.product_details)?f.product_details:[];return P.length===0?null:e.jsx(n.Table,{size:"small",bordered:!0,pagination:!1,rowKey:O=>`${f?.receipt_id??"r"}_${O?.product_name??O?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:O=>bi(O)}],dataSource:P})},L=[{title:"Receipt No",dataIndex:"receipt_no",key:"receipt_no"},{title:"Date",dataIndex:"receipt_date",key:"receipt_date"},{title:"Amount",dataIndex:"receipt_amount",key:"receipt_amount",render:f=>bi(f)}],N=async()=>{if(!s||s.length!==2)return;const[f,P]=s;await x({duration:[f.format("YYYY-MM-DD"),P.format("YYYY-MM-DD")],class:o||"",section:d||"",student_id:y||""})};return e.jsx("div",{children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,lg:8,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Filters"}),style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Duration"}),e.jsx(n.DatePicker.RangePicker,{value:s,onChange:r,style:{width:"100%"}})]}),e.jsx(X,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:f=>{const P=f?.value??"";l(P),c(""),h(""),p(O=>!O)}}),e.jsx(X,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:f=>{const P=f?.value??"";c(P),h("")}},`section_${u}`),e.jsx(X,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:f=>h(f?.value??"")}),e.jsx(ne,{type:"button",value:g?"Searching...":"Search",disabled:g,onClick:N,style:{width:"100%"}})]})})}),e.jsx(n.Col,{xs:24,lg:16,children:e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Sell Reports"}),e.jsx(St,{data:{tableRef:a}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:g,rowKey:f=>String(f?.receipt_id??f?.receipt_no??Math.random()),columns:L,expandable:{expandedRowRender:R},dataSource:T,pagination:{pageSize:20}})]})})})]})})}const km=({token:t})=>e.jsx(Im,{token:t}),Pm=Ke.product;function Om({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState([]),[l,d]=i.useState([]),[c,y]=i.useState(!1),[h,u]=i.useState(!1),[p,w]=i.useState(null),[v,b]=i.useState(0),[m,j]=i.useState(null),[D,I]=i.useState(""),k=i.useRef(null),S=xa.useReactToPrint({contentRef:k,documentTitle:"Stock Barcodes"}),{isLoading:x,error:g,data:C,mutate:T}=al({token:t,page:a.page,perPage:a.rowsPerPage}),R=($,F)=>{s({page:$,rowsPerPage:parseInt(F,10)})},L={selectedRowKeys:r,onChange:($,F)=>{o($),d(F)}},N=$=>{w($),b(Number($?.quantity??0)),j(null),I(""),y(!0)},f=()=>{y(!1),w(null),b(0),j(null),I("")},P=async()=>{if(!p?.id)return;u(!0);const $=new FormData;$.append("product_id",String(p.id)),$.append("qty",String(v??0)),m&&$.append("tran_date",m.format("YYYY-MM-DD")),D&&$.append("remarks",D);try{const F=await ja(Pm.addStock,$,t);F?.Status==="Success"?(_.success("Success! Updated quantity.",{duration:1e3}),f(),await T()):_.error(F?.msg??"Failed to update quantity.",{duration:1e3})}catch{_.error("Failed to update quantity.",{duration:1e3})}finally{u(!1)}},O=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",width:100},{title:"Unit",dataIndex:"unit_name",key:"unit_name",width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["lg"]},{title:"Action",key:"action",width:160,fixed:"right",render:($,F)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(n.Button,{size:"small",onClick:()=>N(F),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:p?.name?`Update Stock: ${p.name}`:"Update Stock",open:c,onCancel:f,onOk:P,okButtonProps:{loading:h},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Quantity"}),e.jsx(n.InputNumber,{min:0,style:{width:"100%"},value:v,onChange:$=>b($??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{style:{width:"100%"},value:m,onChange:j})]}),e.jsx(st,{label:"Remarks",name:"remarks",rows:3,value:D,onChange:$=>I($.target.value)})]})}),e.jsxs(A,{pt:5,pb:2,children:[e.jsxs(A,{children:["Manage Stock",e.jsx(ne,{type:"button",value:"Print Barcodes",disabled:!l||l.length===0,onClick:()=>S?.(),style:{minWidth:170}})]}),e.jsx(A,{style:{padding:"12px 16px"},children:e.jsx(n.Card,{style:{borderRadius:16},children:e.jsx(Re,{parentCallback:R,data:{newData:C,columns:O,columnstype:"antd",action:!1,Loading:x,error:g,rowSelection:L}})})})]}),e.jsx("div",{style:{position:"absolute",left:-1e4,top:0},children:e.jsx("div",{ref:k,children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,padding:24},children:(Array.isArray(l)?l:[]).map($=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:$?.name??""}),e.jsx(po,{value:String($?.barcode??$?.id??""),height:50,width:1.6,displayValue:!0})]},$?.id??$?.barcode??$?.name))})})})]})}const Mm=({token:t})=>e.jsx(Om,{token:t}),Em=Ke.report.stock,Fm=Ke.product.dropdown,$m=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Um({token:t}){const a=i.useRef(null),[s,r]=i.useState(null),[o,l]=i.useState(""),{data:d}=W(t?[Fm,t]:null,([b,m])=>H(b,m)),c=i.useMemo(()=>$m(d),[d]),{trigger:y,isMutating:h,data:u}=tt(Em,(b,{arg:m})=>Xs(b,{arg:m},t));i.useEffect(()=>{const m=new Date().toISOString().slice(0,10);y({duration:[m,m]})},[y]);const p=i.useMemo(()=>{const b=u?.data??u??[];return(Array.isArray(b)?b:[]).flatMap(j=>(Array.isArray(j?.ledger)?j.ledger:[]).map((D,I)=>({key:`${j.product_id??j.product_name??"p"}-${I}`,date:D?.date,product:j?.product_name,opening:D?.opening,inward:D?.inward,outward:D?.outward,closing:D?.closing})))},[u]),w=[{title:"Date",dataIndex:"date",key:"date"},{title:"Product",dataIndex:"product",key:"product"},{title:"Opening",dataIndex:"opening",key:"opening"},{title:"Inward",dataIndex:"inward",key:"inward"},{title:"Outward",dataIndex:"outward",key:"outward"},{title:"Closing",dataIndex:"closing",key:"closing",render:b=>e.jsx("span",{style:{color:Number(b)<0?"red":"green"},children:b})}],v=async()=>{if(!s||s.length!==2)return;const[b,m]=s;await y({duration:[b.format("YYYY-MM-DD"),m.format("YYYY-MM-DD")],product_id:o||""})};return e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Stock Report"}),style:{borderRadius:16},children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",marginBottom:16,flexWrap:"wrap"},children:[e.jsx(n.DatePicker.RangePicker,{value:s,onChange:r}),e.jsxs("select",{value:o,onChange:b=>l(b.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),c.map(b=>e.jsx("option",{value:String(b?.value??""),children:String(b?.label??"")},String(b?.value??b?.id??b?.label)))]}),e.jsx(n.Button,{type:"primary",onClick:v,loading:h,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(St,{data:{tableRef:a}})})]}),e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:h,rowKey:"key",columns:w,dataSource:p,pagination:{pageSize:50}})]})]})}const Nm=({token:t})=>e.jsx(Um,{token:t}),ji=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],kt={total_packages:124,total_downloads:45892,active_packages:118,deprecated_packages:6,pending_approval:3,published_this_month:12,published_this_week:4,packages_needing_update:8,packages_with_issues:2},Si=[{npm_id:"NPM-001",package_name:"@ubk/erp-core",version:"1.2.1",description:"Core ERP utilities and shared types",author:"UBK Infotech",repository:"https://github.com/ubk/erp-core",license:"MIT",status:"published",created_at:"2024-01-15",updated_at:"2025-06-20"},{npm_id:"NPM-002",package_name:"@ubk/erp-components",version:"2.0.0",description:"Reusable Ant Design ERP component library",author:"UBK Infotech",repository:"https://github.com/ubk/erp-components",license:"ISC",status:"published",created_at:"2024-03-10",updated_at:"2025-08-01"},{npm_id:"NPM-003",package_name:"@ubk/erp-api-client",version:"0.9.5",description:"Axios-based API client for UBK ERP backends",author:"UBK Infotech",repository:"https://github.com/ubk/erp-api-client",license:"MIT",status:"draft",created_at:"2025-05-22",updated_at:"2025-07-14"},{npm_id:"NPM-004",package_name:"@ubk/erp-hooks",version:"1.1.0",description:"Custom React hooks for ERP workflows",author:"UBK Infotech",repository:"https://github.com/ubk/erp-hooks",license:"MIT",status:"published",created_at:"2024-08-05",updated_at:"2025-04-30"},{npm_id:"NPM-005",package_name:"@ubk/erp-utils",version:"3.2.1",description:"Utility functions for date, currency, and validation",author:"UBK Infotech",repository:"https://github.com/ubk/erp-utils",license:"ISC",status:"deprecated",created_at:"2023-11-20",updated_at:"2025-02-10"}],vi=[{key:"dashboard",label:"Dashboard"},{key:"allPackages",label:"All Packages"},{key:"published",label:"Published"},{key:"draft",label:"Draft"},{key:"deprecated",label:"Deprecated"},{key:"pendingApproval",label:"Pending Approval"}];function Lm(){const[t,a]=i.useState("dashboard"),[s,r]=i.useState("This Month"),[o,l]=i.useState(""),[d,c]=i.useState(""),[y,h]=i.useState(1),[u,p]=i.useState(10),[w,v]=i.useState(""),b=i.useRef(null),m=["dashboard","allPackages","published","draft","deprecated","pendingApproval"].includes(t),j=i.useMemo(()=>{if(!w.trim())return Si;const x=w.toLowerCase();return Si.filter(g=>Object.values(g).some(C=>String(C??"").toLowerCase().includes(x)))},[w]),D=i.useMemo(()=>{const x=(y-1)*u;return j.slice(x,x+u)},[j,y,u]),I=()=>{h(1)},k=()=>{const x=[{title:"Total Packages",value:kt.total_packages,icon:e.jsx(te.FileTextOutlined,{}),color:"#1976d2"},{title:"Total Downloads",value:kt.total_downloads.toLocaleString(),icon:e.jsx(te.StarOutlined,{}),color:"#2e7d32"},{title:"Active Packages",value:kt.active_packages,icon:e.jsx(te.CheckCircleOutlined,{}),color:"#0288d1"},{title:"Deprecated",value:kt.deprecated_packages,icon:e.jsx(te.CloseCircleOutlined,{}),color:"#d32f2f"},{title:"Pending Approval",value:kt.pending_approval,icon:e.jsx(te.ClockCircleOutlined,{}),color:"#ed6c02"},{title:"Published This Month",value:kt.published_this_month,icon:e.jsx(te.CalendarOutlined,{}),color:"#9c27b0"},{title:"Published This Week",value:kt.published_this_week,icon:e.jsx(te.SyncOutlined,{}),color:"#455a64"},{title:"Needs Update",value:kt.packages_needing_update,icon:e.jsx(te.CodeOutlined,{}),color:"#c62828"},{title:"With Issues",value:kt.packages_with_issues,icon:e.jsx(te.CloseCircleOutlined,{}),color:"#f57c00"}];return e.jsx(n.Row,{gutter:[16,16],children:x.map((g,C)=>e.jsx(n.Col,{xs:24,sm:12,md:8,lg:6,children:e.jsxs(n.Card,{style:{display:"flex",alignItems:"center",padding:16,borderLeft:`6px solid ${g.color}`,transition:"0.2s",cursor:"default"},bodyStyle:{display:"flex",alignItems:"center",width:"100%"},children:[e.jsx(A,{style:{width:48,height:48,borderRadius:"50%",backgroundColor:`${g.color}15`,color:g.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,marginRight:16,flexShrink:0},children:g.icon}),e.jsxs(A,{children:[e.jsx(n.Typography.Text,{type:"secondary",style:{fontSize:12,fontWeight:500},children:g.title}),e.jsx("div",{style:{fontSize:22,fontWeight:700,marginTop:4},children:g.value})]})]})},C))})},S=()=>{const x=[{title:"NPM ID",dataIndex:"npm_id",key:"npm_id",width:100},{title:"Package Name",dataIndex:"package_name",key:"package_name",ellipsis:!0},{title:"Version",dataIndex:"version",key:"version",width:100},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,responsive:["md"]},{title:"Author",dataIndex:"author",key:"author",width:140,responsive:["lg"]},{title:"License",dataIndex:"license",key:"license",width:100},{title:"Status",dataIndex:"status",key:"status",width:120,render:g=>{let C="default";return g==="published"?C="green":g==="draft"?C="orange":g==="deprecated"?C="red":g==="pending"&&(C="blue"),e.jsx(n.Tag,{color:C,children:g.toUpperCase()})}},{title:"Created Date",dataIndex:"created_at",key:"created_at",width:120,responsive:["lg"]},{title:"Updated Date",dataIndex:"updated_at",key:"updated_at",width:120,responsive:["lg"]},{title:"Actions",key:"action",width:120,fixed:"right",render:(g,C)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer",fontSize:13},children:"View"})}];return t==="dashboard"?[]:x};return e.jsx(A,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"NPM Package Report"})}),e.jsxs(A,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],mb:3,children:[m&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(X,{options:ji,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:ji.find(x=>x.value===s)||null,onChange:x=>r(x?.value||"This Month")})}),s==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Me,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:x=>l(x?x.format("YYYY-MM-DD"):"")})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Me,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:x=>c(x?x.format("YYYY-MM-DD"):"")})})]})]}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(A,{display:"flex",alignItems:"center",height:"100%",mt:t==="dashboard"?0:2,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:I})})})]}),e.jsx(n.Tabs,{activeKey:t,onChange:a,items:vi})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:vi.find(x=>x.key===t)?.label||"Report"})}),e.jsxs(A,{p:3,children:[t!=="dashboard"&&e.jsx(St,{data:{tableRef:b}}),t==="dashboard"?k():e.jsx(n.Table,{size:"small",dataSource:D,columns:S(),loading:!1,pagination:!1,bordered:!0,rowKey:x=>x.npm_id||x.package_name||Math.random(),ref:b}),t!=="dashboard"&&j.length>0&&e.jsx(n.Pagination,{current:y,pageSize:u,total:j.length,onChange:(x,g)=>{h(x),p(g)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const ts=t=>t??localStorage.getItem("authToken")??"",rr=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Ie={upload:"api/branchapi/frontoffice/uploadfrontofficeDocument",roleDropdown:"api/Branch/getRoledropdownforBranch",staff:{list:"api/branchapi/staff/stafflist",searchByRole:"api/branchapi/staff/staffsearchbyRole",searchByKeywords:"api/branchapi/staff/staffsearchbyKeywords",deactivate:"api/branchapi/staff/staff_deactive",basicById:"api/branchapi/staff/getbasicdetailsbyID",experienceById:"api/branchapi/staff/getworkexperencebyID",payrollById:"api/branchapi/staff/getpayrollbyID",lastEmpNo:"api/branchapi/staff/getLastStaffEMPnumber",addBasic:"api/branchapi/staff/addstaffbasicdetails",editBasic:"api/branchapi/staff/editstaffbasicdetails",addExperience:"api/branchapi/staff/addstaffExperience",editExperience:"api/branchapi/staff/editstaffExperience",addPayroll:"api/branchapi/staff/addstaffpayroll",editPayroll:"api/branchapi/staff/editstaffpayroll",uploadProfile:"api/branchapi/staff/uploadstaffProfilepicture",uploadDocuments:"api/branchapi/staff/uploadDocuments"},master:{shift:{dropdown:"api/branchapi/generalSettings/shiftDropdown",table:"api/branchapi/generalSettings/shiftTable",add:"api/branchapi/generalSettings/shiftTable",add:"api/branchapi/generalSettings/addshift",edit:"api/branchapi/generalSettings/addshift",edit:"api/branchapi/generalSettings/editshift",remove:"api/branchapi/generalSettings/deleteshift",show:"api/branchapi/generalSettings/shiftShowdata"},department:{dropdown:"api/branchapi/humanResource/departmentDropdown",table:"api/branchapi/humanResource/departmenttypeTable",add:"api/branchapi/humanResource/adddepartment",edit:"api/branchapi/humanResource/editdepartment",remove:"api/branchapi/humanResource/deletedepartment",show:"api/branchapi/humanResource/departmentShowdata"},designation:{dropdown:"api/branchapi/humanResource/designationDropdown",table:"api/branchapi/humanResource/designationTable",add:"api/branchapi/humanResource/adddesignation",edit:"api/branchapi/humanResource/editdesignation",remove:"api/branchapi/humanResource/deletedesignation",show:"api/branchapi/humanResource/designationShowdata"},leaveType:{dropdown:"api/branchapi/humanResource/leavetypeDropdown",table:"api/branchapi/humanResource/LeavetypeTable",add:"api/branchapi/humanResource/addleavetype",edit:"api/branchapi/humanResource/editleavetype",remove:"api/branchapi/humanResource/deleteleavetype",show:"api/branchapi/humanResource/leavetypeShowdata"}},leave:{table:"api/branchapi/humanResource/LeaveTable",apply:"api/branchapi/humanResource/applyLeave",requestTable:"api/branchapi/humanResource/leaverequestTable",approveRequest:"api/branchapi/humanResource/approveleaveRequest"},attendance:{staffListForAttendance:"api/staff/attendence/stafflistforAttendence",staffDropdownByRole:"api/staff/attendence/getStaffDropDownByRoleId",addAttendanceToStaffByBranch:"api/staff/attendence/addattendencetoStaffbyBranch",manualAttendance:"api/staff/attendence/staffMenualAttendance",staffShiftByStaffId:"api/branchapi/staff/getStaffShiftByStaffId",dailyAttendance:"api/staff/attendence/dailyAttendance",dailyAttendanceMultipleShift:"api/staff/attendence/dailyAttendanceMultipleShift"},attendanceReport:{monthlyStaffReport:"api/AttendenceReport/staffmonthlyAttendenceReport_new",staffAttendanceList:"api/AttendenceReport/staffAttendanceList",overallStaffReport:"api/staff/attendence/getAlloverAttendenceReportofStaff"},payroll:{monthlyGraph:"api/branchapi/reportGraph/monthlyPayroleReportgraph",staffPayrollByStaffId:"api/branchapi/humanResource/getStaffPayroleByStaffID",generatePayslip:"api/branchapi/humanResource/generatePayslip",payrollByRole:"api/branchapi/humanResource/getpayrolebyRole",monthlyReport:"api/branchapi/humanResource/monthlyPayRolereport"}},nl=()=>rr(He(),Ie.upload),Bm=()=>rr(He(),Ie.staff.uploadProfile),qm=()=>rr(He(),Ie.staff.uploadDocuments),zm=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return H(l,ts(r))},Rt=async(t,a,s)=>Ee(t,a,ts(s)),zt=async(t,a,s)=>Be(t,a,ts(s)),tn=async(t,a,s)=>qe(t,a,ts(s)),Jt=Ie.staff,Ym=Ie.master.shift.dropdown,Vm=Ie.master.department.dropdown,Wm=Ie.master.designation.dropdown,Hm=Ie.roleDropdown,bn=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Km=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ka={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},wi={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Gm({token:t,mode:a,staffId:s,initialValues:r,onSubmitted:o}){const l=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))}catch{return null}},[]),d=String(l?.multiple_shift??"").toLowerCase()==="yes",[c,y]=i.useState(r?.roleValue??null),[h,u]=i.useState(r?.departmentValue??null),[p,w]=i.useState(r?.designationValue??null),[v,b]=i.useState(r?.genderValue??null),[m,j]=i.useState(r?.shiftValue??(d?[]:null)),[D,I]=i.useState(r?.dob?ee(r.dob):null),[k,S]=i.useState(r?.doj?ee(r.doj):null),[x,g]=i.useState(r?.file??""),{data:C}=W(t?[Ym,t]:null,([V,q])=>H(V,q)),{data:T}=W(t?[Vm,t]:null,([V,q])=>H(V,q)),{data:R}=W(t?[Wm,t]:null,([V,q])=>H(V,q)),{data:L}=W(t?[Hm,t]:null,([V,q])=>H(V,q)),{data:N}=W(t?[Jt.lastEmpNo,t]:null,([V,q])=>H(V,q)),f=i.useMemo(()=>bn(C),[C]),P=i.useMemo(()=>bn(T),[T]),O=i.useMemo(()=>bn(R),[R]),$=i.useMemo(()=>bn(L),[L]),F=i.useMemo(()=>{const V=N?.data?.emp_number??N?.emp_number??N?.data??"";return String(V??"")},[N]),U=async V=>{V.preventDefault();const q=new FormData(V.target);q.set("role",c?.value??c??""),q.set("department",h?.value??h??""),q.set("designation",p?.value??p??""),q.set("gender",v?.value??v??""),q.set("dob",D?D.format("YYYY-MM-DD"):""),q.set("doj",k?k.format("YYYY-MM-DD"):""),d?(q.delete("shift_id"),(Array.isArray(m)?m:[]).forEach(M=>{q.append("shift_id[]",M?.value??M??"")})):q.set("shift_id",m?.value??m??""),x&&q.set("file",x);try{const E=a==="edit"&&s,M=E?Jt.editBasic:Jt.addBasic;E&&q.set("staff_id",String(s));const B=E?await zt(M,q,t):await Rt(M,q,t),z=B?.ID??B?.id??s??null;_.success("Success!",{duration:1e3}),o?.({staffId:z,basic:{roleValue:c,departmentValue:h,designationValue:p,genderValue:v,shiftValue:m,dob:D,doj:k,file:x}})}catch(E){_.error(E?.response?.data?.msg??E?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:U,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"number",name:"emp_number",label:"EMP No",defaultValue:r?.emp_number??F,required:!0}),e.jsx(Y,{type:"text",name:"f_name",label:"First Name",defaultValue:r?.f_name??"",required:!0}),e.jsx(Y,{type:"text",name:"l_name",label:"Last Name",defaultValue:r?.l_name??"",required:!0}),e.jsx(Y,{type:"text",name:"pan_no",label:"PAN",defaultValue:r?.pan_no??""}),e.jsx(Y,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:r?.adhar_no??""}),e.jsx(X,{label:"Role",options:$,value:c,onChange:V=>y(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(X,{label:"Department",options:P,value:h,onChange:V=>u(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(X,{label:"Designation",options:O,value:p,onChange:V=>w(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(X,{label:"Gender",options:[{value:"Male",label:"Male"},{value:"Female",label:"Female"},{value:"Other",label:"Other"}],value:v,onChange:V=>b(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"text",name:"email",label:"Email",defaultValue:r?.email??""}),e.jsxs("div",{children:[e.jsx("div",{style:ka,children:"DOB"}),e.jsx(n.DatePicker,{value:D,onChange:V=>I(V),style:wi,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:ka,children:"DOJ"}),e.jsx(n.DatePicker,{value:k,onChange:V=>S(V),style:wi,placeholder:"Select DOJ"})]}),e.jsx(Y,{type:"text",name:"bloodGroup",label:"Blood Group",defaultValue:r?.bloodGroup??""}),e.jsx(Y,{type:"text",name:"contact_no",label:"Contact No",defaultValue:r?.contact_no??"",required:!0}),e.jsx(Y,{type:"text",name:"education",label:"Education",defaultValue:r?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:ka,children:"Shift"}),e.jsx(X,{options:f,value:m,onChange:V=>j(V??(d?[]:null)),isMulti:d,closeMenuOnSelect:!d,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:ka,children:"Profile Picture"}),e.jsx(n.Upload,{maxCount:1,action:Bm(),headers:t?{Authorization:t}:void 0,onChange:V=>{if(V?.file?.status==="done"){const q=Km(V?.file?.response);q&&g(q)}V?.file?.status==="removed"&&g("")},children:e.jsx(n.Button,{type:"link",style:{paddingLeft:0},children:x?"Change":"Upload"})})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:ka,children:"Address"}),e.jsx("textarea",{name:"address",rows:3,defaultValue:r?.address??"",placeholder:"Address",style:{width:"100%",resize:"vertical",padding:10,border:"1px solid #d9d9d9",borderRadius:8,outline:"none"}})]}),e.jsx("div",{style:{gridColumn:"1 / -1",display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save & Next",color:"primary"})})]})})}const jn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},_i={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Jm=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Ci=t=>{if(!t)return null;const a=ee(t);return a.isValid()?a:null};function Qm({token:t,mode:a,staffId:s,initialRows:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(()=>(Array.isArray(r)&&r.length?r:[{name:"",from:null,to:null,image:""}]).map(b=>({name:b?.name??"",from:Ci(b?.from),to:Ci(b?.to),image:b?.image??""}))),y=i.useMemo(()=>t?{Authorization:t}:void 0,[t]),h=(v,b)=>{c(m=>m.map((j,D)=>D===v?{...j,...b}:j))},u=()=>c(v=>[...v,{name:"",from:null,to:null,image:""}]),p=v=>c(b=>b.length<=1?b:b.filter((m,j)=>j!==v)),w=async v=>{if(v.preventDefault(),!s){_.error("Missing staff id.",{duration:1e3});return}const b=new FormData;b.append("staff_id",String(s)),d.forEach((m,j)=>{b.append(`experience[${j}][name]`,String(m?.name??"")),b.append(`experience[${j}][from]`,m?.from?m.from.format("YYYY-MM-DD"):""),b.append(`experience[${j}][to]`,m?.to?m.to.format("YYYY-MM-DD"):""),b.append(`experience[${j}][image]`,String(m?.image??""))});try{const m=a==="edit",j=m?Jt.editExperience:Jt.addExperience,D=m?await zt(j,b,t):await Rt(j,b,t);_.success("Success!",{duration:1e3}),o?.({experience:d,result:D})}catch(m){_.error(m?.response?.data?.msg??m?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:w,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[d.map((v,b)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end",border:"1px solid #eee",borderRadius:12,padding:14},children:[e.jsxs("div",{children:[e.jsx("div",{style:jn,children:"Name"}),e.jsx("input",{value:v.name,onChange:m=>h(b,{name:m.target.value}),placeholder:"Company / School",style:{width:"100%",height:40,border:"none",borderBottom:"1px solid #d9d9d9",outline:"none",background:"transparent"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:jn,children:"From"}),e.jsx(n.DatePicker,{value:v.from,onChange:m=>h(b,{from:m}),style:_i})]}),e.jsxs("div",{children:[e.jsx("div",{style:jn,children:"To"}),e.jsx(n.DatePicker,{value:v.to,onChange:m=>h(b,{to:m}),style:_i})]}),e.jsxs("div",{children:[e.jsx("div",{style:jn,children:"Document"}),e.jsx(n.Upload,{maxCount:1,action:qm(),headers:y,onChange:m=>{if(m?.file?.status==="done"){const j=Jm(m?.file?.response);j&&h(b,{image:j})}m?.file?.status==="removed"&&h(b,{image:""})},children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),children:"Upload"})}),!!v.image&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:v.image})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:e.jsx(n.Button,{type:"text",icon:e.jsx(te.DeleteOutlined,{}),danger:!0,onClick:()=>p(b),disabled:d.length<=1})})]},`exp-${b}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(n.Button,{icon:e.jsx(te.PlusOutlined,{}),onClick:u,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(n.Button,{onClick:l,children:"Back"}),e.jsx(ne,{type:"submit",value:"Save & Next",color:"primary"})]})]})]})})}const Ai=(t,a=[])=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){const s=a.length?a:["allowances","Allowances","dedection","Dedection","deductions","Deductions"],r=[t];t?.data&&typeof t.data=="object"&&r.push(t.data);for(const l of r)for(const d of s){const c=l?.[d]??l?.[d.toLowerCase()]??l?.[d.toUpperCase()];if(Array.isArray(c)&&c.length>0)return c}const o=t?.data;if(Array.isArray(o)&&o.length>0)return o}return[]},Pa=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function Xm({token:t,mode:a,staffId:s,initialValues:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(r?.type??"Permanent"),[y,h]=i.useState(r?.salary_type??Pa[0]?.value),[u,p]=i.useState(Number(r?.amount??0)),[w,v]=i.useState(Number(r?.basic_pay)),[b,m]=i.useState(r?.declarationPERyear??""),{data:j}=W(t?[lc,t]:null,([g,C])=>H(g,C),{revalidateOnFocus:!1}),D=i.useMemo(()=>Ai(j,["allowances","Allowances"]),[j]),I=i.useMemo(()=>Ai(j,["dedection","Dedection","deductions","Deductions"]),[j]),k=i.useMemo(()=>{const g=Number(w||0),C=(Array.isArray(D)?D:[]).map(f=>{const P=f?.amount_type??f?.amountType??f?.type??"",O=Number(f?.Amount??f?.amount??0),F=String(P).trim().toLowerCase()==="flat"?O:Number(g)/100*Number(O||0);return{...f,value:Number.isFinite(F)?F:0}}),T=(Array.isArray(I)?I:[]).map(f=>{const P=f?.amount_type??f?.amountType??f?.type??"",O=Number(f?.Amount??f?.amount??0),F=String(P).trim().toLowerCase()==="flat"?O:Number(g)/100*Number(O||0);return{...f,value:Number.isFinite(F)?F:0}}),R=C.reduce((f,P)=>f+Number(P?.value||0),0),L=T.reduce((f,P)=>f+Number(P?.value||0),0),N=Math.max(0,Number(g)+R-L);return{allowances:C,deductions:T,netAmount:N}},[D,I,w]),S=async g=>{if(g.preventDefault(),!s){_.error("Missing staff id.",{duration:1e3});return}const C=new FormData;C.append("staff_id",String(s)),C.append("type",d),d==="Nonpermanent"?(C.append("salary_type",y??""),C.append("amount",String(u||"")),C.append("Allowances",JSON.stringify([])),C.append("Dedection",JSON.stringify([]))):(C.append("basic_pay",String(w||"")),C.append("declarationPERyear",String(b??"")),C.append("Allowances",JSON.stringify(k.allowances||[])),C.append("Dedection",JSON.stringify(k.deductions||[])),C.append("amount",String(k.netAmount||0)));try{const T=a==="edit",R=T?Jt.editPayroll:Jt.addPayroll,L=T?await zt(R,C,t):await Rt(R,C,t);o?.({payroll:{staffType:d,salaryType:y,amount:u,basicPay:w,declaration:b},result:L})}catch(T){_.error(T?.response?.data?.msg??T?.message??"Failed.",{duration:1e3})}},x=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(g,C)=>`${C?.Amount??""} / ${C?.amount_type??""}`},{title:"Value",dataIndex:"value",key:"value",width:120}],[]);return e.jsx("form",{onSubmit:S,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:d==="Nonpermanent"?"Non Permanent":"Permanent",value:d},onChange:g=>c(g?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),d==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(X,{label:"Type",options:Pa,value:Pa.find(g=>g.value===y)??Pa[0],onChange:g=>h(g?.value??Pa[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"number",label:"Amount",value:u,onChange:g=>p(Number(g.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{type:"number",label:"Basic Pay",value:w,onChange:g=>v(Number(g.target.value||0)),required:!0}),e.jsx(Y,{type:"text",label:"IT Declarations/Year",value:b,onChange:g=>m(g.target.value)}),e.jsx(Y,{type:"number",label:"Net Amount",value:k.netAmount,disabled:!0})]})]}),d==="Permanent"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Allowances"}),children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(g,C)=>`${g?.title??"a"}-${C}`,columns:x,dataSource:k.allowances,pagination:!1})}),e.jsx(n.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Deductions"}),children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(g,C)=>`${g?.title??"d"}-${C}`,columns:x,dataSource:k.deductions,pagination:!1})})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:e.jsx(ne,{type:"submit",value:"Finish",color:"primary"})})]})})}const Zm=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function eh({token:t,mode:a="add",staffId:s,onFinished:r}){const[o,l]=i.useState(0),[d,c]=i.useState(s??null),[y,h]=i.useState(null),[u,p]=i.useState(null),[w,v]=i.useState(null),b=a==="edit"?s??d:null,m=i.useMemo(()=>b?`${Ie.staff.basicById}?staff_id=${encodeURIComponent(String(b))}`:null,[b]),j=i.useMemo(()=>b?`${Ie.staff.experienceById}?staff_id=${encodeURIComponent(String(b))}`:null,[b]),D=i.useMemo(()=>b?`${Ie.staff.payrollById}?staff_id=${encodeURIComponent(String(b))}`:null,[b]),{data:I}=W(t&&m?[m,t]:null,([R,L])=>H(R,L)),{data:k}=W(t&&j?[j,t]:null,([R,L])=>H(R,L)),{data:S}=W(t&&D?[D,t]:null,([R,L])=>H(R,L)),x=i.useMemo(()=>{const R=Zm(I)[0]??I?.data??I??null;return R?{emp_number:R?.emp_number??R?.empNo??"",f_name:R?.f_name??R?.firstname??R?.first_name??"",l_name:R?.l_name??R?.lastname??R?.last_name??"",pan_no:R?.pan_no??"",adhar_no:R?.adhar_no??"",email:R?.email??"",dob:R?.dob??"",doj:R?.doj??"",bloodGroup:R?.bloodGroup??R?.blood_group??"",contact_no:R?.contact_no??R?.phone??"",education:R?.education??"",address:R?.address??"",file:R?.file??R?.profile_picture??""}:null},[I]),g=i.useMemo(()=>{const R=k?.data??k??null;return(Array.isArray(R?.experience)?R.experience:Array.isArray(R)?R:[]).map(N=>({name:N?.name??"",from:N?.from??"",to:N?.to??"",image:N?.image??""}))},[k]),C=i.useMemo(()=>{const R=S?.data??S??null;return R?{type:R?.type??"Permanent",salary_type:R?.salary_type??"",amount:R?.amount??"",basic_pay:R?.basic_pay??"",declarationPERyear:R?.declarationPERyear??""}:null},[S]),T=i.useMemo(()=>[{title:"Basic"},{title:"Experience"},{title:"Payroll"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:a==="edit"?"Edit Staff":"Add Staff"}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(n.Steps,{current:o,items:T}),o===0&&e.jsx(Gm,{token:t,mode:a,staffId:b,initialValues:x,onSubmitted:({staffId:R})=>{R&&c(R),l(1)}}),o===1&&e.jsx(Qm,{token:t,mode:a,staffId:b??d,initialRows:g,onBack:()=>l(0),onSubmitted:()=>l(2)}),o===2&&e.jsx(Xm,{token:t,mode:a,staffId:b??d,initialValues:C,onBack:()=>l(1),onSubmitted:()=>{_.success("Completed.",{duration:1e3}),r?.({staffId:b??d}),l(0),a!=="edit"&&(c(null),h(null),p(null),v(null))}})]})})]})}function th({token:t}){return e.jsx(eh,{token:t,mode:"add"})}const ah=({token:t})=>e.jsx(th,{token:t}),Sn=Ie.staff,nh=Ie.roleDropdown,sh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},rh=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function ih({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(""),[l,d]=i.useState(""),{data:c}=W(t?[nh,t]:null,([D,I])=>H(D,I)),y=i.useMemo(()=>sh(c),[c]),h=i.useMemo(()=>{const D=a.page,I=a.rowsPerPage,k=r&&!l?`${Sn.searchByRole}?role_id=${encodeURIComponent(String(r))}`:l?`${Sn.searchByKeywords}?key=${encodeURIComponent(String(l))}`:Sn.list,S=k.includes("?")?"&":"?";return`${k}${S}page=${encodeURIComponent(String(D))}&per_page=${encodeURIComponent(String(I))}`},[a.page,a.rowsPerPage,l,r]),{isLoading:u,error:p,data:w,mutate:v}=W(t?[h,t]:null,([D,I])=>H(D,I)),b=i.useMemo(()=>rh(w),[w]),m=async D=>{const I=D?.id??D?.fk_staffID??D?.staff_id;if(I)try{await tn(Sn.deactivate,I,t),_.success("Success! Staff deactivated.",{duration:1e3}),await v()}catch(k){_.error(k?.response?.data?.msg??k?.message??"Failed to deactivate staff.",{duration:1e3})}},j=i.useMemo(()=>[{title:"Name",key:"name",ellipsis:!0,render:(D,I)=>`${I?.firstname??I?.first_name??""} ${I?.lastname??I?.last_name??""}`.trim()||I?.name||""},{title:"Role",dataIndex:"role_name",key:"role_name",ellipsis:!0,responsive:["md"]},{title:"Phone",dataIndex:"phone",key:"phone",ellipsis:!0,responsive:["md"]},{title:"Email",dataIndex:"email",key:"email",ellipsis:!0,responsive:["lg"]},{title:"Status",dataIndex:"status",key:"status",width:120,responsive:["lg"]},{title:"Action",key:"action",width:90,fixed:"right",render:(D,I)=>e.jsx(n.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(te.DeleteOutlined,{}),onClick:()=>m(I),style:{padding:2}})}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20,alignItems:"start"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:3,style:{margin:0},children:"Filters"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{options:[{value:"",label:"All Roles"},...y],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:D=>{o(D?.value??""),s(I=>({...I,page:1}))}}),e.jsx(Y,{type:"text",label:"Keyword",value:l,onChange:D=>d(D.target.value),placeholder:"Search by keywords"}),e.jsx(ne,{type:"button",value:"Refresh",onClick:()=>v()})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:7,style:{margin:0},children:"Staff Directory"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:u,rowKey:D=>String(D?.id??D?.fk_staffID??D?.staff_id??Math.random()),columns:j,dataSource:b,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(D,I)=>s({page:D,rowsPerPage:I}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]})}const oh=({token:t})=>e.jsx(ih,{token:t}),lh=Ie.attendance,dh=Ie.roleDropdown,Di=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},vn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ti={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function ch({token:t,open:a,onClose:s,roleId:r,onSaved:o}){const[l,d]=i.useState(null),[c,y]=i.useState(""),[h,u]=i.useState(ee()),[p,w]=i.useState(ee()),[v,b]=i.useState(ee()),m=i.useMemo(()=>r?`${Ie.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(r))}`:null,[r]),{data:j}=W(t&&m?[m,t]:null,([g,C])=>H(g,C)),D=i.useMemo(()=>Di(j),[j]),{trigger:I,data:k}=tt(t?Ie.attendance.staffShiftByStaffId:null,(g,{arg:C})=>Gt(g,{arg:C},t)),S=i.useMemo(()=>Di(k),[k]),x=async()=>{if(!l?.value){_.error("Select staff.",{duration:1e3});return}if(!c){_.error("Select shift.",{duration:1e3});return}const g=new FormData;g.set("staffID",String(l.value)),g.set("shift_id",String(c)),g.set("attendance_date",h?h.format("YYYY-MM-DD"):""),g.set("intime",p?p.format("h:mm a"):""),g.set("outime",v?v.format("h:mm a"):"");try{await Rt(Ie.attendance.manualAttendance,g,t),_.success("Success!",{duration:1e3}),o?.(),s?.(),d(null),y(""),u(ee()),w(ee()),b(ee())}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed.",{duration:1e3})}};return e.jsx(n.Modal,{open:a,onCancel:s,footer:null,destroyOnClose:!0,title:"Attendance",width:620,children:e.jsx(n.Card,{children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(X,{label:"Staff",options:D,value:l,onChange:async g=>{if(d(g??null),y(""),g?.value&&I)try{await I({staff_id:g.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"Shift"}),e.jsx(n.Radio.Group,{value:c,onChange:g=>y(g.target.value),style:{display:"grid",gap:8},children:S.map(g=>e.jsx(n.Radio,{value:g?.value,children:g?.label??g?.name??g?.title??String(g?.value??"")},String(g?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"Date"}),e.jsx(n.DatePicker,{value:h,onChange:g=>g&&u(g),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"Start Time"}),e.jsx(n.TimePicker,{value:p,onChange:g=>g&&w(g),use12Hours:!0,format:"h:mm a",style:Ti})]}),e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"End Time"}),e.jsx(n.TimePicker,{value:v,onChange:g=>g&&b(g),use12Hours:!0,format:"h:mm a",style:Ti})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(n.Button,{onClick:s,children:"Cancel"}),e.jsx(ne,{type:"button",value:"Save",color:"primary",onClick:x})]})]})})})}const uh=({tableRef:t,excelDisabled:a})=>{const s=new Date().getTime(),r=xa.useReactToPrint({content:()=>t?.current});return e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(n.Row,{gutter:8,children:[e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",icon:e.jsx(te.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(n.Col,{children:a?e.jsx(n.Button,{type:"text",icon:e.jsx(te.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>_.error("You must save attendance before download",{duration:2e3})}):e.jsx(Jo.DownloadTableExcel,{filename:s,sheet:"users",currentTableRef:t?.current,children:e.jsx(n.Button,{type:"text",icon:e.jsx(te.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},ph=(t,a)=>{const s=t?.data?.data??t?.data??t??null;return s?a==="student"?Array.isArray(s?.student)?s.student:[]:Array.isArray(s?.staff)?s.staff:[]:[]},mh=t=>{const a=t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.total??t?.total_rows,s=Number(a);return Number.isFinite(s)&&s>=0?s:0},hh=(t,a)=>{const s=t?.data?.data??t?.data??t??null;return s?a==="student"?{sunday:String(s?.sunday??"").toLowerCase()==="yes",holiday:String(s?.holiday??"").toLowerCase()==="yes"}:{sunday:!!s?.sunday,holiday:!!s?.holiday}:{sunday:!1,holiday:!1}};function fh({token:t,url:a,columns:s,reload:r,setReload:o,saveBtnRef:l,setSaveBtnDisabled:d,date:c,type:y="staff"}){const h=i.useRef(null),[u,p]=i.useState({page:0,rowsPerPage:10}),[w,v]=i.useState(!1),[b,m]=i.useState(!1),[j,D]=i.useState(null),[I,k]=i.useState([]),[S,x]=i.useState({sunday:!1,holiday:!1}),[g,C]=i.useState(!0);i.useEffect(()=>{p(N=>({...N,page:0}))},[a]),i.useEffect(()=>{let N=!0;return(async()=>{if(!(!t||!a)){v(!0);try{const P=String(a).includes("?")?"&":"?",O=`${a}${P}page=${u.page+1}&per_page=${u.rowsPerPage}`,$=await H(O,t);if(!N)return;D($),$?.Status==="Success"?(d?.(!1),k(ph($,y)),x(hh($,y))):(d?.(!0),k([]),x({sunday:!1,holiday:!1}))}catch{if(!N)return;d?.(!0),k([])}finally{N&&v(!1)}}})(),()=>{N=!1}},[u.page,u.rowsPerPage,r,d,t,y,a]);const T=i.useMemo(()=>mh(j),[j]);i.useEffect(()=>{const N=(Array.isArray(I)?I:[]).find(f=>f?.attendence_type_id===null);C(!!N)},[I]);const R=async()=>{if(t){m(!0);try{if(y==="staff"){const N=(Array.isArray(I)?I:[]).map(f=>({staff_id:f?.staff_id,attendence_type_id:f?.attendence_type_id?f.attendence_type_id:"1",in_time:f?.intime,out_time:f?.outtime,date:c}));await Rt(Ie.attendance.addAttendanceToStaffByBranch,N,t),_.success("Attendance saved successfully",{duration:2e3}),o?.(f=>!f)}else _.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(N){_.error(N?.response?.data?.msg??N?.message??"Failed required dates",{duration:2e3})}finally{m(!1)}}},L=i.useMemo(()=>(Array.isArray(s)?s:[]).map(f=>f?.selector==="attendence_type_id"?{title:f?.name??"Attendance",dataIndex:f.selector,key:f.selector,render:P=>P==null||P===""?e.jsx(n.Tag,{color:"orange",children:"Not Set"}):String(P)==="1"?e.jsx(n.Tag,{color:"green",children:"Present"}):String(P)==="4"?e.jsx(n.Tag,{color:"red",children:"Absent"}):String(P)==="3"?e.jsx(n.Tag,{color:"orange",children:"Late"}):e.jsx(n.Tag,{children:String(P)})}:f?.selector==="snum"?{title:f?.name??"Sl",key:f.selector,render:(P,O,$)=>$+1}:{title:f?.name??f?.selector,dataIndex:f?.selector,key:f?.selector}),[s]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{children:[e.jsx(uh,{tableRef:h,excelDisabled:g}),e.jsx(n.Modal,{open:b,footer:null,closable:!1,centered:!0,children:e.jsxs("div",{style:{display:"grid",placeItems:"center",gap:12,padding:12},children:[e.jsx(n.Spin,{size:"large"}),e.jsx("div",{children:"Please wait..."})]})}),S.sunday?e.jsx("div",{style:{textAlign:"center",fontWeight:600,padding:"16px 0"},children:"Weekly Off"}):S.holiday?e.jsx("div",{style:{textAlign:"center",padding:"16px 0"},children:e.jsx("div",{style:{fontWeight:700,marginBottom:6},children:"Holiday"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:h,children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(N,f)=>String(N?.id??N?.staff_id??f),columns:L,dataSource:I,loading:w,pagination:{current:u.page+1,pageSize:u.rowsPerPage,total:T,showSizeChanger:!0,onChange:(N,f)=>p({page:N-1,rowsPerPage:f})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:R,ref:l,style:{display:"none"},children:"hidden"})]})]})]})}const yh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},gh={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function xh({token:t}){const[a,s]=i.useState(""),[r,o]=i.useState(ee().format("YYYY-MM-DD")),[l,d]=i.useState(!1),[c,y]=i.useState(null),[h,u]=i.useState(!1),[p,w]=i.useState(!0),[v,b]=i.useState(!1),m=i.useRef(null),{data:j}=W(t?[dh,t]:null,([k,S])=>H(k,S)),D=i.useMemo(()=>yh(j),[j]),I=i.useMemo(()=>[{id:"1",name:"Staff Id",selector:"employee_id",sortable:!0},{id:"2",name:"Name",selector:"full_name",sortable:!0},{id:"4",name:"Contact",selector:"contact_no",sortable:!0},{id:"3",name:"Attendance",selector:"attendence_type_id",sortable:!0},{id:"5",name:"In Time",selector:"intime",sortable:!0},{id:"6",name:"Out Time",selector:"outtime",sortable:!0}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,onChange:k=>s(k?.value??""),required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{defaultValue:ee(),onChange:k=>k&&o(k.format("YYYY-MM-DD")),style:gh,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>{!a||!r||(y(`${lh.staffListForAttendance}?role=${encodeURIComponent(String(a))}&date=${encodeURIComponent(String(r))}`),d(k=>!k))}})})]})}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap",marginBottom:12},children:[e.jsx(n.Button,{size:"small",type:h?"primary":"default",onClick:()=>u(k=>!k),children:h?"Marked":"Mark As Holiday"}),e.jsx(n.Button,{size:"small",type:"default",disabled:p,onClick:()=>b(!0),children:"Give Attendance"})]}),c?e.jsx(fh,{token:t,url:c,columns:I,reload:l,setReload:d,saveBtnRef:m,setSaveBtnDisabled:w,date:r,type:"staff",holidayChecked:h}):null]}),e.jsx(ch,{token:t,open:v,onClose:()=>b(!1),roleId:a,onSaved:()=>d(k=>!k)})]})}const bh=({token:t})=>e.jsx(xh,{token:t}),Ri=Ie.attendanceReport.monthlyStaffReport,jh=Ie.roleDropdown,Sh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function vh({token:t}){const a=i.useRef(null),[s,r]=i.useState(!1),[o,l]=i.useState([]),[d,c]=i.useState({role:"",rolllabel:"",year:"",month:""}),y=i.useMemo(()=>ar(5),[]),{data:h}=W(t?[jh,t]:null,([N,f])=>H(N,f)),u=i.useMemo(()=>Sh(h),[h]),[p,w]=i.useState([]),[v,b]=i.useState(1),[m,j]=i.useState(!1),[D,I]=i.useState(!1),[k,S]=i.useState(null),x=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:g}=tt(t&&Ri?`${Ri}?page=${v}&per_page=3`:null,(N,{arg:f})=>Gt(N,{arg:f},t),{onSuccess:N=>{j(!1);const f=Array.isArray(N)?N:[];f.length>0&&w(P=>[...P||[],...f]),f.length>1?b(P=>P+1):I(!1)},onError:()=>{j(!1),I(!1)}});i.useEffect(()=>{D&&g&&k&&g(k)},[D,v,k,g]);const C=i.useMemo(()=>{const N=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(f,P)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:P?.full_name??""})}];return Array.isArray(p)&&p.length>0&&((p[0]?.monthly_data??[]).forEach((P,O)=>{N.push({title:O+1,align:"center",key:String(O+1),render:($,F)=>{const U=F?.monthly_data?.[O]?.[0]?.data?.[0]??{},V=U?.intime??"",q=U?.outtime??"",E=U?.attendance_type??"";return e.jsx(n.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",V]}),e.jsxs("div",{children:["Out Time ",q]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:et(E)})})}})}),N.push({title:"Total",key:"Total",render:(P,O)=>{const $=O?.monthly_data??[],F=$.filter(V=>V?.[0]?.data?.[0]?.attendance_type==="A").length,U=$.filter(V=>V?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",F," P : ",U]})})}})),N},[p]),T=i.useMemo(()=>[{label:"Present",el:et("P")},{label:"Absent",el:et("A")},{label:"Leave",el:et("L")},{label:"Weekly Off",el:et("W")},{label:"Holiday",el:et("H")}],[]),R=i.useMemo(()=>d.month?o.find(N=>N?.value==d.month)?.label??d.month??"--":"--",[d.month,o]),L=async N=>{if(N.preventDefault(),!d.role||!d.year||!d.month)return;b(1),j(!0),w([]);const f={session:x,year:d.year,month:d.month,day:"01",role:d.role};S(f),I(!0),await g?.(f)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{className:"d-print-none",title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Attendance Report"}),children:e.jsx("form",{onSubmit:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:N=>c(f=>({...f,role:N?.value??"",rolllabel:N?.label??""}))}),e.jsx(X,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:N=>{const f=nr(N?.value);l(f),r(P=>!P),c(P=>({...P,year:N?.label??""}))}}),e.jsx(X,{options:o,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:N=>c(f=>({...f,month:N?.value??""}))},`month-${s}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Monthly Attendance Report"}),children:e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),e.jsxs("div",{style:{border:"1px solid #ddd",borderRadius:8,padding:16,marginBottom:24,backgroundColor:"#f8f9fa"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:12,alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:18,fontWeight:600,marginBottom:6},children:"Staff Attendance Summary"}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:10,fontSize:13},children:[e.jsxs("div",{children:["Role: ",e.jsx("span",{style:{fontWeight:700},children:d.rolllabel||"--"})]}),e.jsxs("div",{children:["Year: ",e.jsx("span",{style:{fontWeight:700},children:d.year||"--"})]}),e.jsxs("div",{children:["Month: ",e.jsx("span",{style:{fontWeight:700},children:R})]})]})]}),e.jsx("div",{className:"d-print-none",style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(St,{data:{tableRef:a}})})]}),e.jsx("div",{style:{marginTop:14,paddingTop:14,borderTop:"1px solid #e0e0e0"},children:e.jsx("div",{style:{display:"flex",justifyContent:"center",flexWrap:"wrap",gap:12,fontSize:12},children:T.map(N=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("div",{children:[N.label," :"]}),e.jsx("div",{children:N.el})]},N.label))})})]}),e.jsx(n.Skeleton,{active:!0,loading:m,paragraph:{rows:10},children:e.jsx(n.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:C,dataSource:p,pagination:!1,scroll:{x:"max-content"},rowKey:(N,f)=>String(N?.staff_id??N?.id??f)})})]})})]})}const wh=({token:t})=>e.jsx(vh,{token:t}),Ii=Ie.payroll,_h=Ie.roleDropdown,Ch=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Ah=t=>t?.data?.data??t?.data??t??[];function Dh({token:t,receiptDetailsPath:a="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:s}){const[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,y]=i.useState([]),[h,u]=i.useState({role:"",roleLabel:"",year:"",month:""}),[p,w]=i.useState(null),v=C=>{if(!C)return;if(typeof s=="function"){s(C);return}const T=`${a}?id=${encodeURIComponent(String(C))}`;typeof window<"u"&&window?.location&&(window.location.href=T)},{data:b}=W(t?[_h,t]:null,([C,T])=>H(C,T)),m=i.useMemo(()=>Ch(b),[b]),j=i.useMemo(()=>ar(5),[]),{isLoading:D,error:I,data:k}=W(t&&p?[p,t]:null,([C,T])=>H(C,T)),S=i.useMemo(()=>{const C=Ah(k);return Array.isArray(C)?C:[]},[k]),x=i.useMemo(()=>{const C=k?.pagination?.total_rows??k?.data?.pagination?.total_rows??k?.total??k?.total_rows,T=Number(C);return Number.isFinite(T)&&T>=0?T:S.length},[k,S.length]),g=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(C,T,R)=>R+1},{title:"Name",dataIndex:"full_name",key:"full_name",ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Mobile No",dataIndex:"contact_no",key:"contact_no",width:140,responsive:["md"]},{title:"Status",dataIndex:"status",key:"status",width:120,align:"center",render:(C,T)=>{const R=T?.id??T?.staff_id??T?.staffId;return e.jsx(n.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{v(R)},children:Ko(T?.status)})}}],[]);return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll"}),children:[e.jsx("form",{onSubmit:C=>{if(C.preventDefault(),!h.role||!h.year||!h.month)return;const T=`${Ii.payrollByRole}?page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.rowsPerPage))}&role=${encodeURIComponent(String(h.role))}&year=${encodeURIComponent(String(h.year))}&month=${encodeURIComponent(String(h.month))}`;w(T)},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",marginBottom:14,padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsx(X,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:C=>u(T=>({...T,role:C?.value??"",roleLabel:C?.label??""}))}),e.jsx(X,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:C=>{const T=nr(C?.value);y(T),d(R=>!R),u(R=>({...R,year:C?.label??"",month:""}))}}),e.jsx(X,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:C=>u(T=>({...T,month:C?.value??""}))},`month-${l}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary",onClick:()=>o(C=>({...C,page:1}))})})]})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:D,rowKey:(C,T)=>String(C?.id??C?.staff_id??T),columns:g,dataSource:S,pagination:{current:r.page,pageSize:r.rowsPerPage,total:x,showSizeChanger:!0,onChange:(C,T)=>{o({page:C,rowsPerPage:T}),!(!h.role||!h.year||!h.month)&&w(`${Ii.payrollByRole}?page=${encodeURIComponent(String(C))}&per_page=${encodeURIComponent(String(T))}&role=${encodeURIComponent(String(h.role))}&year=${encodeURIComponent(String(h.year))}&month=${encodeURIComponent(String(h.month))}`)}},scroll:{x:"max-content"}})]})})}const Th=({token:t})=>e.jsx(Dh,{token:t}),sl=Ie.leave,Sa=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>W(r&&t?[t,a,s,r]:null,([l,d,c,y])=>zm({baseUrl:l,page:d,perPage:c},y)),Rh=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:sl.requestTable,page:a,perPage:s}),Ih=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},kh=(t,a)=>{const s=new FormData;return Object.entries(t??{}).forEach(([r,o])=>{o!=null&&s.append(r,String(o))}),s.set("status",a),s};function Ph({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),{isLoading:r,error:o,data:l,mutate:d}=Rh({token:t,page:a.page,perPage:a.rowsPerPage}),c=i.useMemo(()=>Ih(l),[l]),y=async(u,p)=>{try{const w=kh(u,p),v=await zt(sl.approveRequest,w,t);v?.Status==="Success"?_.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):_.error(v?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(w){_.error(w?.response?.data?.msg??w?.message??"Failed to update request.",{duration:1e3})}},h=i.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(u,p)=>p?.full_name??p?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(u,p)=>p?.leave_from??p?.from_date??""},{title:"To",key:"leave_to",width:120,render:(u,p)=>p?.leave_to??p?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(u,p)=>p?.leavetype??p?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(u,p)=>p?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(u,p)=>p?.employee_remark??p?.reason??""},{title:"View",key:"document_file",width:140,render:(u,p)=>{const w=p?.document_file;return w?e.jsx(n.Button,{size:"small",onClick:()=>window.open(w,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(u,p)=>{const w=String(p?.status??"").toLowerCase();return w==="approved"?e.jsx(n.Tag,{color:"green",children:"Approved"}):w==="declined"?e.jsx(n.Tag,{color:"red",children:"Declined"}):e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10},children:[e.jsx(n.Button,{type:"text",size:"small",onClick:()=>y(p,"approved"),icon:e.jsx(te.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(n.Button,{type:"text",size:"small",onClick:()=>y(p,"declined"),icon:e.jsx(te.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Approve Leave Requests"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:r,rowKey:(u,p)=>String(u?.id??u?.leave_id??p),columns:h,dataSource:c,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(u,p)=>s({page:u,rowsPerPage:p}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Oh=({token:t})=>e.jsx(Ph,{token:t}),Mh=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Eh=({token:t,value:a,onChange:s})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:nl(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=Mh(o?.file?.response);l&&s?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})},rl=Ie.leave,Fh=Ie.master.leaveType.dropdown,$h=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:rl.table,page:a,perPage:s}),Uh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Ts={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Nh({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c]=n.Form.useForm(),{isLoading:y,error:h,data:u,mutate:p}=$h({token:t,page:a.page,perPage:a.rowsPerPage}),{data:w}=W(t?[Fh,t]:null,([S,x])=>H(S,x)),v=i.useMemo(()=>Uh(w),[w]),b=(S,x)=>s({page:S,rowsPerPage:parseInt(x,10)}),m=()=>{d(""),c.resetFields(),c.setFieldsValue({apply_date:ee()}),o(!0)},j=()=>{o(!1),d(""),c.resetFields()},D=async S=>{const x=new FormData;x.set("apply_date",S?.apply_date?S.apply_date.format("YYYY-MM-DD"):""),x.set("leave_type",S?.leave_type?.value??S?.leave_type??""),x.set("from_date",S?.from_date?S.from_date.format("YYYY-MM-DD"):""),x.set("to_date",S?.to_date?S.to_date.format("YYYY-MM-DD"):""),x.set("reason",S?.reason??""),l&&x.set("file",l);try{await Rt(rl.apply,x,t),_.success("Success! Leave request submitted.",{duration:1e3}),j(),await p()}catch(g){_.error(g?.response?.data?.msg??g?.message??"Failed to submit leave request.",{duration:1e3})}},I=i.useMemo(()=>{const S=u?.data??u??[];return Array.isArray(S)?S:Array.isArray(S?.data)?S.data:[]},[u]),k=i.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(S,x)=>x?.leavetype??x?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(S,x)=>x?.date??x?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(S,x)=>x?.leave_from??x?.from_date??""},{title:"To",key:"leave_to",width:130,render:(S,x)=>x?.leave_to??x?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(S,x)=>x?.employee_remark??"",ellipsis:!0,responsive:["md"]}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:r,title:"Add Leave Request",onCancel:j,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:c,layout:"vertical",onFinish:D,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"apply_date",rules:[{required:!0,message:"Select date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{style:Ts})]})}),e.jsx(n.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(X,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Leave Type",allowSelectAll:!1})}),e.jsx(n.Form.Item,{name:"from_date",rules:[{required:!0,message:"Select from date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From"}),e.jsx(n.DatePicker,{style:Ts})]})}),e.jsx(n.Form.Item,{name:"to_date",rules:[{required:!0,message:"Select to date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To"}),e.jsx(n.DatePicker,{style:Ts})]})}),e.jsx(n.Form.Item,{name:"reason",rules:[{required:!0,message:"Enter reason"}],children:e.jsx(Y,{type:"text",label:"Reason",placeholder:"Reason"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:22},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(Eh,{token:t,value:l,onChange:d})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx(n.Button,{onClick:j,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Apply Leave"}),extra:e.jsx(ne,{type:"button",value:"Add Leave Request",onClick:m})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Leave Requests"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:y,rowKey:(S,x)=>String(S?.id??S?.leave_id??x),columns:k,dataSource:I,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(S,x)=>b(S,x),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Lh=({token:t})=>e.jsx(Nh,{token:t}),Fn=Ie.master.leaveType,Bh=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:Fn.table,page:a,perPage:s});function qh({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState(!1),[c,y]=i.useState(null),{isLoading:h,error:u,data:p,mutate:w}=Bh({token:t,page:a.page,perPage:a.rowsPerPage}),v=(S,x)=>{s({page:S,rowsPerPage:parseInt(x,10)})},b=async S=>{const x=new FormData;x.set("title",S?.title??"");try{await w(Rt(Fn.add,x,t),ze(x)),_.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(g){_.error(g?.response?.data?.msg??g?.message??"Failed to add leave type.",{duration:1e3})}},m=S=>{y(S??null),o.setFieldsValue({title:S?.leave_type_name??S?.name??""}),d(!0)},j=()=>{d(!1),y(null),o.resetFields()},D=async S=>{const x=c?.id??c?.leave_type_id;if(!x){_.error("Missing leave type id.",{duration:1e3});return}const g=new FormData;g.set("id",String(x)),g.set("title",S?.title??"");try{await zt(Fn.edit,g,t),await w(),_.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),j()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to update leave type.",{duration:1e3})}},I=async S=>{const x=S?.id??S?.leave_type_id;if(x)try{await w(tn(Fn.remove,x,t),Ne(x)),_.success("Success! Deleted leave type.",{duration:1e3})}catch(g){_.error(g?.response?.data?.msg??g?.message??"Failed to delete leave type.",{duration:1e3})}},k=i.useMemo(()=>[{title:"Name",dataIndex:"type",key:"type",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(S,x)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>m(x)}),e.jsx(n.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>I(x),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(te.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Leave Type",onCancel:j,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:D,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:j,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Leave Type"}),children:e.jsxs(n.Form,{form:r,layout:"vertical",onFinish:b,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Leave Type List"}),children:e.jsx(Re,{parentCallback:v,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:h,error:u}})})]})}const zh=({token:t})=>e.jsx(qh,{token:t}),$n=Ie.master.department,Yh=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:$n.table,page:a,perPage:s});function Vh({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState(!1),[c,y]=i.useState(null),{isLoading:h,error:u,data:p,mutate:w}=Yh({token:t,page:a.page,perPage:a.rowsPerPage}),v=(S,x)=>{s({page:S,rowsPerPage:parseInt(x,10)})},b=async S=>{const x=new FormData;x.set("title",S?.title??"");try{await w(Rt($n.add,x,t),ze(x)),_.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(g){_.error(g?.response?.data?.msg??g?.message??"Failed to add department.",{duration:1e3})}},m=S=>{y(S??null),o.setFieldsValue({title:S?.department_name??S?.name??""}),d(!0)},j=()=>{d(!1),y(null),o.resetFields()},D=async S=>{const x=c?.id??c?.department_id;if(!x){_.error("Missing department id.",{duration:1e3});return}const g=new FormData;g.set("id",String(x)),g.set("title",S?.title??"");try{await zt($n.edit,g,t),await w(),_.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),j()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to update department.",{duration:1e3})}},I=async S=>{const x=S?.id??S?.department_id;if(x)try{await w(tn($n.remove,x,t),Ne(x)),_.success("Success! Deleted department.",{duration:1e3})}catch(g){_.error(g?.response?.data?.msg??g?.message??"Failed to delete department.",{duration:1e3})}},k=i.useMemo(()=>[{title:"Name",dataIndex:"department_name",key:"department_name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(S,x)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>m(x)}),e.jsx(n.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>I(x),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(te.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Department",onCancel:j,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:D,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:j,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Department"}),children:e.jsxs(n.Form,{form:r,layout:"vertical",onFinish:b,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Department List"}),children:e.jsx(Re,{parentCallback:v,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:h,error:u}})})]})}const Wh=({token:t})=>e.jsx(Vh,{token:t}),Un=Ie.master.designation,Hh=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:Un.table,page:a,perPage:s});function Kh({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState(!1),[c,y]=i.useState(null),{isLoading:h,error:u,data:p,mutate:w}=Hh({token:t,page:a.page,perPage:a.rowsPerPage}),v=(S,x)=>{s({page:S,rowsPerPage:parseInt(x,10)})},b=async S=>{const x=new FormData;x.set("title",S?.title??"");try{await w(Rt(Un.add,x,t),ze(x)),_.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(g){_.error(g?.response?.data?.msg??g?.message??"Failed to add designation.",{duration:1e3})}},m=S=>{y(S??null),o.setFieldsValue({title:S?.designation??""}),d(!0)},j=()=>{d(!1),y(null),o.resetFields()},D=async S=>{const x=c?.id??c?.designation_id;if(!x){_.error("Missing designation id.",{duration:1e3});return}const g=new FormData;g.set("id",String(x)),g.set("title",S?.title??"");try{await zt(Un.edit,g,t),await w(),_.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),j()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to update designation.",{duration:1e3})}},I=async S=>{const x=S?.id??S?.designation_id;if(x)try{await w(tn(Un.remove,x,t),Ne(x)),_.success("Success! Deleted designation.",{duration:1e3})}catch(g){_.error(g?.response?.data?.msg??g?.message??"Failed to delete designation.",{duration:1e3})}},k=i.useMemo(()=>[{title:"Name",dataIndex:"designation",key:"designation",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(S,x)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>m(x)}),e.jsx(n.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>I(x),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(te.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Designation",onCancel:j,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:D,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:j,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Designation"}),children:e.jsxs(n.Form,{form:r,layout:"vertical",onFinish:b,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Designation List"}),children:e.jsx(Re,{parentCallback:v,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:h,error:u}})})]})}const Gh=({token:t})=>e.jsx(Kh,{token:t}),Nn=Ie.master.shift,Jh=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:Nn.table,page:a,perPage:s}),dt="hh:mm A",da=t=>{const a=String(t??"");if(!a)return null;const s=ee(a,[dt,"HH:mm","HH:mm:ss"],!0);return s.isValid()?s:null},ca=t=>t?t.format(dt):"",jt={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Qh({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState(!1),[c,y]=i.useState(null),{isLoading:h,error:u,data:p,mutate:w}=Jh({token:t,page:a.page,perPage:a.rowsPerPage}),v=(g,C)=>{s({page:g,rowsPerPage:parseInt(C,10)})},b=(g,C)=>{const T=new FormData;return C&&T.set("id",String(C)),T.set("name",g?.name??""),T.set("start_time",ca(g?.start_time)),T.set("end_time",ca(g?.end_time)),T.set("shift_start_from",ca(g?.shift_start_from)),T.set("shift_start_to",ca(g?.shift_start_to)),T.set("shift_end_from",ca(g?.shift_end_from)),T.set("shift_end_to",ca(g?.shift_end_to)),T},m=async g=>{try{const C=b(g);await w(Rt(Nn.add,C,t),ze(C)),_.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to add shift.",{duration:1e3})}},j=g=>{y(g??null),o.setFieldsValue({name:g?.shift_name??g?.name??"",start_time:da(g?.start_time),end_time:da(g?.end_time),shift_start_from:da(g?.shift_start_from),shift_start_to:da(g?.shift_start_to),shift_end_from:da(g?.shift_end_from),shift_end_to:da(g?.shift_end_to)}),d(!0)},D=()=>{d(!1),y(null),o.resetFields()},I=async g=>{const C=c?.id??c?.shift_id;if(!C){_.error("Missing shift id.",{duration:1e3});return}try{const T=b(g,C);await zt(Nn.edit,T,t),await w(),_.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),D()}catch(T){_.error(T?.response?.data?.msg??T?.message??"Failed to update shift.",{duration:1e3})}},k=async g=>{const C=g?.id??g?.shift_id;if(C)try{await w(tn(Nn.remove,C,t),Ne(C)),_.success("Success! Deleted shift.",{duration:1e3})}catch(T){_.error(T?.response?.data?.msg??T?.message??"Failed to delete shift.",{duration:1e3})}},S=i.useMemo(()=>[{title:"Name",dataIndex:"shift_name",key:"shift_name",ellipsis:!0,fixed:"left",width:160},{title:"Start Time",dataIndex:"start_time",key:"start_time",width:120},{title:"End Time",dataIndex:"end_time",key:"end_time",width:120},{title:"Start From",dataIndex:"shift_start_from",key:"shift_start_from",width:120,responsive:["md"]},{title:"Start To",dataIndex:"shift_start_to",key:"shift_start_to",width:120,responsive:["md"]},{title:"End From",dataIndex:"shift_end_from",key:"shift_end_from",width:120,responsive:["md"]},{title:"End To",dataIndex:"shift_end_to",key:"shift_end_to",width:120,responsive:["md"]},{title:"Action",key:"action",width:110,fixed:"right",render:(g,C)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(te.EditOutlined,{}),onClick:()=>j(C)}),e.jsx(n.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>k(C),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(te.DeleteOutlined,{})})})]})}],[]),x=[{required:!0,message:"Select time"}];return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Shift",onCancel:D,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:I,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(n.Form.Item,{name:"start_time",label:"Start Time",rules:x,children:e.jsx(n.TimePicker,{format:dt,use12Hours:!0,style:jt})}),e.jsx(n.Form.Item,{name:"end_time",label:"End Time",rules:x,children:e.jsx(n.TimePicker,{format:dt,use12Hours:!0,style:jt})}),e.jsx(n.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(n.TimePicker,{format:dt,use12Hours:!0,style:jt})}),e.jsx(n.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(n.TimePicker,{format:dt,use12Hours:!0,style:jt})}),e.jsx(n.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(n.TimePicker,{format:dt,use12Hours:!0,style:jt})}),e.jsx(n.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(n.TimePicker,{format:dt,use12Hours:!0,style:jt})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:D,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Shift"}),children:e.jsx(n.Form,{form:r,layout:"vertical",onFinish:m,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(n.Form.Item,{name:"start_time",label:"Start Time",rules:x,children:e.jsx(n.TimePicker,{format:dt,use12Hours:!0,style:jt})}),e.jsx(n.Form.Item,{name:"end_time",label:"End Time",rules:x,children:e.jsx(n.TimePicker,{format:dt,use12Hours:!0,style:jt})}),e.jsx(n.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(n.TimePicker,{format:dt,use12Hours:!0,style:jt})}),e.jsx(n.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(n.TimePicker,{format:dt,use12Hours:!0,style:jt})}),e.jsx(n.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(n.TimePicker,{format:dt,use12Hours:!0,style:jt})}),e.jsx(n.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(n.TimePicker,{format:dt,use12Hours:!0,style:jt})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Shift List"}),children:e.jsx(Re,{parentCallback:v,data:{newData:p,columns:S,columnstype:"antd",action:!1,Loading:h,error:u}})})]})}const Xh=({token:t})=>e.jsx(Qh,{token:t}),ki=Ie.attendance;function Zh({data:t}){return t?e.jsx("div",{style:{margin:15,fontSize:13,padding:10},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{}),(t?.shifts??[]).map((a,s)=>e.jsx("th",{colSpan:"2",style:{border:"1px solid #000",paddingLeft:10},children:a?.shift_name??""},`${s}heading1`))]}),e.jsxs("tr",{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Sl.No"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Teacher's Name"}),(t?.shifts??[]).map((a,s)=>e.jsxs(i.Fragment,{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"In Time"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Out Time"})]},`${s}heading2`))]})]}),e.jsx("tbody",{children:(t?.data??[]).map((a,s)=>e.jsxs("tr",{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:s+1})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:`${a?.name??""} ${a?.surname??""}`.trim()})}),(t?.shifts??[]).map((r,o)=>e.jsxs(i.Fragment,{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a?.attendance_data?(a.attendance_data?.[r?.office_shift_id]?.checkintime??"").toUpperCase():""})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a?.attendance_data?(a.attendance_data?.[r?.office_shift_id]?.checkouttime??"").toUpperCase():""})})]},`${o}cells${s}`))]},`${s}row`))})]})}):null}const ef=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},tf=t=>{const a=String(t??"").toLowerCase();return a==="present"?e.jsx(n.Tag,{color:"green",children:"Present"}):a==="absent"?e.jsx(n.Tag,{color:"red",children:"Absent"}):a==="leave"?e.jsx(n.Tag,{color:"orange",children:"Leave"}):e.jsx(n.Tag,{children:t??""})};function af({token:t}){const[a,s]=i.useState(ee()),[r,o]=i.useState(!1),[l,d]=i.useState(0),c=i.useMemo(()=>`${r?ki.dailyAttendanceMultipleShift:ki.dailyAttendance}?attendance_date=${encodeURIComponent(a.format("YYYY-MM-DD"))}`,[a,r,l]),{isLoading:y,error:h,data:u}=W(t?[c,t]:null,([m,j])=>H(m,j)),p=i.useMemo(()=>ef(u),[u]),w=i.useMemo(()=>r?u?.data?.data??u?.data??u??null:null,[u,r]),v=xa.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),b=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(m,j,D)=>D+1},{title:"Name",key:"name",render:(m,j)=>`${j?.name??""} ${j?.surname??""}`.trim(),ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(m,j)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[tf(j?.attendance),j?.late_time?e.jsx(n.Tag,{color:"red",children:"L"}):null]})},{title:"In Time",key:"intime",width:120,render:(m,j)=>j?.attendance_data?.[0]?.intime??""},{title:"Out Time",key:"outtime",width:120,render:(m,j)=>j?.attendance_data?.[0]?.outtime??""},{title:"Late",key:"late",width:100,render:(m,j)=>j?.late_time?e.jsx(n.Tag,{color:"red",children:j.late_time}):""}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Daily Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:a,onChange:m=>m&&s(m),style:{width:"100%"},allowClear:!1})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:22},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222"},children:"Multiple Shift"}),e.jsx(n.Switch,{checked:r,onChange:o})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",onClick:()=>d(m=>m+1)})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(te.PrinterOutlined,{style:{color:"#5080f8",fontSize:18,cursor:"pointer"},onClick:v}),children:e.jsxs("div",{id:"ubk-hr-daily-attendance-print",children:[e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),r?e.jsx(Zh,{data:w}):e.jsx(n.Table,{bordered:!0,size:"small",loading:y,rowKey:(m,j)=>String(m?.id??m?.staff_id??j),columns:b,dataSource:p,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const nf=({token:t})=>e.jsx(af,{token:t}),Pi=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},sf=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"";function rf({token:t,staffId:a}){const[s,r]=i.useState(!1),[o,l]=i.useState(null),[d,c]=i.useState({value:"Cash",label:"Cash"}),[y,h]=i.useState(""),[u,p]=i.useState(""),w=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),v=R=>{const L=Number(R??0),N=Number.isFinite(L)?L.toLocaleString("en-IN"):"0";return`${w?`${w} `:""}${N}`},b=i.useMemo(()=>a?`${Ie.staff.basicById}?staff_id=${encodeURIComponent(String(a))}`:null,[a]),m=i.useMemo(()=>a?`${Ie.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(a))}`:null,[a]),{data:j}=W(t&&b?[b,t]:null,([R,L])=>H(R,L)),{data:D,isLoading:I,mutate:k}=W(t&&m?[m,t]:null,([R,L])=>H(R,L)),S=i.useMemo(()=>Pi(j)[0]??j?.data??j??null,[j]),x=i.useMemo(()=>Pi(D),[D]),g=i.useMemo(()=>[{title:"Month",dataIndex:"month",key:"month",width:120,align:"center"},{title:"Basic Salary",dataIndex:"basic_salary",key:"basic_salary",width:140,align:"center",render:(R,L)=>e.jsx("div",{style:{fontSize:11},children:Tt(L?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(R,L)=>e.jsx("div",{style:{fontSize:11},children:Tt(L?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(R,L)=>e.jsx("div",{style:{fontSize:11},children:Tt(L?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(R,L)=>e.jsx("div",{style:{fontSize:11},children:Tt(L?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(R,L)=>e.jsx("div",{style:{cursor:L?.status==="due"?"pointer":"default"},onClick:()=>{L?.status==="due"&&(l(L),r(!0))},children:Ko(L?.status)})}],[]),C=i.useMemo(()=>[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"DD",label:"DD"},{value:"Bank",label:"Bank"},{value:"Internet Banking",label:"Internet Banking"},{value:"Cheque",label:"Cheque"}],[]),T=async()=>{if(!o)return;const R={...o,staff_id:a,payment_type:d?.value??"",notes:y,attchement:u};try{await Ee(Ie.payroll.generatePayslip,{arg:R},t),_.success("Success!",{duration:1e3}),r(!1),l(null),h(""),p(""),await k()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed.",{duration:1e3})}};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx("div",{style:{fontSize:13,color:"#444"},children:S?`${S?.f_name??S?.firstname??""} ${S?.l_name??S?.lastname??""}`.trim():""}),e.jsx(n.Table,{bordered:!0,size:"small",loading:I,rowKey:(R,L)=>String(R?.id??`${R?.month}-${L}`),columns:g,dataSource:x,pagination:{pageSize:12},scroll:{x:"max-content"}})]})}),e.jsx(n.Modal,{open:s,onCancel:()=>{r(!1),l(null)},footer:null,destroyOnClose:!0,title:"Payment Options",width:640,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(X,{label:"Pay",options:C,value:d,onChange:R=>c(R??C[0]),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Note"}),e.jsx(n.Input.TextArea,{rows:4,placeholder:"Note",value:y,onChange:R=>h(R.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(n.Upload,{maxCount:1,action:nl(),headers:t?{Authorization:t}:void 0,onChange:R=>{if(R?.file?.status==="done"){const L=sf(R?.file?.response);L&&p(L)}R?.file?.status==="removed"&&p("")},children:e.jsx(n.Button,{icon:e.jsx(te.UploadOutlined,{}),children:"Upload"})}),!!u&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:u})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(n.Button,{onClick:()=>r(!1),children:"Cancel"}),e.jsx(ne,{type:"button",value:o?.Total_Payable_Amount?`Pay ${v(o.Total_Payable_Amount)}`:"Pay",onClick:T})]})]})})]})}function of({token:t,staffId:a}){const s=i.useMemo(()=>{if(a!=null&&String(a).trim()!=="")return a;if(typeof window>"u")return null;const r=new URLSearchParams(window.location.search).get("id");return r||null},[a]);return s?e.jsx(rf,{token:t,staffId:s}):e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsx("div",{style:{fontSize:13,color:"#666"},children:"Missing staff id."})})}function Yt({onAdd:t,onExport:a,onPrint:s,onDownload:r,onFilter:o,onRefresh:l,actions:d}){const c=i.useMemo(()=>[{key:"add",title:"Add",icon:e.jsx(te.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(te.FileExcelOutlined,{}),onClick:a},{key:"print",title:"Print",icon:e.jsx(te.PrinterOutlined,{}),onClick:s},{key:"download",title:"Download",icon:e.jsx(te.DownloadOutlined,{}),onClick:r},{key:"filter",title:"Filter",icon:e.jsx(te.FilterOutlined,{}),onClick:o},{key:"refresh",title:"Refresh",icon:e.jsx(te.ReloadOutlined,{}),onClick:l}],[t,a,s,r,o,l]),y=i.useMemo(()=>{const h=Array.isArray(d)&&d.length?new Set(d):null;return h?c.filter(u=>h.has(u.key)):c},[c,d]);return e.jsx(n.Space,{size:8,children:y.map(h=>e.jsx(n.Tooltip,{title:h.title,children:e.jsx(n.Button,{type:"text",icon:h.icon,onClick:h.onClick,disabled:!h.onClick})},h.key))})}const ir=t=>t??localStorage.getItem("authToken")??"",Pt={dashboard:{monthlyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentmonthlyReportgraph",weeklyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentweeklyReportgraph"},dropdowns:{classes:"api/branchapi/academy/classdropdownlist",sectionsByClass:"api/branchapi/academy/sectionoftheClass",sessions:"api/branchapi/generalSettings/sessiondropdown"},studentAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass",save:"api/studentAttendace/addattendencebyBranch",emergencyLeave:"api/StudentAttendace/emergency_leave"},dailyAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass"},monthlyReport:{table:"api/branchapi/student/studentmonthlyAttendence",byStudent:"api/branchapi/student/getStududentMonthlyByIdUrlnew"},yearlyReport:{table:"api/branchapi/student/studentyearlyAttendenceReport"}},Nt=async(t,a)=>H(t,ir(a)),lf=async(t,a,s)=>Ee(t,a,ir(s)),df=async(t,a,s)=>za(t,{arg:a},ir(s)),Ya=(t,a)=>{const s=new URLSearchParams;Object.entries(a??{}).forEach(([o,l])=>{l==null||l===""||s.set(o,String(l))});const r=t.includes("?")?"&":"?";return`${t}${r}${s.toString()}`},Oi=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}},cf=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},il=(t,a)=>{const s=t?.data?.data??t?.data??t??{},r=a?s?.[a]:s;return Array.isArray(r)?r:Array.isArray(s?.student)?s.student:Array.isArray(s?.staff)?s.staff:Array.isArray(s?.data)?s.data:[]},uf=t=>Array.isArray(t?.monthly_data)?t.monthly_data:Array.isArray(t?.month_data)?t.month_data:[],pf=t=>{const a={present:0,absent:0,late:0,leave:0};return(Array.isArray(t)?t:[]).forEach(s=>{if(Array.isArray(s?.monthly_data)||Array.isArray(s?.month_data)){uf(s).forEach(o=>{const l=o?.[0]?.data?.[0]??o?.data?.[0]??o??{},d=String(l?.attendance_type??l?.attendence_type_id??"").toUpperCase();(d==="P"||d==="1")&&(a.present+=1),(d==="A"||d==="4")&&(a.absent+=1),(d==="L"||d==="3")&&(a.late+=1),(d==="LEAVE"||d==="2")&&(a.leave+=1)});return}const r=String(s?.attendance_type??s?.attendence_type_id??"").toUpperCase();(r==="P"||r==="1")&&(a.present+=1),(r==="A"||r==="4")&&(a.absent+=1),(r==="L"||r==="3")&&(a.late+=1),(r==="LEAVE"||r==="2")&&(a.leave+=1)}),a},or=(t,a)=>{const{data:s,isLoading:r,error:o}=W(a&&t?[t,a]:null,([l,d])=>Nt(l,d));return{isLoading:r,error:o,data:s,options:i.useMemo(()=>cf(s),[s])}},as=t=>or(Pt.dropdowns.classes,t),ns=(t,a)=>{const s=t?`${Pt.dropdowns.sectionsByClass}?class_id=${encodeURIComponent(String(t))}`:null;return or(s,a)},mf=t=>or(Pt.dropdowns.sessions,t),lr=t=>{const a=String(t??"").toUpperCase();return et(a==="1"||a==="P"||a==="PRESENT"?"P":a==="4"||a==="A"||a==="ABSENT"?"A":a==="3"||a==="L"||a==="LATE"?"L":a==="2"||a==="LEAVE"?"LEAVE":a==="W"?"W":a==="H"?"H":a||"-")},ol=(t,a,s)=>{const r=new Blob([t],{type:a}),o=URL.createObjectURL(r),l=document.createElement("a");l.href=o,l.download=s,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(o)},Mi=t=>String(t??"").replace(/"/g,'""'),hf=({rows:t,columns:a,fileName:s})=>{const r=Array.isArray(a)?a:[],o=Array.isArray(t)?t:[],l=r.map(c=>`"${Mi(c?.title??c?.name??c?.key??c?.dataIndex)}"`).join(","),d=o.map((c,y)=>r.map(h=>{const u=h?.dataIndex??h?.selector??h?.key,p=u==="sl"?y+1:c?.[u];return`"${Mi(p)}"`}).join(",")).join(`
60
+ `);ol([l,d].filter(Boolean).join(`
61
+ `),"text/csv;charset=utf-8;",s)},ff=({value:t,fileName:a})=>{ol(JSON.stringify(t??null,null,2),"application/json;charset=utf-8;",a)};function ll({summary:t}){const a=[{key:"present",label:"Present",color:"#52c41a"},{key:"absent",label:"Absent",color:"#ff4d4f"},{key:"late",label:"Late",color:"#fa8c16"},{key:"leave",label:"Leave",color:"#1677ff"}];return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(170px, 1fr))",gap:16},children:a.map(s=>e.jsxs(n.Card,{size:"small",styles:{body:{padding:16}},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:8},children:s.label}),e.jsx("div",{style:{fontSize:24,fontWeight:700,color:s.color},children:t?.[s.key]??0})]},s.key))})}function ga({summary:t,title:a="Attendance Overview"}){const s=i.useMemo(()=>[{key:"present",label:"Present",value:Number(t?.present??0),color:"#52c41a"},{key:"absent",label:"Absent",value:Number(t?.absent??0),color:"#ff4d4f"},{key:"late",label:"Late",value:Number(t?.late??0),color:"#fa8c16"},{key:"leave",label:"Leave",value:Number(t?.leave??0),color:"#1677ff"}],[t]),r=Math.max(...s.map(o=>o.value),1);return e.jsx(n.Card,{size:"small",title:a,children:e.jsx("div",{style:{display:"grid",gap:12},children:s.map(o=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"100px 1fr 50px",gap:12,alignItems:"center"},children:[e.jsx("div",{style:{fontSize:12,color:"#444"},children:o.label}),e.jsx("div",{style:{height:12,background:"#f0f0f0",borderRadius:999},children:e.jsx("div",{style:{width:`${o.value/r*100}%`,height:"100%",background:o.color,borderRadius:999}})}),e.jsx("div",{style:{fontSize:12,fontWeight:600,textAlign:"right"},children:o.value})]},o.key))})})}function yf(){const t=[{label:"Present",node:et("P")},{label:"Absent",node:et("A")},{label:"Late",node:et("L")},{label:"Weekly Off",node:et("W")},{label:"Holiday",node:et("H")}];return e.jsx(n.Space,{wrap:!0,size:[12,8],children:t.map(a=>e.jsxs(n.Space,{size:6,children:[e.jsx("span",{style:{fontSize:12,color:"#555"},children:a.label}),a.node]},a.label))})}function Lt({items:t}){const a=Array.isArray(t)?t.filter(s=>s?.value):[];return a.length?e.jsx(n.Space,{wrap:!0,size:[8,8],children:a.map(s=>e.jsxs(n.Tag,{color:"blue",children:[s.label,": ",s.value]},s.label))}):null}function ss({title:t,subtitle:a,printRef:s,exportRows:r,exportColumns:o,onRefresh:l,onAdd:d,filterSection:c,summary:y,chartContent:h,reportTitle:u,reportExtra:p,children:w,fileBaseName:v="attendance"}){const b=xa.useReactToPrint({content:()=>s?.current});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsxs("div",{children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:t}),a?e.jsx(n.Typography.Text,{type:"secondary",style:{display:"block",marginTop:4},children:a}):null]}),extra:e.jsx(Yt,{actions:["add","export","print","download","refresh"],onAdd:d,onExport:()=>hf({rows:r,columns:o,fileName:`${v}.csv`}),onPrint:b,onDownload:()=>ff({value:r,fileName:`${v}.json`}),onRefresh:l}),children:c}),e.jsx(ll,{summary:y}),h===!1?null:h||e.jsx(ga,{summary:y}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:u}),extra:p,children:w})]})}const gf=[{label:"Present",value:"1"},{label:"Absent",value:"4"},{label:"Late",value:"3"},{label:"Leave",value:"2"}];function xf({rows:t,loading:a,sunday:s,holiday:r,holidayTitle:o,onChangeRows:l,onEmergency:d}){const c=(h,u)=>{const p=(Array.isArray(t)?t:[]).map((w,v)=>(w?.student_session_id??w?.student_id??w?.id??v)===h?{...w,...u}:w);l?.(p)},y=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(h,u,p)=>p+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(h,u)=>u?.full_name??u?.student_name??u?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:180,render:(h,u,p)=>{const w=u?.student_session_id??u?.student_id??u?.id??p;return e.jsx(n.Select,{size:"small",style:{width:"100%"},options:gf,value:String(h??"1"),onChange:v=>c(w,{attendence_type_id:v})})}},{title:"Date",dataIndex:"date",key:"date",width:120,render:h=>h?ee(h).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120},{title:"Emergency Leave",key:"emergency_leave",width:140,render:(h,u)=>e.jsx(n.Tag,{color:"orange",style:{cursor:"pointer"},icon:e.jsx(te.ClockCircleOutlined,{}),onClick:()=>d?.(u),children:"E.L"})}],[d,t]);return s?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):r?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:o||"--"})]}):e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(h,u)=>String(h?.student_session_id??h?.student_id??h?.id??u),columns:y,dataSource:Array.isArray(t)?t:[],loading:a,pagination:{pageSize:25},scroll:{x:"max-content"}})}function bf({rows:t,loading:a,sunday:s,holiday:r,holidayTitle:o}){const l=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(d,c,y)=>y+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(d,c)=>c?.full_name??c?.student_name??c?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:120,render:d=>lr(d)},{title:"Date",dataIndex:"date",key:"date",width:120,render:d=>d?ee(d).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120}],[]);return s?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):r?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:o||"--"})]}):e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(d,c)=>String(d?.student_session_id??d?.student_id??d?.id??c),columns:l,dataSource:Array.isArray(t)?t:[],loading:a,pagination:{pageSize:25},scroll:{x:"max-content"}})}function jf({data:t,loading:a,onViewStudent:s}){const r=t?.data??t??{},o=Array.isArray(r?.studentAttendance)?r.studentAttendance:Array.isArray(r)?r:[],l=Array.isArray(r?.monthly_holiday)?r.monthly_holiday:[],d=Array.isArray(r?.dateSun)?r.dateSun:[],c=Number(r?.totalDaysMonth??0),y=i.useMemo(()=>{const h=[{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,fixed:"left"},{title:"Name",key:"student_name",width:180,fixed:"left",render:(u,p)=>e.jsx(n.Button,{type:"link",style:{padding:0},onClick:()=>s?.(p),children:p?.student_name??p?.full_name??"--"})}];return[...new Array(c).keys()].forEach(u=>{h.push({title:String(u+1),key:`day-${u+1}`,width:52,align:"center",render:(p,w)=>{const b=w?.[`${w?.student_id}_${o.indexOf(w)}`]?.[u]??{},m=b?.attendance_date,j=l.find(D=>D?.date===m);return d.includes(m)?Vr("sunday","W"):j?Vr("holiday","H"):lr(b?.attendence_type_id)}})}),h.push({title:"Total",key:"total",width:140,fixed:"right",render:(u,p)=>{let w=0,v=0,b=0;return[...new Array(c).keys()].forEach(m=>{const j=p?.[`${p?.student_id}_${o.indexOf(p)}`]?.[m]??{},D=String(j?.attendence_type_id??"");D==="1"&&(w+=1),D==="4"&&(v+=1),D==="3"&&(b+=1)}),e.jsxs("span",{children:["P: ",w," A: ",v," L: ",b]})}}),h},[l,s,o,d,c]);return e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(h,u)=>String(h?.student_id??u),columns:y,dataSource:o,loading:a,pagination:{pageSize:20},scroll:{x:"max-content"},locale:{emptyText:e.jsx(n.Empty,{description:"No monthly report found"})}})}function Sf({open:t,onClose:a,loading:s,data:r,studentName:o}){const l=Array.isArray(r?.data?.report)?r.data.report:[],d=[{title:"Date",dataIndex:"attendance_date",key:"attendance_date",render:c=>c?ee(c).format("DD-MM-YYYY"):"--"},{title:"Status",key:"status",render:(c,y)=>lr(y?.attendence_type_id??y?.attendance_type)},{title:"In Time",dataIndex:"intime",key:"intime"},{title:"Out Time",dataIndex:"outtime",key:"outtime"},{title:"Remark",dataIndex:"remark",key:"remark"}];return e.jsx(n.Modal,{open:t,onCancel:a,footer:null,width:900,title:`Monthly Details${o?` - ${o}`:""}`,children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(c,y)=>String(c?.attendance_date??y),columns:d,dataSource:l,loading:s,pagination:{pageSize:20},scroll:{x:"max-content"}})})}function vf({open:t,onClose:a,onSubmit:s,loading:r}){const[o,l]=n.Modal.useModal(),[d,c]=i.useState(null),[y,h]=i.useState(""),u=async()=>{if(!d){await o.warning({title:"Select time"});return}await s?.({outtime:d.format("h:mm a"),message:y}),c(null),h("")};return e.jsxs(e.Fragment,{children:[l,e.jsx(n.Modal,{title:"Emergency Leave",open:t,onCancel:a,onOk:u,confirmLoading:r,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Select Time"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:d,onChange:c,style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Purpose"}),e.jsx(n.Input.TextArea,{rows:4,value:y,onChange:p=>h(p.target.value)})]})]})})]})}const dl=t=>pf(t),Ei=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a.reduce((s,r)=>({present:s.present+Number(r?.present??r?.Present??r?.total_present??0),absent:s.absent+Number(r?.absent??r?.Absent??r?.total_absent??0),late:s.late+Number(r?.late??r?.Late??0),leave:s.leave+Number(r?.leave??r?.Leave??0)}),{present:0,absent:0,late:0,leave:0}):{present:Number(a?.present??a?.Present??a?.total_present??0),absent:Number(a?.absent??a?.Absent??a?.total_absent??0),late:Number(a?.late??a?.Late??0),leave:Number(a?.leave??a?.Leave??0)}};function wf({token:t}){const{data:a}=W(t?[Pt.dashboard.monthlyGraph,t]:null,([l,d])=>Nt(l,d)),{data:s}=W(t?[Pt.dashboard.weeklyGraph,t]:null,([l,d])=>Nt(l,d)),r=i.useMemo(()=>Ei(a),[a]),o=i.useMemo(()=>Ei(s),[s]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsxs(n.Card,{children:[e.jsx(n.Typography.Title,{level:4,style:{marginTop:0},children:"Attendance Dashboard"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:0},children:"Student attendance overview with monthly and weekly analytics migrated from the ERP dashboard."})]}),e.jsx(ll,{summary:r}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20},children:[e.jsx(ga,{summary:r,title:"Monthly Attendance Chart"}),e.jsx(ga,{summary:o,title:"Weekly Attendance Chart"})]})]})}const Rs=Pt.studentAttendance,_f={width:"100%",height:40};function Cf({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[y,h]=i.useState(""),[u,p]=i.useState(""),[w,v]=i.useState(""),[b,m]=i.useState(ee()),[j,D]=i.useState(0),[I,k]=i.useState([]),[S,x]=i.useState(!1),[g,C]=i.useState(null),[T,R]=i.useState(!1),[L,N]=i.useState(!1),f=as(t),P=ns(s,t),O=i.useMemo(()=>!s||!d||j===0?null:Ya(Rs.list,{cID:s,sID:d,batch_id:u,date:b.format("YYYY-MM-DD")}),[u,s,b,j,d]),{data:$,isLoading:F,mutate:U}=W(t&&O?[O,t]:null,([J,ae])=>Nt(J,ae));i.useEffect(()=>{k(il($,"student"))},[$]);const V=$?.data?.data??$?.data??$??{},q=!!V?.sunday,E=!!V?.holiday?.holiday,M=V?.holiday?.title??"",B=i.useMemo(()=>dl(I),[I]),z=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),G=async()=>{if(I.length)try{N(!0),await lf(Rs.save,{attendenceData:I,date:b.format("YYYY-MM-DD"),holiday:S?"YES":"NO"},t),_.success("Student attendance saved."),U?.()}catch(J){_.error(J?.message??"Failed to save attendance.")}finally{N(!1)}},re=async({outtime:J,message:ae})=>{if(g?.attendence_id)try{R(!0),await df(Rs.emergencyLeave,{outtime:J,message:ae,id:g.attendence_id},t),_.success("Emergency leave updated."),C(null),U?.()}catch(oe){_.error(oe?.message??"Failed to update emergency leave.")}finally{R(!1)}},K=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(X,{options:f.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:J=>{r(J?.value??""),l(J?.label??""),c(""),h(""),p(""),v("")},required:!0}),e.jsx(X,{options:P.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:J=>{c(J?.value??""),h(J?.label??""),p(""),v("")},required:!0},`section-${s}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:b,onChange:J=>J&&m(J),style:_f,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>D(J=>J+1)})})]}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Date",value:b.format("DD-MM-YYYY")}]})]});return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{}),e.jsx(ss,{title:"Student Attendance",printRef:a,exportRows:I,exportColumns:z,onRefresh:()=>U?.(),filterSection:K,summary:B,chartContent:!1,reportTitle:"Student Attendance List",reportExtra:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(n.Button,{size:"small",type:S?"primary":"default",onClick:()=>x(J=>!J),children:S?"Marked":"Mark As Holiday"}),e.jsx(n.Button,{size:"small",type:"primary",onClick:G,loading:L,disabled:!I.length,children:"Save Attendance"})]}),fileBaseName:"student-attendance",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ot,{}),e.jsx(n.Typography.Title,{level:5,children:"Student Attendance"}),e.jsx(n.Card,{size:"small",style:{marginBottom:12},children:e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Date",value:b.format("DD-MM-YYYY")}]})})]}),e.jsx(xf,{rows:I,loading:F,sunday:q,holiday:E,holidayTitle:M,onChangeRows:k,onEmergency:C})]})}),e.jsx(vf,{open:!!g,onClose:()=>C(null),onSubmit:re,loading:T})]})}const Af=Pt.dailyAttendance,Df={width:"100%",height:40};function Tf({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[y,h]=i.useState(""),[u,p]=i.useState(""),[w,v]=i.useState(ee()),[b,m]=i.useState(0),j=as(t),D=ns(s,t),I=i.useMemo(()=>!s||!d||b===0?null:Ya(Af.list,{cID:s,sID:d,batch_id:u,date:w.format("YYYY-MM-DD")}),[u,s,w,b,d]),{data:k,isLoading:S,mutate:x}=W(t&&I?[I,t]:null,([O,$])=>Nt(O,$)),g=i.useMemo(()=>il(k,"student"),[k]),C=k?.data?.data??k?.data??k??{},T=!!C?.sunday,R=!!C?.holiday?.holiday,L=C?.holiday?.title??"",N=i.useMemo(()=>dl(g),[g]),f=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),P=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(X,{options:j.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:O=>{r(O?.value??""),l(O?.label??""),c(""),h(""),p(""),setBatchLabel("")},required:!0}),e.jsx(X,{options:D.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:O=>{c(O?.value??""),h(O?.label??""),p(""),setBatchLabel("")},required:!0},`section-${s}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:w,onChange:O=>O&&v(O),style:Df,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>m(O=>O+1)})})]}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Date",value:w.format("DD-MM-YYYY")}]})]});return e.jsx(ss,{title:"Daily Attendance",subtitle:"Read-only daily attendance enquiry migrated from ERP AttendanceDashboard.",printRef:a,exportRows:g,exportColumns:f,onRefresh:()=>x?.(),filterSection:P,summary:N,chartContent:e.jsx(ga,{summary:N,title:"Daily Attendance Overview"}),reportTitle:"Daily Attendance List",fileBaseName:"daily-attendance",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ot,{}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Date",value:w.format("DD-MM-YYYY")}]})]}),e.jsx(bf,{rows:g,loading:S,sunday:T,holiday:R,holidayTitle:L})]})})}const Fi=Pt.monthlyReport,Rf=t=>{const a=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],s=Number(t?.totalDaysMonth??0),r={present:0,absent:0,late:0,leave:0};return a.forEach((o,l)=>{[...new Array(s).keys()].forEach(d=>{const c=o?.[`${o?.student_id}_${l}`]?.[d]??{},y=String(c?.attendence_type_id??"");y==="1"&&(r.present+=1),y==="4"&&(r.absent+=1),y==="3"&&(r.late+=1),y==="2"&&(r.leave+=1)})}),r},If=t=>{const a=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],s=Number(t?.totalDaysMonth??0);return a.map((r,o)=>{let l=0,d=0,c=0;return[...new Array(s).keys()].forEach(y=>{const h=r?.[`${r?.student_id}_${o}`]?.[y]??{},u=String(h?.attendence_type_id??"");u==="1"&&(l+=1),u==="4"&&(d+=1),u==="3"&&(c+=1)}),{roll_no:r?.roll_no??"",student_name:r?.student_name??r?.full_name??"",present:l,absent:d,late:c}})};function kf({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[y,h]=i.useState(""),[u,p]=i.useState(""),[w,v]=i.useState(""),[b,m]=i.useState(String(new Date().getFullYear())),[j,D]=i.useState(String(new Date().getMonth()+1).padStart(2,"0")),[I,k]=i.useState(0),[S,x]=i.useState(null),g=as(t),C=ns(s,t),T=i.useMemo(()=>nr(Number(b)),[b]),R=i.useMemo(()=>ar(10),[]),L=i.useMemo(()=>!s||!d||!b||!j||I===0?null:Ya(Fi.table,{session:Oi(),class_id:s,section_id:d,year:b,month:j,batch_id:u}),[u,s,j,I,d,b]),{data:N,isLoading:f,mutate:P}=W(t&&L?[L,t]:null,([B,z])=>Nt(B,z)),O=N?.data?.data??N?.data??N??{},$=i.useMemo(()=>Rf(O),[O]),F=i.useMemo(()=>If(O),[O]),U=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Name",dataIndex:"student_name"},{title:"Present",dataIndex:"present"},{title:"Absent",dataIndex:"absent"},{title:"Late",dataIndex:"late"}],[]),V=i.useMemo(()=>S?.student_id?Ya(Fi.byStudent,{student_id:S.student_id,month:j,year:b,session:Oi()}):null,[j,S,b]),{data:q,isLoading:E}=W(t&&V?[V,t]:null,([B,z])=>Nt(B,z)),M=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(X,{options:g.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:B=>{r(B?.value??""),l(B?.label??""),c(""),h(""),p(""),v("")},required:!0}),e.jsx(X,{options:C.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:B=>{c(B?.value??""),h(B?.label??""),p(""),v("")},required:!0},`section-${s}`),e.jsx(X,{options:R,label:"Year",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:R.find(B=>String(B?.value)===String(b))??null,onChange:B=>m(String(B?.value??"")),required:!0}),e.jsx(X,{options:T,label:"Month",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:T.find(B=>String(B?.value)===String(j))??null,onChange:B=>D(String(B?.value??"").padStart(2,"0")),required:!0},`month-${b}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>k(B=>B+1)})})]}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Month",value:T.find(B=>String(B?.value)===String(j))?.label??j},{label:"Year",value:b}]}),e.jsx(yf,{})]});return e.jsxs(e.Fragment,{children:[e.jsx(ss,{title:"Monthly Report",subtitle:"Monthly class-wise attendance matrix and student drilldown.",printRef:a,exportRows:F,exportColumns:U,onRefresh:()=>P?.(),filterSection:M,summary:$,chartContent:e.jsx(ga,{summary:$,title:"Monthly Attendance Summary"}),reportTitle:"Monthly Attendance Table",fileBaseName:"monthly-attendance-report",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ot,{}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Month",value:T.find(B=>String(B?.value)===String(j))?.label??j},{label:"Year",value:b}]})]}),e.jsx(jf,{data:O,loading:f,onViewStudent:x})]})}),e.jsx(Sf,{open:!!S,onClose:()=>x(null),loading:E,data:q,studentName:S?.student_name??S?.full_name})]})}const Pf=Pt.yearlyReport,Of=t=>{const a=t?.data?.data??t?.data??t??{};return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:Array.isArray(a?.students)?a.students:Array.isArray(a?.report)?a.report:[]},Mf=t=>(Array.isArray(t)?t:[]).reduce((a,s)=>({present:a.present+Number(s?.singleStudentPresentData??s?.present??0),absent:a.absent+Number(s?.singleStudentAbsentData??s?.absent??0),late:a.late+Number(s?.late??0),leave:a.leave+Number(s?.leave??0)}),{present:0,absent:0,late:0,leave:0});function Ef({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[y,h]=i.useState(""),[u,p]=i.useState(""),[w,v]=i.useState(""),[b,m]=i.useState(""),[j,D]=i.useState(""),[I,k]=i.useState(0),S=as(t),x=ns(s,t),g=mf(t),C=i.useMemo(()=>!s||!d||I===0?null:Ya(Pf.table,{class_id:s,section_id:d,session_id:u,batch_id:b}),[b,s,I,d,u]),{data:T,isLoading:R,mutate:L}=W(t&&C?[C,t]:null,([F,U])=>Nt(F,U)),N=i.useMemo(()=>Of(T),[T]),f=i.useMemo(()=>Mf(N),[N]),P=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Present",dataIndex:"singleStudentPresentData"},{title:"Absent",dataIndex:"singleStudentAbsentData"}],[]),O=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(F,U,V)=>V+1},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",dataIndex:"full_name",key:"full_name"},{title:"Total Present",dataIndex:"singleStudentPresentData",key:"singleStudentPresentData",width:130},{title:"Total Absent",dataIndex:"singleStudentAbsentData",key:"singleStudentAbsentData",width:130}],[]),$=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(X,{options:S.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{r(F?.value??""),l(F?.label??""),c(""),h(""),m(""),D("")},required:!0}),e.jsx(X,{options:x.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{c(F?.value??""),h(F?.label??""),m(""),D("")},required:!0},`section-${s}`),e.jsx(X,{options:g.options,label:"Session",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{p(F?.value??""),v(F?.label??"")},required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>k(F=>F+1)})})]}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Session",value:w}]})]});return e.jsx(ss,{title:"Yearly Report",subtitle:"Yearly attendance summary migrated from ERP AttendanceDashboard.",printRef:a,exportRows:N,exportColumns:P,onRefresh:()=>L?.(),filterSection:$,summary:f,chartContent:e.jsx(ga,{summary:f,title:"Yearly Attendance Summary"}),reportTitle:"Yearly Attendance List",fileBaseName:"yearly-attendance-report",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ot,{}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:y},{label:"Session",value:w}]})]}),e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(F,U)=>String(F?.student_id??F?.id??U),columns:O,dataSource:N,loading:R,pagination:{pageSize:25},scroll:{x:"max-content"}})]})})}const Ff=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function $f({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(At),{isLoading:o,data:l}=W(s&&r?[`${kc}?id=${r}`,s]:null,([v,b])=>H(v,b)),{data:d}=W(s?[Fo,s]:null,([v,b])=>H(v,b)),c=i.useMemo(()=>Ff(d),[d]),y=l?.data?.[0],[h,u]=i.useState({income_head:"",name:"",invoice_no:"",date:ee(),amount:"",description:"",doc:""});i.useEffect(()=>{y&&u({income_head:y?.inc_head_id||"",name:y?.name||"",invoice_no:y?.invoice_no||"",date:y?.date?ee(y.date):ee(),amount:y?.amount||"",description:y?.note||"",doc:y?.documents||""})},[y]);const p=(v,b)=>{u(m=>({...m,[v]:b}))},w=c.find(v=>String(v.value)===String(h.income_head))??null;return o?e.jsx(A,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(A,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:v=>a(v,r),children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Edit Income"})}),e.jsx(A,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(A,{children:[e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(X,{label:"Income Head",options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"income_head",required:!0,value:w,onChange:v=>p("income_head",v?.value||"")})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0,value:h.name,onChange:v=>p("name",v.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0,value:h.invoice_no,onChange:v=>p("invoice_no",v.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:h.date,Desplay:"Date",name:"date",required:!0,onChange:v=>p("date",v)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"amount",type:"number",label:"Amount",required:!0,value:h.amount,onChange:v=>p("amount",v.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(st,{name:"description",label:"Description",rows:3,value:h.description,onChange:v=>p("description",v.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(A,{children:[e.jsx(n.Upload,{action:`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`,headers:{Authorization:s},maxCount:1,onChange:v=>{if(v.file.status==="removed"&&p("doc",""),v.file.status==="done"){const b=v.file.response?.data??v.file.response?.file??"";p("doc",String(b??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:h.doc?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:h.doc||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Uf=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Nf({token:t}){const[a,s]=i.useState([]),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,y]=i.useState({income_head:"",name:"",invoice_no:"",date:ee().format("YYYY-MM-DD"),amount:"",description:"",doc:""}),[h,u]=i.useState(!1),[p,w]=i.useState({page:1,rowsPerPage:10}),v=(f,P)=>{w({...p,page:f,rowsPerPage:parseInt(P,10)})},b=async(f,P)=>{try{await I(Ee(f,P,t),ze(P)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},{isLoading:m,error:j,data:D,mutate:I}=W(t?[wc,t,p.page,p.rowsPerPage]:null,([f,P,O,$])=>H(`${f}?page=${O}&per_page=${$}`,P)),k=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0},{id:"3",name:"Income Category",selector:"income_category",sortable:!0},{id:"4",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"5",name:"Date",selector:"date",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0},{id:"8",name:"File",selector:"documents",sortable:!1,render:f=>f?e.jsx("span",{style:{textDecoration:"underline",color:"#5080f8",cursor:"pointer"},onClick:()=>window.open(`${He()}/branch/frontoffice/${f}`,"_blank"),children:"View"}):"Not Uploaded"}],[]),S=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],x=async f=>{try{await I(qe(Ac,f,t),Ne(f)),_.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{_.error("Failed to delete the item.",{duration:1e3})}},g=async(f,P,O)=>{try{await I(Be(f,P,t)),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),await O(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},C=async(f,P)=>{f.preventDefault();const O=new FormData(f.target);await g(Cc,O,P),R(!1)},T=async f=>{if(f.preventDefault(),!f.target.date.value)_.error("Select required dates",{duration:1e3}),f.target?.date?.focus(),d("textDanger");else{const P=new FormData(f.target);await b(_c,P),f.target.reset(),o(""),y(O=>({...O,date:ee().format("YYYY-MM-DD")}))}},R=f=>{u(f)},{data:L}=W(t?[Fo,t]:null,([f,P])=>H(f,P)),N=i.useMemo(()=>Uf(L),[L]);return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Add Income"})}),e.jsx(A,{p:3,children:e.jsx("form",{onSubmit:T,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{label:"Income Head",options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"income_head",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ee(),Desplay:"Date",name:"date",status:l===""?"":"error",classnme:l,onChange:()=>d("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"amount",type:"number",label:"Amount",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(A,{children:[e.jsx(n.Upload,{action:`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`,headers:{Authorization:t},maxCount:1,onChange:f=>{if(f.file.status==="removed"&&o(""),f.file.status==="done"){const P=f.file.response?.data??f.file.response?.file??"";o(String(P??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:r?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:r||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(st,{name:"description",label:"Description",rows:3})})}),e.jsx(n.Col,{xs:24,md:12,className:"buttonCoustom",children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Income List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:v,data:{newData:D,columns:k,action:!0,Loading:m,ActionView:S,error:j,editDesign:e.jsx($f,{data:{handleUpdate:C,token:t}}),deleteTodoMutation:x,open:h,DrawerUpdate:R}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; } .buttonCoustom { margin-top: 8px; }"})]})}const $i={width:"100%",height:40};function Lf({token:t}){const[a,s]=i.useState(null),[r,o]=i.useState(null),[l,d]=i.useState(""),[c,y]=i.useState(""),[h,u]=i.useState(""),[p,w]=i.useState({page:1,rowsPerPage:10}),v=(S,x)=>{w({...p,page:S,rowsPerPage:parseInt(x,10)})},{isLoading:b,error:m,data:j,mutate:D}=W(t&&l?[l,t,p.page,p.rowsPerPage]:null,([S,x,g,C])=>H(`${S}page=${g}&per_page=${C}`,x)),I=i.useMemo(()=>[{id:"1",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"2",name:"Date",selector:"date",sortable:!0},{id:"3",name:"Name",selector:"name",sortable:!0},{id:"4",name:"Description",selector:"description",sortable:!0},{id:"5",name:"Income Category",selector:"income_category",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0}],[]),k=()=>{if(!a){_.error("Select required dates",{duration:1e3}),y("textDanger");return}if(!r){_.error("Select required dates",{duration:1e3}),u("textDanger");return}const S=a.format("YYYY-MM-DD"),x=r.format("YYYY-MM-DD");d(`${Oc}?from_date=${S}&to_date=${x}&`),w(g=>({...g,page:1}))};return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Search Income"})}),e.jsx(A,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],alignItems:"end",children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(A,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From Date"}),e.jsx(n.DatePicker,{value:a,onChange:S=>{s(S),y("")},style:$i,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(A,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To Date"}),e.jsx(n.DatePicker,{value:r,onChange:S=>{o(S),u("")},style:$i,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:k})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Income List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:v,data:{newData:j,columns:I,action:!1,Loading:b,error:m,pageController:p}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}function Bf({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(At),{isLoading:o,data:l}=W(s&&r?[`${Pc}?id=${r}`,s]:null,([u,p])=>H(u,p)),d=l?.data?.[0],[c,y]=i.useState({incomehead:"",description:""});i.useEffect(()=>{d&&y({incomehead:d?.income_category||"",description:d?.description||""})},[d]);const h=(u,p)=>{y(w=>({...w,[u]:p}))};return o?e.jsx(A,{pt:4,pb:1,style:{width:350},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(A,{pt:4,pb:1,style:{width:350},children:[e.jsx("form",{onSubmit:u=>a(u),children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(A,{children:[e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(Y,{name:"incomehead",type:"text",label:"Income Head Name",required:!0,value:c.incomehead,onChange:u=>h("incomehead",u.target.value)})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(A,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",required:!0,value:c.description,onChange:u=>h("description",u.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})})})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function qf({token:t}){const[a,s]=i.useState({incomehead:"",description:""}),[r,o]=i.useState(!1),[l,d]=i.useState({page:1,rowsPerPage:10}),c=(S,x)=>{d({...l,page:S,rowsPerPage:parseInt(x,10)})},y=async(S,x)=>{try{await w(Ee(S,x,t),ze(x)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},{isLoading:h,error:u,data:p,mutate:w}=W(t?[Dc,t,l.page,l.rowsPerPage]:null,([S,x,g,C])=>H(`${S}?page=${g}&per_page=${C}`,x)),v=i.useMemo(()=>[{id:"1",name:"Name",selector:"income_category",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],[]),b=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],m=async S=>{try{await w(qe(Ic,S,t),Ne(S)),_.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{_.error("Failed to delete the item.",{duration:1e3})}},j=async(S,x)=>{try{await w(Be(S,x,t)),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"})}catch{_.error("Failed to update the item.",{duration:1e3})}},D=async S=>{S.preventDefault();const x=new FormData(S.target);await j(Rc,x),k(!1)},I=async S=>{S.preventDefault();const x=new FormData(S.target);await y(Tc,x),S.target.reset()},k=S=>{o(S)};return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:5,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Income Head"})}),e.jsx(A,{p:3,children:e.jsx("form",{onSubmit:I,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(A,{children:e.jsx(Y,{name:"incomehead",type:"text",label:"Income Head Name",required:!0,value:a.incomehead,onChange:S=>s(x=>({...x,incomehead:S.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(A,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",required:!0,value:a.description,onChange:S=>s(x=>({...x,description:S.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,md:19,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Income Head List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:c,data:{newData:p,columns:v,action:!0,Loading:h,ActionView:b,error:u,editDesign:e.jsx(Bf,{data:{handleUpdate:D,token:t}}),deleteTodoMutation:m,open:r,DrawerUpdate:k}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Ui=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Ni=[{label:"Cash",value:"cash"},{label:"UPI",value:"upi"},{label:"Phonepay",value:"phonepay"},{label:"Google Pay",value:"google_pay"},{label:"Net Banking",value:"net_banking"},{label:"Cheque",value:"cheque"},{label:"Demand Draft",value:"demand_draft"}];function zf({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(At),{isLoading:o,data:l}=W(s&&r?[`${qc}?id=${r}`,s]:null,([D,I])=>H(D,I)),{data:d}=W(s?[$o,s]:null,([D,I])=>H(D,I)),{data:c}=W(s?[Uo,s]:null,([D,I])=>H(D,I)),y=i.useMemo(()=>Ui(d),[d]),h=i.useMemo(()=>Ui(c),[c]),u=l?.data?.[0],[p,w]=i.useState({expense_head:"",vendor:"",name:"",invoice_no:"",date:ee(),amount:"",payment_mode:"",note:"",doc:""});i.useEffect(()=>{u&&w({expense_head:u?.exp_head_id||"",vendor:u?.fk_vendor_id||"",name:u?.name||"",invoice_no:u?.invoice_number||"",date:u?.date?ee(u.date):ee(),amount:u?.amount||"",payment_mode:u?.payment_mode||"",note:u?.note||"",doc:u?.documents||""})},[u]);const v=(D,I)=>{w(k=>({...k,[D]:I}))},b=y.find(D=>String(D.value)===String(p.expense_head))??null,m=h.find(D=>String(D.value)===String(p.vendor))??null,j=Ni.find(D=>String(D.value)===String(p.payment_mode))??null;return o?e.jsx(A,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(A,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:D=>a(D,r),children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Edit Expense"})}),e.jsx(A,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(A,{children:[e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(X,{label:"Expense Head",options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"expense_head",required:!0,value:b,onChange:D=>v("expense_head",D?.value||"")})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{label:"Vendor",options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"vendor",value:m,onChange:D=>v("vendor",D?.value||"")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0,value:p.name,onChange:D=>v("name",D.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0,value:p.invoice_no,onChange:D=>v("invoice_no",D.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:p.date,Desplay:"Date",name:"date",required:!0,onChange:D=>v("date",D)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"amount",type:"number",label:"Amount",required:!0,value:p.amount,onChange:D=>v("amount",D.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{label:"Payment Mode",options:Ni,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"payment_mode",required:!0,value:j,onChange:D=>v("payment_mode",D?.value||"")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(st,{name:"note",label:"Description",rows:3,value:p.note,onChange:D=>v("note",D.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(A,{children:[e.jsx(n.Upload,{action:`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`,headers:{Authorization:s},maxCount:1,onChange:D=>{if(D.file.status==="removed"&&v("doc",""),D.file.status==="done"){const I=D.file.response?.data??D.file.response?.file??"";v("doc",String(I??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:p.doc?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:p.doc||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Li=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Yf=[{label:"Cash",value:"cash"},{label:"UPI",value:"upi"},{label:"Phonepay",value:"phonepay"},{label:"Google Pay",value:"google_pay"},{label:"Net Banking",value:"net_banking"},{label:"Cheque",value:"cheque"},{label:"Demand Draft",value:"demand_draft"}];function Vf({token:t}){const[a,s]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState({expense_head:"",vendor:"",name:"",invoice_no:"",date:ee(),amount:"",payment_mode:"",note:"",doc:""}),[c,y]=i.useState(!1),[h,u]=i.useState({page:1,rowsPerPage:10}),p=(f,P)=>{u({...h,page:f,rowsPerPage:parseInt(P,10)})},w=async(f,P)=>{try{await j(Ee(f,P,t),ze(P)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},{isLoading:v,error:b,data:m,mutate:j}=W(t?[Mc,t,h.page,h.rowsPerPage]:null,([f,P,O,$])=>H(`${f}?page=${O}&per_page=${$}`,P)),D=i.useMemo(()=>[{id:"1",name:"Sl No",selector:"__serialNumber",sortable:!0},{id:"2",name:"Name",selector:"name",sortable:!0},{id:"3",name:"Description",selector:"description",sortable:!0},{id:"4",name:"Expense Category",selector:"exp_category",sortable:!0},{id:"5",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0},{id:"8",name:"File",selector:"documents",sortable:!1,render:f=>f?e.jsx("span",{style:{textDecoration:"underline",color:"#5080f8",cursor:"pointer"},onClick:()=>window.open(`${He()}/branch/frontoffice/${f}`,"_blank"),children:"View"}):"Not Uploaded"}],[]),I=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],k=async f=>{try{await j(qe($c,f,t),Ne(f)),_.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{_.error("Failed to delete the item.",{duration:1e3})}},S=async(f,P,O)=>{try{await j(Be(f,P,t)),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),await O(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},x=async(f,P)=>{f.preventDefault();const O=new FormData(f.target);await S(Fc,O,P),C(!1)},g=async f=>{if(f.preventDefault(),!f.target.date.value)_.error("Select required dates",{duration:1e3}),f.target?.date?.focus(),o("textDanger");else{const P=new FormData(f.target);await w(Ec,P),f.target.reset(),s(""),d(O=>({...O,date:ee()}))}},C=f=>{y(f)},{data:T}=W(t?[$o,t]:null,([f,P])=>H(f,P)),{data:R}=W(t?[Uo,t]:null,([f,P])=>H(f,P)),L=i.useMemo(()=>Li(T),[T]),N=i.useMemo(()=>Li(R),[R]);return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Add Expense"})}),e.jsx(A,{p:3,children:e.jsx("form",{onSubmit:g,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{label:"Expense Head",options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"expense_head",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{label:"Vendor",options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"vendor"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:ee(),Desplay:"Date",name:"date",status:r===""?"":"error",classnme:r,onChange:()=>o("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(Y,{name:"amount",type:"number",label:"Amount",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(X,{label:"Payment Mode",options:Yf,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"payment_mode",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(A,{children:e.jsx(st,{name:"note",label:"Description",rows:3})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(A,{children:[e.jsx(n.Upload,{action:`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`,headers:{Authorization:t},maxCount:1,onChange:f=>{if(f.file.status==="removed"&&s(""),f.file.status==="done"){const P=f.file.response?.data??f.file.response?.file??"";s(String(P??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:a||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,className:"buttonCoustom",children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Expense List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:p,data:{newData:m,columns:D,action:!0,Loading:v,ActionView:I,error:b,editDesign:e.jsx(zf,{data:{handleUpdate:x,token:t}}),deleteTodoMutation:k,open:c,DrawerUpdate:C}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; } .buttonCoustom { margin-top: 8px; }"})]})}const Bi={width:"100%",height:40};function Wf({token:t}){const[a,s]=i.useState(null),[r,o]=i.useState(null),[l,d]=i.useState(""),[c,y]=i.useState(""),[h,u]=i.useState(""),[p,w]=i.useState({page:1,rowsPerPage:10}),v=(S,x)=>{w({...p,page:S,rowsPerPage:parseInt(x,10)})},{isLoading:b,error:m,data:j,mutate:D}=W(t&&l?[l,t,p.page,p.rowsPerPage]:null,([S,x,g,C])=>H(`${S}page=${g}&per_page=${C}`,x)),I=i.useMemo(()=>[{id:"1",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"2",name:"Date",selector:"date",sortable:!0},{id:"3",name:"Name",selector:"name",sortable:!0},{id:"4",name:"Description",selector:"description",sortable:!0},{id:"5",name:"Expense Category",selector:"exp_category",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0}],[]),k=()=>{if(!a){_.error("Select required dates",{duration:1e3}),y("textDanger");return}if(!r){_.error("Select required dates",{duration:1e3}),u("textDanger");return}const S=a.format("YYYY-MM-DD"),x=r.format("YYYY-MM-DD");d(`${Yc}?from_date=${S}&to_date=${x}&`),w(g=>({...g,page:1}))};return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Search Expense"})}),e.jsx(A,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],alignItems:"end",children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(A,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From Date"}),e.jsx(n.DatePicker,{value:a,onChange:S=>{s(S),y("")},style:Bi,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(A,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To Date"}),e.jsx(n.DatePicker,{value:r,onChange:S=>{o(S),u("")},style:Bi,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:k})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Expense List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:v,data:{newData:j,columns:I,action:!1,Loading:b,error:m,pageController:p}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}function Hf({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(At),{isLoading:o,data:l}=W(s&&r?[`${zc}?id=${r}`,s]:null,([u,p])=>H(u,p)),d=l?.data?.[0],[c,y]=i.useState({expensehead:"",description:""});i.useEffect(()=>{d&&y({expensehead:d?.exp_category||"",description:d?.description||""})},[d]);const h=(u,p)=>{y(w=>({...w,[u]:p}))};return o?e.jsx(A,{pt:4,pb:1,style:{width:350},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(A,{pt:4,pb:1,style:{width:350},children:[e.jsx("form",{onSubmit:u=>a(u),children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(A,{children:[e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(Y,{name:"expensehead",type:"text",label:"Expense Head Name",required:!0,value:c.expensehead,onChange:u=>h("expensehead",u.target.value)})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(A,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",required:!0,value:c.description,onChange:u=>h("description",u.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})})})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function Kf({token:t}){const[a,s]=i.useState({expensehead:"",description:""}),[r,o]=i.useState(!1),[l,d]=i.useState({page:1,rowsPerPage:10}),c=(S,x)=>{d({...l,page:S,rowsPerPage:parseInt(x,10)})},y=async(S,x)=>{try{await w(Ee(S,x,t),ze(x)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},{isLoading:h,error:u,data:p,mutate:w}=W(t?[Uc,t,l.page,l.rowsPerPage]:null,([S,x,g,C])=>H(`${S}?page=${g}&per_page=${C}`,x)),v=i.useMemo(()=>[{id:"1",name:"Name",selector:"exp_category",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],[]),b=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],m=async S=>{try{await w(qe(Bc,S,t),Ne(S)),_.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{_.error("Failed to delete the item.",{duration:1e3})}},j=async(S,x)=>{try{await w(Be(S,x,t)),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"})}catch{_.error("Failed to update the item.",{duration:1e3})}},D=async S=>{S.preventDefault();const x=new FormData(S.target);await j(Lc,x),k(!1)},I=async S=>{S.preventDefault();const x=new FormData(S.target);await y(Nc,x),S.target.reset()},k=S=>{o(S)};return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:5,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Expense Head"})}),e.jsx(A,{p:3,children:e.jsx("form",{onSubmit:I,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(A,{children:e.jsx(Y,{name:"expensehead",type:"text",label:"Expense Head Name",required:!0,value:a.expensehead,onChange:S=>s(x=>({...x,expensehead:S.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(A,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",required:!0,value:a.description,onChange:S=>s(x=>({...x,description:S.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,md:19,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Expense Head List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:c,data:{newData:p,columns:v,action:!0,Loading:h,ActionView:b,error:u,editDesign:e.jsx(Hf,{data:{handleUpdate:D,token:t}}),deleteTodoMutation:m,open:r,DrawerUpdate:k}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function Gf({token:t}){const[a,s]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,y]=i.useState(0),[h,u]=i.useState(""),[p,w]=i.useState({page:1,rowsPerPage:10}),v=(R,L)=>{w({...p,page:R,rowsPerPage:parseInt(L,10)})},{isLoading:b,error:m,data:j,mutate:D}=W(t&&h?[h,t,p.page,p.rowsPerPage]:null,([R,L,N,f])=>H(`${R}page=${N}&per_page=${f}`,L)),{data:I}=W(t?[Zs,t]:null,([R,L])=>H(R,L)),{data:k}=W(t&&a?[`${er}?class_id=${a}`,t]:null,([R,L])=>H(R,L)),S=i.useMemo(()=>I?Array.isArray(I)?I:Array.isArray(I?.data)?I.data:[]:[],[I]),x=i.useMemo(()=>k?Array.isArray(k)?k:Array.isArray(k?.data)?k.data:[]:[],[k]),g=i.useMemo(()=>[{id:"1",name:"First Name",selector:"firstname",sortable:!0},{id:"2",name:"Last Name",selector:"lastname",sortable:!0},{id:"3",name:"Class",selector:"class",sortable:!0},{id:"4",name:"Section",selector:"section",sortable:!0},{id:"5",name:"ID",selector:"username",sortable:!0},{id:"6",name:"Password",selector:"password",sortable:!0}],[]),C=R=>{s(R?.value||""),o(""),y(L=>L+1)},T=R=>{if(R.preventDefault(),!a){_.error("Please select class",{duration:1e3});return}if(!r){_.error("Please select section",{duration:1e3});return}const L=`${Vc}?class_id=${a}&section_id=${r}&keyword=${l||""}&`;u(L),w(N=>({...N,page:1}))};return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Student Login Credential"})}),e.jsx(A,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(A,{children:e.jsx(X,{label:"Class",options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:S.find(R=>String(R.value)===String(a))??null,onChange:C})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(A,{children:e.jsx(X,{label:"Section",options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:x.find(R=>String(R.value)===String(r))??null,onChange:R=>o(R?.value||"")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(A,{children:e.jsx(Y,{name:"keyword",type:"text",label:"Search By Keyword",value:l,onChange:R=>d(R.target.value)})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:T})})]})})]})}),h&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:v,data:{newData:j,columns:g,action:!1,Loading:b,error:m,pageController:p}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function Jf({token:t}){const[a,s]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,y]=i.useState(0),[h,u]=i.useState(No),[p,w]=i.useState(!1),[v,b]=i.useState(null);console.log("Selected Student ID:",p);const[m,j]=i.useState({page:1,rowsPerPage:10}),D=($,F)=>{j({...m,page:$,rowsPerPage:parseInt(F,10)})},{isLoading:I,error:k,data:S,mutate:x}=W(t&&h?[h,t,m.page,m.rowsPerPage]:null,([$,F,U,V])=>H(`${$}page=${U}&per_page=${V}`,F)),{data:g}=W(t?[Zs,t]:null,([$,F])=>H($,F)),{data:C}=W(t&&a?[`${er}?class_id=${a}`,t]:null,([$,F])=>H($,F)),T=i.useMemo(()=>g?Array.isArray(g)?g:Array.isArray(g?.data)?g.data:[]:[],[g]),R=i.useMemo(()=>C?Array.isArray(C)?C:Array.isArray(C?.data)?C.data:[]:[],[C]),L=i.useMemo(()=>[{id:"1",name:"EC No",selector:"ec_no",sortable:!0},{id:"2",name:"Roll NO",selector:"roll_no",sortable:!0},{id:"3",name:"Admission Number",selector:"admission_no",sortable:!0},{id:"4",name:"First Name",selector:"firstname",sortable:!0},{id:"5",name:"Last Name",selector:"lastname",sortable:!0},{id:"6",name:"Class",selector:"class",sortable:!0},{id:"7",name:"Section",selector:"section",sortable:!0},{id:"8",name:"Father Name",selector:"father_name",sortable:!0},{id:"9",name:"Medicine",selector:"Medical",sortable:!1,render:($,F)=>e.jsx(n.Button,{type:"primary",size:"small",onClick:()=>{b(F.id),w(!0)},children:"Medical"})}],[]),N=$=>{s($?.value||""),o(""),y(F=>F+1)},f=$=>{if($.preventDefault(),!a||!r){_.error("Please select class and section",{duration:1e3});return}const F=`${Bo}?cID=${a}&sID=${r}&page=${m.page}&per_page=${m.rowsPerPage}&`;u(F),j(U=>({...U,page:1}))},P=$=>{$.preventDefault();const F=$.target.searchField?.value||"";d(F);const U=`${Lo}?key=${F}&page=${m.page}&per_page=${m.rowsPerPage}&`;u(U),j(V=>({...V,page:1}))},O=async $=>{$.preventDefault();const F=new FormData($.target),U=Wc;try{await x(addData(U,F,t)),_.success("Medicine added successfully",{duration:1e3}),$.target.reset()}catch{_.error("Failed to add medicine",{duration:1e3})}};return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Medical Report"})}),e.jsx(A,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:f,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(A,{children:e.jsx(X,{label:"Class",options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:T.find($=>String($.value)===String(a))??null,onChange:N})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(A,{children:e.jsx(X,{label:"Section",options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:R.find($=>String($.value)===String(r))??null,onChange:$=>o($?.value||"")})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:P,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:16,children:e.jsx(Y,{name:"searchField",type:"text",label:"Search By Keyword",value:l,onChange:$=>d($.target.value)})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:D,data:{newData:S,columns:L,action:!1,Loading:I,error:k,pageController:m}})})]})})]}),e.jsx(n.Drawer,{title:"Medical Report",placement:"right",width:600,open:p,footer:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(ne,{type:"button",value:"Close",color:"default"})})}),children:e.jsx(Qf,{studentId:v,token:t,onAddMedicine:O})}),e.jsx("style",{children:".noDisplay { display: none; } .buttonCoustom { margin-top: 8px; }"})]})}function Qf({studentId:t,token:a,onAddMedicine:s}){const{data:r}=W(a&&t?[`${qo}?id=${t}`,a]:null,([y,h])=>H(y,h)),{data:o}=W(a&&t?[`${Hc}?student_id=${t}`,a]:null,([y,h])=>H(y,h)),l=r?.studentBasicDetails?.[0];let d=[];Array.isArray(o?.data)?d=o.data:Array.isArray(o)&&(d=o);const c=[{title:"Medicine",dataIndex:"medicine",key:"medicine"},{title:"Notes",dataIndex:"notes",key:"notes"},{title:"Date",dataIndex:"date_time",key:"date_time"}];return e.jsxs(A,{children:[l&&e.jsxs(A,{mb:3,children:[e.jsxs(Se,{level:4,children:["Name: ",l?.firstname," ",l?.lastname]}),e.jsxs("div",{style:{fontSize:15},children:["Class: ",l?.class," (",l?.section,")"]}),e.jsxs("div",{style:{fontSize:15},children:["Admission No: ",l?.admission_no]})]}),e.jsx(Se,{level:5,style:{marginBottom:8},children:"Add Medicine"}),e.jsx("form",{onSubmit:s,style:{marginBottom:24},children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(A,{children:[e.jsx(Y,{name:"medicine",type:"text",label:"Medicine Name",required:!0}),e.jsx("input",{name:"student_id",type:"hidden",value:t||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(A,{children:e.jsx(st,{name:"notes",label:"Note",rows:3})})}),e.jsx(n.Col,{xs:24,children:e.jsx(A,{children:e.jsx(Me,{format:"YYYY-MM-DD HH:mm",Desplay:"Date",name:"date_time",defaultValue:ee()})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Add",color:"primary"})})})})})]})}),e.jsx(Se,{level:5,style:{marginBottom:8},children:"Previous Medicine"}),e.jsx(n.Table,{size:"small",dataSource:d,pagination:!1,columns:c})]})}const{Group:qi}=n.Checkbox;function Xf({token:t}){const[a,s]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,y]=i.useState(0),[h,u]=i.useState(No),[p,w]=i.useState(!1),[v,b]=i.useState(null),[m,j]=i.useState({page:1,rowsPerPage:10}),D=(U,V)=>{j({...m,page:U,rowsPerPage:parseInt(V,10)})},{isLoading:I,error:k,data:S,mutate:x}=W(t&&h?[h,t,m.page,m.rowsPerPage]:null,([U,V,q,E])=>H(`${U}page=${q}&per_page=${E}`,V)),{data:g}=W(t?[Zs,t]:null,([U,V])=>H(U,V)),{data:C}=W(t&&a?[`${er}?class_id=${a}`,t]:null,([U,V])=>H(U,V)),T=i.useMemo(()=>g?Array.isArray(g)?g:Array.isArray(g?.data)?g.data:[]:[],[g]),R=i.useMemo(()=>C?Array.isArray(C)?C:Array.isArray(C?.data)?C.data:[]:[],[C]),L=i.useMemo(()=>[{id:"1",name:"EC No",selector:"ec_no",sortable:!0},{id:"2",name:"Roll NO",selector:"roll_no",sortable:!0},{id:"3",name:"Admission Number",selector:"admission_no",sortable:!0},{id:"4",name:"First Name",selector:"firstname",sortable:!0},{id:"5",name:"Last Name",selector:"lastname",sortable:!0},{id:"6",name:"Class",selector:"class",sortable:!0},{id:"7",name:"Section",selector:"section",sortable:!0},{id:"8",name:"Father Name",selector:"father_name",sortable:!0},{id:"9",name:"Assign Subject",selector:"Assign",sortable:!1,render:(U,V)=>e.jsx(n.Button,{type:"primary",size:"small",onClick:()=>{b(V.id),w(!0)},children:"Assign"})}],[]),N=U=>{s(U?.value||""),o(""),y(V=>V+1)},f=U=>{if(U.preventDefault(),!a||!r){_.error("Please select class and section",{duration:1e3});return}const V=`${Bo}?cID=${a}&sID=${r}&page=${m.page}&per_page=${m.rowsPerPage}&`;u(V),j(q=>({...q,page:1}))},P=U=>{U.preventDefault();const V=U.target.searchField?.value||"";d(V);const q=`${Lo}?key=${V}&page=${m.page}&per_page=${m.rowsPerPage}&`;u(q),j(E=>({...E,page:1}))},O=async U=>{U.preventDefault();const V=new FormData(U.target),q=Gc;try{await x(Be(q,V,t)),_.success("Subject updated successfully",{duration:1e3}),U.target.reset(),w(!1)}catch{_.error("Failed to update subject",{duration:1e3})}},$=async U=>{U.preventDefault();const V=new FormData(U.target),q=Vs;try{await x(Be(q,V,t)),_.success("Extra curricular updated successfully",{duration:1e3}),U.target.reset(),w(!1)}catch{_.error("Failed to update extra curricular",{duration:1e3})}},F=U=>{w(U)};return e.jsxs(A,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Assign Student Subject"})}),e.jsx(A,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:f,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(A,{children:e.jsx(X,{label:"Class",options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:T.find(U=>String(U.value)===String(a))??null,onChange:N})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(A,{children:e.jsx(X,{label:"Section",options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:R.find(U=>String(U.value)===String(r))??null,onChange:U=>o(U?.value||"")})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:P,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:16,children:e.jsx(Y,{name:"searchField",type:"text",label:"Search By Keyword",value:l,onChange:U=>d(U.target.value)})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(A,{pt:3,children:e.jsx(Re,{parentCallback:D,data:{newData:S,columns:L,action:!1,Loading:I,error:k,pageController:m}})})]})})]}),p&&e.jsx(Zf,{open:p,DrawerUpdate:F,studentId:v,token:t,onUpdate:O,onUpdate2:$}),e.jsx("style",{children:".noDisplay { display: none; } .buttonCoustom { margin-top: 8px; }"})]})}function Zf({open:t,DrawerUpdate:a,studentId:s,token:r,onUpdate:o,onUpdate2:l}){const[d,c]=i.useState([]),[y,h]=i.useState([]),[u,p]=i.useState([]),[w,v]=i.useState(!1),[b,m]=i.useState([]),[j,D]=i.useState([]),[I,k]=i.useState([]),{trigger:S}=tt(qo,async(L,{arg:N})=>await H(`${L}?id=${N.id}`,r)),{trigger:x}=tt(Vs,async()=>await H(`${Vs}?student_id=${s}`,r)),{trigger:g}=tt(Kc,async(L,{arg:N})=>await H(`${L}?id=${N.id}`,r));i.useEffect(()=>{(async()=>{if(!s)return;v(!0);const N=await S({id:s});N?.studentBasicDetails?.[0];const f=await x(),P=await g({id:s});c(N),p(P),N&&h(f),v(!1)})()},[s,S,x,g]);const C=L=>{D(L);const N=d?.data?.filter(f=>!L.includes(f.value));m(JSON.stringify(N))},T=L=>{k(L)},R=d?.studentBasicDetails?.[0];return!w&&s?e.jsx("div",{style:{position:"fixed",top:0,right:0,width:400,height:"100vh",background:"#fff",boxShadow:"-2px 0 8px rgba(0,0,0,0.15)",zIndex:9999,overflow:"auto"},children:e.jsxs(A,{p:3,children:[e.jsx(A,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(Se,{level:5,style:{margin:0,color:"#fff"},children:"Edit Assigned Subjects"})}),e.jsxs(A,{p:3,children:[R&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs(Se,{level:4,children:["Name: ",R?.firstname," ",R?.lastname]}),e.jsxs("div",{style:{fontSize:15},children:["Class: ",R?.class," (",R?.section,")"]}),e.jsxs("div",{style:{fontSize:15},children:["Admission No: ",R?.admission_no]})]}),e.jsx("form",{onSubmit:o,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsxs(n.Col,{xs:24,children:[e.jsx(Se,{level:5,children:"Subjects"}),e.jsx(qi,{options:d?.data?.map(L=>({label:L.label||L.name,value:L.value})),value:j,onChange:C,style:{display:"grid",gap:8}})]}),e.jsxs(n.Col,{xs:24,children:[e.jsx("input",{name:"student_id",type:"hidden",value:s||"",readOnly:!0}),e.jsx("input",{name:"subjectUncheck[]",type:"hidden",value:b,readOnly:!0})]}),d?.data?.length===0?e.jsx(n.Col,{xs:24,children:e.jsx("span",{style:{cursor:"pointer",fontSize:15,color:"blue",textDecoration:"underline"},children:"Please Assign Subject"})}):e.jsx(n.Col,{xs:24,className:"buttonCoustom",children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Update",color:"primary"})})})})})]})}),y?.data?.length>0&&e.jsx("form",{onSubmit:l,style:{marginTop:24},children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsxs(n.Col,{xs:24,children:[e.jsx(Se,{level:5,children:"Extra Curricular Activities"}),e.jsx(qi,{options:y?.data?.map(L=>({label:L.label||L.name,value:L.value})),value:I,onChange:T,style:{display:"grid",gap:8}})]}),e.jsx(n.Col,{xs:24,children:e.jsx("input",{name:"student_id",type:"hidden",value:s||"",readOnly:!0})}),e.jsx(n.Col,{xs:24,className:"buttonCoustom",children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(A,{children:e.jsx(ne,{type:"submit",value:"Update",color:"primary"})})})})})]})})]})]})}):e.jsx("div",{style:{position:"fixed",top:0,right:0,width:400,height:"100vh",background:"#fff",boxShadow:"-2px 0 8px rgba(0,0,0,0.15)",zIndex:9999,overflow:"auto"},children:e.jsx(A,{p:3,children:e.jsx("div",{children:"Loading..."})})})}function ey(){return null}const rs=t=>t??localStorage.getItem("authToken")??"",ty=(t,a)=>{const s=String(t??""),r=String(a);return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},cl=()=>JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",De={uploadNotes:"api/branchapi/Academy/uploadNotes",master:{classes:{dropdown:"api/branchapi/academy/classdropdownlist",table:"api/branchapi/academy/classestableList",add:"api/branchapi/academy/addclasses",edit:"api/branchapi/academy/editclass",remove:"api/branchapi/academy/deleteclass",show:"api/branchapi/academy/classShowdata"},sections:{list:"api/branchapi/academy/sectionlist",table:"api/branchapi/academy/sectiontableList",add:"api/branchapi/academy/addsections",edit:"api/branchapi/academy/editsection",remove:"api/branchapi/academy/deletesection",show:"api/branchapi/academy/sectionShowdata",byClass:"api/branchapi/academy/sectionoftheClass"},subjects:{dropdown:"api/branchapi/Academy/getClassSubjectdropdown",byClassLabelValue:"api/branchapi/Academy/getSubjectsbyClassaslablevalue",table:"api/branchapi/academy/subjecttableList",add:"api/branchapi/academy/addsubjects",edit:"api/branchapi/academy/editsubject",remove:"api/branchapi/academy/deletesubject",show:"api/branchapi/academy/subjectShowdata"},holidays:{table:"api/branchapi/academy/holidayList",add:"api/branchapi/academy/addholidays",edit:"api/branchapi/academy/editholidays",remove:"api/branchapi/academy/deleteholiday",show:"api/branchapi/academy/getByIdholidays"}},assignSubjects:{assign:"api/branchapi/Academy/assign_class_subjects",list:"api/branchapi/academy/getSubjectsbyClass",update:"api/branchapi/academy/updateAssignSubject",editByClass:"api/branchapi/academy/editSubjectsbyClass"},assignByClass:{teacherDropdown:"api/branchapi/topics/getTeacherDropdown",classWithSection:"api/branchapi/academy/getClasswithSection",assignedSubjectsOfTeacher:"api/branchapi/academy/getassignedSubjectsofTeacher",subjectsOfTeacherByTeacherId:"api/branchapi/academy/getSubjectsofTeacherbyTeacherID",assignClassToTeacher:"api/branchapi/academy/assignClasstoTeacher",deleteTeacherSub:"api/branchapi/academy/deleteTeacherSub"},promoteStudents:{searchByClassSection:"api/branchapi/student/currentSessionStudentlist",sessionDropdown:"api/branchapi/generalSettings/sessiondropdown",promote:"api/branchapi/student/promotestudent"},timeGroup:{table:"api/branchapi/academy/getTimeGroupTable",add:"api/branchapi/academy/addTimeGroup",edit:"api/branchapi/academy/editTimeGroup",remove:"api/branchapi/academy/deleteTimeGroup",show:"api/branchapi/academy/getTimeGroupDataById",dropdown:"api/branchapi/academy/getTimeGroupDropDown"},assignTimeGroup:{classIdByTimeGroup:"api/branchapi/academy/getClassIdByTimeGroup",table:"api/branchapi/academy/getAssignedTimeGroupTable",show:"api/branchapi/academy/getAssignedTimeGroupDataById",assign:"api/branchapi/academy/assignTimeGroup"},timetable:{save:"api/timetable/save",byClassSection:"api/timetable/class",teacherTimetable:"api/timetable/teacher/",teachersBySubject:"api/branchapi/Academy/gettechersSubject"},notes:{table:"api/branchapi/Academy/getNotesTable",add:"api/branchapi/Academy/addNotes"},syllabus:{table:"api/branchapi/Academy/getsyllabusTable",add:"api/branchapi/Academy/addsyllabus",edit:"api/branchapi/Academy/editsyllabus"},transferCertificate:{studentList:"api/branchapi/student/getstudenttransferCertificateList",addData:"api/branchapi/academy/addtransferCertificatedata",view:"api/branchapi/academy/gettransferCertificateUrl"},coscholastic:{table:"api/branchapi/academy/getcoscholastic",addSkill:"api/branchapi/academy/add_coscholastic_skill",deleteSkill:"api/branchapi/academy/deleteCoscholastic",categoryDropdown:"api/branchapi/academy/coscholastic_categorydropdown",addCategory:"api/branchapi/academy/addcoscholastic_category",deleteCategory:"api/branchapi/academy/coscholasticCategoryDelete"}},ay=()=>ty(He(),De.uploadNotes),ny=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return H(l,rs(r))},wt=async(t,a,s,{includeSession:r=!1}={})=>{const o=a instanceof FormData?a:new FormData;return r&&!o.has("session_id")&&o.append("session_id",cl()),Ee(t,o,rs(s))},Bt=async(t,a,s,{includeSession:r=!1}={})=>{const o=a instanceof FormData?a:new FormData;return r&&!o.has("session_id")&&o.append("session_id",cl()),Be(t,o,rs(s))},qt=async(t,a,s)=>qe(t,a,rs(s)),Ln=De.master.sections,an=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>W(r&&t?[t,a,s,r]:null,([l,d,c,y])=>ny({baseUrl:l,page:d,perPage:c},y)),sy=({token:t,page:a=1,perPage:s=10})=>an({token:t,baseUrl:Ln.table,page:a,perPage:s}),ry=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function iy({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),{data:y,isLoading:h,mutate:u}=sy({token:t,page:a.page,perPage:a.perPage}),p=i.useMemo(()=>ry(y),[y]),w=i.useMemo(()=>y?.pagination?.total_rows??y?.pagination?.total??p.length??0,[y,p]),v=async I=>{I.preventDefault();const k=new FormData(I.target);try{await wt(Ln.add,k,t),_.success("Success! Added new item.",{duration:1e3}),I.target.reset(),u()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to add the new item.",{duration:1500})}},b=async I=>{try{await qt(Ln.remove,I,t),_.success("Success! Deleted item.",{duration:1e3}),u()}catch(k){_.error(k?.response?.data?.msg??k?.message??"Failed to delete the item.",{duration:1500})}},m=I=>{d(I),o(!0),c.setFieldsValue({section:I?.section??""})},j=async I=>{const k=new FormData;k.append("id",String(l?.id??"")),k.append("section",I.section??"");try{await Bt(Ln.edit,k,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),u()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update the item.",{duration:1500})}},D=i.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(I,k)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>m(k)}),e.jsx(n.Popconfirm,{title:"Delete this section?",onConfirm:()=>b(k?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Section",open:r,onClose:()=>{o(!1),d(null)},width:420,children:e.jsxs(n.Form,{form:c,layout:"vertical",onFinish:j,children:[e.jsx(n.Form.Item,{label:"Section Name",name:"section",rules:[{required:!0,message:"Section Name is required"}],children:e.jsx(n.Input,{placeholder:"Section Name"})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Section"}),children:e.jsx("form",{onSubmit:v,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"section",label:"Section Name",required:!0}),e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Section List"}),extra:e.jsx(n.Space,{}),children:e.jsx(n.Table,{rowKey:I=>I.id,columns:D,dataSource:p,loading:h,pagination:{current:a.page,pageSize:a.perPage,total:w,showSizeChanger:!0,onChange:(I,k)=>s({page:I,perPage:k})}})})]})}function oy({token:t}){return e.jsx(iy,{token:t})}const Na=De.master.classes,ly=({token:t,page:a=1,perPage:s=10})=>an({token:t,baseUrl:Na.table,page:a,perPage:s}),dy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},cy=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function uy({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),[y]=n.Form.useForm(),{data:h}=W(t?[De.master.sections.list,t]:null,([T,R])=>H(T,R)),u=i.useMemo(()=>cy(h),[h]),p=i.useMemo(()=>u.map(T=>({label:T.label??T.section??String(T.value??""),value:String(T.value??T.id??"")})),[u]),{data:w,isLoading:v,mutate:b}=ly({token:t,page:a.page,perPage:a.perPage}),m=i.useMemo(()=>dy(w),[w]),j=i.useMemo(()=>w?.pagination?.total_rows??w?.pagination?.total??m.length??0,[w,m]),{data:D}=W(t&&l?[`${Na.show}?id=${encodeURIComponent(String(l))}`,t]:null,([T,R])=>H(T,R)),I=i.useMemo(()=>{const T=D?.data??D;return Array.isArray(T)?T:Array.isArray(T?.data)?T.data:T?[T]:[]},[D]),k=T=>{const R=T?.id??T?.class_id;R&&(d(R),o(!0))};i.useEffect(()=>{if(!r||!I.length)return;const T=I[0],R=I.map(f=>f?.section_id??f?.fk_sectionId??f?.sectionId??f?.section).filter(f=>f!=null&&String(f).trim()!=="").map(f=>String(f)),L=Array.isArray(T?.section_ids)?T.section_ids.map(f=>String(f)):typeof T?.section_ids=="string"?T.section_ids.split(",").map(f=>f.trim()).filter(Boolean):Array.isArray(T?.section)?T.section.map(f=>String(f)):[],N=R.length?R:L;y.setFieldsValue({name:T?.class??T?.name??"",section:N})},[r,I,y]);const S=async T=>{const R=new FormData;R.append("name",T.name??""),(T.section??[]).forEach(L=>R.append("section[]",String(L)));try{await wt(Na.add,R,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),b()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},x=async T=>{const R=new FormData;R.append("id",String(l??"")),R.append("name",T.name??""),(T.section??[]).forEach(L=>R.append("section[]",String(L)));try{await Bt(Na.edit,R,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),b()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to update the item.",{duration:1500})}},g=async T=>{try{await qt(Na.remove,T,t),_.success("Success! Deleted item.",{duration:1e3}),b()}catch(R){_.error(R?.response?.data?.msg??R?.message??"Failed to delete the item.",{duration:1500})}},C=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(T,R)=>T??R?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:T=>T??""},{title:"Actions",key:"actions",width:120,render:(T,R)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>k(R)}),e.jsx(n.Popconfirm,{title:"Delete this class?",onConfirm:()=>g(R?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Class",open:r,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(n.Form,{form:y,layout:"vertical",onFinish:x,children:[e.jsx(n.Form.Item,{label:"Class",name:"name",rules:[{required:!0,message:"Class is required"}],children:e.jsx(n.Input,{placeholder:"Class"})}),e.jsx(n.Form.Item,{label:"Sections",name:"section",rules:[{required:!0,message:"Please select at least one section"}],children:e.jsx(n.Checkbox.Group,{options:p})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Class"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:S,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",label:"Class",rules:[{required:!0,message:"Class is required"}],children:e.jsx(n.Input,{placeholder:"Class"})}),e.jsx(n.Form.Item,{name:"section",label:"Sections",rules:[{required:!0,message:"Select at least one section"}],children:e.jsx(n.Checkbox.Group,{options:p})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Class List"}),children:e.jsx(n.Table,{rowKey:T=>T.id,columns:C,dataSource:m,loading:v,pagination:{current:a.page,pageSize:a.perPage,total:j,showSizeChanger:!0,onChange:(T,R)=>s({page:T,perPage:R})}})})]})}function py({token:t}){return e.jsx(uy,{token:t})}const La=De.master.subjects,my=({token:t,page:a=1,perPage:s=10})=>an({token:t,baseUrl:La.table,page:a,perPage:s}),hy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},zi=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],Yi=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function fy({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),[y]=n.Form.useForm(),{data:h,isLoading:u,mutate:p}=my({token:t,page:a.page,perPage:a.perPage}),w=i.useMemo(()=>hy(h),[h]),v=i.useMemo(()=>h?.pagination?.total_rows??h?.pagination?.total??w.length??0,[h,w]),{data:b}=W(t&&l?[`${La.show}?id=${encodeURIComponent(String(l))}`,t]:null,([x,g])=>H(x,g)),m=i.useMemo(()=>{const x=b?.data??b;return Array.isArray(x)?x[0]:x??null},[b]);i.useEffect(()=>{r&&m&&y.setFieldsValue({name:m?.name??"",subject_type:m?.subject_type??m?.type??"",type:"",subject_types:Array.isArray(m?.subject_types)?m.subject_types:typeof m?.subject_types=="string"?m.subject_types.split(",").map(x=>x.trim()).filter(Boolean):[],code:m?.code??""})},[r,m,y]);const j=async x=>{const g=x?.type??x?.subject_type??"",C={name:x?.name??"",subject_type:g,type:g,subject_types:Array.isArray(x?.subject_types)?x.subject_types:[],code:x?.code??""};try{await Ee(La.add,C,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),p()}catch(T){_.error(T?.response?.data?.msg??T?.message??"Failed to add the new item.",{duration:1500})}},D=async x=>{const g=new FormData,C=x?.type??x?.subject_type??"";g.append("id",String(l??"")),g.append("name",x.name??""),g.append("subject_type",x.subject_type??""),g.append("subject_type",C),g.append("type",C),g.append("code",x.code??"");try{await Bt(La.edit,g,t),_.success("Success! Updated item.",{duration:1e3}),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(T){_.error(T?.response?.data?.msg??T?.message??"Failed to update the item.",{duration:1500})}},I=async x=>{try{await qt(La.remove,x,t),_.success("Success! Deleted item.",{duration:1e3}),p()}catch(g){_.error(g?.response?.data?.msg??g?.message??"Failed to delete the item.",{duration:1500})}},k=x=>{const g=x?.id;g&&(d(g),o(!0))},S=i.useMemo(()=>[{title:"Subject Name",dataIndex:"name",key:"name"},{title:"Subject",dataIndex:"subject_type",key:"subject_type"},{title:"Subject Code",dataIndex:"code",key:"code"},{title:"Subject Type",key:"subject_types",render:(x,g)=>{const C=[],T=g?.subject_types;Array.isArray(T)?T.forEach(P=>{const O=String(P??"").trim();O&&C.push(O)}):typeof T=="string"&&T.split(",").map(P=>P.trim()).filter(Boolean).forEach(P=>C.push(P));const R=["yes","1","true"].includes(String(g?.is_practical??"").toLowerCase()),L=["yes","1","true"].includes(String(g?.is_theory??"").toLowerCase());R&&C.push("Practical"),L&&C.push("Theory");const N=C.map(P=>String(P??"").trim()).filter(Boolean).map(P=>P.toLowerCase()==="practical"?"Practical":P.toLowerCase()==="theory"?"Theory":P),f=Array.from(new Set(N));return f.length?f.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(x,g)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>k(g)}),e.jsx(n.Popconfirm,{title:"Delete this subject?",onConfirm:()=>I(g?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Subject",open:r,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(n.Form,{form:y,layout:"vertical",onFinish:D,children:[e.jsx(n.Form.Item,{label:"Subject Name",name:"name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(Y,{placeholder:"Subject Name"})}),e.jsx(n.Form.Item,{label:"Subject",name:"subject_type",rules:[{required:!0,message:"Select subject category"}],children:e.jsx(n.Radio.Group,{options:Yi})}),e.jsx(n.Form.Item,{label:"Subject Type",name:"subject_types",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(n.Checkbox.Group,{options:zi})}),e.jsx(n.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(Y,{placeholder:"Subject Code"})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Subject"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",label:"Subject Name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(Y,{placeholder:"Subject Name"})}),e.jsx(n.Form.Item,{name:"subject_type",label:"Subject",rules:[{required:!0,message:"Select subject"}],children:e.jsx(n.Radio.Group,{options:Yi})}),e.jsx(n.Form.Item,{name:"subject_types",label:"Subject Type",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(n.Checkbox.Group,{options:zi})}),e.jsx(n.Form.Item,{name:"code",label:"Subject Code",children:e.jsx(Y,{placeholder:"Subject Code"})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Subject List"}),children:e.jsx(n.Table,{rowKey:x=>x.id,columns:S,dataSource:w,loading:u,pagination:{current:a.page,pageSize:a.perPage,total:v,showSizeChanger:!0,onChange:(x,g)=>s({page:x,perPage:g})}})})]})}function yy({token:t}){return e.jsx(fy,{token:t})}const Ba=De.master.holidays,gy=({token:t,page:a=1,perPage:s=10})=>an({token:t,baseUrl:Ba.table,page:a,perPage:s}),xy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},wn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function by({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),[y]=n.Form.useForm(),{data:h,isLoading:u,mutate:p}=gy({token:t,page:a.page,perPage:a.perPage}),w=i.useMemo(()=>xy(h),[h]),v=i.useMemo(()=>h?.pagination?.total_rows??h?.pagination?.total??w.length??0,[h,w]),{data:b}=W(t&&l?[`${Ba.show}?id=${encodeURIComponent(String(l))}`,t]:null,([x,g])=>H(x,g)),m=i.useMemo(()=>{const x=b?.data??b;return Array.isArray(x)?x[0]:x??null},[b]);i.useEffect(()=>{r&&m&&y.setFieldsValue({title:m?.holiday_title??"",description:m?.holiday_description??"",from:m?.start_date?ee(m.start_date):null,to:m?.end_date?ee(m.end_date):null})},[r,m,y]);const j=async x=>{const g=new FormData;g.append("title",x.title??""),g.append("description",x.description??""),g.append("from",x.from?ee(x.from).format("YYYY-MM-DD"):""),g.append("to",x.to?ee(x.to).format("YYYY-MM-DD"):"");try{await wt(Ba.add,g,t,{includeSession:!0}),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),p()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to add the new item.",{duration:1500})}},D=async x=>{const g=new FormData;g.append("id",String(l??"")),g.append("title",x.title??""),g.append("description",x.description??""),g.append("from",x.from?ee(x.from).format("YYYY-MM-DD"):""),g.append("to",x.to?ee(x.to).format("YYYY-MM-DD"):"");try{await Bt(Ba.edit,g,t,{includeSession:!0}),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to update the item.",{duration:1500})}},I=async x=>{try{await qt(Ba.remove,x,t),_.success("Success! Deleted item.",{duration:1e3}),p()}catch(g){_.error(g?.response?.data?.msg??g?.message??"Failed to delete the item.",{duration:1500})}},k=x=>{const g=x?.id;g&&(d(g),o(!0))},S=i.useMemo(()=>[{title:"Holiday Title",dataIndex:"holiday_title",key:"holiday_title"},{title:"Holiday Description",dataIndex:"holiday_description",key:"holiday_description"},{title:"Start From",dataIndex:"start_date",key:"start_date"},{title:"End At",dataIndex:"end_date",key:"end_date"},{title:"Actions",key:"actions",width:120,render:(x,g)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>k(g)}),e.jsx(n.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>I(g?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Holiday",open:r,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(n.Form,{form:y,layout:"vertical",onFinish:D,children:[e.jsx(n.Form.Item,{label:"Holiday Title",name:"title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(Y,{placeholder:"Holiday Title"})}),e.jsx(n.Form.Item,{label:"Holiday Description",name:"description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(Y,{placeholder:"Holiday Description"})}),e.jsx(n.Form.Item,{label:"Start From",name:"from",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:wn})}),e.jsx(n.Form.Item,{label:"End At",name:"to",rules:[{required:!0,message:"End date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:wn})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Holidays"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"title",label:"Holiday Title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(Y,{placeholder:"Holiday Title"})}),e.jsx(n.Form.Item,{name:"description",label:"Holiday Description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(st,{placeholder:"Holiday Description"})}),e.jsx(n.Form.Item,{name:"from",label:"Start From",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:wn})}),e.jsx(n.Form.Item,{name:"to",label:"End At",rules:[{required:!0,message:"End date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:wn})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Holidays List"}),children:e.jsx(n.Table,{rowKey:x=>x.id,columns:S,dataSource:w,loading:u,pagination:{current:a.page,pageSize:a.perPage,total:v,showSizeChanger:!0,onChange:(x,g)=>s({page:x,perPage:g})}})})]})}function jy({token:t}){return e.jsx(by,{token:t})}const Bn=De.assignSubjects,Sy=({token:t,page:a=1,perPage:s=50})=>an({token:t,baseUrl:Bn.list,page:a,perPage:s}),Vi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],vy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function wy({token:t}){const[a,s]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,y]=i.useState(!1),[h,u]=i.useState(!1),[p,w]=i.useState(null),[v,b]=i.useState([]),{data:m}=W(t?[De.master.classes.dropdown,t]:null,([O,$])=>H(O,$)),{data:j}=W(t?[De.master.subjects.dropdown,t]:null,([O,$])=>H(O,$)),D=i.useMemo(()=>Vi(m),[m]),I=i.useMemo(()=>Vi(j),[j]),k=i.useMemo(()=>I.map(O=>({label:O.label??O.subject??String(O.value??""),value:O.value??O.id})),[I]),{data:S,isLoading:x,mutate:g}=Sy({token:t,page:a.page,perPage:a.perPage}),C=i.useMemo(()=>vy(S),[S]),T=i.useMemo(()=>S?.pagination?.total_rows??S?.pagination?.total??C.length??0,[S,C]),{data:R}=W(t&&p?[`${Bn.editByClass}?class_id=${encodeURIComponent(String(p))}`,t]:null,([O,$])=>H(O,$));i.useEffect(()=>{if(!h)return;const O=R?.data??R,$=Array.isArray(O)?O:Array.isArray(O?.data)?O.data:[];b($.map(F=>F.subject_id).filter(Boolean))},[h,R]);const L=async O=>{if(O.preventDefault(),!r?.value){_.error("Please select class",{duration:1200});return}if(!l.length){_.error("Please select subjects",{duration:1200});return}const $=new FormData;$.append("class_id",String(r.value)),l.forEach(F=>$.append("subject[]",String(F)));try{y(!0),await Bt(Bn.assign,$,t),_.success("Success! Updated item.",{duration:1e3}),o(null),d([]),g()}catch(F){_.error(F?.response?.data?.msg??F?.message??"Failed to update the item.",{duration:1500})}finally{y(!1)}},N=O=>{O&&(w(O),u(!0))},f=async()=>{if(!p)return;if(!v.length){_.error("Please select subjects",{duration:1200});return}const O=new FormData;O.append("class_id",String(p)),v.forEach($=>O.append("subject[]",String($)));try{await Bt(Bn.update,O,t),_.success("Success! Updated item.",{duration:1e3}),u(!1),w(null),g()}catch($){_.error($?.response?.data?.msg??$?.message??"Failed to update the item.",{duration:1500})}},P=i.useMemo(()=>[{title:"Class",dataIndex:"class",align:"center",width:"15%"},{title:"Subject",dataIndex:"subject_name",width:"70%",render:(O,$)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:($?.subject_name??O??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(O,$)=>e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>N($?.class_id)})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Assigned Subjects",open:h,onClose:()=>{u(!1),w(null)},width:520,extra:e.jsxs(n.Space,{children:[e.jsx(n.Button,{onClick:()=>u(!1),children:"Cancel"}),e.jsx(n.Button,{type:"primary",onClick:f,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(X,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:D.find(O=>String(O.value)===String(p))??null,onChange:()=>{},isDisabled:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(n.Checkbox.Group,{options:k,value:v,onChange:b})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Subject"}),children:e.jsx("form",{onSubmit:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:r,onChange:O=>o(O??null)}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(n.Checkbox.Group,{options:k,value:l,onChange:d})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:c?"Please Wait..":"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assigned Subject List"}),children:e.jsx(n.Table,{rowKey:O=>O.id,columns:P,dataSource:C,loading:x,pagination:{current:a.page,pageSize:a.perPage,total:T,showSizeChanger:!0,onChange:(O,$)=>s({page:O,perPage:$})}})})]})}function _y({token:t}){return e.jsx(wy,{token:t})}const ua=De.assignByClass,ul=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(typeof t?.data?.Status=="string"&&Array.isArray(t?.data?.data))return t.data.data;if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Oa=t=>ul(t),Cy=t=>ul(t),Ma=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function Ay({token:t}){const[a,s]=i.useState(null),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,y]=i.useState("No"),[h,u]=i.useState([]),[p,w]=i.useState([]),[v,b]=i.useState(null),[m,j]=i.useState(null),[D,I]=i.useState(!1),[k,S]=i.useState(""),{data:x}=W(t?[ua.teacherDropdown,t]:null,([de,Q])=>H(de,Q)),{data:g}=W(t?[De.master.classes.dropdown,t]:null,([de,Q])=>H(de,Q)),{data:C}=W(t&&m?[m,t]:null,([de,Q])=>H(de,Q)),{data:T}=W(t&&v?[v,t]:null,([de,Q])=>H(de,Q)),R=i.useMemo(()=>Oa(x),[x]),L=i.useMemo(()=>Oa(g),[g]),N=i.useMemo(()=>Oa(C),[C]),f=i.useMemo(()=>Oa(T),[T]),{data:P}=W(t&&a&&r&&l?[`${ua.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(a))}&class_id=${encodeURIComponent(String(r))}&section_id=${encodeURIComponent(String(l))}`,t]:null,([de,Q])=>H(de,Q)),O=P?.data??P??null;i.useEffect(()=>{O&&(u(Array.isArray(O?.subject_ids)?O.subject_ids:[]),y(O?.isClassTeacher||"No"),w([]))},[O]);const{data:$}=W(t?[ua.classWithSection,t]:null,([de,Q])=>H(de,Q)),F=i.useMemo(()=>Oa($),[$]),[U,V]=i.useState(null),[q,E]=i.useState({page:1,perPage:25});i.useEffect(()=>{U||F?.[0]&&V(`${F[0].class_id}val${F[0].section_id}`)},[F,U]);const M=i.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),B=i.useMemo(()=>{if(!U)return null;const[de,Q]=String(U).split("val");if(!de||!Q)return null;const ce=q.page??1,Te=q.perPage??25;return`${ua.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(ce))}&per_page=${encodeURIComponent(String(Te))}&session_id=${encodeURIComponent(String(M))}&class_id=${encodeURIComponent(String(de))}&section_id=${encodeURIComponent(String(Q))}`},[U,q.page,q.perPage,M]),{data:z,isLoading:G,mutate:re}=W(t&&B?[B,t]:null,([de,Q])=>H(de,Q),{revalidateOnFocus:!1}),K=i.useMemo(()=>Cy(z),[z]),J=i.useMemo(()=>{const de=z?.pagination??z?.data?.pagination??z?.data?.data?.pagination;return de?.total_rows??de?.total??K.length??0},[z,K]),ae=async de=>{if(de.preventDefault(),S(""),!a||!r||!l){_.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(h)||h.length===0){S("error"),_.error("Please Select Subject",{duration:1200});return}const Q=new FormData;Q.append("teacher_id",String(a)),Q.append("class_id",String(r)),Q.append("section_id",String(l)),Q.append("isClassTeacher",String(c??"No")),Ma(h).forEach(ce=>Q.append("subject_ids[]",String(ce))),Ma(p).forEach(ce=>Q.append("delete_subject[]",String(ce)));try{await wt(ua.assignClassToTeacher,Q,t,{includeSession:!0}),_.success("Success! Added new item.",{duration:1e3}),S(""),re()}catch(ce){_.error(ce?.response?.data?.msg??ce?.message??"Failed to add the new item.",{duration:1500})}},oe=async de=>{try{await qt(ua.deleteTeacherSub,de,t),_.success("Success! Deleted item.",{duration:1e3}),re()}catch(Q){_.error(Q?.response?.data?.msg??Q?.message??"Failed to delete the item.",{duration:1500})}},pe=de=>{const Q=Array.isArray(de?.child)?de.child:[],ce=[{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Subject Code",dataIndex:"code",key:"code",align:"center"},{title:"Action",key:"action",align:"center",render:(Te,$e)=>e.jsx(n.Popconfirm,{title:"Delete this subject?",onConfirm:()=>oe($e?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(n.Table,{columns:ce,bordered:!0,size:"small",dataSource:Q,pagination:!1,rowKey:Te=>Te.id})})},_e=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(de,Q)=>e.jsxs("div",{children:[Q.teacher_name,Q.classTeacher==="Yes"?e.jsx("span",{style:{fontWeight:700},children:" (Class Teacher)"}):null]})}],le=i.useMemo(()=>(F??[]).map(de=>({label:de.label??`${de.class_name??""} ${de.section_name??""}`.trim(),key:`${de.class_id}val${de.section_id}`,children:e.jsx(n.Table,{size:"small",columns:_e,bordered:!0,dataSource:Array.isArray(K)?K:[],loading:G,rowKey:Q=>Q.id,expandable:{expandedRowRender:pe},pagination:{current:q.page,pageSize:q.perPage,total:J,showSizeChanger:!0,onChange:(Q,ce)=>E({page:Q,perPage:ce})}})})),[F,q.page,q.perPage,K,G,J]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(320px, 380px) 1fr",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign by Class"}),children:e.jsx("form",{onSubmit:ae,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(X,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:R.find(de=>String(de.value)===String(a))??null,onChange:de=>s(de?.value??null)}),e.jsx(X,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:L.find(de=>String(de.value)===String(r))??null,onChange:de=>{const Q=de?.value??null;o(Q),d(null),b(Q?`${De.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(Q))}`:null),j(Q?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(Q))}`:null),I(ce=>!ce)}}),e.jsx(X,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:N.find(de=>String(de.value)===String(l))??null,onChange:de=>d(de?.value??null)},`section_${D}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Is Class Teacher?"}),(()=>{const de=[{label:"Yes",value:"Yes"},{label:"No",value:"No"}];return e.jsx(X,{style:{width:"100%"},options:de,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:de.find(Q=>String(Q.value)===String(c??"No"))??de[1],onChange:Q=>y(Q?.value??"No")})})()]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subject"}),e.jsx(X,{isMulti:!0,style:{width:"100%"},placeholder:"select Subject",options:f,value:(f??[]).filter(de=>Ma(h).some(Q=>String(Q)===String(de.value))),onChange:(de,Q)=>{const Te=(Array.isArray(de)?de:[]).map(Le=>Le?.value).filter(Le=>Le!=null&&Le!=="");u(Te);const $e=Array.isArray(O?.subject_ids)?O.subject_ids.map(String):[],ke=Q?.removedValue?.value,Ve=Q?.option?.value;(Q?.action==="remove-value"||Q?.action==="pop-value")&&ke!=null&&$e.includes(String(ke))&&w(Le=>Array.from(new Set([...Ma(Le).map(String),String(ke)]))),Q?.action==="select-option"&&Ve!=null&&$e.includes(String(Ve))&&w(Le=>Ma(Le).filter(at=>String(at)!==String(Ve)))}},`subjects_${D}`),k?e.jsx("div",{style:{color:"#ff4d4f",marginTop:6,fontSize:12},children:"Please select subject"}):null]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Teacher List"}),children:e.jsx(n.Tabs,{activeKey:U??void 0,onChange:de=>{V(de),E(Q=>({...Q,page:1}))},items:le,type:"card",size:"small"})})]})]})}function Dy({token:t}){return e.jsx(Ay,{token:t})}const Ea=De.timeGroup,Ty=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},$t={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function _n(t){if(!t)return null;const a=ee(String(t),["h:mm a","HH:mm:ss","HH:mm"],!0);return a.isValid()?a:null}function Ut(t){return t?ee(t).format("h:mm a"):""}function Ry({token:t}){const[a,s]=i.useState({page:1,perPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),[y]=n.Form.useForm(),h=`${Ea.table}?page=${encodeURIComponent(String(a.page))}&per_page=${encodeURIComponent(String(a.perPage))}`,{data:u,isLoading:p,mutate:w}=W(t?[h,t]:null,([g,C])=>H(g,C)),v=i.useMemo(()=>Ty(u),[u]),b=i.useMemo(()=>u?.pagination?.total_rows??u?.pagination?.total??v.length??0,[u,v]),{data:m}=W(t&&l?[`${Ea.show}?id=${encodeURIComponent(String(l))}`,t]:null,([g,C])=>H(g,C)),j=i.useMemo(()=>{const g=m?.data??m;return Array.isArray(g)?g[0]:g??null},[m]);i.useEffect(()=>{r&&j&&y.setFieldsValue({title:j?.title??"",start_time_from:_n(j?.start_time_from),start_time_to:_n(j?.start_time_to),end_time_from:_n(j?.end_time_from),end_time_to:_n(j?.end_time_to)})},[r,j,y]);const D=async g=>{const C=new FormData;C.append("title",g.title??""),C.append("start_time_from",Ut(g.start_time_from)),C.append("start_time_to",Ut(g.start_time_to)),C.append("end_time_from",Ut(g.end_time_from)),C.append("end_time_to",Ut(g.end_time_to));try{await wt(Ea.add,C,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),w()}catch(T){_.error(T?.response?.data?.msg??T?.message??"Failed to add the new item.",{duration:1500})}},I=async g=>{const C=new FormData;C.append("id",String(l??"")),C.append("title",g.title??""),C.append("start_time_from",Ut(g.start_time_from)),C.append("start_time_to",Ut(g.start_time_to)),C.append("end_time_from",Ut(g.end_time_from)),C.append("end_time_to",Ut(g.end_time_to));try{await Bt(Ea.edit,C,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),w()}catch(T){_.error(T?.response?.data?.msg??T?.message??"Failed to update the item.",{duration:1500})}},k=async g=>{try{await qt(Ea.remove,g,t),_.success("Success! Deleted item.",{duration:1e3}),w()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to delete the item.",{duration:1500})}},S=g=>{g?.id&&(d(g.id),o(!0))},x=i.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:120,render:(g,C)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>S(C)}),e.jsx(n.Popconfirm,{title:"Delete this time group?",onConfirm:()=>k(C?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Time Group",open:r,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(n.Form,{form:y,layout:"vertical",onFinish:I,children:[e.jsx(n.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:$t})}),e.jsx(n.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:$t})}),e.jsx(n.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:$t})}),e.jsx(n.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:$t})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Submit",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Create Time Group"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:D,initialValues:{},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:$t})}),e.jsx(n.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:$t})}),e.jsx(n.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:$t})}),e.jsx(n.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:$t})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Time Group List"}),children:e.jsx(n.Table,{rowKey:g=>g.id,columns:x,dataSource:v,loading:p,pagination:{current:a.page,pageSize:a.perPage,total:b,showSizeChanger:!0,onChange:(g,C)=>s({page:g,perPage:C})}})})]})}function Iy({token:t}){return e.jsx(Ry,{token:t})}const Fa=De.assignTimeGroup,ky=De.timeGroup.dropdown,Py=De.master.classes.dropdown,Wi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Oy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function My({token:t}){const[a,s]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,y]=i.useState(""),[h,u]=i.useState(""),[p,w]=i.useState(null),[v,b]=i.useState(!1),[m,j]=i.useState(!1),[D,I]=i.useState(null),[k,S]=i.useState([]),[x,g]=i.useState(""),[C,T]=i.useState(""),{data:R}=W(t?[ky,t]:null,([K,J])=>H(K,J)),{data:L}=W(t?[Py,t]:null,([K,J])=>H(K,J)),N=i.useMemo(()=>Wi(R?.data??R),[R]),f=i.useMemo(()=>Wi(L),[L]),{data:P}=W(t&&p?[p,t]:null,([K,J])=>H(K,J));i.useEffect(()=>{const K=Array.isArray(P?.data)?P.data.map(J=>J.fk_classId):[];K.length&&d(K)},[P]);const O=`${Fa.table}?page=${encodeURIComponent(String(a.page))}&per_page=${encodeURIComponent(String(a.perPage))}`,{data:$,isLoading:F,mutate:U}=W(t?[O,t]:null,([K,J])=>H(K,J)),V=i.useMemo(()=>Oy($),[$]),q=i.useMemo(()=>$?.pagination?.total_rows??$?.pagination?.total??V.length??0,[$,V]),{data:E}=W(t&&D?[`${Fa.show}?id=${encodeURIComponent(String(D))}`,t]:null,([K,J])=>H(K,J)),M=E?.data??E??null;i.useEffect(()=>{if(!m||!M)return;const K=Array.isArray(M?.class_ids)?M.class_ids:[];S(K);const J=Array.isArray(N)?N.find(ae=>String(ae.value)===String(M?.timegroup_id)):null;J&&T(`${J.start_time_from} -> ${J.end_time_from}`)},[m,M,N]);const B=async K=>{if(K.preventDefault(),y(""),!r?.value){_.error("Select Time Group",{duration:1200});return}if(!l.length){y("error"),_.error("Please Select Classes",{duration:1200});return}const J=new FormData;J.append("timegroup_id",String(r.value)),l.forEach(ae=>J.append("class_ids[]",String(ae)));try{await wt(Fa.assign,J,t),_.success("Success! Added new item.",{duration:1e3}),d([]),o(null),u(""),U()}catch(ae){_.error(ae?.response?.data?.msg??ae?.message??"Failed to add the new item.",{duration:1500})}},z=async()=>{if(g(""),!D)return;if(!k.length){g("error"),_.error("Please Select Classes",{duration:1200});return}const K=new FormData;K.append("id",String(D)),K.append("timegroup_id",String(M?.timegroup_id??"")),k.forEach(J=>K.append("class_ids[]",String(J)));try{await Bt(Fa.assign,K,t),_.success("Success! Updated item.",{duration:1e3}),j(!1),I(null),U()}catch(J){_.error(J?.response?.data?.msg??J?.message??"Failed to update the item.",{duration:1500})}},G=K=>{K&&(I(K),j(!0))},re=i.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Class Names",dataIndex:"class_names",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:90,render:(K,J)=>J?.class_names?e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>G(J?.id)}):null}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Assigned Time Group",open:m,onClose:()=>{j(!1),I(null)},width:520,extra:e.jsxs(n.Space,{children:[e.jsx(n.Button,{onClick:()=>j(!1),children:"Cancel"}),e.jsx(n.Button,{type:"primary",onClick:z,children:"Submit"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(X,{options:Array.isArray(N)?N:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:N.find(K=>String(K.value)===String(M?.timegroup_id))??null,onChange:()=>{},isDisabled:!0}),e.jsx("div",{style:{marginTop:4,fontSize:16},children:C}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(n.Select,{mode:"multiple",style:{width:"100%"},status:x,value:k,placeholder:"Select Classes",onChange:K=>S(K),options:Array.isArray(f)?f:[]})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Time Group"}),children:e.jsx("form",{onSubmit:B,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx(X,{options:Array.isArray(N)?N:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:r,onChange:K=>{o(K??null),d([]),y(""),K?.value?(w(`${Fa.classIdByTimeGroup}?id=${encodeURIComponent(String(K.value))}`),u(`${K.start_time_from} -> ${K.end_time_from}`)):(w(null),u("")),b(J=>!J)}}),e.jsx("div",{style:{marginTop:6},children:h})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(X,{mode:"multiple",style:{width:"100%"},status:c,value:l,placeholder:"Select Classes",onChange:K=>d(K),options:Array.isArray(f)?f:[]},`class_${v}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assigned Time group List"}),children:e.jsx(n.Table,{rowKey:K=>K.id,columns:re,dataSource:V,loading:F,pagination:{current:a.page,pageSize:a.perPage,total:q,showSizeChanger:!0,onChange:(K,J)=>s({page:K,perPage:J})}})})]})}function Ey({token:t}){return e.jsx(My,{token:t})}const Ws=De.promoteStudents,Fy=({token:t})=>W(t?[Ws.sessionDropdown,t]:null,([a,s])=>H(a,s)),Cn=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},$y=(t,a)=>{const s=t?.pagination??t?.data?.pagination??t?.data?.data?.pagination,r=s?.total_rows??s?.total??s?.totalItems;return Number.isFinite(Number(r))?Number(r):a};function Uy({token:t}){const[a]=n.Form.useForm(),[s,r]=i.useState({page:1,perPage:300}),[o,l]=i.useState({classId:null,sectionId:null}),[d,c]=i.useState({sessionId:null,classId:null}),[y,h]=i.useState(!1),[u,p]=i.useState([]),w=i.useMemo(()=>new Set(u),[u]),[v,b]=i.useState({}),[m,j]=i.useState({}),{data:D}=W(t?[De.master.classes.dropdown,t]:null,([z,G])=>H(z,G)),I=i.useMemo(()=>Cn(D),[D]),k=i.useMemo(()=>o.classId?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(o.classId))}`:null,[o.classId]),{data:S}=W(t&&k?[k,t]:null,([z,G])=>H(z,G)),x=i.useMemo(()=>Cn(S),[S]),g=i.useMemo(()=>d.classId?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:C}=W(t&&g?[g,t]:null,([z,G])=>H(z,G),{revalidateOnFocus:!1}),T=i.useMemo(()=>Cn(C),[C]),{data:R}=Fy({token:t}),L=i.useMemo(()=>Cn(R),[R]),{trigger:N,data:f,isMutating:P}=tt(t?Ws.searchByClassSection:null,(z,{arg:G})=>Gt(z,{arg:G},t)),O=i.useMemo(()=>{const z=f?.data?.data??f?.data??f??[];return Array.isArray(z)?z:Array.isArray(z?.data)?z.data:[]},[f]),$=i.useMemo(()=>$y(f,O.length??0),[f,O.length]),F=i.useMemo(()=>{const z=new Map;return(Array.isArray(O)?O:[]).forEach(G=>{G?.id!==void 0&&G?.id!==null&&z.set(String(G.id),G)}),z},[O]),U=i.useCallback((z,G)=>{const re=String(z);j(K=>({...K,[re]:{...K?.[re]??{},...G}}))},[]),V=i.useCallback((z,G)=>{const re=String(z),K=G==="Leave";b(J=>({...J,[re]:K}))},[]),q=z=>{const G=z?.class_id?.value??z?.class_id??null,re=z?.section_id?.value??z?.section_id??null;if(!G||!re){_.error("Please select Class and Section",{duration:1200});return}r(K=>({...K,page:1})),l({classId:G,sectionId:re}),p([]),b({}),j({})},E=async()=>{if(!d.sessionId||!d.classId){_.error("Please select Session and Class for promotion",{duration:1300});return}if(!Array.isArray(u)||u.length===0){_.error("Please select students to promote",{duration:1200});return}const z=u.map(J=>String(J)).map(J=>{const ae=F.get(J)??{},oe=!!v?.[J],pe=m?.[J]??{},_e=String(pe.current_result??"Pass");if(oe){const Q=String(pe.leave_date??"");return{student_id:J,current_result:_e,next_session_status:"Leave",leave_date:Q}}const le=String(pe.roll_no??ae?.roll_no??""),de=String(pe.section_id??"");return{student_id:J,roll_no:le,section_id:de,current_result:_e,next_session_status:"Continue"}});if(z.some(J=>J?.next_session_status==="Leave"&&!String(J?.leave_date??"").trim())){_.error("Leave date is required for Leave students.",{duration:1500});return}if(z.some(J=>J?.next_session_status==="Continue"&&!String(J?.section_id??"").trim())){_.error("Section is required for Continue students.",{duration:1500});return}const K={class_id:String(d.classId),session_id:String(d.sessionId),students:z};try{const J=await Be(Ws.promote,K,t);if(J?.Status&&String(J.Status)!=="success")throw new Error(J?.msg||"Failed to update");_.success("Success! Updated.",{duration:1e3});const ae=Number(J?.success_count??0)+Number(J?.leave_count??0),oe=s.page===Math.ceil((Number($)||0)/s.perPage||1),pe=ae>0&&ae===O.length&&O.length===u.length,_e=oe&&pe&&s.page>1?s.page-1:s.page;r(le=>({...le,page:_e})),N?.({cID:o.classId,sID:o.sectionId,page:_e,per_page:s.perPage}),p([]),b({}),j({})}catch(J){_.error(J?.response?.data?.msg??J?.message??"Failed to update",{duration:1500})}},M=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:140},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:120,render:(z,G)=>{const re=String(G?.id??""),K=w.has(re),J=!!v?.[re],oe=(m?.[re]??{}).roll_no??(J?"":G?.roll_no??"");return e.jsx(n.Input,{value:K?oe:G?.roll_no,style:K?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!K||J,onChange:pe=>U(re,{roll_no:pe.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(z,G)=>`${G?.firstname??""} ${G?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(z,G)=>{const re=String(G?.id??""),K=w.has(re),J=!!v?.[re],oe=(m?.[re]??{}).section_id??"",pe=Array.isArray(T)?T:[];return e.jsx(n.Select,{options:pe,placeholder:K&&!J?"Select Section":"Section",disabled:!K||J,value:K&&!J&&oe||void 0,style:{width:"100%"},onChange:_e=>U(re,{section_id:_e})},`section_${re}_${y}_${J?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(z,G)=>{const re=String(G?.id??""),K=w.has(re),J=m?.[re]??{},ae=String(J.current_result??"Pass");return e.jsxs(n.Radio.Group,{value:ae,disabled:!K,buttonStyle:"solid",onChange:oe=>U(re,{current_result:oe.target.value}),children:[e.jsx(n.Radio.Button,{value:"Pass",children:"Pass"}),e.jsx(n.Radio.Button,{value:"Fail",children:"Fail"})]})}},{title:"Next Session Status",dataIndex:"next_session_status",key:"next_session_status",width:220,render:(z,G)=>{const re=String(G?.id??""),K=w.has(re),J=!!v?.[re],ae=m?.[re]??{},oe=String(ae.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(n.Radio.Group,{value:J?"Leave":"Continue",disabled:!K,buttonStyle:"solid",onChange:pe=>V(re,pe.target.value),children:[e.jsx(n.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(n.Radio.Button,{value:"Leave",children:"Leave"})]}),K&&J&&e.jsx(n.DatePicker,{style:{width:"100%"},value:oe?ee(oe):null,onChange:pe=>U(re,{leave_date:pe?pe.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[V,v,m,w,y,T,U]),B=i.useMemo(()=>({selectedRowKeys:u,onChange:z=>p((Array.isArray(z)?z:[]).map(G=>String(G)))}),[u]);return i.useEffect(()=>{!o.classId||!o.sectionId||N&&N({cID:o.classId,sID:o.sectionId,page:s.page,per_page:s.perPage})},[s.page,s.perPage,N,o.classId,o.sectionId]),e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Promote Students"}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"class_id",label:"Class",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:z=>z,children:e.jsx(X,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:z=>{const G=z?.value??null;a.setFieldValue("section_id",null),l({classId:G,sectionId:null})}})}),e.jsx(n.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:z=>z,children:e.jsx(X,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Promote Students In Next Session"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(n.Typography.Text,{children:["Selected: ",u.length]}),e.jsx(n.Typography.Text,{type:"secondary",children:"Select students → set Continue/Leave → Save"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{label:"Session",options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:L.find(z=>String(z.value)===String(d.sessionId))??null,onChange:z=>c(G=>({...G,sessionId:z?.value??null}))}),e.jsx(X,{label:"Class",options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:I.find(z=>String(z.value)===String(d.classId))??null,onChange:z=>{const G=z?.value??null;c(re=>({...re,classId:G})),h(re=>!re)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Save",color:"primary",onClick:E})})]}),e.jsx(n.Table,{rowKey:z=>String(z.id),rowSelection:B,columns:M,dataSource:O,loading:P,pagination:{current:s.page,pageSize:s.perPage,total:$,showSizeChanger:!0,onChange:(z,G)=>{r({page:z,perPage:G}),p([]),b({}),j({})}}})]})})]})}function Ny({token:t}){return e.jsx(Uy,{token:t})}const ma=De.coscholastic,Ly=({token:t})=>W(t?[ma.table,t]:null,([a,s])=>H(a,s),{revalidateOnFocus:!1}),By=({token:t})=>W(t?[ma.categoryDropdown,t]:null,([a,s])=>H(a,s),{revalidateOnFocus:!1}),Hi=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]};function qy({token:t}){const[a,s]=i.useState(""),[r,o]=i.useState(null),[l,d]=i.useState(null),c=i.useRef(null),{data:y}=W(t?[De.master.classes.dropdown,t]:null,([C,T])=>H(C,T)),h=i.useMemo(()=>Hi(y),[y]),{data:u,isLoading:p,mutate:w}=Ly({token:t}),v=i.useMemo(()=>{const C=u?.data?.data??u?.data??u??[];return Array.isArray(C)?C:Array.isArray(C?.data)?C.data:[]},[u]),{data:b,mutate:m}=By({token:t}),j=i.useMemo(()=>Hi(b),[b]),D=i.useMemo(()=>(Array.isArray(j)?j:[]).map(C=>({value:C?.value??C?.id,label:C?.label??C?.title??""})),[j]),I=async()=>{const C=String(a??"").trim();if(!C){_.error("Please enter category title",{duration:1200});return}try{await Ee(ma.addCategory,{title:C},t),_.success("Success! Added category.",{duration:1e3}),s(""),m()}catch(T){_.error(T?.response?.data?.msg??T?.message??"Failed to add category",{duration:1500})}},k=async C=>{try{await qt(ma.deleteCategory,C,t),_.success("Success! Deleted category.",{duration:1e3}),m()}catch(T){_.error(T?.response?.data?.msg??T?.message??"Failed to delete category",{duration:1500})}},S=async C=>{if(C.preventDefault(),!r){_.error("Please select Category",{duration:1200});return}if(!l){_.error("Please select Class",{duration:1200});return}if(!C?.target?.skill?.value){_.error("Please enter Skill Name",{duration:1200});return}const R=new FormData(C.target);R.append("scholastic_catid",String(r)),R.append("class_id",String(l));try{await wt(ma.addSkill,R,t),_.success("Success! Added new item.",{duration:1e3}),C.target.reset(),d(null),w()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},x=async C=>{try{await qt(ma.deleteSkill,C,t),_.success("Success! Deleted item.",{duration:1e3}),w()}catch(T){_.error(T?.response?.data?.msg??T?.message??"Failed to delete the item.",{duration:1500})}},g=i.useMemo(()=>[{title:"Skill Category",dataIndex:"title",key:"title"},{title:"Class",dataIndex:"class",key:"class"},{title:"Skill Name",dataIndex:"skill",key:"skill"},{title:"Action",key:"action",width:90,render:(C,T)=>e.jsx(n.Popconfirm,{title:"Delete this skill?",onConfirm:()=>x(T?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Co Scholastic Area"}),children:e.jsx("form",{onSubmit:S,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Category"}),e.jsx(X,{style:{width:"100%"},value:D.find(C=>String(C.value)===String(r))??null,placeholder:"Select Category",onChange:C=>o(C?.value??null),options:D}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:10},children:[e.jsx(Y,{placeholder:"New category",ref:c,value:a,onChange:C=>s(C.target.value)}),e.jsx(n.Button,{type:"text",icon:e.jsx(te.PlusOutlined,{}),onClick:I}),e.jsx(n.Popconfirm,{title:"Delete selected category?",onConfirm:()=>{r&&(k(r),o(null))},children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{}),disabled:!r})})]})]}),e.jsx(X,{label:"Class",options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:h.find(C=>String(C.value)===String(l))??null,onChange:C=>d(C?.value??null)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Skill Name"}),e.jsx(Y,{name:"skill",placeholder:"Skill Name"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Co Scholastic Area List"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(n.Table,{rowKey:C=>C.id,columns:g,dataSource:v,loading:p,pagination:!1})})]})}function zy({token:t}){return e.jsx(qy,{token:t})}const Yy=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",pl=({token:t,value:a,onChange:s})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:ay(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=Yy(o?.file?.response);l&&s?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})},Ki=De.notes,Vy=({token:t,url:a})=>W(t&&a?[a,t]:null,([s,r])=>H(s,r),{revalidateOnFocus:!1}),An=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Wy=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r};function Hy({token:t}){const[a]=n.Form.useForm(),[s]=n.Form.useForm(),[r,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null,sectionId:null}),[c,y]=i.useState(!1),[h,u]=i.useState(""),{data:p}=W(t?[De.master.classes.dropdown,t]:null,([B,z])=>H(B,z)),w=i.useMemo(()=>An(p),[p]),v=i.useMemo(()=>l.classId?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:b}=W(t&&v?[v,t]:null,([B,z])=>H(B,z)),m=i.useMemo(()=>An(b),[b]),j=i.useMemo(()=>!l.classId||!l.sectionId?null:`${Ki.table}?class_id=${encodeURIComponent(String(l.classId))}&section_id=${encodeURIComponent(String(l.sectionId))}&page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.perPage))}`,[l.classId,l.sectionId,r.page,r.perPage]),{data:D,isLoading:I,mutate:k}=Vy({token:t,url:j}),S=i.useMemo(()=>{const B=D?.data?.data??D?.data??D??[];return Array.isArray(B)?B:Array.isArray(B?.data)?B.data:[]},[D]),x=i.useMemo(()=>D?.pagination?.total_rows??D?.pagination?.total??S.length??0,[D,S.length]),[g,C]=i.useState(null),[T,R]=i.useState(null),[L,N]=i.useState(null),[f,P]=i.useState(!1),{data:O}=W(t&&L?[L,t]:null,([B,z])=>H(B,z),{revalidateOnFocus:!1}),$=i.useMemo(()=>An(O),[O]),{data:F}=W(t&&T?[T,t]:null,([B,z])=>H(B,z)),U=i.useMemo(()=>An(F),[F]),V=B=>{const z=B?.class_id?.value??null,G=B?.section_id?.value??null;!z||!G||(o(re=>({...re,page:1})),d({classId:z,sectionId:G}))},q=()=>{u(""),y(!0),C(null),R(null),N(null),P(B=>!B),s.resetFields()},E=async B=>{const z=B?.class_id?.value??null,G=B?.section_id?.value??null,re=B?.sub_id?.value??null,K=B?.status?.value??"publish",J=B?.title??"",ae=B?.remark??"";if(!z||!G||!re||!J||!ae||!h){_.error("Please fill all fields",{duration:1200});return}const oe=new FormData;oe.append("class_id",String(z)),oe.append("section_id",String(G)),oe.append("sub_id",String(re)),oe.append("title",String(J)),oe.append("remark",String(ae)),oe.append("status",String(K)),oe.append("file",String(h));try{await wt(Ki.add,oe,t),_.success("Success! Added new item.",{duration:1e3}),y(!1),k()}catch(pe){_.error(pe?.response?.data?.msg??pe?.message??"Failed to add the new item.",{duration:1500})}},M=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",align:"center"},{title:"Remarks",dataIndex:"remark",key:"remark",align:"center"},{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Staff Name",dataIndex:"teacher_name",key:"teacher_name",align:"center"},{title:"Status",key:"status",align:"center",render:(B,z)=>{const G=String(z?.status??"").toLowerCase();return e.jsx(n.Tag,{color:G==="publish"?"green":"red",children:z?.status??"-"})}},{title:"File",key:"file",align:"center",render:(B,z)=>{const G=z?.file;if(!G)return"-";const re=Wy(He(),`/student/note/${G}`);return e.jsx("a",{href:re,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Date",dataIndex:"publish_date",key:"publish_date",align:"center"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:"Add Note",open:c,onCancel:()=>y(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(n.Form,{form:s,layout:"vertical",onFinish:E,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:B=>B,children:e.jsx(X,{options:w,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:B=>{const z=B?.value??null;C(z),s.setFieldValue("section_id",null),s.setFieldValue("sub_id",null),N(z?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(z))}`:null),R(z?`${De.master.subjects.dropdown}?class_id=${encodeURIComponent(String(z))}`:null),P(G=>!G)}},`class_${f}`)}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:B=>B,children:e.jsx(X,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${f}_${g??"none"}`)}),e.jsx(n.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:B=>B,children:e.jsx(X,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${f}_${T??"none"}`)}),e.jsx(n.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{label:"Remark",name:"remark",rules:[{required:!0,message:"Remark is required"}],children:e.jsx(Y,{placeholder:"Remark"})}),e.jsx(n.Form.Item,{label:"Status",name:"status",initialValue:{label:"Publish",value:"publish"},getValueFromEvent:B=>B,children:e.jsx(X,{options:[{label:"Publish",value:"publish"},{label:"Unpublish",value:"unpublish"}],closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx(n.Form.Item,{label:"File",required:!0,children:e.jsx(pl,{token:t,value:h,onChange:u})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>y(!1),children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Notes"}),e.jsx(Yt,{actions:["add","export","print","download","filter"],onAdd:q,onPrint:()=>window.print()})]}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:V,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:B=>B,children:e.jsx(X,{options:w,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:B=>{const z=B?.value??null;a.setFieldValue("section_id",null),d({classId:z,sectionId:null})}})}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:B=>B,children:e.jsx(X,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Note List"}),children:e.jsx(n.Table,{rowKey:B=>B.id,columns:M,dataSource:S,loading:I,pagination:{current:r.page,pageSize:r.perPage,total:x,showSizeChanger:!0,onChange:(B,z)=>o({page:B,perPage:z})}})})]})}function Ky({token:t}){return e.jsx(Hy,{token:t})}const Gy=({token:t})=>W(t?[De.promoteStudents.sessionDropdown,t]:null,([a,s])=>H(a,s),{revalidateOnFocus:!1}),Gi=De.transferCertificate,Is=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Jy={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Qy=(t,a)=>t.inputtype==="Select"?null:t.inputtype==="date"?ee():"",Ji=t=>[{name:"ncc_details",inputtype:"text",label:"Ncc Details",required:!1},{name:"extra_curricular_activites",inputtype:"text",label:"Games played or extra-curricular activities in which the pupil usually took part",required:!1},{name:"generalConduct",inputtype:"text",label:"General conduct",required:!1},{name:"qualified_class",inputtype:"Select",label:"Qualified class",required:!1},{name:"application_date",inputtype:"date",label:"Date of application for certificate",required:!1},{name:"issue_date",inputtype:"date",label:"Date of issue of certificate",required:!1},{name:"reason_of_leaving",inputtype:"text",label:"Reason for leaving the school",required:!1},{name:"otherRemarks",inputtype:"text",label:"Any other remarks",required:!1},{name:"student_id",inputtype:"hidden",label:"",required:!1,value:t},{name:"qualified_for_promotion",inputtype:"radio",label:"Qualified for promotion",required:!1},{name:"failed",inputtype:"radio",label:"Failed",required:!1},{name:"nationality",inputtype:"text",label:"Nationality",required:!1},{name:"checked_by",inputtype:"text",label:"Checked By",required:!1},{name:"checked_by_designation",inputtype:"text",label:"Checked By Designation",required:!1}],Qi=t=>[{name:"change_of_school",inputtype:"text",label:"Change of School",required:!1},{name:"character_remark",inputtype:"text",label:"Character",required:!1},{name:"generalConduct",inputtype:"text",label:"General conduct",required:!1},{name:"application_date",inputtype:"date",label:"Date of application for certificate",required:!1},{name:"issue_date",inputtype:"date",label:"Date of issue of certificate",required:!1},{name:"last_attendance",inputtype:"date",label:"Last Class Attendence",required:!1},{name:"otherRemarks",inputtype:"text",label:"Any other remarks",required:!1},{name:"student_id",inputtype:"hidden",label:"",required:!1,value:t},{name:"qualified_for_promotion",inputtype:"radio",label:"Qualified for promotion",required:!1}];function Xy({token:t,transferCertificateViewPath:a="/AcademicsDashboard/TransferCertificateView",onOpenTransferCertificateView:s}){const[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState({page:1,perPage:10}),[c,y]=i.useState({classId:null,sectionId:null,sessionId:null}),[h,u]=i.useState(null),[p,w]=i.useState(!1),{data:v}=W(t?[De.master.classes.dropdown,t]:null,([M,B])=>H(M,B)),b=i.useMemo(()=>Is(v),[v]),{data:m}=W(t&&h?[h,t]:null,([M,B])=>H(M,B)),j=i.useMemo(()=>Is(m),[m]),{data:D}=Gy({token:t}),I=i.useMemo(()=>Is(D),[D]),k=i.useMemo(()=>!c.classId||!c.sectionId||!c.sessionId?null:`${Gi.studentList}?class_id=${encodeURIComponent(String(c.classId))}&section_id=${encodeURIComponent(String(c.sectionId))}&session_id=${encodeURIComponent(String(c.sessionId))}&page=${encodeURIComponent(String(l.page))}&per_page=${encodeURIComponent(String(l.perPage))}`,[c.classId,c.sectionId,c.sessionId,l.page,l.perPage]),{data:S,isLoading:x,mutate:g}=W(t&&k?[k,t]:null,([M,B])=>H(M,B),{revalidateOnFocus:!1,onSuccess:M=>{const B=M?.data?.data??M?.data??[];Array.isArray(B)&&B[0]?.transefer_certificate_id&&O(String(B[0].transefer_certificate_id))}}),C=i.useMemo(()=>{const M=S?.data?.data??S?.data??S??[];return Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[]},[S]),T=i.useMemo(()=>S?.pagination?.total_rows??S?.pagination?.total??C.length??0,[S,C.length]),[R,L]=i.useState(!1),[N,f]=i.useState(null),[P,O]=i.useState("1"),$=M=>{f(M);const B=P==="1"?Ji(M):Qi(M),z={};B.forEach(G=>{z[G.name]=G.value??Qy(G)}),o.setFieldsValue(z),L(!0)},F=async M=>{if(!M)return;if(typeof s=="function")return s(M);const B=`${a}?id=${encodeURIComponent(String(M))}`;window.location.href=B},U=M=>{const B=M?.class_id?.value??null,z=M?.section_id?.value??null,G=M?.session_id?.value??null;if(!B||!z||!G){_.error("Please select Class, Section and Session",{duration:1200});return}d(re=>({...re,page:1})),y({classId:B,sectionId:z,sessionId:G})},V=async M=>{const B=new FormData;Object.entries(M??{}).forEach(([z,G])=>{if(G!=null){if(ee.isDayjs(G)){B.append(z,G.format("YYYY-MM-DD"));return}B.append(z,String(G))}});try{await wt(Gi.addData,B,t),_.success("Success! Added new item.",{duration:1e3}),L(!1),f(null),g()}catch(z){_.error(z?.response?.data?.msg??z?.message??"Failed to add the new item.",{duration:1500})}},q=i.useMemo(()=>P==="1"?Ji(N):Qi(N),[P,N]),E=i.useMemo(()=>[{title:"Admission no",dataIndex:"admission_no",key:"admission_no",align:"center"},{title:"Roll NO",dataIndex:"roll_no",key:"roll_no",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",align:"center"},{title:"Class",dataIndex:"class",key:"class",align:"center"},{title:"Section",dataIndex:"section",key:"section",align:"center"},{title:"Guardian Name",dataIndex:"guardian_name",key:"guardian_name",align:"center"},{title:"Mobile No",dataIndex:"mobileno",key:"mobileno",align:"center"},{title:"Action",key:"action",align:"center",width:80,render:(M,B)=>e.jsx(n.Button,{type:"text",icon:B?.transfer_certificate_data==="not_present"?e.jsx(te.EyeOutlined,{}):e.jsx(te.CheckOutlined,{}),onClick:()=>{B?.transfer_certificate_data==="not_present"?$(B?.id):F(B?.id)}})}],[P]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:"Transfer Certificate",open:R,onCancel:()=>L(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:V,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:q.map(M=>M.inputtype==="hidden"?e.jsx(n.Form.Item,{name:M.name,initialValue:M.value??"",style:{display:"none"},children:e.jsx("input",{type:"hidden"})},M.name):M.inputtype==="date"?e.jsx(n.Form.Item,{label:M.label,name:M.name,children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:Jy})},M.name):M.inputtype==="radio"?e.jsx(n.Form.Item,{label:M.label,name:M.name,children:e.jsx(n.Radio.Group,{options:[{label:"Yes",value:"Yes"},{label:"No",value:"No"}]})},M.name):M.inputtype==="Select"?e.jsx(n.Form.Item,{label:M.label,name:M.name,getValueFromEvent:B=>B,children:e.jsx(X,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})},M.name):e.jsx(n.Form.Item,{label:M.label,name:M.name,children:e.jsx(Y,{placeholder:M.label})},M.name))}),e.jsxs(n.Space,{style:{width:"100%",justifyContent:"flex-end"},children:[e.jsx(ne,{type:"submit",value:"Submit",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>L(!1),children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Student History"}),children:e.jsx(n.Form,{form:r,layout:"vertical",onFinish:U,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:M=>M,children:e.jsx(X,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{const B=M?.value??null;u(B?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(B))}`:null),w(z=>!z),r.setFieldValue("section_id",null)}})}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:M=>M,children:e.jsx(X,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${p}`)}),e.jsx(n.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:M=>M,children:e.jsx(X,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Student List"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(n.Table,{rowKey:M=>M.id,columns:E,dataSource:C,loading:x,pagination:{current:l.page,pageSize:l.perPage,total:T,showSizeChanger:!0,onChange:(M,B)=>d({page:M,perPage:B})}})})]})}function Zy({token:t,transferCertificateViewPath:a,onOpenTransferCertificateView:s}){return e.jsx(Xy,{token:t,transferCertificateViewPath:a,onOpenTransferCertificateView:s})}const eg=({token:t,url:a})=>W(t&&a?[a,t]:null,([s,r])=>H(s,r),{revalidateOnFocus:!1}),ks=De.syllabus,Xi=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},tg=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r};function ag({token:t}){const[a]=n.Form.useForm(),[s]=n.Form.useForm(),[r,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null}),[c,y]=i.useState(!1),[h,u]=i.useState(null),[p,w]=i.useState(""),{data:v}=W(t?[De.master.classes.dropdown,t]:null,([F,U])=>H(F,U)),b=i.useMemo(()=>Xi(v),[v]),m=i.useMemo(()=>l.classId?`${ks.table}?class_id=${encodeURIComponent(String(l.classId))}&page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.perPage))}`:null,[l.classId,r.page,r.perPage]),{data:j,isLoading:D,mutate:I}=eg({token:t,url:m}),k=i.useMemo(()=>{const F=j?.data?.data??j?.data??j??[];return Array.isArray(F)?F:Array.isArray(F?.data)?F.data:[]},[j]),S=i.useMemo(()=>j?.pagination?.total_rows??j?.pagination?.total??k.length??0,[j,k.length]),[x,g]=i.useState(null),[C,T]=i.useState(!1),{data:R}=W(t&&x?[x,t]:null,([F,U])=>H(F,U),{revalidateOnFocus:!1}),L=i.useMemo(()=>Xi(R),[R]),N=F=>{const U=F?.class_id?.value??null;U&&(o(V=>({...V,page:1})),d({classId:U}))},f=()=>{u(null),w(""),g(null),T(F=>!F),s.resetFields(),y(!0)},P=F=>{u(F),w(F?.attchement??"");const U=F?.class_id;g(U?`${De.master.subjects.dropdown}?class_id=${encodeURIComponent(String(U))}`:null),T(V=>!V),s.setFieldsValue({class_id:b.find(V=>String(V.value)===String(U))??null,sub_id:L.find(V=>String(V.value)===String(F?.sub_id??F?.subject_id))??(F?.sub_id||F?.subject_id?{label:F?.subject_title??"Subject",value:F?.sub_id??F?.subject_id}:null),title:F?.title??"",description:F?.description??""}),y(!0)},O=async F=>{const U=F?.class_id?.value??null,V=F?.sub_id?.value??null,q=F?.title??"",E=F?.description??"";if(!U||!V||!q||!E||!p){_.error("Please fill all fields",{duration:1200});return}const M=new FormData;M.append("class_id",String(U)),M.append("sub_id",String(V)),M.append("title",String(q)),M.append("description",String(E)),M.append("file",String(p));try{h?.id?(M.append("id",String(h.id)),await wt(ks.edit,M,t),_.success("Success! Updated item.",{duration:1e3})):(await wt(ks.add,M,t),_.success("Success! Added new item.",{duration:1e3})),y(!1),u(null),I()}catch(B){_.error(B?.response?.data?.msg??B?.message??"Failed to save",{duration:1500})}},$=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",align:"center"},{title:"Description",dataIndex:"description",key:"description",align:"center"},{title:"Subject",dataIndex:"subject_title",key:"subject_title",align:"center"},{title:"File",key:"file",align:"center",render:(F,U)=>{const V=U?.attchement;if(!V)return"-";const q=tg(He(),`uploads/student/note/${V}`);return e.jsx("a",{href:q,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:(F,U)=>e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>P(U)})}],[L,b]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:h?"Edit Syllabus":"Add Syllabus",open:c,onCancel:()=>{y(!1),u(null),w("")},footer:null,width:820,destroyOnClose:!0,children:e.jsx(n.Form,{form:s,layout:"vertical",onFinish:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:F=>F,children:e.jsx(X,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{const U=F?.value??null;s.setFieldValue("sub_id",null),g(U?`${De.master.subjects.dropdown}?class_id=${encodeURIComponent(String(U))}`:null),T(V=>!V)}},`class_${h?.id??"add"}_${C}`)}),e.jsx(n.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:F=>F,children:e.jsx(X,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${h?.id??"add"}_${C}_${x??"none"}`)}),e.jsx(n.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{label:"Description",name:"description",rules:[{required:!0,message:"Description is required"}],children:e.jsx(st,{placeholder:"Description"})}),e.jsx(n.Form.Item,{label:"File",required:!0,children:e.jsx(pl,{token:t,value:p,onChange:w})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>y(!1),children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Syllabus"}),e.jsx(Yt,{actions:["add","export","print","download","filter"],onAdd:f,onPrint:()=>window.print()})]}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:F=>F,children:e.jsx(X,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Syllabus List"}),children:e.jsx(n.Table,{rowKey:F=>F.id,columns:$,dataSource:k,loading:D,pagination:{current:r.page,pageSize:r.perPage,total:S,showSizeChanger:!0,onChange:(F,U)=>o({page:F,perPage:U})}})})]})}function ng({token:t}){return e.jsx(ag,{token:t})}const is=De.timetable,Zi=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},eo=t=>{if(!t)return"";const a=ee(t,"HH:mm:ss");return a.isValid()?a.format("h:mm a"):String(t)},sg=t=>{const a=String(t).trim().toLowerCase();if(!a)return"default";let s=0;for(let o=0;o<a.length;o+=1)s=(s*31+a.charCodeAt(o))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[s%r.length]},to=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],rg=t=>{const a=String(t||"");return a?a.charAt(0).toUpperCase()+a.slice(1):"-"};function ig({token:t}){const[a,s]=i.useState(null),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,y]=i.useState(""),[h,u]=i.useState(""),{data:p}=W(t?[De.master.classes.dropdown,t]:null,([g,C])=>H(g,C)),w=i.useMemo(()=>Zi(p),[p]),{data:v}=W(t&&a?[a,t]:null,([g,C])=>H(g,C)),b=i.useMemo(()=>Zi(v),[v]),{data:m,isLoading:j}=W(t&&l?[l,t]:null,([g,C])=>H(g,C),{revalidateOnFocus:!1}),D=i.useMemo(()=>m?.days??m?.data?.days??m?.data?.data?.days??{},[m]),{dataSource:I,daySpanByFirstKey:k}=i.useMemo(()=>{const g=Object.entries(D||{}).slice().sort((R,L)=>to.indexOf(String(R[0]).toLowerCase())-to.indexOf(String(L[0]).toLowerCase())),C=new Map,T=[];for(const[R,L]of g){const N=(Array.isArray(L)?L:[]).slice().sort((P,O)=>Number(P?.order_no||0)-Number(O?.order_no||0)),f=N.length;for(let P=0;P<f;P+=1){const O=N[P],$=O?.id||`${R}-${O?.order_no}-${P}`;P===0&&C.set($,f),T.push({key:$,_dayKey:R,...O})}}return{dataSource:T,daySpanByFirstKey:C}},[D]),S=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(g,C)=>{const T=k.get(C.key);return T===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(te.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(n.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:rg(g)})]}),props:{rowSpan:T}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:g=>e.jsx(n.Tag,{color:"#5080f8",style:{fontWeight:500},children:g})},{title:"Time",key:"time",width:180,render:(g,C)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(te.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(n.Typography.Text,{children:[eo(C?.time_from)," - ",eo(C?.time_to)]})]})},{title:"Subject",key:"subject",render:(g,C)=>{if(String(C?.is_break)==="1")return e.jsx(n.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const R=C?.subject_name||"-";return e.jsx(n.Tag,{color:sg(R),style:{fontWeight:500},children:R})}},{title:"Teacher",key:"teacher",render:(g,C)=>{const T=String(C?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(te.UserOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:T?"-":C?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(g,C)=>{const T=String(C?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(te.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:T?"-":C?.room_no||"-"})]})}}],[k]),x=g=>{g.preventDefault();const C=g.target.class_id?.value,T=g.target.section_id?.value;if(!C||!T)return;const R=w.find(P=>String(P.value)===String(C)),L=b.find(P=>String(P.value)===String(T));y(R?.label||""),u(L?.label||"");const f=`${is.byClassSection}/${C}/section/${T}`;d(f)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Class / Section Wise Timetable"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{options:w,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:g=>{s(`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(g?.value??""))}`),o(C=>!C)}}),e.jsx(X,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",allowSelectAll:!1,required:!0},`section_${r}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:c||h?`Timetable: ${c} ${h}`:"Timetable"}),children:e.jsx(n.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:I,columns:S,rowKey:"key",loading:j,scroll:{x:"max-content"}})})]})}const og=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},ao=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],lg=t=>{const a=String(t||"");return a?a.charAt(0).toUpperCase()+a.slice(1):"-"},no=t=>{if(!t)return"";const a=ee(t,"HH:mm:ss");return a.isValid()?a.format("h:mm a"):String(t)},dg=t=>{const a=String(t).trim().toLowerCase();if(!a)return"default";let s=0;for(let o=0;o<a.length;o+=1)s=(s*31+a.charCodeAt(o))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[s%r.length]};function cg({token:t}){const[a,s]=i.useState(null),[r,o]=i.useState(null),{data:l}=W(t?[De.assignByClass.teacherDropdown,t]:null,([v,b])=>H(v,b)),d=i.useMemo(()=>og(l),[l]),{data:c,isLoading:y}=W(t&&r?[r,t]:null,([v,b])=>H(v,b),{revalidateOnFocus:!1}),{dataSource:h,daySpanByFirstKey:u}=i.useMemo(()=>{const b=(Array.isArray(c?.data)&&c.data||Array.isArray(c?.data?.data)&&c.data.data||[]).slice().sort((I,k)=>{const S=ao.indexOf(String(I?.day_name||"").toLowerCase()),x=ao.indexOf(String(k?.day_name||"").toLowerCase());if(S!==x)return S-x;const g=Number(I?.order_no||0),C=Number(k?.order_no||0);return g!==C?g-C:String(I?.time_from||"").localeCompare(String(k?.time_from||""))}),m=new Map,j=[];let D=0;for(;D<b.length;){const I=String(b[D]?.day_name||"").toLowerCase();let k=D;for(;k<b.length&&String(b[k]?.day_name||"").toLowerCase()===I;)k+=1;const S=k-D;for(let x=D;x<k;x+=1){const g=b[x],C=g?.id||`${I}-${g?.order_no}-${x}`;x===D&&m.set(C,S),j.push({key:C,_dayKey:I,...g})}D=k}return{dataSource:j,daySpanByFirstKey:m}},[c]),p=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(v,b)=>{const m=u.get(b.key);return m===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(te.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(n.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:lg(v)})]}),props:{rowSpan:m}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:v=>e.jsx(n.Tag,{color:"#5080f8",style:{fontWeight:500},children:v})},{title:"Time",key:"time",width:180,render:(v,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(te.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(n.Typography.Text,{children:[no(b?.time_from)," - ",no(b?.time_to)]})]})},{title:"Subject",key:"subject",render:(v,b)=>{if(String(b?.is_break)==="1")return e.jsx(n.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const j=b?.subject_name||"-";return e.jsx(n.Tag,{color:dg(j),style:{fontWeight:500},children:j})}},{title:"Class",key:"class",width:160,render:(v,b)=>e.jsxs(n.Tag,{color:"purple",style:{fontWeight:500},children:[b?.class_name||b?.class_id||"-"," ",b?.section_name?`(${b.section_name})`:""]})},{title:"Room",key:"room_no",width:120,render:(v,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(te.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:b?.room_no||"-"})]})}],[u]),w=v=>{v.preventDefault();const b=v.target.teacher_id?.value;if(!b)return;s(b);const j=`${is.teacherTimetable}${encodeURIComponent(String(b))}`;o(j)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Teacher Wise Timetable"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:w,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(X,{options:d,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teacher",name:"teacher_id",allowSelectAll:!1,required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Timetable"}),children:e.jsx(n.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:h,columns:p,rowKey:"key",loading:y,scroll:{x:"max-content"}})})]})}function so(t){if(!t)return null;const a=String(t).trim().replaceAll(".",":");if(!a)return null;const s=a.toLowerCase(),r=s.includes("am")||s.includes("pm");let o=0,l=0,d=0;if(r){const y=s.replace(/\s+/g," ").match(/^(\d{1,2})\s*:\s*(\d{1,2})(?:\s*:\s*(\d{1,2}))?\s*(am|pm)$/i);if(!y)return null;o=Number.parseInt(y[1],10),l=Number.parseInt(y[2],10),d=Number.parseInt(y[3]||"0",10);const h=y[4].toLowerCase();h==="pm"&&o<12&&(o+=12),h==="am"&&o===12&&(o=0)}else{const c=a.split(":").map(y=>y.trim());if(c.length<2)return null;o=Number.parseInt(c[0],10),l=Number.parseInt(c[1],10),d=Number.parseInt(c[2]||"0",10)}return![o,l,d].every(c=>Number.isFinite(c))||o<0||o>23||l<0||l>59||d<0||d>59?null:ee().hour(o).minute(l).second(d).millisecond(0)}function $a(t,a){const s=Number.parseInt(a,10);return!Number.isFinite(s)||s<=0||!t||!t.isValid?.()?null:t.add(s,"minute")}const qn=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},qa={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},ug=t=>{const a=qa[String(t)];return a?a.charAt(0).toUpperCase()+a.slice(1):String(t)},pg=({token:t,classId:a,sectionId:s,subjectId:r,value:o,onChange:l,disabled:d})=>{const c=t&&a&&s&&r?`${is.teachersBySubject}?subject_id=${encodeURIComponent(String(r))}&class_id=${encodeURIComponent(String(a))}&section_id=${encodeURIComponent(String(s))}`:null,{data:y,isLoading:h}=W(c?[c,t]:null,([p,w])=>H(p,w),{revalidateOnFocus:!1}),u=i.useMemo(()=>qn(y?.data??y).map(w=>({value:w?.value??w?.id,label:w?.label??w?.name??w?.teacher_name??""})),[y]);return e.jsx(n.Select,{placeholder:d?"-":"Select Teacher",loading:h,disabled:d,style:{width:"100%"},options:u,value:o?String(o):void 0,onChange:p=>l?.(p),showSearch:!0,optionFilterProp:"label"})};function mg({token:t}){const[a]=n.Form.useForm(),[s,r]=i.useState({classId:null,sectionId:null,dayKey:"1",daysEnabled:{0:!1,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0}}),[o,l]=i.useState({startTime:null,endTime:null,duration:40,interval:0,roomNo:"",tiffinEnabled:!1,tiffinAfterPeriod:3,tiffinDuration:20}),[d,c]=i.useState({0:[],1:[],2:[],3:[],4:[],5:[],6:[]}),[y,h]=i.useState(!1),u=i.useMemo(()=>t?De.master.classes.dropdown:null,[t]),{data:p}=W(u?[u,t]:null,([f,P])=>H(f,P)),w=i.useMemo(()=>qn(p).map(f=>({value:f?.value??f?.id,label:f?.label??f?.title??""})),[p]),v=i.useMemo(()=>!t||!s.classId?null:`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(s.classId))}`,[s.classId,t]),{data:b}=W(v?[v,t]:null,([f,P])=>H(f,P)),m=i.useMemo(()=>qn(b).map(f=>({value:f?.value??f?.id,label:f?.label??f?.title??""})),[b]),j=i.useMemo(()=>!t||!s.classId?null:`${De.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(s.classId))}`,[s.classId,t]),{data:D}=W(j?[j,t]:null,([f,P])=>H(f,P)),I=i.useMemo(()=>qn(D).map(f=>({value:f?.value??f?.id,label:f?.label??f?.title??""})),[D]),k=i.useMemo(()=>Array.isArray(d?.[s.dayKey])?d[s.dayKey]:[],[s.dayKey,d]),S=i.useCallback((f,P,O)=>{c($=>{const F={...$},U=Array.isArray(F[f])?F[f].slice():[];return U[P]={...U[P]??{},...O},F[f]=U,F})},[]),x=i.useCallback((f,P)=>{c(O=>{const $={...O},F=Array.isArray($[f])?$[f].slice():[];return F.splice(P,1),$[f]=F.map((U,V)=>({...U,order_no:V+1})),$})},[]),g=i.useCallback(f=>{c(P=>{const O={...P},$=Array.isArray(O[f])?O[f].slice():[];let F=null,U=null;const V=$[$.length-1];if(V?.time_to){const q=so(V.time_to),E=Number.parseInt(o.interval,10)||0,M=Number.parseInt(o.duration,10)||0,B=$a(q,E),z=M>0?$a(B,M):null;F=B?.isValid?.()?B.format("HH:mm:ss"):null,U=z?.isValid?.()?z.format("HH:mm:ss"):null}return $.push({order_no:$.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:F,time_to:U,is_break:!1}),O[f]=$,O})},[o.duration,o.interval,o.roomNo]),C=i.useCallback(()=>{const f=o.startTime,P=o.endTime,O=Number.parseInt(o.duration,10),$=Number.parseInt(o.interval,10);if(!f||!f.isValid?.()){_.error("Start time is required",{duration:1500});return}if(!P||!P.isValid?.()){_.error("End time is required",{duration:1500});return}if(!P.isAfter(f)){_.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(O)||O<=0){_.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite($)||$<0){_.error("Interval must be 0 or more",{duration:1500});return}const F=()=>{const U=[];let V=f;for(let q=0;q<50;q+=1){const E=$a(V,O);if(!E||!E.isValid?.()||E.isAfter(P))break;U.push({order_no:U.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:V.format("HH:mm:ss"),time_to:E.format("HH:mm:ss"),is_break:!1});const M=$a(E,$);if(!M||!M.isValid?.()||M.isAfter(P)||M.isSame(P))break;V=M}if(o.tiffinEnabled){const q=Math.max(0,Number.parseInt(o.tiffinAfterPeriod,10)||0),E=Math.max(0,Number.parseInt(o.tiffinDuration,10)||0),M=Math.min(q,U.length);if(M>0&&E>0){const B=U[M-1],z=B?.time_to?so(B.time_to):null,G=z?$a(z,E):null;z?.isValid?.()&&G?.isValid?.()&&!G.isAfter(P)&&U.splice(M,0,{order_no:M+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:z.format("HH:mm:ss"),time_to:G.format("HH:mm:ss"),is_break:!0})}}return U.map((q,E)=>({...q,order_no:E+1}))};c(U=>{const V={...U};return Object.keys(qa).forEach(q=>{s.daysEnabled?.[q]&&(V[q]=F())}),V}),_.success("Generated schedule",{duration:1e3})},[o,s.daysEnabled]),T=i.useCallback(()=>{const f=localStorage.getItem("genrall_settings"),O=(f?JSON.parse(f):{})?.session_id??"1",$=s.classId,F=s.sectionId,U=Object.keys(qa).map(V=>{const q=(Array.isArray(d?.[V])?d[V]:[]).map((E,M)=>({order_no:M+1,subject_id:E?.is_break?0:E?.subject_id??null,teacher_id:E?.is_break?0:E?.teacher_id??null,room_no:E?.room_no??"",time_from:E?.time_from??null,time_to:E?.time_to??null,is_break:E?.is_break?1:0}));return{day:qa[V],class_id:$,section_id:F,session_id:O,args:q}});return{class_id:$,section_id:F,session_id:O,days:U}},[s.classId,s.sectionId,d]),R=i.useCallback(async()=>{if(!s.classId||!s.sectionId){_.error("Please select Class and Section",{duration:1500});return}const f=T(),P=Array.isArray(f?.days)?f.days:[];if(!P.some(F=>Array.isArray(F?.args)&&F.args.length>0)){_.error("No timetable rows to submit",{duration:1500});return}const $=F=>{const U=F?.is_break;return U===1||U==="1"||U===!0?!0:String(U??"").toLowerCase()==="true"};P.some(F=>(Array.isArray(F?.args)?F.args:[]).some(U=>String(U?.time_from??"").trim()&&String(U?.time_to??"").trim()?$(U)?!1:!String(U?.subject_id??"").trim()||!String(U?.teacher_id??"").trim():!0)),h(!0);try{const F=is.save,U=F==="api/timetable/save"?"timetable/save":null,V=async M=>{const B=await Zn(M,f,t);if(B&&typeof B=="object")return B;throw new Error("No response from server")};let q;try{q=await V(F)}catch{q=await V(U)}const E=String(q?.msg??"");if(String(q?.Status)==="Success"){if(Array.isArray(q?.data)&&q.data.length===0&&E){_.error(E,{duration:3e3});return}_.success(E||"Weekly Time Table added successfully!",{duration:1200});return}_.error(E||"Failed to add time table",{duration:3e3})}catch(F){_.error(F?.response?.data?.msg??F?.message??"Failed to add time table",{duration:3e3})}finally{h(!1)}},[T,s.classId,s.sectionId,t]),L=i.useMemo(()=>[{title:"Period",dataIndex:"order_no",key:"order_no",width:80},{title:"Time From",dataIndex:"time_from",key:"time_from",width:120,render:f=>f?ee(f,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:f=>f?ee(f,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(f,P,O)=>e.jsx(n.Switch,{checked:!!P?.is_break,onChange:$=>{S(s.dayKey,O,{is_break:$,subject_id:$?"":P?.subject_id??"",teacher_id:$?"":P?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(f,P,O)=>e.jsx(n.Select,{placeholder:P?.is_break?"-":"Select Subject",disabled:!!P?.is_break,style:{width:"100%"},options:I,value:P?.subject_id?String(P.subject_id):void 0,onChange:$=>S(s.dayKey,O,{subject_id:$,teacher_id:""}),showSearch:!0,optionFilterProp:"label"})},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(f,P,O)=>e.jsx(pg,{token:t,classId:s.classId,sectionId:s.sectionId,subjectId:P?.subject_id,disabled:!!P?.is_break||!P?.subject_id,value:P?.teacher_id,onChange:$=>S(s.dayKey,O,{teacher_id:$})})},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(f,P,O)=>e.jsx(n.Input,{value:P?.room_no??"",onChange:$=>S(s.dayKey,O,{room_no:$.target.value})})},{title:"Action",key:"action",width:90,render:(f,P,O)=>e.jsx(n.Popconfirm,{title:"Delete this row?",onConfirm:()=>x(s.dayKey,O),children:e.jsx(n.Button,{danger:!0,type:"text",children:"Delete"})})}],[s.classId,s.dayKey,s.sectionId,x,I,t,S]),N=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Create Time Table"}),children:e.jsx(n.Form,{form:a,layout:"vertical",initialValues:{duration:o.duration,interval:o.interval,roomNo:o.roomNo,tiffinEnabled:o.tiffinEnabled,tiffinAfterPeriod:o.tiffinAfterPeriod,tiffinDuration:o.tiffinDuration},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",required:!0,children:e.jsx(n.Select,{placeholder:"Select Class",options:w,value:s.classId?String(s.classId):void 0,onChange:f=>{r(P=>({...P,classId:f,sectionId:null})),c({0:[],1:[],2:[],3:[],4:[],5:[],6:[]})},showSearch:!0,optionFilterProp:"label"})}),e.jsx(n.Form.Item,{label:"Section",required:!0,children:e.jsx(n.Select,{placeholder:"Select Section",options:m,value:s.sectionId?String(s.sectionId):void 0,onChange:f=>r(P=>({...P,sectionId:f})),disabled:!s.classId,showSearch:!0,optionFilterProp:"label"})}),e.jsx(n.Form.Item,{label:"Start Time",required:!0,children:e.jsx(n.TimePicker,{value:o.startTime,onChange:f=>l(P=>({...P,startTime:f})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"End Time",required:!0,children:e.jsx(n.TimePicker,{value:o.endTime,onChange:f=>l(P=>({...P,endTime:f})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Duration (min)",required:!0,children:e.jsx(n.InputNumber,{min:1,value:o.duration,onChange:f=>l(P=>({...P,duration:f})),style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Interval (min)",children:e.jsx(n.InputNumber,{min:0,value:o.interval,onChange:f=>l(P=>({...P,interval:f})),style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Room No",children:e.jsx(n.Input,{value:o.roomNo,onChange:f=>l(P=>({...P,roomNo:f.target.value}))})}),e.jsx(n.Form.Item,{label:"Tiffin Break",children:e.jsxs(n.Space,{children:[e.jsx(n.Switch,{checked:o.tiffinEnabled,onChange:f=>l(P=>({...P,tiffinEnabled:f}))}),e.jsx(n.Typography.Text,{type:"secondary",children:o.tiffinEnabled?"Enabled":"Disabled"})]})}),e.jsx(n.Form.Item,{label:"After Period",tooltip:"Insert break row after this period",style:{marginBottom:0},children:e.jsx(n.InputNumber,{min:1,value:o.tiffinAfterPeriod,onChange:f=>l(P=>({...P,tiffinAfterPeriod:f})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsx(n.Form.Item,{label:"Break Duration (min)",style:{marginBottom:0},children:e.jsx(n.InputNumber,{min:1,value:o.tiffinDuration,onChange:f=>l(P=>({...P,tiffinDuration:f})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(n.Button,{onClick:C,children:"Generate"}),e.jsx(n.Button,{type:"primary",loading:y,onClick:R,children:"Save"})]})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Edit Week"}),extra:e.jsxs(n.Space,{children:[e.jsx(n.Typography.Text,{type:"secondary",children:"Day"}),e.jsx(n.Select,{style:{width:160},value:s.dayKey,onChange:f=>r(P=>({...P,dayKey:f})),options:Object.keys(qa).map(f=>({value:String(f),label:ug(f)}))}),e.jsx(n.Button,{onClick:()=>g(s.dayKey),children:"Add Row"})]}),children:e.jsx(n.Table,{rowKey:(f,P)=>`${s.dayKey}_${P}`,columns:L,dataSource:k,pagination:!1,size:"middle",scroll:{x:"max-content"}})})]});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Typography.Title,{level:4,style:{margin:0},children:"Time Table"}),e.jsx(n.Tabs,{type:"card",items:[{key:"create",label:"Create",children:N},{key:"routine",label:"Routine",children:e.jsx(ig,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(cg,{token:t})}]})]})}function hg({token:t}){return e.jsx(mg,{token:t})}function fg(){return null}const Xt=t=>t??localStorage.getItem("authToken")??"",dr=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},ft={organization:{get:"api/branchapi/generalSettings/getorganizationsettingsData",save:"api/branchapi/generalSettings/addorganizationSetting",currencyDropdown:"api/branchapi/generalSettings/currencyDropdown",countryCodeDropdown:"api/branchapi/generalSettings/contrycodeDropdown",timezoneDropdown:"api/branchapi/generalSettings/timezoneDropdown",boardsDropdown:"api/branchapi/generalSettings/getAffliatedBoardsDropDown",uploadLogo:"api/superAdmin/upload_logo",uploadSignature:"api/branchapi/generalSettings/upload_signature",uploadFirebaseJson:"api/branchapi/generalSettings/firebaseJsonUpload"},academicYear:{table:"api/branchapi/generalSettings/sessiontable",add:"api/branchapi/generalSettings/addsession",setActive:"api/branchapi/generalSettings/setsession",remove:"api/branchapi/generalSettings/deletesession"},feeReceiptSetting:{get:"api/branchapi/generalSettings/feesReceiptSettingData",save:"api/branchapi/generalSettings/feesReceiptSetting"},marksheetSetting:{templateTypes:"api/branchapi/GeneralSettings/getmarkssheetTemplate",classDropdown:"api/exam/exam/getClassforAssignMarksSheetType",assignedTable:"api/branchapi/GeneralSettings/getassign_templete",assign:"api/branchapi/GeneralSettings/assign_templete",remove:"api/branchapi/GeneralSettings/deleteTemplate"},legalPages:{get:"api/branchapi/generalSettings/getlegalpage",termsSave:"api/branchapi/generalSettings/terms",privacySave:"api/branchapi/generalSettings/privacy",aboutSave:"api/branchapi/generalSettings/about_us"},feesInfo:{get:"api/branchapi/generalSettings/getFeesInfo",save:"api/branchapi/generalSettings/addFeesInfo",statesDropdown:"api/superAdmin/states"},payrollSettings:{table:"api/branchapi/GeneralSettings/getsetting_allowances_dedection",add:"api/branchapi/GeneralSettings/addsetting_allowances_dedection",edit:"api/branchapi/GeneralSettings/updatesetting_allowances_dedection",remove:"api/branchapi/GeneralSettings/deletesetting_allowances_dedection",byId:"api/branchapi/GeneralSettings/getsetting_allowances_dedectionById"},paymentGateway:{get:"api/payment_gateway/PaymentProcess/getPaymentGatewayList",save:"api/payment_gateway/PaymentProcess"}},cr=t=>dr(He(),t),yg=()=>dr(He(),"uploads"),ml=t=>dr(yg(),t),gg=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return H(l,Xt(r))},xg=async(t,a)=>H(t,Xt(a)),nn=async(t,a,s)=>Ee(t,a,Xt(s)),hl=async(t,a,s)=>Be(t,a,Xt(s)),ur=async(t,a,s)=>qe(t,a,Xt(s)),bg=async(t,a,s)=>Zn(t,{arg:a},Xt(s)),fl=async(t,a,s)=>za(t,{arg:a},Xt(s)),yl=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>W(r&&t?[t,a,s,r]:null,([l,d,c,y])=>gg({baseUrl:l,page:d,perPage:c},y)),yt=({url:t,token:a})=>W(a&&t?[t,a]:null,([r,o])=>xg(r,o)),jg={border:"1px solid #d9d9d9",borderRadius:8,padding:12,minHeight:320,background:"#fff"};function Sg({value:t,onChange:a,placeholder:s}){const[r,o]=i.useState(t??""),l=i.useMemo(()=>typeof t=="string"?t:r,[r,t]);return e.jsx("div",{style:jg,children:e.jsx(Ho,{html:l||"",onChange:d=>{const c=d?.target?.value??"";o(c),a?.(c)},style:{outline:"none",minHeight:280},placeholder:s})})}function Vt({title:t,actions:a,children:s,headerExtra:r}){return e.jsx("div",{style:{display:"grid",gap:20},children:s})}const vg=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function pr({token:t,title:a,fetchUrl:s,saveUrl:r,fieldName:o,initialHtmlFieldName:l}){const d=i.useRef(null),c=yt({url:s,token:t}),h=i.useMemo(()=>vg(c.data),[c.data])?.[l??o]??"",[u,p]=i.useState("");i.useEffect(()=>{p(typeof h=="string"?h:"")},[h]);const w=()=>p(typeof h=="string"?h:""),v=()=>{const j=new Blob([String(u??"")],{type:"text/html"}),D=URL.createObjectURL(j),I=document.createElement("a");I.href=D,I.download=`${String(a??"legal").toLowerCase().replaceAll(" ","-")}.html`,I.click(),URL.revokeObjectURL(D)},b=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(te.SaveOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(te.SyncOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:w},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:v,disabled:!u}],[u,h]),m=async j=>{j.preventDefault();try{(await fl(r,{[o]:u??""},t))?.Status==="Success"?_.success("Updated successfully.",{duration:1e3}):_.success("Updated.",{duration:1e3}),c.mutate?.()}catch(D){_.error(D?.response?.data?.msg??D?.message??"Failed to update.",{duration:1500})}};return c.isLoading&&!c.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:a,actions:b,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Editor"}),children:e.jsxs("form",{ref:d,onSubmit:m,children:[e.jsx(Sg,{value:u,onChange:p,placeholder:`Enter ${a} content...`}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Update"})})]})})})]})}const wg=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",_g=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:");function ha({token:t,value:a,onChange:s,action:r,accept:o,maxCount:l=1,previewUrl:d}){const c=i.useMemo(()=>{if(t)return{Authorization:t}},[t]),y=i.useMemo(()=>a?d||(_g(a)?a:""):"",[d,a]);return e.jsxs("div",{style:{display:"grid",gap:8},children:[y?e.jsx("img",{src:y,alt:"upload-preview",style:{width:88,height:88,objectFit:"cover",borderRadius:8,border:"1px solid #d9d9d9",background:"#fafafa"}}):null,e.jsx(n.Upload,{maxCount:l,action:r,accept:o,headers:c,onChange:h=>{if(h?.file?.status==="removed"&&s?.(""),h?.file?.status==="done"){const u=wg(h?.file?.response);u&&s?.(u)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})]})}const Mt=ft.organization,gl=()=>cr(Mt.uploadLogo),Ps=()=>cr(Mt.uploadSignature),Cg=()=>cr(Mt.uploadFirebaseJson),Ag=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],Dg=({token:t})=>yt({url:Mt.get,token:t}),Tg=({token:t})=>yt({url:Mt.currencyDropdown,token:t}),Rg=({token:t})=>yt({url:Mt.countryCodeDropdown,token:t}),Ig=({token:t})=>yt({url:Mt.timezoneDropdown,token:t}),kg=({token:t})=>yt({url:Mt.boardsDropdown,token:t}),Dn=t=>Ag(t?.data),ro={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Pg=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].map(t=>({value:t,label:t})),io=[{value:"Yes",label:"Yes"},{value:"No",label:"No"}],oo=[{value:"yes",label:"Yes"},{value:"no",label:"No"}],Og=t=>{const a=t?.data;return Array.isArray(a?.data)?a.data[0]??null:Array.isArray(a)?a[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null},Mg=t=>t?.data?.inout_setting?.[0]??t?.inout_setting?.[0]??null,Eg=t=>t?.data?.notification_settings?.[0]??t?.notification_settings?.[0]??null;function Fg({token:t}){const a=i.useRef(null),s=Dg({token:t}),r=Tg({token:t}),o=Rg({token:t}),l=Ig({token:t}),d=kg({token:t}),c=i.useMemo(()=>Og(s.data),[s.data]),y=i.useMemo(()=>Mg(s.data),[s.data]),h=i.useMemo(()=>Eg(s.data),[s.data]),u=i.useMemo(()=>Dn(r),[r.data]),p=i.useMemo(()=>Dn(o),[o.data]),w=i.useMemo(()=>Dn(l),[l.data]),v=i.useMemo(()=>Dn(d),[d.data]),[b,m]=i.useState(null),[j,D]=i.useState(null),[I,k]=i.useState(null),[S,x]=i.useState(null),[g,C]=i.useState([]),[T,R]=i.useState("No"),[L,N]=i.useState("yes"),[f,P]=i.useState("no"),[O,$]=i.useState("Yes"),[F,U]=i.useState(""),[V,q]=i.useState(""),[E,M]=i.useState(null),[B,z]=i.useState(null),[G,re]=i.useState(null),[K,J]=i.useState(null),ae=()=>{const Q=(()=>{try{const ce=c?.weekly_off;if(!ce)return[];const Te=Array.isArray(ce)?ce:JSON.parse(ce);return Array.isArray(Te)?Te.filter(Boolean).map($e=>({value:$e,label:$e})):[]}catch{return[]}})();C(Q),m(u.find(ce=>ce?.value===c?.currency)??null),D(p.find(ce=>ce?.value===c?.country_code)??null),k(w.find(ce=>ce?.value===c?.time_zone)??null),x(v.find(ce=>ce?.value===c?.affliated_board_id)??null),U(c?.logo??""),q(c?.json_file??""),R(c?.attendance_salary_calculation??"No"),N(c?.salary_period??"yes"),P(c?.multiple_shift??"no"),$(c?.readmission_charges??"Yes"),M(y?.in_from?ee(y.in_from,"h:mm A"):null),z(y?.in_to?ee(y.in_to,"h:mm A"):null),re(y?.out_from?ee(y.out_from,"h:mm A"):null),J(y?.out_to?ee(y.out_to,"h:mm A"):null)};i.useEffect(()=>{c&&ae()},[c,u,p,w,v]);const oe=()=>{a.current?.reset?.(),ae()},pe=()=>{const Q=new FormData(a.current??void 0),ce=Object.fromEntries(Q.entries());ce.weekly_off_day=g.map(Ve=>Ve?.value).filter(Boolean);const Te=new Blob([JSON.stringify(ce,null,2)],{type:"application/json"}),$e=URL.createObjectURL(Te),ke=document.createElement("a");ke.href=$e,ke.download="organization-setting.json",ke.click(),URL.revokeObjectURL($e)},_e=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(te.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(te.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:oe},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:pe,disabled:!c}],[c,g]),le=async Q=>{Q.preventDefault();try{const ce=new FormData(Q.target);ce.set("currency",b?.value??""),ce.set("code",j?.value??""),ce.set("time_zone",I?.value??""),ce.set("affliated_board_id",S?.value??""),ce.set("board_name",S?.label??""),ce.set("attendance_salary_calculation",T),ce.set("salary_period",L),ce.set("multiple_shift",f),ce.set("readmission_charges",O),g.forEach(ke=>{ke?.value&&ce.append("weekly_off_day[]",ke.value)}),ce.set("logo",F??""),ce.set("json_file",V??""),ce.set("server_key",h?.server_key??""),ce.set("in_time_start",E?ee(E).format("h:mm A"):""),ce.set("in_time_end",B?ee(B).format("h:mm A"):""),ce.set("out_time_start",G?ee(G).format("h:mm A"):""),ce.set("out_time_end",K?ee(K).format("h:mm A"):""),await nn(Mt.save,ce,t);const $e={...JSON.parse(localStorage.getItem("genrall_settings")??"null")??{},logo:F||c?.logo||"",affliated_board_id:S?.value??c?.affliated_board_id??"",board_name:S?.label??c?.board_name??"",multiple_shift:f??c?.multiple_shift??""};localStorage.setItem("genrall_settings",JSON.stringify($e)),_.success("Organization settings saved.",{duration:1e3}),s.mutate?.()}catch(ce){_.error(ce?.response?.data?.msg??ce?.message??"Failed to save settings.",{duration:1500})}},de=T==="Yes";return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Organization",actions:_e,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Organization Details"}),children:e.jsxs("form",{ref:a,onSubmit:le,children:[e.jsxs("div",{style:ro,children:[e.jsx(Y,{type:"text",name:"name",label:"Organization Name*",required:!0,defaultValue:c?.name??""}),e.jsxs("div",{children:[e.jsx(X,{label:"Currency*",options:u,value:b,onChange:Q=>m(Q)}),e.jsx("input",{type:"hidden",name:"currency",value:b?.value??""})]}),e.jsxs("div",{children:[e.jsx(X,{label:"Default Country Code*",options:p,value:j,onChange:Q=>D(Q)}),e.jsx("input",{type:"hidden",name:"code",value:j?.value??""})]}),e.jsxs("div",{children:[e.jsx(X,{label:"Time Zone*",options:w,value:I,onChange:Q=>k(Q)}),e.jsx("input",{type:"hidden",name:"time_zone",value:I?.value??""})]}),e.jsx(Y,{type:"text",name:"admission_prefix",label:"Receipt Prefix*",required:!0,defaultValue:c?.admission_prefix??""}),e.jsx(Y,{type:"number",name:"admission_start_number",label:"Admission Start Number*",required:!0,defaultValue:c?.admission_no_prefix??c?.admission_start_number??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Re-admission Charges"}),e.jsx(n.Radio.Group,{options:io,optionType:"button",buttonStyle:"solid",value:O,onChange:Q=>$(Q.target.value)}),e.jsx("input",{type:"hidden",name:"readmission_charges",value:O})]}),e.jsxs("div",{children:[e.jsx(X,{label:"Weekly off Day",options:Pg,isMulti:!0,value:g,onChange:Q=>C(Q??[])}),g.map(Q=>e.jsx("input",{type:"hidden",name:"weekly_off_day[]",value:Q.value},Q.value))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time Start*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:E,onChange:Q=>M(Q),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_start",value:E?ee(E).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time End*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:B,onChange:Q=>z(Q),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_end",value:B?ee(B).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time Start*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:G,onChange:Q=>re(Q),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_start",value:G?ee(G).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time End*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:K,onChange:Q=>J(Q),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_end",value:K?ee(K).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Period"}),e.jsx(n.Radio.Group,{options:oo,optionType:"button",buttonStyle:"solid",value:L,onChange:Q=>N(Q.target.value)}),e.jsx("input",{type:"hidden",name:"salary_period",value:L})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Deduction"}),e.jsx(n.Radio.Group,{options:io,optionType:"button",buttonStyle:"solid",value:T,onChange:Q=>R(Q.target.value)}),e.jsx("input",{type:"hidden",name:"attendance_salary_calculation",value:T})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Multiple Shift"}),e.jsx(n.Radio.Group,{options:oo,optionType:"button",buttonStyle:"solid",value:f,onChange:Q=>P(Q.target.value)}),e.jsx("input",{type:"hidden",name:"multiple_shift",value:f})]}),de?e.jsx(Y,{type:"number",name:"late_absent_day",label:"No of Late",defaultValue:c?.late_absent_day??""}):e.jsx("input",{type:"hidden",name:"late_absent_day",value:""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:ro,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Logo Upload"}),e.jsx(ha,{token:t,action:gl(),value:F,accept:"image/*",onChange:Q=>U(Q)}),e.jsx("input",{type:"hidden",name:"logo",value:F??""})]}),e.jsxs("div",{children:[e.jsx(X,{label:"Select Affiliated Board",options:v,value:S,onChange:Q=>x(Q)}),e.jsx("input",{type:"hidden",name:"affliated_board_id",value:S?.value??""}),e.jsx("input",{type:"hidden",name:"board_name",value:S?.label??""})]}),e.jsx(st,{label:"Address",name:"address",rows:3,defaultValue:c?.location_name??c?.address??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Json for Notification"}),e.jsx(ha,{token:t,action:Cg(),value:V,accept:".json",onChange:Q=>q(Q)}),e.jsx("input",{type:"hidden",name:"json_file",value:V??""})]})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]})}function $g({token:t}){return e.jsx(Fg,{token:t})}const zn=ft.academicYear,Ug=({token:t,page:a=1,perPage:s=10})=>yl({baseUrl:zn.table,token:t,page:a,perPage:s}),Ng={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Lg=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[],Bg=(t,a=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??a;function qg({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(()=>{const g=ee(),C=ee().add(1,"year");return`${g.format("YYYY")}-${C.format("YYYY")}`}),[c,y]=i.useState(ee()),[h,u]=i.useState(ee().add(1,"year")),{isLoading:p,data:w,mutate:v}=Ug({token:t,page:a.page,perPage:a.rowsPerPage}),b=i.useMemo(()=>Lg(w),[w]),m=i.useMemo(()=>Bg(w,b.length),[w,b.length]),j=async()=>{if(!l){_.error("Session name is required.");return}if(h&&c&&ee(h).isBefore(c)){_.error("End date must be after start date.");return}try{const g=new FormData;g.set("name",l),g.set("start_date",c?ee(c).format("YYYY-MM-DD"):""),g.set("end_date",h?ee(h).format("YYYY-MM-DD"):""),await nn(zn.add,g,t),_.success("Academic year added.",{duration:1e3}),o(!1),v?.()}catch(g){_.error(g?.response?.data?.msg??g?.message??"Failed to add academic year.",{duration:1500})}},D=async g=>{try{const C=new FormData;C.set("session",String(g)),await hl(zn.setActive,C,t);const T=JSON.parse(localStorage.getItem("genrall_settings")??"null")??{};localStorage.setItem("genrall_settings",JSON.stringify({...T,session_id:String(g)})),_.success("Academic year activated.",{duration:1e3}),v?.()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to activate academic year.",{duration:1500})}},I=async g=>{try{await v(ur(zn.remove,g,t)),_.success("Academic year deleted.",{duration:1e3})}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to delete academic year.",{duration:1500})}},k=()=>{const g=new Blob([JSON.stringify(b,null,2)],{type:"application/json"}),C=URL.createObjectURL(g),T=document.createElement("a");T.href=C,T.download="academic-years.json",T.click(),URL.revokeObjectURL(C)},S=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(te.PlusOutlined,{}),onClick:()=>o(!0)},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:()=>v?.()},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:k,disabled:b.length===0}],[b.length,v]),x=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name"},{title:"Start Date",dataIndex:"start_date",key:"start_date"},{title:"End Date",dataIndex:"end_date",key:"end_date"},{title:"Active",key:"active",render:(g,C)=>{const T=C.status==="Active";return e.jsxs("span",{children:[e.jsx(n.Popconfirm,{title:T?"Deactivate Academic Year?":"Activate Academic Year?",description:T?"Deactivate is not allowed. Activate another session to switch.":"This will set this year as the current academic session.",onConfirm:()=>{T?_.error("Deactivate is not allowed. Activate another session to switch."):D(C.id)},okText:"Yes",cancelText:"No",children:e.jsx(n.Switch,{checked:T})}),T&&e.jsx(n.Tag,{color:"green",style:{marginLeft:8},children:"Active"})]})}},{title:"Action",key:"action",render:(g,C)=>e.jsx(n.Popconfirm,{title:"Delete academic year?",description:"This will remove the session.",onConfirm:()=>I(C.id),okText:"Yes",cancelText:"No",children:e.jsx(n.Button,{type:"link",danger:!0,children:"Delete"})})}],[t,b.length]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Academic Year",actions:S,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Sessions"}),children:e.jsx(n.Table,{rowKey:"id",dataSource:b,columns:x,loading:p,pagination:{current:a.page,pageSize:a.rowsPerPage,total:m,showSizeChanger:!0,onChange:(g,C)=>s({page:g,rowsPerPage:Number(C)})}})})}),e.jsx(n.Modal,{open:r,onCancel:()=>o(!1),footer:null,title:"Add Academic Year",children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:Ng,children:[e.jsx(Y,{label:"Session Name*",value:l,onChange:g=>d(g.target.value)}),e.jsxs("div",{children:[e.jsx(Me,{Desplay:"Start Date*",value:c,onChange:g=>y(g),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:c?ee(c).format("YYYY-MM-DD"):""})]}),e.jsxs("div",{children:[e.jsx(Me,{Desplay:"End Date*",value:h,onChange:g=>u(g),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:h?ee(h).format("YYYY-MM-DD"):""})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ne,{value:"Submit",type:"button",onClick:j}),e.jsx(n.Button,{onClick:()=>o(!1),children:"Cancel"})]})]})})]})}function zg({token:t}){return e.jsx(qg,{token:t})}const xl=ft.feeReceiptSetting,Yg=({token:t})=>yt({url:xl.get,token:t}),Os={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:16,alignItems:"start"},Vg=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function Wg({token:t}){const a=i.useRef(null),s=Yg({token:t}),r=i.useMemo(()=>Vg(s.data),[s.data]),[o,l]=i.useState(""),[d,c]=i.useState(!1),[y,h]=i.useState(!1),[u,p]=i.useState(!1),[w,v]=i.useState("0"),[b,m]=i.useState("0"),[j,D]=i.useState("0"),[I,k]=i.useState(!1),[S,x]=i.useState(!1),[g,C]=i.useState(""),[T,R]=i.useState(!1),L=()=>{l(r?.number_of_receipt??""),c(String(r?.roll_number??"0")==="1"),h(String(r?.address??"0")==="1"),p(String(r?.gardian_name??"0")==="1"),v(String(r?.authorized_signatory??"0")),m(String(r?.parent_signatory??"0")),D(String(r?.dynamic_qr_code_device??"0")),k(String(r?.sequence_payment??"0")==="1"),x(String(r?.previois_fees??"0")==="1"),C(r?.upfront_payment_months??"")};i.useEffect(()=>{r&&L()},[r]);const N=()=>{a.current?.reset?.(),L()},f=()=>{const $={number_of_receipt:o,rollnumber:d?1:0,address:y?1:0,gardianname:u?1:0,authorizedsignatory:w,parentsignatory:b,dynamic_qr_code_device:j,sequence_payment:I?1:0,previois_fees:S?1:0,upfront_payment_months:g},F=new Blob([JSON.stringify($,null,2)],{type:"application/json"}),U=URL.createObjectURL(F),V=document.createElement("a");V.href=U,V.download="fee-receipt-setting.json",V.click(),URL.revokeObjectURL(U)},P=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(te.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(te.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:N},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:f,disabled:!r}],[r,o,d,y,u,w,b,j,I,S,g]),O=async $=>{$.preventDefault(),R(!0);try{const F=new FormData;F.set("number_of_receipt",String(o??"")),F.set("rollnumber",d?"1":"0"),F.set("address",y?"1":"0"),F.set("gardianname",u?"1":"0"),F.set("authorizedsignatory",String(w??"0")),F.set("parentsignatory",String(b??"0")),F.set("dynamic_qr_code_device",String(j??"0")),F.set("sequence_payment",I?"1":"0"),F.set("previois_fees",S?"1":"0"),F.set("upfront_payment_months",String(g??"")),await nn(xl.save,F,t),_.success("Fee receipt settings updated.",{duration:1e3}),s.mutate?.()}catch(F){_.error(F?.response?.data?.msg??F?.message??"Failed to update settings.",{duration:1500})}finally{R(!1)}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Fee Receipt Setting",actions:P,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Settings Form"}),children:e.jsxs("form",{ref:a,onSubmit:O,children:[e.jsxs("div",{style:Os,children:[e.jsx(Y,{type:"number",name:"number_of_receipt",label:"Number Of Receipt",value:o,onChange:$=>l($.target.value)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Roll Number"}),e.jsx(n.Checkbox,{checked:d,onChange:$=>c($.target.checked),children:"Show Roll Number in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Address"}),e.jsx(n.Checkbox,{checked:y,onChange:$=>h($.target.checked),children:"Show address in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Guardian Name"}),e.jsx(n.Checkbox,{checked:u,onChange:$=>p($.target.checked),children:"Show Guardian Name in Fees Receipt"})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Os,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Authorized Signatory"}),e.jsxs(n.Radio.Group,{value:w,onChange:$=>v($.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Parent Signatory"}),e.jsxs(n.Radio.Group,{value:b,onChange:$=>m($.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Dynamic QR Code Device"}),e.jsxs(n.Radio.Group,{value:j,onChange:$=>D($.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Os,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sequence Payment"}),e.jsx(n.Checkbox,{checked:I,onChange:$=>k($.target.checked),children:"Student can pay in sequence"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Previous Fees"}),e.jsx(n.Checkbox,{checked:S,onChange:$=>x($.target.checked),children:"Previous Fees Carry Over to Next Year"})]}),e.jsx(Y,{type:"number",name:"upfront_payment_months",label:"Max Advance Payment (Months)",value:g,onChange:$=>C($.target.value)})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:T?"Updating...":"Done",disabled:T})})]})})})]})}function Hg({token:t}){return e.jsx(Wg,{token:t})}const Va=ft.marksheetSetting,Kg=({token:t})=>yt({url:Va.templateTypes,token:t}),Gg=({token:t})=>yt({url:Va.classDropdown,token:t}),Jg=({token:t})=>yt({url:Va.assignedTable,token:t}),Qg={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:20,alignItems:"end"},lo=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],Xg=Array.from({length:12},(t,a)=>({value:String(a+1),label:`Design ${a+1}`})),Zg=t=>t?Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t)?t:[]:[];function ex({token:t}){const a=i.useRef(null),s=Kg({token:t}),r=Gg({token:t}),o=Jg({token:t}),l=i.useMemo(()=>lo(s.data),[s.data]),d=i.useMemo(()=>lo(r.data),[r.data]),c=i.useMemo(()=>Zg(o.data),[o.data]),[y,h]=i.useState(null),[u,p]=i.useState(null),[w,v]=i.useState([]),b=()=>{a.current?.reset?.(),h(null),p(null),v([])},m=()=>{const S=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),x=URL.createObjectURL(S),g=document.createElement("a");g.href=x,g.download="marksheet-templates.json",g.click(),URL.revokeObjectURL(x)},j=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(te.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:b},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:m,disabled:c.length===0}],[c.length]),D=async S=>{if(S.preventDefault(),!y?.value){_.error("Select marksheet type.",{duration:1200});return}if(!u?.value){_.error("Select design.",{duration:1200});return}if(!w?.length){_.error("Select at least one class.",{duration:1200});return}try{const x=new FormData;x.set("temp_id",String(y.value)),x.set("ui_id",String(u.value)),w.forEach(g=>x.append("class_id[]",String(g))),await nn(Va.assign,x,t),_.success("Marksheet template assigned.",{duration:1e3}),o.mutate?.(),b()}catch(x){_.error(x?.response?.data?.msg??x?.message??"Failed to assign template.",{duration:1500})}},I=async S=>{try{await ur(Va.remove,S,t),_.success("Template removed.",{duration:1e3}),o.mutate?.()}catch(x){_.error(x?.response?.data?.msg??x?.message??"Failed to remove template.",{duration:1500})}},k=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class"},{title:"Template Name",dataIndex:"name",key:"name"},{title:"Template Design",dataIndex:"ui_id",key:"ui_id"},{title:"Action",key:"action",render:(S,x)=>e.jsx(pt,{id:x?.id,funcName:I})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Marksheet Setting",actions:j,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Template"}),children:e.jsxs("form",{ref:a,onSubmit:D,children:[e.jsxs("div",{style:Qg,children:[e.jsxs("div",{children:[e.jsx(X,{label:"Select Marksheet Type",options:l,value:y,onChange:S=>h(S)}),e.jsx("input",{type:"hidden",name:"temp_id",value:y?.value??""})]}),e.jsxs("div",{children:[e.jsx(X,{label:"Select Design",options:Xg,value:u,onChange:S=>p(S)}),e.jsx("input",{type:"hidden",name:"ui_id",value:u?.value??""})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:8},children:"Class"}),e.jsx(n.Checkbox.Group,{options:d,value:w,onChange:S=>v(S)})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save"})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Marksheet List"}),children:e.jsx(n.Table,{size:"small",rowKey:"id",columns:k,dataSource:c,pagination:!1})})]})})]})}function tx({token:t}){return e.jsx(ex,{token:t})}const Ms={fetch:`${ft.legalPages.get}?page_name=terms`,save:ft.legalPages.termsSave,fieldName:"terms_data"};function ax({token:t}){return e.jsx(pr,{token:t,title:"Terms",fetchUrl:Ms.fetch,saveUrl:Ms.save,fieldName:Ms.fieldName})}function nx({token:t}){return e.jsx(ax,{token:t})}const Es={fetch:`${ft.legalPages.get}?page_name=privacy`,save:ft.legalPages.privacySave,fieldName:"privacy_data"};function sx({token:t}){return e.jsx(pr,{token:t,title:"Privacy",fetchUrl:Es.fetch,saveUrl:Es.save,fieldName:Es.fieldName})}function rx({token:t}){return e.jsx(sx,{token:t})}const Fs={fetch:`${ft.legalPages.get}?page_name=about_us`,save:ft.legalPages.aboutSave,fieldName:"about_data"};function ix({token:t}){return e.jsx(pr,{token:t,title:"About",fetchUrl:Fs.fetch,saveUrl:Fs.save,fieldName:Fs.fieldName})}function ox({token:t}){return e.jsx(ix,{token:t})}const mr=ft.feesInfo,lx=({token:t})=>yt({url:mr.get,token:t}),dx=({token:t})=>yt({url:mr.statesDropdown,token:t}),$s={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},cx=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null,ux=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[]:[],px=t=>t?ml(`branch/logo/${t}`):"",Us=t=>t?ml(`branch/signature/${t}`):"";function mx({token:t}){const a=i.useRef(null),s=lx({token:t}),r=dx({token:t}),o=i.useMemo(()=>cx(s.data),[s.data]),l=i.useMemo(()=>ux(r.data),[r.data]),[d,c]=i.useState(null),[y,h]=i.useState(""),[u,p]=i.useState(""),[w,v]=i.useState(""),[b,m]=i.useState(""),j=g=>{const C=new FormData(g),T=Object.fromEntries(C.entries());return T.state_id=d?.value??"",T.fees_receipt_logo=y,T.manager_signature=u,T.principal_signature=w,T.stamp=b,T},D=()=>{c(l.find(g=>String(g?.value)===String(o?.state_id??""))??null),h(o?.fees_receipt_logo??""),p(o?.manager_signature??""),v(o?.principal_signature??""),m(o?.stamp??"")};i.useEffect(()=>{o&&D()},[o,l]);const I=()=>{a.current?.reset?.(),D()},k=()=>{const g=j(a.current),C=new Blob([JSON.stringify(g,null,2)],{type:"application/json"}),T=URL.createObjectURL(C),R=document.createElement("a");R.href=T,R.download="fees-info.json",R.click(),URL.revokeObjectURL(T)},S=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(te.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(te.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:I},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:k,disabled:!o}],[o,d,y,u,w,b]),x=async g=>{g.preventDefault();try{const C=j(g.target);await bg(mr.save,C,t),_.success("Fees info saved.",{duration:1e3}),s.mutate?.()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to save fees info.",{duration:1500})}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Fees Info",actions:S,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"School Information"}),children:e.jsxs("form",{ref:a,onSubmit:x,children:[e.jsxs("div",{style:$s,children:[e.jsx(Y,{name:"Bussiness_name",label:"Business Name*",defaultValue:o?.name??"",required:!0}),e.jsx(Y,{name:"cin",label:"Sub Heading",defaultValue:o?.cin??""}),e.jsx(Y,{name:"school_no",type:"number",label:"School Number",defaultValue:o?.school_no??""}),e.jsx(Y,{name:"website",label:"Website",defaultValue:o?.website??""}),e.jsx(Y,{name:"school_Code",label:"School Code",defaultValue:o?.school_Code??""}),e.jsx(Y,{name:"offical_number",label:"Official Number",defaultValue:o?.offical_number??""}),e.jsx(Y,{name:"email_id",label:"Email",defaultValue:o?.email_id??""}),e.jsx(Y,{name:"receipt_prefix",label:"Receipt Prefix",defaultValue:o?.receipt_prefix??""}),e.jsx(Y,{name:"recipt_start_number",type:"number",label:"Receipt Start Number",defaultValue:o?.recipt_start_number??""}),e.jsxs("div",{children:[e.jsx(X,{label:"State",options:l,value:d,onChange:c}),e.jsx("input",{type:"hidden",name:"state_id",value:d?.value??""})]}),e.jsx(Y,{name:"affiliation_no",label:"Affiliation Number",defaultValue:o?.affiliation_no??""}),e.jsx(Y,{name:"affiliation_desc",label:"Affiliation Description",defaultValue:o?.affiliation_desc??""}),e.jsx(Y,{name:"udise_code",label:"UDISE Code",defaultValue:o?.udise_code??""}),e.jsx(Y,{name:"color_code",label:"Primary Color",defaultValue:o?.color_code??""}),e.jsx(Y,{name:"fontcolor_code",label:"Font Color",defaultValue:o?.fontcolor_code??""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:$s,children:[e.jsx(st,{name:"Bussiness_address",rows:3,label:"Business Address",defaultValue:o?.Bussiness_address??o?.bussiness_address??""}),e.jsx(st,{name:"note",rows:3,label:"Note",defaultValue:o?.note??""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:$s,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Fees Receipt Logo"}),e.jsx(ha,{token:t,action:gl(),value:y,previewUrl:px(y),accept:"image/*",onChange:h}),e.jsx("input",{type:"hidden",name:"fees_receipt_logo",value:y})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Manager Signature"}),e.jsx(ha,{token:t,action:Ps(),value:u,previewUrl:Us(u),accept:"image/*",onChange:p}),e.jsx("input",{type:"hidden",name:"manager_signature",value:u})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Principal Signature"}),e.jsx(ha,{token:t,action:Ps(),value:w,previewUrl:Us(w),accept:"image/*",onChange:v}),e.jsx("input",{type:"hidden",name:"principal_signature",value:w})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Stamp"}),e.jsx(ha,{token:t,action:Ps(),value:b,previewUrl:Us(b),accept:"image/*",onChange:m}),e.jsx("input",{type:"hidden",name:"stamp",value:b})]})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save"})})]})})})]})}function hx({token:t}){return e.jsx(mx,{token:t})}const Yn=ft.payrollSettings,fx=({token:t,page:a=1,perPage:s=10})=>yl({baseUrl:Yn.table,token:t,page:a,perPage:s}),yx={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Ua=[{value:"Allowances",label:"Allowances"},{value:"Dedection",label:"Dedection"}],Ns=[{value:"Flat",label:"Flat"},{value:"Percentage",label:"Percentage"}],gx=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],xx=(t,a=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??a;function bx({token:t}){const a=i.useRef(null),s=i.useRef(null),[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,y]=i.useState(null),[h,u]=i.useState(Ua[0]),[p,w]=i.useState(null),[v,b]=i.useState(null),[m,j]=i.useState(null),D=fx({token:t,page:r.page,perPage:r.rowsPerPage}),I=i.useMemo(()=>gx(D.data),[D.data]),k=i.useMemo(()=>xx(D.data,I.length),[D.data,I.length]),S=async N=>{N.preventDefault();try{const f=new FormData(N.target);f.set("type",h?.value??""),f.set("amount_type",p?.value??""),await nn(Yn.add,f,t),_.success("Payroll setting added.",{duration:1e3}),D.mutate?.(),N.target.reset(),w(null),u(Ua[0])}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to add payroll setting.",{duration:1500})}},x=N=>{y(N),b(Ua.find(f=>f.value===N?.type)??null),j(Ns.find(f=>f.value===N?.amount_type)??null),d(!0)},g=async N=>{N.preventDefault();try{const f=new FormData(N.target);f.set("id",String(c?.id??"")),f.set("type",v?.value??""),f.set("amount_type",m?.value??""),await hl(Yn.edit,f,t),_.success("Payroll setting updated.",{duration:1e3}),d(!1),D.mutate?.()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to update payroll setting.",{duration:1500})}},C=async N=>{try{await ur(Yn.remove,N,t),_.success("Payroll setting deleted.",{duration:1e3}),D.mutate?.()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to delete payroll setting.",{duration:1500})}},T=()=>{const N=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),f=URL.createObjectURL(N),P=document.createElement("a");P.href=f,P.download="payroll-settings.json",P.click(),URL.revokeObjectURL(f)},R=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(te.PlusOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:()=>D.mutate?.()},{key:"save",label:"Save",icon:e.jsx(te.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:T,disabled:I.length===0}],[I.length]),L=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title"},{title:"Type",dataIndex:"type",key:"type"},{title:"Amount Type",dataIndex:"amount_type",key:"amount_type"},{title:"Amount",dataIndex:"Amount",key:"Amount"},{title:"Action",key:"action",render:(N,f)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(n.Button,{type:"text",icon:e.jsx(te.EditOutlined,{}),onClick:()=>x(f)}),e.jsx(n.Popconfirm,{title:"Delete payroll setting?",onConfirm:()=>C(f.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(te.DeleteOutlined,{})})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Payroll Settings",actions:R,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"minmax(320px, 420px) 1fr"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Allowances / Deductions"}),children:e.jsxs("form",{ref:a,onSubmit:S,children:[e.jsxs("div",{style:yx,children:[e.jsx(Y,{name:"title",label:"Title",required:!0}),e.jsxs("div",{children:[e.jsx(X,{label:"Type",options:Ua,value:h,onChange:u}),e.jsx("input",{type:"hidden",name:"type",value:h?.value??""})]}),e.jsxs("div",{children:[e.jsx(X,{label:"Amount Type",options:Ns,value:p,onChange:w}),e.jsx("input",{type:"hidden",name:"amount_type",value:p?.value??""})]}),e.jsx(Y,{name:"Amount",type:"number",label:"Amount",required:!0})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:20},children:e.jsx(ne,{type:"submit",value:"Submit"})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Settings List"}),children:e.jsx(n.Table,{rowKey:"id",columns:L,dataSource:I,loading:D.isLoading,pagination:{current:r.page,pageSize:r.rowsPerPage,total:k,showSizeChanger:!0,onChange:(N,f)=>o({page:N,rowsPerPage:Number(f)})}})})]})}),e.jsx(n.Drawer,{open:l,onClose:()=>d(!1),title:"Edit Payroll Setting",width:420,children:e.jsx("form",{ref:s,onSubmit:g,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{name:"title",label:"Title",required:!0,defaultValue:c?.title??""}),e.jsxs("div",{children:[e.jsx(X,{label:"Type",options:Ua,value:v,onChange:b}),e.jsx("input",{type:"hidden",name:"type",value:v?.value??""})]}),e.jsxs("div",{children:[e.jsx(X,{label:"Amount Type",options:Ns,value:m,onChange:j}),e.jsx("input",{type:"hidden",name:"amount_type",value:m?.value??""})]}),e.jsx(Y,{name:"Amount",type:"number",label:"Amount",required:!0,defaultValue:c?.Amount??""}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Update"})})]})})})]})}function jx({token:t}){return e.jsx(bx,{token:t})}const bl=ft.paymentGateway,Sx=({token:t})=>yt({url:bl.get,token:t}),vx=[{id:"Razorpay",title:"Razorpay",fields:["keyId","keySecret"]},{id:"PhonePe",title:"Pine Labs",fields:["merchantId","saltKey","saltIndex"]},{id:"Paytm",title:"HDFC",fields:["merchantId","merchantKey"]},{id:"SabPaisa",title:"SabPaisa",fields:["clientCode","transUserName","transUserPassword","authKey","authIV"]}],Wt={Razorpay:{keyId:"",keySecret:"",isActive:!0},PhonePe:{merchantId:"",saltKey:"",saltIndex:"1",isActive:!1},Paytm:{merchantId:"",merchantKey:"",isActive:!1},SabPaisa:{clientCode:"",transUserName:"",transUserPassword:"",authKey:"",authIV:"",isActive:!1}},co=t=>{const a=Array.isArray(t?.data)&&t.data[0]||Array.isArray(t?.data?.data)&&t.data.data[0]||Array.isArray(t)&&t[0]||null;if(!a?.data)return Wt;try{const s=JSON.parse(a.data||"{}"),r=s?.data&&typeof s.data=="object"?s.data:s;return{Razorpay:{...Wt.Razorpay,...r?.Razorpay??{}},PhonePe:{...Wt.PhonePe,...r?.PhonePe??r?.PineLab??r?.PineLabs??{}},Paytm:{...Wt.Paytm,...r?.Paytm??r?.HDFC??{}},SabPaisa:{...Wt.SabPaisa,...r?.SabPaisa??{}}}}catch{return Wt}};function wx({token:t}){const a=i.useRef(null),s=Sx({token:t}),[r,o]=i.useState(Wt);i.useEffect(()=>{s.data&&o(co(s.data))},[s.data]);const l=(u,p,w)=>{o(v=>({...v,[u]:{...v[u],[p]:w}}))},d=()=>o(co(s.data)),c=()=>{const u=new Blob([JSON.stringify(r,null,2)],{type:"application/json"}),p=URL.createObjectURL(u),w=document.createElement("a");w.href=p,w.download="payment-gateway-settings.json",w.click(),URL.revokeObjectURL(p)},y=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(te.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(te.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(te.ReloadOutlined,{}),onClick:d},{key:"export",label:"Export",icon:e.jsx(te.ExportOutlined,{}),onClick:c}],[r,s.data]),h=async u=>{u.preventDefault();try{await fl(bl.save,{data:r},t),_.success("Payment gateway settings saved.",{duration:1e3}),s.mutate?.()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to save gateway settings.",{duration:1500})}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Payment Gateway",actions:y,children:e.jsxs("form",{ref:a,onSubmit:h,style:{display:"grid",gap:20},children:[vx.map(u=>{const p=r[u.id]??{};return e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:u.title}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontSize:14,fontWeight:500},children:["Enable ",u.title]}),e.jsx(n.Switch,{checked:!!p.isActive,onChange:w=>l(u.id,"isActive",w)})]}),e.jsx(n.Divider,{style:{margin:0}}),e.jsx("div",{style:{display:"grid",gap:16,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:u.fields.map(w=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:w}),e.jsx(n.Input,{value:p[w]??"",type:w.toLowerCase().includes("secret")||w.toLowerCase().includes("password")?"password":"text",onChange:v=>l(u.id,w,v.target.value)})]},w))})]})},u.id)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save"})})]})})]})}function _x({token:t}){return e.jsx(wx,{token:t})}const Cx=({routes:t=[],onNavigate:a})=>e.jsx(n.Row,{gutter:[16,16],children:t.map((s,r)=>e.jsx(n.Col,{xs:24,md:8,lg:8,children:e.jsx(A,{children:e.jsx(mo,{icon:s?.icon??"",title:s?.title??"",path:s?.path??"",onClick:a})})},`${r}route001`))});exports.About=ox;exports.AcademicYear=zg;exports.Academics=ey;exports.AddBook=$p;exports.AddDriver=Ip;exports.AddExpense=Vf;exports.AddHomework=Mp;exports.AddIncome=Nf;exports.AddStaff=ah;exports.AdmissionEnquiry=hu;exports.ApplyLeave=Lh;exports.AprroveLeaveRequest=Oh;exports.AssignByClass=Dy;exports.AssignStudentSubject=Xf;exports.AssignStudentToTransport=Rp;exports.AssignSubjects=_y;exports.AssignTimeGroup=Ey;exports.AssignVehicles=jp;exports.AttendanceDashboard=wf;exports.BookList=Up;exports.BuySellProduct=Sm;exports.Category=cm;exports.Class=py;exports.CoScholasticArea=zy;exports.Complain=pp;exports.CreateTimeGroup=Iy;exports.DailyAttendance=Tf;exports.Department=Wh;exports.Designation=Gh;exports.ErpDashboard=wl;exports.ExpenseHead=Kf;exports.FeeReceiptSetting=Hg;exports.FeesInfo=hx;exports.GatePass=yp;exports.GeneralSetting=fg;exports.Holidays=jy;exports.IncomeHead=qf;exports.IssueReturn=Lp;exports.LeaveType=zh;exports.LibraryAssignStudent=Bp;exports.LibraryCategory=qp;exports.LibraryRenewalReport=Yp;exports.LibraryReport=zp;exports.ManageStock=Mm;exports.MarksheetSetting=tx;exports.MedicalReport=Jf;exports.MenuSubmenu=Jc;exports.MonthlyReport=kf;exports.Notes=Ky;exports.NpmReport=Lm;exports.Organization=$g;exports.PaymentGateway=_x;exports.Payroll=Th;exports.PayrollReceiptDetails=of;exports.PayrollSettings=jx;exports.PhoneCallLog=Yu;exports.PostalDispatch=Ju;exports.PostalReceive=ap;exports.Privacy=rx;exports.Products=im;exports.PromoteStudents=Ny;exports.RoutePage=Cx;exports.RouteTimeTable=kp;exports.SearchExpense=Wf;exports.SearchIncome=Lf;exports.Sections=oy;exports.SellReports=km;exports.SetupFrontOffice=mp;exports.Shift=Xh;exports.StaffAttendance=bh;exports.StaffAttendanceReport=wh;exports.StaffDailyAttendance=nf;exports.StaffDirectory=oh;exports.StockReport=Nm;exports.Stoppage=Op;exports.StudentAttendance=Cf;exports.StudentLoginCredential=Gf;exports.SubCategory=ym;exports.Subjects=yy;exports.SubmissionDetails=Ep;exports.Syllabus=ng;exports.Terms=nx;exports.TimeTable=hg;exports.TransferCertificate=Zy;exports.TransportRoutes=gp;exports.TransportVehicles=xp;exports.Unit=Cm;exports.Vendor=Xp;exports.VisitorBook=Eu;exports.YearlyReport=Ef;exports.setBaseUrl=ic;