ubk.erp.webpack 1.2.7 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/dist/Api/api.d.ts +53 -0
- package/dist/Layout/FontOffice/Complain.d.ts +5 -0
- package/dist/Layout/FontOffice/ComplainEdit.d.ts +5 -0
- package/dist/Layout/FontOffice/GatePass.d.ts +5 -0
- package/dist/Layout/FontOffice/PhoneCallLog.d.ts +5 -0
- package/dist/Layout/FontOffice/PhoneCallLogEdit.d.ts +5 -0
- package/dist/Layout/FontOffice/PostalDispatch.d.ts +5 -0
- package/dist/Layout/FontOffice/PostalDispatchEdit.d.ts +5 -0
- package/dist/Layout/FontOffice/PostalReceive.d.ts +5 -0
- package/dist/Layout/FontOffice/PostalReceiveEdit.d.ts +5 -0
- package/dist/Layout/FontOffice/SetupFrontOffice.d.ts +5 -0
- package/dist/Layout/FontOffice/VisitorBook.d.ts +5 -0
- package/dist/Layout/FontOffice/VisitorEdit.d.ts +5 -0
- package/dist/Layout/Transport/AssignStudentToTransport.d.ts +2 -1
- package/dist/Layout/Transport/TransportRoutes.d.ts +2 -1
- package/dist/index.cjs +12 -12
- package/dist/index.d.ts +7 -0
- package/dist/index.js +11217 -9151
- 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"),s=require("antd"),G=require("swr"),_=require("react-hot-toast"),i=require("react"),Je=require("swr/mutation"),X=require("@ant-design/icons"),ae=require("dayjs"),Mo=require("react-dom/server"),on=require("react-to-print"),Pi=require("react-select"),Ei=require("react-barcode"),Fo=()=>e.jsxs(s.Card,{style:{borderRadius:16},children:[e.jsx(s.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),e.jsx(s.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),le=({width:t,height:n,display:a,justifyContent:r,alignItems:o,flexDirection:l,gap:d,style:c,children:b,...y})=>{const u={width:t,height:n,display:a,justifyContent:r,alignItems:o,flexDirection:l,gap:d,...c};return e.jsx("div",{style:u,...y,children:b})},Me=({variant:t,fontWeight:n,style:a,children:r,...o})=>{const l=n==="bold"?700:n==="light"?300:n;return t==="h1"?e.jsx(s.Typography.Title,{level:1,style:{fontWeight:l,...a},...o,children:r}):t==="h2"?e.jsx(s.Typography.Title,{level:2,style:{fontWeight:l,...a},...o,children:r}):t==="h3"?e.jsx(s.Typography.Title,{level:3,style:{fontWeight:l,...a},...o,children:r}):t==="h4"?e.jsx(s.Typography.Title,{level:4,style:{fontWeight:l,...a},...o,children:r}):t==="h5"?e.jsx(s.Typography.Title,{level:5,style:{fontWeight:l,...a},...o,children:r}):e.jsx(s.Typography.Text,{style:{fontWeight:l,...a},...o,children:r})};function Mi({title:t="",icon:n="",path:a="",onClick:r}){const o=()=>{if(r){r(a);return}typeof window<"u"&&typeof a=="string"&&a.length>0&&window.location.assign(a)};return e.jsxs(s.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(le,{width:"100%",display:"flex",justifyContent:"center",alignItems:"center",style:{padding:"10px 12px",minHeight:80},children:e.jsx("img",{src:n,alt:"",style:{width:45,height:50,objectFit:"contain"}})}),e.jsx(le,{style:{padding:"0 12px"},children:e.jsx(s.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(le,{style:{padding:"10px 10px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:35},children:e.jsx(Me,{variant:"button",fontWeight:"bold",style:{fontSize:12},children:t})})]})}function Fi(t,n){return function(){return t.apply(n,arguments)}}const{toString:No}=Object.prototype,{getPrototypeOf:Aa}=Object,{iterator:Ta,toStringTag:Ni}=Symbol,Ra=(t=>n=>{const a=No.call(n);return t[a]||(t[a]=a.slice(8,-1).toLowerCase())})(Object.create(null)),yt=t=>(t=t.toLowerCase(),n=>Ra(n)===t),Ia=t=>n=>typeof n===t,{isArray:ln}=Array,an=Ia("undefined");function Pn(t){return t!==null&&!an(t)&&t.constructor!==null&&!an(t.constructor)&&et(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const $i=yt("ArrayBuffer");function $o(t){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(t):n=t&&t.buffer&&$i(t.buffer),n}const Uo=Ia("string"),et=Ia("function"),Ui=Ia("number"),En=t=>t!==null&&typeof t=="object",Bo=t=>t===!0||t===!1,la=t=>{if(Ra(t)!=="object")return!1;const n=Aa(t);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Ni in t)&&!(Ta in t)},Lo=t=>{if(!En(t)||Pn(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},qo=yt("Date"),zo=yt("File"),Yo=t=>!!(t&&typeof t.uri<"u"),Wo=t=>t&&typeof t.getParts<"u",Vo=yt("Blob"),Ho=yt("FileList"),Ko=t=>En(t)&&et(t.pipe);function Go(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Vs=Go(),Hs=typeof Vs.FormData<"u"?Vs.FormData:void 0,Jo=t=>{if(!t)return!1;if(Hs&&t instanceof Hs)return!0;const n=Aa(t);if(!n||n===Object.prototype||!et(t.append))return!1;const a=Ra(t);return a==="formdata"||a==="object"&&et(t.toString)&&t.toString()==="[object FormData]"},Qo=yt("URLSearchParams"),[Xo,Zo,el,tl]=["ReadableStream","Request","Response","Headers"].map(yt),nl=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Mn(t,n,{allOwnKeys:a=!1}={}){if(t===null||typeof t>"u")return;let r,o;if(typeof t!="object"&&(t=[t]),ln(t))for(r=0,o=t.length;r<o;r++)n.call(null,t[r],r,t);else{if(Pn(t))return;const l=a?Object.getOwnPropertyNames(t):Object.keys(t),d=l.length;let c;for(r=0;r<d;r++)c=l[r],n.call(null,t[c],c,t)}}function Bi(t,n){if(Pn(t))return null;n=n.toLowerCase();const a=Object.keys(t);let r=a.length,o;for(;r-- >0;)if(o=a[r],n===o.toLowerCase())return o;return null}const Ut=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Li=t=>!an(t)&&t!==Ut;function js(){const{caseless:t,skipUndefined:n}=Li(this)&&this||{},a={},r=(o,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const d=t&&Bi(a,l)||l;la(a[d])&&la(o)?a[d]=js(a[d],o):la(o)?a[d]=js({},o):ln(o)?a[d]=o.slice():(!n||!an(o))&&(a[d]=o)};for(let o=0,l=arguments.length;o<l;o++)arguments[o]&&Mn(arguments[o],r);return a}const al=(t,n,a,{allOwnKeys:r}={})=>(Mn(n,(o,l)=>{a&&et(o)?Object.defineProperty(t,l,{value:Fi(o,a),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,l,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),sl=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),rl=(t,n,a,r)=>{t.prototype=Object.create(n.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:n.prototype}),a&&Object.assign(t.prototype,a)},il=(t,n,a,r)=>{let o,l,d;const c={};if(n=n||{},t==null)return n;do{for(o=Object.getOwnPropertyNames(t),l=o.length;l-- >0;)d=o[l],(!r||r(d,t,n))&&!c[d]&&(n[d]=t[d],c[d]=!0);t=a!==!1&&Aa(t)}while(t&&(!a||a(t,n))&&t!==Object.prototype);return n},ol=(t,n,a)=>{t=String(t),(a===void 0||a>t.length)&&(a=t.length),a-=n.length;const r=t.indexOf(n,a);return r!==-1&&r===a},ll=t=>{if(!t)return null;if(ln(t))return t;let n=t.length;if(!Ui(n))return null;const a=new Array(n);for(;n-- >0;)a[n]=t[n];return a},dl=(t=>n=>t&&n instanceof t)(typeof Uint8Array<"u"&&Aa(Uint8Array)),cl=(t,n)=>{const r=(t&&t[Ta]).call(t);let o;for(;(o=r.next())&&!o.done;){const l=o.value;n.call(t,l[0],l[1])}},ul=(t,n)=>{let a;const r=[];for(;(a=t.exec(n))!==null;)r.push(a);return r},pl=yt("HTMLFormElement"),ml=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(a,r,o){return r.toUpperCase()+o}),Ks=(({hasOwnProperty:t})=>(n,a)=>t.call(n,a))(Object.prototype),yl=yt("RegExp"),qi=(t,n)=>{const a=Object.getOwnPropertyDescriptors(t),r={};Mn(a,(o,l)=>{let d;(d=n(o,l,t))!==!1&&(r[l]=d||o)}),Object.defineProperties(t,r)},fl=t=>{qi(t,(n,a)=>{if(et(t)&&["arguments","caller","callee"].indexOf(a)!==-1)return!1;const r=t[a];if(et(r)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+a+"'")})}})},hl=(t,n)=>{const a={},r=o=>{o.forEach(l=>{a[l]=!0})};return ln(t)?r(t):r(String(t).split(n)),a},gl=()=>{},xl=(t,n)=>t!=null&&Number.isFinite(t=+t)?t:n;function bl(t){return!!(t&&et(t.append)&&t[Ni]==="FormData"&&t[Ta])}const Sl=t=>{const n=new Array(10),a=(r,o)=>{if(En(r)){if(n.indexOf(r)>=0)return;if(Pn(r))return r;if(!("toJSON"in r)){n[o]=r;const l=ln(r)?[]:{};return Mn(r,(d,c)=>{const b=a(d,o+1);!an(b)&&(l[c]=b)}),n[o]=void 0,l}}return r};return a(t,0)},jl=yt("AsyncFunction"),vl=t=>t&&(En(t)||et(t))&&et(t.then)&&et(t.catch),zi=((t,n)=>t?setImmediate:n?((a,r)=>(Ut.addEventListener("message",({source:o,data:l})=>{o===Ut&&l===a&&r.length&&r.shift()()},!1),o=>{r.push(o),Ut.postMessage(a,"*")}))(`axios@${Math.random()}`,[]):a=>setTimeout(a))(typeof setImmediate=="function",et(Ut.postMessage)),_l=typeof queueMicrotask<"u"?queueMicrotask.bind(Ut):typeof process<"u"&&process.nextTick||zi,wl=t=>t!=null&&et(t[Ta]),K={isArray:ln,isArrayBuffer:$i,isBuffer:Pn,isFormData:Jo,isArrayBufferView:$o,isString:Uo,isNumber:Ui,isBoolean:Bo,isObject:En,isPlainObject:la,isEmptyObject:Lo,isReadableStream:Xo,isRequest:Zo,isResponse:el,isHeaders:tl,isUndefined:an,isDate:qo,isFile:zo,isReactNativeBlob:Yo,isReactNative:Wo,isBlob:Vo,isRegExp:yl,isFunction:et,isStream:Ko,isURLSearchParams:Qo,isTypedArray:dl,isFileList:Ho,forEach:Mn,merge:js,extend:al,trim:nl,stripBOM:sl,inherits:rl,toFlatObject:il,kindOf:Ra,kindOfTest:yt,endsWith:ol,toArray:ll,forEachEntry:cl,matchAll:ul,isHTMLForm:pl,hasOwnProperty:Ks,hasOwnProp:Ks,reduceDescriptors:qi,freezeMethods:fl,toObjectSet:hl,toCamelCase:ml,noop:gl,toFiniteNumber:xl,findKey:Bi,global:Ut,isContextDefined:Li,isSpecCompliantForm:bl,toJSONObject:Sl,isAsyncFn:jl,isThenable:vl,setImmediate:zi,asap:_l,isIterable:wl};let _e=class Yi extends Error{static from(n,a,r,o,l,d){const c=new Yi(n.message,a||n.code,r,o,l);return c.cause=n,c.name=n.name,n.status!=null&&c.status==null&&(c.status=n.status),d&&Object.assign(c,d),c}constructor(n,a,r,o,l){super(n),Object.defineProperty(this,"message",{value:n,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,a&&(this.code=a),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:K.toJSONObject(this.config),code:this.code,status:this.status}}};_e.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";_e.ERR_BAD_OPTION="ERR_BAD_OPTION";_e.ECONNABORTED="ECONNABORTED";_e.ETIMEDOUT="ETIMEDOUT";_e.ERR_NETWORK="ERR_NETWORK";_e.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";_e.ERR_DEPRECATED="ERR_DEPRECATED";_e.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";_e.ERR_BAD_REQUEST="ERR_BAD_REQUEST";_e.ERR_CANCELED="ERR_CANCELED";_e.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";_e.ERR_INVALID_URL="ERR_INVALID_URL";_e.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const Cl=null;function vs(t){return K.isPlainObject(t)||K.isArray(t)}function Wi(t){return K.endsWith(t,"[]")?t.slice(0,-2):t}function Va(t,n,a){return t?t.concat(n).map(function(o,l){return o=Wi(o),!a&&l?"["+o+"]":o}).join(a?".":""):n}function Al(t){return K.isArray(t)&&!t.some(vs)}const Tl=K.toFlatObject(K,{},null,function(n){return/^is[A-Z]/.test(n)});function Da(t,n,a){if(!K.isObject(t))throw new TypeError("target must be an object");n=n||new FormData,a=K.toFlatObject(a,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,I){return!K.isUndefined(I[g])});const r=a.metaTokens,o=a.visitor||x,l=a.dots,d=a.indexes,c=a.Blob||typeof Blob<"u"&&Blob,b=a.maxDepth===void 0?100:a.maxDepth,y=c&&K.isSpecCompliantForm(n);if(!K.isFunction(o))throw new TypeError("visitor must be a function");function u(h){if(h===null)return"";if(K.isDate(h))return h.toISOString();if(K.isBoolean(h))return h.toString();if(!y&&K.isBlob(h))throw new _e("Blob is not supported. Use a Buffer instead.");return K.isArrayBuffer(h)||K.isTypedArray(h)?y&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function x(h,g,I){let R=h;if(K.isReactNative(n)&&K.isReactNativeBlob(h))return n.append(Va(I,g,l),u(h)),!1;if(h&&!I&&typeof h=="object"){if(K.endsWith(g,"{}"))g=r?g:g.slice(0,-2),h=JSON.stringify(h);else if(K.isArray(h)&&Al(h)||(K.isFileList(h)||K.endsWith(g,"[]"))&&(R=K.toArray(h)))return g=Wi(g),R.forEach(function(w,f){!(K.isUndefined(w)||w===null)&&n.append(d===!0?Va([g],f,l):d===null?g:g+"[]",u(w))}),!1}return vs(h)?!0:(n.append(Va(I,g,l),u(h)),!1)}const j=[],C=Object.assign(Tl,{defaultVisitor:x,convertValue:u,isVisitable:vs});function m(h,g,I=0){if(!K.isUndefined(h)){if(I>b)throw new _e("Object is too deeply nested ("+I+" levels). Max depth: "+b,_e.ERR_FORM_DATA_DEPTH_EXCEEDED);if(j.indexOf(h)!==-1)throw Error("Circular reference detected in "+g.join("."));j.push(h),K.forEach(h,function(D,w){(!(K.isUndefined(D)||D===null)&&o.call(n,D,K.isString(w)?w.trim():w,g,C))===!0&&m(D,g?g.concat(w):[w],I+1)}),j.pop()}}if(!K.isObject(t))throw new TypeError("data must be an object");return m(t),n}function Gs(t){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(r){return n[r]})}function Ts(t,n){this._pairs=[],t&&Da(t,this,n)}const Vi=Ts.prototype;Vi.append=function(n,a){this._pairs.push([n,a])};Vi.toString=function(n){const a=n?function(r){return n.call(this,r,Gs)}:Gs;return this._pairs.map(function(o){return a(o[0])+"="+a(o[1])},"").join("&")};function Rl(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Hi(t,n,a){if(!n)return t;const r=a&&a.encode||Rl,o=K.isFunction(a)?{serialize:a}:a,l=o&&o.serialize;let d;if(l?d=l(n,o):d=K.isURLSearchParams(n)?n.toString():new Ts(n,o).toString(r),d){const c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class Js{constructor(){this.handlers=[]}use(n,a,r){return this.handlers.push({fulfilled:n,rejected:a,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){K.forEach(this.handlers,function(r){r!==null&&n(r)})}}const Rs={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Il=typeof URLSearchParams<"u"?URLSearchParams:Ts,Dl=typeof FormData<"u"?FormData:null,kl=typeof Blob<"u"?Blob:null,Ol={isBrowser:!0,classes:{URLSearchParams:Il,FormData:Dl,Blob:kl},protocols:["http","https","file","blob","url","data"]},Is=typeof window<"u"&&typeof document<"u",_s=typeof navigator=="object"&&navigator||void 0,Pl=Is&&(!_s||["ReactNative","NativeScript","NS"].indexOf(_s.product)<0),El=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ml=Is&&window.location.href||"http://localhost",Fl=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Is,hasStandardBrowserEnv:Pl,hasStandardBrowserWebWorkerEnv:El,navigator:_s,origin:Ml},Symbol.toStringTag,{value:"Module"})),He={...Fl,...Ol};function Nl(t,n){return Da(t,new He.classes.URLSearchParams,{visitor:function(a,r,o,l){return He.isNode&&K.isBuffer(a)?(this.append(r,a.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...n})}function $l(t){return K.matchAll(/\w+|\[(\w*)]/g,t).map(n=>n[0]==="[]"?"":n[1]||n[0])}function Ul(t){const n={},a=Object.keys(t);let r;const o=a.length;let l;for(r=0;r<o;r++)l=a[r],n[l]=t[l];return n}function Ki(t){function n(a,r,o,l){let d=a[l++];if(d==="__proto__")return!0;const c=Number.isFinite(+d),b=l>=a.length;return d=!d&&K.isArray(o)?o.length:d,b?(K.hasOwnProp(o,d)?o[d]=K.isArray(o[d])?o[d].concat(r):[o[d],r]:o[d]=r,!c):((!o[d]||!K.isObject(o[d]))&&(o[d]=[]),n(a,r,o[d],l)&&K.isArray(o[d])&&(o[d]=Ul(o[d])),!c)}if(K.isFormData(t)&&K.isFunction(t.entries)){const a={};return K.forEachEntry(t,(r,o)=>{n($l(r),o,a,0)}),a}return null}const Kt=(t,n)=>t!=null&&K.hasOwnProp(t,n)?t[n]:void 0;function Bl(t,n,a){if(K.isString(t))try{return(n||JSON.parse)(t),K.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(a||JSON.stringify)(t)}const Fn={transitional:Rs,adapter:["xhr","http","fetch"],transformRequest:[function(n,a){const r=a.getContentType()||"",o=r.indexOf("application/json")>-1,l=K.isObject(n);if(l&&K.isHTMLForm(n)&&(n=new FormData(n)),K.isFormData(n))return o?JSON.stringify(Ki(n)):n;if(K.isArrayBuffer(n)||K.isBuffer(n)||K.isStream(n)||K.isFile(n)||K.isBlob(n)||K.isReadableStream(n))return n;if(K.isArrayBufferView(n))return n.buffer;if(K.isURLSearchParams(n))return a.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let c;if(l){const b=Kt(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return Nl(n,b).toString();if((c=K.isFileList(n))||r.indexOf("multipart/form-data")>-1){const y=Kt(this,"env"),u=y&&y.FormData;return Da(c?{"files[]":n}:n,u&&new u,b)}}return l||o?(a.setContentType("application/json",!1),Bl(n)):n}],transformResponse:[function(n){const a=Kt(this,"transitional")||Fn.transitional,r=a&&a.forcedJSONParsing,o=Kt(this,"responseType"),l=o==="json";if(K.isResponse(n)||K.isReadableStream(n))return n;if(n&&K.isString(n)&&(r&&!o||l)){const c=!(a&&a.silentJSONParsing)&&l;try{return JSON.parse(n,Kt(this,"parseReviver"))}catch(b){if(c)throw b.name==="SyntaxError"?_e.from(b,_e.ERR_BAD_RESPONSE,this,null,Kt(this,"response")):b}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:He.classes.FormData,Blob:He.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};K.forEach(["delete","get","head","post","put","patch"],t=>{Fn.headers[t]={}});const Ll=K.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"]),ql=t=>{const n={};let a,r,o;return t&&t.split(`
|
|
2
|
-
`).forEach(function(d){o=d.indexOf(":"),
|
|
3
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...a){const r=new this(n);return a.forEach(o=>r.set(o)),r}static accessor(n){const r=(this[Qs]=this[Qs]={accessors:{}}).accessors,o=this.prototype;function l(d){const c=pn(d);r[c]||(Gl(o,d),r[c]=!0)}return K.isArray(n)?n.forEach(l):l(n),this}};tt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);K.reduceDescriptors(tt.prototype,({value:t},n)=>{let a=n[0].toUpperCase()+n.slice(1);return{get:()=>t,set(r){this[a]=r}}});K.freezeMethods(tt);function Ka(t,n){const a=this||Fn,r=n||a,o=tt.from(r.headers);let l=r.data;return K.forEach(t,function(c){l=c.call(a,l,o.normalize(),n?n.status:void 0)}),o.normalize(),l}function Gi(t){return!!(t&&t.__CANCEL__)}let Nn=class extends _e{constructor(n,a,r){super(n??"canceled",_e.ERR_CANCELED,a,r),this.name="CanceledError",this.__CANCEL__=!0}};function Ji(t,n,a){const r=a.config.validateStatus;!a.status||!r||r(a.status)?t(a):n(new _e("Request failed with status code "+a.status,[_e.ERR_BAD_REQUEST,_e.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a))}function Jl(t){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return n&&n[1]||""}function Ql(t,n){t=t||10;const a=new Array(t),r=new Array(t);let o=0,l=0,d;return n=n!==void 0?n:1e3,function(b){const y=Date.now(),u=r[l];d||(d=y),a[o]=b,r[o]=y;let x=l,j=0;for(;x!==o;)j+=a[x++],x=x%t;if(o=(o+1)%t,o===l&&(l=(l+1)%t),y-d<n)return;const C=u&&y-u;return C?Math.round(j*1e3/C):void 0}}function Xl(t,n){let a=0,r=1e3/n,o,l;const d=(y,u=Date.now())=>{a=u,o=null,l&&(clearTimeout(l),l=null),t(...y)};return[(...y)=>{const u=Date.now(),x=u-a;x>=r?d(y,u):(o=y,l||(l=setTimeout(()=>{l=null,d(o)},r-x)))},()=>o&&d(o)]}const Ca=(t,n,a=3)=>{let r=0;const o=Ql(50,250);return Xl(l=>{const d=l.loaded,c=l.lengthComputable?l.total:void 0,b=c!=null?Math.min(d,c):d,y=Math.max(0,b-r),u=o(y);r=Math.max(r,b);const x={loaded:b,total:c,progress:c?b/c:void 0,bytes:y,rate:u||void 0,estimated:u&&c?(c-b)/u:void 0,event:l,lengthComputable:c!=null,[n?"download":"upload"]:!0};t(x)},a)},Xs=(t,n)=>{const a=t!=null;return[r=>n[0]({lengthComputable:a,total:t,loaded:r}),n[1]]},Zs=t=>(...n)=>K.asap(()=>t(...n)),Zl=He.hasStandardBrowserEnv?((t,n)=>a=>(a=new URL(a,He.origin),t.protocol===a.protocol&&t.host===a.host&&(n||t.port===a.port)))(new URL(He.origin),He.navigator&&/(msie|trident)/i.test(He.navigator.userAgent)):()=>!0,ed=He.hasStandardBrowserEnv?{write(t,n,a,r,o,l,d){if(typeof document>"u")return;const c=[`${t}=${encodeURIComponent(n)}`];K.isNumber(a)&&c.push(`expires=${new Date(a).toUTCString()}`),K.isString(r)&&c.push(`path=${r}`),K.isString(o)&&c.push(`domain=${o}`),l===!0&&c.push("secure"),K.isString(d)&&c.push(`SameSite=${d}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;const n=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return n?decodeURIComponent(n[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function td(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function nd(t,n){return n?t.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):t}function Qi(t,n,a){let r=!td(n);return t&&(r||a===!1)?nd(t,n):n}const er=t=>t instanceof tt?{...t}:t;function zt(t,n){n=n||{};const a=Object.create(null);Object.defineProperty(a,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(y,u,x,j){return K.isPlainObject(y)&&K.isPlainObject(u)?K.merge.call({caseless:j},y,u):K.isPlainObject(u)?K.merge({},u):K.isArray(u)?u.slice():u}function o(y,u,x,j){if(K.isUndefined(u)){if(!K.isUndefined(y))return r(void 0,y,x,j)}else return r(y,u,x,j)}function l(y,u){if(!K.isUndefined(u))return r(void 0,u)}function d(y,u){if(K.isUndefined(u)){if(!K.isUndefined(y))return r(void 0,y)}else return r(void 0,u)}function c(y,u,x){if(K.hasOwnProp(n,x))return r(y,u);if(K.hasOwnProp(t,x))return r(void 0,y)}const b={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:(y,u,x)=>o(er(y),er(u),x,!0)};return K.forEach(Object.keys({...t,...n}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const x=K.hasOwnProp(b,u)?b[u]:o,j=K.hasOwnProp(t,u)?t[u]:void 0,C=K.hasOwnProp(n,u)?n[u]:void 0,m=x(j,C,u);K.isUndefined(m)&&x!==c||(a[u]=m)}),a}const Xi=t=>{const n=zt({},t),a=j=>K.hasOwnProp(n,j)?n[j]:void 0,r=a("data");let o=a("withXSRFToken");const l=a("xsrfHeaderName"),d=a("xsrfCookieName");let c=a("headers");const b=a("auth"),y=a("baseURL"),u=a("allowAbsoluteUrls"),x=a("url");if(n.headers=c=tt.from(c),n.url=Hi(Qi(y,x,u),t.params,t.paramsSerializer),b&&c.set("Authorization","Basic "+btoa((b.username||"")+":"+(b.password?unescape(encodeURIComponent(b.password)):""))),K.isFormData(r)){if(He.hasStandardBrowserEnv||He.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(K.isFunction(r.getHeaders)){const j=r.getHeaders(),C=["content-type","content-length"];Object.entries(j).forEach(([m,h])=>{C.includes(m.toLowerCase())&&c.set(m,h)})}}if(He.hasStandardBrowserEnv&&(K.isFunction(o)&&(o=o(n)),o===!0||o==null&&Zl(n.url))){const C=l&&d&&ed.read(d);C&&c.set(l,C)}return n},ad=typeof XMLHttpRequest<"u",sd=ad&&function(t){return new Promise(function(a,r){const o=Xi(t);let l=o.data;const d=tt.from(o.headers).normalize();let{responseType:c,onUploadProgress:b,onDownloadProgress:y}=o,u,x,j,C,m;function h(){C&&C(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function I(){if(!g)return;const D=tt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),f={data:!c||c==="text"||c==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:D,config:t,request:g};Ji(function(S){a(S),h()},function(S){r(S),h()},f),g=null}"onloadend"in g?g.onloadend=I:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(I)},g.onabort=function(){g&&(r(new _e("Request aborted",_e.ECONNABORTED,t,g)),g=null)},g.onerror=function(w){const f=w&&w.message?w.message:"Network Error",p=new _e(f,_e.ERR_NETWORK,t,g);p.event=w||null,r(p),g=null},g.ontimeout=function(){let w=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const f=o.transitional||Rs;o.timeoutErrorMessage&&(w=o.timeoutErrorMessage),r(new _e(w,f.clarifyTimeoutError?_e.ETIMEDOUT:_e.ECONNABORTED,t,g)),g=null},l===void 0&&d.setContentType(null),"setRequestHeader"in g&&K.forEach(d.toJSON(),function(w,f){g.setRequestHeader(f,w)}),K.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),c&&c!=="json"&&(g.responseType=o.responseType),y&&([j,m]=Ca(y,!0),g.addEventListener("progress",j)),b&&g.upload&&([x,C]=Ca(b),g.upload.addEventListener("progress",x),g.upload.addEventListener("loadend",C)),(o.cancelToken||o.signal)&&(u=D=>{g&&(r(!D||D.type?new Nn(null,t,g):D),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const R=Jl(o.url);if(R&&He.protocols.indexOf(R)===-1){r(new _e("Unsupported protocol "+R+":",_e.ERR_BAD_REQUEST,t));return}g.send(l||null)})},rd=(t,n)=>{const{length:a}=t=t?t.filter(Boolean):[];if(n||a){let r=new AbortController,o;const l=function(y){if(!o){o=!0,c();const u=y instanceof Error?y:this.reason;r.abort(u instanceof _e?u:new Nn(u instanceof Error?u.message:u))}};let d=n&&setTimeout(()=>{d=null,l(new _e(`timeout of ${n}ms exceeded`,_e.ETIMEDOUT))},n);const c=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(y=>{y.unsubscribe?y.unsubscribe(l):y.removeEventListener("abort",l)}),t=null)};t.forEach(y=>y.addEventListener("abort",l));const{signal:b}=r;return b.unsubscribe=()=>K.asap(c),b}},id=function*(t,n){let a=t.byteLength;if(a<n){yield t;return}let r=0,o;for(;r<a;)o=r+n,yield t.slice(r,o),r=o},od=async function*(t,n){for await(const a of ld(t))yield*id(a,n)},ld=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const n=t.getReader();try{for(;;){const{done:a,value:r}=await n.read();if(a)break;yield r}}finally{await n.cancel()}},tr=(t,n,a,r)=>{const o=od(t,n);let l=0,d,c=b=>{d||(d=!0,r&&r(b))};return new ReadableStream({async pull(b){try{const{done:y,value:u}=await o.next();if(y){c(),b.close();return}let x=u.byteLength;if(a){let j=l+=x;a(j)}b.enqueue(new Uint8Array(u))}catch(y){throw c(y),y}},cancel(b){return c(b),o.return()}},{highWaterMark:2})},nr=64*1024,{isFunction:Yn}=K,dd=(({Request:t,Response:n})=>({Request:t,Response:n}))(K.global),{ReadableStream:ar,TextEncoder:sr}=K.global,rr=(t,...n)=>{try{return!!t(...n)}catch{return!1}},cd=t=>{t=K.merge.call({skipUndefined:!0},dd,t);const{fetch:n,Request:a,Response:r}=t,o=n?Yn(n):typeof fetch=="function",l=Yn(a),d=Yn(r);if(!o)return!1;const c=o&&Yn(ar),b=o&&(typeof sr=="function"?(m=>h=>m.encode(h))(new sr):async m=>new Uint8Array(await new a(m).arrayBuffer())),y=l&&c&&rr(()=>{let m=!1;const h=new a(He.origin,{body:new ar,method:"POST",get duplex(){return m=!0,"half"}}),g=h.headers.has("Content-Type");return h.body!=null&&h.body.cancel(),m&&!g}),u=d&&c&&rr(()=>K.isReadableStream(new r("").body)),x={stream:u&&(m=>m.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!x[m]&&(x[m]=(h,g)=>{let I=h&&h[m];if(I)return I.call(h);throw new _e(`Response type '${m}' is not supported`,_e.ERR_NOT_SUPPORT,g)})});const j=async m=>{if(m==null)return 0;if(K.isBlob(m))return m.size;if(K.isSpecCompliantForm(m))return(await new a(He.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(K.isArrayBufferView(m)||K.isArrayBuffer(m))return m.byteLength;if(K.isURLSearchParams(m)&&(m=m+""),K.isString(m))return(await b(m)).byteLength},C=async(m,h)=>{const g=K.toFiniteNumber(m.getContentLength());return g??j(h)};return async m=>{let{url:h,method:g,data:I,signal:R,cancelToken:D,timeout:w,onDownloadProgress:f,onUploadProgress:p,responseType:S,headers:A,withCredentials:O="same-origin",fetchOptions:q}=Xi(m),U=n||fetch;S=S?(S+"").toLowerCase():"text";let v=rd([R,D&&D.toAbortSignal()],w),M=null;const P=v&&v.unsubscribe&&(()=>{v.unsubscribe()});let N;try{if(p&&y&&g!=="get"&&g!=="head"&&(N=await C(A,I))!==0){let T=new a(h,{method:"POST",body:I,duplex:"half"}),$;if(K.isFormData(I)&&($=T.headers.get("content-type"))&&A.setContentType($),T.body){const[B,Y]=Xs(N,Ca(Zs(p)));I=tr(T.body,nr,B,Y)}}K.isString(O)||(O=O?"include":"omit");const E=l&&"credentials"in a.prototype;if(K.isFormData(I)){const T=A.getContentType();T&&/^multipart\/form-data/i.test(T)&&!/boundary=/i.test(T)&&A.delete("content-type")}const F={...q,signal:v,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:I,duplex:"half",credentials:E?O:void 0};M=l&&new a(h,F);let L=await(l?U(M,q):U(h,F));const z=u&&(S==="stream"||S==="response");if(u&&(f||z&&P)){const T={};["status","statusText","headers"].forEach(ne=>{T[ne]=L[ne]});const $=K.toFiniteNumber(L.headers.get("content-length")),[B,Y]=f&&Xs($,Ca(Zs(f),!0))||[];L=new r(tr(L.body,nr,B,()=>{Y&&Y(),P&&P()}),T)}S=S||"text";let k=await x[K.findKey(x,S)||"text"](L,m);return!z&&P&&P(),await new Promise((T,$)=>{Ji(T,$,{data:k,headers:tt.from(L.headers),status:L.status,statusText:L.statusText,config:m,request:M})})}catch(E){throw P&&P(),E&&E.name==="TypeError"&&/Load failed|fetch/i.test(E.message)?Object.assign(new _e("Network Error",_e.ERR_NETWORK,m,M,E&&E.response),{cause:E.cause||E}):_e.from(E,E&&E.code,m,M,E&&E.response)}}},ud=new Map,Zi=t=>{let n=t&&t.env||{};const{fetch:a,Request:r,Response:o}=n,l=[r,o,a];let d=l.length,c=d,b,y,u=ud;for(;c--;)b=l[c],y=u.get(b),y===void 0&&u.set(b,y=c?new Map:cd(n)),u=y;return y};Zi();const Ds={http:Cl,xhr:sd,fetch:{get:Zi}};K.forEach(Ds,(t,n)=>{if(t){try{Object.defineProperty(t,"name",{value:n})}catch{}Object.defineProperty(t,"adapterName",{value:n})}});const ir=t=>`- ${t}`,pd=t=>K.isFunction(t)||t===null||t===!1;function md(t,n){t=K.isArray(t)?t:[t];const{length:a}=t;let r,o;const l={};for(let d=0;d<a;d++){r=t[d];let c;if(o=r,!pd(r)&&(o=Ds[(c=String(r)).toLowerCase()],o===void 0))throw new _e(`Unknown adapter '${c}'`);if(o&&(K.isFunction(o)||(o=o.get(n))))break;l[c||"#"+d]=o}if(!o){const d=Object.entries(l).map(([b,y])=>`adapter ${b} `+(y===!1?"is not supported by the environment":"is not available in the build"));let c=a?d.length>1?`since :
|
|
4
|
-
`+d.map(
|
|
5
|
-
`):" "+
|
|
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(`
|
|
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),
|
|
9
|
-
`+l)}}catch{}}throw r}}_request(n,a){typeof n=="string"?(a=a||{},a.url=n):a=n||{},a=zt(this.defaults,a);const{transitional:r,paramsSerializer:o,headers:l}=a;r!==void 0&&ca.assertOptions(r,{silentJSONParsing:dt.transitional(dt.boolean),forcedJSONParsing:dt.transitional(dt.boolean),clarifyTimeoutError:dt.transitional(dt.boolean),legacyInterceptorReqResOrdering:dt.transitional(dt.boolean)},!1),o!=null&&(K.isFunction(o)?a.paramsSerializer={serialize:o}:ca.assertOptions(o,{encode:dt.function,serialize:dt.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),ca.assertOptions(a,{baseUrl:dt.spelling("baseURL"),withXsrfToken:dt.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let d=l&&K.merge(l.common,l[a.method]);l&&K.forEach(["delete","get","head","post","put","patch","common"],m=>{delete l[m]}),a.headers=tt.concat(d,l);const c=[];let b=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(a)===!1)return;b=b&&h.synchronous;const g=a.transitional||Rs;g&&g.legacyInterceptorReqResOrdering?c.unshift(h.fulfilled,h.rejected):c.push(h.fulfilled,h.rejected)});const y=[];this.interceptors.response.forEach(function(h){y.push(h.fulfilled,h.rejected)});let u,x=0,j;if(!b){const m=[or.bind(this),void 0];for(m.unshift(...c),m.push(...y),j=m.length,u=Promise.resolve(a);x<j;)u=u.then(m[x++],m[x++]);return u}j=c.length;let C=a;for(;x<j;){const m=c[x++],h=c[x++];try{C=m(C)}catch(g){h.call(this,g);break}}try{u=or.call(this,C)}catch(m){return Promise.reject(m)}for(x=0,j=y.length;x<j;)u=u.then(y[x++],y[x++]);return u}getUri(n){n=zt(this.defaults,n);const a=Qi(n.baseURL,n.url,n.allowAbsoluteUrls);return Hi(a,n.params,n.paramsSerializer)}};K.forEach(["delete","get","head","options"],function(n){Bt.prototype[n]=function(a,r){return this.request(zt(r||{},{method:n,url:a,data:(r||{}).data}))}});K.forEach(["post","put","patch"],function(n){function a(r){return function(l,d,c){return this.request(zt(c||{},{method:n,headers:r?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}Bt.prototype[n]=a(),Bt.prototype[n+"Form"]=a(!0)});let fd=class no{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let a;this.promise=new Promise(function(l){a=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},n(function(l,d,c){r.reason||(r.reason=new Nn(l,d,c),a(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const a=this._listeners.indexOf(n);a!==-1&&this._listeners.splice(a,1)}toAbortSignal(){const n=new AbortController,a=r=>{n.abort(r)};return this.subscribe(a),n.signal.unsubscribe=()=>this.unsubscribe(a),n.signal}static source(){let n;return{token:new no(function(o){n=o}),cancel:n}}};function hd(t){return function(a){return t.apply(null,a)}}function gd(t){return K.isObject(t)&&t.isAxiosError===!0}const ws={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(ws).forEach(([t,n])=>{ws[n]=t});function ao(t){const n=new Bt(t),a=Fi(Bt.prototype.request,n);return K.extend(a,Bt.prototype,n,{allOwnKeys:!0}),K.extend(a,n,null,{allOwnKeys:!0}),a.create=function(o){return ao(zt(t,o))},a}const Ne=ao(Fn);Ne.Axios=Bt;Ne.CanceledError=Nn;Ne.CancelToken=fd;Ne.isCancel=Gi;Ne.VERSION=to;Ne.toFormData=Da;Ne.AxiosError=_e;Ne.Cancel=Ne.CanceledError;Ne.all=function(n){return Promise.all(n)};Ne.spread=hd;Ne.isAxiosError=gd;Ne.mergeConfig=zt;Ne.AxiosHeaders=tt;Ne.formToJSON=t=>Ki(K.isHTMLForm(t)?new FormData(t):t);Ne.getAdapter=eo.getAdapter;Ne.HttpStatusCode=ws;Ne.default=Ne;const{Axios:nh,AxiosError:ah,CanceledError:sh,isCancel:rh,CancelToken:ih,VERSION:oh,all:lh,Cancel:dh,isAxiosError:ch,spread:uh,toFormData:ph,AxiosHeaders:mh,HttpStatusCode:yh,formToJSON:fh,getAdapter:hh,mergeConfig:gh}=Ne,xd=()=>new Promise(t=>setTimeout(()=>t(),800));let Cs=null;const bd=t=>{Cs=t,xt.defaults.baseURL=ks()},ks=()=>Cs||"https://npmapi.ubkerp.com/",xt=Ne.create({baseURL:ks()}),nt=()=>ks(),Ye=async(t,n,a)=>{const r=await xt.post(t,n,{headers:{Authorization:a}});if(console.log("ddddfdfdfd",r.data?.Status),r.data?.Status=="Success")return r?.data?.data||r?.data;throw new Error(r.data?.msg)},Q=async(t,n)=>{try{let r=t;if(!t.includes("session_id")){const l=t.includes("?")?"&":"?";r=`${t}${l}session_id=1`}return(await xt.get(r,{headers:{Authorization:n}})).data}catch(a){throw a.response?.status===401&&console.error("401 Unauthorized"),a}},Sd=async(t,n)=>{const a=await xt.post(t,"",{headers:{Authorization:n}});if(a.data?.Status=="Success")return a?.data?.data||a?.data;throw new Error(a.data?.msg)},Oa=async(t,n,a)=>{try{const r=await xt.post(t,n,{headers:{Authorization:a,"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}},Dn=async(t,n,a)=>{const r=n?.arg;return(await xt.post(t,r,{headers:{Authorization:a}}))?.data},Lt=async(t,n,a)=>{const r=n?.arg,o=t.includes("?")?"&":"?";return(await xt.get(t+o,{params:r,headers:{Authorization:a}}))?.data},jd="api/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",Os=async(t,n,a)=>{const r=n?.arg,o=t.includes("?")?"&":"?",l=await xt.get(t+o,{params:r,headers:{Authorization:a}});if(console.log("ddddfdfdfd",l.data?.Status),l.data?.Status=="Success")return l?.data?.data||l?.data;throw new Error(l.data?.msg)},ut=async(t,n,a)=>(await xd(),(await xt.post(t,n,{headers:{Authorization:a}}))?.data),at=async(t,n,a)=>(await xt.delete(`${t}/${n}`,{headers:{Authorization:a}})).data,vd="api/report/LibraryRenewalReport/renewalHistory",_d="api/report/LibraryRenewalReport/renewalFineReport",wd="api/report/LibraryRenewalReport/currentlyRenewedBooks",Cd="api/report/LibraryRenewalReport/upcomingRenewalDue",Ad="api/report/LibraryRenewalReport/overdueRenewalReport",Td="api/report/LibraryRenewalReport/renewalLimitReport",Rd="api/report/LibraryRenewalReport/renewalStatusReport",Id="api/report/LibraryRenewalReport/studentWiseReport",Dd="api/report/LibraryRenewalReport/bookWiseReport",kd="api/report/LibraryRenewalReport/classWiseReport",Od="api/report/LibraryRenewalReport/staffWiseReport",Pd="api/report/LibraryRenewalReport/renewalStatisticsByDate",Ed=({token:t,menu:n})=>{const{isLoading:a,data:r}=G(t?["api/sdk/Menus",t]:null,([l,d])=>Sd(l,d)),o=r?.find(l=>l.path===n)?.sub_menu??[];return console.log("menuData",r),e.jsx(s.Row,{gutter:[16,16],children:o?.map((l,d)=>l.dashboard_show==="YES"?e.jsx(s.Col,{xs:24,md:8,lg:8,children:e.jsx(le,{children:e.jsx(Mi,{icon:`${nt()}icons/frontoffice/${l.icons}`,title:l.submenu_name,path:l.menu_key})})},`${d}office001`):null)})};function so(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qe={},Ja,dr;function Md(){return dr||(dr=1,Ja=function t(n,a){if(n===a)return!0;if(n&&a&&typeof n=="object"&&typeof a=="object"){if(n.constructor!==a.constructor)return!1;var r,o,l;if(Array.isArray(n)){if(r=n.length,r!=a.length)return!1;for(o=r;o--!==0;)if(!t(n[o],a[o]))return!1;return!0}if(n.constructor===RegExp)return n.source===a.source&&n.flags===a.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===a.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===a.toString();if(l=Object.keys(n),r=l.length,r!==Object.keys(a).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(a,l[o]))return!1;for(o=r;o--!==0;){var d=l[o];if(!t(n[d],a[d]))return!1}return!0}return n!==n&&a!==a}),Ja}var Wn={exports:{}},Vn={exports:{}},Ie={};var cr;function Fd(){if(cr)return Ie;cr=1;var t=typeof Symbol=="function"&&Symbol.for,n=t?Symbol.for("react.element"):60103,a=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,b=t?Symbol.for("react.async_mode"):60111,y=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,x=t?Symbol.for("react.suspense"):60113,j=t?Symbol.for("react.suspense_list"):60120,C=t?Symbol.for("react.memo"):60115,m=t?Symbol.for("react.lazy"):60116,h=t?Symbol.for("react.block"):60121,g=t?Symbol.for("react.fundamental"):60117,I=t?Symbol.for("react.responder"):60118,R=t?Symbol.for("react.scope"):60119;function D(f){if(typeof f=="object"&&f!==null){var p=f.$$typeof;switch(p){case n:switch(f=f.type,f){case b:case y:case r:case l:case o:case x:return f;default:switch(f=f&&f.$$typeof,f){case c:case u:case m:case C:case d:return f;default:return p}}case a:return p}}}function w(f){return D(f)===y}return Ie.AsyncMode=b,Ie.ConcurrentMode=y,Ie.ContextConsumer=c,Ie.ContextProvider=d,Ie.Element=n,Ie.ForwardRef=u,Ie.Fragment=r,Ie.Lazy=m,Ie.Memo=C,Ie.Portal=a,Ie.Profiler=l,Ie.StrictMode=o,Ie.Suspense=x,Ie.isAsyncMode=function(f){return w(f)||D(f)===b},Ie.isConcurrentMode=w,Ie.isContextConsumer=function(f){return D(f)===c},Ie.isContextProvider=function(f){return D(f)===d},Ie.isElement=function(f){return typeof f=="object"&&f!==null&&f.$$typeof===n},Ie.isForwardRef=function(f){return D(f)===u},Ie.isFragment=function(f){return D(f)===r},Ie.isLazy=function(f){return D(f)===m},Ie.isMemo=function(f){return D(f)===C},Ie.isPortal=function(f){return D(f)===a},Ie.isProfiler=function(f){return D(f)===l},Ie.isStrictMode=function(f){return D(f)===o},Ie.isSuspense=function(f){return D(f)===x},Ie.isValidElementType=function(f){return typeof f=="string"||typeof f=="function"||f===r||f===y||f===l||f===o||f===x||f===j||typeof f=="object"&&f!==null&&(f.$$typeof===m||f.$$typeof===C||f.$$typeof===d||f.$$typeof===c||f.$$typeof===u||f.$$typeof===g||f.$$typeof===I||f.$$typeof===R||f.$$typeof===h)},Ie.typeOf=D,Ie}var De={};var ur;function Nd(){return ur||(ur=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,n=t?Symbol.for("react.element"):60103,a=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,b=t?Symbol.for("react.async_mode"):60111,y=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,x=t?Symbol.for("react.suspense"):60113,j=t?Symbol.for("react.suspense_list"):60120,C=t?Symbol.for("react.memo"):60115,m=t?Symbol.for("react.lazy"):60116,h=t?Symbol.for("react.block"):60121,g=t?Symbol.for("react.fundamental"):60117,I=t?Symbol.for("react.responder"):60118,R=t?Symbol.for("react.scope"):60119;function D(re){return typeof re=="string"||typeof re=="function"||re===r||re===y||re===l||re===o||re===x||re===j||typeof re=="object"&&re!==null&&(re.$$typeof===m||re.$$typeof===C||re.$$typeof===d||re.$$typeof===c||re.$$typeof===u||re.$$typeof===g||re.$$typeof===I||re.$$typeof===R||re.$$typeof===h)}function w(re){if(typeof re=="object"&&re!==null){var ie=re.$$typeof;switch(ie){case n:var V=re.type;switch(V){case b:case y:case r:case l:case o:case x:return V;default:var oe=V&&V.$$typeof;switch(oe){case c:case u:case m:case C:case d:return oe;default:return ie}}case a:return ie}}}var f=b,p=y,S=c,A=d,O=n,q=u,U=r,v=m,M=C,P=a,N=l,E=o,F=x,L=!1;function z(re){return L||(L=!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.")),k(re)||w(re)===b}function k(re){return w(re)===y}function T(re){return w(re)===c}function $(re){return w(re)===d}function B(re){return typeof re=="object"&&re!==null&&re.$$typeof===n}function Y(re){return w(re)===u}function ne(re){return w(re)===r}function H(re){return w(re)===m}function W(re){return w(re)===C}function ee(re){return w(re)===a}function se(re){return w(re)===l}function me(re){return w(re)===o}function ve(re){return w(re)===x}De.AsyncMode=f,De.ConcurrentMode=p,De.ContextConsumer=S,De.ContextProvider=A,De.Element=O,De.ForwardRef=q,De.Fragment=U,De.Lazy=v,De.Memo=M,De.Portal=P,De.Profiler=N,De.StrictMode=E,De.Suspense=F,De.isAsyncMode=z,De.isConcurrentMode=k,De.isContextConsumer=T,De.isContextProvider=$,De.isElement=B,De.isForwardRef=Y,De.isFragment=ne,De.isLazy=H,De.isMemo=W,De.isPortal=ee,De.isProfiler=se,De.isStrictMode=me,De.isSuspense=ve,De.isValidElementType=D,De.typeOf=w})()),De}var pr;function ro(){return pr||(pr=1,process.env.NODE_ENV==="production"?Vn.exports=Fd():Vn.exports=Nd()),Vn.exports}var Qa,mr;function $d(){if(mr)return Qa;mr=1;var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,a=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 b=Object.getOwnPropertyNames(d).map(function(u){return d[u]});if(b.join("")!=="0123456789")return!1;var y={};return"abcdefghijklmnopqrst".split("").forEach(function(u){y[u]=u}),Object.keys(Object.assign({},y)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Qa=o()?Object.assign:function(l,d){for(var c,b=r(l),y,u=1;u<arguments.length;u++){c=Object(arguments[u]);for(var x in c)n.call(c,x)&&(b[x]=c[x]);if(t){y=t(c);for(var j=0;j<y.length;j++)a.call(c,y[j])&&(b[y[j]]=c[y[j]])}}return b},Qa}var Xa,yr;function Ps(){if(yr)return Xa;yr=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Xa=t,Xa}var Za,fr;function io(){return fr||(fr=1,Za=Function.call.bind(Object.prototype.hasOwnProperty)),Za}var es,hr;function Ud(){if(hr)return es;hr=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var n=Ps(),a={},r=io();t=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function o(l,d,c,b,y){if(process.env.NODE_ENV!=="production"){for(var u in l)if(r(l,u)){var x;try{if(typeof l[u]!="function"){var j=Error((b||"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 j.name="Invariant Violation",j}x=l[u](d,u,b,c,null,n)}catch(m){x=m}if(x&&!(x instanceof Error)&&t((b||"React class")+": type specification of "+c+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof x+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),x instanceof Error&&!(x.message in a)){a[x.message]=!0;var C=y?y():"";t("Failed "+c+" type: "+x.message+(C??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(a={})},es=o,es}var ts,gr;function Bd(){if(gr)return ts;gr=1;var t=ro(),n=$d(),a=Ps(),r=io(),o=Ud(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(c){var b="Warning: "+c;typeof console<"u"&&console.error(b);try{throw new Error(b)}catch{}});function d(){return null}return ts=function(c,b){var y=typeof Symbol=="function"&&Symbol.iterator,u="@@iterator";function x(k){var T=k&&(y&&k[y]||k[u]);if(typeof T=="function")return T}var j="<<anonymous>>",C={array:I("array"),bigint:I("bigint"),bool:I("boolean"),func:I("function"),number:I("number"),object:I("object"),string:I("string"),symbol:I("symbol"),any:R(),arrayOf:D,element:w(),elementType:f(),instanceOf:p,node:q(),objectOf:A,oneOf:S,oneOfType:O,shape:v,exact:M};function m(k,T){return k===T?k!==0||1/k===1/T:k!==k&&T!==T}function h(k,T){this.message=k,this.data=T&&typeof T=="object"?T:{},this.stack=""}h.prototype=Error.prototype;function g(k){if(process.env.NODE_ENV!=="production")var T={},$=0;function B(ne,H,W,ee,se,me,ve){if(ee=ee||j,me=me||W,ve!==a){if(b){var re=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 re.name="Invariant Violation",re}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var ie=ee+":"+W;!T[ie]&&$<3&&(l("You are manually calling a React.PropTypes validation function for the `"+me+"` prop on `"+ee+"`. 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."),T[ie]=!0,$++)}}return H[W]==null?ne?H[W]===null?new h("The "+se+" `"+me+"` is marked as required "+("in `"+ee+"`, but its value is `null`.")):new h("The "+se+" `"+me+"` is marked as required in "+("`"+ee+"`, but its value is `undefined`.")):null:k(H,W,ee,se,me)}var Y=B.bind(null,!1);return Y.isRequired=B.bind(null,!0),Y}function I(k){function T($,B,Y,ne,H,W){var ee=$[B],se=E(ee);if(se!==k){var me=F(ee);return new h("Invalid "+ne+" `"+H+"` of type "+("`"+me+"` supplied to `"+Y+"`, expected ")+("`"+k+"`."),{expectedType:k})}return null}return g(T)}function R(){return g(d)}function D(k){function T($,B,Y,ne,H){if(typeof k!="function")return new h("Property `"+H+"` of component `"+Y+"` has invalid PropType notation inside arrayOf.");var W=$[B];if(!Array.isArray(W)){var ee=E(W);return new h("Invalid "+ne+" `"+H+"` of type "+("`"+ee+"` supplied to `"+Y+"`, expected an array."))}for(var se=0;se<W.length;se++){var me=k(W,se,Y,ne,H+"["+se+"]",a);if(me instanceof Error)return me}return null}return g(T)}function w(){function k(T,$,B,Y,ne){var H=T[$];if(!c(H)){var W=E(H);return new h("Invalid "+Y+" `"+ne+"` of type "+("`"+W+"` supplied to `"+B+"`, expected a single ReactElement."))}return null}return g(k)}function f(){function k(T,$,B,Y,ne){var H=T[$];if(!t.isValidElementType(H)){var W=E(H);return new h("Invalid "+Y+" `"+ne+"` of type "+("`"+W+"` supplied to `"+B+"`, expected a single ReactElement type."))}return null}return g(k)}function p(k){function T($,B,Y,ne,H){if(!($[B]instanceof k)){var W=k.name||j,ee=z($[B]);return new h("Invalid "+ne+" `"+H+"` of type "+("`"+ee+"` supplied to `"+Y+"`, expected ")+("instance of `"+W+"`."))}return null}return g(T)}function S(k){if(!Array.isArray(k))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 T($,B,Y,ne,H){for(var W=$[B],ee=0;ee<k.length;ee++)if(m(W,k[ee]))return null;var se=JSON.stringify(k,function(ve,re){var ie=F(re);return ie==="symbol"?String(re):re});return new h("Invalid "+ne+" `"+H+"` of value `"+String(W)+"` "+("supplied to `"+Y+"`, expected one of "+se+"."))}return g(T)}function A(k){function T($,B,Y,ne,H){if(typeof k!="function")return new h("Property `"+H+"` of component `"+Y+"` has invalid PropType notation inside objectOf.");var W=$[B],ee=E(W);if(ee!=="object")return new h("Invalid "+ne+" `"+H+"` of type "+("`"+ee+"` supplied to `"+Y+"`, expected an object."));for(var se in W)if(r(W,se)){var me=k(W,se,Y,ne,H+"."+se,a);if(me instanceof Error)return me}return null}return g(T)}function O(k){if(!Array.isArray(k))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var T=0;T<k.length;T++){var $=k[T];if(typeof $!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+L($)+" at index "+T+"."),d}function B(Y,ne,H,W,ee){for(var se=[],me=0;me<k.length;me++){var ve=k[me],re=ve(Y,ne,H,W,ee,a);if(re==null)return null;re.data&&r(re.data,"expectedType")&&se.push(re.data.expectedType)}var ie=se.length>0?", expected one of type ["+se.join(", ")+"]":"";return new h("Invalid "+W+" `"+ee+"` supplied to "+("`"+H+"`"+ie+"."))}return g(B)}function q(){function k(T,$,B,Y,ne){return P(T[$])?null:new h("Invalid "+Y+" `"+ne+"` supplied to "+("`"+B+"`, expected a ReactNode."))}return g(k)}function U(k,T,$,B,Y){return new h((k||"React class")+": "+T+" type `"+$+"."+B+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+Y+"`.")}function v(k){function T($,B,Y,ne,H){var W=$[B],ee=E(W);if(ee!=="object")return new h("Invalid "+ne+" `"+H+"` of type `"+ee+"` "+("supplied to `"+Y+"`, expected `object`."));for(var se in k){var me=k[se];if(typeof me!="function")return U(Y,ne,H,se,F(me));var ve=me(W,se,Y,ne,H+"."+se,a);if(ve)return ve}return null}return g(T)}function M(k){function T($,B,Y,ne,H){var W=$[B],ee=E(W);if(ee!=="object")return new h("Invalid "+ne+" `"+H+"` of type `"+ee+"` "+("supplied to `"+Y+"`, expected `object`."));var se=n({},$[B],k);for(var me in se){var ve=k[me];if(r(k,me)&&typeof ve!="function")return U(Y,ne,H,me,F(ve));if(!ve)return new h("Invalid "+ne+" `"+H+"` key `"+me+"` supplied to `"+Y+"`.\nBad object: "+JSON.stringify($[B],null," ")+`
|
|
10
|
-
Valid keys: `+JSON.stringify(Object.keys(k),null," "));var re=ve(W,me,Y,ne,H+"."+me,a);if(re)return re}return null}return g(T)}function P(k){switch(typeof k){case"number":case"string":case"undefined":return!0;case"boolean":return!k;case"object":if(Array.isArray(k))return k.every(P);if(k===null||c(k))return!0;var T=x(k);if(T){var $=T.call(k),B;if(T!==k.entries){for(;!(B=$.next()).done;)if(!P(B.value))return!1}else for(;!(B=$.next()).done;){var Y=B.value;if(Y&&!P(Y[1]))return!1}}else return!1;return!0;default:return!1}}function N(k,T){return k==="symbol"?!0:T?T["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&T instanceof Symbol:!1}function E(k){var T=typeof k;return Array.isArray(k)?"array":k instanceof RegExp?"object":N(T,k)?"symbol":T}function F(k){if(typeof k>"u"||k===null)return""+k;var T=E(k);if(T==="object"){if(k instanceof Date)return"date";if(k instanceof RegExp)return"regexp"}return T}function L(k){var T=F(k);switch(T){case"array":case"object":return"an "+T;case"boolean":case"date":case"regexp":return"a "+T;default:return T}}function z(k){return!k.constructor||!k.constructor.name?j:k.constructor.name}return C.checkPropTypes=o,C.resetWarningCache=o.resetWarningCache,C.PropTypes=C,C},ts}var ns,xr;function Ld(){if(xr)return ns;xr=1;var t=Ps();function n(){}function a(){}return a.resetWarningCache=n,ns=function(){function r(d,c,b,y,u,x){if(x!==t){var j=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 j.name="Invariant Violation",j}}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:a,resetWarningCache:n};return l.PropTypes=l,l},ns}var br;function oo(){if(br)return Wn.exports;if(br=1,process.env.NODE_ENV!=="production"){var t=ro(),n=!0;Wn.exports=Bd()(t.isElement,n)}else Wn.exports=Ld()();return Wn.exports}var Sr;function qd(){if(Sr)return qe;Sr=1;var t=qe&&qe.__extends||(function(){var C=function(m,h){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,I){g.__proto__=I}||function(g,I){for(var R in I)Object.prototype.hasOwnProperty.call(I,R)&&(g[R]=I[R])},C(m,h)};return function(m,h){if(typeof h!="function"&&h!==null)throw new TypeError("Class extends value "+String(h)+" is not a constructor or null");C(m,h);function g(){this.constructor=m}m.prototype=h===null?Object.create(h):(g.prototype=h.prototype,new g)}})(),n=qe&&qe.__assign||function(){return n=Object.assign||function(C){for(var m,h=1,g=arguments.length;h<g;h++){m=arguments[h];for(var I in m)Object.prototype.hasOwnProperty.call(m,I)&&(C[I]=m[I])}return C},n.apply(this,arguments)},a=qe&&qe.__createBinding||(Object.create?(function(C,m,h,g){g===void 0&&(g=h);var I=Object.getOwnPropertyDescriptor(m,h);(!I||("get"in I?!m.__esModule:I.writable||I.configurable))&&(I={enumerable:!0,get:function(){return m[h]}}),Object.defineProperty(C,g,I)}):(function(C,m,h,g){g===void 0&&(g=h),C[g]=m[h]})),r=qe&&qe.__setModuleDefault||(Object.create?(function(C,m){Object.defineProperty(C,"default",{enumerable:!0,value:m})}):function(C,m){C.default=m}),o=qe&&qe.__importStar||function(C){if(C&&C.__esModule)return C;var m={};if(C!=null)for(var h in C)h!=="default"&&Object.prototype.hasOwnProperty.call(C,h)&&a(m,C,h);return r(m,C),m},l=qe&&qe.__rest||function(C,m){var h={};for(var g in C)Object.prototype.hasOwnProperty.call(C,g)&&m.indexOf(g)<0&&(h[g]=C[g]);if(C!=null&&typeof Object.getOwnPropertySymbols=="function")for(var I=0,g=Object.getOwnPropertySymbols(C);I<g.length;I++)m.indexOf(g[I])<0&&Object.prototype.propertyIsEnumerable.call(C,g[I])&&(h[g[I]]=C[g[I]]);return h},d=qe&&qe.__importDefault||function(C){return C&&C.__esModule?C:{default:C}};Object.defineProperty(qe,"__esModule",{value:!0});var c=o(i),b=d(Md()),y=o(oo());function u(C){return C&&C.replace(/ |\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function x(C){var m=document.createTextNode("");C.appendChild(m);var h=document.activeElement===C;if(m!==null&&m.nodeValue!==null&&h){var g=window.getSelection();if(g!==null){var I=document.createRange();I.setStart(m,m.nodeValue.length),I.collapse(!0),g.removeAllRanges(),g.addRange(I)}C instanceof HTMLElement&&C.focus()}}var j=(function(C){t(m,C);function m(){var h=C!==null&&C.apply(this,arguments)||this;return h.lastHtml=h.props.html,h.el=typeof h.props.innerRef=="function"?{current:null}:c.createRef(),h.getEl=function(){return(h.props.innerRef&&typeof h.props.innerRef!="function"?h.props.innerRef:h.el).current},h.emitChange=function(g){var I=h.getEl();if(I){var R=I.innerHTML;if(h.props.onChange&&R!==h.lastHtml){var D=Object.assign({},g,{target:{value:R}});h.props.onChange(D)}h.lastHtml=R}},h}return m.prototype.render=function(){var h=this,g=this.props,I=g.tagName,R=g.html,D=g.innerRef,w=l(g,["tagName","html","innerRef"]);return c.createElement(I||"div",n(n({},w),{ref:typeof D=="function"?function(f){D(f),h.el.current=f}:D||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:R}}),this.props.children)},m.prototype.shouldComponentUpdate=function(h){var g=this.props,I=this.getEl();return!I||u(h.html)!==u(I.innerHTML)?!0:g.disabled!==h.disabled||g.tagName!==h.tagName||g.className!==h.className||g.innerRef!==h.innerRef||g.placeholder!==h.placeholder||!(0,b.default)(g.style,h.style)},m.prototype.componentDidUpdate=function(){var h=this.getEl();h&&(this.props.html!==h.innerHTML&&(h.innerHTML=this.props.html),this.lastHtml=this.props.html,x(h))},m.propTypes={html:y.string.isRequired,onChange:y.func,disabled:y.bool,tagName:y.string,className:y.string,style:y.object,innerRef:y.oneOfType([y.object,y.func])},m})(c.Component);return qe.default=j,qe}var zd=qd();const lo=so(zd),Yd={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Wd={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"},J=i.forwardRef(({style:t,onFocus:n,onBlur:a,...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:Yd,children:r.label}),e.jsx("input",{placeholder:r.placeholder||r.label,...r,ref:o,onFocus:c=>{d(!0),n?.(c)},onBlur:c=>{d(!1),a?.(c)},style:{...Wd,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})}),jr=[{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 Es(t){const n=ae().year(),a=[];for(let r=n;r>=n-t;r--)a.push({label:String(r),value:r});return a}function ze(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 Ms(t){const n=ae().year(),a=ae().month();return t<n?jr:jr.slice(0,a+1)}function vr(t,n){switch(t){case"sunday":return e.jsx("span",{className:"monthlyLabel sunday",children:n});case"holiday":return e.jsx("span",{className:"monthlyLabel holiday",children:n});default:return e.jsx("span",{className:"monthlyLabel",children:n})}}function Vd(){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 co=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(s.Tag,{color:"success",children:"Present"});case"Absent":return e.jsx(s.Tag,{color:"error",children:"Absent"});case"NO Attendance":return e.jsx(s.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""}},ht=t=>{const n=JSON.parse(localStorage.getItem("genrall_settings"));return console.log("amount______",t),e.jsxs(e.Fragment,{children:[n?.currency_icon," ",Number(t||0).toLocaleString("en-IN")]})};var mn={},yn={},rt={},fn={},Gt={},_r;function Hd(){if(_r)return Gt;_r=1;var t=Gt&&Gt.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Gt,"__esModule",{value:!0});const n=t(i),a=Mo,r=["string","number","boolean"];function o({header:l,body:d}){const c=n.default.createElement("tr",null,l.map(y=>n.default.createElement("th",{key:y},y))),b=d.map((y,u)=>Array.isArray(y)?n.default.createElement("tr",{key:u},y.map((x,j)=>n.default.createElement("th",{key:j}," ",x," "))):y!==null&&typeof y=="object"?n.default.createElement("tr",{key:u},Object.entries(y).map(([x,j],C)=>typeof j=="object"?(console.error(`typeof ${x} is incorrect, only accept ${r.join(", ")} `),n.default.createElement("th",{key:C})):n.default.createElement("th",{key:C},n.default.createElement(n.default.Fragment,null,j)))):(console.error(`
|
|
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(/ |\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(`
|
|
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,a.renderToString)(n.default.createElement("table",null,n.default.createElement("tbody",null,c,b)))}return Gt.default=o,Gt}var wr;function Kd(){return wr||(wr=1,(function(t){var n=fn&&fn.__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 a(l){return window.btoa(unescape(encodeURIComponent(l)))}t.base64=a;function r(l,d){return l.replace(/{(\w+)}/g,(c,b)=>d[b])}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=Hd();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return n(o).default}})})(fn)),fn}var Cr;function uo(){if(Cr)return rt;Cr=1;var t=rt&&rt.__createBinding||(Object.create?(function(y,u,x,j){j===void 0&&(j=x);var C=Object.getOwnPropertyDescriptor(u,x);(!C||("get"in C?!u.__esModule:C.writable||C.configurable))&&(C={enumerable:!0,get:function(){return u[x]}}),Object.defineProperty(y,j,C)}):(function(y,u,x,j){j===void 0&&(j=x),y[j]=u[x]})),n=rt&&rt.__setModuleDefault||(Object.create?(function(y,u){Object.defineProperty(y,"default",{enumerable:!0,value:u})}):function(y,u){y.default=u}),a=rt&&rt.__importStar||function(y){if(y&&y.__esModule)return y;var u={};if(y!=null)for(var x in y)x!=="default"&&Object.prototype.hasOwnProperty.call(y,x)&&t(u,y,x);return n(u,y),u};Object.defineProperty(rt,"__esModule",{value:!0}),rt.downloadExcel=rt.excel=void 0;const r=a(Kd());function o(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function l(y,u){const x=window.document.createElement("a");return x.href=r.uri+r.base64(r.format(r.template,u)),x.download=y,document.body.appendChild(x),x.click(),document.body.removeChild(x),!0}function d(y,u){if(y)return y.cloneNode(!0).outerHTML;if(u)return r.createTable(u);console.error("currentTableRef or tablePayload does not exist")}function c({fileName:y,sheet:u,tablePayload:x},j){if(!o())return!1;const C=d(j,x);return l(y,{worksheet:u||"Worksheet",table:C})}rt.downloadExcel=c;function b({currentTableRef:y,filename:u,sheet:x}){function j(){if(!o())return!1;const C=d(y),m=`${u}.xls`;return l(m,{worksheet:x||"Worksheet",table:C})}return{onDownload:j}}return rt.excel=b,rt}var Ar;function Gd(){if(Ar)return yn;Ar=1,Object.defineProperty(yn,"__esModule",{value:!0}),yn.useDownloadExcel=void 0;const t=i,n=uo();function a({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,n.excel)(d),[d])}return yn.useDownloadExcel=a,yn}var Tr;function Jd(){return Tr||(Tr=1,(function(t){var n=mn&&mn.__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 a=n(i),r=Gd();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return r.useDownloadExcel}});const o=uo();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return o.downloadExcel}});const l=({currentTableRef:d,filename:c,sheet:b,children:y})=>{const{onDownload:u}=(0,r.useDownloadExcel)({currentTableRef:d,filename:c,sheet:b});return a.default.createElement("span",{onClick:u},y)};t.DownloadTableExcel=l})(mn)),mn}var po=Jd();const dn=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:n}=t.data;t?.tableRef;const a=new Date().getTime(),r=on.useReactToPrint({content:()=>n.current});return e.jsx(e.Fragment,{children:e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsxs(s.Row,{gutter:8,children:[e.jsx(s.Col,{children:e.jsx(s.Button,{type:"text",icon:e.jsx(X.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(s.Col,{children:e.jsx(po.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:n.current,children:e.jsx(s.Button,{type:"text",icon:e.jsx(X.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},_t=t=>{const{tableRef:n}=t;return new Date().getTime(),e.jsx(e.Fragment,{children:e.jsx(s.Row,{justify:"center",children:e.jsx(s.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},Qd=i.createContext(),Xd=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),Le=t=>{const{columns:n,action:a,DrawerUpdate:r,editDesign:o,newData:l,Loading:d,error:c,deleteTodoMutation:b,open:y,ActionView:u,viewDetails:x,myType:j,type:C,urlkey:m,columnstype:h,rowSelection:g}=t.data,I=Xd(),[R,D]=i.useState(!1),[w,f]=i.useState(null),[p,S]=i.useState("false"),[A,O]=i.useState(!1),[q,U]=i.useState(!1),[v,M]=i.useState(),[P,N]=i.useState(""),E=()=>D(!1),F=te=>{S(te),D(!0)},[L,z]=i.useState(),[k,T]=i.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),$=i.useRef(null),B=(te,ye)=>{t.parentCallback?.(te,ye),T({rowsPerPage:ye,page:te})},Y=(te,ye)=>{f(ye),O(!0),M(te)},ne=(te,ye)=>{f(ye),U(!0),M(te)},H=t?.data?.onNavigate??t?.onNavigate,W=(te,ye)=>{if(typeof H=="function"){H(te,ye);return}typeof window<"u"&&typeof te=="string"&&te.length>0&&window.location.assign(te)},ee=te=>{if(C==="staff"){W(`/HumanResourceDashboard/StaffFullInformation?id=${te.fk_staffID}`,te);return}W(`/StudentInformation/StudentFullInformation?id=${te.id}`,te)},se=(te,ye)=>{z(te),r?.(ye)},me=async(te,ye,he,Te)=>{r?.(!0),he!==""&&((await Te({id:te,admission_no:ye,ec_no:he}))?.Status==="Success"?s.message.success("Ec No updated successfully"):s.message.error("Failed to Update Ec No."))},ve=()=>e.jsx(Qd.Provider,{value:L,children:o}),{trigger:re}=Je("branchapi/staff/updateStaffPassword",Dn),{trigger:ie}=Je("branchapi/Student/updateEcNo",Dn),{trigger:V}=Je(m,(te,ye)=>Dn("student/studentDetails/editStudentLogInCredential",ye)),oe=async te=>{te.preventDefault(),O(!1);try{(await re({staff_id:v,new_passwod:te.target.password.value}))?.Status==="Success"?s.message.success("Password updated successfully"):s.message.error("Failed to update password")}catch{s.message.error("Failed to update password")}},Ce=async te=>{te.preventDefault(),U(!1);try{(await V({edit_id:w?.edit_id,new_passwod:te.target.password.value,username:te.target.username.value,branch_id:JSON.parse(localStorage.getItem("genrall_settings"))?.fk_branchID}))?.Status==="Success"?s.message.success("Password updated successfully"):s.message.error("Failed to update password")}catch(ye){s.message.error(ye?.response?.data?.msg??"Failed to update password")}},Oe=(Array.isArray(n)?n:[]).some(te=>te?.fixed==="left"),Pe=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:h==="antd"&&Oe?"left":void 0,sorter:(te,ye)=>(te.__serialNumber??0)-(ye.__serialNumber??0),render:te=>te},...h==="antd"?n:(Array.isArray(n)?n:[]).map(te=>({title:te.name,dataIndex:te.selector,key:te.selector,sorter:te.sorter||(te.sortable?(ye,he)=>{const Te=ye[te.selector]??"",Re=he[te.selector]??"";return typeof Te=="number"&&typeof Re=="number"?Te-Re:String(Te).localeCompare(String(Re))}:!1),render:(ye,he)=>{switch(te.selector){case"my_staff":return he.staff_id!=="0"?he.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(s.Image,{width:50,src:`undefined/branch/gallery/${he.gallery_cat_logo}`});case"file01":return he.documents?e.jsx("div",{onClick:()=>F(`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 ht(ye);case"full_name":return e.jsx("span",{onClick:()=>ee(he),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:ye||`${he.firstname} ${he.lastname}`});case"extra_curricular_activity":return ye==="Yes"?"Extra Subject":"Fees Master";case"is_active":return ye==="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(s.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:()=>Y(he.id,he),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return e.jsx("span",{onClick:()=>ne(he.id,he),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return e.jsx(s.Tag,{onClick:()=>x?.(he.id),color:ye==="paid"?"#66aa18":ye==="partially_paid"?"#ff5722":"#DC143C",children:ye==="paid"?"Paid":ye==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return Vd().find(Te=>Te.value===ye)?.label;case"status":return e.jsx("span",{onClick:()=>x?.(he?.fk_staffID,he?.total_leave),className:`label ${ye==="due"?"label-danger":"label-success"}`,style:{cursor:"pointer"},children:ye==="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(lo,{html:he.ec_no,onBlur:Te=>me(he.id,he.admission_no,Te.target.innerHTML,ie)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(s.Button,{type:"primary",icon:e.jsx(X.SendOutlined,{}),size:"small",onClick:()=>se(he.id,!0,te.name),children:te.name});case"Button":return e.jsx(s.Tag,{color:"cyan",onClick:()=>x?.(he),children:te.name});default:return ye}}})),...a?[{title:"Action",key:"action",render:(te,ye)=>{const he=ye?.current_status==="Promoted",Te=()=>{if(j=="sameAddUpdate"){se(ye,!0);return}if(j?.type==="examEdit"){j.editFunc(ye.id);return}se(ye.id||ye,!0)},Re=()=>{if(j==="student_result"){x?.(ye);return}if(j==="student"){x?.(ye.id,ye.class_id);return}x?.(ye.id)},ft=()=>{b?.(ye?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[u?.[0]?.status&&e.jsx(s.Button,{icon:e.jsx(X.EditOutlined,{}),size:"small",disabled:he,onClick:Te}),u?.[1]?.status&&e.jsx(s.Button,{icon:e.jsx(X.DeleteOutlined,{}),size:"small",danger:!0,disabled:he,onClick:ft}),u?.[2]?.status&&e.jsx(s.Button,{icon:e.jsx(X.EyeOutlined,{}),size:"small",onClick:Re})]})}}]:[]],Fe=i.useMemo(()=>l?Array.isArray(l?.data)?l.data:Array.isArray(l)?l:[]:[],[l]),Ee=i.useMemo(()=>{const te=P.trim().toLowerCase();return te?Fe.filter(ye=>Object.values(ye??{}).some(he=>String(he??"").toLowerCase().includes(te))):Fe},[Fe,P]),Ke=!!t.parentCallback,Ve=P?Ee.length:l?.pagination?.total_rows??Ee.length,Ue=(k.page-1)*k.rowsPerPage,We=Ke?Ee:Ee.slice(Ue,Ue+k.rowsPerPage),pt=i.useMemo(()=>(We??[]).map((te,ye)=>({...te??{},__serialNumber:Ue+ye+1})),[Ue,We]),fe=Ve===0?0:Math.min(Ue+1,Ve),be=Ve===0?0:Math.min(Ue+We.length,Ve);let ge;return d?ge=e.jsx("p",{children:"Loading..."}):c?ge=e.jsx("p",{children:c.message}):We.length?ge=e.jsx(s.Table,{dataSource:pt,columns:Pe,size:"small",bordered:!0,pagination:!1,rowSelection:g,rowKey:(te,ye)=>te?.id??te?._id??ye,scroll:{x:"max-content"}}):ge=e.jsx(s.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(s.Drawer,{open:y,placement:"right",onClose:()=>r?.(!1),width:720,children:ve()}),e.jsx(s.Modal,{title:"Update Password",open:A,onCancel:()=>O(!1),footer:null,children:e.jsx("form",{onSubmit:oe,children:e.jsxs(le,{children:[e.jsx(le,{style:{marginBottom:12},children:e.jsx(J,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(le,{style:{marginTop:16},children:e.jsx(s.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(s.Modal,{title:" Update Credential",open:q,onCancel:()=>U(!1),footer:null,children:e.jsx("form",{onSubmit:Ce,children:e.jsxs(le,{children:[e.jsx(le,{style:{marginBottom:12},children:e.jsx(J,{type:"text",label:"User Name",name:"username",required:"required",value:w?.username?w?.username:"",onChange:te=>f({...w,username:te.target.value})})}),e.jsx(le,{style:{marginBottom:12},children:e.jsx(J,{label:"Password",name:"password",required:"required",value:w?.password?w?.password:"",onChange:te=>f({...w,password:te.target.value})})}),e.jsx(le,{style:{marginTop:16},children:e.jsx(s.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(s.Modal,{open:R,onCancel:E,footer:null,centered:!0,width:"80%",className:I.modal,children:e.jsxs("div",{style:{position:"relative"},className:I.img,children:[e.jsx(s.Image,{src:p,alt:"",style:{width:"100%"},preview:!1}),e.jsx(s.Button,{type:"text",icon:e.jsx(X.CloseOutlined,{}),onClick:E,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),e.jsxs(s.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,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:`
|
|
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(k),null," "));var re=ve(W,me,Y,ne,H+".
|
|
|
56
56
|
.ubk-table-shell .ant-pagination .ant-pagination-next button:hover {
|
|
57
57
|
color: #8f99ff;
|
|
58
58
|
}
|
|
59
|
-
`}),e.jsx(le,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(dn,{data:{tableRef:$}})})}),e.jsxs("div",{className:"ubk-table-shell",ref:$,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(s.Select,{size:"small",value:k.rowsPerPage,onChange:te=>B(1,te),options:[10,25,50,100].map(te=>({label:te,value:te})),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(s.Input,{size:"small",allowClear:!0,value:P,onChange:te=>{N(te.target.value),T(ye=>({...ye,page:1}))},placeholder:"Enter search keyword",prefix:e.jsx(X.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(_t,{})}),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 ${be} of ${Ve} entries`}),e.jsx(s.Pagination,{current:k.page,pageSize:k.rowsPerPage,total:Ve||0,showSizeChanger:!1,onChange:B})]})]})]})},Zd=({token:t,type:n})=>{const[a,r]=i.useState({page:1,rowsPerPage:10}),o="api/branchapi/frontoffice/enquirytablelist",l=o.includes("?")?o.endsWith("?")||o.endsWith("&")?"":"&":"?",d=`${o}${l}page=${a.page}&per_page=${a.rowsPerPage}`,{isLoading:c,data:b,error:y}=G(t?[d,t]:null,([R,D])=>Q(R,D)),[u,x]=i.useState(!1),j=(R,D)=>{r({page:R,rowsPerPage:parseInt(D)})},C=async R=>{},m=R=>{console.log("dsdsdsdsd",R),x(R)},h=()=>{},g=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],I=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(R,D)=>R.name.localeCompare(D.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(R,D)=>(R.contact||"").localeCompare(D.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(R,D)=>(R.description||"").localeCompare(D.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(R,D)=>(R.source_name||"").localeCompare(D.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(R,D)=>new Date(R.date)-new Date(D.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(R,D)=>new Date(R.follow_up_date)-new Date(D.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Le,{parentCallback:j,data:{newData:b,columns:I,action:!0,Loading:c,error:y,open:u,viewDetails:h,deleteTodoMutation:C,DrawerUpdate:m,ActionView:g}})})},ec={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"},de=i.forwardRef(({error:t,success:n,disabled:a,style:r,...o},l)=>e.jsx("div",{className:"form-group",style:{marginBottom:0},children:e.jsx("input",{...o,ref:l,disabled:a,style:{...ec,opacity:a?.7:1,cursor:a?"not-allowed":"pointer",...r||{}}})})),ot=({id:t,funcName:n,disabled:a=!1})=>{const r="Data",[o,l]=i.useState(!1),d=()=>{l(!0),n(t),s.message.success(`${r} deleted successfully!`)},c=()=>{s.message.info(`Deletion of ${r} cancelled`)};return e.jsx(s.Popconfirm,{title:`Delete ${r}?`,description:`Are you sure you want to delete ${r}?`,onConfirm:d,onCancel:c,okText:"Yes",cancelText:"No",disabled:a||o,children:e.jsx(s.Button,{danger:!0,disabled:a,loading:o,icon:e.jsx(X.DeleteOutlined,{}),size:"small"})})},st=t=>({optimisticData:n=>[...n.data,t],populateCache:(n,a)=>[...a.data,n]}),Qe=t=>({optimisticData:n=>n.data.filter(a=>a.id!==t),populateCache:(n,a)=>a.data.filter(r=>r.id!==t)}),Rr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function tc({token:t}){const[n,a]=i.useState({pagination:{current:1,pageSize:10}}),[r,o]=i.useState(!1),[l,d]=i.useState(null),c=`api/branchapi/Transport/routeTableList?page=${n.pagination.current}&per_page=${n.pagination.pageSize}`,b="api/branchapi/Transport/addroute",y="api/branchapi/Transport/editroute",u="api/branchapi/Transport/deleteroute",{isLoading:x,data:j,error:C,mutate:m}=G(t?[c,t]:null,([A,O])=>Q(A,O)),h=async(A,O)=>{try{await m(Ye(A,O,t),st(O)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},g=A=>{A.preventDefault();const O=new FormData(A.target);h(b,O),A.target.reset()},I=(A,O)=>{a(q=>({...q,pagination:{current:A,pageSize:parseInt(O,10)}}))},R=async A=>{try{await m(at(u,A,t),Qe(A)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},D=A=>{d(A),o(!0)},w=async A=>{try{await ut(y,A,t),await m(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},f=async A=>{A.preventDefault();const O=new FormData(A.target);O.append("id",l?.id),w(O)},p=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(A,O)=>A.name.localeCompare(O.route_title)}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(A,O)=>A.fare-O.fare}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(A,O)=>A.note.localeCompare(O.note)}},{title:"Action",key:"action",render:(A,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(O),style:{padding:2}}),e.jsx(ot,{id:O?.id,funcName:R})]})}],S=l?.route_title?`Edit ${l.route_title}`:"Edit Route";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:r,title:S,placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:f,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"title",label:"Title",defaultValue:l?.route_title||"",required:"required"}),e.jsx(J,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:l?.fare||"",required:"required"}),e.jsx(J,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsx("div",{style:{display:"none"},children:e.jsx(J,{type:"text",name:"no_of_vehicle",label:"Note"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Rr,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(le,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsx("div",{children:e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Route"})}),e.jsx(le,{px:3,pb:2,children:e.jsx("form",{onSubmit:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(J,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"}),e.jsx(J,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"}),e.jsx(J,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",style:Rr,children:"Cancel"})]})]})})})]})}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Route List"})}),e.jsx(le,{children:e.jsx(Le,{parentCallback:I,data:{newData:j,columns:p,columnstype:"antd",action:!1,Loading:x,error:C,deleteTodoMutation:R}})})]})})]})})]})}const Ir={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function nc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),c=`api/branchapi/Transport/vehiclesTableList?page=${n.page}&per_page=${n.rowsPerPage}`,b="api/branchapi/Transport/addvehicles",y="api/branchapi/Transport/editvehicle",u="api/branchapi/Transport/deletevehicle",{isLoading:x,data:j,error:C,mutate:m}=G(t?[c,t]:null,([A,O])=>Q(A,O)),h=async(A,O)=>{try{await m(Ye(A,O,t),st(O)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},g=A=>{A.preventDefault();const O=new FormData(A.target);h(b,O),A.target.reset()},I=async A=>{try{await m(at(u,A,t),Qe(A)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},R=A=>{d(A),o(!0)},D=async A=>{try{await ut(y,A,t),await m(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},w=async A=>{A.preventDefault();const O=new FormData(A.target);O.append("id",l?.id),D(O)},f=(A,O)=>{a({page:A,rowsPerPage:parseInt(O,10)})},p=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(A,O)=>A.vehicle_no.localeCompare(O.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(A,O)=>A.vehicle_model.localeCompare(O.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(A,O)=>A.seating_capacity-O.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(A,O)=>A.manufacture_year-O.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(A,O)=>A.gps_url.localeCompare(O.gps_url)},render:(A,O)=>e.jsx("span",{title:O?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:O?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(A,O)=>A.note.localeCompare(O.note)}},{title:"Action",key:"action",render:(A,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>R(O),style:{padding:2}}),e.jsx(ot,{id:O?.id,funcName:I})]})}],S=l?.vehicle_no?`Edit ${l.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:r,title:S,placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:w,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"number",label:"Vehicle Number",defaultValue:l?.vehicle_no||"",required:"required"}),e.jsx(J,{type:"text",name:"model",label:"Vehicle Model",defaultValue:l?.vehicle_model||""}),e.jsx(J,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:l?.manufacture_year||""}),e.jsx(J,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:l?.seating_capacity||""}),e.jsx(J,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:l?.gps_url||""}),e.jsx(J,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Ir,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(le,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(le,{px:3,pb:2,children:e.jsx("form",{onSubmit:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(J,{type:"text",name:"number",label:"Vehicle Number",required:"required"}),e.jsx(J,{type:"text",name:"model",label:"Vehicle Model"}),e.jsx(J,{type:"number",name:"manufacture_year",label:"Manufacture Year"}),e.jsx(J,{type:"number",name:"seating_capacity",label:"Max Seating Capacity"}),e.jsx(J,{type:"text",name:"gps_url",label:"Gps Url"}),e.jsx(J,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",style:Ir,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(le,{children:e.jsx(Le,{parentCallback:f,data:{newData:j,columns:p,columnstype:"antd",action:!1,Loading:x,error:C,deleteTodoMutation:I}})})]})})]})})]})}var ac=oo();const as=so(ac),mo=()=>{};class Fs extends i.Component{state={value:this.props.value||this.props.defaultValue||""};selectRef=null;setSelectRef=n=>{this.selectRef=n};componentDidUpdate(n){n.value!==this.props.value&&this.setState({value:this.props.value})}onChange=(n,a)=>{this.props.onChange(n,a),this.setState({value:n})};getValue=()=>{const{value:n}=this.state;return n?Array.isArray(n)?n.length?"valid":"":typeof n=="object"?n.value||"":n:""};render(){const{SelectComponent:n,required:a,...r}=this.props;console.log("sdsdsfsdddddddd",{...r});const{isDisabled:o}=this.props,l=!o;return e.jsxs("div",{children:[e.jsx(n,{...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:mo,onFocus:()=>this.selectRef.focus(),required:a})]})}}Fs.defaultProps={onChange:mo};Fs.protoTypes={selectComponent:as.func.isRequired,onChange:as.func,required:as.bool};const sc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},rc={menuPortal:t=>({...t,zIndex:9999}),control:(t,n)=>({...t,minHeight:40,height:40,fontSize:"14px",border:"none",borderBottom:`1px solid ${n.isFocused?"#222":"#d9d9d9"}`,borderRadius:0,boxShadow:"none",backgroundColor:"transparent",transition:"border-color 0.2s ease","&:hover":{border:"none",borderBottom:`1px solid ${n.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,n)=>({...t,padding:"0 0 0 8px",color:n.isFocused?"#222":"#b5b5b5"}),singleValue:t=>({...t,color:"#222",marginLeft:0}),placeholder:t=>({...t,color:"#9f9f9f",marginLeft:0}),option:(t,n)=>({...t,fontSize:"14px",backgroundColor:n.isFocused?"#f8f8f8":"#fff",color:"#222",cursor:"pointer"})},yo=t=>e.jsx(Pi.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),ic=t=>e.jsx(Fs,{...t,SelectComponent:Pi,components:{Input:yo},options:t.options}),Z=i.forwardRef(({...t},n)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:sc,children:t?.label}),e.jsx(ic,{components:{Input:yo},menuPortalTarget:document.body,styles:rc,className:"input-cont",...t,ref:n})]})),oc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Dr=({dataIndex:t,title:n,record:a,children:r,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});function lc({token:t}){const[n,a]=i.useState(!1),[r,o]=i.useState({pagination:{current:1,pageSize:50}}),[l,d]=i.useState(null),[c,b]=i.useState([]),y="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleDropdown",x="api/branchapi/Transport/getchechkedVehicleData",j="api/branchapi/Transport/assignedVehicleTable",C="api/branchapi/transport/assignvehicle",m="api/branchapi/Transport/deleteassignvehicle",h=l?`${x}?route_id=${l}`:null,{isLoading:g,data:I,mutate:R}=G(t?[`${j}?page=${r.pagination.current}&per_page=${r.pagination.pageSize}`,t]:null,([T,$])=>Q(T,$)),{data:D}=G(t&&y?[y,t]:null,([T,$])=>Q(T,$)),{data:w}=G(t&&u?[u,t]:null,([T,$])=>Q(T,$)),f=t&&h?[h,t]:null,{isLoading:p,data:S}=G(f,([T,$])=>Q(T,$)),{Status:A="Failed",pagination:{total_rows:O=0}={}}=I||{},{data:q=[]}=A==="Success"?I:{},U=i.useMemo(()=>{const T=D?.data??D??[];return Array.isArray(T)?T:[]},[D]),v=i.useMemo(()=>{const T=w?.data??w??[];return(Array.isArray(T)?T:[]).map(B=>{if(B==null)return null;if(typeof B=="string"||typeof B=="number")return{label:String(B),value:B};const Y=B.value??B.vehicle_id??B.id??B.vehicleID,ne=B.label??B.vehicle_name??B.vehicle_no??B.vehicle_number??B.name??String(Y??"");return Y==null||ne===""?null:{label:String(ne),value:Y}}).filter(Boolean)},[w]),M=i.useMemo(()=>{const T=S?.data??S??[];return(Array.isArray(T)?T:[]).map(B=>B?.value??B?.vehicle_id??B?.id??B).filter(B=>B!=null)},[S]);i.useEffect(()=>{b(M)},[M,n]);const P=async(T,$,B)=>{try{await R(Ye(T,$,t),st($)),h&&G.mutate(f),a(Y=>!Y),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(Y){_.error(Y?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},N=T=>{T.preventDefault();const $=new FormData;$.append("route_id",l??""),c.length?c.forEach(B=>$.append("vehicle_ids[]",B)):$.append("vehicle_ids[]",""),P(C,$)},E=T=>{o($=>({...$,pagination:{current:T,pageSize:$.pagination.pageSize}}))},F=async T=>{try{await R(at(m,T,t),Qe(T)),h&&G.mutate(f),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},L=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(T,$,B)=>e.jsx(e.Fragment,{children:$.children.map((Y,ne,H)=>e.jsx("span",{children:`${Y.vehicle_name} ${ne+1===H.length?"":","}`},`${ne}vehicle001`))})},{title:"Action",render:(T,$,B)=>e.jsx(e.Fragment,{children:e.jsx(ot,{id:$?.route_id,funcName:F})})}],z=T=>{const $=["route_id","index"];for(let B=0;B<$.length;B++)if(T[$[B]])return T[$[B]]},k=T=>{const{children:$=[]}=T||{},B=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:Y=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:Y=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:Y=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:Y=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:Y=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:Y=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:Y=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(s.Table,{components:{body:{cell:Dr}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:B,rowKey:Y=>z(Y)+"cell01",dataSource:$,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(le,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(le,{px:3,pb:2,children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(Z,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:T=>{d(T?.value??null),a($=>!$)}})}),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(s.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:v,value:c,onChange:T=>b(T),disabled:!l||p})},`check001${n}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),b([]),a(T=>!T)},style:oc,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(le,{style:{padding:"10px 16px"},children:e.jsx(s.Table,{components:{body:{cell:Dr}},columns:L,bordered:!0,rowKey:T=>z(T),dataSource:Array.isArray(q)?q:[],loading:g,expandable:{expandedRowRender:k,childrenColumnName:"changed"},pagination:{current:r.pagination.current,pageSize:r.pagination.pageSize,total:O,showSizeChanger:!0,onChange:E,onShowSizeChange:(T,$)=>{o(B=>({...B,pagination:{current:1,pageSize:$}}))},showTotal:(T,$)=>`${$[0]}-${$[1]} of ${T} items`}})})]})})]})})]})}const dc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},cc={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},uc=(t,n,a)=>n?t>ae(a).endOf("day")||t<ae(n).endOf("day"):!1,gt=i.forwardRef(function(n,a){const{...r}=n;return e.jsxs("div",{className:"form-group",children:[r.Desplay&&e.jsx("label",{className:`labelfont ${r.classnme?r.classnme:""}`,style:dc,children:r.Desplay}),e.jsx(s.DatePicker,{...r,style:{...cc,...r.style||{}},className:"form-group",disabledDate:o=>uc(o,r.sessionStart||r.minDate?.subtract(1,"day").format("YYYY-MM-DD"),r.sessionEnd||r.maxDate?.format("YYYY-MM-DD")),required:!0,ref:a})]})}),kr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ss=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Jt=(t,n,a)=>{if(n==null||n==="")return null;const r=t.find(o=>String(o.value)===String(n));return r||(a?{label:String(a),value:n}:{label:String(n),value:n})},pc=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},mc=t=>{if(t==null||t===""||t==="null"||t==="undefined")return"";if(Array.isArray(t))return t.filter(a=>a!=null&&a!==""&&String(a).toLowerCase()!=="null"&&String(a).toLowerCase()!=="undefined").join(", ");const n=String(t).trim();return!n||n.toLowerCase()==="null"||n.toLowerCase()==="undefined"?"":n};function yc({token:t,assignmentId:n,studentName:a,onClose:r,onSuccess:o}){const l="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",c="api/branchapi/Transport/getrouteDropdown",b="api/branchapi/Transport/getvehicleListByRouteIdwithCount",y="api/branchapi/Transport/getStoppageDropdown",u="api/branchapi/Transport/routeShowdata",[x,j]=i.useState(null),[C,m]=i.useState(null),[h,g]=i.useState(null),[I,R]=i.useState(ae()),[D,w]=i.useState(""),[f,p]=i.useState(0),[S,A]=i.useState(0),{data:O,isLoading:q}=G(t&&n?[`${l}?id=${n}`,t]:null,([V,oe])=>Q(V,oe)),U=i.useMemo(()=>{if(!O||O?.Status&&O.Status!=="Success")return null;const V=O?.data??O;return Array.isArray(V)?V[0]??null:V},[O]);i.useEffect(()=>{const V=U?.fk_route_id??U?.route_id;V!=null&&j(V),U?.vehicle_id!=null&&m(U.vehicle_id),U?.stop_id!=null&&g(U.stop_id),R(U?.start_date?ae(U.start_date):ae()),w(mc(U?.service_push))},[U]);const v=t&&x?`${b}?route_id=${x}`:null,M=t&&x?`${u}?id=${x}`:null,P=t&&x?`${y}?route_id=${x}`:null,{data:N}=G(t&&c?[c,t]:null,([V,oe])=>Q(V,oe)),{data:E,isLoading:F}=G(v?[v,t]:null,([V,oe])=>Q(V,oe)),{data:L,isLoading:z}=G(P?[P,t]:null,([V,oe])=>Q(V,oe)),{data:k}=G(M?[M,t]:null,([V,oe])=>Q(V,oe)),T=i.useMemo(()=>ss(N),[N]),$=i.useMemo(()=>ss(E),[E]),B=i.useMemo(()=>ss(L),[L]),Y=O?.data[0]?.rootCost,ne=pc(),H=a||[U?.firstname,U?.lastname].filter(Boolean).join(" ")||"",W=(V,oe)=>{switch(oe){case"route_id":j(V?.value??null),m(null),g(null),p(Ce=>Ce+1),A(Ce=>Ce+1);break;case"vehicle_id":m(V?.value??null),g(null),A(Ce=>Ce+1);break;case"stop_id":g(V?.value??null);break}},ee=async V=>{if(V.preventDefault(),!x||!C||!h){_.error("Please select Route, Vehicle and Stop",{duration:1200});return}const oe=new FormData;oe.append("id",String(n)),oe.append("student_id",String(U?.fk_student_id??U?.student_id??"")),oe.append("fk_route_id",String(x)),oe.append("vehicle_id",String(C)),oe.append("stop_id",String(h)),oe.append("rootCost",String(Y??"")),oe.append("start_date",I?.isValid?.()?I.format("YYYY-MM-DD"):ae().format("YYYY-MM-DD")),oe.append("puse_service",String(D??""));try{await ut(d,oe,t),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o?.(),r?.()}catch(Ce){_.error(Ce?.message??"Failed to update the item.",{duration:1e3})}};if(q||!(U&&!q&&(!x||!F&&!z)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(s.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(s.Button,{type:"text",onClick:r,style:kr,children:"Close"})]});const me=U.fk_route_id??U.route_id,ve=Jt(T,me,U.route_title),re=Jt($,U.vehicle_id,U.vehicle_name??U.vehicle_no),ie=Jt(B,U.stop_id,U.stop_name??U.stoppage_name);return e.jsx("form",{onSubmit:ee,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"title",label:"Student",defaultValue:H,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:U.fk_student_id??U.student_id??""}),e.jsx(Z,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:Jt(T,x,ve?.label)??null,onChange:V=>W(V,"route_id")}),e.jsx(Z,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:Jt($,C,re?.label)??null,onChange:V=>W(V,"vehicle_id")},`edit-vehicle-${f}`),e.jsx(Z,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:Jt(B,h,ie?.label)??null,onChange:V=>W(V,"stop_id")},`edit-stop-${S}`),e.jsx(J,{type:"text",label:"Route Cost",value:Y!=null?`${ne}${Y}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:Y??""}),e.jsx(gt,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:I,onChange:V=>R(V)}),e.jsx(J,{type:"text",label:"Pause Service",value:D,onChange:V=>w(V?.target?.value??""),placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:r,style:kr,children:"Cancel"})]})]})},`edit-${n}-${f}`)}const Or={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},fc=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[]},hn=t=>fc(t),hc=t=>t||"",gc=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},xc=t=>{const n=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return n==="page"||n==="sendpage"?"page":"drawer"},bc=(t,n)=>{const a=n||"/TransportDashboard/EditAssignStudentTransport?id={id}",r=t?.id??"",o=encodeURIComponent(String(r));if(a.includes("{id}"))return a.replaceAll("{id}",o);if(a.includes(":id"))return a.replace(":id",o);try{const d=new URL(a,"http://localhost");if(d.searchParams.has("id"))return d.searchParams.set("id",String(r)),`${d.pathname}${d.search}${d.hash}`}catch{}const l=a.includes("?")?"&":"?";return`${a}${l}id=${o}`};function Sc({token:t,editType:n,onNavigate:a,editPagePath:r}){const l=xc(n)==="drawer",d="api/branchapi/academy/classdropdownlist",c="api/branchapi/academy/sectionoftheClass",b="api/branchapi/Transport/routeStudentList",y="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleListByRouteIdwithCount",x="api/branchapi/Transport/getStoppageDropdown",j="api/branchapi/Transport/routeShowdata",C="api/branchapi/Transport/assignTransportRoutesStudent",m="api/branchapi/transport/removeStudentTransport",[h,g]=i.useState(null),[I,R]=i.useState(!1),[D,w]=i.useState(!1),[f,p]=i.useState(null),[S,A]=i.useState(null),[O,q]=i.useState(null),[U,v]=i.useState(null),[M,P]=i.useState(!1),[N,E]=i.useState(!1),[F,L]=i.useState({page:1,rowsPerPage:50}),[z,k]=i.useState(null),[T,$]=i.useState(!1),[B,Y]=i.useState(null),[ne,H]=i.useState(null),[W,ee]=i.useState(null),[se,me]=i.useState(null),[ve,re]=i.useState(null),[ie,V]=i.useState(null),[oe,Ce]=i.useState(null),[Oe,Pe]=i.useState(ae()),[Fe,Ee]=i.useState(""),Ke=(ue,xe)=>{const ke=ue?.value??null;switch(xe){case"class_id":ee(ke),me(null),k(ke?`${c}?class_id=${encodeURIComponent(String(ke))}`:null),R(Be=>!Be);break;case"route_id":re(ke),V(null),Ce(null),H(ke),A(ke?`${u}?route_id=${encodeURIComponent(String(ke))}`:null),q(ke?`${j}?id=${encodeURIComponent(String(ke))}`:null),v(null),P(Be=>!Be),E(Be=>!Be);break;case"vehicle_id":V(ke),Ce(null),v(ve?`${x}?route_id=${encodeURIComponent(String(ve))}`:null),E(Be=>!Be);break;case"stop_id":Ce(ke);break}},Ve=ue=>{if(l){p(ue),w(!0);return}const xe=bc(ue,r);if(typeof a=="function"){a(xe,ue);return}typeof window<"u"&&xe&&window.location.assign(xe)},Ue=()=>{w(!1),p(null)},We=f?`Edit — ${f.firstname??""} ${f.lastname??""}`.trim():"Edit Student Transport",{data:pt}=G(t&&d?[d,t]:null,([ue,xe])=>Q(ue,xe)),{data:fe}=G(t&&z?[z,t]:null,([ue,xe])=>Q(ue,xe)),{data:be}=G(t&&S?[S,t]:null,([ue,xe])=>Q(ue,xe)),{data:ge}=G(t&&U?[U,t]:null,([ue,xe])=>Q(ue,xe)),{data:te}=G(t&&O?[O,t]:null,([ue,xe])=>Q(ue,xe)),{data:ye}=G(t&&y?[y,t]:null,([ue,xe])=>Q(ue,xe)),he=t&&h?`${h}&page=${F.page}&per_page=${F.rowsPerPage}`:null,{isLoading:Te,error:Re,data:ft,mutate:Ct}=G(he?[he,t]:null,([ue,xe])=>Q(ue,xe)),At=i.useMemo(()=>hn(pt),[pt]),Wt=i.useMemo(()=>hn(fe),[fe]),Vt=i.useMemo(()=>hn(be),[be]),Ht=i.useMemo(()=>hn(ge),[ge]),pe=i.useMemo(()=>hn(ye),[ye]),Se=te?.data?.[0]?.fare??te?.data?.fare??te?.fare??te?.data?.data?.[0]?.fare??te?.data?.data?.fare;console.log("aaaaaaaaaaaa",te),i.useEffect(()=>{Se==null||Se===""||Ee(String(Se))},[Se]);const Ge=async ue=>{try{await Ct(at(m,ue,t),Qe(ue)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},St=[{title:"Route Status",key:"route_status",render:(ue,xe)=>xe.fk_route_id?e.jsx("span",{children:xe.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(ue,xe)=>hc(xe.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:(ue,xe)=>`${xe.firstname} ${xe.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(ue,xe)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:xe.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(ot,{id:xe?.id,funcName:Ge}),e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>Ve(xe),style:{padding:2}})]}):e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.PlusOutlined,{}),onClick:()=>za(xe.student_id),style:{padding:2}})})}],Ba=async(ue,xe)=>{try{await Ct(Ye(ue,xe,t),st(xe)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),$(!1),ce()}catch{_.error("Failed to add the new item.",{duration:1e3})}},La=ue=>{if(ue.preventDefault(),!W||!se){_.error("Please select Class and Section",{duration:1200});return}g(`${b}?cID=${encodeURIComponent(String(W))}&sID=${encodeURIComponent(String(se))}`),L(xe=>({...xe,page:1}))},qa=(ue,xe)=>{L({page:ue,rowsPerPage:parseInt(xe,10)})},za=ue=>{Y(ue),$(!0)},Ya=ue=>{if(ue.preventDefault(),!B){_.error("Student is required",{duration:1200});return}if(!ve||!ie||!oe){_.error("Please select Route, Vehicle and Stop",{duration:1300});return}const xe=new FormData;xe.append("student_id",String(B)),xe.append("fk_route_id",String(ve)),xe.append("vehicle_id",String(ie)),xe.append("stop_id",String(oe)),xe.append("start_date",Oe?.isValid?.()?Oe.format("YYYY-MM-DD"):ae().format("YYYY-MM-DD")),xe.append("rootCost",String(Fe??"")),Ba(C,xe)},ce=()=>{$(!1),A(null),q(null),v(null),H(null),re(null),V(null),Ce(null),Pe(ae()),Ee(""),P(ue=>!ue),E(ue=>!ue)},je=gc();return e.jsxs("div",{children:[l&&e.jsx(s.Drawer,{open:D,title:We,placement:"right",width:420,destroyOnClose:!0,onClose:Ue,children:f?.id&&e.jsx(yc,{token:t,assignmentId:f.id,studentName:`${f.firstname??""} ${f.lastname??""}`.trim(),onClose:Ue,onSuccess:()=>Ct()})}),e.jsx(s.Modal,{open:T,title:"Assign Student to Transport",onCancel:ce,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:Ya,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20},children:[e.jsx(Z,{options:pe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:pe.find(ue=>String(ue.value)===String(ve))??null,onChange:ue=>Ke(ue,"route_id")}),e.jsx(Z,{options:Vt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:Vt.find(ue=>String(ue.value)===String(ie))??null,onChange:ue=>Ke(ue,"vehicle_id")},`vehicle001${M}`),e.jsx(Z,{options:Ht,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:Ht.find(ue=>String(ue.value)===String(oe))??null,onChange:ue=>Ke(ue,"stop_id")},`stop001${N}`),e.jsx(gt,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:Oe,onChange:ue=>Pe(ue)}),e.jsx(J,{type:"text",name:"rootCost",label:"Route Cost",value:Fe,onChange:ue=>Ee(ue?.target?.value??"")}),e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:String(Fe??"").trim()?`${je}${Fe} — Assign`:"Assign",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:ce,style:Or,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(le,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Search Students"})}),e.jsx(le,{px:3,pb:2,children:e.jsx("form",{onSubmit:La,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:At,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:ue=>Ke(ue,"class_id"),required:!0,allowSelectAll:!1,value:At.find(ue=>String(ue.value)===String(W))??null}),e.jsx(Z,{options:Wt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:Wt.find(ue=>String(ue.value)===String(se))??null,onChange:ue=>me(ue?.value??null)},`section1${I}`),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Search",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{g(null),k(null),ee(null),me(null),R(ue=>!ue)},style:Or,children:"Cancel"})]})]})})})]}),h&&e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Student List"})}),e.jsx(le,{children:e.jsx(Le,{parentCallback:qa,data:{newData:ft,columns:St,columnstype:"antd",action:!1,Loading:Te,error:Re,deleteTodoMutation:Ge,pageController:F}})})]})})]})})]})}const Pr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Hn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function jc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,b]=i.useState(""),[y,u]=i.useState(""),[x,j]=i.useState(""),[C,m]=i.useState(!1),h=`api/branchapi/Transport/getdriverTable?page=${n.page}&per_page=${n.rowsPerPage}`,g="api/branchapi/Transport/add_driver",I="api/branchapi/Transport/edit_driver",R="api/branchapi/Transport/deletedriver",D="api/branchapi/staff/uploadDocuments",w=i.useMemo(()=>String(D).startsWith("http")?D:`${nt()??""}${String(D).replace(/^\/+/,"")}`,[D]),f=nt()??"",{isLoading:p,data:S,error:A,mutate:O}=G(t?[h,t]:null,([z,k])=>Q(z,k)),q=async(z,k)=>{try{await Ye(z,k,t),await O(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),b("")}catch(T){_.error(T?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},U=z=>{z.preventDefault();const k=new FormData(z.target);q(g,k),z.target.reset()},v=async z=>{try{await O(at(R,z,t),Qe(z)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},M=z=>{d(z),b(z?.image??""),o(!0)},P=async z=>{try{await ut(I,z,t),await O(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),b("")}catch(k){_.error(k?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},N=z=>{z.preventDefault();const k=new FormData(z.target);k.append("id",l?.id??""),P(k)},E=(z,k)=>{a({page:z,rowsPerPage:parseInt(k,10)})},F=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(z,k)=>String(z?.name??"").localeCompare(String(k?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(z,k)=>String(z?.Driver_licence??"").localeCompare(String(k?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(z,k)=>Number(z?.contact_number??0)-Number(k?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(z,k)=>String(z?.address??"").localeCompare(String(k?.address??""))}},{title:"Image",key:"image",width:100,render:(z,k)=>{const T=k?.image?`${f}staff/document/${k.image}`:"";return T?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(s.Image,{width:80,src:T,preview:{visible:!1,onVisibleChange:()=>{m(!0),u(T),j(k?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(z,k)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>M(k),style:{padding:2}}),e.jsx(ot,{id:k?.id,funcName:v})]})}],L=l?.name?`Edit ${l.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:r,title:L,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{o(!1),d(null),b("")},children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"name",label:"Driver Name",defaultValue:l?.name??"",required:"required"}),e.jsx(J,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:l?.Driver_licence??"",required:"required"}),e.jsx(J,{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:Hn,children:"Address"}),e.jsx(s.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:Hn,children:"Image"}),e.jsx(s.Upload,{maxCount:1,action:w,headers:t?{Authorization:t}:void 0,onChange:z=>{if(z?.file?.status!=="done")return;const k=z?.file?.response,T=k?.data??k?.filename??k?.file??k?.path??"";T&&b(String(T))},children:e.jsx(s.Button,{icon:e.jsx(X.UploadOutlined,{}),disabled:!w,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),b("")},style:Pr,children:"Cancel"})]})]})})}),e.jsx(s.Modal,{zIndex:9999,open:C,title:x,footer:null,onCancel:()=>m(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:y})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(le,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(le,{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(J,{type:"text",name:"name",label:"Driver Name",required:"required"}),e.jsx(J,{type:"text",name:"Driver_licence",label:"Driver Licence",required:"required"}),e.jsx(J,{type:"number",name:"contact_number",label:"Driver Contact",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Hn,children:"Address"}),e.jsx(s.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:Hn,children:"Image"}),e.jsx(s.Upload,{maxCount:1,action:w,headers:t?{Authorization:t}:void 0,onChange:z=>{if(z?.file?.status!=="done")return;const k=z?.file?.response,T=k?.data??k?.filename??k?.file??k?.path??"";T&&b(String(T))},children:e.jsx(s.Button,{icon:e.jsx(X.UploadOutlined,{}),disabled:!w,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",onClick:()=>b(""),style:Pr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(le,{children:e.jsx(Le,{parentCallback:E,data:{newData:S,columns:F,columnstype:"antd",action:!1,Loading:p,error:A,deleteTodoMutation:v}})})]})})]})})]})}const Er={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Qt={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Kn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Mr=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],Gn=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function vc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(!1),[c,b]=i.useState(null),[y,u]=i.useState(null),[x,j]=i.useState(null),[C,m]=i.useState(null),[h,g]=i.useState(ae()),[I,R]=i.useState(ae()),[D,w]=i.useState("pick"),[f,p]=i.useState(!1),[S,A]=i.useState(null),[O,q]=i.useState(null),[U,v]=i.useState(!1),[M,P]=i.useState(null),[N,E]=i.useState(null),[F,L]=i.useState(null),[z,k]=i.useState(null),[T,$]=i.useState(ae()),[B,Y]=i.useState(ae()),[ne,H]=i.useState("pick"),W=`api/branchapi/Transport/assignRouteTimeList?page=${n.page}&per_page=${n.rowsPerPage}`,ee="api/branchapi/Transport/assignRouteTime",se="api/branchapi/Transport/editAssignRouteTime",me="api/branchapi/Transport/deleteAssignRouteTime",ve="api/branchapi/Transport/driverDropdown",re="api/branchapi/transport/routeTimetableShowdata",ie="api/branchapi/Transport/getrouteDropdown",V="api/branchapi/Transport/getvehicleDropdown",{isLoading:oe,data:Ce,error:Oe,mutate:Pe}=G(t?[W,t]:null,([pe,Se])=>Q(pe,Se)),{data:Fe}=G(t&&ie?[ie,t]:null,([pe,Se])=>Q(pe,Se)),{data:Ee}=G(t&&ve?[ve,t]:null,([pe,Se])=>Q(pe,Se)),Ke=i.useMemo(()=>c?`${V}?route_id=${c}`:null,[c,V]),{data:Ve}=G(t&&Ke?[Ke,t]:null,([pe,Se])=>Q(pe,Se)),Ue=i.useMemo(()=>Gn(Fe),[Fe]),We=i.useMemo(()=>Gn(Ee),[Ee]),pt=i.useMemo(()=>Gn(Ve),[Ve]),fe=(pe,Se)=>{a({page:pe,rowsPerPage:parseInt(Se,10)})},be=async pe=>{pe.preventDefault();const Se=new FormData(pe.target);Se.set("route_id",y?.value??c??""),Se.set("driver_id",x?.value??""),Se.set("vehicle_id",C?.value??""),Se.set("start_time",h?h.format("h:mm a"):""),Se.set("drop_time",I?I.format("h:mm a"):""),Se.set("type",D);try{await Ye(ee,Se,t),await Pe(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),pe.target.reset(),b(null),u(null),j(null),m(null),d(Ge=>!Ge),g(ae()),R(ae()),w("pick"),o(Ge=>!Ge)}catch(Ge){_.error(Ge?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},ge=async pe=>{try{await at(me,pe,t),await Pe(),_.success("Success! Deleted item.",{duration:1e3})}catch(Se){_.error(Se?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},te=pe=>{A(pe),p(!0);const Se=pe?.id??pe?.route_time_id??pe?.routeId??null;q(Se);const Ge=pe?.route_id??pe?.routeId??pe?.fk_route_id;P(Ge??null),E(Ue.find(St=>St?.value===(Ge??pe?.route_id))??null),L(We.find(St=>St?.value===(pe?.driver_id??pe?.driverId))??null),k(null),v(St=>!St),$(pe?.start_time?ae(pe.start_time,["h:mm a","HH:mm"]):ae()),Y(pe?.drop_time?ae(pe.drop_time,["h:mm a","HH:mm"]):ae()),H(pe?.type??"pick")},ye=i.useMemo(()=>{if(!O)return null;const pe=String(re).includes("?")?"&":"?";return`${re}${pe}id=${encodeURIComponent(String(O))}`},[O,re]),{data:he,isLoading:Te}=G(t&&ye?[ye,t]:null,([pe,Se])=>Q(pe,Se)),Re=i.useMemo(()=>{const pe=he?.data??he;return Array.isArray(pe)?pe[0]??null:Array.isArray(pe?.data)?pe.data[0]??null:pe??null},[he]),ft=i.useMemo(()=>M?`${V}?route_id=${M}`:null,[M,V]),{data:Ct}=G(t&&ft?[ft,t]:null,([pe,Se])=>Q(pe,Se)),At=i.useMemo(()=>Gn(Ct),[Ct]);i.useEffect(()=>{if(!Re)return;const pe=Re?.route_id??Re?.fk_route_id??Re?.routeId;P(pe??null),E(Ue.find(Se=>Se?.value===pe)??null),L(We.find(Se=>Se?.value===Re?.driver_id)??null),k(null),$(Re?.start_time?ae(Re.start_time,["h:mm a","HH:mm"]):ae()),Y(Re?.drop_time?ae(Re.drop_time,["h:mm a","HH:mm"]):ae()),H(Re?.type??"pick"),v(Se=>!Se)},[We,Re,Ue]),i.useEffect(()=>{if(!Re)return;const pe=Re?.vehicle_id??Re?.vehicleId;pe&&k(At.find(Se=>Se?.value===pe)??null)},[Re,At]);const Wt=async pe=>{if(pe.preventDefault(),!O)return;const Se=new FormData(pe.target);Se.set("id",String(O)),Se.set("route_id",N?.value??M??""),Se.set("driver_id",F?.value??""),Se.set("vehicle_id",z?.value??""),Se.set("start_time",T?T.format("h:mm a"):""),Se.set("drop_time",B?B.format("h:mm a"):""),Se.set("type",ne);try{await ut(se,Se,t),await Pe(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),p(!1),A(null)}catch(Ge){_.error(Ge?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Vt=[{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:(pe,Se)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>te(Se),style:{padding:2}}),e.jsx(ot,{id:Se?.id??Se?.routeId??Se?.route_time_id,funcName:ge})]})}],Ht=S?.route_title?`Edit ${S.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:f,title:Ht,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{p(!1),A(null),q(null),P(null),E(null),L(null),k(null)},children:e.jsx("form",{onSubmit:Wt,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:Te?.6:1},children:[e.jsx(Z,{options:Ue,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:N,onChange:pe=>{P(pe?.value??null),E(pe??null),k(null),v(Se=>!Se)}}),e.jsx(Z,{options:We,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:F,onChange:pe=>L(pe??null)}),e.jsx(Z,{options:At,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:z,onChange:pe=>k(pe??null)},`edit-vehicle-${U}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Qt,children:"Start Time"}),e.jsx(s.TimePicker,{value:T,onChange:pe=>$(pe),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Kn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Qt,children:"Drop Time"}),e.jsx(s.TimePicker,{value:B,onChange:pe=>Y(pe),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Kn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Qt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(s.Radio.Group,{options:Mr,optionType:"button",buttonStyle:"solid",value:ne,onChange:pe=>H(pe.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{p(!1),A(null)},style:Er,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(le,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(le,{px:3,pb:2,children:e.jsx("form",{onSubmit:be,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:Ue,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:y,onChange:pe=>{b(pe?.value??null),u(pe??null),m(null),d(Se=>!Se)},allowSelectAll:!1,required:!0}),e.jsx(Z,{options:We,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:x,onChange:pe=>j(pe??null),allowSelectAll:!1,required:!0}),e.jsx(Z,{options:pt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:C,onChange:pe=>m(pe??null),allowSelectAll:!1,required:!0},`vehicle-${l}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Qt,children:"Start Time"}),e.jsx(s.TimePicker,{value:h,onChange:pe=>g(pe),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Kn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Qt,children:"Drop Time"}),e.jsx(s.TimePicker,{value:I,onChange:pe=>R(pe),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Kn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Qt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(s.Radio.Group,{options:Mr,optionType:"button",buttonStyle:"solid",value:D,onChange:pe=>w(pe.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Add",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",onClick:()=>{b(null),u(null),j(null),m(null),d(pe=>!pe),g(ae()),R(ae()),w("pick"),o(pe=>!pe)},style:Er,children:"Cancel"})]})]})},`form-${r}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(le,{children:e.jsx(Le,{parentCallback:fe,data:{newData:Ce,columns:Vt,columnstype:"antd",action:!1,Loading:oe,error:Oe,deleteTodoMutation:ge}})})]})})]})})]})}const _c={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Fr={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Nr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},$r=({dataIndex:t,title:n,record:a,children:r,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});let Ur=2;function wc({token:t}){const[n,a]=i.useState([]),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,b]=i.useState({pagination:{current:1,pageSize:50}}),{isLoading:y,data:u,mutate:x}=G(t?[`api/branchapi/transport/getrouteStoppageData?page=${c.pagination.current}&per_page=${c.pagination.pageSize}`,t]:null,([P,N])=>Q(P,N)),{Status:j="Failed",pagination:{total_rows:C=0}={}}=u||{},{data:m=[]}=j==="Success"?u:{},{data:h}=G(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([P,N])=>Q(P,N)),g=i.useMemo(()=>{const P=h?.data??h??[];if(Array.isArray(P))return P;if(P&&typeof P=="object"){if(Array.isArray(P?.data))return P.data;if(Array.isArray(P?.data?.data))return P.data.data}return[]},[h]),{data:I}=G(t&&r?["api/branchapi/transport/getrouteStoppageData?route_id="+r,t]:null,([P,N])=>Q(P,N)),{Status:R="Failed"}=I||{},D=async(P,N)=>{try{await x(Ye(P,N,t),st(N)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},w=P=>P?typeof P=="string"?P:P?.isValid?.()?P.format("h:mm a"):"":"",f=(P,N=[])=>{const E=(Array.isArray(P)?P:[]).map(z=>({id:z?.id??"",name:String(z?.stop_name??z?.name??"").trim(),pickTime:w(z?.pickup_time??z?.pickTime??z?.pickupTime),drop_time:w(z?.drop_time??z?.dropTime)})),F=E.filter(z=>z?.id!=null&&String(z.id).trim()!==""),L=E.filter(z=>!(z?.id!=null&&String(z.id).trim()!==""));return{route_id:r??"",edit_stoppage:F,add_stoppage:L,delete_stoppage:Array.isArray(N)?N:[]}},p=P=>{P.preventDefault();const N="/api/branchapi/transport/addstoppageToRoute",E=f(n,l);D(N,E)},S=()=>{a(P=>[...Array.isArray(P)?P:[],{idKey:Ur++,stop_name:"",pickup_time:ae().format("h:mm a"),drop_time:ae().format("h:mm a")}])},A=P=>{if(n.length===1)return;const N=n[P];N?.id!=null&&String(N.id).trim()!==""&&!N?.idKey&&d(E=>{const F=Array.isArray(E)?E:[];return F.some(z=>String(z)===String(N.id))?F:[...F,N.id]}),a(E=>{const F=[...E];return F.splice(P,1),F})},O=P=>{b(N=>({...N,pagination:{current:P,pageSize:N.pagination.pageSize}}))},q=async P=>{const N="/api/branchapi/Transport/deletevehicle";try{await x(at(N,P,t),Qe(P)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}};i.useEffect(()=>{if(R==="Success"){const P=Array.isArray(I?.data)?I.data:[];P.length>0?(a(P),d([])):r&&(a([{idKey:Ur++,stop_name:"",pickup_time:ae().format("h:mm a"),drop_time:ae().format("h:mm a")}]),d([]))}},[R,I,r]);const U=P=>{const{children:N=[]}=P||{},E=[{title:"Stop Name",dataIndex:"stop_name",onCell:F=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:F=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:F=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(s.Table,{components:{body:{cell:$r}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:E,rowKey:F=>v(F)+"cell01",dataSource:N,pagination:!1})})})},v=P=>{const N=["id","index"];for(let E=0;E<N.length;E++)if(P[N[E]])return P[N[E]]},M=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(P,N,E)=>e.jsx(e.Fragment,{children:(Array.isArray(N.children)?N.children:[]).map((F,L,z)=>e.jsx("span",{children:`${F.stop_name} ${L+1===z.length?"":","}`},`${L}vehicle001`))})},{title:"Action",render:(P,N,E)=>e.jsx(e.Fragment,{children:e.jsx(ot,{id:N?.route_id,funcName:q})})}];return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(le,{pt:5,pb:1,children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(le,{px:3,pb:2,children:e.jsxs("form",{onSubmit:p,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(Z,{options:g,value:g.find(P=>String(P.value)===String(r))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:P=>{o(P?.value??null),a([]),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(X.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(de,{type:"submit",value:"Add",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{o(null),a([]),d([])},style:_c,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:n.length>0&&n.map((P,N)=>{const E=P.pickup_time?ae(P.pickup_time,"h:mm a"):null,F=P.drop_time?ae(P.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(J,{value:P.stop_name??"",type:"text",name:`stoppage[${N}][name]`,label:"Place Name*",required:"required",onChange:L=>{const z=L?.target?.value??"";a(k=>{const T=[...k];return T[N]={...T[N]??{},stop_name:z},T})}}),P?.id!=null&&String(P.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${N}][id]`,value:String(P.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Fr,children:"Pick Time"}),e.jsx(s.TimePicker,{value:E,use12Hours:!0,format:"h:mm a",name:`stoppage[${N}][pickTime]`,allowClear:!1,style:Nr,onChange:L=>{const z=L?L.format("h:mm a"):"";a(k=>{const T=[...k];return T[N]={...T[N]??{},pickup_time:z},T})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Fr,children:"Drop Time"}),e.jsx(s.TimePicker,{value:F,use12Hours:!0,format:"h:mm a",name:`stoppage[${N}][drop_time]`,allowClear:!1,style:Nr,onChange:L=>{const z=L?L.format("h:mm a"):"";a(k=>{const T=[...k];return T[N]={...T[N]??{},drop_time:z},T})}})]}),e.jsx("div",{style:{marginBottom:8},children:n.length>1&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer"},onClick:()=>A(N),children:e.jsx(X.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},P.idKey?P.idKey+"exp":P.id+"exp")})})]})}),e.jsx(le,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(le,{style:{padding:"10px 16px"},children:e.jsx(s.Table,{components:{body:{cell:$r}},columns:M,bordered:!0,size:"small",rowKey:P=>v(P),dataSource:m,loading:y,expandable:{expandedRowRender:U,childrenColumnName:"changed"},pagination:{current:c.pagination.current,pageSize:c.pagination.pageSize,total:C,showSizeChanger:!0,onChange:O,onShowSizeChange:(P,N)=>{b(E=>({...E,pagination:{current:1,pageSize:N}}))},showTotal:(P,N)=>`${N[0]}-${N[1]} of ${P} items`}})})]})]})}const Cc=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),r=String(n).replace(/^\/+/,"");return`${a}/${r}`};function Ac({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState(null),[o,l]=i.useState(null),[d,c]=i.useState(null),[b,y]=i.useState(null),[u,x]=i.useState(null),[j,C]=i.useState(null),[m,h]=i.useState(null),g="api/branchapi/library/bookCategorydropdown",I="api/branchapi/academy/classdropdownlist",R="api/branchapi/Academy/getClassSubjectdropdown",D="api/branchapi/library/addBook",w="api/branchapi/library/uploadcsv",{data:f}=G(n?[g,n]:null,([v,M])=>Q(v,M)),{data:p}=G(n&&I?[I,n]:null,([v,M])=>Q(v,M)),{data:S}=G(n&&R?[R,n]:null,([v,M])=>Q(v,M)),A=i.useMemo(()=>Cc(nt(),w),[w]),O=async v=>{v.preventDefault();const M=new FormData(v.target);M.set("cat_id",u?.value??""),M.set("class_id",j?.value??""),M.set("subject_id",m?.value??"");try{await Ye(D,M,n),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),v.target.reset(),x(null),C(null),h(null)}catch(P){_.error(P?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},q=async v=>{if(v.preventDefault(),!a){_.error("Please select a CSV file.",{duration:1e3});return}const M=new FormData;M.append("file",a),M.append("cat_id",o?.value??""),M.append("class_id",d?.value??""),M.append("subject_id",b?.value??"");try{const P=await Ne.post(A,M,{headers:{Authorization:n,"Content-type":"multipart/form-data"}});P?.data?.Status==="Failed"?_.error(String(P?.data?.msg??"Upload failed."),{duration:1e3}):(_.success(String(P?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),r(null),v.target.reset(),l(null),c(null),y(null))}catch(P){_.error(P?.response?.data?.msg??"Upload failed.",{duration:1e3})}},U=()=>{fetch("/books.csv").then(v=>{v.blob().then(M=>{const P=window.URL.createObjectURL(M);let N=document.createElement("a");N.href=P,N.download="/books.csv",N.click()})})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:e.jsx(s.Button,{type:"link",icon:e.jsx(X.DownloadOutlined,{}),onClick:U,children:"Download Sample"}),children:[e.jsx(s.Divider,{children:"Information"}),e.jsx(s.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:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:o,onChange:v=>l(v??null)}),e.jsx(Z,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:d,onChange:v=>c(v??null)}),e.jsx(Z,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:b,onChange:v=>y(v??null)}),e.jsx(J,{type:"file",label:"Upload CSV",name:"csv",accept:".csv",onChange:v=>r(v.target.files?.[0]??null),required:!0}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Book"}),children:e.jsx("form",{onSubmit:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(J,{type:"text",label:"Book Name",name:"title",required:!0}),e.jsx(J,{type:"text",label:"Author",name:"author",required:!0}),e.jsx(J,{type:"text",label:"Publication",name:"publisher"}),e.jsx(J,{type:"number",label:"Qty",name:"quantity",required:!0}),e.jsx(J,{type:"number",label:"Book Price",name:"price",required:!0}),e.jsx(J,{type:"number",label:"Fine Per Day",name:"fine",required:!0}),e.jsx(J,{type:"text",label:"Barcode",name:"barcode"}),e.jsx(Z,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:u,onChange:v=>x(v??null)}),e.jsx(Z,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:j,onChange:v=>C(v??null)}),e.jsx(Z,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:m,onChange:v=>h(v??null)}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})})})]})}const rs={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},is=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Tc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState([]),[o,l]=i.useState([]),d=i.useRef(),c={selectedRowKeys:a,onChange:(ee,se)=>{r(ee),l(se)}},b=on.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),y=()=>{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}b?.()}},[u,x]=i.useState(!1),[j,C]=i.useState(null),[m,h]=i.useState(null),[g,I]=i.useState(null),[R,D]=i.useState(null),[w,f]=i.useState({page:1,rowsPerPage:10}),p=(ee,se)=>{f({page:ee,rowsPerPage:parseInt(se,10)})},S="api/branchapi/library/booktable",A="api/branchapi/library/deletebooks",O="api/branchapi/library/editbook",q=`${S}?page=${w.page}&per_page=${w.rowsPerPage}`,{isLoading:U,error:v,data:M,mutate:P}=G(n?[q,n]:null,([ee,se])=>Q(ee,se)),N="api/branchapi/library/bookCategorydropdown",E="api/branchapi/academy/classdropdownlist",F="api/branchapi/Academy/getClassSubjectdropdown",{data:L}=G(n?[N,n]:null,([ee,se])=>Q(ee,se)),{data:z}=G(n&&E?[E,n]:null,([ee,se])=>Q(ee,se)),{data:k}=G(n&&F?[F,n]:null,([ee,se])=>Q(ee,se)),T=i.useMemo(()=>is(L),[L]),$=i.useMemo(()=>is(z),[z]),B=i.useMemo(()=>is(k),[k]),Y=async ee=>{try{await at(A,ee,n),await P(),_.success("Success! Deleted item.",{duration:1e3})}catch(se){_.error(se?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ne=ee=>{C(ee??null);const se=ee?.cat_id??ee?.fk_cat_id??ee?.category_id,me=ee?.class_id??ee?.fk_class_id,ve=ee?.subject_id??ee?.fk_subject_id;h(T.find(re=>re?.value===se)??null),I($.find(re=>re?.value===me)??null),D(B.find(re=>re?.value===ve)??null),x(!0)},H=async ee=>{ee.preventDefault();const se=j?.id??j?.book_id??j?._id;if(!se)return;const me=new FormData(ee.target);me.set("id",String(se)),me.set("cat_id",m?.value??""),me.set("class_id",g?.value??""),me.set("subject_id",R?.value??"");try{await ut(O,me,n),await P(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),x(!1),C(null)}catch(ve){_.error(ve?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},W=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:(ee,se)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>ne(se),style:{padding:2}}),e.jsx(s.Button,{type:"text",size:"small",danger:!0,onClick:()=>Y(se?.id??se?.book_id??se?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[T,$,Y,B]);return e.jsxs("div",{style:{},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:u,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{x(!1),C(null)},children:e.jsx("form",{onSubmit:H,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(J,{label:"Book Name",name:"title",defaultValue:j?.book_title??"",required:!0}),e.jsx(J,{label:"Author",name:"author",defaultValue:j?.author??"",required:!0}),e.jsx(J,{label:"Publication",name:"publish",defaultValue:j?.publish??""}),e.jsx(J,{label:"Qty",name:"quantity",type:"number",defaultValue:j?.quantity??""}),e.jsx(J,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:j?.perunitcost??""}),e.jsx(J,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:j?.fine_amount??""}),e.jsx(J,{label:"Barcode",name:"barcode",defaultValue:j?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:rs,children:"Category"}),e.jsx(Z,{options:T,value:m,onChange:ee=>h(ee??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:rs,children:"Class"}),e.jsx(Z,{options:$,value:g,onChange:ee=>I(ee??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:rs,children:"Subject"}),e.jsx(Z,{options:B,value:R,onChange:ee=>D(ee??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{x(!1),C(null)},children:"Cancel"})]})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:o.length>0?e.jsxs(s.Button,{type:"primary",onClick:y,children:["Print Barcode (",o.length,")"]}):null,children:e.jsx(Le,{parentCallback:p,data:{newData:M,columns:W,columnstype:"antd",action:!1,Loading:U,error:v,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((ee,se)=>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:ee.book_title}),e.jsx(Ei,{value:ee.barcode?String(ee.barcode):String(ee.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},se))})})})]})}const Rc=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),r=String(n).replace(/^\/+/,"");return`${a}/${r}`},Tt=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Jn=t=>ae(t).add(1,"month").format("YYYY-MM-DD"),Ic=i.forwardRef(({token:t,onReturn:n},a)=>{const r=t??localStorage.getItem("authToken")??"",[o,l]=i.useState("issue"),d=o==="return",[c,b]=i.useState(!1),[y,u]=i.useState(!1),[x,j]=i.useState(null),[C,m]=i.useState([]),[h,g]=i.useState([]),[I,R]=i.useState([]),[D,w]=i.useState(0),[f,p]=i.useState(!1),[S,A]=i.useState(null),[O,q]=i.useState(null),[U,v]=i.useState(null),[M,P]=i.useState(!1),[N,E]=i.useState("Cash"),[F,L]=i.useState(""),[z,k]=i.useState(""),[T,$]=i.useState(0),[B,Y]=i.useState("NO_FINE"),ne=i.useRef(null),[H]=s.Form.useForm(),[W]=s.Form.useForm(),ee="api/branchapi/library/bookCategorydropdown",se="api/branchapi/academy/classdropdownlist",me="api/branchapi/Academy/getClassSubjectdropdown",{data:ve}=G(r?[ee,r]:null,([ce,je])=>Q(ce,je)),{data:re}=G(r&&se?[se,r]:null,([ce,je])=>Q(ce,je)),{data:ie}=G(r&&me?[me,r]:null,([ce,je])=>Q(ce,je)),V=i.useMemo(()=>Tt(ve),[ve]),oe=i.useMemo(()=>Tt(re),[re]),Ce=i.useMemo(()=>Tt(ie),[ie]),Oe="api/branchapi/library/studentsearchByNameID",Pe="api/branchapi/library/booksearchBybookname",Fe="api/branchapi/library/issuedBookList",Ee="api/branchapi/library/issueLibrarybook",Ke="api/branchapi/library/returnedLibrarybook",{trigger:Ve,data:Ue}=Je(Oe,(ce,je)=>Lt(ce,je,r)),{trigger:We,data:pt}=Je(Pe,(ce,je)=>Lt(ce,je,r)),{trigger:fe,data:be}=Je(Fe,(ce,je)=>Lt(ce,je,r)),{trigger:ge}=Je(d?Ke:Ee,(ce,je)=>Oa(ce,je,r)),te=i.useMemo(()=>Tt(Ue),[Ue]),ye=i.useMemo(()=>Tt(pt),[pt]),he=i.useMemo(()=>Tt(be),[be]),Te=ce=>{const je=Jn(ae());m(ue=>ue.some(xe=>String(xe?.id)===String(ce?.id))?ue:[...ue,{...ce,return_date:ce?.return_date?ce.return_date:je}])},Re=async()=>{console.log("Reloading IssueReturn..."),_.success("Success",{duration:1e3}),g([]),R([]),w(0),Y("FINE_PAY_LATER"),await fe({id:x?.student_id})};i.useImperativeHandle(a,()=>({reloadPayLater:Re}));const ft=ce=>{m(je=>je.filter(ue=>String(ue?.id)!==String(ce)))},Ct=async ce=>{if(r){if(!ce){j(null);return}c||await Ve({id:ce})}},At=async({search:ce})=>{if(!r||!c)return;const je=await Ve({id:ce}),ue=Tt(je);ue.length===1&&(j(ue[0]),await fe({id:ue[0]?.student_id}),H.resetFields())},Wt=async(ce,je)=>{j(je??null),m([]),g([]),R([]),w(0),Y("NO_FINE"),$(0),je?.student_id&&await fe({id:je.student_id}),H.resetFields()},Vt=async ce=>{r&&ce&&(y||await We({book:ce}))},Ht=async({search_book:ce})=>{if(!r||!y)return;const je=await We({book:ce,catID:S?.value??"",sID:U?.value??"",cID:O?.value??""}),ue=Tt(je);ue.length&&(Te(ue[0]),W.resetFields())},pe=(ce,je)=>{Te(je),W.resetFields()},Se=async()=>{if(!x?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!C.length){_.error("Select at least one book.",{duration:1e3});return}const ce=await ge({member_id:x.member_id,fine:!1,books:C});ce?.Status==="Success"&&(_.success(String(ce?.msg??"Success"),{duration:1e3}),m([]),j(null),g([]),R([]),w(0))},Ge=async()=>{if(!x?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!I.length){_.error("Select at least one book to return.",{duration:1e3});return}if(Number(D)>0){Y("FINE_PAID"),P(!0);return}const ce=await ge({member_id:x.member_id,collection_type:"NO_FINE",amount:0,books:JSON.stringify(I)});ce?.Status==="Success"?(_.success(String(ce?.msg??"Success"),{duration:1e3}),g([]),R([]),w(0),await fe({id:x?.student_id})):_.error(String(ce?.msg??"Failed"),{duration:1e3})},St=async()=>{if(!x?.member_id)return;const ce=Math.max(0,Number(D)-Number(T||0)),je={member_id:x.member_id,collection_type:B,amount:B==="FINE_PAID"?ce:0,payment_type:N,notes:F,attchement:z,discount:T||0,books:JSON.stringify(I)},ue=await ge(je);P(!1),ue?.Status==="Success"?(_.success(String(ue?.msg??"Success"),{duration:1e3}),g([]),R([]),w(0),$(0),L(""),k(""),Y("NO_FINE"),await fe({id:x?.student_id})):_.error(String(ue?.msg??"Failed"),{duration:1e3})},Ba=async()=>{if(!x?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!I.length){_.error("Select at least one book to return.",{duration:1e3});return}const ce={member_id:x.member_id,collection_type:"FINE_PAY_LATER",amount:0,books:JSON.stringify(I)};n(ce)},La=i.useMemo(()=>Rc(nt(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),qa=[{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,je)=>e.jsx(gt,{defaultValue:ae(je?.return_date||ae().add(30,"day")),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(ue,xe)=>{m(ke=>ke.map(Be=>String(Be?.id)===String(je?.id)?{...Be,return_date:xe}:Be))}})},{title:"Action",key:"action",width:120,fixed:"right",render:(ce,je)=>e.jsx(s.Button,{type:"text",danger:!0,onClick:()=>ft(je?.id),children:"Remove"})}],za={selectedRowKeys:h,onChange:(ce,je)=>{g(ce),R(je);const ue=(je??[]).reduce((xe,ke)=>xe+Number(ke?.totalfine??0),0);w(ue)},onSelect:(ce,je,ue)=>{if(je){const xe=ue.map(ke=>({...ke,return_date:ke?.return_date?ke.return_date:Jn(ke?.issue_date||ae())}));R(xe)}},onSelectAll:(ce,je)=>{if(ce){const ue=je.map(xe=>({...xe,return_date:xe?.return_date?xe.return_date:Jn(xe?.issue_date||ae())}));R(ue)}}},Ya=[{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,je)=>{const xe=I.find(Be=>String(Be?.id)===String(je?.id))?.return_date||je?.return_date,ke=Jn(je?.issue_date||ae());return e.jsx(gt,{defaultValue:ae(xe||ke),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(Be,Po)=>{R(Eo=>Eo.map(Wa=>String(Wa?.id)===String(je?.id)?{...Wa,return_date:Po}:Wa))}})}},{title:"Days",key:"days",width:100,render:(ce,je)=>{const xe=I.find(Be=>String(Be?.id)===String(je?.id))?.return_date||je?.return_date,ke=je?.issue_date;if(ke&&xe){const Be=ae(xe).diff(ae(ke),"day");return Be>=0?Be: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(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:M,onCancel:()=>P(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(s.Radio.Group,{value:N,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(s.Input.TextArea,{rows:3,value:F,onChange:ce=>L(ce.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(s.Upload,{action:La,headers:{Authorization:r},maxCount:1,onChange:ce=>{if(ce.file.status==="done"){const je=ce.file.response?.data??ce.file.response?.file??"";k(String(je??""))}},children:e.jsx(s.Button,{icon:e.jsx(X.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(s.Input,{type:"number",value:T,onChange:ce=>$(ce.target.value),placeholder:"0"})]}),e.jsxs(s.Button,{type:"primary",onClick:St,children:["Collect ₹",Math.max(0,Number(D)-Number(T||0))]}),e.jsx(s.Button,{onClick:()=>P(!1),children:"Cancel"})]})}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[e.jsxs(s.Row,{gutter:[16,16],align:"middle",children:[e.jsx(s.Col,{xs:24,md:10,children:e.jsx(s.Radio.Group,{value:o,onChange:ce=>{const je=ce.target.value;l(je),m([]),g([]),R([]),w(0),Y("NO_FINE"),$(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"},{label:"Renewal",value:"Renewal"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(s.Col,{xs:24,md:14,children:e.jsx(s.Form,{form:H,onFinish:At,layout:"vertical",children:e.jsx(s.Form.Item,{name:"search",label:"Search Student",children:e.jsx(s.Space.Compact,{style:{width:"100%"},children:c?e.jsx(s.Input,{autoFocus:!0,addonBefore:e.jsxs(s.Space,{children:[e.jsx(X.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:c,onChange:ce=>b(ce.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(s.AutoComplete,{options:te,onSelect:Wt,onSearch:Ct,style:{width:"100%"},allowClear:!0,children:e.jsx(s.Input,{addonBefore:e.jsxs(s.Space,{children:[e.jsx(X.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:c,onChange:ce=>b(ce.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),x?e.jsxs(e.Fragment,{children:[e.jsx(s.Divider,{}),e.jsxs(s.Row,{gutter:[12,12],children:[e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Name:"})," ",x?.value??""]}),e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Card No:"})," ",x?.library_card_no??""]}),e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Member ID:"})," ",x?.member_id??""]})]})]}):null,e.jsx(s.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(s.Table,{dataSource:he,columns:Ya,rowSelection:za,pagination:!1,rowKey:ce=>ce?.id??ce?.issue_id??ce?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(s.Divider,{}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs(s.Typography.Text,{strong:!0,children:["Total Fine: ₹",D]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx(s.Button,{type:"primary",onClick:Ge,disabled:!I.length,children:D>0?`Pay Now ₹ ${Math.max(0,Number(D)-Number(T||0))}`:"Return Selected"}),D>0?e.jsx(s.Button,{onClick:Ba,disabled:!I.length,children:"Pay Later"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(s.Row,{gutter:[16,16],align:"middle",children:[e.jsx(s.Col,{xs:24,md:18,children:e.jsx(s.Form,{form:W,onFinish:Ht,layout:"vertical",children:e.jsx(s.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(s.Space.Compact,{style:{width:"100%"},children:y?e.jsx(s.Input,{autoFocus:!0,disabled:!x,addonBefore:e.jsxs(s.Space,{children:[e.jsx(X.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:y,onChange:ce=>u(ce.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(s.AutoComplete,{disabled:!x,options:ye,onSelect:pe,onSearch:Vt,style:{width:"100%"},allowClear:!0,children:e.jsx(s.Input,{addonBefore:e.jsxs(s.Space,{children:[e.jsx(X.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:y,onChange:ce=>u(ce.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(s.Button,{style:{width:"100%"},icon:e.jsx(X.FilterOutlined,{}),onClick:()=>p(!0),children:"Filter"})})]}),e.jsx(s.Drawer,{open:f,onClose:()=>p(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{label:"Category",options:V,value:S,onChange:ce=>A(ce??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(Z,{label:"Class",options:oe,value:O,onChange:ce=>q(ce??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(Z,{label:"Subjects",options:Ce,value:U,onChange:ce=>v(ce??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(s.Button,{type:"primary",onClick:()=>p(!1),children:"Apply"})]})}),e.jsx(s.Divider,{}),e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:720},children:e.jsx(s.Table,{dataSource:C,columns:qa,pagination:!1,rowKey:ce=>ce?.id??ce?.book_id??ce?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Issue",onClick:Se})})]})]}),e.jsx("div",{ref:ne,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}),Br=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Dc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState({page:1,rowsPerPage:10}),[o,l]=i.useState(null),[d,c]=i.useState(null),[b,y]=i.useState(!1),[u,x]=i.useState(!1),[j,C]=i.useState(null),[m,h]=i.useState(!1),g="api/branchapi/academy/classdropdownlist",I="api/branchapi/academy/sectionoftheClass",R="api/branchapi/library/studenttableForLibrary",D="api/branchapi/library/addmembershipforStudent",w="api/branchapi/library/removemembershipforStudent",f=i.useMemo(()=>{if(!o?.value)return null;const k=I.includes("?")?"&":"?";return`${I}${k}class_id=${encodeURIComponent(String(o.value))}`},[I,o?.value]),p=i.useMemo(()=>{if(!o?.value||!d?.value)return null;const k=R.includes("?")?"&":"?";return`${R}${k}cID=${encodeURIComponent(String(o.value))}&sID=${encodeURIComponent(String(d.value))}&page=${a.page}&per_page=${a.rowsPerPage}`},[a.page,a.rowsPerPage,o?.value,d?.value,R]),{data:S}=G(n&&g?[g,n]:null,([k,T])=>Q(k,T)),{data:A}=G(n&&f?[f,n]:null,([k,T])=>Q(k,T)),{isLoading:O,error:q,data:U,mutate:v}=G(n&&p?[p,n]:null,([k,T])=>Q(k,T)),M=i.useMemo(()=>Br(S),[S]),P=i.useMemo(()=>Br(A),[A]),N=(k,T)=>{r({page:k,rowsPerPage:parseInt(T,10)})},E=k=>{const T=k?.id??k?.student_id??k?.member_id;C(T??null),x(!0),h($=>!$)},F=async k=>{if(k.preventDefault(),!j)return;const T=new FormData(k.target);T.set("id",String(j));try{await Ye(D,T,n),_.success("Success! Added member.",{duration:1e3,icon:"🎉"}),x(!1),C(null),await v()}catch($){_.error($?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},L=async k=>{try{await at(w,k,n),_.success("Success! Removed member.",{duration:1e3}),await v()}catch(T){_.error(T?.response?.data?.msg??"Failed to remove member.",{duration:1e3})}},z=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:(k,T)=>(console.log("data______________",T),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:T?.library_card_no==null?e.jsx(s.Button,{type:"primary",size:"small",icon:e.jsx(X.UserAddOutlined,{}),onClick:()=>E(T)}):e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{}),onClick:()=>L(T?.id??T?.student_id??T?.member_id)})}))}],[L]);return e.jsxs("div",{style:{},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:u,title:"Add Member",onCancel:()=>{x(!1),C(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:F,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(J,{type:"text",label:"Library Card Number",name:"library_num",required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Add",color:"primary"})})]})},`add-${m}`)}),e.jsx(s.Card,{title:e.jsx(s.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(Z,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:o,onChange:k=>{l(k??null),c(null),y(T=>!T)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(Z,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:k=>c(k??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${b}`),e.jsx(de,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!o?.value||!d?.value){_.error("Select class and section.",{duration:1e3});return}r(k=>({...k,page:1}))}})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Le,{parentCallback:N,data:{newData:U,columns:z,columnstype:"antd",action:!1,Loading:O,error:q}})})]})}function kc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState({page:1,rowsPerPage:10}),[o]=s.Form.useForm(),[l]=s.Form.useForm(),[d,c]=i.useState(!1),[b,y]=i.useState(null),u="api/branchapi/library/BookCategorytable",x="api/branchapi/library/addBookCategory",j="api/branchapi/library/editBookCategory",C="api/branchapi/library/deleteBookCategory",m=i.useMemo(()=>{const q=u.includes("?")?"&":"?";return`${u}${q}page=${a.page}&per_page=${a.rowsPerPage}`},[u,a.page,a.rowsPerPage]),{isLoading:h,error:g,data:I,mutate:R}=G(n&&m?[m,n]:null,([q,U])=>Q(q,U)),D=(q,U)=>{r({page:q,rowsPerPage:parseInt(U,10)})},w=async q=>{const U=new FormData;U.set("title",q?.title??"");try{await Ye(x,U,n),_.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),o.resetFields(),await R()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to add category.",{duration:1e3})}},f=q=>{y(q??null),l.setFieldsValue({title:q?.name??""}),c(!0)},p=()=>{c(!1),y(null),l.resetFields()},S=async q=>{const U=b?.id??b?.category_id??b?.cat_id;if(!U){_.error("Missing category id.",{duration:1e3});return}const v=new FormData;v.set("id",String(U)),v.set("title",q?.title??"");try{await ut(j,v,n),_.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),p(),await R()}catch(M){_.error(M?.response?.data?.msg??M?.message??"Failed to update category.",{duration:1e3})}},A=async q=>{const U=q?.id??q?.category_id??q?.cat_id;if(!U){_.error("Missing category id.",{duration:1e3});return}try{await at(C,U,n),_.success("Success! Deleted category.",{duration:1e3}),await R()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to delete category.",{duration:1e3})}},O=i.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(q,U)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>f(U)}),e.jsx(s.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>A(U),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[A]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:d,title:"Edit Category",onCancel:p,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:l,layout:"vertical",onFinish:S,children:[e.jsx(s.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(s.Input,{placeholder:"Enter category name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:p,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,lg:8,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:w,children:[e.jsx(s.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(s.Input,{placeholder:"Enter category name"})}),e.jsx(de,{type:"submit",value:"Add",color:"primary"})]})})}),e.jsx(s.Col,{xs:24,lg:16,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:e.jsx(Le,{parentCallback:D,data:{newData:I,columns:O,columnstype:"antd",action:!1,Loading:h,error:g}})})})]})]})}const os=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Oc({token:t}){const[n,a]=i.useState([ae().format("YYYY-MM-DD"),ae().format("YYYY-MM-DD")]),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,b]=i.useState(null),[y,u]=i.useState(!1),[x,j]=i.useState(!1),C="api/branchapi/academy/classdropdownlist",m="api/branchapi/academy/sectionoftheClass",h="api/branchapi/library/memberDropdown",g="api/report/libraryReport/libraryReport",I=i.useMemo(()=>{if(!r?.value)return null;const E=m.includes("?")?"&":"?";return`${m}${E}class_id=${encodeURIComponent(String(r.value))}`},[m,r?.value]),R=i.useMemo(()=>{if(!r?.value)return null;const E=h.includes("?")?"&":"?",F=`${h}${E}class=${encodeURIComponent(String(r.value))}`;return l?.value?`${F}§ion=${encodeURIComponent(String(l.value))}`:F},[h,r?.value,l?.value]),{isLoading:D,error:w,data:f,mutate:p}=G(t&&C?[C,t]:null,([E,F])=>Q(E,F)),{data:S}=G(t&&I?[I,t]:null,([E,F])=>Q(E,F)),{data:A}=G(t&&R?[R,t]:null,([E,F])=>Q(E,F)),O=i.useMemo(()=>os(f),[f]),q=i.useMemo(()=>os(S),[S]),U=i.useMemo(()=>os(A),[A]),{trigger:v,data:M}=Je(g,(E,F)=>Os(E,F,t));i.useEffect(()=>{(async()=>{j(!0);try{await v({duration:n})}finally{j(!1)}})()},[]);const P=async()=>{j(!0);try{await v({duration:n,class:r?.value??"",section:l?.value??"",student_id:c?.value??""})}finally{j(!1)}},N=[{title:"Name",dataIndex:"full_name",render:(E,F)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:F?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(E,F)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:F?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(E,F)=>e.jsxs(s.Typography.Text,{style:{fontSize:12},children:[F?.class??"","(",F?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(E,F)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:F?.book_title??""})},{title:"Issue Date",key:"date",render:(E,F,L)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:F?.issue_date??""})},{title:"Due Return Date",key:"date",render:(E,F,L)=>e.jsx(s.Tag,{color:"orange",children:F?.return_date??""})},{title:"Return Date",key:"date",render:(E,F,L)=>F?.retured_by_user?e.jsx(s.Tag,{color:"green",children:F?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(E,F,L)=>String(F?.is_returned??"")==="1"?e.jsx(s.Tag,{color:"green",children:"Return"}):e.jsx(s.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:(E,F,L)=>{const z=F?.late_fine?Number(F.late_fine):0;return z?e.jsx(s.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:z}):null}}];return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[e.jsxs(s.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(s.Col,{xs:24,md:8,children:e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Duration"}),e.jsx(s.DatePicker.RangePicker,{style:{width:"100%"},value:[ae(n[0],"YYYY-MM-DD"),ae(n[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(E,F)=>{Array.isArray(F)&&F.length===2&&a([F[0],F[1]])}})]})}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(Z,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:r,onChange:E=>{o(E??null),d(null),b(null),u(F=>!F)},allowSelectAll:!1})}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:l,onChange:E=>{d(E??null),b(null)},allowSelectAll:!1},`section1${y}`)}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(Z,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:E=>b(E??null),allowSelectAll:!1})}),e.jsx(s.Col,{xs:24,md:1,children:e.jsx(s.Button,{type:"primary",icon:e.jsx(X.SearchOutlined,{}),onClick:P,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(s.Table,{columns:N,pagination:!1,dataSource:Array.isArray(M?.data)?M.data:[],size:"small",rowKey:(E,F)=>E?.id??E?.issue_id??E?.fees_receipt_id??F,loading:x,scroll:{x:"max-content"},summary:E=>{const F=E.reduce((z,k)=>z+Number(k?.late_fine??0),0),L=E.reduce((z,k)=>z+Number(k?.is_returned??0),0);return e.jsxs(s.Table.Summary.Row,{children:[e.jsx(s.Table.Summary.Cell,{colSpan:4,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",E.length]})}),e.jsx(s.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(E.length-L)]})}),e.jsx(s.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",L]})}),e.jsx(s.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",F.toLocaleString("en-IN")]})})]})}})})]})]})}const Lr=[{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"}],qr=[{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 Pc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState("renewalHistory"),[o,l]=i.useState("This Month"),[d,c]=i.useState(""),[b,y]=i.useState(""),[u,x]=i.useState(7),[j,C]=i.useState(1),[m,h]=i.useState(20),[g,I]=i.useState(""),[R,D]=i.useState("DESC"),w=i.useRef(null),f=F=>{const L=new URLSearchParams;return["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(a)&&(L.set("date_range",o),o==="Custom"&&d&&b&&(L.set("from_date",d),L.set("to_date",b))),["renewalHistory","renewalFineReport","currentlyRenewedBooks","upcomingRenewalDue","overdueRenewalReport","renewalLimitReport","renewalStatusReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport"].includes(a)&&(L.set("page",String(j)),L.set("per_page",String(m))),a==="upcomingRenewalDue"&&L.set("days_ahead",String(u)),g&&L.set("sort_by",g),R&&L.set("sort_dir",R),`${F}?${L.toString()}`},p=i.useMemo(()=>{switch(a){case"renewalHistory":return f(vd);case"renewalFineReport":return f(_d);case"currentlyRenewedBooks":return f(wd);case"upcomingRenewalDue":return f(Cd);case"overdueRenewalReport":return f(Ad);case"renewalLimitReport":return f(Td);case"renewalStatusReport":return f(Rd);case"studentWiseReport":return f(Id);case"bookWiseReport":return f(Dd);case"classWiseReport":return f(kd);case"staffWiseReport":return f(Od);case"renewalStatisticsByDate":return f(Pd);default:return null}},[a,o,d,b,u,j,m]),{data:S,isLoading:A}=G(n?[p,n]:null,([F,L])=>Q(F,L)),O=S?.data||{},q=O?.rows||[],U=O?.pagination||{},v=F=>{r(F),C(1),h(20)},M=()=>{C(1)},P=()=>{switch(a){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:F=>e.jsx(s.Tag,{color:F==="renewed"?"green":"red",children:F})},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",render:F=>F??"-"},{title:"Paid Amount",dataIndex:"paid_amount",key:"paid_amount",render:F=>F??"-"},{title:"Due Amount",dataIndex:"due_amount",key:"due_amount",render:F=>F??"-"},{title:"Fine Status",dataIndex:"fine_payment_status",key:"fine_payment_status",render:F=>F?e.jsx(s.Tag,{color:F==="paid"?"green":F==="partial"?"orange":"red",children:F}):"-"}];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:F=>F??"-"},{title:"Overdue Days",dataIndex:"overdue_days",key:"overdue_days",render:F=>F??"-"},{title:"Fine",dataIndex:"fine_amount",key:"fine_amount",render:F=>F??"-"},{title:"Due",dataIndex:"due_amount",key:"due_amount",render:F=>F??"-"},{title:"Can Renew",dataIndex:"can_renew",key:"can_renew",render:F=>e.jsx(s.Tag,{color:F?"green":"red",children:F?"Yes":"No"})},{title:"Reasons",dataIndex:"reasons",key:"reasons",render:F=>Array.isArray(F)?F.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[]}},N=["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(a),E=i.useMemo(()=>P(),[a]);return e.jsx(le,{pt:5,pb:1,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(le,{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(le,{p:3,children:[e.jsxs(s.Row,{gutter:[16,16],mb:3,children:[N&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(Z,{options:Lr,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:Lr.find(F=>F.value===o)||null,onChange:F=>l(F?.value||"This Month")})}),o==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(gt,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:F=>c(F?F.format("YYYY-MM-DD"):"")})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(gt,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:F=>y(F?F.format("YYYY-MM-DD"):"")})})]})]}),a==="upcomingRenewalDue"&&e.jsx(s.Col,{xs:24,md:6,children:e.jsx(Z,{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:F=>x(F?.value||7)})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(le,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:M})})})]}),e.jsx(s.Tabs,{activeKey:a,onChange:v,items:qr})]})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(le,{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(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:qr.find(F=>F.key===a)?.label||"Report"})}),e.jsxs(le,{p:3,children:[e.jsx(dn,{data:{tableRef:w}}),A?e.jsx(le,{py:8,textAlign:"center",children:e.jsx(s.Typography.Text,{type:"secondary",children:"Loading report data..."})}):e.jsx(s.Table,{size:"small",dataSource:q,columns:E,loading:A,pagination:!1,bordered:!0,rowKey:F=>F.renewal_id||F.id||JSON.stringify(F),ref:w}),q.length>0&&e.jsx(s.Pagination,{current:j,pageSize:m,total:U.total_rows||q.length,onChange:(F,L)=>{C(F),h(L)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const Pa=t=>t??localStorage.getItem("authToken")??"",Ec=(t,n)=>{const a=String(t??""),r=String(n);return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r},$e={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"}},Mc=()=>Ec(nt(),$e.upload),Fc=async({baseUrl:t,page:n=1,perPage:a=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,Pa(r))},$n=async(t,n,a)=>Ye(t,n,Pa(a)),cn=async(t,n,a)=>ut(t,n,Pa(a)),Un=async(t,n,a)=>at(t,n,Pa(a)),Nc=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",sn=({token:t,value:n,onChange:a})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:Mc(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=Nc(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},ua=$e.vendor,Bn=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,b])=>Fc({baseUrl:l,page:d,perPage:c},b)),$c=({token:t,page:n=1,perPage:a=10})=>Bn({baseUrl:ua.list,page:n,perPage:a,token:t}),Uc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},zr=[{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 Bc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,b]=i.useState(""),{isLoading:y,error:u,data:x,mutate:j}=$c({token:t,page:n.page,perPage:n.rowsPerPage}),C=async w=>{try{await j($n(ua.add,w,t),st(w)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(f){_.error(f?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},m=w=>{w.preventDefault();const f=new FormData(w.target);c&&f.set("image",c),C(f),w.target.reset(),b("")},h=(w,f)=>{a({page:w,rowsPerPage:parseInt(f,10)})},g=async w=>{try{await j(Un(ua.remove,w,t),Qe(w)),_.success("Success! Deleted item.",{duration:1e3})}catch(f){_.error(f?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},I=w=>{d(w),o(!0),b("")},R=async w=>{w.preventDefault();const f=new FormData(w.target);f.set("id",String(l?.id??"")),c&&f.set("image",c);try{await cn(ua.edit,f,t),await j(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),b("")}catch(p){_.error(p?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},D=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:(w,f)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>I(f),style:{padding:2}}),e.jsx(ot,{id:f?.id,funcName:g})]})}],[g]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Vendor",placement:"right",width:520,onClose:()=>{o(!1),d(null),b("")},children:e.jsx("form",{onSubmit:R,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[zr.map(w=>e.jsx(J,{type:w.type,name:w.name,label:w.label,defaultValue:l?.[w.name]??"",required:w.required?"required":void 0},w.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(sn,{token:t,value:c,onChange:b})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),b("")},style:Uc,children:"Cancel"})]})]})})}),e.jsxs(le,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(le,{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:[zr.map(w=>e.jsx(J,{type:w.type,name:w.name,label:w.label,required:w.required?"required":void 0},w.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(sn,{token:t,value:c,onChange:b})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(le,{pt:3,children:e.jsx(Le,{parentCallback:h,data:{newData:x,columns:D,columnstype:"antd",action:!1,Loading:y,error:u}})})]})]})]})}const Lc=({token:t})=>e.jsx(Bc,{token:t}),qc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},zc={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"},Dt=({style:t,onFocus:n,onBlur:a,...r})=>{const[o,l]=i.useState(!1);return e.jsxs("div",{style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:qc,children:r.label}),e.jsx("textarea",{placeholder:r.placeholder||r.label,...r,onFocus:d=>{l(!0),n?.(d)},onBlur:d=>{l(!1),a?.(d)},style:{...zc,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})},pa=$e.product,Yr=$e.vendor.dropdown,Wr=$e.category.dropdown,Yc=$e.subCategory.dropdown,Vr=$e.unit.dropdown,fo=({token:t,page:n=1,perPage:a=10})=>Bn({baseUrl:pa.list,page:n,perPage:a,token:t}),Wc=({token:t})=>G(t&&Yr?[Yr,t]:null,([a,r])=>Q(a,r)),Vc=({token:t})=>G(t&&Wr?[Wr,t]:null,([a,r])=>Q(a,r)),Hc=({token:t})=>G(t&&Vr?[Vr,t]:null,([a,r])=>Q(a,r)),Kc=({token:t,categoryId:n})=>{const a=t&&n?`${Yc}?category_id=${encodeURIComponent(String(n))}`:null;return G(a?[a,t]:null,([o,l])=>Q(o,l))},Qn=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Gc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Jc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,b]=i.useState(""),[y,u]=i.useState(""),[x,j]=i.useState(""),[C,m]=i.useState(""),[h,g]=i.useState(""),{isLoading:I,error:R,data:D,mutate:w}=fo({token:t,page:n.page,perPage:n.rowsPerPage}),{data:f}=Wc({token:t}),{data:p}=Vc({token:t}),{data:S}=Hc({token:t}),{data:A}=Kc({token:t,categoryId:y}),O=i.useMemo(()=>Qn(f),[f]),q=i.useMemo(()=>Qn(p),[p]),U=i.useMemo(()=>Qn(S),[S]),v=i.useMemo(()=>Qn(A),[A]),M=async k=>{try{await w($n(pa.add,k,t),st(k)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(T){_.error(T?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},P=k=>{k.preventDefault();const T=new FormData(k.target);y&&T.set("fk_categoryID",String(y)),x&&T.set("fk_sub_categoryID",String(x)),C&&T.set("vendor_id",String(C)),h&&T.set("unit",String(h)),c&&T.set("image",c),M(T),k.target.reset(),b(""),u(""),j(""),m(""),g("")},N=(k,T)=>{a({page:k,rowsPerPage:parseInt(T,10)})},E=async k=>{try{await w(Un(pa.remove,k,t),Qe(k)),_.success("Success! Deleted item.",{duration:1e3})}catch(T){_.error(T?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},F=k=>{d(k),o(!0),b(""),u(k?.fk_categoryID??k?.category_id??""),j(k?.fk_sub_categoryID??k?.sub_category_id??""),m(k?.vendor_id??""),g(k?.unit??k?.unit_id??"")},L=async k=>{k.preventDefault();const T=new FormData(k.target);T.set("id",String(l?.id??"")),y&&T.set("fk_categoryID",String(y)),x&&T.set("fk_sub_categoryID",String(x)),C&&T.set("vendor_id",String(C)),h&&T.set("unit",String(h)),c&&T.set("image",c);try{await cn(pa.edit,T,t),await w(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),b("")}catch($){_.error($?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},z=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:(k,T)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>F(T),style:{padding:2}}),e.jsx(ot,{id:T?.id,funcName:E})]})}],[E]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Product",placement:"right",width:520,onClose:()=>{o(!1),d(null),b("")},children:e.jsx("form",{onSubmit:L,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx(J,{type:"text",name:"name",label:"Product Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:k=>{const T=k?.value??"";u(T),j("")},defaultValue:y?q.find(k=>String(k?.value)===String(y)):null}),e.jsx(Z,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:k=>j(k?.value??""),defaultValue:x?v.find(k=>String(k?.value)===String(x)):null}),e.jsx(J,{type:"text",name:"barcode",label:"Barcode",defaultValue:l?.barcode??""}),e.jsx(Z,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:k=>g(k?.value??""),defaultValue:h?U.find(k=>String(k?.value)===String(h)):null}),e.jsx(J,{type:"number",name:"quantity",label:"Quantity*",defaultValue:l?.quantity??"",required:"required"}),e.jsx(J,{type:"number",name:"price",label:"Price*",defaultValue:l?.price??"",required:"required"}),e.jsx(Z,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:k=>m(k?.value??""),defaultValue:C?O.find(k=>String(k?.value)===String(C)):null}),e.jsx(J,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:l?.hsn_code??""}),e.jsx(Dt,{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(sn,{token:t,value:c,onChange:b})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),b("")},style:Gc,children:"Cancel"})]})]})})}),e.jsxs(le,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(le,{px:3,pb:2,children:e.jsx("form",{onSubmit:P,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(J,{type:"text",name:"name",label:"Product Name*",required:"required"}),e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:k=>{const T=k?.value??"";u(T),j("")}}),e.jsx(Z,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:k=>j(k?.value??"")},`subcat_${y}`),e.jsx(J,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(Z,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:k=>g(k?.value??"")}),e.jsx(J,{type:"number",name:"quantity",label:"Quantity*",required:"required"}),e.jsx(J,{type:"number",name:"price",label:"Price*",required:"required"}),e.jsx(Z,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:k=>m(k?.value??"")}),e.jsx(J,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(Dt,{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(sn,{token:t,value:c,onChange:b})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(le,{pt:3,children:e.jsx(Le,{parentCallback:N,data:{newData:D,columns:z,columnstype:"antd",action:!1,Loading:I,error:R}})})]})]})]})}const Qc=({token:t})=>e.jsx(Jc,{token:t}),ma=$e.category,Xc=({token:t,page:n=1,perPage:a=10})=>Bn({baseUrl:ma.list,page:n,perPage:a,token:t}),Zc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function eu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:b,data:y,mutate:u}=Xc({token:t,page:n.page,perPage:n.rowsPerPage}),x=async R=>{try{await u($n(ma.add,R,t),st(R)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){_.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},j=R=>{R.preventDefault();const D=new FormData(R.target);x(D),R.target.reset()},C=(R,D)=>{a({page:R,rowsPerPage:parseInt(D,10)})},m=async R=>{try{await u(Un(ma.remove,R,t),Qe(R)),_.success("Success! Deleted item.",{duration:1e3})}catch(D){_.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},h=R=>{d(R),o(!0)},g=async R=>{R.preventDefault();const D=new FormData(R.target);D.set("id",String(l?.id??""));try{await cn(ma.edit,D,t),await u(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(w){_.error(w?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},I=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(R,D)=>String(R?.name??"").localeCompare(String(D?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(R,D)=>String(R?.description??"").localeCompare(String(D?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(R,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(D),style:{padding:2}}),e.jsx(ot,{id:D?.id,funcName:m})]})}],[m]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.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:g,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"name",label:"Name",defaultValue:l?.name??"",required:"required"}),e.jsx(J,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Zc,children:"Cancel"})]})]})})}),e.jsxs(le,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(le,{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(J,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(J,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(le,{pt:3,children:e.jsx(Le,{parentCallback:C,data:{newData:y,columns:I,columnstype:"antd",action:!1,Loading:c,error:b}})})]})]})]})}const tu=({token:t})=>e.jsx(eu,{token:t}),ya=$e.subCategory,Hr=$e.category.dropdown,nu=({token:t,page:n=1,perPage:a=10})=>Bn({baseUrl:ya.list,page:n,perPage:a,token:t}),au=({token:t})=>G(t&&Hr?[Hr,t]:null,([a,r])=>Q(a,r)),su=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},ru={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function iu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,b]=i.useState(""),{isLoading:y,error:u,data:x,mutate:j}=nu({token:t,page:n.page,perPage:n.rowsPerPage}),{data:C}=au({token:t}),m=i.useMemo(()=>su(C),[C]),h=async p=>{try{await j($n(ya.add,p,t),st(p)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(S){_.error(S?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},g=p=>{p.preventDefault();const S=new FormData(p.target);S.set("status","active"),S.set("img",c||""),h(S),p.target.reset(),b("")},I=(p,S)=>{a({page:p,rowsPerPage:parseInt(S,10)})},R=async p=>{try{await j(Un(ya.remove,p,t),Qe(p)),_.success("Success! Deleted item.",{duration:1e3})}catch(S){_.error(S?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},D=p=>{d(p),o(!0)},w=async p=>{p.preventDefault();const S=new FormData(p.target);S.set("id",String(l?.id??"")),c&&S.set("img",c);try{await cn(ya.edit,S,t),await j(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),b("")}catch(A){_.error(A?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},f=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(p,S)=>String(p?.name??"").localeCompare(String(S?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(p,S)=>String(p?.description??"").localeCompare(String(S?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(p,S)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(S),style:{padding:2}}),e.jsx(ot,{id:S?.id,funcName:R})]})}],[R]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Sub Category",placement:"right",width:420,onClose:()=>{o(!1),d(null),b("")},children:e.jsx("form",{onSubmit:w,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Z,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:l?.category_id?m.find(p=>String(p?.value)===String(l.category_id)):null,allowSelectAll:!1,required:!0}),e.jsx(J,{type:"text",name:"name",label:"Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(J,{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(sn,{token:t,value:c,onChange:b})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),b("")},style:ru,children:"Cancel"})]})]})})}),e.jsxs(le,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(le,{px:3,pb:2,children:e.jsx("form",{onSubmit:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",allowSelectAll:!1,required:!0}),e.jsx(J,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(J,{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(sn,{token:t,value:c,onChange:b})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(le,{pt:3,children:e.jsx(Le,{parentCallback:I,data:{newData:x,columns:f,columnstype:"antd",action:!1,Loading:y,error:u}})})]})]})]})}const ou=({token:t})=>e.jsx(iu,{token:t}),ls=$e.product,lu=$e.academy.classes,du=$e.academy.sections,cu=$e.student.dropdown;function gn(t){const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]}function Xn(t,n){const a=Math.trunc(Number(t)||1),r=Math.max(1,a);return!Number.isFinite(Number(n))||Number(n)<=0?r:Math.min(r,Math.trunc(Number(n)))}function Xe(t){return String(t??"")}function uu({token:t}){const[n,a]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,b]=i.useState(!1),[y,u]=i.useState(""),[x,j]=i.useState([]),[C,m]=i.useState({}),[h,g]=i.useState({}),[I,R]=i.useState(!1),[D,w]=i.useState(""),[f,p]=i.useState(0),[S,A]=i.useState(""),[O,q]=i.useState(ae()),[U,v]=i.useState([]),M={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},P=!!(n&&r&&l),{data:N}=G(t?[lu,t]:null,([fe,be])=>Q(fe,be)),E=i.useMemo(()=>gn(N),[N]),F=t&&n?`${du}?class_id=${encodeURIComponent(String(n))}`:null,{data:L}=G(F?[F,t]:null,([fe,be])=>Q(fe,be)),z=i.useMemo(()=>gn(L),[L]),k=t&&n&&r?`${cu}?class=${encodeURIComponent(String(n))}§ion=${encodeURIComponent(String(r))}`:null,{data:T}=G(k?[k,t]:null,([fe,be])=>Q(fe,be)),$=i.useMemo(()=>gn(T),[T]),B=P?`${ls.list}?page=1&per_page=10000`:null,{data:Y,isLoading:ne}=G(t&&B?[B,t]:null,([fe,be])=>Q(fe,be),{revalidateOnFocus:!1}),H=i.useMemo(()=>gn(Y),[Y]),W=i.useMemo(()=>{const fe=new Map;return(Array.isArray(H)?H:[]).forEach(be=>{fe.set(Xe(be?.id),be)}),fe},[H]),ee=i.useMemo(()=>{const fe=Object.entries(h||{});return fe.length===0?[]:fe.map(([be,ge])=>{const te=W.get(Xe(be));return te?{id:te?.id,name:te?.name,barcode:te?.barcode,stock:Number(te?.quantity||0),price:Number(te?.price||0),quantity:Xn(ge,Number(te?.quantity||0))}:null}).filter(Boolean)},[h,W]),se=i.useMemo(()=>new Set(ee.map(fe=>Xe(fe?.id))),[ee]),me=i.useMemo(()=>(Array.isArray(ee)?ee:[]).reduce((be,ge)=>be+Number(ge?.price||0)*Number(ge?.quantity||1),0),[ee]),ve=i.useMemo(()=>{const fe=Number(f||0);return!Number.isFinite(fe)||fe<=0?0:Math.min(fe,me)},[f,me]),re=i.useMemo(()=>Math.max(0,me-ve),[ve,me]),ie=i.useMemo(()=>(Array.isArray(H)?H:[]).slice(0,30).map(fe=>({value:Xe(fe?.id),label:`${fe?.name??""}${fe?.barcode?` • ${fe.barcode}`:""}${fe?.quantity!==void 0&&fe?.quantity!==null?` • Stock: ${fe.quantity}`:""}`,product:fe})),[H]),{trigger:V}=Je(t&&P?ls.search:null,(fe,{arg:be})=>Lt(fe,{arg:be},t));i.useEffect(()=>{if(!P){j([]);return}const fe=String(y||"").trim();if(fe.length<2){j(ie);return}let be=!0;const ge=setTimeout(async()=>{let te=[];try{if(V){const he=await V({search:fe});te=gn(he)}}catch{te=[]}if(!Array.isArray(te)||te.length===0){const he=fe.toLowerCase();te=(Array.isArray(H)?H:[]).filter(Te=>{const Re=String(Te?.name??"").toLowerCase(),ft=String(Te?.barcode??"").toLowerCase();return Re.includes(he)||ft.includes(he)}).slice(0,30)}const ye=te.slice(0,30).map(he=>({value:Xe(he?.id),label:`${he?.name??""}${he?.barcode?` • ${he.barcode}`:""}${he?.quantity!==void 0&&he?.quantity!==null?` • Stock: ${he.quantity}`:""}`,product:he}));be&&j(ye)},250);return()=>{be=!1,clearTimeout(ge)}},[ie,P,V,H,y]),i.useEffect(()=>{g({}),m({}),u(""),j([]),R(!1),w(""),p(0),A(""),q(ae()),v([])},[n,r,l]);const oe=i.useCallback((fe,be=1)=>{const ge=fe?.id;if(!ge)return;const te=Number(fe?.quantity||0);if(te<=0){_.error("Out of stock.",{duration:1e3});return}const ye=Xn(be,te);g(he=>{const Te=he||{};return Object.prototype.hasOwnProperty.call(Te,Xe(ge))?(_.error("Product already added.",{duration:1e3}),Te):{...Te,[Xe(ge)]:ye}})},[g]),Ce=i.useCallback((fe,be,ge)=>{g(te=>{const ye=te||{},he=Xe(fe);return Object.prototype.hasOwnProperty.call(ye,he)?{...ye,[he]:Xn(be,ge)}:ye})},[]),Oe=i.useCallback(fe=>{g(be=>{const ge=be||{},te=Xe(fe);if(!Object.prototype.hasOwnProperty.call(ge,te))return ge;const ye={...ge};return delete ye[te],ye})},[]),Pe=i.useCallback((fe,be,ge)=>{m(te=>({...te||{},[Xe(fe)]:Xn(be,ge)}))},[]),Fe=i.useCallback((fe,be)=>{be?.product&&oe(be.product,1),u(""),j(ie)},[oe,ie]),Ee=i.useCallback(fe=>{if(fe.key!=="Enter")return;fe.preventDefault();const be=Array.isArray(x)&&x.length>0?x[0]:null;if(be?.product){oe(be.product,1),u(""),j(ie);return}const ge=String(y||"").trim().toLowerCase();if(ge.length===0)return;const te=(Array.isArray(H)?H:[]).find(ye=>{const he=String(ye?.name??"").toLowerCase(),Te=String(ye?.barcode??"").toLowerCase();return he.includes(ge)||Te.includes(ge)});te&&(oe(te,1),u(""),j(ie))},[oe,ie,H,x,y]),Ke=()=>{if(!t){_.error("Missing token.",{duration:1e3});return}if(!n){_.error("Select class.",{duration:1e3});return}if(!r){_.error("Select section.",{duration:1e3});return}if(!l){_.error("Select student.",{duration:1e3});return}if(!ee||ee.length===0){_.error("Add at least one product.",{duration:1e3});return}R(!0)},{trigger:Ve,isMutating:Ue}=Je(t?ls.sellProduct:null,(fe,{arg:be})=>Oa(fe,{arg:be},t)),We=async()=>{if(!D){_.error("Select payment type.",{duration:1e3});return}const fe=(Array.isArray(ee)?ee:[]).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||""})),be={amount:me,class:n,section:r,student_id:l,payment_type:D,discount:ve,notes:S||"",receipt_date:O?ae(O).format("YYYY-MM-DD"):"",product:JSON.stringify(fe),total_payable_amount:me,attchement:U[0]?.originFileObj||""};try{const te=Array.isArray(U)&&U.length>0&&U[0]?.originFileObj?(()=>{const he=new FormData;return Object.entries(be).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})():be,ye=await Ve(te);ye?.Status==="Success"?(_.success("Success! Product sold.",{duration:1e3}),R(!1),g({}),m({}),u(""),j(ie),w(""),p(0),A(""),q(ae()),v([])):_.error(ye?.msg??"Failed to submit.",{duration:1e3})}catch{_.error("Failed to submit.",{duration:1e3})}},pt=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,be)=>{const ge=Xe(be?.id),te=Number(be?.quantity||0),ye=se.has(ge),he=(ye?h?.[ge]:C?.[ge])??1;return e.jsx(s.InputNumber,{min:1,max:Number.isFinite(te)&&te>0?te:void 0,value:he,onChange:Te=>{ye?Ce(ge,Te,te):Pe(ge,Te,te)},disabled:te<=0})}},{title:"Amount",key:"amount",width:140,render:(fe,be)=>{const ge=Xe(be?.id),te=(se.has(ge)?h?.[ge]:C?.[ge])??1;return Number(be?.price||0)*Number(te||1)}},{title:"Action",key:"action",width:120,render:(fe,be)=>{const ge=Xe(be?.id),te=Number(be?.quantity||0),ye=se.has(ge),he=(ye?h?.[ge]:C?.[ge])??1;return ye?e.jsx(s.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(X.DeleteOutlined,{}),onClick:()=>Oe(ge),style:{padding:2}}):e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.PlusOutlined,{}),disabled:te<=0,onClick:()=>oe(be,he),style:{padding:2}})}}],[oe,se,h,C,Oe,Pe,Ce]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(le,{pt:5,pb:2,children:[e.jsxs(le,{style:{padding:"12px 16px"},children:[e.jsx(le,{children:"Sell Product"}),e.jsx(s.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(Z,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:fe=>{const be=fe?.value??"";a(be),o(""),d(""),b(ge=>!ge)}}),e.jsx(Z,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:fe=>{const be=fe?.value??"";o(be),d("")}},`section_${c}`),e.jsx(Z,{options:$,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(s.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(le,{style:{marginTop:12},children:"Product Section"}),e.jsx(s.AutoComplete,{value:y,options:x,onSearch:u,onFocus:()=>{P&&String(y||"").trim().length<2&&j(ie)},onSelect:Fe,disabled:!P,children:e.jsx(s.Input,{placeholder:"Search by product name or barcode",onKeyDown:Ee,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",ht(me)]})]}),e.jsx(s.Table,{rowKey:fe=>Xe(fe?.id),columns:pt,dataSource:H,loading:ne,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:ee.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:ht(me)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(de,{type:"button",value:"Submit",disabled:!P||ee.length===0,onClick:Ke,style:{flex:1,minWidth:140}}),e.jsx(s.Button,{type:"text",style:M,onClick:()=>{g({}),m({}),u(""),j(ie)},disabled:ee.length===0,children:"Clear"})]})]})]})})]}),e.jsx(s.Modal,{open:I,title:"Payment",onCancel:()=>R(!1),onOk:We,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(s.Select,{value:D||void 0,onChange:w,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(s.DatePicker,{value:O,onChange:fe=>q(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(s.InputNumber,{min:0,max:me,value:f,onChange:fe=>p(Number(fe||0)),style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Attachment"}),e.jsx(s.Upload,{fileList:U,beforeUpload:()=>!1,onChange:({fileList:fe})=>v((fe||[]).slice(-1)),maxCount:1,children:e.jsx(s.Button,{icon:e.jsx(X.UploadOutlined,{}),children:"Upload"})})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Notes"}),e.jsx(s.Input.TextArea,{value:S,onChange:fe=>A(fe.target.value),rows:3})]}),e.jsx(s.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:ht(me)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:ht(ve)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Net Amount"}),e.jsx("span",{children:ht(re)})]})]})})]})})]})}const pu=({token:t})=>e.jsx(uu,{token:t}),fa=$e.unit,mu=({token:t,page:n=1,perPage:a=10})=>Bn({baseUrl:fa.list,page:n,perPage:a,token:t}),yu={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function fu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:b,data:y,mutate:u}=mu({token:t,page:n.page,perPage:n.rowsPerPage}),x=async R=>{try{await u($n(fa.add,R,t),st(R)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){_.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},j=R=>{R.preventDefault();const D=new FormData(R.target);x(D),R.target.reset()},C=(R,D)=>{a({page:R,rowsPerPage:parseInt(D,10)})},m=async R=>{try{await u(Un(fa.remove,R,t),Qe(R)),_.success("Success! Deleted item.",{duration:1e3})}catch(D){_.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},h=R=>{d(R),o(!0)},g=async R=>{R.preventDefault();const D=new FormData(R.target);D.set("id",String(l?.id??""));try{await cn(fa.edit,D,t),await u(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(w){_.error(w?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},I=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(R,D)=>String(R?.name??"").localeCompare(String(D?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(R,D)=>String(R?.description??"").localeCompare(String(D?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(R,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(D),style:{padding:2}}),e.jsx(ot,{id:D?.id,funcName:m})]})}],[m]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.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:g,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"name",label:"Unit Name",defaultValue:l?.name??"",required:"required"}),e.jsx(J,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:yu,children:"Cancel"})]})]})})}),e.jsxs(le,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(le,{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(J,{type:"text",name:"name",label:"Unit Name*",required:"required"}),e.jsx(J,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(le,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Me,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(le,{pt:3,children:e.jsx(Le,{parentCallback:C,data:{newData:y,columns:I,columnstype:"antd",action:!1,Loading:c,error:b}})})]})]})]})}const hu=({token:t})=>e.jsx(fu,{token:t}),gu=$e.product.sellReports,xu=$e.academy.classes,bu=$e.academy.sections,Su=$e.student.dropdown,Kr=t=>{const n=Number(t??0);return Number.isFinite(n)?n.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function ju({token:t}){const n=i.useRef(null),[a,r]=i.useState(null),[o,l]=i.useState(""),[d,c]=i.useState(""),[b,y]=i.useState(""),[u,x]=i.useState(!1),j=v=>{const M=v?.data?.data??v?.data??v??[];return Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[]},{data:C}=G(t?[xu,t]:null,([v,M])=>Q(v,M)),m=i.useMemo(()=>j(C),[C]),h=t&&o?`${bu}?class_id=${encodeURIComponent(String(o))}`:null,{data:g}=G(h?[h,t]:null,([v,M])=>Q(v,M)),I=i.useMemo(()=>j(g),[g]),R=t&&o&&d?`${Su}?class=${encodeURIComponent(String(o))}§ion=${encodeURIComponent(String(d))}`:null,{data:D}=G(R?[R,t]:null,([v,M])=>Q(v,M)),w=i.useMemo(()=>j(D),[D]),{trigger:f,isMutating:p,data:S}=Je(gu,(v,{arg:M})=>Os(v,{arg:M},t));i.useEffect(()=>{const M=new Date().toISOString().slice(0,10);f({duration:[M,M]})},[f]);const A=i.useMemo(()=>{const v=S?.data??S??[];return Array.isArray(v)?v:[]},[S]),O=v=>{const M=Array.isArray(v?.product_details)?v.product_details:[];return M.length===0?null:e.jsx(s.Table,{size:"small",bordered:!0,pagination:!1,rowKey:P=>`${v?.receipt_id??"r"}_${P?.product_name??P?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:P=>Kr(P)}],dataSource:M})},q=[{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:v=>Kr(v)}],U=async()=>{if(!a||a.length!==2)return;const[v,M]=a;await f({duration:[v.format("YYYY-MM-DD"),M.format("YYYY-MM-DD")],class:o||"",section:d||"",student_id:b||""})};return e.jsx("div",{children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,lg:8,children:e.jsx(s.Card,{title:e.jsx(s.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(s.DatePicker.RangePicker,{value:a,onChange:r,style:{width:"100%"}})]}),e.jsx(Z,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:v=>{const M=v?.value??"";l(M),c(""),y(""),x(P=>!P)}}),e.jsx(Z,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:v=>{const M=v?.value??"";c(M),y("")}},`section_${u}`),e.jsx(Z,{options:w,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:v=>y(v?.value??"")}),e.jsx(de,{type:"button",value:p?"Searching...":"Search",disabled:p,onClick:U,style:{width:"100%"}})]})})}),e.jsx(s.Col,{xs:24,lg:16,children:e.jsx(s.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Sell Reports"}),e.jsx(dn,{data:{tableRef:n}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(_t,{})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:p,rowKey:v=>String(v?.receipt_id??v?.receipt_no??Math.random()),columns:q,expandable:{expandedRowRender:O},dataSource:A,pagination:{pageSize:20}})]})})})]})})}const vu=({token:t})=>e.jsx(ju,{token:t}),_u=$e.product;function wu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState([]),[l,d]=i.useState([]),[c,b]=i.useState(!1),[y,u]=i.useState(!1),[x,j]=i.useState(null),[C,m]=i.useState(0),[h,g]=i.useState(null),[I,R]=i.useState(""),D=i.useRef(null),w=on.useReactToPrint({contentRef:D,documentTitle:"Stock Barcodes"}),{isLoading:f,error:p,data:S,mutate:A}=fo({token:t,page:n.page,perPage:n.rowsPerPage}),O=(N,E)=>{a({page:N,rowsPerPage:parseInt(E,10)})},q={selectedRowKeys:r,onChange:(N,E)=>{o(N),d(E)}},U=N=>{j(N),m(Number(N?.quantity??0)),g(null),R(""),b(!0)},v=()=>{b(!1),j(null),m(0),g(null),R("")},M=async()=>{if(!x?.id)return;u(!0);const N=new FormData;N.append("product_id",String(x.id)),N.append("qty",String(C??0)),h&&N.append("tran_date",h.format("YYYY-MM-DD")),I&&N.append("remarks",I);try{const E=await cn(_u.addStock,N,t);E?.Status==="Success"?(_.success("Success! Updated quantity.",{duration:1e3}),v(),await A()):_.error(E?.msg??"Failed to update quantity.",{duration:1e3})}catch{_.error("Failed to update quantity.",{duration:1e3})}finally{u(!1)}},P=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:(N,E)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(s.Button,{size:"small",onClick:()=>U(E),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:x?.name?`Update Stock: ${x.name}`:"Update Stock",open:c,onCancel:v,onOk:M,okButtonProps:{loading:y},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(s.InputNumber,{min:0,style:{width:"100%"},value:C,onChange:N=>m(N??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{style:{width:"100%"},value:h,onChange:g})]}),e.jsx(Dt,{label:"Remarks",name:"remarks",rows:3,value:I,onChange:N=>R(N.target.value)})]})}),e.jsxs(le,{pt:5,pb:2,children:[e.jsxs(le,{children:["Manage Stock",e.jsx(de,{type:"button",value:"Print Barcodes",disabled:!l||l.length===0,onClick:()=>w?.(),style:{minWidth:170}})]}),e.jsx(le,{style:{padding:"12px 16px"},children:e.jsx(s.Card,{style:{borderRadius:16},children:e.jsx(Le,{parentCallback:O,data:{newData:S,columns:P,columnstype:"antd",action:!1,Loading:f,error:p,rowSelection:q}})})})]}),e.jsx("div",{style:{position:"absolute",left:-1e4,top:0},children:e.jsx("div",{ref:D,children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,padding:24},children:(Array.isArray(l)?l:[]).map(N=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:N?.name??""}),e.jsx(Ei,{value:String(N?.barcode??N?.id??""),height:50,width:1.6,displayValue:!0})]},N?.id??N?.barcode??N?.name))})})})]})}const Cu=({token:t})=>e.jsx(wu,{token:t}),Au=$e.report.stock,Tu=$e.product.dropdown,Ru=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function Iu({token:t}){const n=i.useRef(null),[a,r]=i.useState(null),[o,l]=i.useState(""),{data:d}=G(t?[Tu,t]:null,([m,h])=>Q(m,h)),c=i.useMemo(()=>Ru(d),[d]),{trigger:b,isMutating:y,data:u}=Je(Au,(m,{arg:h})=>Os(m,{arg:h},t));i.useEffect(()=>{const h=new Date().toISOString().slice(0,10);b({duration:[h,h]})},[b]);const x=i.useMemo(()=>{const m=u?.data??u??[];return(Array.isArray(m)?m:[]).flatMap(g=>(Array.isArray(g?.ledger)?g.ledger:[]).map((I,R)=>({key:`${g.product_id??g.product_name??"p"}-${R}`,date:I?.date,product:g?.product_name,opening:I?.opening,inward:I?.inward,outward:I?.outward,closing:I?.closing})))},[u]),j=[{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:m=>e.jsx("span",{style:{color:Number(m)<0?"red":"green"},children:m})}],C=async()=>{if(!a||a.length!==2)return;const[m,h]=a;await b({duration:[m.format("YYYY-MM-DD"),h.format("YYYY-MM-DD")],product_id:o||""})};return e.jsxs(s.Card,{title:e.jsx(s.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(s.DatePicker.RangePicker,{value:a,onChange:r}),e.jsxs("select",{value:o,onChange:m=>l(m.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),c.map(m=>e.jsx("option",{value:String(m?.value??""),children:String(m?.label??"")},String(m?.value??m?.id??m?.label)))]}),e.jsx(s.Button,{type:"primary",onClick:C,loading:y,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(dn,{data:{tableRef:n}})})]}),e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(_t,{})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:y,rowKey:"key",columns:j,dataSource:x,pagination:{pageSize:50}})]})]})}const Du=({token:t})=>e.jsx(Iu,{token:t}),Gr=[{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"}],jt={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},Jr=[{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"}],Qr=[{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 ku(){const[t,n]=i.useState("dashboard"),[a,r]=i.useState("This Month"),[o,l]=i.useState(""),[d,c]=i.useState(""),[b,y]=i.useState(1),[u,x]=i.useState(10),[j,C]=i.useState(""),m=i.useRef(null),h=["dashboard","allPackages","published","draft","deprecated","pendingApproval"].includes(t),g=i.useMemo(()=>{if(!j.trim())return Jr;const f=j.toLowerCase();return Jr.filter(p=>Object.values(p).some(S=>String(S??"").toLowerCase().includes(f)))},[j]),I=i.useMemo(()=>{const f=(b-1)*u;return g.slice(f,f+u)},[g,b,u]),R=()=>{y(1)},D=()=>{const f=[{title:"Total Packages",value:jt.total_packages,icon:e.jsx(X.FileTextOutlined,{}),color:"#1976d2"},{title:"Total Downloads",value:jt.total_downloads.toLocaleString(),icon:e.jsx(X.StarOutlined,{}),color:"#2e7d32"},{title:"Active Packages",value:jt.active_packages,icon:e.jsx(X.CheckCircleOutlined,{}),color:"#0288d1"},{title:"Deprecated",value:jt.deprecated_packages,icon:e.jsx(X.CloseCircleOutlined,{}),color:"#d32f2f"},{title:"Pending Approval",value:jt.pending_approval,icon:e.jsx(X.ClockCircleOutlined,{}),color:"#ed6c02"},{title:"Published This Month",value:jt.published_this_month,icon:e.jsx(X.CalendarOutlined,{}),color:"#9c27b0"},{title:"Published This Week",value:jt.published_this_week,icon:e.jsx(X.SyncOutlined,{}),color:"#455a64"},{title:"Needs Update",value:jt.packages_needing_update,icon:e.jsx(X.CodeOutlined,{}),color:"#c62828"},{title:"With Issues",value:jt.packages_with_issues,icon:e.jsx(X.CloseCircleOutlined,{}),color:"#f57c00"}];return e.jsx(s.Row,{gutter:[16,16],children:f.map((p,S)=>e.jsx(s.Col,{xs:24,sm:12,md:8,lg:6,children:e.jsxs(s.Card,{style:{display:"flex",alignItems:"center",padding:16,borderLeft:`6px solid ${p.color}`,transition:"0.2s",cursor:"default"},bodyStyle:{display:"flex",alignItems:"center",width:"100%"},children:[e.jsx(le,{style:{width:48,height:48,borderRadius:"50%",backgroundColor:`${p.color}15`,color:p.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,marginRight:16,flexShrink:0},children:p.icon}),e.jsxs(le,{children:[e.jsx(s.Typography.Text,{type:"secondary",style:{fontSize:12,fontWeight:500},children:p.title}),e.jsx("div",{style:{fontSize:22,fontWeight:700,marginTop:4},children:p.value})]})]})},S))})},w=()=>{const f=[{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:p=>{let S="default";return p==="published"?S="green":p==="draft"?S="orange":p==="deprecated"?S="red":p==="pending"&&(S="blue"),e.jsx(s.Tag,{color:S,children:p.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:(p,S)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer",fontSize:13},children:"View"})}];return t==="dashboard"?[]:f};return e.jsx(le,{pt:5,pb:1,children:e.jsxs(s.Row,{gutter:[16,16],children:[e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(le,{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(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"NPM Package Report"})}),e.jsxs(le,{p:3,children:[e.jsxs(s.Row,{gutter:[16,16],mb:3,children:[h&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(Z,{options:Gr,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:Gr.find(f=>f.value===a)||null,onChange:f=>r(f?.value||"This Month")})}),a==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(s.Col,{xs:24,md:6,children:e.jsx(gt,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:f=>l(f?f.format("YYYY-MM-DD"):"")})}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(gt,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:f=>c(f?f.format("YYYY-MM-DD"):"")})})]})]}),e.jsx(s.Col,{xs:24,md:6,children:e.jsx(le,{display:"flex",alignItems:"center",height:"100%",mt:t==="dashboard"?0:2,children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:R})})})]}),e.jsx(s.Tabs,{activeKey:t,onChange:n,items:Qr})]})]})}),e.jsx(s.Col,{xs:24,children:e.jsxs(s.Card,{children:[e.jsx(le,{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(s.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:Qr.find(f=>f.key===t)?.label||"Report"})}),e.jsxs(le,{p:3,children:[t!=="dashboard"&&e.jsx(dn,{data:{tableRef:m}}),t==="dashboard"?D():e.jsx(s.Table,{size:"small",dataSource:I,columns:w(),loading:!1,pagination:!1,bordered:!0,rowKey:f=>f.npm_id||f.package_name||Math.random(),ref:m}),t!=="dashboard"&&g.length>0&&e.jsx(s.Pagination,{current:b,pageSize:u,total:g.length,onChange:(f,p)=>{y(f),x(p)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const Ea=t=>t??localStorage.getItem("authToken")??"",Ns=(t,n)=>{const a=String(t??""),r=String(n??"");return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r},Ae={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"}},ho=()=>Ns(nt(),Ae.upload),Ou=()=>Ns(nt(),Ae.staff.uploadProfile),Pu=()=>Ns(nt(),Ae.staff.uploadDocuments),Eu=async({baseUrl:t,page:n=1,perPage:a=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,Ea(r))},bt=async(t,n,a)=>Ye(t,n,Ea(a)),Mt=async(t,n,a)=>ut(t,n,Ea(a)),Ln=async(t,n,a)=>at(t,n,Ea(a)),qt=Ae.staff,Mu=Ae.master.shift.dropdown,Fu=Ae.master.department.dropdown,Nu=Ae.master.designation.dropdown,$u=Ae.roleDropdown,Zn=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Uu=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",xn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Xr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Bu({token:t,mode:n,staffId:a,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,b]=i.useState(r?.roleValue??null),[y,u]=i.useState(r?.departmentValue??null),[x,j]=i.useState(r?.designationValue??null),[C,m]=i.useState(r?.genderValue??null),[h,g]=i.useState(r?.shiftValue??(d?[]:null)),[I,R]=i.useState(r?.dob?ae(r.dob):null),[D,w]=i.useState(r?.doj?ae(r.doj):null),[f,p]=i.useState(r?.file??""),{data:S}=G(t?[Mu,t]:null,([L,z])=>Q(L,z)),{data:A}=G(t?[Fu,t]:null,([L,z])=>Q(L,z)),{data:O}=G(t?[Nu,t]:null,([L,z])=>Q(L,z)),{data:q}=G(t?[$u,t]:null,([L,z])=>Q(L,z)),{data:U}=G(t?[qt.lastEmpNo,t]:null,([L,z])=>Q(L,z)),v=i.useMemo(()=>Zn(S),[S]),M=i.useMemo(()=>Zn(A),[A]),P=i.useMemo(()=>Zn(O),[O]),N=i.useMemo(()=>Zn(q),[q]),E=i.useMemo(()=>{const L=U?.data?.emp_number??U?.emp_number??U?.data??"";return String(L??"")},[U]),F=async L=>{L.preventDefault();const z=new FormData(L.target);z.set("role",c?.value??c??""),z.set("department",y?.value??y??""),z.set("designation",x?.value??x??""),z.set("gender",C?.value??C??""),z.set("dob",I?I.format("YYYY-MM-DD"):""),z.set("doj",D?D.format("YYYY-MM-DD"):""),d?(z.delete("shift_id"),(Array.isArray(h)?h:[]).forEach(T=>{z.append("shift_id[]",T?.value??T??"")})):z.set("shift_id",h?.value??h??""),f&&z.set("file",f);try{const k=n==="edit"&&a,T=k?qt.editBasic:qt.addBasic;k&&z.set("staff_id",String(a));const $=k?await Mt(T,z,t):await bt(T,z,t),B=$?.ID??$?.id??a??null;_.success("Success!",{duration:1e3}),o?.({staffId:B,basic:{roleValue:c,departmentValue:y,designationValue:x,genderValue:C,shiftValue:h,dob:I,doj:D,file:f}})}catch(k){_.error(k?.response?.data?.msg??k?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:F,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(J,{type:"number",name:"emp_number",label:"EMP No",defaultValue:r?.emp_number??E,required:!0}),e.jsx(J,{type:"text",name:"f_name",label:"First Name",defaultValue:r?.f_name??"",required:!0}),e.jsx(J,{type:"text",name:"l_name",label:"Last Name",defaultValue:r?.l_name??"",required:!0}),e.jsx(J,{type:"text",name:"pan_no",label:"PAN",defaultValue:r?.pan_no??""}),e.jsx(J,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:r?.adhar_no??""}),e.jsx(Z,{label:"Role",options:N,value:c,onChange:L=>b(L??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Z,{label:"Department",options:M,value:y,onChange:L=>u(L??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Z,{label:"Designation",options:P,value:x,onChange:L=>j(L??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Z,{label:"Gender",options:[{value:"Male",label:"Male"},{value:"Female",label:"Female"},{value:"Other",label:"Other"}],value:C,onChange:L=>m(L??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(J,{type:"text",name:"email",label:"Email",defaultValue:r?.email??""}),e.jsxs("div",{children:[e.jsx("div",{style:xn,children:"DOB"}),e.jsx(s.DatePicker,{value:I,onChange:L=>R(L),style:Xr,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:xn,children:"DOJ"}),e.jsx(s.DatePicker,{value:D,onChange:L=>w(L),style:Xr,placeholder:"Select DOJ"})]}),e.jsx(J,{type:"text",name:"bloodGroup",label:"Blood Group",defaultValue:r?.bloodGroup??""}),e.jsx(J,{type:"text",name:"contact_no",label:"Contact No",defaultValue:r?.contact_no??"",required:!0}),e.jsx(J,{type:"text",name:"education",label:"Education",defaultValue:r?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:xn,children:"Shift"}),e.jsx(Z,{options:v,value:h,onChange:L=>g(L??(d?[]:null)),isMulti:d,closeMenuOnSelect:!d,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:xn,children:"Profile Picture"}),e.jsx(s.Upload,{maxCount:1,action:Ou(),headers:t?{Authorization:t}:void 0,onChange:L=>{if(L?.file?.status==="done"){const z=Uu(L?.file?.response);z&&p(z)}L?.file?.status==="removed"&&p("")},children:e.jsx(s.Button,{type:"link",style:{paddingLeft:0},children:f?"Change":"Upload"})})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:xn,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(de,{type:"submit",value:"Save & Next",color:"primary"})})]})})}const ea={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Zr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Lu=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ei=t=>{if(!t)return null;const n=ae(t);return n.isValid()?n:null};function qu({token:t,mode:n,staffId:a,initialRows:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(()=>(Array.isArray(r)&&r.length?r:[{name:"",from:null,to:null,image:""}]).map(m=>({name:m?.name??"",from:ei(m?.from),to:ei(m?.to),image:m?.image??""}))),b=i.useMemo(()=>t?{Authorization:t}:void 0,[t]),y=(C,m)=>{c(h=>h.map((g,I)=>I===C?{...g,...m}:g))},u=()=>c(C=>[...C,{name:"",from:null,to:null,image:""}]),x=C=>c(m=>m.length<=1?m:m.filter((h,g)=>g!==C)),j=async C=>{if(C.preventDefault(),!a){_.error("Missing staff id.",{duration:1e3});return}const m=new FormData;m.append("staff_id",String(a)),d.forEach((h,g)=>{m.append(`experience[${g}][name]`,String(h?.name??"")),m.append(`experience[${g}][from]`,h?.from?h.from.format("YYYY-MM-DD"):""),m.append(`experience[${g}][to]`,h?.to?h.to.format("YYYY-MM-DD"):""),m.append(`experience[${g}][image]`,String(h?.image??""))});try{const h=n==="edit",g=h?qt.editExperience:qt.addExperience,I=h?await Mt(g,m,t):await bt(g,m,t);_.success("Success!",{duration:1e3}),o?.({experience:d,result:I})}catch(h){_.error(h?.response?.data?.msg??h?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[d.map((C,m)=>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:ea,children:"Name"}),e.jsx("input",{value:C.name,onChange:h=>y(m,{name:h.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:ea,children:"From"}),e.jsx(s.DatePicker,{value:C.from,onChange:h=>y(m,{from:h}),style:Zr})]}),e.jsxs("div",{children:[e.jsx("div",{style:ea,children:"To"}),e.jsx(s.DatePicker,{value:C.to,onChange:h=>y(m,{to:h}),style:Zr})]}),e.jsxs("div",{children:[e.jsx("div",{style:ea,children:"Document"}),e.jsx(s.Upload,{maxCount:1,action:Pu(),headers:b,onChange:h=>{if(h?.file?.status==="done"){const g=Lu(h?.file?.response);g&&y(m,{image:g})}h?.file?.status==="removed"&&y(m,{image:""})},children:e.jsx(s.Button,{icon:e.jsx(X.UploadOutlined,{}),children:"Upload"})}),!!C.image&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:C.image})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:e.jsx(s.Button,{type:"text",icon:e.jsx(X.DeleteOutlined,{}),danger:!0,onClick:()=>x(m),disabled:d.length<=1})})]},`exp-${m}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(s.Button,{icon:e.jsx(X.PlusOutlined,{}),onClick:u,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(s.Button,{onClick:l,children:"Back"}),e.jsx(de,{type:"submit",value:"Save & Next",color:"primary"})]})]})]})})}const ti=(t,n=[])=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){const a=n.length?n:["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 a){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[]},bn=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function zu({token:t,mode:n,staffId:a,initialValues:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(r?.type??"Permanent"),[b,y]=i.useState(r?.salary_type??bn[0]?.value),[u,x]=i.useState(Number(r?.amount??0)),[j,C]=i.useState(Number(r?.basic_pay)),[m,h]=i.useState(r?.declarationPERyear??""),{data:g}=G(t?[jd,t]:null,([p,S])=>Q(p,S),{revalidateOnFocus:!1}),I=i.useMemo(()=>ti(g,["allowances","Allowances"]),[g]),R=i.useMemo(()=>ti(g,["dedection","Dedection","deductions","Deductions"]),[g]),D=i.useMemo(()=>{const p=Number(j||0),S=(Array.isArray(I)?I:[]).map(v=>{const M=v?.amount_type??v?.amountType??v?.type??"",P=Number(v?.Amount??v?.amount??0),E=String(M).trim().toLowerCase()==="flat"?P:Number(p)/100*Number(P||0);return{...v,value:Number.isFinite(E)?E:0}}),A=(Array.isArray(R)?R:[]).map(v=>{const M=v?.amount_type??v?.amountType??v?.type??"",P=Number(v?.Amount??v?.amount??0),E=String(M).trim().toLowerCase()==="flat"?P:Number(p)/100*Number(P||0);return{...v,value:Number.isFinite(E)?E:0}}),O=S.reduce((v,M)=>v+Number(M?.value||0),0),q=A.reduce((v,M)=>v+Number(M?.value||0),0),U=Math.max(0,Number(p)+O-q);return{allowances:S,deductions:A,netAmount:U}},[I,R,j]),w=async p=>{if(p.preventDefault(),!a){_.error("Missing staff id.",{duration:1e3});return}const S=new FormData;S.append("staff_id",String(a)),S.append("type",d),d==="Nonpermanent"?(S.append("salary_type",b??""),S.append("amount",String(u||"")),S.append("Allowances",JSON.stringify([])),S.append("Dedection",JSON.stringify([]))):(S.append("basic_pay",String(j||"")),S.append("declarationPERyear",String(m??"")),S.append("Allowances",JSON.stringify(D.allowances||[])),S.append("Dedection",JSON.stringify(D.deductions||[])),S.append("amount",String(D.netAmount||0)));try{const A=n==="edit",O=A?qt.editPayroll:qt.addPayroll,q=A?await Mt(O,S,t):await bt(O,S,t);o?.({payroll:{staffType:d,salaryType:b,amount:u,basicPay:j,declaration:m},result:q})}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed.",{duration:1e3})}},f=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(p,S)=>`${S?.Amount??""} / ${S?.amount_type??""}`},{title:"Value",dataIndex:"value",key:"value",width:120}],[]);return e.jsx("form",{onSubmit:w,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(Z,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:d==="Nonpermanent"?"Non Permanent":"Permanent",value:d},onChange:p=>c(p?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),d==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(Z,{label:"Type",options:bn,value:bn.find(p=>p.value===b)??bn[0],onChange:p=>y(p?.value??bn[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(J,{type:"number",label:"Amount",value:u,onChange:p=>x(Number(p.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{type:"number",label:"Basic Pay",value:j,onChange:p=>C(Number(p.target.value||0)),required:!0}),e.jsx(J,{type:"text",label:"IT Declarations/Year",value:m,onChange:p=>h(p.target.value)}),e.jsx(J,{type:"number",label:"Net Amount",value:D.netAmount,disabled:!0})]})]}),d==="Permanent"&&e.jsxs(e.Fragment,{children:[e.jsx(s.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Allowances"}),children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(p,S)=>`${p?.title??"a"}-${S}`,columns:f,dataSource:D.allowances,pagination:!1})}),e.jsx(s.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Deductions"}),children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(p,S)=>`${p?.title??"d"}-${S}`,columns:f,dataSource:D.deductions,pagination:!1})})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:e.jsx(de,{type:"submit",value:"Finish",color:"primary"})})]})})}const Yu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Wu({token:t,mode:n="add",staffId:a,onFinished:r}){const[o,l]=i.useState(0),[d,c]=i.useState(a??null),[b,y]=i.useState(null),[u,x]=i.useState(null),[j,C]=i.useState(null),m=n==="edit"?a??d:null,h=i.useMemo(()=>m?`${Ae.staff.basicById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),g=i.useMemo(()=>m?`${Ae.staff.experienceById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),I=i.useMemo(()=>m?`${Ae.staff.payrollById}?staff_id=${encodeURIComponent(String(m))}`:null,[m]),{data:R}=G(t&&h?[h,t]:null,([O,q])=>Q(O,q)),{data:D}=G(t&&g?[g,t]:null,([O,q])=>Q(O,q)),{data:w}=G(t&&I?[I,t]:null,([O,q])=>Q(O,q)),f=i.useMemo(()=>{const O=Yu(R)[0]??R?.data??R??null;return O?{emp_number:O?.emp_number??O?.empNo??"",f_name:O?.f_name??O?.firstname??O?.first_name??"",l_name:O?.l_name??O?.lastname??O?.last_name??"",pan_no:O?.pan_no??"",adhar_no:O?.adhar_no??"",email:O?.email??"",dob:O?.dob??"",doj:O?.doj??"",bloodGroup:O?.bloodGroup??O?.blood_group??"",contact_no:O?.contact_no??O?.phone??"",education:O?.education??"",address:O?.address??"",file:O?.file??O?.profile_picture??""}:null},[R]),p=i.useMemo(()=>{const O=D?.data??D??null;return(Array.isArray(O?.experience)?O.experience:Array.isArray(O)?O:[]).map(U=>({name:U?.name??"",from:U?.from??"",to:U?.to??"",image:U?.image??""}))},[D]),S=i.useMemo(()=>{const O=w?.data??w??null;return O?{type:O?.type??"Permanent",salary_type:O?.salary_type??"",amount:O?.amount??"",basic_pay:O?.basic_pay??"",declarationPERyear:O?.declarationPERyear??""}:null},[w]),A=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(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:n==="edit"?"Edit Staff":"Add Staff"}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(s.Steps,{current:o,items:A}),o===0&&e.jsx(Bu,{token:t,mode:n,staffId:m,initialValues:f,onSubmitted:({staffId:O})=>{O&&c(O),l(1)}}),o===1&&e.jsx(qu,{token:t,mode:n,staffId:m??d,initialRows:p,onBack:()=>l(0),onSubmitted:()=>l(2)}),o===2&&e.jsx(zu,{token:t,mode:n,staffId:m??d,initialValues:S,onBack:()=>l(1),onSubmitted:()=>{_.success("Completed.",{duration:1e3}),r?.({staffId:m??d}),l(0),n!=="edit"&&(c(null),y(null),x(null),C(null))}})]})})]})}function Vu({token:t}){return e.jsx(Wu,{token:t,mode:"add"})}const Hu=({token:t})=>e.jsx(Vu,{token:t}),ta=Ae.staff,Ku=Ae.roleDropdown,Gu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Ju=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Qu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(""),[l,d]=i.useState(""),{data:c}=G(t?[Ku,t]:null,([I,R])=>Q(I,R)),b=i.useMemo(()=>Gu(c),[c]),y=i.useMemo(()=>{const I=n.page,R=n.rowsPerPage,D=r&&!l?`${ta.searchByRole}?role_id=${encodeURIComponent(String(r))}`:l?`${ta.searchByKeywords}?key=${encodeURIComponent(String(l))}`:ta.list,w=D.includes("?")?"&":"?";return`${D}${w}page=${encodeURIComponent(String(I))}&per_page=${encodeURIComponent(String(R))}`},[n.page,n.rowsPerPage,l,r]),{isLoading:u,error:x,data:j,mutate:C}=G(t?[y,t]:null,([I,R])=>Q(I,R)),m=i.useMemo(()=>Ju(j),[j]),h=async I=>{const R=I?.id??I?.fk_staffID??I?.staff_id;if(R)try{await Ln(ta.deactivate,R,t),_.success("Success! Staff deactivated.",{duration:1e3}),await C()}catch(D){_.error(D?.response?.data?.msg??D?.message??"Failed to deactivate staff.",{duration:1e3})}},g=i.useMemo(()=>[{title:"Name",key:"name",ellipsis:!0,render:(I,R)=>`${R?.firstname??R?.first_name??""} ${R?.lastname??R?.last_name??""}`.trim()||R?.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:(I,R)=>e.jsx(s.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(X.DeleteOutlined,{}),onClick:()=>h(R),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(s.Card,{title:e.jsx(s.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(Z,{options:[{value:"",label:"All Roles"},...b],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:I=>{o(I?.value??""),a(R=>({...R,page:1}))}}),e.jsx(J,{type:"text",label:"Keyword",value:l,onChange:I=>d(I.target.value),placeholder:"Search by keywords"}),e.jsx(de,{type:"button",value:"Refresh",onClick:()=>C()})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:7,style:{margin:0},children:"Staff Directory"}),children:e.jsx(s.Table,{bordered:!0,size:"small",loading:u,rowKey:I=>String(I?.id??I?.fk_staffID??I?.staff_id??Math.random()),columns:g,dataSource:m,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(I,R)=>a({page:I,rowsPerPage:R}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]})}const Xu=({token:t})=>e.jsx(Qu,{token:t}),Zu=Ae.attendance,ep=Ae.roleDropdown,ni=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},na={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"};function tp({token:t,open:n,onClose:a,roleId:r,onSaved:o}){const[l,d]=i.useState(null),[c,b]=i.useState(""),[y,u]=i.useState(ae()),[x,j]=i.useState(ae()),[C,m]=i.useState(ae()),h=i.useMemo(()=>r?`${Ae.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(r))}`:null,[r]),{data:g}=G(t&&h?[h,t]:null,([p,S])=>Q(p,S)),I=i.useMemo(()=>ni(g),[g]),{trigger:R,data:D}=Je(t?Ae.attendance.staffShiftByStaffId:null,(p,{arg:S})=>Lt(p,{arg:S},t)),w=i.useMemo(()=>ni(D),[D]),f=async()=>{if(!l?.value){_.error("Select staff.",{duration:1e3});return}if(!c){_.error("Select shift.",{duration:1e3});return}const p=new FormData;p.set("staffID",String(l.value)),p.set("shift_id",String(c)),p.set("attendance_date",y?y.format("YYYY-MM-DD"):""),p.set("intime",x?x.format("h:mm a"):""),p.set("outime",C?C.format("h:mm a"):"");try{await bt(Ae.attendance.manualAttendance,p,t),_.success("Success!",{duration:1e3}),o?.(),a?.(),d(null),b(""),u(ae()),j(ae()),m(ae())}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed.",{duration:1e3})}};return e.jsx(s.Modal,{open:n,onCancel:a,footer:null,destroyOnClose:!0,title:"Attendance",width:620,children:e.jsx(s.Card,{children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{label:"Staff",options:I,value:l,onChange:async p=>{if(d(p??null),b(""),p?.value&&R)try{await R({staff_id:p.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:na,children:"Shift"}),e.jsx(s.Radio.Group,{value:c,onChange:p=>b(p.target.value),style:{display:"grid",gap:8},children:w.map(p=>e.jsx(s.Radio,{value:p?.value,children:p?.label??p?.name??p?.title??String(p?.value??"")},String(p?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:na,children:"Date"}),e.jsx(s.DatePicker,{value:y,onChange:p=>p&&u(p),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:na,children:"Start Time"}),e.jsx(s.TimePicker,{value:x,onChange:p=>p&&j(p),use12Hours:!0,format:"h:mm a",style:ai})]}),e.jsxs("div",{children:[e.jsx("div",{style:na,children:"End Time"}),e.jsx(s.TimePicker,{value:C,onChange:p=>p&&m(p),use12Hours:!0,format:"h:mm a",style:ai})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(s.Button,{onClick:a,children:"Cancel"}),e.jsx(de,{type:"button",value:"Save",color:"primary",onClick:f})]})]})})})}const np=({tableRef:t,excelDisabled:n})=>{const a=new Date().getTime(),r=on.useReactToPrint({content:()=>t?.current});return e.jsx(s.Row,{justify:"end",children:e.jsx(s.Col,{children:e.jsxs(s.Row,{gutter:8,children:[e.jsx(s.Col,{children:e.jsx(s.Button,{type:"text",icon:e.jsx(X.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(s.Col,{children:n?e.jsx(s.Button,{type:"text",icon:e.jsx(X.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>_.error("You must save attendance before download",{duration:2e3})}):e.jsx(po.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:t?.current,children:e.jsx(s.Button,{type:"text",icon:e.jsx(X.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},ap=(t,n)=>{const a=t?.data?.data??t?.data??t??null;return a?n==="student"?Array.isArray(a?.student)?a.student:[]:Array.isArray(a?.staff)?a.staff:[]:[]},sp=t=>{const n=t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.total??t?.total_rows,a=Number(n);return Number.isFinite(a)&&a>=0?a:0},rp=(t,n)=>{const a=t?.data?.data??t?.data??t??null;return a?n==="student"?{sunday:String(a?.sunday??"").toLowerCase()==="yes",holiday:String(a?.holiday??"").toLowerCase()==="yes"}:{sunday:!!a?.sunday,holiday:!!a?.holiday}:{sunday:!1,holiday:!1}};function ip({token:t,url:n,columns:a,reload:r,setReload:o,saveBtnRef:l,setSaveBtnDisabled:d,date:c,type:b="staff"}){const y=i.useRef(null),[u,x]=i.useState({page:0,rowsPerPage:10}),[j,C]=i.useState(!1),[m,h]=i.useState(!1),[g,I]=i.useState(null),[R,D]=i.useState([]),[w,f]=i.useState({sunday:!1,holiday:!1}),[p,S]=i.useState(!0);i.useEffect(()=>{x(U=>({...U,page:0}))},[n]),i.useEffect(()=>{let U=!0;return(async()=>{if(!(!t||!n)){C(!0);try{const M=String(n).includes("?")?"&":"?",P=`${n}${M}page=${u.page+1}&per_page=${u.rowsPerPage}`,N=await Q(P,t);if(!U)return;I(N),N?.Status==="Success"?(d?.(!1),D(ap(N,b)),f(rp(N,b))):(d?.(!0),D([]),f({sunday:!1,holiday:!1}))}catch{if(!U)return;d?.(!0),D([])}finally{U&&C(!1)}}})(),()=>{U=!1}},[u.page,u.rowsPerPage,r,d,t,b,n]);const A=i.useMemo(()=>sp(g),[g]);i.useEffect(()=>{const U=(Array.isArray(R)?R:[]).find(v=>v?.attendence_type_id===null);S(!!U)},[R]);const O=async()=>{if(t){h(!0);try{if(b==="staff"){const U=(Array.isArray(R)?R:[]).map(v=>({staff_id:v?.staff_id,attendence_type_id:v?.attendence_type_id?v.attendence_type_id:"1",in_time:v?.intime,out_time:v?.outtime,date:c}));await bt(Ae.attendance.addAttendanceToStaffByBranch,U,t),_.success("Attendance saved successfully",{duration:2e3}),o?.(v=>!v)}else _.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(U){_.error(U?.response?.data?.msg??U?.message??"Failed required dates",{duration:2e3})}finally{h(!1)}}},q=i.useMemo(()=>(Array.isArray(a)?a:[]).map(v=>v?.selector==="attendence_type_id"?{title:v?.name??"Attendance",dataIndex:v.selector,key:v.selector,render:M=>M==null||M===""?e.jsx(s.Tag,{color:"orange",children:"Not Set"}):String(M)==="1"?e.jsx(s.Tag,{color:"green",children:"Present"}):String(M)==="4"?e.jsx(s.Tag,{color:"red",children:"Absent"}):String(M)==="3"?e.jsx(s.Tag,{color:"orange",children:"Late"}):e.jsx(s.Tag,{children:String(M)})}:v?.selector==="snum"?{title:v?.name??"Sl",key:v.selector,render:(M,P,N)=>N+1}:{title:v?.name??v?.selector,dataIndex:v?.selector,key:v?.selector}),[a]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{children:[e.jsx(np,{tableRef:y,excelDisabled:p}),e.jsx(s.Modal,{open:m,footer:null,closable:!1,centered:!0,children:e.jsxs("div",{style:{display:"grid",placeItems:"center",gap:12,padding:12},children:[e.jsx(s.Spin,{size:"large"}),e.jsx("div",{children:"Please wait..."})]})}),w.sunday?e.jsx("div",{style:{textAlign:"center",fontWeight:600,padding:"16px 0"},children:"Weekly Off"}):w.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:y,children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(U,v)=>String(U?.id??U?.staff_id??v),columns:q,dataSource:R,loading:j,pagination:{current:u.page+1,pageSize:u.rowsPerPage,total:A,showSizeChanger:!0,onChange:(U,v)=>x({page:U-1,rowsPerPage:v})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:O,ref:l,style:{display:"none"},children:"hidden"})]})]})]})}const op=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},lp={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function dp({token:t}){const[n,a]=i.useState(""),[r,o]=i.useState(ae().format("YYYY-MM-DD")),[l,d]=i.useState(!1),[c,b]=i.useState(null),[y,u]=i.useState(!1),[x,j]=i.useState(!0),[C,m]=i.useState(!1),h=i.useRef(null),{data:g}=G(t?[ep,t]:null,([D,w])=>Q(D,w)),I=i.useMemo(()=>op(g),[g]),R=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(s.Card,{title:e.jsx(s.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(Z,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,onChange:D=>a(D?.value??""),required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{defaultValue:ae(),onChange:D=>D&&o(D.format("YYYY-MM-DD")),style:lp,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>{!n||!r||(b(`${Zu.staffListForAttendance}?role=${encodeURIComponent(String(n))}&date=${encodeURIComponent(String(r))}`),d(D=>!D))}})})]})}),e.jsxs(s.Card,{title:e.jsx(s.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(s.Button,{size:"small",type:y?"primary":"default",onClick:()=>u(D=>!D),children:y?"Marked":"Mark As Holiday"}),e.jsx(s.Button,{size:"small",type:"default",disabled:x,onClick:()=>m(!0),children:"Give Attendance"})]}),c?e.jsx(ip,{token:t,url:c,columns:R,reload:l,setReload:d,saveBtnRef:h,setSaveBtnDisabled:j,date:r,type:"staff",holidayChecked:y}):null]}),e.jsx(tp,{token:t,open:C,onClose:()=>m(!1),roleId:n,onSaved:()=>d(D=>!D)})]})}const cp=({token:t})=>e.jsx(dp,{token:t}),si=Ae.attendanceReport.monthlyStaffReport,up=Ae.roleDropdown,pp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function mp({token:t}){const n=i.useRef(null),[a,r]=i.useState(!1),[o,l]=i.useState([]),[d,c]=i.useState({role:"",rolllabel:"",year:"",month:""}),b=i.useMemo(()=>Es(5),[]),{data:y}=G(t?[up,t]:null,([U,v])=>Q(U,v)),u=i.useMemo(()=>pp(y),[y]),[x,j]=i.useState([]),[C,m]=i.useState(1),[h,g]=i.useState(!1),[I,R]=i.useState(!1),[D,w]=i.useState(null),f=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:p}=Je(t&&si?`${si}?page=${C}&per_page=3`:null,(U,{arg:v})=>Lt(U,{arg:v},t),{onSuccess:U=>{g(!1);const v=Array.isArray(U)?U:[];v.length>0&&j(M=>[...M||[],...v]),v.length>1?m(M=>M+1):R(!1)},onError:()=>{g(!1),R(!1)}});i.useEffect(()=>{I&&p&&D&&p(D)},[I,C,D,p]);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:(v,M)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:M?.full_name??""})}];return Array.isArray(x)&&x.length>0&&((x[0]?.monthly_data??[]).forEach((M,P)=>{U.push({title:P+1,align:"center",key:String(P+1),render:(N,E)=>{const F=E?.monthly_data?.[P]?.[0]?.data?.[0]??{},L=F?.intime??"",z=F?.outtime??"",k=F?.attendance_type??"";return e.jsx(s.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",L]}),e.jsxs("div",{children:["Out Time ",z]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:ze(k)})})}})}),U.push({title:"Total",key:"Total",render:(M,P)=>{const N=P?.monthly_data??[],E=N.filter(L=>L?.[0]?.data?.[0]?.attendance_type==="A").length,F=N.filter(L=>L?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",E," P : ",F]})})}})),U},[x]),A=i.useMemo(()=>[{label:"Present",el:ze("P")},{label:"Absent",el:ze("A")},{label:"Leave",el:ze("L")},{label:"Weekly Off",el:ze("W")},{label:"Holiday",el:ze("H")}],[]),O=i.useMemo(()=>d.month?o.find(U=>U?.value==d.month)?.label??d.month??"--":"--",[d.month,o]),q=async U=>{if(U.preventDefault(),!d.role||!d.year||!d.month)return;m(1),g(!0),j([]);const v={session:f,year:d.year,month:d.month,day:"01",role:d.role};w(v),R(!0),await p?.(v)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{className:"d-print-none",title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Attendance Report"}),children:e.jsx("form",{onSubmit:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:U=>c(v=>({...v,role:U?.value??"",rolllabel:U?.label??""}))}),e.jsx(Z,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:U=>{const v=Ms(U?.value);l(v),r(M=>!M),c(M=>({...M,year:U?.label??""}))}}),e.jsx(Z,{options:o,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:U=>c(v=>({...v,month:U?.value??""}))},`month-${a}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Monthly Attendance Report"}),children:e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(_t,{})}),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:O})]})]})]}),e.jsx("div",{className:"d-print-none",style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(dn,{data:{tableRef:n}})})]}),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(s.Skeleton,{active:!0,loading:h,paragraph:{rows:10},children:e.jsx(s.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:S,dataSource:x,pagination:!1,scroll:{x:"max-content"},rowKey:(U,v)=>String(U?.staff_id??U?.id??v)})})]})})]})}const yp=({token:t})=>e.jsx(mp,{token:t}),ri=Ae.payroll,fp=Ae.roleDropdown,hp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},gp=t=>t?.data?.data??t?.data??t??[];function xp({token:t,receiptDetailsPath:n="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:a}){const[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,b]=i.useState([]),[y,u]=i.useState({role:"",roleLabel:"",year:"",month:""}),[x,j]=i.useState(null),C=S=>{if(!S)return;if(typeof a=="function"){a(S);return}const A=`${n}?id=${encodeURIComponent(String(S))}`;typeof window<"u"&&window?.location&&(window.location.href=A)},{data:m}=G(t?[fp,t]:null,([S,A])=>Q(S,A)),h=i.useMemo(()=>hp(m),[m]),g=i.useMemo(()=>Es(5),[]),{isLoading:I,error:R,data:D}=G(t&&x?[x,t]:null,([S,A])=>Q(S,A)),w=i.useMemo(()=>{const S=gp(D);return Array.isArray(S)?S:[]},[D]),f=i.useMemo(()=>{const S=D?.pagination?.total_rows??D?.data?.pagination?.total_rows??D?.total??D?.total_rows,A=Number(S);return Number.isFinite(A)&&A>=0?A:w.length},[D,w.length]),p=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(S,A,O)=>O+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 O=A?.id??A?.staff_id??A?.staffId;return e.jsx(s.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{C(O)},children:co(A?.status)})}}],[]);return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsxs(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Payroll"}),children:[e.jsx("form",{onSubmit:S=>{if(S.preventDefault(),!y.role||!y.year||!y.month)return;const A=`${ri.payrollByRole}?page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.rowsPerPage))}&role=${encodeURIComponent(String(y.role))}&year=${encodeURIComponent(String(y.year))}&month=${encodeURIComponent(String(y.month))}`;j(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(Z,{options:h,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(Z,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:S=>{const A=Ms(S?.value);b(A),d(O=>!O),u(O=>({...O,year:S?.label??"",month:""}))}}),e.jsx(Z,{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(de,{type:"submit",value:"Search",color:"primary",onClick:()=>o(S=>({...S,page:1}))})})]})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:I,rowKey:(S,A)=>String(S?.id??S?.staff_id??A),columns:p,dataSource:w,pagination:{current:r.page,pageSize:r.rowsPerPage,total:f,showSizeChanger:!0,onChange:(S,A)=>{o({page:S,rowsPerPage:A}),!(!y.role||!y.year||!y.month)&&j(`${ri.payrollByRole}?page=${encodeURIComponent(String(S))}&per_page=${encodeURIComponent(String(A))}&role=${encodeURIComponent(String(y.role))}&year=${encodeURIComponent(String(y.year))}&month=${encodeURIComponent(String(y.month))}`)}},scroll:{x:"max-content"}})]})})}const bp=({token:t})=>e.jsx(xp,{token:t}),go=Ae.leave,un=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,b])=>Eu({baseUrl:l,page:d,perPage:c},b)),Sp=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:go.requestTable,page:n,perPage:a}),jp=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},vp=(t,n)=>{const a=new FormData;return Object.entries(t??{}).forEach(([r,o])=>{o!=null&&a.append(r,String(o))}),a.set("status",n),a};function _p({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),{isLoading:r,error:o,data:l,mutate:d}=Sp({token:t,page:n.page,perPage:n.rowsPerPage}),c=i.useMemo(()=>jp(l),[l]),b=async(u,x)=>{try{const j=vp(u,x),C=await Mt(go.approveRequest,j,t);C?.Status==="Success"?_.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):_.error(C?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to update request.",{duration:1e3})}},y=i.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(u,x)=>x?.full_name??x?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(u,x)=>x?.leave_from??x?.from_date??""},{title:"To",key:"leave_to",width:120,render:(u,x)=>x?.leave_to??x?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(u,x)=>x?.leavetype??x?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(u,x)=>x?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(u,x)=>x?.employee_remark??x?.reason??""},{title:"View",key:"document_file",width:140,render:(u,x)=>{const j=x?.document_file;return j?e.jsx(s.Button,{size:"small",onClick:()=>window.open(j,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(u,x)=>{const j=String(x?.status??"").toLowerCase();return j==="approved"?e.jsx(s.Tag,{color:"green",children:"Approved"}):j==="declined"?e.jsx(s.Tag,{color:"red",children:"Declined"}):e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10},children:[e.jsx(s.Button,{type:"text",size:"small",onClick:()=>b(x,"approved"),icon:e.jsx(X.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(s.Button,{type:"text",size:"small",onClick:()=>b(x,"declined"),icon:e.jsx(X.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Approve Leave Requests"}),children:e.jsx(s.Table,{bordered:!0,size:"small",loading:r,rowKey:(u,x)=>String(u?.id??u?.leave_id??x),columns:y,dataSource:c,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(u,x)=>a({page:u,rowsPerPage:x}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const wp=({token:t})=>e.jsx(_p,{token:t}),Cp=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Ap=({token:t,value:n,onChange:a})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:ho(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=Cp(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},xo=Ae.leave,Tp=Ae.master.leaveType.dropdown,Rp=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:xo.table,page:n,perPage:a}),Ip=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},ds={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Dp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c]=s.Form.useForm(),{isLoading:b,error:y,data:u,mutate:x}=Rp({token:t,page:n.page,perPage:n.rowsPerPage}),{data:j}=G(t?[Tp,t]:null,([w,f])=>Q(w,f)),C=i.useMemo(()=>Ip(j),[j]),m=(w,f)=>a({page:w,rowsPerPage:parseInt(f,10)}),h=()=>{d(""),c.resetFields(),c.setFieldsValue({apply_date:ae()}),o(!0)},g=()=>{o(!1),d(""),c.resetFields()},I=async w=>{const f=new FormData;f.set("apply_date",w?.apply_date?w.apply_date.format("YYYY-MM-DD"):""),f.set("leave_type",w?.leave_type?.value??w?.leave_type??""),f.set("from_date",w?.from_date?w.from_date.format("YYYY-MM-DD"):""),f.set("to_date",w?.to_date?w.to_date.format("YYYY-MM-DD"):""),f.set("reason",w?.reason??""),l&&f.set("file",l);try{await bt(xo.apply,f,t),_.success("Success! Leave request submitted.",{duration:1e3}),g(),await x()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to submit leave request.",{duration:1e3})}},R=i.useMemo(()=>{const w=u?.data??u??[];return Array.isArray(w)?w:Array.isArray(w?.data)?w.data:[]},[u]),D=i.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(w,f)=>f?.leavetype??f?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(w,f)=>f?.date??f?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(w,f)=>f?.leave_from??f?.from_date??""},{title:"To",key:"leave_to",width:130,render:(w,f)=>f?.leave_to??f?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(w,f)=>f?.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(s.Modal,{open:r,title:"Add Leave Request",onCancel:g,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:c,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(s.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(s.DatePicker,{style:ds})]})}),e.jsx(s.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(Z,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Leave Type",allowSelectAll:!1})}),e.jsx(s.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(s.DatePicker,{style:ds})]})}),e.jsx(s.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(s.DatePicker,{style:ds})]})}),e.jsx(s.Form.Item,{name:"reason",rules:[{required:!0,message:"Enter reason"}],children:e.jsx(J,{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(Ap,{token:t,value:l,onChange:d})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx(s.Button,{onClick:g,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Apply Leave"}),extra:e.jsx(de,{type:"button",value:"Add Leave Request",onClick:h})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Leave Requests"}),children:e.jsx(s.Table,{bordered:!0,size:"small",loading:b,rowKey:(w,f)=>String(w?.id??w?.leave_id??f),columns:D,dataSource:R,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(w,f)=>m(w,f),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const kp=({token:t})=>e.jsx(Dp,{token:t}),ha=Ae.master.leaveType,Op=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:ha.table,page:n,perPage:a});function Pp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,b]=i.useState(null),{isLoading:y,error:u,data:x,mutate:j}=Op({token:t,page:n.page,perPage:n.rowsPerPage}),C=(w,f)=>{a({page:w,rowsPerPage:parseInt(f,10)})},m=async w=>{const f=new FormData;f.set("title",w?.title??"");try{await j(bt(ha.add,f,t),st(f)),_.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to add leave type.",{duration:1e3})}},h=w=>{b(w??null),o.setFieldsValue({title:w?.leave_type_name??w?.name??""}),d(!0)},g=()=>{d(!1),b(null),o.resetFields()},I=async w=>{const f=c?.id??c?.leave_type_id;if(!f){_.error("Missing leave type id.",{duration:1e3});return}const p=new FormData;p.set("id",String(f)),p.set("title",w?.title??"");try{await Mt(ha.edit,p,t),await j(),_.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),g()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update leave type.",{duration:1e3})}},R=async w=>{const f=w?.id??w?.leave_type_id;if(f)try{await j(Ln(ha.remove,f,t),Qe(f)),_.success("Success! Deleted leave type.",{duration:1e3})}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete leave type.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"type",key:"type",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(w,f)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(f)}),e.jsx(s.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>R(f),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Leave Type",onCancel:g,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:g,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Leave Type"}),children:e.jsxs(s.Form,{form:r,layout:"vertical",onFinish:m,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Leave Type List"}),children:e.jsx(Le,{parentCallback:C,data:{newData:x,columns:D,columnstype:"antd",action:!1,Loading:y,error:u}})})]})}const Ep=({token:t})=>e.jsx(Pp,{token:t}),ga=Ae.master.department,Mp=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:ga.table,page:n,perPage:a});function Fp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,b]=i.useState(null),{isLoading:y,error:u,data:x,mutate:j}=Mp({token:t,page:n.page,perPage:n.rowsPerPage}),C=(w,f)=>{a({page:w,rowsPerPage:parseInt(f,10)})},m=async w=>{const f=new FormData;f.set("title",w?.title??"");try{await j(bt(ga.add,f,t),st(f)),_.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to add department.",{duration:1e3})}},h=w=>{b(w??null),o.setFieldsValue({title:w?.department_name??w?.name??""}),d(!0)},g=()=>{d(!1),b(null),o.resetFields()},I=async w=>{const f=c?.id??c?.department_id;if(!f){_.error("Missing department id.",{duration:1e3});return}const p=new FormData;p.set("id",String(f)),p.set("title",w?.title??"");try{await Mt(ga.edit,p,t),await j(),_.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),g()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update department.",{duration:1e3})}},R=async w=>{const f=w?.id??w?.department_id;if(f)try{await j(Ln(ga.remove,f,t),Qe(f)),_.success("Success! Deleted department.",{duration:1e3})}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete department.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"department_name",key:"department_name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(w,f)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(f)}),e.jsx(s.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>R(f),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Department",onCancel:g,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:g,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Department"}),children:e.jsxs(s.Form,{form:r,layout:"vertical",onFinish:m,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Department List"}),children:e.jsx(Le,{parentCallback:C,data:{newData:x,columns:D,columnstype:"antd",action:!1,Loading:y,error:u}})})]})}const Np=({token:t})=>e.jsx(Fp,{token:t}),xa=Ae.master.designation,$p=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:xa.table,page:n,perPage:a});function Up({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,b]=i.useState(null),{isLoading:y,error:u,data:x,mutate:j}=$p({token:t,page:n.page,perPage:n.rowsPerPage}),C=(w,f)=>{a({page:w,rowsPerPage:parseInt(f,10)})},m=async w=>{const f=new FormData;f.set("title",w?.title??"");try{await j(bt(xa.add,f,t),st(f)),_.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to add designation.",{duration:1e3})}},h=w=>{b(w??null),o.setFieldsValue({title:w?.designation??""}),d(!0)},g=()=>{d(!1),b(null),o.resetFields()},I=async w=>{const f=c?.id??c?.designation_id;if(!f){_.error("Missing designation id.",{duration:1e3});return}const p=new FormData;p.set("id",String(f)),p.set("title",w?.title??"");try{await Mt(xa.edit,p,t),await j(),_.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),g()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update designation.",{duration:1e3})}},R=async w=>{const f=w?.id??w?.designation_id;if(f)try{await j(Ln(xa.remove,f,t),Qe(f)),_.success("Success! Deleted designation.",{duration:1e3})}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete designation.",{duration:1e3})}},D=i.useMemo(()=>[{title:"Name",dataIndex:"designation",key:"designation",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(w,f)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(f)}),e.jsx(s.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>R(f),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Designation",onCancel:g,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:g,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Designation"}),children:e.jsxs(s.Form,{form:r,layout:"vertical",onFinish:m,children:[e.jsx(s.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Designation List"}),children:e.jsx(Le,{parentCallback:C,data:{newData:x,columns:D,columnstype:"antd",action:!1,Loading:y,error:u}})})]})}const Bp=({token:t})=>e.jsx(Up,{token:t}),ba=Ae.master.shift,Lp=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:ba.table,page:n,perPage:a}),Ze="hh:mm A",Xt=t=>{const n=String(t??"");if(!n)return null;const a=ae(n,[Ze,"HH:mm","HH:mm:ss"],!0);return a.isValid()?a:null},Zt=t=>t?t.format(Ze):"",ct={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function qp({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState(!1),[c,b]=i.useState(null),{isLoading:y,error:u,data:x,mutate:j}=Lp({token:t,page:n.page,perPage:n.rowsPerPage}),C=(p,S)=>{a({page:p,rowsPerPage:parseInt(S,10)})},m=(p,S)=>{const A=new FormData;return S&&A.set("id",String(S)),A.set("name",p?.name??""),A.set("start_time",Zt(p?.start_time)),A.set("end_time",Zt(p?.end_time)),A.set("shift_start_from",Zt(p?.shift_start_from)),A.set("shift_start_to",Zt(p?.shift_start_to)),A.set("shift_end_from",Zt(p?.shift_end_from)),A.set("shift_end_to",Zt(p?.shift_end_to)),A},h=async p=>{try{const S=m(p);await j(bt(ba.add,S,t),st(S)),_.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to add shift.",{duration:1e3})}},g=p=>{b(p??null),o.setFieldsValue({name:p?.shift_name??p?.name??"",start_time:Xt(p?.start_time),end_time:Xt(p?.end_time),shift_start_from:Xt(p?.shift_start_from),shift_start_to:Xt(p?.shift_start_to),shift_end_from:Xt(p?.shift_end_from),shift_end_to:Xt(p?.shift_end_to)}),d(!0)},I=()=>{d(!1),b(null),o.resetFields()},R=async p=>{const S=c?.id??c?.shift_id;if(!S){_.error("Missing shift id.",{duration:1e3});return}try{const A=m(p,S);await Mt(ba.edit,A,t),await j(),_.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),I()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update shift.",{duration:1e3})}},D=async p=>{const S=p?.id??p?.shift_id;if(S)try{await j(Ln(ba.remove,S,t),Qe(S)),_.success("Success! Deleted shift.",{duration:1e3})}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete shift.",{duration:1e3})}},w=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:(p,S)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(X.EditOutlined,{}),onClick:()=>g(S)}),e.jsx(s.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>D(S),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]),f=[{required:!0,message:"Select time"}];return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Shift",onCancel:I,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:R,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(s.Form.Item,{name:"start_time",label:"Start Time",rules:f,children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ct})}),e.jsx(s.Form.Item,{name:"end_time",label:"End Time",rules:f,children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ct})}),e.jsx(s.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ct})}),e.jsx(s.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ct})}),e.jsx(s.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ct})}),e.jsx(s.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ct})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:I,children:"Cancel"}),e.jsx(de,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Shift"}),children:e.jsx(s.Form,{form:r,layout:"vertical",onFinish:h,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(J,{type:"text",label:"Name"})}),e.jsx(s.Form.Item,{name:"start_time",label:"Start Time",rules:f,children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ct})}),e.jsx(s.Form.Item,{name:"end_time",label:"End Time",rules:f,children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ct})}),e.jsx(s.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ct})}),e.jsx(s.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ct})}),e.jsx(s.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ct})}),e.jsx(s.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(s.TimePicker,{format:Ze,use12Hours:!0,style:ct})}),e.jsx(de,{type:"submit",value:"Save",color:"primary"})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Shift List"}),children:e.jsx(Le,{parentCallback:C,data:{newData:x,columns:w,columnstype:"antd",action:!1,Loading:y,error:u}})})]})}const zp=({token:t})=>e.jsx(qp,{token:t}),ii=Ae.attendance;function Yp({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((n,a)=>e.jsx("th",{colSpan:"2",style:{border:"1px solid #000",paddingLeft:10},children:n?.shift_name??""},`${a}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((n,a)=>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"})]},`${a}heading2`))]})]}),e.jsx("tbody",{children:(t?.data??[]).map((n,a)=>e.jsxs("tr",{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a+1})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:`${n?.name??""} ${n?.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:n?.attendance_data?(n.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:n?.attendance_data?(n.attendance_data?.[r?.office_shift_id]?.checkouttime??"").toUpperCase():""})})]},`${o}cells${a}`))]},`${a}row`))})]})}):null}const Wp=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Vp=t=>{const n=String(t??"").toLowerCase();return n==="present"?e.jsx(s.Tag,{color:"green",children:"Present"}):n==="absent"?e.jsx(s.Tag,{color:"red",children:"Absent"}):n==="leave"?e.jsx(s.Tag,{color:"orange",children:"Leave"}):e.jsx(s.Tag,{children:t??""})};function Hp({token:t}){const[n,a]=i.useState(ae()),[r,o]=i.useState(!1),[l,d]=i.useState(0),c=i.useMemo(()=>`${r?ii.dailyAttendanceMultipleShift:ii.dailyAttendance}?attendance_date=${encodeURIComponent(n.format("YYYY-MM-DD"))}`,[n,r,l]),{isLoading:b,error:y,data:u}=G(t?[c,t]:null,([h,g])=>Q(h,g)),x=i.useMemo(()=>Wp(u),[u]),j=i.useMemo(()=>r?u?.data?.data??u?.data??u??null:null,[u,r]),C=on.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),m=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(h,g,I)=>I+1},{title:"Name",key:"name",render:(h,g)=>`${g?.name??""} ${g?.surname??""}`.trim(),ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(h,g)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[Vp(g?.attendance),g?.late_time?e.jsx(s.Tag,{color:"red",children:"L"}):null]})},{title:"In Time",key:"intime",width:120,render:(h,g)=>g?.attendance_data?.[0]?.intime??""},{title:"Out Time",key:"outtime",width:120,render:(h,g)=>g?.attendance_data?.[0]?.outtime??""},{title:"Late",key:"late",width:100,render:(h,g)=>g?.late_time?e.jsx(s.Tag,{color:"red",children:g.late_time}):""}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.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(s.DatePicker,{value:n,onChange:h=>h&&a(h),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(s.Switch,{checked:r,onChange:o})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",onClick:()=>d(h=>h+1)})})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(X.PrinterOutlined,{style:{color:"#5080f8",fontSize:18,cursor:"pointer"},onClick:C}),children:e.jsxs("div",{id:"ubk-hr-daily-attendance-print",children:[e.jsx("div",{className:"print-only",children:e.jsx(_t,{})}),r?e.jsx(Yp,{data:j}):e.jsx(s.Table,{bordered:!0,size:"small",loading:b,rowKey:(h,g)=>String(h?.id??h?.staff_id??g),columns:m,dataSource:x,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const Kp=({token:t})=>e.jsx(Hp,{token:t}),oi=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Gp=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 Jp({token:t,staffId:n}){const[a,r]=i.useState(!1),[o,l]=i.useState(null),[d,c]=i.useState({value:"Cash",label:"Cash"}),[b,y]=i.useState(""),[u,x]=i.useState(""),j=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),C=O=>{const q=Number(O??0),U=Number.isFinite(q)?q.toLocaleString("en-IN"):"0";return`${j?`${j} `:""}${U}`},m=i.useMemo(()=>n?`${Ae.staff.basicById}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),h=i.useMemo(()=>n?`${Ae.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),{data:g}=G(t&&m?[m,t]:null,([O,q])=>Q(O,q)),{data:I,isLoading:R,mutate:D}=G(t&&h?[h,t]:null,([O,q])=>Q(O,q)),w=i.useMemo(()=>oi(g)[0]??g?.data??g??null,[g]),f=i.useMemo(()=>oi(I),[I]),p=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:(O,q)=>e.jsx("div",{style:{fontSize:11},children:ht(q?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(O,q)=>e.jsx("div",{style:{fontSize:11},children:ht(q?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(O,q)=>e.jsx("div",{style:{fontSize:11},children:ht(q?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(O,q)=>e.jsx("div",{style:{fontSize:11},children:ht(q?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(O,q)=>e.jsx("div",{style:{cursor:q?.status==="due"?"pointer":"default"},onClick:()=>{q?.status==="due"&&(l(q),r(!0))},children:co(q?.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 O={...o,staff_id:n,payment_type:d?.value??"",notes:b,attchement:u};try{await Ye(Ae.payroll.generatePayslip,{arg:O},t),_.success("Success!",{duration:1e3}),r(!1),l(null),y(""),x(""),await D()}catch(q){_.error(q?.response?.data?.msg??q?.message??"Failed.",{duration:1e3})}};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.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:w?`${w?.f_name??w?.firstname??""} ${w?.l_name??w?.lastname??""}`.trim():""}),e.jsx(s.Table,{bordered:!0,size:"small",loading:R,rowKey:(O,q)=>String(O?.id??`${O?.month}-${q}`),columns:p,dataSource:f,pagination:{pageSize:12},scroll:{x:"max-content"}})]})}),e.jsx(s.Modal,{open:a,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(Z,{label:"Pay",options:S,value:d,onChange:O=>c(O??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(s.Input.TextArea,{rows:4,placeholder:"Note",value:b,onChange:O=>y(O.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(s.Upload,{maxCount:1,action:ho(),headers:t?{Authorization:t}:void 0,onChange:O=>{if(O?.file?.status==="done"){const q=Gp(O?.file?.response);q&&x(q)}O?.file?.status==="removed"&&x("")},children:e.jsx(s.Button,{icon:e.jsx(X.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(s.Button,{onClick:()=>r(!1),children:"Cancel"}),e.jsx(de,{type:"button",value:o?.Total_Payable_Amount?`Pay ${C(o.Total_Payable_Amount)}`:"Pay",onClick:A})]})]})})]})}function Qp({token:t,staffId:n}){const a=i.useMemo(()=>{if(n!=null&&String(n).trim()!=="")return n;if(typeof window>"u")return null;const r=new URLSearchParams(window.location.search).get("id");return r||null},[n]);return a?e.jsx(Jp,{token:t,staffId:a}):e.jsx(s.Card,{title:e.jsx(s.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 Ft({onAdd:t,onExport:n,onPrint:a,onDownload:r,onFilter:o,onRefresh:l,actions:d}){const c=i.useMemo(()=>[{key:"add",title:"Add",icon:e.jsx(X.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(X.FileExcelOutlined,{}),onClick:n},{key:"print",title:"Print",icon:e.jsx(X.PrinterOutlined,{}),onClick:a},{key:"download",title:"Download",icon:e.jsx(X.DownloadOutlined,{}),onClick:r},{key:"filter",title:"Filter",icon:e.jsx(X.FilterOutlined,{}),onClick:o},{key:"refresh",title:"Refresh",icon:e.jsx(X.ReloadOutlined,{}),onClick:l}],[t,n,a,r,o,l]),b=i.useMemo(()=>{const y=Array.isArray(d)&&d.length?new Set(d):null;return y?c.filter(u=>y.has(u.key)):c},[c,d]);return e.jsx(s.Space,{size:8,children:b.map(y=>e.jsx(s.Tooltip,{title:y.title,children:e.jsx(s.Button,{type:"text",icon:y.icon,onClick:y.onClick,disabled:!y.onClick})},y.key))})}const $s=t=>t??localStorage.getItem("authToken")??"",vt={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"}},kt=async(t,n)=>Q(t,$s(n)),Xp=async(t,n,a)=>Ye(t,n,$s(a)),Zp=async(t,n,a)=>Dn(t,{arg:n},$s(a)),kn=(t,n)=>{const a=new URLSearchParams;Object.entries(n??{}).forEach(([o,l])=>{l==null||l===""||a.set(o,String(l))});const r=t.includes("?")?"&":"?";return`${t}${r}${a.toString()}`},li=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}},em=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},bo=(t,n)=>{const a=t?.data?.data??t?.data??t??{},r=n?a?.[n]:a;return Array.isArray(r)?r:Array.isArray(a?.student)?a.student:Array.isArray(a?.staff)?a.staff:Array.isArray(a?.data)?a.data:[]},tm=t=>Array.isArray(t?.monthly_data)?t.monthly_data:Array.isArray(t?.month_data)?t.month_data:[],nm=t=>{const n={present:0,absent:0,late:0,leave:0};return(Array.isArray(t)?t:[]).forEach(a=>{if(Array.isArray(a?.monthly_data)||Array.isArray(a?.month_data)){tm(a).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")&&(n.present+=1),(d==="A"||d==="4")&&(n.absent+=1),(d==="L"||d==="3")&&(n.late+=1),(d==="LEAVE"||d==="2")&&(n.leave+=1)});return}const r=String(a?.attendance_type??a?.attendence_type_id??"").toUpperCase();(r==="P"||r==="1")&&(n.present+=1),(r==="A"||r==="4")&&(n.absent+=1),(r==="L"||r==="3")&&(n.late+=1),(r==="LEAVE"||r==="2")&&(n.leave+=1)}),n},Us=(t,n)=>{const{data:a,isLoading:r,error:o}=G(n&&t?[t,n]:null,([l,d])=>kt(l,d));return{isLoading:r,error:o,data:a,options:i.useMemo(()=>em(a),[a])}},Ma=t=>Us(vt.dropdowns.classes,t),Fa=(t,n)=>{const a=t?`${vt.dropdowns.sectionsByClass}?class_id=${encodeURIComponent(String(t))}`:null;return Us(a,n)},am=t=>Us(vt.dropdowns.sessions,t),Bs=t=>{const n=String(t??"").toUpperCase();return ze(n==="1"||n==="P"||n==="PRESENT"?"P":n==="4"||n==="A"||n==="ABSENT"?"A":n==="3"||n==="L"||n==="LATE"?"L":n==="2"||n==="LEAVE"?"LEAVE":n==="W"?"W":n==="H"?"H":n||"-")},So=(t,n,a)=>{const r=new Blob([t],{type:n}),o=URL.createObjectURL(r),l=document.createElement("a");l.href=o,l.download=a,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(o)},di=t=>String(t??"").replace(/"/g,'""'),sm=({rows:t,columns:n,fileName:a})=>{const r=Array.isArray(n)?n:[],o=Array.isArray(t)?t:[],l=r.map(c=>`"${di(c?.title??c?.name??c?.key??c?.dataIndex)}"`).join(","),d=o.map((c,b)=>r.map(y=>{const u=y?.dataIndex??y?.selector??y?.key,x=u==="sl"?b+1:c?.[u];return`"${di(x)}"`}).join(",")).join(`
|
|
60
|
-
`);
|
|
61
|
-
`),"text/csv;charset=utf-8;",a)},rm=({value:t,fileName:n})=>{So(JSON.stringify(t??null,null,2),"application/json;charset=utf-8;",n)};function jo({summary:t}){const n=[{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:n.map(a=>e.jsxs(s.Card,{size:"small",styles:{body:{padding:16}},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:8},children:a.label}),e.jsx("div",{style:{fontSize:24,fontWeight:700,color:a.color},children:t?.[a.key]??0})]},a.key))})}function rn({summary:t,title:n="Attendance Overview"}){const a=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(...a.map(o=>o.value),1);return e.jsx(s.Card,{size:"small",title:n,children:e.jsx("div",{style:{display:"grid",gap:12},children:a.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 im(){const t=[{label:"Present",node:ze("P")},{label:"Absent",node:ze("A")},{label:"Late",node:ze("L")},{label:"Weekly Off",node:ze("W")},{label:"Holiday",node:ze("H")}];return e.jsx(s.Space,{wrap:!0,size:[12,8],children:t.map(n=>e.jsxs(s.Space,{size:6,children:[e.jsx("span",{style:{fontSize:12,color:"#555"},children:n.label}),n.node]},n.label))})}function Ot({items:t}){const n=Array.isArray(t)?t.filter(a=>a?.value):[];return n.length?e.jsx(s.Space,{wrap:!0,size:[8,8],children:n.map(a=>e.jsxs(s.Tag,{color:"blue",children:[a.label,": ",a.value]},a.label))}):null}function Na({title:t,subtitle:n,printRef:a,exportRows:r,exportColumns:o,onRefresh:l,onAdd:d,filterSection:c,summary:b,chartContent:y,reportTitle:u,reportExtra:x,children:j,fileBaseName:C="attendance"}){const m=on.useReactToPrint({content:()=>a?.current});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsxs("div",{children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:t}),n?e.jsx(s.Typography.Text,{type:"secondary",style:{display:"block",marginTop:4},children:n}):null]}),extra:e.jsx(Ft,{actions:["add","export","print","download","refresh"],onAdd:d,onExport:()=>sm({rows:r,columns:o,fileName:`${C}.csv`}),onPrint:m,onDownload:()=>rm({value:r,fileName:`${C}.json`}),onRefresh:l}),children:c}),e.jsx(jo,{summary:b}),y===!1?null:y||e.jsx(rn,{summary:b}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:u}),extra:x,children:j})]})}const om=[{label:"Present",value:"1"},{label:"Absent",value:"4"},{label:"Late",value:"3"},{label:"Leave",value:"2"}];function lm({rows:t,loading:n,sunday:a,holiday:r,holidayTitle:o,onChangeRows:l,onEmergency:d}){const c=(y,u)=>{const x=(Array.isArray(t)?t:[]).map((j,C)=>(j?.student_session_id??j?.student_id??j?.id??C)===y?{...j,...u}:j);l?.(x)},b=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(y,u,x)=>x+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:(y,u)=>u?.full_name??u?.student_name??u?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:180,render:(y,u,x)=>{const j=u?.student_session_id??u?.student_id??u?.id??x;return e.jsx(s.Select,{size:"small",style:{width:"100%"},options:om,value:String(y??"1"),onChange:C=>c(j,{attendence_type_id:C})})}},{title:"Date",dataIndex:"date",key:"date",width:120,render:y=>y?ae(y).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:(y,u)=>e.jsx(s.Tag,{color:"orange",style:{cursor:"pointer"},icon:e.jsx(X.ClockCircleOutlined,{}),onClick:()=>d?.(u),children:"E.L"})}],[d,t]);return a?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(s.Table,{bordered:!0,size:"small",rowKey:(y,u)=>String(y?.student_session_id??y?.student_id??y?.id??u),columns:b,dataSource:Array.isArray(t)?t:[],loading:n,pagination:{pageSize:25},scroll:{x:"max-content"}})}function dm({rows:t,loading:n,sunday:a,holiday:r,holidayTitle:o}){const l=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(d,c,b)=>b+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=>Bs(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 a?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(s.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:n,pagination:{pageSize:25},scroll:{x:"max-content"}})}function cm({data:t,loading:n,onViewStudent:a}){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),b=i.useMemo(()=>{const y=[{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,fixed:"left"},{title:"Name",key:"student_name",width:180,fixed:"left",render:(u,x)=>e.jsx(s.Button,{type:"link",style:{padding:0},onClick:()=>a?.(x),children:x?.student_name??x?.full_name??"--"})}];return[...new Array(c).keys()].forEach(u=>{y.push({title:String(u+1),key:`day-${u+1}`,width:52,align:"center",render:(x,j)=>{const m=j?.[`${j?.student_id}_${o.indexOf(j)}`]?.[u]??{},h=m?.attendance_date,g=l.find(I=>I?.date===h);return d.includes(h)?vr("sunday","W"):g?vr("holiday","H"):Bs(m?.attendence_type_id)}})}),y.push({title:"Total",key:"total",width:140,fixed:"right",render:(u,x)=>{let j=0,C=0,m=0;return[...new Array(c).keys()].forEach(h=>{const g=x?.[`${x?.student_id}_${o.indexOf(x)}`]?.[h]??{},I=String(g?.attendence_type_id??"");I==="1"&&(j+=1),I==="4"&&(C+=1),I==="3"&&(m+=1)}),e.jsxs("span",{children:["P: ",j," A: ",C," L: ",m]})}}),y},[l,a,o,d,c]);return e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(y,u)=>String(y?.student_id??u),columns:b,dataSource:o,loading:n,pagination:{pageSize:20},scroll:{x:"max-content"},locale:{emptyText:e.jsx(s.Empty,{description:"No monthly report found"})}})}function um({open:t,onClose:n,loading:a,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,b)=>Bs(b?.attendence_type_id??b?.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(s.Modal,{open:t,onCancel:n,footer:null,width:900,title:`Monthly Details${o?` - ${o}`:""}`,children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(c,b)=>String(c?.attendance_date??b),columns:d,dataSource:l,loading:a,pagination:{pageSize:20},scroll:{x:"max-content"}})})}function pm({open:t,onClose:n,onSubmit:a,loading:r}){const[o,l]=s.Modal.useModal(),[d,c]=i.useState(null),[b,y]=i.useState(""),u=async()=>{if(!d){await o.warning({title:"Select time"});return}await a?.({outtime:d.format("h:mm a"),message:b}),c(null),y("")};return e.jsxs(e.Fragment,{children:[l,e.jsx(s.Modal,{title:"Emergency Leave",open:t,onCancel:n,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(s.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(s.Input.TextArea,{rows:4,value:b,onChange:x=>y(x.target.value)})]})]})})]})}const vo=t=>nm(t),ci=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n.reduce((a,r)=>({present:a.present+Number(r?.present??r?.Present??r?.total_present??0),absent:a.absent+Number(r?.absent??r?.Absent??r?.total_absent??0),late:a.late+Number(r?.late??r?.Late??0),leave:a.leave+Number(r?.leave??r?.Leave??0)}),{present:0,absent:0,late:0,leave:0}):{present:Number(n?.present??n?.Present??n?.total_present??0),absent:Number(n?.absent??n?.Absent??n?.total_absent??0),late:Number(n?.late??n?.Late??0),leave:Number(n?.leave??n?.Leave??0)}};function mm({token:t}){const{data:n}=G(t?[vt.dashboard.monthlyGraph,t]:null,([l,d])=>kt(l,d)),{data:a}=G(t?[vt.dashboard.weeklyGraph,t]:null,([l,d])=>kt(l,d)),r=i.useMemo(()=>ci(n),[n]),o=i.useMemo(()=>ci(a),[a]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsxs(s.Card,{children:[e.jsx(s.Typography.Title,{level:4,style:{marginTop:0},children:"Attendance Dashboard"}),e.jsx(s.Typography.Paragraph,{style:{marginBottom:0},children:"Student attendance overview with monthly and weekly analytics migrated from the ERP dashboard."})]}),e.jsx(jo,{summary:r}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20},children:[e.jsx(rn,{summary:r,title:"Monthly Attendance Chart"}),e.jsx(rn,{summary:o,title:"Weekly Attendance Chart"})]})]})}const cs=vt.studentAttendance,ym={width:"100%",height:40};function fm({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[b,y]=i.useState(""),[u,x]=i.useState(""),[j,C]=i.useState(""),[m,h]=i.useState(ae()),[g,I]=i.useState(0),[R,D]=i.useState([]),[w,f]=i.useState(!1),[p,S]=i.useState(null),[A,O]=i.useState(!1),[q,U]=i.useState(!1),v=Ma(t),M=Fa(a,t),P=i.useMemo(()=>!a||!d||g===0?null:kn(cs.list,{cID:a,sID:d,batch_id:u,date:m.format("YYYY-MM-DD")}),[u,a,m,g,d]),{data:N,isLoading:E,mutate:F}=G(t&&P?[P,t]:null,([W,ee])=>kt(W,ee));i.useEffect(()=>{D(bo(N,"student"))},[N]);const L=N?.data?.data??N?.data??N??{},z=!!L?.sunday,k=!!L?.holiday?.holiday,T=L?.holiday?.title??"",$=i.useMemo(()=>vo(R),[R]),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"}],[]),Y=async()=>{if(R.length)try{U(!0),await Xp(cs.save,{attendenceData:R,date:m.format("YYYY-MM-DD"),holiday:w?"YES":"NO"},t),_.success("Student attendance saved."),F?.()}catch(W){_.error(W?.message??"Failed to save attendance.")}finally{U(!1)}},ne=async({outtime:W,message:ee})=>{if(p?.attendence_id)try{O(!0),await Zp(cs.emergencyLeave,{outtime:W,message:ee,id:p.attendence_id},t),_.success("Emergency leave updated."),S(null),F?.()}catch(se){_.error(se?.message??"Failed to update emergency leave.")}finally{O(!1)}},H=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(Z,{options:v.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:W=>{r(W?.value??""),l(W?.label??""),c(""),y(""),x(""),C("")},required:!0}),e.jsx(Z,{options:M.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:W=>{c(W?.value??""),y(W?.label??""),x(""),C("")},required:!0},`section-${a}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{value:m,onChange:W=>W&&h(W),style:ym,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>I(W=>W+1)})})]}),e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:b},{label:"Date",value:m.format("DD-MM-YYYY")}]})]});return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{}),e.jsx(Na,{title:"Student Attendance",printRef:n,exportRows:R,exportColumns:B,onRefresh:()=>F?.(),filterSection:H,summary:$,chartContent:!1,reportTitle:"Student Attendance List",reportExtra:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(s.Button,{size:"small",type:w?"primary":"default",onClick:()=>f(W=>!W),children:w?"Marked":"Mark As Holiday"}),e.jsx(s.Button,{size:"small",type:"primary",onClick:Y,loading:q,disabled:!R.length,children:"Save Attendance"})]}),fileBaseName:"student-attendance",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(_t,{}),e.jsx(s.Typography.Title,{level:5,children:"Student Attendance"}),e.jsx(s.Card,{size:"small",style:{marginBottom:12},children:e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:b},{label:"Date",value:m.format("DD-MM-YYYY")}]})})]}),e.jsx(lm,{rows:R,loading:E,sunday:z,holiday:k,holidayTitle:T,onChangeRows:D,onEmergency:S})]})}),e.jsx(pm,{open:!!p,onClose:()=>S(null),onSubmit:ne,loading:A})]})}const hm=vt.dailyAttendance,gm={width:"100%",height:40};function xm({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[b,y]=i.useState(""),[u,x]=i.useState(""),[j,C]=i.useState(ae()),[m,h]=i.useState(0),g=Ma(t),I=Fa(a,t),R=i.useMemo(()=>!a||!d||m===0?null:kn(hm.list,{cID:a,sID:d,batch_id:u,date:j.format("YYYY-MM-DD")}),[u,a,j,m,d]),{data:D,isLoading:w,mutate:f}=G(t&&R?[R,t]:null,([P,N])=>kt(P,N)),p=i.useMemo(()=>bo(D,"student"),[D]),S=D?.data?.data??D?.data??D??{},A=!!S?.sunday,O=!!S?.holiday?.holiday,q=S?.holiday?.title??"",U=i.useMemo(()=>vo(p),[p]),v=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"}],[]),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(Z,{options:g.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:P=>{r(P?.value??""),l(P?.label??""),c(""),y(""),x(""),setBatchLabel("")},required:!0}),e.jsx(Z,{options:I.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:P=>{c(P?.value??""),y(P?.label??""),x(""),setBatchLabel("")},required:!0},`section-${a}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{value:j,onChange:P=>P&&C(P),style:gm,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>h(P=>P+1)})})]}),e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:b},{label:"Date",value:j.format("DD-MM-YYYY")}]})]});return e.jsx(Na,{title:"Daily Attendance",subtitle:"Read-only daily attendance enquiry migrated from ERP AttendanceDashboard.",printRef:n,exportRows:p,exportColumns:v,onRefresh:()=>f?.(),filterSection:M,summary:U,chartContent:e.jsx(rn,{summary:U,title:"Daily Attendance Overview"}),reportTitle:"Daily Attendance List",fileBaseName:"daily-attendance",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(_t,{}),e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:b},{label:"Date",value:j.format("DD-MM-YYYY")}]})]}),e.jsx(dm,{rows:p,loading:w,sunday:A,holiday:O,holidayTitle:q})]})})}const ui=vt.monthlyReport,bm=t=>{const n=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],a=Number(t?.totalDaysMonth??0),r={present:0,absent:0,late:0,leave:0};return n.forEach((o,l)=>{[...new Array(a).keys()].forEach(d=>{const c=o?.[`${o?.student_id}_${l}`]?.[d]??{},b=String(c?.attendence_type_id??"");b==="1"&&(r.present+=1),b==="4"&&(r.absent+=1),b==="3"&&(r.late+=1),b==="2"&&(r.leave+=1)})}),r},Sm=t=>{const n=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],a=Number(t?.totalDaysMonth??0);return n.map((r,o)=>{let l=0,d=0,c=0;return[...new Array(a).keys()].forEach(b=>{const y=r?.[`${r?.student_id}_${o}`]?.[b]??{},u=String(y?.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 jm({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[b,y]=i.useState(""),[u,x]=i.useState(""),[j,C]=i.useState(""),[m,h]=i.useState(String(new Date().getFullYear())),[g,I]=i.useState(String(new Date().getMonth()+1).padStart(2,"0")),[R,D]=i.useState(0),[w,f]=i.useState(null),p=Ma(t),S=Fa(a,t),A=i.useMemo(()=>Ms(Number(m)),[m]),O=i.useMemo(()=>Es(10),[]),q=i.useMemo(()=>!a||!d||!m||!g||R===0?null:kn(ui.table,{session:li(),class_id:a,section_id:d,year:m,month:g,batch_id:u}),[u,a,g,R,d,m]),{data:U,isLoading:v,mutate:M}=G(t&&q?[q,t]:null,([$,B])=>kt($,B)),P=U?.data?.data??U?.data??U??{},N=i.useMemo(()=>bm(P),[P]),E=i.useMemo(()=>Sm(P),[P]),F=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"}],[]),L=i.useMemo(()=>w?.student_id?kn(ui.byStudent,{student_id:w.student_id,month:g,year:m,session:li()}):null,[g,w,m]),{data:z,isLoading:k}=G(t&&L?[L,t]:null,([$,B])=>kt($,B)),T=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(Z,{options:p.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{r($?.value??""),l($?.label??""),c(""),y(""),x(""),C("")},required:!0}),e.jsx(Z,{options:S.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{c($?.value??""),y($?.label??""),x(""),C("")},required:!0},`section-${a}`),e.jsx(Z,{options:O,label:"Year",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:O.find($=>String($?.value)===String(m))??null,onChange:$=>h(String($?.value??"")),required:!0}),e.jsx(Z,{options:A,label:"Month",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:A.find($=>String($?.value)===String(g))??null,onChange:$=>I(String($?.value??"").padStart(2,"0")),required:!0},`month-${m}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>D($=>$+1)})})]}),e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:b},{label:"Month",value:A.find($=>String($?.value)===String(g))?.label??g},{label:"Year",value:m}]}),e.jsx(im,{})]});return e.jsxs(e.Fragment,{children:[e.jsx(Na,{title:"Monthly Report",subtitle:"Monthly class-wise attendance matrix and student drilldown.",printRef:n,exportRows:E,exportColumns:F,onRefresh:()=>M?.(),filterSection:T,summary:N,chartContent:e.jsx(rn,{summary:N,title:"Monthly Attendance Summary"}),reportTitle:"Monthly Attendance Table",fileBaseName:"monthly-attendance-report",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(_t,{}),e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:b},{label:"Month",value:A.find($=>String($?.value)===String(g))?.label??g},{label:"Year",value:m}]})]}),e.jsx(cm,{data:P,loading:v,onViewStudent:f})]})}),e.jsx(um,{open:!!w,onClose:()=>f(null),loading:k,data:z,studentName:w?.student_name??w?.full_name})]})}const vm=vt.yearlyReport,_m=t=>{const n=t?.data?.data??t?.data??t??{};return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:Array.isArray(n?.students)?n.students:Array.isArray(n?.report)?n.report:[]},wm=t=>(Array.isArray(t)?t:[]).reduce((n,a)=>({present:n.present+Number(a?.singleStudentPresentData??a?.present??0),absent:n.absent+Number(a?.singleStudentAbsentData??a?.absent??0),late:n.late+Number(a?.late??0),leave:n.leave+Number(a?.leave??0)}),{present:0,absent:0,late:0,leave:0});function Cm({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[b,y]=i.useState(""),[u,x]=i.useState(""),[j,C]=i.useState(""),[m,h]=i.useState(""),[g,I]=i.useState(""),[R,D]=i.useState(0),w=Ma(t),f=Fa(a,t),p=am(t),S=i.useMemo(()=>!a||!d||R===0?null:kn(vm.table,{class_id:a,section_id:d,session_id:u,batch_id:m}),[m,a,R,d,u]),{data:A,isLoading:O,mutate:q}=G(t&&S?[S,t]:null,([E,F])=>kt(E,F)),U=i.useMemo(()=>_m(A),[A]),v=i.useMemo(()=>wm(U),[U]),M=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Present",dataIndex:"singleStudentPresentData"},{title:"Absent",dataIndex:"singleStudentAbsentData"}],[]),P=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(E,F,L)=>L+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}],[]),N=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(Z,{options:w.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{r(E?.value??""),l(E?.label??""),c(""),y(""),h(""),I("")},required:!0}),e.jsx(Z,{options:f.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{c(E?.value??""),y(E?.label??""),h(""),I("")},required:!0},`section-${a}`),e.jsx(Z,{options:p.options,label:"Session",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{x(E?.value??""),C(E?.label??"")},required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Search",color:"primary",onClick:()=>D(E=>E+1)})})]}),e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:b},{label:"Session",value:j}]})]});return e.jsx(Na,{title:"Yearly Report",subtitle:"Yearly attendance summary migrated from ERP AttendanceDashboard.",printRef:n,exportRows:U,exportColumns:M,onRefresh:()=>q?.(),filterSection:N,summary:v,chartContent:e.jsx(rn,{summary:v,title:"Yearly Attendance Summary"}),reportTitle:"Yearly Attendance List",fileBaseName:"yearly-attendance-report",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(_t,{}),e.jsx(Ot,{items:[{label:"Class",value:o},{label:"Section",value:b},{label:"Session",value:j}]})]}),e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(E,F)=>String(E?.student_id??E?.id??F),columns:P,dataSource:U,loading:O,pagination:{pageSize:25},scroll:{x:"max-content"}})]})})}function Am(){return null}const $a=t=>t??localStorage.getItem("authToken")??"",Tm=(t,n)=>{const a=String(t??""),r=String(n);return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r},_o=()=>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"}},Rm=()=>Tm(nt(),we.uploadNotes),Im=async({baseUrl:t,page:n=1,perPage:a=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,$a(r))},mt=async(t,n,a,{includeSession:r=!1}={})=>{const o=n instanceof FormData?n:new FormData;return r&&!o.has("session_id")&&o.append("session_id",_o()),Ye(t,o,$a(a))},Pt=async(t,n,a,{includeSession:r=!1}={})=>{const o=n instanceof FormData?n:new FormData;return r&&!o.has("session_id")&&o.append("session_id",_o()),ut(t,o,$a(a))},Et=async(t,n,a)=>at(t,n,$a(a)),Sa=we.master.sections,qn=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,b])=>Im({baseUrl:l,page:d,perPage:c},b)),Dm=({token:t,page:n=1,perPage:a=10})=>qn({token:t,baseUrl:Sa.table,page:n,perPage:a}),km=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Om({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),{data:b,isLoading:y,mutate:u}=Dm({token:t,page:n.page,perPage:n.perPage}),x=i.useMemo(()=>km(b),[b]),j=i.useMemo(()=>b?.pagination?.total_rows??b?.pagination?.total??x.length??0,[b,x]),C=async R=>{R.preventDefault();const D=new FormData(R.target);try{await mt(Sa.add,D,t),_.success("Success! Added new item.",{duration:1e3}),R.target.reset(),u()}catch(w){_.error(w?.response?.data?.msg??w?.message??"Failed to add the new item.",{duration:1500})}},m=async R=>{try{await Et(Sa.remove,R,t),_.success("Success! Deleted item.",{duration:1e3}),u()}catch(D){_.error(D?.response?.data?.msg??D?.message??"Failed to delete the item.",{duration:1500})}},h=R=>{d(R),o(!0),c.setFieldsValue({section:R?.section??""})},g=async R=>{const D=new FormData;D.append("id",String(l?.id??"")),D.append("section",R.section??"");try{await Pt(Sa.edit,D,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),u()}catch(w){_.error(w?.response?.data?.msg??w?.message??"Failed to update the item.",{duration:1500})}},I=i.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(R,D)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>h(D)}),e.jsx(s.Popconfirm,{title:"Delete this section?",onConfirm:()=>m(D?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Section",open:r,onClose:()=>{o(!1),d(null)},width:420,children:e.jsxs(s.Form,{form:c,layout:"vertical",onFinish:g,children:[e.jsx(s.Form.Item,{label:"Section Name",name:"section",rules:[{required:!0,message:"Section Name is required"}],children:e.jsx(s.Input,{placeholder:"Section Name"})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Section"}),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.jsx(J,{type:"text",name:"section",label:"Section Name",required:!0}),e.jsx(de,{type:"submit",value:"Submit",color:"primary"})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Section List"}),extra:e.jsx(s.Space,{}),children:e.jsx(s.Table,{rowKey:R=>R.id,columns:I,dataSource:x,loading:y,pagination:{current:n.page,pageSize:n.perPage,total:j,showSizeChanger:!0,onChange:(R,D)=>a({page:R,perPage:D})}})})]})}function Pm({token:t}){return e.jsx(Om,{token:t})}const An=we.master.classes,Em=({token:t,page:n=1,perPage:a=10})=>qn({token:t,baseUrl:An.table,page:n,perPage:a}),Mm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Fm=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function Nm({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[b]=s.Form.useForm(),{data:y}=G(t?[we.master.sections.list,t]:null,([A,O])=>Q(A,O)),u=i.useMemo(()=>Fm(y),[y]),x=i.useMemo(()=>u.map(A=>({label:A.label??A.section??String(A.value??""),value:String(A.value??A.id??"")})),[u]),{data:j,isLoading:C,mutate:m}=Em({token:t,page:n.page,perPage:n.perPage}),h=i.useMemo(()=>Mm(j),[j]),g=i.useMemo(()=>j?.pagination?.total_rows??j?.pagination?.total??h.length??0,[j,h]),{data:I}=G(t&&l?[`${An.show}?id=${encodeURIComponent(String(l))}`,t]:null,([A,O])=>Q(A,O)),R=i.useMemo(()=>{const A=I?.data??I;return Array.isArray(A)?A:Array.isArray(A?.data)?A.data:A?[A]:[]},[I]),D=A=>{const O=A?.id??A?.class_id;O&&(d(O),o(!0))};i.useEffect(()=>{if(!r||!R.length)return;const A=R[0],O=R.map(v=>v?.section_id??v?.fk_sectionId??v?.sectionId??v?.section).filter(v=>v!=null&&String(v).trim()!=="").map(v=>String(v)),q=Array.isArray(A?.section_ids)?A.section_ids.map(v=>String(v)):typeof A?.section_ids=="string"?A.section_ids.split(",").map(v=>v.trim()).filter(Boolean):Array.isArray(A?.section)?A.section.map(v=>String(v)):[],U=O.length?O:q;b.setFieldsValue({name:A?.class??A?.name??"",section:U})},[r,R,b]);const w=async A=>{const O=new FormData;O.append("name",A.name??""),(A.section??[]).forEach(q=>O.append("section[]",String(q)));try{await mt(An.add,O,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),m()}catch(q){_.error(q?.response?.data?.msg??q?.message??"Failed to add the new item.",{duration:1500})}},f=async A=>{const O=new FormData;O.append("id",String(l??"")),O.append("name",A.name??""),(A.section??[]).forEach(q=>O.append("section[]",String(q)));try{await Pt(An.edit,O,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),m()}catch(q){_.error(q?.response?.data?.msg??q?.message??"Failed to update the item.",{duration:1500})}},p=async A=>{try{await Et(An.remove,A,t),_.success("Success! Deleted item.",{duration:1e3}),m()}catch(O){_.error(O?.response?.data?.msg??O?.message??"Failed to delete the item.",{duration:1500})}},S=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(A,O)=>A??O?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:A=>A??""},{title:"Actions",key:"actions",width:120,render:(A,O)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(O)}),e.jsx(s.Popconfirm,{title:"Delete this class?",onConfirm:()=>p(O?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Class",open:r,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(s.Form,{form:b,layout:"vertical",onFinish:f,children:[e.jsx(s.Form.Item,{label:"Class",name:"name",rules:[{required:!0,message:"Class is required"}],children:e.jsx(s.Input,{placeholder:"Class"})}),e.jsx(s.Form.Item,{label:"Sections",name:"section",rules:[{required:!0,message:"Please select at least one section"}],children:e.jsx(s.Checkbox.Group,{options:x})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Class"}),children:e.jsx(s.Form,{form:c,layout:"vertical",onFinish:w,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"name",label:"Class",rules:[{required:!0,message:"Class is required"}],children:e.jsx(s.Input,{placeholder:"Class"})}),e.jsx(s.Form.Item,{name:"section",label:"Sections",rules:[{required:!0,message:"Select at least one section"}],children:e.jsx(s.Checkbox.Group,{options:x})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Class List"}),children:e.jsx(s.Table,{rowKey:A=>A.id,columns:S,dataSource:h,loading:C,pagination:{current:n.page,pageSize:n.perPage,total:g,showSizeChanger:!0,onChange:(A,O)=>a({page:A,perPage:O})}})})]})}function $m({token:t}){return e.jsx(Nm,{token:t})}const Tn=we.master.subjects,Um=({token:t,page:n=1,perPage:a=10})=>qn({token:t,baseUrl:Tn.table,page:n,perPage:a}),Bm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},pi=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],mi=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function Lm({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[b]=s.Form.useForm(),{data:y,isLoading:u,mutate:x}=Um({token:t,page:n.page,perPage:n.perPage}),j=i.useMemo(()=>Bm(y),[y]),C=i.useMemo(()=>y?.pagination?.total_rows??y?.pagination?.total??j.length??0,[y,j]),{data:m}=G(t&&l?[`${Tn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([f,p])=>Q(f,p)),h=i.useMemo(()=>{const f=m?.data??m;return Array.isArray(f)?f[0]:f??null},[m]);i.useEffect(()=>{r&&h&&b.setFieldsValue({name:h?.name??"",subject_type:h?.subject_type??h?.type??"",type:"",subject_types:Array.isArray(h?.subject_types)?h.subject_types:typeof h?.subject_types=="string"?h.subject_types.split(",").map(f=>f.trim()).filter(Boolean):[],code:h?.code??""})},[r,h,b]);const g=async f=>{const p=f?.type??f?.subject_type??"",S={name:f?.name??"",subject_type:p,type:p,subject_types:Array.isArray(f?.subject_types)?f.subject_types:[],code:f?.code??""};try{await Ye(Tn.add,S,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),x()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},I=async f=>{const p=new FormData,S=f?.type??f?.subject_type??"";p.append("id",String(l??"")),p.append("name",f.name??""),p.append("subject_type",f.subject_type??""),p.append("subject_type",S),p.append("type",S),p.append("code",f.code??"");try{await Pt(Tn.edit,p,t),_.success("Success! Updated item.",{duration:1e3}),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),x()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},R=async f=>{try{await Et(Tn.remove,f,t),_.success("Success! Deleted item.",{duration:1e3}),x()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete the item.",{duration:1500})}},D=f=>{const p=f?.id;p&&(d(p),o(!0))},w=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:(f,p)=>{const S=[],A=p?.subject_types;Array.isArray(A)?A.forEach(M=>{const P=String(M??"").trim();P&&S.push(P)}):typeof A=="string"&&A.split(",").map(M=>M.trim()).filter(Boolean).forEach(M=>S.push(M));const O=["yes","1","true"].includes(String(p?.is_practical??"").toLowerCase()),q=["yes","1","true"].includes(String(p?.is_theory??"").toLowerCase());O&&S.push("Practical"),q&&S.push("Theory");const U=S.map(M=>String(M??"").trim()).filter(Boolean).map(M=>M.toLowerCase()==="practical"?"Practical":M.toLowerCase()==="theory"?"Theory":M),v=Array.from(new Set(U));return v.length?v.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(f,p)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(p)}),e.jsx(s.Popconfirm,{title:"Delete this subject?",onConfirm:()=>R(p?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Subject",open:r,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(s.Form,{form:b,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{label:"Subject Name",name:"name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(J,{placeholder:"Subject Name"})}),e.jsx(s.Form.Item,{label:"Subject",name:"subject_type",rules:[{required:!0,message:"Select subject category"}],children:e.jsx(s.Radio.Group,{options:mi})}),e.jsx(s.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(s.Checkbox.Group,{options:pi})}),e.jsx(s.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(J,{placeholder:"Subject Code"})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Subject"}),children:e.jsx(s.Form,{form:c,layout:"vertical",onFinish:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"name",label:"Subject Name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(J,{placeholder:"Subject Name"})}),e.jsx(s.Form.Item,{name:"subject_type",label:"Subject",rules:[{required:!0,message:"Select subject"}],children:e.jsx(s.Radio.Group,{options:mi})}),e.jsx(s.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(s.Checkbox.Group,{options:pi})}),e.jsx(s.Form.Item,{name:"code",label:"Subject Code",children:e.jsx(J,{placeholder:"Subject Code"})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Subject List"}),children:e.jsx(s.Table,{rowKey:f=>f.id,columns:w,dataSource:j,loading:u,pagination:{current:n.page,pageSize:n.perPage,total:C,showSizeChanger:!0,onChange:(f,p)=>a({page:f,perPage:p})}})})]})}function qm({token:t}){return e.jsx(Lm,{token:t})}const Rn=we.master.holidays,zm=({token:t,page:n=1,perPage:a=10})=>qn({token:t,baseUrl:Rn.table,page:n,perPage:a}),Ym=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},aa={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Wm({token:t}){const[n,a]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[b]=s.Form.useForm(),{data:y,isLoading:u,mutate:x}=zm({token:t,page:n.page,perPage:n.perPage}),j=i.useMemo(()=>Ym(y),[y]),C=i.useMemo(()=>y?.pagination?.total_rows??y?.pagination?.total??j.length??0,[y,j]),{data:m}=G(t&&l?[`${Rn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([f,p])=>Q(f,p)),h=i.useMemo(()=>{const f=m?.data??m;return Array.isArray(f)?f[0]:f??null},[m]);i.useEffect(()=>{r&&h&&b.setFieldsValue({title:h?.holiday_title??"",description:h?.holiday_description??"",from:h?.start_date?ae(h.start_date):null,to:h?.end_date?ae(h.end_date):null})},[r,h,b]);const g=async f=>{const p=new FormData;p.append("title",f.title??""),p.append("description",f.description??""),p.append("from",f.from?ae(f.from).format("YYYY-MM-DD"):""),p.append("to",f.to?ae(f.to).format("YYYY-MM-DD"):"");try{await mt(Rn.add,p,t,{includeSession:!0}),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),x()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to add the new item.",{duration:1500})}},I=async f=>{const p=new FormData;p.append("id",String(l??"")),p.append("title",f.title??""),p.append("description",f.description??""),p.append("from",f.from?ae(f.from).format("YYYY-MM-DD"):""),p.append("to",f.to?ae(f.to).format("YYYY-MM-DD"):"");try{await Pt(Rn.edit,p,t,{includeSession:!0}),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),x()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update the item.",{duration:1500})}},R=async f=>{try{await Et(Rn.remove,f,t),_.success("Success! Deleted item.",{duration:1e3}),x()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to delete the item.",{duration:1500})}},D=f=>{const p=f?.id;p&&(d(p),o(!0))},w=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:(f,p)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>D(p)}),e.jsx(s.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>R(p?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Holiday",open:r,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(s.Form,{form:b,layout:"vertical",onFinish:I,children:[e.jsx(s.Form.Item,{label:"Holiday Title",name:"title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(J,{placeholder:"Holiday Title"})}),e.jsx(s.Form.Item,{label:"Holiday Description",name:"description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(J,{placeholder:"Holiday Description"})}),e.jsx(s.Form.Item,{label:"Start From",name:"from",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:aa})}),e.jsx(s.Form.Item,{label:"End At",name:"to",rules:[{required:!0,message:"End date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:aa})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Holidays"}),children:e.jsx(s.Form,{form:c,layout:"vertical",onFinish:g,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"title",label:"Holiday Title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(J,{placeholder:"Holiday Title"})}),e.jsx(s.Form.Item,{name:"description",label:"Holiday Description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(Dt,{placeholder:"Holiday Description"})}),e.jsx(s.Form.Item,{name:"from",label:"Start From",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:aa})}),e.jsx(s.Form.Item,{name:"to",label:"End At",rules:[{required:!0,message:"End date is required"}],children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:aa})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Holidays List"}),children:e.jsx(s.Table,{rowKey:f=>f.id,columns:w,dataSource:j,loading:u,pagination:{current:n.page,pageSize:n.perPage,total:C,showSizeChanger:!0,onChange:(f,p)=>a({page:f,perPage:p})}})})]})}function Vm({token:t}){return e.jsx(Wm,{token:t})}const ja=we.assignSubjects,Hm=({token:t,page:n=1,perPage:a=50})=>qn({token:t,baseUrl:ja.list,page:n,perPage:a}),yi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Km=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Gm({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,b]=i.useState(!1),[y,u]=i.useState(!1),[x,j]=i.useState(null),[C,m]=i.useState([]),{data:h}=G(t?[we.master.classes.dropdown,t]:null,([P,N])=>Q(P,N)),{data:g}=G(t?[we.master.subjects.dropdown,t]:null,([P,N])=>Q(P,N)),I=i.useMemo(()=>yi(h),[h]),R=i.useMemo(()=>yi(g),[g]),D=i.useMemo(()=>R.map(P=>({label:P.label??P.subject??String(P.value??""),value:P.value??P.id})),[R]),{data:w,isLoading:f,mutate:p}=Hm({token:t,page:n.page,perPage:n.perPage}),S=i.useMemo(()=>Km(w),[w]),A=i.useMemo(()=>w?.pagination?.total_rows??w?.pagination?.total??S.length??0,[w,S]),{data:O}=G(t&&x?[`${ja.editByClass}?class_id=${encodeURIComponent(String(x))}`,t]:null,([P,N])=>Q(P,N));i.useEffect(()=>{if(!y)return;const P=O?.data??O,N=Array.isArray(P)?P:Array.isArray(P?.data)?P.data:[];m(N.map(E=>E.subject_id).filter(Boolean))},[y,O]);const q=async P=>{if(P.preventDefault(),!r?.value){_.error("Please select class",{duration:1200});return}if(!l.length){_.error("Please select subjects",{duration:1200});return}const N=new FormData;N.append("class_id",String(r.value)),l.forEach(E=>N.append("subject[]",String(E)));try{b(!0),await Pt(ja.assign,N,t),_.success("Success! Updated item.",{duration:1e3}),o(null),d([]),p()}catch(E){_.error(E?.response?.data?.msg??E?.message??"Failed to update the item.",{duration:1500})}finally{b(!1)}},U=P=>{P&&(j(P),u(!0))},v=async()=>{if(!x)return;if(!C.length){_.error("Please select subjects",{duration:1200});return}const P=new FormData;P.append("class_id",String(x)),C.forEach(N=>P.append("subject[]",String(N)));try{await Pt(ja.update,P,t),_.success("Success! Updated item.",{duration:1e3}),u(!1),j(null),p()}catch(N){_.error(N?.response?.data?.msg??N?.message??"Failed to update the item.",{duration:1500})}},M=i.useMemo(()=>[{title:"Class",dataIndex:"class",align:"center",width:"15%"},{title:"Subject",dataIndex:"subject_name",width:"70%",render:(P,N)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:(N?.subject_name??P??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(P,N)=>e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>U(N?.class_id)})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Assigned Subjects",open:y,onClose:()=>{u(!1),j(null)},width:520,extra:e.jsxs(s.Space,{children:[e.jsx(s.Button,{onClick:()=>u(!1),children:"Cancel"}),e.jsx(s.Button,{type:"primary",onClick:v,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:I.find(P=>String(P.value)===String(x))??null,onChange:()=>{},isDisabled:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(s.Checkbox.Group,{options:D,value:C,onChange:m})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Subject"}),children:e.jsx("form",{onSubmit:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:r,onChange:P=>o(P??null)}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(s.Checkbox.Group,{options:D,value:l,onChange:d})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:c?"Please Wait..":"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assigned Subject List"}),children:e.jsx(s.Table,{rowKey:P=>P.id,columns:M,dataSource:S,loading:f,pagination:{current:n.page,pageSize:n.perPage,total:A,showSizeChanger:!0,onChange:(P,N)=>a({page:P,perPage:N})}})})]})}function Jm({token:t}){return e.jsx(Gm,{token:t})}const en=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[]},Sn=t=>wo(t),Qm=t=>wo(t),jn=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function Xm({token:t}){const[n,a]=i.useState(null),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,b]=i.useState("No"),[y,u]=i.useState([]),[x,j]=i.useState([]),[C,m]=i.useState(null),[h,g]=i.useState(null),[I,R]=i.useState(!1),[D,w]=i.useState(""),{data:f}=G(t?[en.teacherDropdown,t]:null,([ie,V])=>Q(ie,V)),{data:p}=G(t?[we.master.classes.dropdown,t]:null,([ie,V])=>Q(ie,V)),{data:S}=G(t&&h?[h,t]:null,([ie,V])=>Q(ie,V)),{data:A}=G(t&&C?[C,t]:null,([ie,V])=>Q(ie,V)),O=i.useMemo(()=>Sn(f),[f]),q=i.useMemo(()=>Sn(p),[p]),U=i.useMemo(()=>Sn(S),[S]),v=i.useMemo(()=>Sn(A),[A]),{data:M}=G(t&&n&&r&&l?[`${en.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(n))}&class_id=${encodeURIComponent(String(r))}§ion_id=${encodeURIComponent(String(l))}`,t]:null,([ie,V])=>Q(ie,V)),P=M?.data??M??null;i.useEffect(()=>{P&&(u(Array.isArray(P?.subject_ids)?P.subject_ids:[]),b(P?.isClassTeacher||"No"),j([]))},[P]);const{data:N}=G(t?[en.classWithSection,t]:null,([ie,V])=>Q(ie,V)),E=i.useMemo(()=>Sn(N),[N]),[F,L]=i.useState(null),[z,k]=i.useState({page:1,perPage:25});i.useEffect(()=>{F||E?.[0]&&L(`${E[0].class_id}val${E[0].section_id}`)},[E,F]);const T=i.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),$=i.useMemo(()=>{if(!F)return null;const[ie,V]=String(F).split("val");if(!ie||!V)return null;const oe=z.page??1,Ce=z.perPage??25;return`${en.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(oe))}&per_page=${encodeURIComponent(String(Ce))}&session_id=${encodeURIComponent(String(T))}&class_id=${encodeURIComponent(String(ie))}§ion_id=${encodeURIComponent(String(V))}`},[F,z.page,z.perPage,T]),{data:B,isLoading:Y,mutate:ne}=G(t&&$?[$,t]:null,([ie,V])=>Q(ie,V),{revalidateOnFocus:!1}),H=i.useMemo(()=>Qm(B),[B]),W=i.useMemo(()=>{const ie=B?.pagination??B?.data?.pagination??B?.data?.data?.pagination;return ie?.total_rows??ie?.total??H.length??0},[B,H]),ee=async ie=>{if(ie.preventDefault(),w(""),!n||!r||!l){_.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(y)||y.length===0){w("error"),_.error("Please Select Subject",{duration:1200});return}const V=new FormData;V.append("teacher_id",String(n)),V.append("class_id",String(r)),V.append("section_id",String(l)),V.append("isClassTeacher",String(c??"No")),jn(y).forEach(oe=>V.append("subject_ids[]",String(oe))),jn(x).forEach(oe=>V.append("delete_subject[]",String(oe)));try{await mt(en.assignClassToTeacher,V,t,{includeSession:!0}),_.success("Success! Added new item.",{duration:1e3}),w(""),ne()}catch(oe){_.error(oe?.response?.data?.msg??oe?.message??"Failed to add the new item.",{duration:1500})}},se=async ie=>{try{await Et(en.deleteTeacherSub,ie,t),_.success("Success! Deleted item.",{duration:1e3}),ne()}catch(V){_.error(V?.response?.data?.msg??V?.message??"Failed to delete the item.",{duration:1500})}},me=ie=>{const V=Array.isArray(ie?.child)?ie.child:[],oe=[{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Subject Code",dataIndex:"code",key:"code",align:"center"},{title:"Action",key:"action",align:"center",render:(Ce,Oe)=>e.jsx(s.Popconfirm,{title:"Delete this subject?",onConfirm:()=>se(Oe?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(s.Table,{columns:oe,bordered:!0,size:"small",dataSource:V,pagination:!1,rowKey:Ce=>Ce.id})})},ve=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(ie,V)=>e.jsxs("div",{children:[V.teacher_name,V.classTeacher==="Yes"?e.jsx("span",{style:{fontWeight:700},children:" (Class Teacher)"}):null]})}],re=i.useMemo(()=>(E??[]).map(ie=>({label:ie.label??`${ie.class_name??""} ${ie.section_name??""}`.trim(),key:`${ie.class_id}val${ie.section_id}`,children:e.jsx(s.Table,{size:"small",columns:ve,bordered:!0,dataSource:Array.isArray(H)?H:[],loading:Y,rowKey:V=>V.id,expandable:{expandedRowRender:me},pagination:{current:z.page,pageSize:z.perPage,total:W,showSizeChanger:!0,onChange:(V,oe)=>k({page:V,perPage:oe})}})})),[E,z.page,z.perPage,H,Y,W]);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(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign by Class"}),children:e.jsx("form",{onSubmit:ee,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:O.find(ie=>String(ie.value)===String(n))??null,onChange:ie=>a(ie?.value??null)}),e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:q.find(ie=>String(ie.value)===String(r))??null,onChange:ie=>{const V=ie?.value??null;o(V),d(null),m(V?`${we.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(V))}`:null),g(V?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(V))}`:null),R(oe=>!oe)}}),e.jsx(Z,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:U.find(ie=>String(ie.value)===String(l))??null,onChange:ie=>d(ie?.value??null)},`section_${I}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Is Class Teacher?"}),(()=>{const ie=[{label:"Yes",value:"Yes"},{label:"No",value:"No"}];return e.jsx(Z,{style:{width:"100%"},options:ie,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:ie.find(V=>String(V.value)===String(c??"No"))??ie[1],onChange:V=>b(V?.value??"No")})})()]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subject"}),e.jsx(Z,{isMulti:!0,style:{width:"100%"},placeholder:"select Subject",options:v,value:(v??[]).filter(ie=>jn(y).some(V=>String(V)===String(ie.value))),onChange:(ie,V)=>{const Ce=(Array.isArray(ie)?ie:[]).map(Ee=>Ee?.value).filter(Ee=>Ee!=null&&Ee!=="");u(Ce);const Oe=Array.isArray(P?.subject_ids)?P.subject_ids.map(String):[],Pe=V?.removedValue?.value,Fe=V?.option?.value;(V?.action==="remove-value"||V?.action==="pop-value")&&Pe!=null&&Oe.includes(String(Pe))&&j(Ee=>Array.from(new Set([...jn(Ee).map(String),String(Pe)]))),V?.action==="select-option"&&Fe!=null&&Oe.includes(String(Fe))&&j(Ee=>jn(Ee).filter(Ke=>String(Ke)!==String(Fe)))}},`subjects_${I}`),D?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(de,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Teacher List"}),children:e.jsx(s.Tabs,{activeKey:F??void 0,onChange:ie=>{L(ie),k(V=>({...V,page:1}))},items:re,type:"card",size:"small"})})]})]})}function Zm({token:t}){return e.jsx(Xm,{token:t})}const vn=we.timeGroup,ey=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Rt={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function sa(t){if(!t)return null;const n=ae(String(t),["h:mm a","HH:mm:ss","HH:mm"],!0);return n.isValid()?n:null}function It(t){return t?ae(t).format("h:mm a"):""}function ty({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=s.Form.useForm(),[b]=s.Form.useForm(),y=`${vn.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:u,isLoading:x,mutate:j}=G(t?[y,t]:null,([p,S])=>Q(p,S)),C=i.useMemo(()=>ey(u),[u]),m=i.useMemo(()=>u?.pagination?.total_rows??u?.pagination?.total??C.length??0,[u,C]),{data:h}=G(t&&l?[`${vn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([p,S])=>Q(p,S)),g=i.useMemo(()=>{const p=h?.data??h;return Array.isArray(p)?p[0]:p??null},[h]);i.useEffect(()=>{r&&g&&b.setFieldsValue({title:g?.title??"",start_time_from:sa(g?.start_time_from),start_time_to:sa(g?.start_time_to),end_time_from:sa(g?.end_time_from),end_time_to:sa(g?.end_time_to)})},[r,g,b]);const I=async p=>{const S=new FormData;S.append("title",p.title??""),S.append("start_time_from",It(p.start_time_from)),S.append("start_time_to",It(p.start_time_to)),S.append("end_time_from",It(p.end_time_from)),S.append("end_time_to",It(p.end_time_to));try{await mt(vn.add,S,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),j()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},R=async p=>{const S=new FormData;S.append("id",String(l??"")),S.append("title",p.title??""),S.append("start_time_from",It(p.start_time_from)),S.append("start_time_to",It(p.start_time_to)),S.append("end_time_from",It(p.end_time_from)),S.append("end_time_to",It(p.end_time_to));try{await Pt(vn.edit,S,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),j()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},D=async p=>{try{await Et(vn.remove,p,t),_.success("Success! Deleted item.",{duration:1e3}),j()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to delete the item.",{duration:1500})}},w=p=>{p?.id&&(d(p.id),o(!0))},f=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:(p,S)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>w(S)}),e.jsx(s.Popconfirm,{title:"Delete this time group?",onConfirm:()=>D(S?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Time Group",open:r,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(s.Form,{form:b,layout:"vertical",onFinish:R,children:[e.jsx(s.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(s.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Rt})}),e.jsx(s.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Rt})}),e.jsx(s.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Rt})}),e.jsx(s.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Rt})}),e.jsxs(s.Space,{children:[e.jsx(de,{type:"submit",value:"Submit",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Create Time Group"}),children:e.jsx(s.Form,{form:c,layout:"vertical",onFinish:I,initialValues:{},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(s.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Rt})}),e.jsx(s.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Rt})}),e.jsx(s.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Rt})}),e.jsx(s.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm a",style:Rt})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Time Group List"}),children:e.jsx(s.Table,{rowKey:p=>p.id,columns:f,dataSource:C,loading:x,pagination:{current:n.page,pageSize:n.perPage,total:m,showSizeChanger:!0,onChange:(p,S)=>a({page:p,perPage:S})}})})]})}function ny({token:t}){return e.jsx(ty,{token:t})}const _n=we.assignTimeGroup,ay=we.timeGroup.dropdown,sy=we.master.classes.dropdown,fi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],ry=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function iy({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,b]=i.useState(""),[y,u]=i.useState(""),[x,j]=i.useState(null),[C,m]=i.useState(!1),[h,g]=i.useState(!1),[I,R]=i.useState(null),[D,w]=i.useState([]),[f,p]=i.useState(""),[S,A]=i.useState(""),{data:O}=G(t?[ay,t]:null,([H,W])=>Q(H,W)),{data:q}=G(t?[sy,t]:null,([H,W])=>Q(H,W)),U=i.useMemo(()=>fi(O?.data??O),[O]),v=i.useMemo(()=>fi(q),[q]),{data:M}=G(t&&x?[x,t]:null,([H,W])=>Q(H,W));i.useEffect(()=>{const H=Array.isArray(M?.data)?M.data.map(W=>W.fk_classId):[];H.length&&d(H)},[M]);const P=`${_n.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:N,isLoading:E,mutate:F}=G(t?[P,t]:null,([H,W])=>Q(H,W)),L=i.useMemo(()=>ry(N),[N]),z=i.useMemo(()=>N?.pagination?.total_rows??N?.pagination?.total??L.length??0,[N,L]),{data:k}=G(t&&I?[`${_n.show}?id=${encodeURIComponent(String(I))}`,t]:null,([H,W])=>Q(H,W)),T=k?.data??k??null;i.useEffect(()=>{if(!h||!T)return;const H=Array.isArray(T?.class_ids)?T.class_ids:[];w(H);const W=Array.isArray(U)?U.find(ee=>String(ee.value)===String(T?.timegroup_id)):null;W&&A(`${W.start_time_from} -> ${W.end_time_from}`)},[h,T,U]);const $=async H=>{if(H.preventDefault(),b(""),!r?.value){_.error("Select Time Group",{duration:1200});return}if(!l.length){b("error"),_.error("Please Select Classes",{duration:1200});return}const W=new FormData;W.append("timegroup_id",String(r.value)),l.forEach(ee=>W.append("class_ids[]",String(ee)));try{await mt(_n.assign,W,t),_.success("Success! Added new item.",{duration:1e3}),d([]),o(null),u(""),F()}catch(ee){_.error(ee?.response?.data?.msg??ee?.message??"Failed to add the new item.",{duration:1500})}},B=async()=>{if(p(""),!I)return;if(!D.length){p("error"),_.error("Please Select Classes",{duration:1200});return}const H=new FormData;H.append("id",String(I)),H.append("timegroup_id",String(T?.timegroup_id??"")),D.forEach(W=>H.append("class_ids[]",String(W)));try{await Pt(_n.assign,H,t),_.success("Success! Updated item.",{duration:1e3}),g(!1),R(null),F()}catch(W){_.error(W?.response?.data?.msg??W?.message??"Failed to update the item.",{duration:1500})}},Y=H=>{H&&(R(H),g(!0))},ne=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:(H,W)=>W?.class_names?e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>Y(W?.id)}):null}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Drawer,{title:"Edit Assigned Time Group",open:h,onClose:()=>{g(!1),R(null)},width:520,extra:e.jsxs(s.Space,{children:[e.jsx(s.Button,{onClick:()=>g(!1),children:"Cancel"}),e.jsx(s.Button,{type:"primary",onClick:B,children:"Submit"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{options:Array.isArray(U)?U:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:U.find(H=>String(H.value)===String(T?.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(s.Select,{mode:"multiple",style:{width:"100%"},status:f,value:D,placeholder:"Select Classes",onChange:H=>w(H),options:Array.isArray(v)?v:[]})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Time Group"}),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.jsxs("div",{children:[e.jsx(Z,{options:Array.isArray(U)?U:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:r,onChange:H=>{o(H??null),d([]),b(""),H?.value?(j(`${_n.classIdByTimeGroup}?id=${encodeURIComponent(String(H.value))}`),u(`${H.start_time_from} -> ${H.end_time_from}`)):(j(null),u("")),m(W=>!W)}}),e.jsx("div",{style:{marginTop:6},children:y})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(Z,{mode:"multiple",style:{width:"100%"},status:c,value:l,placeholder:"Select Classes",onChange:H=>d(H),options:Array.isArray(v)?v:[]},`class_${C}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assigned Time group List"}),children:e.jsx(s.Table,{rowKey:H=>H.id,columns:ne,dataSource:L,loading:E,pagination:{current:n.page,pageSize:n.perPage,total:z,showSizeChanger:!0,onChange:(H,W)=>a({page:H,perPage:W})}})})]})}function oy({token:t}){return e.jsx(iy,{token:t})}const As=we.promoteStudents,ly=({token:t})=>G(t?[As.sessionDropdown,t]:null,([n,a])=>Q(n,a)),ra=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[]},dy=(t,n)=>{const a=t?.pagination??t?.data?.pagination??t?.data?.data?.pagination,r=a?.total_rows??a?.total??a?.totalItems;return Number.isFinite(Number(r))?Number(r):n};function cy({token:t}){const[n]=s.Form.useForm(),[a,r]=i.useState({page:1,perPage:300}),[o,l]=i.useState({classId:null,sectionId:null}),[d,c]=i.useState({sessionId:null,classId:null}),[b,y]=i.useState(!1),[u,x]=i.useState([]),j=i.useMemo(()=>new Set(u),[u]),[C,m]=i.useState({}),[h,g]=i.useState({}),{data:I}=G(t?[we.master.classes.dropdown,t]:null,([B,Y])=>Q(B,Y)),R=i.useMemo(()=>ra(I),[I]),D=i.useMemo(()=>o.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(o.classId))}`:null,[o.classId]),{data:w}=G(t&&D?[D,t]:null,([B,Y])=>Q(B,Y)),f=i.useMemo(()=>ra(w),[w]),p=i.useMemo(()=>d.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:S}=G(t&&p?[p,t]:null,([B,Y])=>Q(B,Y),{revalidateOnFocus:!1}),A=i.useMemo(()=>ra(S),[S]),{data:O}=ly({token:t}),q=i.useMemo(()=>ra(O),[O]),{trigger:U,data:v,isMutating:M}=Je(t?As.searchByClassSection:null,(B,{arg:Y})=>Lt(B,{arg:Y},t)),P=i.useMemo(()=>{const B=v?.data?.data??v?.data??v??[];return Array.isArray(B)?B:Array.isArray(B?.data)?B.data:[]},[v]),N=i.useMemo(()=>dy(v,P.length??0),[v,P.length]),E=i.useMemo(()=>{const B=new Map;return(Array.isArray(P)?P:[]).forEach(Y=>{Y?.id!==void 0&&Y?.id!==null&&B.set(String(Y.id),Y)}),B},[P]),F=i.useCallback((B,Y)=>{const ne=String(B);g(H=>({...H,[ne]:{...H?.[ne]??{},...Y}}))},[]),L=i.useCallback((B,Y)=>{const ne=String(B),H=Y==="Leave";m(W=>({...W,[ne]:H}))},[]),z=B=>{const Y=B?.class_id?.value??B?.class_id??null,ne=B?.section_id?.value??B?.section_id??null;if(!Y||!ne){_.error("Please select Class and Section",{duration:1200});return}r(H=>({...H,page:1})),l({classId:Y,sectionId:ne}),x([]),m({}),g({})},k=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 B=u.map(W=>String(W)).map(W=>{const ee=E.get(W)??{},se=!!C?.[W],me=h?.[W]??{},ve=String(me.current_result??"Pass");if(se){const V=String(me.leave_date??"");return{student_id:W,current_result:ve,next_session_status:"Leave",leave_date:V}}const re=String(me.roll_no??ee?.roll_no??""),ie=String(me.section_id??"");return{student_id:W,roll_no:re,section_id:ie,current_result:ve,next_session_status:"Continue"}});if(B.some(W=>W?.next_session_status==="Leave"&&!String(W?.leave_date??"").trim())){_.error("Leave date is required for Leave students.",{duration:1500});return}if(B.some(W=>W?.next_session_status==="Continue"&&!String(W?.section_id??"").trim())){_.error("Section is required for Continue students.",{duration:1500});return}const H={class_id:String(d.classId),session_id:String(d.sessionId),students:B};try{const W=await ut(As.promote,H,t);if(W?.Status&&String(W.Status)!=="success")throw new Error(W?.msg||"Failed to update");_.success("Success! Updated.",{duration:1e3});const ee=Number(W?.success_count??0)+Number(W?.leave_count??0),se=a.page===Math.ceil((Number(N)||0)/a.perPage||1),me=ee>0&&ee===P.length&&P.length===u.length,ve=se&&me&&a.page>1?a.page-1:a.page;r(re=>({...re,page:ve})),U?.({cID:o.classId,sID:o.sectionId,page:ve,per_page:a.perPage}),x([]),m({}),g({})}catch(W){_.error(W?.response?.data?.msg??W?.message??"Failed to update",{duration:1500})}},T=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,Y)=>{const ne=String(Y?.id??""),H=j.has(ne),W=!!C?.[ne],se=(h?.[ne]??{}).roll_no??(W?"":Y?.roll_no??"");return e.jsx(s.Input,{value:H?se:Y?.roll_no,style:H?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!H||W,onChange:me=>F(ne,{roll_no:me.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(B,Y)=>`${Y?.firstname??""} ${Y?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(B,Y)=>{const ne=String(Y?.id??""),H=j.has(ne),W=!!C?.[ne],se=(h?.[ne]??{}).section_id??"",me=Array.isArray(A)?A:[];return e.jsx(s.Select,{options:me,placeholder:H&&!W?"Select Section":"Section",disabled:!H||W,value:H&&!W&&se||void 0,style:{width:"100%"},onChange:ve=>F(ne,{section_id:ve})},`section_${ne}_${b}_${W?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(B,Y)=>{const ne=String(Y?.id??""),H=j.has(ne),W=h?.[ne]??{},ee=String(W.current_result??"Pass");return e.jsxs(s.Radio.Group,{value:ee,disabled:!H,buttonStyle:"solid",onChange:se=>F(ne,{current_result:se.target.value}),children:[e.jsx(s.Radio.Button,{value:"Pass",children:"Pass"}),e.jsx(s.Radio.Button,{value:"Fail",children:"Fail"})]})}},{title:"Next Session Status",dataIndex:"next_session_status",key:"next_session_status",width:220,render:(B,Y)=>{const ne=String(Y?.id??""),H=j.has(ne),W=!!C?.[ne],ee=h?.[ne]??{},se=String(ee.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(s.Radio.Group,{value:W?"Leave":"Continue",disabled:!H,buttonStyle:"solid",onChange:me=>L(ne,me.target.value),children:[e.jsx(s.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(s.Radio.Button,{value:"Leave",children:"Leave"})]}),H&&W&&e.jsx(s.DatePicker,{style:{width:"100%"},value:se?ae(se):null,onChange:me=>F(ne,{leave_date:me?me.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[L,C,h,j,b,A,F]),$=i.useMemo(()=>({selectedRowKeys:u,onChange:B=>x((Array.isArray(B)?B:[]).map(Y=>String(Y)))}),[u]);return i.useEffect(()=>{!o.classId||!o.sectionId||U&&U({cID:o.classId,sID:o.sectionId,page:a.page,per_page:a.perPage})},[a.page,a.perPage,U,o.classId,o.sectionId]),e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Promote Students"}),children:e.jsx(s.Form,{form:n,layout:"vertical",onFinish:z,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{name:"class_id",label:"Class",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:B=>B,children:e.jsx(Z,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:B=>{const Y=B?.value??null;n.setFieldValue("section_id",null),l({classId:Y,sectionId:null})}})}),e.jsx(s.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:B=>B,children:e.jsx(Z,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Promote Students In Next Session"}),extra:e.jsx(Ft,{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(s.Typography.Text,{children:["Selected: ",u.length]}),e.jsx(s.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(Z,{label:"Session",options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:q.find(B=>String(B.value)===String(d.sessionId))??null,onChange:B=>c(Y=>({...Y,sessionId:B?.value??null}))}),e.jsx(Z,{label:"Class",options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:R.find(B=>String(B.value)===String(d.classId))??null,onChange:B=>{const Y=B?.value??null;c(ne=>({...ne,classId:Y})),y(ne=>!ne)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"button",value:"Save",color:"primary",onClick:k})})]}),e.jsx(s.Table,{rowKey:B=>String(B.id),rowSelection:$,columns:T,dataSource:P,loading:M,pagination:{current:a.page,pageSize:a.perPage,total:N,showSizeChanger:!0,onChange:(B,Y)=>{r({page:B,perPage:Y}),x([]),m({}),g({})}}})]})})]})}function uy({token:t}){return e.jsx(cy,{token:t})}const tn=we.coscholastic,py=({token:t})=>G(t?[tn.table,t]:null,([n,a])=>Q(n,a),{revalidateOnFocus:!1}),my=({token:t})=>G(t?[tn.categoryDropdown,t]:null,([n,a])=>Q(n,a),{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 yy({token:t}){const[n,a]=i.useState(""),[r,o]=i.useState(null),[l,d]=i.useState(null),c=i.useRef(null),{data:b}=G(t?[we.master.classes.dropdown,t]:null,([S,A])=>Q(S,A)),y=i.useMemo(()=>hi(b),[b]),{data:u,isLoading:x,mutate:j}=py({token:t}),C=i.useMemo(()=>{const S=u?.data?.data??u?.data??u??[];return Array.isArray(S)?S:Array.isArray(S?.data)?S.data:[]},[u]),{data:m,mutate:h}=my({token:t}),g=i.useMemo(()=>hi(m),[m]),I=i.useMemo(()=>(Array.isArray(g)?g:[]).map(S=>({value:S?.value??S?.id,label:S?.label??S?.title??""})),[g]),R=async()=>{const S=String(n??"").trim();if(!S){_.error("Please enter category title",{duration:1200});return}try{await Ye(tn.addCategory,{title:S},t),_.success("Success! Added category.",{duration:1e3}),a(""),h()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add category",{duration:1500})}},D=async S=>{try{await Et(tn.deleteCategory,S,t),_.success("Success! Deleted category.",{duration:1e3}),h()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete category",{duration:1500})}},w=async S=>{if(S.preventDefault(),!r){_.error("Please select Category",{duration:1200});return}if(!l){_.error("Please select Class",{duration:1200});return}if(!S?.target?.skill?.value){_.error("Please enter Skill Name",{duration:1200});return}const O=new FormData(S.target);O.append("scholastic_catid",String(r)),O.append("class_id",String(l));try{await mt(tn.addSkill,O,t),_.success("Success! Added new item.",{duration:1e3}),S.target.reset(),d(null),j()}catch(q){_.error(q?.response?.data?.msg??q?.message??"Failed to add the new item.",{duration:1500})}},f=async S=>{try{await Et(tn.deleteSkill,S,t),_.success("Success! Deleted item.",{duration:1e3}),j()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete the item.",{duration:1500})}},p=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(s.Popconfirm,{title:"Delete this skill?",onConfirm:()=>f(A?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Co Scholastic Area"}),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.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Category"}),e.jsx(Z,{style:{width:"100%"},value:I.find(S=>String(S.value)===String(r))??null,placeholder:"Select Category",onChange:S=>o(S?.value??null),options:I}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:10},children:[e.jsx(J,{placeholder:"New category",ref:c,value:n,onChange:S=>a(S.target.value)}),e.jsx(s.Button,{type:"text",icon:e.jsx(X.PlusOutlined,{}),onClick:R}),e.jsx(s.Popconfirm,{title:"Delete selected category?",onConfirm:()=>{r&&(D(r),o(null))},children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{}),disabled:!r})})]})]}),e.jsx(Z,{label:"Class",options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:y.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(J,{name:"skill",placeholder:"Skill Name"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Co Scholastic Area List"}),extra:e.jsx(Ft,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(s.Table,{rowKey:S=>S.id,columns:p,dataSource:C,loading:x,pagination:!1})})]})}function fy({token:t}){return e.jsx(yy,{token:t})}const hy=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Co=({token:t,value:n,onChange:a})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:Rm(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=hy(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},gi=we.notes,gy=({token:t,url:n})=>G(t&&n?[n,t]:null,([a,r])=>Q(a,r),{revalidateOnFocus:!1}),ia=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[]},xy=(t,n)=>{const a=String(t??""),r=String(n??"");return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r};function by({token:t}){const[n]=s.Form.useForm(),[a]=s.Form.useForm(),[r,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null,sectionId:null}),[c,b]=i.useState(!1),[y,u]=i.useState(""),{data:x}=G(t?[we.master.classes.dropdown,t]:null,([$,B])=>Q($,B)),j=i.useMemo(()=>ia(x),[x]),C=i.useMemo(()=>l.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:m}=G(t&&C?[C,t]:null,([$,B])=>Q($,B)),h=i.useMemo(()=>ia(m),[m]),g=i.useMemo(()=>!l.classId||!l.sectionId?null:`${gi.table}?class_id=${encodeURIComponent(String(l.classId))}§ion_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:I,isLoading:R,mutate:D}=gy({token:t,url:g}),w=i.useMemo(()=>{const $=I?.data?.data??I?.data??I??[];return Array.isArray($)?$:Array.isArray($?.data)?$.data:[]},[I]),f=i.useMemo(()=>I?.pagination?.total_rows??I?.pagination?.total??w.length??0,[I,w.length]),[p,S]=i.useState(null),[A,O]=i.useState(null),[q,U]=i.useState(null),[v,M]=i.useState(!1),{data:P}=G(t&&q?[q,t]:null,([$,B])=>Q($,B),{revalidateOnFocus:!1}),N=i.useMemo(()=>ia(P),[P]),{data:E}=G(t&&A?[A,t]:null,([$,B])=>Q($,B)),F=i.useMemo(()=>ia(E),[E]),L=$=>{const B=$?.class_id?.value??null,Y=$?.section_id?.value??null;!B||!Y||(o(ne=>({...ne,page:1})),d({classId:B,sectionId:Y}))},z=()=>{u(""),b(!0),S(null),O(null),U(null),M($=>!$),a.resetFields()},k=async $=>{const B=$?.class_id?.value??null,Y=$?.section_id?.value??null,ne=$?.sub_id?.value??null,H=$?.status?.value??"publish",W=$?.title??"",ee=$?.remark??"";if(!B||!Y||!ne||!W||!ee||!y){_.error("Please fill all fields",{duration:1200});return}const se=new FormData;se.append("class_id",String(B)),se.append("section_id",String(Y)),se.append("sub_id",String(ne)),se.append("title",String(W)),se.append("remark",String(ee)),se.append("status",String(H)),se.append("file",String(y));try{await mt(gi.add,se,t),_.success("Success! Added new item.",{duration:1e3}),b(!1),D()}catch(me){_.error(me?.response?.data?.msg??me?.message??"Failed to add the new item.",{duration:1500})}},T=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)=>{const Y=String(B?.status??"").toLowerCase();return e.jsx(s.Tag,{color:Y==="publish"?"green":"red",children:B?.status??"-"})}},{title:"File",key:"file",align:"center",render:($,B)=>{const Y=B?.file;if(!Y)return"-";const ne=xy(nt(),`/student/note/${Y}`);return e.jsx("a",{href:ne,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(s.Modal,{title:"Add Note",open:c,onCancel:()=>b(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(s.Form,{form:a,layout:"vertical",onFinish:k,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(Z,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const B=$?.value??null;S(B),a.setFieldValue("section_id",null),a.setFieldValue("sub_id",null),U(B?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(B))}`:null),O(B?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(B))}`:null),M(Y=>!Y)}},`class_${v}`)}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:$=>$,children:e.jsx(Z,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${v}_${p??"none"}`)}),e.jsx(s.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:$=>$,children:e.jsx(Z,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${v}_${A??"none"}`)}),e.jsx(s.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(s.Form.Item,{label:"Remark",name:"remark",rules:[{required:!0,message:"Remark is required"}],children:e.jsx(J,{placeholder:"Remark"})}),e.jsx(s.Form.Item,{label:"Status",name:"status",initialValue:{label:"Publish",value:"publish"},getValueFromEvent:$=>$,children:e.jsx(Z,{options:[{label:"Publish",value:"publish"},{label:"Unpublish",value:"unpublish"}],closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx(s.Form.Item,{label:"File",required:!0,children:e.jsx(Co,{token:t,value:y,onChange:u})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>b(!1),children:"Cancel"})]})]})})}),e.jsx(s.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Notes"}),e.jsx(Ft,{actions:["add","export","print","download","filter"],onAdd:z,onPrint:()=>window.print()})]}),children:e.jsx(s.Form,{form:n,layout:"vertical",onFinish:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(Z,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const B=$?.value??null;n.setFieldValue("section_id",null),d({classId:B,sectionId:null})}})}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:$=>$,children:e.jsx(Z,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Note List"}),children:e.jsx(s.Table,{rowKey:$=>$.id,columns:T,dataSource:w,loading:R,pagination:{current:r.page,pageSize:r.perPage,total:f,showSizeChanger:!0,onChange:($,B)=>o({page:$,perPage:B})}})})]})}function Sy({token:t}){return e.jsx(by,{token:t})}const jy=({token:t})=>G(t?[we.promoteStudents.sessionDropdown,t]:null,([n,a])=>Q(n,a),{revalidateOnFocus:!1}),xi=we.transferCertificate,us=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[]},vy={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},_y=(t,n)=>t.inputtype==="Select"?null:t.inputtype==="date"?ae():"",bi=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}],Si=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 wy({token:t,transferCertificateViewPath:n="/AcademicsDashboard/TransferCertificateView",onOpenTransferCertificateView:a}){const[r]=s.Form.useForm(),[o]=s.Form.useForm(),[l,d]=i.useState({page:1,perPage:10}),[c,b]=i.useState({classId:null,sectionId:null,sessionId:null}),[y,u]=i.useState(null),[x,j]=i.useState(!1),{data:C}=G(t?[we.master.classes.dropdown,t]:null,([T,$])=>Q(T,$)),m=i.useMemo(()=>us(C),[C]),{data:h}=G(t&&y?[y,t]:null,([T,$])=>Q(T,$)),g=i.useMemo(()=>us(h),[h]),{data:I}=jy({token:t}),R=i.useMemo(()=>us(I),[I]),D=i.useMemo(()=>!c.classId||!c.sectionId||!c.sessionId?null:`${xi.studentList}?class_id=${encodeURIComponent(String(c.classId))}§ion_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:w,isLoading:f,mutate:p}=G(t&&D?[D,t]:null,([T,$])=>Q(T,$),{revalidateOnFocus:!1,onSuccess:T=>{const $=T?.data?.data??T?.data??[];Array.isArray($)&&$[0]?.transefer_certificate_id&&P(String($[0].transefer_certificate_id))}}),S=i.useMemo(()=>{const T=w?.data?.data??w?.data??w??[];return Array.isArray(T)?T:Array.isArray(T?.data)?T.data:[]},[w]),A=i.useMemo(()=>w?.pagination?.total_rows??w?.pagination?.total??S.length??0,[w,S.length]),[O,q]=i.useState(!1),[U,v]=i.useState(null),[M,P]=i.useState("1"),N=T=>{v(T);const $=M==="1"?bi(T):Si(T),B={};$.forEach(Y=>{B[Y.name]=Y.value??_y(Y)}),o.setFieldsValue(B),q(!0)},E=async T=>{if(!T)return;if(typeof a=="function")return a(T);const $=`${n}?id=${encodeURIComponent(String(T))}`;window.location.href=$},F=T=>{const $=T?.class_id?.value??null,B=T?.section_id?.value??null,Y=T?.session_id?.value??null;if(!$||!B||!Y){_.error("Please select Class, Section and Session",{duration:1200});return}d(ne=>({...ne,page:1})),b({classId:$,sectionId:B,sessionId:Y})},L=async T=>{const $=new FormData;Object.entries(T??{}).forEach(([B,Y])=>{if(Y!=null){if(ae.isDayjs(Y)){$.append(B,Y.format("YYYY-MM-DD"));return}$.append(B,String(Y))}});try{await mt(xi.addData,$,t),_.success("Success! Added new item.",{duration:1e3}),q(!1),v(null),p()}catch(B){_.error(B?.response?.data?.msg??B?.message??"Failed to add the new item.",{duration:1500})}},z=i.useMemo(()=>M==="1"?bi(U):Si(U),[M,U]),k=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:(T,$)=>e.jsx(s.Button,{type:"text",icon:$?.transfer_certificate_data==="not_present"?e.jsx(X.EyeOutlined,{}):e.jsx(X.CheckOutlined,{}),onClick:()=>{$?.transfer_certificate_data==="not_present"?N($?.id):E($?.id)}})}],[M]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:"Transfer Certificate",open:O,onCancel:()=>q(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:L,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:z.map(T=>T.inputtype==="hidden"?e.jsx(s.Form.Item,{name:T.name,initialValue:T.value??"",style:{display:"none"},children:e.jsx("input",{type:"hidden"})},T.name):T.inputtype==="date"?e.jsx(s.Form.Item,{label:T.label,name:T.name,children:e.jsx(s.DatePicker,{format:"YYYY-MM-DD",style:vy})},T.name):T.inputtype==="radio"?e.jsx(s.Form.Item,{label:T.label,name:T.name,children:e.jsx(s.Radio.Group,{options:[{label:"Yes",value:"Yes"},{label:"No",value:"No"}]})},T.name):T.inputtype==="Select"?e.jsx(s.Form.Item,{label:T.label,name:T.name,getValueFromEvent:$=>$,children:e.jsx(Z,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})},T.name):e.jsx(s.Form.Item,{label:T.label,name:T.name,children:e.jsx(J,{placeholder:T.label})},T.name))}),e.jsxs(s.Space,{style:{width:"100%",justifyContent:"flex-end"},children:[e.jsx(de,{type:"submit",value:"Submit",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>q(!1),children:"Cancel"})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Student History"}),children:e.jsx(s.Form,{form:r,layout:"vertical",onFinish:F,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:T=>T,children:e.jsx(Z,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:T=>{const $=T?.value??null;u($?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String($))}`:null),j(B=>!B),r.setFieldValue("section_id",null)}})}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:T=>T,children:e.jsx(Z,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${x}`)}),e.jsx(s.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:T=>T,children:e.jsx(Z,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Student List"}),extra:e.jsx(Ft,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(s.Table,{rowKey:T=>T.id,columns:k,dataSource:S,loading:f,pagination:{current:l.page,pageSize:l.perPage,total:A,showSizeChanger:!0,onChange:(T,$)=>d({page:T,perPage:$})}})})]})}function Cy({token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:a}){return e.jsx(wy,{token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:a})}const Ay=({token:t,url:n})=>G(t&&n?[n,t]:null,([a,r])=>Q(a,r),{revalidateOnFocus:!1}),ps=we.syllabus,ji=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[]},Ty=(t,n)=>{const a=String(t??""),r=String(n??"");return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r};function Ry({token:t}){const[n]=s.Form.useForm(),[a]=s.Form.useForm(),[r,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null}),[c,b]=i.useState(!1),[y,u]=i.useState(null),[x,j]=i.useState(""),{data:C}=G(t?[we.master.classes.dropdown,t]:null,([E,F])=>Q(E,F)),m=i.useMemo(()=>ji(C),[C]),h=i.useMemo(()=>l.classId?`${ps.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:g,isLoading:I,mutate:R}=Ay({token:t,url:h}),D=i.useMemo(()=>{const E=g?.data?.data??g?.data??g??[];return Array.isArray(E)?E:Array.isArray(E?.data)?E.data:[]},[g]),w=i.useMemo(()=>g?.pagination?.total_rows??g?.pagination?.total??D.length??0,[g,D.length]),[f,p]=i.useState(null),[S,A]=i.useState(!1),{data:O}=G(t&&f?[f,t]:null,([E,F])=>Q(E,F),{revalidateOnFocus:!1}),q=i.useMemo(()=>ji(O),[O]),U=E=>{const F=E?.class_id?.value??null;F&&(o(L=>({...L,page:1})),d({classId:F}))},v=()=>{u(null),j(""),p(null),A(E=>!E),a.resetFields(),b(!0)},M=E=>{u(E),j(E?.attchement??"");const F=E?.class_id;p(F?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(F))}`:null),A(L=>!L),a.setFieldsValue({class_id:m.find(L=>String(L.value)===String(F))??null,sub_id:q.find(L=>String(L.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??""}),b(!0)},P=async E=>{const F=E?.class_id?.value??null,L=E?.sub_id?.value??null,z=E?.title??"",k=E?.description??"";if(!F||!L||!z||!k||!x){_.error("Please fill all fields",{duration:1200});return}const T=new FormData;T.append("class_id",String(F)),T.append("sub_id",String(L)),T.append("title",String(z)),T.append("description",String(k)),T.append("file",String(x));try{y?.id?(T.append("id",String(y.id)),await mt(ps.edit,T,t),_.success("Success! Updated item.",{duration:1e3})):(await mt(ps.add,T,t),_.success("Success! Added new item.",{duration:1e3})),b(!1),u(null),R()}catch($){_.error($?.response?.data?.msg??$?.message??"Failed to save",{duration:1500})}},N=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,F)=>{const L=F?.attchement;if(!L)return"-";const z=Ty(nt(),`uploads/student/note/${L}`);return e.jsx("a",{href:z,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:(E,F)=>e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>M(F)})}],[q,m]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:y?"Edit Syllabus":"Add Syllabus",open:c,onCancel:()=>{b(!1),u(null),j("")},footer:null,width:820,destroyOnClose:!0,children:e.jsx(s.Form,{form:a,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(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:E=>E,children:e.jsx(Z,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{const F=E?.value??null;a.setFieldValue("sub_id",null),p(F?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(F))}`:null),A(L=>!L)}},`class_${y?.id??"add"}_${S}`)}),e.jsx(s.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:E=>E,children:e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${y?.id??"add"}_${S}_${f??"none"}`)}),e.jsx(s.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(J,{placeholder:"Title"})}),e.jsx(s.Form.Item,{label:"Description",name:"description",rules:[{required:!0,message:"Description is required"}],children:e.jsx(Dt,{placeholder:"Description"})}),e.jsx(s.Form.Item,{label:"File",required:!0,children:e.jsx(Co,{token:t,value:x,onChange:j})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(de,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>b(!1),children:"Cancel"})]})]})})}),e.jsx(s.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Syllabus"}),e.jsx(Ft,{actions:["add","export","print","download","filter"],onAdd:v,onPrint:()=>window.print()})]}),children:e.jsx(s.Form,{form:n,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(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:E=>E,children:e.jsx(Z,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Syllabus List"}),children:e.jsx(s.Table,{rowKey:E=>E.id,columns:N,dataSource:D,loading:I,pagination:{current:r.page,pageSize:r.perPage,total:w,showSizeChanger:!0,onChange:(E,F)=>o({page:E,perPage:F})}})})]})}function Iy({token:t}){return e.jsx(Ry,{token:t})}const Ua=we.timetable,vi=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[]},_i=t=>{if(!t)return"";const n=ae(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},Dy=t=>{const n=String(t).trim().toLowerCase();if(!n)return"default";let a=0;for(let o=0;o<n.length;o+=1)a=(a*31+n.charCodeAt(o))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[a%r.length]},wi=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],ky=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"};function Oy({token:t}){const[n,a]=i.useState(null),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,b]=i.useState(""),[y,u]=i.useState(""),{data:x}=G(t?[we.master.classes.dropdown,t]:null,([p,S])=>Q(p,S)),j=i.useMemo(()=>vi(x),[x]),{data:C}=G(t&&n?[n,t]:null,([p,S])=>Q(p,S)),m=i.useMemo(()=>vi(C),[C]),{data:h,isLoading:g}=G(t&&l?[l,t]:null,([p,S])=>Q(p,S),{revalidateOnFocus:!1}),I=i.useMemo(()=>h?.days??h?.data?.days??h?.data?.data?.days??{},[h]),{dataSource:R,daySpanByFirstKey:D}=i.useMemo(()=>{const p=Object.entries(I||{}).slice().sort((O,q)=>wi.indexOf(String(O[0]).toLowerCase())-wi.indexOf(String(q[0]).toLowerCase())),S=new Map,A=[];for(const[O,q]of p){const U=(Array.isArray(q)?q:[]).slice().sort((M,P)=>Number(M?.order_no||0)-Number(P?.order_no||0)),v=U.length;for(let M=0;M<v;M+=1){const P=U[M],N=P?.id||`${O}-${P?.order_no}-${M}`;M===0&&S.set(N,v),A.push({key:N,_dayKey:O,...P})}}return{dataSource:A,daySpanByFirstKey:S}},[I]),w=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(p,S)=>{const A=D.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(X.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(s.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:ky(p)})]}),props:{rowSpan:A}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:p=>e.jsx(s.Tag,{color:"#5080f8",style:{fontWeight:500},children:p})},{title:"Time",key:"time",width:180,render:(p,S)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(s.Typography.Text,{children:[_i(S?.time_from)," - ",_i(S?.time_to)]})]})},{title:"Subject",key:"subject",render:(p,S)=>{if(String(S?.is_break)==="1")return e.jsx(s.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const O=S?.subject_name||"-";return e.jsx(s.Tag,{color:Dy(O),style:{fontWeight:500},children:O})}},{title:"Teacher",key:"teacher",render:(p,S)=>{const A=String(S?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.UserOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(s.Typography.Text,{children:A?"-":S?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(p,S)=>{const A=String(S?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(s.Typography.Text,{children:A?"-":S?.room_no||"-"})]})}}],[D]),f=p=>{p.preventDefault();const S=p.target.class_id?.value,A=p.target.section_id?.value;if(!S||!A)return;const O=j.find(M=>String(M.value)===String(S)),q=m.find(M=>String(M.value)===String(A));b(O?.label||""),u(q?.label||"");const v=`${Ua.byClassSection}/${S}/section/${A}`;d(v)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Class / Section Wise Timetable"}),extra:e.jsx(Ft,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:f,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:p=>{a(`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(p?.value??""))}`),o(S=>!S)}}),e.jsx(Z,{options:m,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(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:c||y?`Timetable: ${c} ${y}`:"Timetable"}),children:e.jsx(s.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:R,columns:w,rowKey:"key",loading:g,scroll:{x:"max-content"}})})]})}const Py=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[]},Ci=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Ey=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"},Ai=t=>{if(!t)return"";const n=ae(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},My=t=>{const n=String(t).trim().toLowerCase();if(!n)return"default";let a=0;for(let o=0;o<n.length;o+=1)a=(a*31+n.charCodeAt(o))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[a%r.length]};function Fy({token:t}){const[n,a]=i.useState(null),[r,o]=i.useState(null),{data:l}=G(t?[we.assignByClass.teacherDropdown,t]:null,([C,m])=>Q(C,m)),d=i.useMemo(()=>Py(l),[l]),{data:c,isLoading:b}=G(t&&r?[r,t]:null,([C,m])=>Q(C,m),{revalidateOnFocus:!1}),{dataSource:y,daySpanByFirstKey:u}=i.useMemo(()=>{const m=(Array.isArray(c?.data)&&c.data||Array.isArray(c?.data?.data)&&c.data.data||[]).slice().sort((R,D)=>{const w=Ci.indexOf(String(R?.day_name||"").toLowerCase()),f=Ci.indexOf(String(D?.day_name||"").toLowerCase());if(w!==f)return w-f;const p=Number(R?.order_no||0),S=Number(D?.order_no||0);return p!==S?p-S:String(R?.time_from||"").localeCompare(String(D?.time_from||""))}),h=new Map,g=[];let I=0;for(;I<m.length;){const R=String(m[I]?.day_name||"").toLowerCase();let D=I;for(;D<m.length&&String(m[D]?.day_name||"").toLowerCase()===R;)D+=1;const w=D-I;for(let f=I;f<D;f+=1){const p=m[f],S=p?.id||`${R}-${p?.order_no}-${f}`;f===I&&h.set(S,w),g.push({key:S,_dayKey:R,...p})}I=D}return{dataSource:g,daySpanByFirstKey:h}},[c]),x=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(C,m)=>{const h=u.get(m.key);return h===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(X.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(s.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:Ey(C)})]}),props:{rowSpan:h}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:C=>e.jsx(s.Tag,{color:"#5080f8",style:{fontWeight:500},children:C})},{title:"Time",key:"time",width:180,render:(C,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(s.Typography.Text,{children:[Ai(m?.time_from)," - ",Ai(m?.time_to)]})]})},{title:"Subject",key:"subject",render:(C,m)=>{if(String(m?.is_break)==="1")return e.jsx(s.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const g=m?.subject_name||"-";return e.jsx(s.Tag,{color:My(g),style:{fontWeight:500},children:g})}},{title:"Class",key:"class",width:160,render:(C,m)=>e.jsxs(s.Tag,{color:"purple",style:{fontWeight:500},children:[m?.class_name||m?.class_id||"-"," ",m?.section_name?`(${m.section_name})`:""]})},{title:"Room",key:"room_no",width:120,render:(C,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(X.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(s.Typography.Text,{children:m?.room_no||"-"})]})}],[u]),j=C=>{C.preventDefault();const m=C.target.teacher_id?.value;if(!m)return;a(m);const g=`${Ua.teacherTimetable}${encodeURIComponent(String(m))}`;o(g)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Teacher Wise Timetable"}),extra:e.jsx(Ft,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),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(Z,{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(de,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Timetable"}),children:e.jsx(s.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:y,columns:x,rowKey:"key",loading:b,scroll:{x:"max-content"}})})]})}function Ti(t){if(!t)return null;const n=String(t).trim().replaceAll(".",":");if(!n)return null;const a=n.toLowerCase(),r=a.includes("am")||a.includes("pm");let o=0,l=0,d=0;if(r){const b=a.replace(/\s+/g," ").match(/^(\d{1,2})\s*:\s*(\d{1,2})(?:\s*:\s*(\d{1,2}))?\s*(am|pm)$/i);if(!b)return null;o=Number.parseInt(b[1],10),l=Number.parseInt(b[2],10),d=Number.parseInt(b[3]||"0",10);const y=b[4].toLowerCase();y==="pm"&&o<12&&(o+=12),y==="am"&&o===12&&(o=0)}else{const c=n.split(":").map(b=>b.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 wn(t,n){const a=Number.parseInt(n,10);return!Number.isFinite(a)||a<=0||!t||!t.isValid?.()?null:t.add(a,"minute")}const va=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[]},In={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},Ny=t=>{const n=In[String(t)];return n?n.charAt(0).toUpperCase()+n.slice(1):String(t)},$y=({token:t,classId:n,sectionId:a,subjectId:r,value:o,onChange:l,disabled:d})=>{const c=t&&n&&a&&r?`${Ua.teachersBySubject}?subject_id=${encodeURIComponent(String(r))}&class_id=${encodeURIComponent(String(n))}§ion_id=${encodeURIComponent(String(a))}`:null,{data:b,isLoading:y}=G(c?[c,t]:null,([x,j])=>Q(x,j),{revalidateOnFocus:!1}),u=i.useMemo(()=>va(b?.data??b).map(j=>({value:j?.value??j?.id,label:j?.label??j?.name??j?.teacher_name??""})),[b]);return e.jsx(s.Select,{placeholder:d?"-":"Select Teacher",loading:y,disabled:d,style:{width:"100%"},options:u,value:o?String(o):void 0,onChange:x=>l?.(x),showSearch:!0,optionFilterProp:"label"})};function Uy({token:t}){const[n]=s.Form.useForm(),[a,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:[]}),[b,y]=i.useState(!1),u=i.useMemo(()=>t?we.master.classes.dropdown:null,[t]),{data:x}=G(u?[u,t]:null,([v,M])=>Q(v,M)),j=i.useMemo(()=>va(x).map(v=>({value:v?.value??v?.id,label:v?.label??v?.title??""})),[x]),C=i.useMemo(()=>!t||!a.classId?null:`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(a.classId))}`,[a.classId,t]),{data:m}=G(C?[C,t]:null,([v,M])=>Q(v,M)),h=i.useMemo(()=>va(m).map(v=>({value:v?.value??v?.id,label:v?.label??v?.title??""})),[m]),g=i.useMemo(()=>!t||!a.classId?null:`${we.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(a.classId))}`,[a.classId,t]),{data:I}=G(g?[g,t]:null,([v,M])=>Q(v,M)),R=i.useMemo(()=>va(I).map(v=>({value:v?.value??v?.id,label:v?.label??v?.title??""})),[I]),D=i.useMemo(()=>Array.isArray(d?.[a.dayKey])?d[a.dayKey]:[],[a.dayKey,d]),w=i.useCallback((v,M,P)=>{c(N=>{const E={...N},F=Array.isArray(E[v])?E[v].slice():[];return F[M]={...F[M]??{},...P},E[v]=F,E})},[]),f=i.useCallback((v,M)=>{c(P=>{const N={...P},E=Array.isArray(N[v])?N[v].slice():[];return E.splice(M,1),N[v]=E.map((F,L)=>({...F,order_no:L+1})),N})},[]),p=i.useCallback(v=>{c(M=>{const P={...M},N=Array.isArray(P[v])?P[v].slice():[];let E=null,F=null;const L=N[N.length-1];if(L?.time_to){const z=Ti(L.time_to),k=Number.parseInt(o.interval,10)||0,T=Number.parseInt(o.duration,10)||0,$=wn(z,k),B=T>0?wn($,T):null;E=$?.isValid?.()?$.format("HH:mm:ss"):null,F=B?.isValid?.()?B.format("HH:mm:ss"):null}return N.push({order_no:N.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:E,time_to:F,is_break:!1}),P[v]=N,P})},[o.duration,o.interval,o.roomNo]),S=i.useCallback(()=>{const v=o.startTime,M=o.endTime,P=Number.parseInt(o.duration,10),N=Number.parseInt(o.interval,10);if(!v||!v.isValid?.()){_.error("Start time is required",{duration:1500});return}if(!M||!M.isValid?.()){_.error("End time is required",{duration:1500});return}if(!M.isAfter(v)){_.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(P)||P<=0){_.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite(N)||N<0){_.error("Interval must be 0 or more",{duration:1500});return}const E=()=>{const F=[];let L=v;for(let z=0;z<50;z+=1){const k=wn(L,P);if(!k||!k.isValid?.()||k.isAfter(M))break;F.push({order_no:F.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:L.format("HH:mm:ss"),time_to:k.format("HH:mm:ss"),is_break:!1});const T=wn(k,N);if(!T||!T.isValid?.()||T.isAfter(M)||T.isSame(M))break;L=T}if(o.tiffinEnabled){const z=Math.max(0,Number.parseInt(o.tiffinAfterPeriod,10)||0),k=Math.max(0,Number.parseInt(o.tiffinDuration,10)||0),T=Math.min(z,F.length);if(T>0&&k>0){const $=F[T-1],B=$?.time_to?Ti($.time_to):null,Y=B?wn(B,k):null;B?.isValid?.()&&Y?.isValid?.()&&!Y.isAfter(M)&&F.splice(T,0,{order_no:T+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:B.format("HH:mm:ss"),time_to:Y.format("HH:mm:ss"),is_break:!0})}}return F.map((z,k)=>({...z,order_no:k+1}))};c(F=>{const L={...F};return Object.keys(In).forEach(z=>{a.daysEnabled?.[z]&&(L[z]=E())}),L}),_.success("Generated schedule",{duration:1e3})},[o,a.daysEnabled]),A=i.useCallback(()=>{const v=localStorage.getItem("genrall_settings"),P=(v?JSON.parse(v):{})?.session_id??"1",N=a.classId,E=a.sectionId,F=Object.keys(In).map(L=>{const z=(Array.isArray(d?.[L])?d[L]:[]).map((k,T)=>({order_no:T+1,subject_id:k?.is_break?0:k?.subject_id??null,teacher_id:k?.is_break?0:k?.teacher_id??null,room_no:k?.room_no??"",time_from:k?.time_from??null,time_to:k?.time_to??null,is_break:k?.is_break?1:0}));return{day:In[L],class_id:N,section_id:E,session_id:P,args:z}});return{class_id:N,section_id:E,session_id:P,days:F}},[a.classId,a.sectionId,d]),O=i.useCallback(async()=>{if(!a.classId||!a.sectionId){_.error("Please select Class and Section",{duration:1500});return}const v=A(),M=Array.isArray(v?.days)?v.days:[];if(!M.some(E=>Array.isArray(E?.args)&&E.args.length>0)){_.error("No timetable rows to submit",{duration:1500});return}const N=E=>{const F=E?.is_break;return F===1||F==="1"||F===!0?!0:String(F??"").toLowerCase()==="true"};M.some(E=>(Array.isArray(E?.args)?E.args:[]).some(F=>String(F?.time_from??"").trim()&&String(F?.time_to??"").trim()?N(F)?!1:!String(F?.subject_id??"").trim()||!String(F?.teacher_id??"").trim():!0)),y(!0);try{const E=Ua.save,F=E==="api/timetable/save"?"timetable/save":null,L=async T=>{const $=await Oa(T,v,t);if($&&typeof $=="object")return $;throw new Error("No response from server")};let z;try{z=await L(E)}catch{z=await L(F)}const k=String(z?.msg??"");if(String(z?.Status)==="Success"){if(Array.isArray(z?.data)&&z.data.length===0&&k){_.error(k,{duration:3e3});return}_.success(k||"Weekly Time Table added successfully!",{duration:1200});return}_.error(k||"Failed to add time table",{duration:3e3})}catch(E){_.error(E?.response?.data?.msg??E?.message??"Failed to add time table",{duration:3e3})}finally{y(!1)}},[A,a.classId,a.sectionId,t]),q=i.useMemo(()=>[{title:"Period",dataIndex:"order_no",key:"order_no",width:80},{title:"Time From",dataIndex:"time_from",key:"time_from",width:120,render:v=>v?ae(v,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:v=>v?ae(v,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(v,M,P)=>e.jsx(s.Switch,{checked:!!M?.is_break,onChange:N=>{w(a.dayKey,P,{is_break:N,subject_id:N?"":M?.subject_id??"",teacher_id:N?"":M?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(v,M,P)=>e.jsx(s.Select,{placeholder:M?.is_break?"-":"Select Subject",disabled:!!M?.is_break,style:{width:"100%"},options:R,value:M?.subject_id?String(M.subject_id):void 0,onChange:N=>w(a.dayKey,P,{subject_id:N,teacher_id:""}),showSearch:!0,optionFilterProp:"label"})},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(v,M,P)=>e.jsx($y,{token:t,classId:a.classId,sectionId:a.sectionId,subjectId:M?.subject_id,disabled:!!M?.is_break||!M?.subject_id,value:M?.teacher_id,onChange:N=>w(a.dayKey,P,{teacher_id:N})})},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(v,M,P)=>e.jsx(s.Input,{value:M?.room_no??"",onChange:N=>w(a.dayKey,P,{room_no:N.target.value})})},{title:"Action",key:"action",width:90,render:(v,M,P)=>e.jsx(s.Popconfirm,{title:"Delete this row?",onConfirm:()=>f(a.dayKey,P),children:e.jsx(s.Button,{danger:!0,type:"text",children:"Delete"})})}],[a.classId,a.dayKey,a.sectionId,f,R,t,w]),U=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Create Time Table"}),children:e.jsx(s.Form,{form:n,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(s.Form.Item,{label:"Class",required:!0,children:e.jsx(s.Select,{placeholder:"Select Class",options:j,value:a.classId?String(a.classId):void 0,onChange:v=>{r(M=>({...M,classId:v,sectionId:null})),c({0:[],1:[],2:[],3:[],4:[],5:[],6:[]})},showSearch:!0,optionFilterProp:"label"})}),e.jsx(s.Form.Item,{label:"Section",required:!0,children:e.jsx(s.Select,{placeholder:"Select Section",options:h,value:a.sectionId?String(a.sectionId):void 0,onChange:v=>r(M=>({...M,sectionId:v})),disabled:!a.classId,showSearch:!0,optionFilterProp:"label"})}),e.jsx(s.Form.Item,{label:"Start Time",required:!0,children:e.jsx(s.TimePicker,{value:o.startTime,onChange:v=>l(M=>({...M,startTime:v})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"End Time",required:!0,children:e.jsx(s.TimePicker,{value:o.endTime,onChange:v=>l(M=>({...M,endTime:v})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"Duration (min)",required:!0,children:e.jsx(s.InputNumber,{min:1,value:o.duration,onChange:v=>l(M=>({...M,duration:v})),style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"Interval (min)",children:e.jsx(s.InputNumber,{min:0,value:o.interval,onChange:v=>l(M=>({...M,interval:v})),style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"Room No",children:e.jsx(s.Input,{value:o.roomNo,onChange:v=>l(M=>({...M,roomNo:v.target.value}))})}),e.jsx(s.Form.Item,{label:"Tiffin Break",children:e.jsxs(s.Space,{children:[e.jsx(s.Switch,{checked:o.tiffinEnabled,onChange:v=>l(M=>({...M,tiffinEnabled:v}))}),e.jsx(s.Typography.Text,{type:"secondary",children:o.tiffinEnabled?"Enabled":"Disabled"})]})}),e.jsx(s.Form.Item,{label:"After Period",tooltip:"Insert break row after this period",style:{marginBottom:0},children:e.jsx(s.InputNumber,{min:1,value:o.tiffinAfterPeriod,onChange:v=>l(M=>({...M,tiffinAfterPeriod:v})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsx(s.Form.Item,{label:"Break Duration (min)",style:{marginBottom:0},children:e.jsx(s.InputNumber,{min:1,value:o.tiffinDuration,onChange:v=>l(M=>({...M,tiffinDuration:v})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(s.Button,{onClick:S,children:"Generate"}),e.jsx(s.Button,{type:"primary",loading:b,onClick:O,children:"Save"})]})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Edit Week"}),extra:e.jsxs(s.Space,{children:[e.jsx(s.Typography.Text,{type:"secondary",children:"Day"}),e.jsx(s.Select,{style:{width:160},value:a.dayKey,onChange:v=>r(M=>({...M,dayKey:v})),options:Object.keys(In).map(v=>({value:String(v),label:Ny(v)}))}),e.jsx(s.Button,{onClick:()=>p(a.dayKey),children:"Add Row"})]}),children:e.jsx(s.Table,{rowKey:(v,M)=>`${a.dayKey}_${M}`,columns:q,dataSource:D,pagination:!1,size:"middle",scroll:{x:"max-content"}})})]});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(s.Typography.Title,{level:4,style:{margin:0},children:"Time Table"}),e.jsx(s.Tabs,{type:"card",items:[{key:"create",label:"Create",children:U},{key:"routine",label:"Routine",children:e.jsx(Oy,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(Fy,{token:t})}]})]})}function By({token:t}){return e.jsx(Uy,{token:t})}function Ly(){return null}const Yt=t=>t??localStorage.getItem("authToken")??"",Ls=(t,n)=>{const a=String(t??""),r=String(n??"");return a?r?a.endsWith("/")&&r.startsWith("/")?`${a}${r.slice(1)}`:!a.endsWith("/")&&!r.startsWith("/")?`${a}/${r}`:`${a}${r}`:a:r},it={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"}},qs=t=>Ls(nt(),t),qy=()=>Ls(nt(),"uploads"),Ao=t=>Ls(qy(),t),zy=async({baseUrl:t,page:n=1,perPage:a=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(n))}&per_page=${encodeURIComponent(String(a))}`;return Q(l,Yt(r))},Yy=async(t,n)=>Q(t,Yt(n)),zn=async(t,n,a)=>Ye(t,n,Yt(a)),To=async(t,n,a)=>ut(t,n,Yt(a)),zs=async(t,n,a)=>at(t,n,Yt(a)),Wy=async(t,n,a)=>Oa(t,{arg:n},Yt(a)),Ro=async(t,n,a)=>Dn(t,{arg:n},Yt(a)),Io=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,b])=>zy({baseUrl:l,page:d,perPage:c},b)),lt=({url:t,token:n})=>G(n&&t?[t,n]:null,([r,o])=>Yy(r,o)),Vy={border:"1px solid #d9d9d9",borderRadius:8,padding:12,minHeight:320,background:"#fff"};function Hy({value:t,onChange:n,placeholder:a}){const[r,o]=i.useState(t??""),l=i.useMemo(()=>typeof t=="string"?t:r,[r,t]);return e.jsx("div",{style:Vy,children:e.jsx(lo,{html:l||"",onChange:d=>{const c=d?.target?.value??"";o(c),n?.(c)},style:{outline:"none",minHeight:280},placeholder:a})})}function Nt({title:t,actions:n,children:a,headerExtra:r}){return e.jsx("div",{style:{display:"grid",gap:20},children:a})}const Ky=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 Ys({token:t,title:n,fetchUrl:a,saveUrl:r,fieldName:o,initialHtmlFieldName:l}){const d=i.useRef(null),c=lt({url:a,token:t}),y=i.useMemo(()=>Ky(c.data),[c.data])?.[l??o]??"",[u,x]=i.useState("");i.useEffect(()=>{x(typeof y=="string"?y:"")},[y]);const j=()=>x(typeof y=="string"?y:""),C=()=>{const g=new Blob([String(u??"")],{type:"text/html"}),I=URL.createObjectURL(g),R=document.createElement("a");R.href=I,R.download=`${String(n??"legal").toLowerCase().replaceAll(" ","-")}.html`,R.click(),URL.revokeObjectURL(I)},m=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:j},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:C,disabled:!u}],[u,y]),h=async g=>{g.preventDefault();try{(await Ro(r,{[o]:u??""},t))?.Status==="Success"?_.success("Updated successfully.",{duration:1e3}):_.success("Updated.",{duration:1e3}),c.mutate?.()}catch(I){_.error(I?.response?.data?.msg??I?.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(Nt,{title:n,actions:m,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Editor"}),children:e.jsxs("form",{ref:d,onSubmit:h,children:[e.jsx(Hy,{value:u,onChange:x,placeholder:`Enter ${n} content...`}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Update"})})]})})})]})}const Gy=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Jy=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:");function nn({token:t,value:n,onChange:a,action:r,accept:o,maxCount:l=1,previewUrl:d}){const c=i.useMemo(()=>{if(t)return{Authorization:t}},[t]),b=i.useMemo(()=>n?d||(Jy(n)?n:""):"",[d,n]);return e.jsxs("div",{style:{display:"grid",gap:8},children:[b?e.jsx("img",{src:b,alt:"upload-preview",style:{width:88,height:88,objectFit:"cover",borderRadius:8,border:"1px solid #d9d9d9",background:"#fafafa"}}):null,e.jsx(s.Upload,{maxCount:l,action:r,accept:o,headers:c,onChange:y=>{if(y?.file?.status==="removed"&&a?.(""),y?.file?.status==="done"){const u=Gy(y?.file?.response);u&&a?.(u)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})]})}const wt=it.organization,Do=()=>qs(wt.uploadLogo),ms=()=>qs(wt.uploadSignature),Qy=()=>qs(wt.uploadFirebaseJson),Xy=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:[]:[],Zy=({token:t})=>lt({url:wt.get,token:t}),ef=({token:t})=>lt({url:wt.currencyDropdown,token:t}),tf=({token:t})=>lt({url:wt.countryCodeDropdown,token:t}),nf=({token:t})=>lt({url:wt.timezoneDropdown,token:t}),af=({token:t})=>lt({url:wt.boardsDropdown,token:t}),oa=t=>Xy(t?.data),Ri={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},sf=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].map(t=>({value:t,label:t})),Ii=[{value:"Yes",label:"Yes"},{value:"No",label:"No"}],Di=[{value:"yes",label:"Yes"},{value:"no",label:"No"}],rf=t=>{const n=t?.data;return Array.isArray(n?.data)?n.data[0]??null:Array.isArray(n)?n[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null},of=t=>t?.data?.inout_setting?.[0]??t?.inout_setting?.[0]??null,lf=t=>t?.data?.notification_settings?.[0]??t?.notification_settings?.[0]??null;function df({token:t}){const n=i.useRef(null),a=Zy({token:t}),r=ef({token:t}),o=tf({token:t}),l=nf({token:t}),d=af({token:t}),c=i.useMemo(()=>rf(a.data),[a.data]),b=i.useMemo(()=>of(a.data),[a.data]),y=i.useMemo(()=>lf(a.data),[a.data]),u=i.useMemo(()=>oa(r),[r.data]),x=i.useMemo(()=>oa(o),[o.data]),j=i.useMemo(()=>oa(l),[l.data]),C=i.useMemo(()=>oa(d),[d.data]),[m,h]=i.useState(null),[g,I]=i.useState(null),[R,D]=i.useState(null),[w,f]=i.useState(null),[p,S]=i.useState([]),[A,O]=i.useState("No"),[q,U]=i.useState("yes"),[v,M]=i.useState("no"),[P,N]=i.useState("Yes"),[E,F]=i.useState(""),[L,z]=i.useState(""),[k,T]=i.useState(null),[$,B]=i.useState(null),[Y,ne]=i.useState(null),[H,W]=i.useState(null),ee=()=>{const V=(()=>{try{const oe=c?.weekly_off;if(!oe)return[];const Ce=Array.isArray(oe)?oe:JSON.parse(oe);return Array.isArray(Ce)?Ce.filter(Boolean).map(Oe=>({value:Oe,label:Oe})):[]}catch{return[]}})();S(V),h(u.find(oe=>oe?.value===c?.currency)??null),I(x.find(oe=>oe?.value===c?.country_code)??null),D(j.find(oe=>oe?.value===c?.time_zone)??null),f(C.find(oe=>oe?.value===c?.affliated_board_id)??null),F(c?.logo??""),z(c?.json_file??""),O(c?.attendance_salary_calculation??"No"),U(c?.salary_period??"yes"),M(c?.multiple_shift??"no"),N(c?.readmission_charges??"Yes"),T(b?.in_from?ae(b.in_from,"h:mm A"):null),B(b?.in_to?ae(b.in_to,"h:mm A"):null),ne(b?.out_from?ae(b.out_from,"h:mm A"):null),W(b?.out_to?ae(b.out_to,"h:mm A"):null)};i.useEffect(()=>{c&&ee()},[c,u,x,j,C]);const se=()=>{n.current?.reset?.(),ee()},me=()=>{const V=new FormData(n.current??void 0),oe=Object.fromEntries(V.entries());oe.weekly_off_day=p.map(Fe=>Fe?.value).filter(Boolean);const Ce=new Blob([JSON.stringify(oe,null,2)],{type:"application/json"}),Oe=URL.createObjectURL(Ce),Pe=document.createElement("a");Pe.href=Oe,Pe.download="organization-setting.json",Pe.click(),URL.revokeObjectURL(Oe)},ve=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:se},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:me,disabled:!c}],[c,p]),re=async V=>{V.preventDefault();try{const oe=new FormData(V.target);oe.set("currency",m?.value??""),oe.set("code",g?.value??""),oe.set("time_zone",R?.value??""),oe.set("affliated_board_id",w?.value??""),oe.set("board_name",w?.label??""),oe.set("attendance_salary_calculation",A),oe.set("salary_period",q),oe.set("multiple_shift",v),oe.set("readmission_charges",P),p.forEach(Pe=>{Pe?.value&&oe.append("weekly_off_day[]",Pe.value)}),oe.set("logo",E??""),oe.set("json_file",L??""),oe.set("server_key",y?.server_key??""),oe.set("in_time_start",k?ae(k).format("h:mm A"):""),oe.set("in_time_end",$?ae($).format("h:mm A"):""),oe.set("out_time_start",Y?ae(Y).format("h:mm A"):""),oe.set("out_time_end",H?ae(H).format("h:mm A"):""),await zn(wt.save,oe,t);const Oe={...JSON.parse(localStorage.getItem("genrall_settings")??"null")??{},logo:E||c?.logo||"",affliated_board_id:w?.value??c?.affliated_board_id??"",board_name:w?.label??c?.board_name??"",multiple_shift:v??c?.multiple_shift??""};localStorage.setItem("genrall_settings",JSON.stringify(Oe)),_.success("Organization settings saved.",{duration:1e3}),a.mutate?.()}catch(oe){_.error(oe?.response?.data?.msg??oe?.message??"Failed to save settings.",{duration:1500})}},ie=A==="Yes";return a.isLoading&&!a.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Nt,{title:"Organization",actions:ve,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Organization Details"}),children:e.jsxs("form",{ref:n,onSubmit:re,children:[e.jsxs("div",{style:Ri,children:[e.jsx(J,{type:"text",name:"name",label:"Organization Name*",required:!0,defaultValue:c?.name??""}),e.jsxs("div",{children:[e.jsx(Z,{label:"Currency*",options:u,value:m,onChange:V=>h(V)}),e.jsx("input",{type:"hidden",name:"currency",value:m?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Default Country Code*",options:x,value:g,onChange:V=>I(V)}),e.jsx("input",{type:"hidden",name:"code",value:g?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Time Zone*",options:j,value:R,onChange:V=>D(V)}),e.jsx("input",{type:"hidden",name:"time_zone",value:R?.value??""})]}),e.jsx(J,{type:"text",name:"admission_prefix",label:"Receipt Prefix*",required:!0,defaultValue:c?.admission_prefix??""}),e.jsx(J,{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(s.Radio.Group,{options:Ii,optionType:"button",buttonStyle:"solid",value:P,onChange:V=>N(V.target.value)}),e.jsx("input",{type:"hidden",name:"readmission_charges",value:P})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Weekly off Day",options:sf,isMulti:!0,value:p,onChange:V=>S(V??[])}),p.map(V=>e.jsx("input",{type:"hidden",name:"weekly_off_day[]",value:V.value},V.value))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time Start*"}),e.jsx(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:k,onChange:V=>T(V),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_start",value:k?ae(k).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(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:$,onChange:V=>B(V),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_end",value:$?ae($).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(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:Y,onChange:V=>ne(V),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_start",value:Y?ae(Y).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(s.TimePicker,{use12Hours:!0,format:"h:mm A",value:H,onChange:V=>W(V),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_end",value:H?ae(H).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(s.Radio.Group,{options:Di,optionType:"button",buttonStyle:"solid",value:q,onChange:V=>U(V.target.value)}),e.jsx("input",{type:"hidden",name:"salary_period",value:q})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Deduction"}),e.jsx(s.Radio.Group,{options:Ii,optionType:"button",buttonStyle:"solid",value:A,onChange:V=>O(V.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(s.Radio.Group,{options:Di,optionType:"button",buttonStyle:"solid",value:v,onChange:V=>M(V.target.value)}),e.jsx("input",{type:"hidden",name:"multiple_shift",value:v})]}),ie?e.jsx(J,{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(s.Divider,{}),e.jsxs("div",{style:Ri,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Logo Upload"}),e.jsx(nn,{token:t,action:Do(),value:E,accept:"image/*",onChange:V=>F(V)}),e.jsx("input",{type:"hidden",name:"logo",value:E??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Select Affiliated Board",options:C,value:w,onChange:V=>f(V)}),e.jsx("input",{type:"hidden",name:"affliated_board_id",value:w?.value??""}),e.jsx("input",{type:"hidden",name:"board_name",value:w?.label??""})]}),e.jsx(Dt,{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(nn,{token:t,action:Qy(),value:L,accept:".json",onChange:V=>z(V)}),e.jsx("input",{type:"hidden",name:"json_file",value:L??""})]})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save",color:"primary"})})]})})})]})}function cf({token:t}){return e.jsx(df,{token:t})}const _a=it.academicYear,uf=({token:t,page:n=1,perPage:a=10})=>Io({baseUrl:_a.table,token:t,page:n,perPage:a}),pf={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},mf=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:[],yf=(t,n=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??n;function ff({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(()=>{const p=ae(),S=ae().add(1,"year");return`${p.format("YYYY")}-${S.format("YYYY")}`}),[c,b]=i.useState(ae()),[y,u]=i.useState(ae().add(1,"year")),{isLoading:x,data:j,mutate:C}=uf({token:t,page:n.page,perPage:n.rowsPerPage}),m=i.useMemo(()=>mf(j),[j]),h=i.useMemo(()=>yf(j,m.length),[j,m.length]),g=async()=>{if(!l){_.error("Session name is required.");return}if(y&&c&&ae(y).isBefore(c)){_.error("End date must be after start date.");return}try{const p=new FormData;p.set("name",l),p.set("start_date",c?ae(c).format("YYYY-MM-DD"):""),p.set("end_date",y?ae(y).format("YYYY-MM-DD"):""),await zn(_a.add,p,t),_.success("Academic year added.",{duration:1e3}),o(!1),C?.()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to add academic year.",{duration:1500})}},I=async p=>{try{const S=new FormData;S.set("session",String(p)),await To(_a.setActive,S,t);const A=JSON.parse(localStorage.getItem("genrall_settings")??"null")??{};localStorage.setItem("genrall_settings",JSON.stringify({...A,session_id:String(p)})),_.success("Academic year activated.",{duration:1e3}),C?.()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to activate academic year.",{duration:1500})}},R=async p=>{try{await C(zs(_a.remove,p,t)),_.success("Academic year deleted.",{duration:1e3})}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to delete academic year.",{duration:1500})}},D=()=>{const p=new Blob([JSON.stringify(m,null,2)],{type:"application/json"}),S=URL.createObjectURL(p),A=document.createElement("a");A.href=S,A.download="academic-years.json",A.click(),URL.revokeObjectURL(S)},w=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(X.PlusOutlined,{}),onClick:()=>o(!0)},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:()=>C?.()},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:D,disabled:m.length===0}],[m.length,C]),f=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:(p,S)=>{const A=S.status==="Active";return e.jsxs("span",{children:[e.jsx(s.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?_.error("Deactivate is not allowed. Activate another session to switch."):I(S.id)},okText:"Yes",cancelText:"No",children:e.jsx(s.Switch,{checked:A})}),A&&e.jsx(s.Tag,{color:"green",style:{marginLeft:8},children:"Active"})]})}},{title:"Action",key:"action",render:(p,S)=>e.jsx(s.Popconfirm,{title:"Delete academic year?",description:"This will remove the session.",onConfirm:()=>R(S.id),okText:"Yes",cancelText:"No",children:e.jsx(s.Button,{type:"link",danger:!0,children:"Delete"})})}],[t,m.length]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Nt,{title:"Academic Year",actions:w,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Sessions"}),children:e.jsx(s.Table,{rowKey:"id",dataSource:m,columns:f,loading:x,pagination:{current:n.page,pageSize:n.rowsPerPage,total:h,showSizeChanger:!0,onChange:(p,S)=>a({page:p,rowsPerPage:Number(S)})}})})}),e.jsx(s.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:pf,children:[e.jsx(J,{label:"Session Name*",value:l,onChange:p=>d(p.target.value)}),e.jsxs("div",{children:[e.jsx(gt,{Desplay:"Start Date*",value:c,onChange:p=>b(p),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:c?ae(c).format("YYYY-MM-DD"):""})]}),e.jsxs("div",{children:[e.jsx(gt,{Desplay:"End Date*",value:y,onChange:p=>u(p),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:y?ae(y).format("YYYY-MM-DD"):""})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(de,{value:"Submit",type:"button",onClick:g}),e.jsx(s.Button,{onClick:()=>o(!1),children:"Cancel"})]})]})})]})}function hf({token:t}){return e.jsx(ff,{token:t})}const ko=it.feeReceiptSetting,gf=({token:t})=>lt({url:ko.get,token:t}),ys={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:16,alignItems:"start"},xf=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 bf({token:t}){const n=i.useRef(null),a=gf({token:t}),r=i.useMemo(()=>xf(a.data),[a.data]),[o,l]=i.useState(""),[d,c]=i.useState(!1),[b,y]=i.useState(!1),[u,x]=i.useState(!1),[j,C]=i.useState("0"),[m,h]=i.useState("0"),[g,I]=i.useState("0"),[R,D]=i.useState(!1),[w,f]=i.useState(!1),[p,S]=i.useState(""),[A,O]=i.useState(!1),q=()=>{l(r?.number_of_receipt??""),c(String(r?.roll_number??"0")==="1"),y(String(r?.address??"0")==="1"),x(String(r?.gardian_name??"0")==="1"),C(String(r?.authorized_signatory??"0")),h(String(r?.parent_signatory??"0")),I(String(r?.dynamic_qr_code_device??"0")),D(String(r?.sequence_payment??"0")==="1"),f(String(r?.previois_fees??"0")==="1"),S(r?.upfront_payment_months??"")};i.useEffect(()=>{r&&q()},[r]);const U=()=>{n.current?.reset?.(),q()},v=()=>{const N={number_of_receipt:o,rollnumber:d?1:0,address:b?1:0,gardianname:u?1:0,authorizedsignatory:j,parentsignatory:m,dynamic_qr_code_device:g,sequence_payment:R?1:0,previois_fees:w?1:0,upfront_payment_months:p},E=new Blob([JSON.stringify(N,null,2)],{type:"application/json"}),F=URL.createObjectURL(E),L=document.createElement("a");L.href=F,L.download="fee-receipt-setting.json",L.click(),URL.revokeObjectURL(F)},M=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:U},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:v,disabled:!r}],[r,o,d,b,u,j,m,g,R,w,p]),P=async N=>{N.preventDefault(),O(!0);try{const E=new FormData;E.set("number_of_receipt",String(o??"")),E.set("rollnumber",d?"1":"0"),E.set("address",b?"1":"0"),E.set("gardianname",u?"1":"0"),E.set("authorizedsignatory",String(j??"0")),E.set("parentsignatory",String(m??"0")),E.set("dynamic_qr_code_device",String(g??"0")),E.set("sequence_payment",R?"1":"0"),E.set("previois_fees",w?"1":"0"),E.set("upfront_payment_months",String(p??"")),await zn(ko.save,E,t),_.success("Fee receipt settings updated.",{duration:1e3}),a.mutate?.()}catch(E){_.error(E?.response?.data?.msg??E?.message??"Failed to update settings.",{duration:1500})}finally{O(!1)}};return a.isLoading&&!a.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Nt,{title:"Fee Receipt Setting",actions:M,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Settings Form"}),children:e.jsxs("form",{ref:n,onSubmit:P,children:[e.jsxs("div",{style:ys,children:[e.jsx(J,{type:"number",name:"number_of_receipt",label:"Number Of Receipt",value:o,onChange:N=>l(N.target.value)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Roll Number"}),e.jsx(s.Checkbox,{checked:d,onChange:N=>c(N.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(s.Checkbox,{checked:b,onChange:N=>y(N.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(s.Checkbox,{checked:u,onChange:N=>x(N.target.checked),children:"Show Guardian Name in Fees Receipt"})]})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:ys,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Authorized Signatory"}),e.jsxs(s.Radio.Group,{value:j,onChange:N=>C(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.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(s.Radio.Group,{value:m,onChange:N=>h(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.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(s.Radio.Group,{value:g,onChange:N=>I(N.target.value),children:[e.jsx(s.Radio,{value:"1",children:"Enable"}),e.jsx(s.Radio,{value:"0",children:"Disable"})]})]})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:ys,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sequence Payment"}),e.jsx(s.Checkbox,{checked:R,onChange:N=>D(N.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(s.Checkbox,{checked:w,onChange:N=>f(N.target.checked),children:"Previous Fees Carry Over to Next Year"})]}),e.jsx(J,{type:"number",name:"upfront_payment_months",label:"Max Advance Payment (Months)",value:p,onChange:N=>S(N.target.value)})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:A?"Updating...":"Done",disabled:A})})]})})})]})}function Sf({token:t}){return e.jsx(bf,{token:t})}const On=it.marksheetSetting,jf=({token:t})=>lt({url:On.templateTypes,token:t}),vf=({token:t})=>lt({url:On.classDropdown,token:t}),_f=({token:t})=>lt({url:On.assignedTable,token:t}),wf={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:20,alignItems:"end"},ki=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:[]:[],Cf=Array.from({length:12},(t,n)=>({value:String(n+1),label:`Design ${n+1}`})),Af=t=>t?Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t)?t:[]:[];function Tf({token:t}){const n=i.useRef(null),a=jf({token:t}),r=vf({token:t}),o=_f({token:t}),l=i.useMemo(()=>ki(a.data),[a.data]),d=i.useMemo(()=>ki(r.data),[r.data]),c=i.useMemo(()=>Af(o.data),[o.data]),[b,y]=i.useState(null),[u,x]=i.useState(null),[j,C]=i.useState([]),m=()=>{n.current?.reset?.(),y(null),x(null),C([])},h=()=>{const w=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),f=URL.createObjectURL(w),p=document.createElement("a");p.href=f,p.download="marksheet-templates.json",p.click(),URL.revokeObjectURL(f)},g=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:m},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:h,disabled:c.length===0}],[c.length]),I=async w=>{if(w.preventDefault(),!b?.value){_.error("Select marksheet type.",{duration:1200});return}if(!u?.value){_.error("Select design.",{duration:1200});return}if(!j?.length){_.error("Select at least one class.",{duration:1200});return}try{const f=new FormData;f.set("temp_id",String(b.value)),f.set("ui_id",String(u.value)),j.forEach(p=>f.append("class_id[]",String(p))),await zn(On.assign,f,t),_.success("Marksheet template assigned.",{duration:1e3}),o.mutate?.(),m()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to assign template.",{duration:1500})}},R=async w=>{try{await zs(On.remove,w,t),_.success("Template removed.",{duration:1e3}),o.mutate?.()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to remove template.",{duration:1500})}},D=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:(w,f)=>e.jsx(ot,{id:f?.id,funcName:R})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Nt,{title:"Marksheet Setting",actions:g,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))"},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Template"}),children:e.jsxs("form",{ref:n,onSubmit:I,children:[e.jsxs("div",{style:wf,children:[e.jsxs("div",{children:[e.jsx(Z,{label:"Select Marksheet Type",options:l,value:b,onChange:w=>y(w)}),e.jsx("input",{type:"hidden",name:"temp_id",value:b?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Select Design",options:Cf,value:u,onChange:w=>x(w)}),e.jsx("input",{type:"hidden",name:"ui_id",value:u?.value??""})]})]}),e.jsx(s.Divider,{}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:8},children:"Class"}),e.jsx(s.Checkbox.Group,{options:d,value:j,onChange:w=>C(w)})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save"})})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Marksheet List"}),children:e.jsx(s.Table,{size:"small",rowKey:"id",columns:D,dataSource:c,pagination:!1})})]})})]})}function Rf({token:t}){return e.jsx(Tf,{token:t})}const fs={fetch:`${it.legalPages.get}?page_name=terms`,save:it.legalPages.termsSave,fieldName:"terms_data"};function If({token:t}){return e.jsx(Ys,{token:t,title:"Terms",fetchUrl:fs.fetch,saveUrl:fs.save,fieldName:fs.fieldName})}function Df({token:t}){return e.jsx(If,{token:t})}const hs={fetch:`${it.legalPages.get}?page_name=privacy`,save:it.legalPages.privacySave,fieldName:"privacy_data"};function kf({token:t}){return e.jsx(Ys,{token:t,title:"Privacy",fetchUrl:hs.fetch,saveUrl:hs.save,fieldName:hs.fieldName})}function Of({token:t}){return e.jsx(kf,{token:t})}const gs={fetch:`${it.legalPages.get}?page_name=about_us`,save:it.legalPages.aboutSave,fieldName:"about_data"};function Pf({token:t}){return e.jsx(Ys,{token:t,title:"About",fetchUrl:gs.fetch,saveUrl:gs.save,fieldName:gs.fieldName})}function Ef({token:t}){return e.jsx(Pf,{token:t})}const Ws=it.feesInfo,Mf=({token:t})=>lt({url:Ws.get,token:t}),Ff=({token:t})=>lt({url:Ws.statesDropdown,token:t}),xs={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Nf=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,$f=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[]:[],Uf=t=>t?Ao(`branch/logo/${t}`):"",bs=t=>t?Ao(`branch/signature/${t}`):"";function Bf({token:t}){const n=i.useRef(null),a=Mf({token:t}),r=Ff({token:t}),o=i.useMemo(()=>Nf(a.data),[a.data]),l=i.useMemo(()=>$f(r.data),[r.data]),[d,c]=i.useState(null),[b,y]=i.useState(""),[u,x]=i.useState(""),[j,C]=i.useState(""),[m,h]=i.useState(""),g=p=>{const S=new FormData(p),A=Object.fromEntries(S.entries());return A.state_id=d?.value??"",A.fees_receipt_logo=b,A.manager_signature=u,A.principal_signature=j,A.stamp=m,A},I=()=>{c(l.find(p=>String(p?.value)===String(o?.state_id??""))??null),y(o?.fees_receipt_logo??""),x(o?.manager_signature??""),C(o?.principal_signature??""),h(o?.stamp??"")};i.useEffect(()=>{o&&I()},[o,l]);const R=()=>{n.current?.reset?.(),I()},D=()=>{const p=g(n.current),S=new Blob([JSON.stringify(p,null,2)],{type:"application/json"}),A=URL.createObjectURL(S),O=document.createElement("a");O.href=A,O.download="fees-info.json",O.click(),URL.revokeObjectURL(A)},w=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:R},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:D,disabled:!o}],[o,d,b,u,j,m]),f=async p=>{p.preventDefault();try{const S=g(p.target);await Wy(Ws.save,S,t),_.success("Fees info saved.",{duration:1e3}),a.mutate?.()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to save fees info.",{duration:1500})}};return a.isLoading&&!a.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Nt,{title:"Fees Info",actions:w,children:e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"School Information"}),children:e.jsxs("form",{ref:n,onSubmit:f,children:[e.jsxs("div",{style:xs,children:[e.jsx(J,{name:"Bussiness_name",label:"Business Name*",defaultValue:o?.name??"",required:!0}),e.jsx(J,{name:"cin",label:"Sub Heading",defaultValue:o?.cin??""}),e.jsx(J,{name:"school_no",type:"number",label:"School Number",defaultValue:o?.school_no??""}),e.jsx(J,{name:"website",label:"Website",defaultValue:o?.website??""}),e.jsx(J,{name:"school_Code",label:"School Code",defaultValue:o?.school_Code??""}),e.jsx(J,{name:"offical_number",label:"Official Number",defaultValue:o?.offical_number??""}),e.jsx(J,{name:"email_id",label:"Email",defaultValue:o?.email_id??""}),e.jsx(J,{name:"receipt_prefix",label:"Receipt Prefix",defaultValue:o?.receipt_prefix??""}),e.jsx(J,{name:"recipt_start_number",type:"number",label:"Receipt Start Number",defaultValue:o?.recipt_start_number??""}),e.jsxs("div",{children:[e.jsx(Z,{label:"State",options:l,value:d,onChange:c}),e.jsx("input",{type:"hidden",name:"state_id",value:d?.value??""})]}),e.jsx(J,{name:"affiliation_no",label:"Affiliation Number",defaultValue:o?.affiliation_no??""}),e.jsx(J,{name:"affiliation_desc",label:"Affiliation Description",defaultValue:o?.affiliation_desc??""}),e.jsx(J,{name:"udise_code",label:"UDISE Code",defaultValue:o?.udise_code??""}),e.jsx(J,{name:"color_code",label:"Primary Color",defaultValue:o?.color_code??""}),e.jsx(J,{name:"fontcolor_code",label:"Font Color",defaultValue:o?.fontcolor_code??""})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:xs,children:[e.jsx(Dt,{name:"Bussiness_address",rows:3,label:"Business Address",defaultValue:o?.Bussiness_address??o?.bussiness_address??""}),e.jsx(Dt,{name:"note",rows:3,label:"Note",defaultValue:o?.note??""})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:xs,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Fees Receipt Logo"}),e.jsx(nn,{token:t,action:Do(),value:b,previewUrl:Uf(b),accept:"image/*",onChange:y}),e.jsx("input",{type:"hidden",name:"fees_receipt_logo",value:b})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Manager Signature"}),e.jsx(nn,{token:t,action:ms(),value:u,previewUrl:bs(u),accept:"image/*",onChange:x}),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(nn,{token:t,action:ms(),value:j,previewUrl:bs(j),accept:"image/*",onChange:C}),e.jsx("input",{type:"hidden",name:"principal_signature",value:j})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Stamp"}),e.jsx(nn,{token:t,action:ms(),value:m,previewUrl:bs(m),accept:"image/*",onChange:h}),e.jsx("input",{type:"hidden",name:"stamp",value:m})]})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save"})})]})})})]})}function Lf({token:t}){return e.jsx(Bf,{token:t})}const wa=it.payrollSettings,qf=({token:t,page:n=1,perPage:a=10})=>Io({baseUrl:wa.table,token:t,page:n,perPage:a}),zf={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Cn=[{value:"Allowances",label:"Allowances"},{value:"Dedection",label:"Dedection"}],Ss=[{value:"Flat",label:"Flat"},{value:"Percentage",label:"Percentage"}],Yf=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Wf=(t,n=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??n;function Vf({token:t}){const n=i.useRef(null),a=i.useRef(null),[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,b]=i.useState(null),[y,u]=i.useState(Cn[0]),[x,j]=i.useState(null),[C,m]=i.useState(null),[h,g]=i.useState(null),I=qf({token:t,page:r.page,perPage:r.rowsPerPage}),R=i.useMemo(()=>Yf(I.data),[I.data]),D=i.useMemo(()=>Wf(I.data,R.length),[I.data,R.length]),w=async U=>{U.preventDefault();try{const v=new FormData(U.target);v.set("type",y?.value??""),v.set("amount_type",x?.value??""),await zn(wa.add,v,t),_.success("Payroll setting added.",{duration:1e3}),I.mutate?.(),U.target.reset(),j(null),u(Cn[0])}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to add payroll setting.",{duration:1500})}},f=U=>{b(U),m(Cn.find(v=>v.value===U?.type)??null),g(Ss.find(v=>v.value===U?.amount_type)??null),d(!0)},p=async U=>{U.preventDefault();try{const v=new FormData(U.target);v.set("id",String(c?.id??"")),v.set("type",C?.value??""),v.set("amount_type",h?.value??""),await To(wa.edit,v,t),_.success("Payroll setting updated.",{duration:1e3}),d(!1),I.mutate?.()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to update payroll setting.",{duration:1500})}},S=async U=>{try{await zs(wa.remove,U,t),_.success("Payroll setting deleted.",{duration:1e3}),I.mutate?.()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to delete payroll setting.",{duration:1500})}},A=()=>{const U=new Blob([JSON.stringify(R,null,2)],{type:"application/json"}),v=URL.createObjectURL(U),M=document.createElement("a");M.href=v,M.download="payroll-settings.json",M.click(),URL.revokeObjectURL(v)},O=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(X.PlusOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:()=>I.mutate?.()},{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:A,disabled:R.length===0}],[R.length]),q=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,v)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(s.Button,{type:"text",icon:e.jsx(X.EditOutlined,{}),onClick:()=>f(v)}),e.jsx(s.Popconfirm,{title:"Delete payroll setting?",onConfirm:()=>S(v.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(X.DeleteOutlined,{})})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Nt,{title:"Payroll Settings",actions:O,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"minmax(320px, 420px) 1fr"},children:[e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Add Allowances / Deductions"}),children:e.jsxs("form",{ref:n,onSubmit:w,children:[e.jsxs("div",{style:zf,children:[e.jsx(J,{name:"title",label:"Title",required:!0}),e.jsxs("div",{children:[e.jsx(Z,{label:"Type",options:Cn,value:y,onChange:u}),e.jsx("input",{type:"hidden",name:"type",value:y?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Amount Type",options:Ss,value:x,onChange:j}),e.jsx("input",{type:"hidden",name:"amount_type",value:x?.value??""})]}),e.jsx(J,{name:"Amount",type:"number",label:"Amount",required:!0})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:20},children:e.jsx(de,{type:"submit",value:"Submit"})})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Payroll Settings List"}),children:e.jsx(s.Table,{rowKey:"id",columns:q,dataSource:R,loading:I.isLoading,pagination:{current:r.page,pageSize:r.rowsPerPage,total:D,showSizeChanger:!0,onChange:(U,v)=>o({page:U,rowsPerPage:Number(v)})}})})]})}),e.jsx(s.Drawer,{open:l,onClose:()=>d(!1),title:"Edit Payroll Setting",width:420,children:e.jsx("form",{ref:a,onSubmit:p,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{name:"title",label:"Title",required:!0,defaultValue:c?.title??""}),e.jsxs("div",{children:[e.jsx(Z,{label:"Type",options:Cn,value:C,onChange:m}),e.jsx("input",{type:"hidden",name:"type",value:C?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Amount Type",options:Ss,value:h,onChange:g}),e.jsx("input",{type:"hidden",name:"amount_type",value:h?.value??""})]}),e.jsx(J,{name:"Amount",type:"number",label:"Amount",required:!0,defaultValue:c?.Amount??""}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Update"})})]})})})]})}function Hf({token:t}){return e.jsx(Vf,{token:t})}const Oo=it.paymentGateway,Kf=({token:t})=>lt({url:Oo.get,token:t}),Gf=[{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"]}],$t={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}},Oi=t=>{const n=Array.isArray(t?.data)&&t.data[0]||Array.isArray(t?.data?.data)&&t.data.data[0]||Array.isArray(t)&&t[0]||null;if(!n?.data)return $t;try{const a=JSON.parse(n.data||"{}"),r=a?.data&&typeof a.data=="object"?a.data:a;return{Razorpay:{...$t.Razorpay,...r?.Razorpay??{}},PhonePe:{...$t.PhonePe,...r?.PhonePe??r?.PineLab??r?.PineLabs??{}},Paytm:{...$t.Paytm,...r?.Paytm??r?.HDFC??{}},SabPaisa:{...$t.SabPaisa,...r?.SabPaisa??{}}}}catch{return $t}};function Jf({token:t}){const n=i.useRef(null),a=Kf({token:t}),[r,o]=i.useState($t);i.useEffect(()=>{a.data&&o(Oi(a.data))},[a.data]);const l=(u,x,j)=>{o(C=>({...C,[u]:{...C[u],[x]:j}}))},d=()=>o(Oi(a.data)),c=()=>{const u=new Blob([JSON.stringify(r,null,2)],{type:"application/json"}),x=URL.createObjectURL(u),j=document.createElement("a");j.href=x,j.download="payment-gateway-settings.json",j.click(),URL.revokeObjectURL(x)},b=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(X.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(X.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(X.ReloadOutlined,{}),onClick:d},{key:"export",label:"Export",icon:e.jsx(X.ExportOutlined,{}),onClick:c}],[r,a.data]),y=async u=>{u.preventDefault();try{await Ro(Oo.save,{data:r},t),_.success("Payment gateway settings saved.",{duration:1e3}),a.mutate?.()}catch(x){_.error(x?.response?.data?.msg??x?.message??"Failed to save gateway settings.",{duration:1500})}};return a.isLoading&&!a.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Nt,{title:"Payment Gateway",actions:b,children:e.jsxs("form",{ref:n,onSubmit:y,style:{display:"grid",gap:20},children:[Gf.map(u=>{const x=r[u.id]??{};return e.jsx(s.Card,{title:e.jsx(s.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(s.Switch,{checked:!!x.isActive,onChange:j=>l(u.id,"isActive",j)})]}),e.jsx(s.Divider,{style:{margin:0}}),e.jsx("div",{style:{display:"grid",gap:16,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:u.fields.map(j=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:j}),e.jsx(s.Input,{value:x[j]??"",type:j.toLowerCase().includes("secret")||j.toLowerCase().includes("password")?"password":"text",onChange:C=>l(u.id,j,C.target.value)})]},j))})]})},u.id)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(de,{type:"submit",value:"Save"})})]})})]})}function Qf({token:t}){return e.jsx(Jf,{token:t})}const Xf=({routes:t=[],onNavigate:n})=>e.jsx(s.Row,{gutter:[16,16],children:t.map((a,r)=>e.jsx(s.Col,{xs:24,md:8,lg:8,children:e.jsx(le,{children:e.jsx(Mi,{icon:a?.icon??"",title:a?.title??"",path:a?.path??"",onClick:n})})},`${r}route001`))});exports.About=Ef;exports.AcademicYear=hf;exports.Academics=Am;exports.AddBook=Ac;exports.AddDriver=jc;exports.AddStaff=Hu;exports.AdmissionEnquiry=Zd;exports.ApplyLeave=kp;exports.AprroveLeaveRequest=wp;exports.AssignByClass=Zm;exports.AssignStudentToTransport=Sc;exports.AssignSubjects=Jm;exports.AssignTimeGroup=oy;exports.AssignVehicles=lc;exports.AttendanceDashboard=mm;exports.BookList=Tc;exports.BuySellProduct=pu;exports.Category=tu;exports.Class=$m;exports.CoScholasticArea=fy;exports.CreateTimeGroup=ny;exports.DailyAttendance=xm;exports.Department=Np;exports.Designation=Bp;exports.ErpDashboard=Fo;exports.FeeReceiptSetting=Sf;exports.FeesInfo=Lf;exports.GeneralSetting=Ly;exports.Holidays=Vm;exports.IssueReturn=Ic;exports.LeaveType=Ep;exports.LibraryAssignStudent=Dc;exports.LibraryCategory=kc;exports.LibraryRenewalReport=Pc;exports.LibraryReport=Oc;exports.ManageStock=Cu;exports.MarksheetSetting=Rf;exports.MenuSubmenu=Ed;exports.MonthlyReport=jm;exports.Notes=Sy;exports.NpmReport=ku;exports.Organization=cf;exports.PaymentGateway=Qf;exports.Payroll=bp;exports.PayrollReceiptDetails=Qp;exports.PayrollSettings=Hf;exports.Privacy=Of;exports.Products=Qc;exports.PromoteStudents=uy;exports.RoutePage=Xf;exports.RouteTimeTable=vc;exports.Sections=Pm;exports.SellReports=vu;exports.Shift=zp;exports.StaffAttendance=cp;exports.StaffAttendanceReport=yp;exports.StaffDailyAttendance=Kp;exports.StaffDirectory=Xu;exports.StockReport=Du;exports.Stoppage=wc;exports.StudentAttendance=fm;exports.SubCategory=ou;exports.Subjects=qm;exports.Syllabus=Iy;exports.Terms=Df;exports.TimeTable=By;exports.TransferCertificate=Cy;exports.TransportRoutes=tc;exports.TransportVehicles=nc;exports.Unit=hu;exports.Vendor=Lc;exports.YearlyReport=Cm;exports.setBaseUrl=bd;
|
|
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}§ion=${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))}§ion=${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))}§ion=${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))}§ion_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))}§ion_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))}§ion_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))}§ion_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))}§ion_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;
|