ubk.erp.webpack 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (357) hide show
  1. package/dist/Api/api.d.ts +21 -0
  2. package/dist/Api/apiOption.d.ts +12 -0
  3. package/dist/ErpDashboard.d.ts +2 -0
  4. package/dist/Layout/Academics/Academics.d.ts +2 -0
  5. package/dist/Layout/Academics/AssignByClass/AssignByClass.d.ts +5 -0
  6. package/dist/Layout/Academics/AssignByClass/Pages/AssignByClassPage.d.ts +5 -0
  7. package/dist/Layout/Academics/AssignByClass/Services/assignByClassService.d.ts +8 -0
  8. package/dist/Layout/Academics/AssignByClass/hooks.d.ts +1 -0
  9. package/dist/Layout/Academics/AssignByClass/index.d.ts +1 -0
  10. package/dist/Layout/Academics/AssignSubjects/AssignSubjects.d.ts +5 -0
  11. package/dist/Layout/Academics/AssignSubjects/Pages/AssignSubjectsPage.d.ts +5 -0
  12. package/dist/Layout/Academics/AssignSubjects/Services/assignSubjectsService.d.ts +6 -0
  13. package/dist/Layout/Academics/AssignSubjects/hooks.d.ts +5 -0
  14. package/dist/Layout/Academics/AssignSubjects/index.d.ts +1 -0
  15. package/dist/Layout/Academics/AssignTimeGroup/AssignTimeGroup.d.ts +5 -0
  16. package/dist/Layout/Academics/AssignTimeGroup/Pages/AssignTimeGroupPage.d.ts +5 -0
  17. package/dist/Layout/Academics/AssignTimeGroup/Services/assignTimeGroupService.d.ts +8 -0
  18. package/dist/Layout/Academics/AssignTimeGroup/hooks.d.ts +1 -0
  19. package/dist/Layout/Academics/AssignTimeGroup/index.d.ts +1 -0
  20. package/dist/Layout/Academics/Class/Class.d.ts +5 -0
  21. package/dist/Layout/Academics/Class/Pages/ClassPage.d.ts +5 -0
  22. package/dist/Layout/Academics/Class/Services/classService.d.ts +8 -0
  23. package/dist/Layout/Academics/Class/hooks.d.ts +5 -0
  24. package/dist/Layout/Academics/Class/index.d.ts +1 -0
  25. package/dist/Layout/Academics/CoScholasticArea/CoScholasticArea.d.ts +5 -0
  26. package/dist/Layout/Academics/CoScholasticArea/Pages/CoScholasticAreaPage.d.ts +5 -0
  27. package/dist/Layout/Academics/CoScholasticArea/Services/coScholasticAreaService.d.ts +8 -0
  28. package/dist/Layout/Academics/CoScholasticArea/hooks.d.ts +10 -0
  29. package/dist/Layout/Academics/CoScholasticArea/index.d.ts +1 -0
  30. package/dist/Layout/Academics/Components/SingleUpload.d.ts +7 -0
  31. package/dist/Layout/Academics/Components/index.d.ts +1 -0
  32. package/dist/Layout/Academics/CreateTimeGroup/CreateTimeGroup.d.ts +5 -0
  33. package/dist/Layout/Academics/CreateTimeGroup/Pages/CreateTimeGroupPage.d.ts +5 -0
  34. package/dist/Layout/Academics/CreateTimeGroup/Services/createTimeGroupService.d.ts +8 -0
  35. package/dist/Layout/Academics/CreateTimeGroup/hooks.d.ts +1 -0
  36. package/dist/Layout/Academics/CreateTimeGroup/index.d.ts +1 -0
  37. package/dist/Layout/Academics/Holidays/Holidays.d.ts +5 -0
  38. package/dist/Layout/Academics/Holidays/Pages/HolidaysPage.d.ts +5 -0
  39. package/dist/Layout/Academics/Holidays/Services/holidaysService.d.ts +7 -0
  40. package/dist/Layout/Academics/Holidays/hooks.d.ts +5 -0
  41. package/dist/Layout/Academics/Holidays/index.d.ts +1 -0
  42. package/dist/Layout/Academics/Notes/Notes.d.ts +5 -0
  43. package/dist/Layout/Academics/Notes/Pages/NotesPage.d.ts +5 -0
  44. package/dist/Layout/Academics/Notes/Services/notesService.d.ts +4 -0
  45. package/dist/Layout/Academics/Notes/hooks.d.ts +6 -0
  46. package/dist/Layout/Academics/Notes/index.d.ts +1 -0
  47. package/dist/Layout/Academics/PromoteStudents/Pages/PromoteStudentsPage.d.ts +5 -0
  48. package/dist/Layout/Academics/PromoteStudents/PromoteStudents.d.ts +5 -0
  49. package/dist/Layout/Academics/PromoteStudents/Services/promoteStudentsService.d.ts +5 -0
  50. package/dist/Layout/Academics/PromoteStudents/hooks.d.ts +3 -0
  51. package/dist/Layout/Academics/PromoteStudents/index.d.ts +1 -0
  52. package/dist/Layout/Academics/Sections/Pages/SectionsPage.d.ts +5 -0
  53. package/dist/Layout/Academics/Sections/Sections.d.ts +5 -0
  54. package/dist/Layout/Academics/Sections/Services/sectionsService.d.ts +9 -0
  55. package/dist/Layout/Academics/Sections/hooks.d.ts +5 -0
  56. package/dist/Layout/Academics/Sections/index.d.ts +1 -0
  57. package/dist/Layout/Academics/Services/academicsService.d.ts +147 -0
  58. package/dist/Layout/Academics/Subjects/Pages/SubjectsPage.d.ts +5 -0
  59. package/dist/Layout/Academics/Subjects/Services/subjectsService.d.ts +9 -0
  60. package/dist/Layout/Academics/Subjects/Subjects.d.ts +5 -0
  61. package/dist/Layout/Academics/Subjects/hooks.d.ts +5 -0
  62. package/dist/Layout/Academics/Subjects/index.d.ts +1 -0
  63. package/dist/Layout/Academics/Syllabus/Pages/SyllabusPage.d.ts +5 -0
  64. package/dist/Layout/Academics/Syllabus/Services/syllabusService.d.ts +5 -0
  65. package/dist/Layout/Academics/Syllabus/Syllabus.d.ts +5 -0
  66. package/dist/Layout/Academics/Syllabus/hooks.d.ts +6 -0
  67. package/dist/Layout/Academics/Syllabus/index.d.ts +1 -0
  68. package/dist/Layout/Academics/TimeTable/Components/Routine.d.ts +5 -0
  69. package/dist/Layout/Academics/TimeTable/Components/TeacherTable.d.ts +5 -0
  70. package/dist/Layout/Academics/TimeTable/Pages/TimeTablePage.d.ts +5 -0
  71. package/dist/Layout/Academics/TimeTable/Services/timeTableService.d.ts +6 -0
  72. package/dist/Layout/Academics/TimeTable/Services/timetableEngine.d.ts +5 -0
  73. package/dist/Layout/Academics/TimeTable/Services/validator.d.ts +10 -0
  74. package/dist/Layout/Academics/TimeTable/TimeTable.d.ts +5 -0
  75. package/dist/Layout/Academics/TimeTable/index.d.ts +1 -0
  76. package/dist/Layout/Academics/TransferCertificate/Pages/TransferCertificatePage.d.ts +7 -0
  77. package/dist/Layout/Academics/TransferCertificate/Services/transferCertificateService.d.ts +5 -0
  78. package/dist/Layout/Academics/TransferCertificate/TransferCertificate.d.ts +7 -0
  79. package/dist/Layout/Academics/TransferCertificate/hooks.d.ts +5 -0
  80. package/dist/Layout/Academics/TransferCertificate/index.d.ts +1 -0
  81. package/dist/Layout/Academics/hooks.d.ts +6 -0
  82. package/dist/Layout/Academics/index.d.ts +15 -0
  83. package/dist/Layout/AttendanceDashboard/AttendanceDashboard.d.ts +5 -0
  84. package/dist/Layout/AttendanceDashboard/Charts/index.d.ts +1 -0
  85. package/dist/Layout/AttendanceDashboard/Components/index.d.ts +1 -0
  86. package/dist/Layout/AttendanceDashboard/Components/shared.d.ts +77 -0
  87. package/dist/Layout/AttendanceDashboard/DailyAttendance/DailyAttendance.d.ts +5 -0
  88. package/dist/Layout/AttendanceDashboard/DailyAttendance/Services/dailyAttendanceService.d.ts +8 -0
  89. package/dist/Layout/AttendanceDashboard/DailyAttendance/hooks.d.ts +1 -0
  90. package/dist/Layout/AttendanceDashboard/DailyAttendance/index.d.ts +1 -0
  91. package/dist/Layout/AttendanceDashboard/MonthlyReport/MonthlyReport.d.ts +5 -0
  92. package/dist/Layout/AttendanceDashboard/MonthlyReport/Services/monthlyReportService.d.ts +9 -0
  93. package/dist/Layout/AttendanceDashboard/MonthlyReport/hooks.d.ts +1 -0
  94. package/dist/Layout/AttendanceDashboard/MonthlyReport/index.d.ts +1 -0
  95. package/dist/Layout/AttendanceDashboard/Reports/index.d.ts +1 -0
  96. package/dist/Layout/AttendanceDashboard/Services/attendanceDashboardService.d.ts +35 -0
  97. package/dist/Layout/AttendanceDashboard/StudentAttendance/Services/studentAttendanceService.d.ts +10 -0
  98. package/dist/Layout/AttendanceDashboard/StudentAttendance/StudentAttendance.d.ts +5 -0
  99. package/dist/Layout/AttendanceDashboard/StudentAttendance/hooks.d.ts +1 -0
  100. package/dist/Layout/AttendanceDashboard/StudentAttendance/index.d.ts +1 -0
  101. package/dist/Layout/AttendanceDashboard/YearlyReport/Services/yearlyReportService.d.ts +8 -0
  102. package/dist/Layout/AttendanceDashboard/YearlyReport/YearlyReport.d.ts +5 -0
  103. package/dist/Layout/AttendanceDashboard/YearlyReport/hooks.d.ts +1 -0
  104. package/dist/Layout/AttendanceDashboard/YearlyReport/index.d.ts +1 -0
  105. package/dist/Layout/AttendanceDashboard/hooks.d.ts +34 -0
  106. package/dist/Layout/AttendanceDashboard/index.d.ts +5 -0
  107. package/dist/Layout/Export/BranchHeader.d.ts +2 -0
  108. package/dist/Layout/Export/ExportAttendance.d.ts +6 -0
  109. package/dist/Layout/Export/ExportDataWithHeader.d.ts +2 -0
  110. package/dist/Layout/FontOffice/AdmissionEnquiry.d.ts +5 -0
  111. package/dist/Layout/FontOffice/FontOfficeMenu.d.ts +5 -0
  112. package/dist/Layout/GeneralSetting/About/About.d.ts +5 -0
  113. package/dist/Layout/GeneralSetting/About/Pages/AboutPage.d.ts +5 -0
  114. package/dist/Layout/GeneralSetting/About/Services/aboutService.d.ts +5 -0
  115. package/dist/Layout/GeneralSetting/About/hooks.d.ts +3 -0
  116. package/dist/Layout/GeneralSetting/About/index.d.ts +1 -0
  117. package/dist/Layout/GeneralSetting/AcademicYear/AcademicYear.d.ts +5 -0
  118. package/dist/Layout/GeneralSetting/AcademicYear/Pages/AcademicYearPage.d.ts +5 -0
  119. package/dist/Layout/GeneralSetting/AcademicYear/Services/academicYearService.d.ts +6 -0
  120. package/dist/Layout/GeneralSetting/AcademicYear/hooks.d.ts +5 -0
  121. package/dist/Layout/GeneralSetting/AcademicYear/index.d.ts +1 -0
  122. package/dist/Layout/GeneralSetting/Components/IconActionToolbar.d.ts +5 -0
  123. package/dist/Layout/GeneralSetting/Components/LegalPageEditor.d.ts +10 -0
  124. package/dist/Layout/GeneralSetting/Components/RichTextEditor.d.ts +7 -0
  125. package/dist/Layout/GeneralSetting/Components/SettingsPageLayout.d.ts +8 -0
  126. package/dist/Layout/GeneralSetting/Components/SingleUpload.d.ts +11 -0
  127. package/dist/Layout/GeneralSetting/Components/index.d.ts +5 -0
  128. package/dist/Layout/GeneralSetting/FeeReceiptSetting/FeeReceiptSetting.d.ts +5 -0
  129. package/dist/Layout/GeneralSetting/FeeReceiptSetting/Pages/FeeReceiptSettingPage.d.ts +5 -0
  130. package/dist/Layout/GeneralSetting/FeeReceiptSetting/Services/feeReceiptSettingService.d.ts +4 -0
  131. package/dist/Layout/GeneralSetting/FeeReceiptSetting/hooks.d.ts +3 -0
  132. package/dist/Layout/GeneralSetting/FeeReceiptSetting/index.d.ts +1 -0
  133. package/dist/Layout/GeneralSetting/FeesInfo/FeesInfo.d.ts +5 -0
  134. package/dist/Layout/GeneralSetting/FeesInfo/Pages/FeesInfoPage.d.ts +5 -0
  135. package/dist/Layout/GeneralSetting/FeesInfo/Services/feesInfoService.d.ts +5 -0
  136. package/dist/Layout/GeneralSetting/FeesInfo/hooks.d.ts +6 -0
  137. package/dist/Layout/GeneralSetting/FeesInfo/index.d.ts +1 -0
  138. package/dist/Layout/GeneralSetting/GeneralSetting.d.ts +2 -0
  139. package/dist/Layout/GeneralSetting/MarksheetSetting/MarksheetSetting.d.ts +5 -0
  140. package/dist/Layout/GeneralSetting/MarksheetSetting/Pages/MarksheetSettingPage.d.ts +5 -0
  141. package/dist/Layout/GeneralSetting/MarksheetSetting/Services/marksheetSettingService.d.ts +7 -0
  142. package/dist/Layout/GeneralSetting/MarksheetSetting/hooks.d.ts +9 -0
  143. package/dist/Layout/GeneralSetting/MarksheetSetting/index.d.ts +1 -0
  144. package/dist/Layout/GeneralSetting/Organization/Organization.d.ts +5 -0
  145. package/dist/Layout/GeneralSetting/Organization/Pages/OrganizationPage.d.ts +5 -0
  146. package/dist/Layout/GeneralSetting/Organization/Services/organizationService.d.ts +14 -0
  147. package/dist/Layout/GeneralSetting/Organization/hooks.d.ts +16 -0
  148. package/dist/Layout/GeneralSetting/Organization/index.d.ts +1 -0
  149. package/dist/Layout/GeneralSetting/PaymentGateway/Pages/PaymentGatewayPage.d.ts +5 -0
  150. package/dist/Layout/GeneralSetting/PaymentGateway/PaymentGateway.d.ts +5 -0
  151. package/dist/Layout/GeneralSetting/PaymentGateway/Services/paymentGatewayService.d.ts +4 -0
  152. package/dist/Layout/GeneralSetting/PaymentGateway/hooks.d.ts +3 -0
  153. package/dist/Layout/GeneralSetting/PaymentGateway/index.d.ts +1 -0
  154. package/dist/Layout/GeneralSetting/PayrollSettings/Pages/PayrollSettingsPage.d.ts +5 -0
  155. package/dist/Layout/GeneralSetting/PayrollSettings/PayrollSettings.d.ts +5 -0
  156. package/dist/Layout/GeneralSetting/PayrollSettings/Services/payrollSettingsService.d.ts +7 -0
  157. package/dist/Layout/GeneralSetting/PayrollSettings/hooks.d.ts +5 -0
  158. package/dist/Layout/GeneralSetting/PayrollSettings/index.d.ts +1 -0
  159. package/dist/Layout/GeneralSetting/Privacy/Pages/PrivacyPage.d.ts +5 -0
  160. package/dist/Layout/GeneralSetting/Privacy/Privacy.d.ts +5 -0
  161. package/dist/Layout/GeneralSetting/Privacy/Services/privacyService.d.ts +5 -0
  162. package/dist/Layout/GeneralSetting/Privacy/hooks.d.ts +3 -0
  163. package/dist/Layout/GeneralSetting/Privacy/index.d.ts +1 -0
  164. package/dist/Layout/GeneralSetting/Services/generalSettingService.d.ts +77 -0
  165. package/dist/Layout/GeneralSetting/Terms/Pages/TermsPage.d.ts +5 -0
  166. package/dist/Layout/GeneralSetting/Terms/Services/termsService.d.ts +5 -0
  167. package/dist/Layout/GeneralSetting/Terms/Terms.d.ts +5 -0
  168. package/dist/Layout/GeneralSetting/Terms/hooks.d.ts +3 -0
  169. package/dist/Layout/GeneralSetting/Terms/index.d.ts +1 -0
  170. package/dist/Layout/GeneralSetting/hooks.d.ts +10 -0
  171. package/dist/Layout/GeneralSetting/index.d.ts +11 -0
  172. package/dist/Layout/HumanResource/AddStaff/AddStaff.d.ts +5 -0
  173. package/dist/Layout/HumanResource/AddStaff/Components/Step1.d.ts +1 -0
  174. package/dist/Layout/HumanResource/AddStaff/Components/Step2.d.ts +1 -0
  175. package/dist/Layout/HumanResource/AddStaff/Components/Step3.d.ts +1 -0
  176. package/dist/Layout/HumanResource/AddStaff/Components/index.d.ts +3 -0
  177. package/dist/Layout/HumanResource/AddStaff/Pages/AddStaffPage.d.ts +5 -0
  178. package/dist/Layout/HumanResource/AddStaff/Services/addStaffService.d.ts +22 -0
  179. package/dist/Layout/HumanResource/AddStaff/index.d.ts +1 -0
  180. package/dist/Layout/HumanResource/ApplyLeave/ApplyLeave.d.ts +5 -0
  181. package/dist/Layout/HumanResource/ApplyLeave/Pages/ApplyLeavePage.d.ts +5 -0
  182. package/dist/Layout/HumanResource/ApplyLeave/Services/applyLeaveService.d.ts +7 -0
  183. package/dist/Layout/HumanResource/ApplyLeave/hooks.d.ts +5 -0
  184. package/dist/Layout/HumanResource/ApplyLeave/index.d.ts +1 -0
  185. package/dist/Layout/HumanResource/AprroveLeaveRequest/AprroveLeaveRequest.d.ts +5 -0
  186. package/dist/Layout/HumanResource/AprroveLeaveRequest/Pages/AprroveLeaveRequestPage.d.ts +5 -0
  187. package/dist/Layout/HumanResource/AprroveLeaveRequest/Services/approveLeaveService.d.ts +6 -0
  188. package/dist/Layout/HumanResource/AprroveLeaveRequest/hooks.d.ts +5 -0
  189. package/dist/Layout/HumanResource/AprroveLeaveRequest/index.d.ts +1 -0
  190. package/dist/Layout/HumanResource/Components/SingleUpload.d.ts +7 -0
  191. package/dist/Layout/HumanResource/Components/index.d.ts +1 -0
  192. package/dist/Layout/HumanResource/Department/Department.d.ts +5 -0
  193. package/dist/Layout/HumanResource/Department/Pages/DepartmentPage.d.ts +5 -0
  194. package/dist/Layout/HumanResource/Department/Services/departmentService.d.ts +8 -0
  195. package/dist/Layout/HumanResource/Department/hooks.d.ts +5 -0
  196. package/dist/Layout/HumanResource/Department/index.d.ts +1 -0
  197. package/dist/Layout/HumanResource/Designation/Designation.d.ts +5 -0
  198. package/dist/Layout/HumanResource/Designation/Pages/DesignationPage.d.ts +5 -0
  199. package/dist/Layout/HumanResource/Designation/Services/designationService.d.ts +8 -0
  200. package/dist/Layout/HumanResource/Designation/hooks.d.ts +5 -0
  201. package/dist/Layout/HumanResource/Designation/index.d.ts +1 -0
  202. package/dist/Layout/HumanResource/HumanResource.d.ts +5 -0
  203. package/dist/Layout/HumanResource/HumanResourceDashboard/HumanResourceDashboard.d.ts +5 -0
  204. package/dist/Layout/HumanResource/HumanResourceDashboard/Pages/HumanResourceDashboardPage.d.ts +5 -0
  205. package/dist/Layout/HumanResource/HumanResourceDashboard/index.d.ts +1 -0
  206. package/dist/Layout/HumanResource/LeaveType/LeaveType.d.ts +5 -0
  207. package/dist/Layout/HumanResource/LeaveType/Pages/LeaveTypePage.d.ts +5 -0
  208. package/dist/Layout/HumanResource/LeaveType/Services/leaveTypeService.d.ts +8 -0
  209. package/dist/Layout/HumanResource/LeaveType/hooks.d.ts +5 -0
  210. package/dist/Layout/HumanResource/LeaveType/index.d.ts +1 -0
  211. package/dist/Layout/HumanResource/MonthlyAttendanceReport/MonthlyAttendanceReport.d.ts +5 -0
  212. package/dist/Layout/HumanResource/MonthlyAttendanceReport/Pages/MonthlyAttendanceReportPage.d.ts +5 -0
  213. package/dist/Layout/HumanResource/MonthlyAttendanceReport/index.d.ts +1 -0
  214. package/dist/Layout/HumanResource/Payroll/Pages/PayrollPage.d.ts +7 -0
  215. package/dist/Layout/HumanResource/Payroll/Payroll.d.ts +5 -0
  216. package/dist/Layout/HumanResource/Payroll/Services/payrollService.d.ts +8 -0
  217. package/dist/Layout/HumanResource/Payroll/index.d.ts +1 -0
  218. package/dist/Layout/HumanResource/PayrollReceiptDetails.d.ts +6 -0
  219. package/dist/Layout/HumanResource/PayrollReport/Pages/PayrollReportPage.d.ts +5 -0
  220. package/dist/Layout/HumanResource/PayrollReport/PayrollReport.d.ts +5 -0
  221. package/dist/Layout/HumanResource/PayrollReport/index.d.ts +1 -0
  222. package/dist/Layout/HumanResource/Services/humanResourceService.d.ts +115 -0
  223. package/dist/Layout/HumanResource/Shift/Pages/ShiftPage.d.ts +5 -0
  224. package/dist/Layout/HumanResource/Shift/Services/shiftService.d.ts +8 -0
  225. package/dist/Layout/HumanResource/Shift/Shift.d.ts +5 -0
  226. package/dist/Layout/HumanResource/Shift/hooks.d.ts +5 -0
  227. package/dist/Layout/HumanResource/Shift/index.d.ts +1 -0
  228. package/dist/Layout/HumanResource/StaffAttendance/Components/AttendancePaginationTable.d.ts +13 -0
  229. package/dist/Layout/HumanResource/StaffAttendance/Pages/StaffAttendancePage.d.ts +5 -0
  230. package/dist/Layout/HumanResource/StaffAttendance/Services/staffAttendanceService.d.ts +10 -0
  231. package/dist/Layout/HumanResource/StaffAttendance/StaffAttendance.d.ts +5 -0
  232. package/dist/Layout/HumanResource/StaffAttendance/index.d.ts +1 -0
  233. package/dist/Layout/HumanResource/StaffAttendanceReport/Pages/StaffAttendanceReportPage.d.ts +5 -0
  234. package/dist/Layout/HumanResource/StaffAttendanceReport/Services/staffAttendanceReportService.d.ts +2 -0
  235. package/dist/Layout/HumanResource/StaffAttendanceReport/StaffAttendanceReport.d.ts +5 -0
  236. package/dist/Layout/HumanResource/StaffAttendanceReport/StaffAttendanceReportCopy.d.ts +5 -0
  237. package/dist/Layout/HumanResource/StaffAttendanceReport/index.d.ts +1 -0
  238. package/dist/Layout/HumanResource/StaffDailyAttendance/Components/StaffMultipleShiftAtt.d.ts +5 -0
  239. package/dist/Layout/HumanResource/StaffDailyAttendance/Pages/StaffDailyAttendancePage.d.ts +5 -0
  240. package/dist/Layout/HumanResource/StaffDailyAttendance/Services/staffDailyAttendanceService.d.ts +9 -0
  241. package/dist/Layout/HumanResource/StaffDailyAttendance/StaffDailyAttendance.d.ts +5 -0
  242. package/dist/Layout/HumanResource/StaffDailyAttendance/index.d.ts +1 -0
  243. package/dist/Layout/HumanResource/StaffDirectory/Pages/StaffDirectoryPage.d.ts +5 -0
  244. package/dist/Layout/HumanResource/StaffDirectory/Services/staffDirectoryService.d.ts +19 -0
  245. package/dist/Layout/HumanResource/StaffDirectory/StaffDirectory.d.ts +5 -0
  246. package/dist/Layout/HumanResource/StaffDirectory/index.d.ts +1 -0
  247. package/dist/Layout/HumanResource/StaffDirectoryEdit/Pages/StaffDirectoryEditPage.d.ts +6 -0
  248. package/dist/Layout/HumanResource/StaffDirectoryEdit/StaffDirectoryEdit.d.ts +6 -0
  249. package/dist/Layout/HumanResource/StaffDirectoryEdit/index.d.ts +1 -0
  250. package/dist/Layout/HumanResource/StaffDirectoryEdit/staffEdit/Step1.d.ts +1 -0
  251. package/dist/Layout/HumanResource/StaffDirectoryEdit/staffEdit/Step2.d.ts +1 -0
  252. package/dist/Layout/HumanResource/StaffDirectoryEdit/staffEdit/Step3.d.ts +1 -0
  253. package/dist/Layout/HumanResource/StaffDirectoryEdit/staffEdit/index.d.ts +3 -0
  254. package/dist/Layout/HumanResource/StaffFullInformation/Components/PayrollInformation.d.ts +5 -0
  255. package/dist/Layout/HumanResource/StaffFullInformation/Components/StaffAttendanceByMonth.d.ts +5 -0
  256. package/dist/Layout/HumanResource/StaffFullInformation/Components/StaffBasicInformation.d.ts +5 -0
  257. package/dist/Layout/HumanResource/StaffFullInformation/Components/StaffExperience.d.ts +5 -0
  258. package/dist/Layout/HumanResource/StaffFullInformation/Components/index.d.ts +4 -0
  259. package/dist/Layout/HumanResource/StaffFullInformation/Pages/StaffFullInformationPage.d.ts +6 -0
  260. package/dist/Layout/HumanResource/StaffFullInformation/StaffFullInformation.d.ts +6 -0
  261. package/dist/Layout/HumanResource/StaffFullInformation/index.d.ts +1 -0
  262. package/dist/Layout/HumanResource/StaffWizard/StaffWizard.d.ts +8 -0
  263. package/dist/Layout/HumanResource/StaffWizard/Step1.d.ts +9 -0
  264. package/dist/Layout/HumanResource/StaffWizard/Step2.d.ts +10 -0
  265. package/dist/Layout/HumanResource/StaffWizard/Step3.d.ts +10 -0
  266. package/dist/Layout/HumanResource/StaffWizard/index.d.ts +1 -0
  267. package/dist/Layout/HumanResource/hooks.d.ts +6 -0
  268. package/dist/Layout/HumanResource/index.d.ts +21 -0
  269. package/dist/Layout/HumanResource/innerPage/PayrollReceiptDetails.d.ts +6 -0
  270. package/dist/Layout/HumanResource/innerPage/StaffAttendanceSingle.d.ts +9 -0
  271. package/dist/Layout/HumanResource/innerPage/index.d.ts +2 -0
  272. package/dist/Layout/Library/AddBook.d.ts +5 -0
  273. package/dist/Layout/Library/AddStudent.d.ts +5 -0
  274. package/dist/Layout/Library/BookList.d.ts +5 -0
  275. package/dist/Layout/Library/Category.d.ts +5 -0
  276. package/dist/Layout/Library/IssueReturn.d.ts +5 -0
  277. package/dist/Layout/Library/LibMonthlyReport.d.ts +5 -0
  278. package/dist/Layout/Transport/AddDriver.d.ts +5 -0
  279. package/dist/Layout/Transport/AssignStudentToTransport.d.ts +8 -0
  280. package/dist/Layout/Transport/AssignVehicles.d.ts +5 -0
  281. package/dist/Layout/Transport/Edit/EditAssignStudentToTransport.d.ts +9 -0
  282. package/dist/Layout/Transport/RouteTimeTable.d.ts +5 -0
  283. package/dist/Layout/Transport/Stoppage copy.d.ts +5 -0
  284. package/dist/Layout/Transport/Stoppage.d.ts +5 -0
  285. package/dist/Layout/Transport/TransportRoutes.d.ts +5 -0
  286. package/dist/Layout/Transport/TransportVehicles.d.ts +5 -0
  287. package/dist/Layout/store/BuySellProduct/BuySellProduct.d.ts +5 -0
  288. package/dist/Layout/store/BuySellProduct/Pages/BuySellProductPage.d.ts +5 -0
  289. package/dist/Layout/store/BuySellProduct/Services/buySellService.d.ts +14 -0
  290. package/dist/Layout/store/BuySellProduct/index.d.ts +1 -0
  291. package/dist/Layout/store/Category/Category.d.ts +5 -0
  292. package/dist/Layout/store/Category/Pages/CategoryPage.d.ts +5 -0
  293. package/dist/Layout/store/Category/Services/categoryService.d.ts +7 -0
  294. package/dist/Layout/store/Category/hooks.d.ts +5 -0
  295. package/dist/Layout/store/Category/index.d.ts +1 -0
  296. package/dist/Layout/store/Components/SingleUpload.d.ts +7 -0
  297. package/dist/Layout/store/ManageStock/ManageStock.d.ts +5 -0
  298. package/dist/Layout/store/ManageStock/Pages/ManageStockPage.d.ts +5 -0
  299. package/dist/Layout/store/ManageStock/Services/manageStockService.d.ts +11 -0
  300. package/dist/Layout/store/ManageStock/index.d.ts +1 -0
  301. package/dist/Layout/store/Products/Pages/ProductsPage.d.ts +5 -0
  302. package/dist/Layout/store/Products/Products.d.ts +5 -0
  303. package/dist/Layout/store/Products/Services/productsService.d.ts +15 -0
  304. package/dist/Layout/store/Products/hooks.d.ts +18 -0
  305. package/dist/Layout/store/Products/index.d.ts +1 -0
  306. package/dist/Layout/store/SellReports/Pages/SellReportsPage.d.ts +5 -0
  307. package/dist/Layout/store/SellReports/SellReports.d.ts +5 -0
  308. package/dist/Layout/store/SellReports/Services/sellReportsService.d.ts +4 -0
  309. package/dist/Layout/store/SellReports/index.d.ts +1 -0
  310. package/dist/Layout/store/Services/storeService.d.ts +84 -0
  311. package/dist/Layout/store/StockReport/Pages/StockReportPage.d.ts +5 -0
  312. package/dist/Layout/store/StockReport/Services/stockReportService.d.ts +2 -0
  313. package/dist/Layout/store/StockReport/StockReport.d.ts +5 -0
  314. package/dist/Layout/store/StockReport/index.d.ts +1 -0
  315. package/dist/Layout/store/SubCategory/Pages/SubCategoryPage.d.ts +5 -0
  316. package/dist/Layout/store/SubCategory/Services/subCategoryService.d.ts +8 -0
  317. package/dist/Layout/store/SubCategory/SubCategory.d.ts +5 -0
  318. package/dist/Layout/store/SubCategory/hooks.d.ts +8 -0
  319. package/dist/Layout/store/SubCategory/index.d.ts +1 -0
  320. package/dist/Layout/store/Unit/Pages/UnitPage.d.ts +5 -0
  321. package/dist/Layout/store/Unit/Services/unitService.d.ts +7 -0
  322. package/dist/Layout/store/Unit/Unit.d.ts +5 -0
  323. package/dist/Layout/store/Unit/hooks.d.ts +5 -0
  324. package/dist/Layout/store/Unit/index.d.ts +1 -0
  325. package/dist/Layout/store/Vendor/Pages/VendorPage.d.ts +5 -0
  326. package/dist/Layout/store/Vendor/Services/vendorService.d.ts +7 -0
  327. package/dist/Layout/store/Vendor/Vendor.d.ts +5 -0
  328. package/dist/Layout/store/Vendor/hooks.d.ts +5 -0
  329. package/dist/Layout/store/Vendor/index.d.ts +1 -0
  330. package/dist/Layout/store/hooks.d.ts +6 -0
  331. package/dist/RoutePage.d.ts +5 -0
  332. package/dist/Secondary/CommonFuntion.d.ts +35 -0
  333. package/dist/Secondary/DummyDataGenerator.d.ts +6 -0
  334. package/dist/Secondary/TextChangeGlobal.d.ts +6 -0
  335. package/dist/Secondary/Year.d.ts +2 -0
  336. package/dist/Services/timetableEngine.test.d.ts +1 -0
  337. package/dist/Services/validator.test.d.ts +1 -0
  338. package/dist/UBKDeleteButton/index.d.ts +7 -0
  339. package/dist/components/Cards/MenuCard/Index.d.ts +7 -0
  340. package/dist/components/CommonActionButtons/CommonActionButtons.d.ts +11 -0
  341. package/dist/components/CommonActionButtons/index.d.ts +1 -0
  342. package/dist/components/MDInput/index.d.ts +2 -0
  343. package/dist/components/UBKBox/index.d.ts +13 -0
  344. package/dist/components/UBKDate/index.d.ts +3 -0
  345. package/dist/components/UBKDeleteButton/index.d.ts +7 -0
  346. package/dist/components/UBKSelect/FixRequiredSelect.d.ts +26 -0
  347. package/dist/components/UBKSelect/MySelect.d.ts +2 -0
  348. package/dist/components/UBKSelect/UBKSelectWL.d.ts +2 -0
  349. package/dist/components/UBKSelect/index.d.ts +2 -0
  350. package/dist/components/UBKSubmit/index.d.ts +2 -0
  351. package/dist/components/UBKTable/UBKantdTable.d.ts +4 -0
  352. package/dist/components/UBKTextarea/index.d.ts +7 -0
  353. package/dist/components/UBKTypography/index.d.ts +8 -0
  354. package/dist/index.cjs +2 -2
  355. package/dist/index.d.ts +48 -289
  356. package/dist/index.js +24 -16
  357. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -6,7 +6,7 @@
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
8
  `,d+1),x=c===-1?"":l.slice(c+1);String(r.stack).endsWith(x)||(r.stack+=`
9
- `+l)}}catch{}}throw r}}_request(n,a){typeof n=="string"?(a=a||{},a.url=n):a=n||{},a=Yt(this.defaults,a);const{transitional:r,paramsSerializer:o,headers:l}=a;r!==void 0&&ca.assertOptions(r,{silentJSONParsing:ct.transitional(ct.boolean),forcedJSONParsing:ct.transitional(ct.boolean),clarifyTimeoutError:ct.transitional(ct.boolean),legacyInterceptorReqResOrdering:ct.transitional(ct.boolean)},!1),o!=null&&(H.isFunction(o)?a.paramsSerializer={serialize:o}:ca.assertOptions(o,{encode:ct.function,serialize:ct.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),ca.assertOptions(a,{baseUrl:ct.spelling("baseURL"),withXsrfToken:ct.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let d=l&&H.merge(l.common,l[a.method]);l&&H.forEach(["delete","get","head","post","put","patch","common"],p=>{delete l[p]}),a.headers=et.concat(d,l);const c=[];let x=!0;this.interceptors.request.forEach(function(y){if(typeof y.runWhen=="function"&&y.runWhen(a)===!1)return;x=x&&y.synchronous;const h=a.transitional||ws;h&&h.legacyInterceptorReqResOrdering?c.unshift(y.fulfilled,y.rejected):c.push(y.fulfilled,y.rejected)});const m=[];this.interceptors.response.forEach(function(y){m.push(y.fulfilled,y.rejected)});let u,b=0,v;if(!x){const p=[ar.bind(this),void 0];for(p.unshift(...c),p.push(...m),v=p.length,u=Promise.resolve(a);b<v;)u=u.then(p[b++],p[b++]);return u}v=c.length;let w=a;for(;b<v;){const p=c[b++],y=c[b++];try{w=p(w)}catch(h){y.call(this,h);break}}try{u=ar.call(this,w)}catch(p){return Promise.reject(p)}for(b=0,v=m.length;b<v;)u=u.then(m[b++],m[b++]);return u}getUri(n){n=Yt(this.defaults,n);const a=qi(n.baseURL,n.url,n.allowAbsoluteUrls);return Ni(a,n.params,n.paramsSerializer)}};H.forEach(["delete","get","head","options"],function(n){Lt.prototype[n]=function(a,r){return this.request(Yt(r||{},{method:n,url:a,data:(r||{}).data}))}});H.forEach(["post","put","patch"],function(n){function a(r){return function(l,d,c){return this.request(Yt(c||{},{method:n,headers:r?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}Lt.prototype[n]=a(),Lt.prototype[n+"Form"]=a(!0)});let rd=class Hi{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 Hi(function(o){n=o}),cancel:n}}};function id(t){return function(a){return t.apply(null,a)}}function od(t){return H.isObject(t)&&t.isAxiosError===!0}const Ss={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(Ss).forEach(([t,n])=>{Ss[n]=t});function Ki(t){const n=new Lt(t),a=Ti(Lt.prototype.request,n);return H.extend(a,Lt.prototype,n,{allOwnKeys:!0}),H.extend(a,n,null,{allOwnKeys:!0}),a.create=function(o){return Ki(Yt(t,o))},a}const Ne=Ki($n);Ne.Axios=Lt;Ne.CanceledError=Nn;Ne.CancelToken=rd;Ne.isCancel=Bi;Ne.VERSION=Wi;Ne.toFormData=Oa;Ne.AxiosError=Se;Ne.Cancel=Ne.CanceledError;Ne.all=function(n){return Promise.all(n)};Ne.spread=id;Ne.isAxiosError=od;Ne.mergeConfig=Yt;Ne.AxiosHeaders=et;Ne.formToJSON=t=>Ui(H.isHTMLForm(t)?new FormData(t):t);Ne.getAdapter=Vi.getAdapter;Ne.HttpStatusCode=Ss;Ne.default=Ne;const{Axios:Py,AxiosError:ky,CanceledError:Ey,isCancel:My,CancelToken:Fy,VERSION:$y,all:Ny,Cancel:Uy,isAxiosError:By,spread:Ly,toFormData:qy,AxiosHeaders:zy,HttpStatusCode:Yy,formToJSON:Vy,getAdapter:Wy,mergeConfig:Hy}=Ne,ld=()=>new Promise(t=>setTimeout(()=>t(),800));let js=null;const dd=t=>{js=t,gt.defaults.baseURL=Ts()},Ts=()=>js||"https://npmapi.ubkerp.com/",gt=Ne.create({baseURL:Ts()}),tt=()=>Ts(),ze=async(t,n,a)=>{const r=await gt.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 gt.get(r,{headers:{Authorization:n}})).data}catch(a){throw a.response?.status===401&&console.error("401 Unauthorized"),a}},cd=async(t,n)=>{const a=await gt.post(t,"",{headers:{Authorization:n}});if(a.data?.Status=="Success")return a?.data?.data||a?.data;throw new Error(a.data?.msg)},ka=async(t,n,a)=>(await gt.post(t,n,{headers:{Authorization:a}}))?.data,On=async(t,n,a)=>{const r=n?.arg;return(await gt.post(t,r,{headers:{Authorization:a}}))?.data},qt=async(t,n,a)=>{const r=n?.arg,o=t.includes("?")?"&":"?";return(await gt.get(t+o,{params:r,headers:{Authorization:a}}))?.data},ud="/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",Is=async(t,n,a)=>{const r=n?.arg,o=t.includes("?")?"&":"?";return(await gt.get(t+o,{params:r,headers:{Authorization:a}}))?.data},pt=async(t,n,a)=>(await ld(),(await gt.post(t,n,{headers:{Authorization:a}}))?.data),nt=async(t,n,a)=>(await gt.delete(`${t}/${n}`,{headers:{Authorization:a}})).data,pd=({token:t,menu:n})=>{const{isLoading:a,data:r}=G(t?["api/sdk/Menus",t]:null,([l,d])=>cd(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(fe,{children:e.jsx(Ai,{icon:`${tt()}icons/frontoffice/${l.icons}`,title:l.submenu_name,path:l.menu_key})})},`${d}office001`):null)})};function Gi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Le={},Wa,rr;function md(){return rr||(rr=1,Wa=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}),Wa}var Wn={exports:{}},Hn={exports:{}},Re={};var ir;function fd(){if(ir)return Re;ir=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,x=t?Symbol.for("react.async_mode"):60111,m=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,b=t?Symbol.for("react.suspense"):60113,v=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,p=t?Symbol.for("react.lazy"):60116,y=t?Symbol.for("react.block"):60121,h=t?Symbol.for("react.fundamental"):60117,R=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function D(g){if(typeof g=="object"&&g!==null){var f=g.$$typeof;switch(f){case n:switch(g=g.type,g){case x:case m:case r:case l:case o:case b:return g;default:switch(g=g&&g.$$typeof,g){case c:case u:case p:case w:case d:return g;default:return f}}case a:return f}}}function C(g){return D(g)===m}return Re.AsyncMode=x,Re.ConcurrentMode=m,Re.ContextConsumer=c,Re.ContextProvider=d,Re.Element=n,Re.ForwardRef=u,Re.Fragment=r,Re.Lazy=p,Re.Memo=w,Re.Portal=a,Re.Profiler=l,Re.StrictMode=o,Re.Suspense=b,Re.isAsyncMode=function(g){return C(g)||D(g)===x},Re.isConcurrentMode=C,Re.isContextConsumer=function(g){return D(g)===c},Re.isContextProvider=function(g){return D(g)===d},Re.isElement=function(g){return typeof g=="object"&&g!==null&&g.$$typeof===n},Re.isForwardRef=function(g){return D(g)===u},Re.isFragment=function(g){return D(g)===r},Re.isLazy=function(g){return D(g)===p},Re.isMemo=function(g){return D(g)===w},Re.isPortal=function(g){return D(g)===a},Re.isProfiler=function(g){return D(g)===l},Re.isStrictMode=function(g){return D(g)===o},Re.isSuspense=function(g){return D(g)===b},Re.isValidElementType=function(g){return typeof g=="string"||typeof g=="function"||g===r||g===m||g===l||g===o||g===b||g===v||typeof g=="object"&&g!==null&&(g.$$typeof===p||g.$$typeof===w||g.$$typeof===d||g.$$typeof===c||g.$$typeof===u||g.$$typeof===h||g.$$typeof===R||g.$$typeof===I||g.$$typeof===y)},Re.typeOf=D,Re}var De={};var or;function yd(){return or||(or=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,x=t?Symbol.for("react.async_mode"):60111,m=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,b=t?Symbol.for("react.suspense"):60113,v=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,p=t?Symbol.for("react.lazy"):60116,y=t?Symbol.for("react.block"):60121,h=t?Symbol.for("react.fundamental"):60117,R=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function D(re){return typeof re=="string"||typeof re=="function"||re===r||re===m||re===l||re===o||re===b||re===v||typeof re=="object"&&re!==null&&(re.$$typeof===p||re.$$typeof===w||re.$$typeof===d||re.$$typeof===c||re.$$typeof===u||re.$$typeof===h||re.$$typeof===R||re.$$typeof===I||re.$$typeof===y)}function C(re){if(typeof re=="object"&&re!==null){var ie=re.$$typeof;switch(ie){case n:var W=re.type;switch(W){case x:case m:case r:case l:case o:case b:return W;default:var oe=W&&W.$$typeof;switch(oe){case c:case u:case p:case w:case d:return oe;default:return ie}}case a:return ie}}}var g=x,f=m,S=c,A=d,P=n,L=u,N=r,j=p,M=w,k=a,F=l,E=o,B=b,Y=!1;function q(re){return Y||(Y=!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.")),O(re)||C(re)===x}function O(re){return C(re)===m}function T(re){return C(re)===c}function $(re){return C(re)===d}function U(re){return typeof re=="object"&&re!==null&&re.$$typeof===n}function z(re){return C(re)===u}function ne(re){return C(re)===r}function K(re){return C(re)===p}function V(re){return C(re)===w}function X(re){return C(re)===a}function ae(re){return C(re)===l}function ce(re){return C(re)===o}function je(re){return C(re)===b}De.AsyncMode=g,De.ConcurrentMode=f,De.ContextConsumer=S,De.ContextProvider=A,De.Element=P,De.ForwardRef=L,De.Fragment=N,De.Lazy=j,De.Memo=M,De.Portal=k,De.Profiler=F,De.StrictMode=E,De.Suspense=B,De.isAsyncMode=q,De.isConcurrentMode=O,De.isContextConsumer=T,De.isContextProvider=$,De.isElement=U,De.isForwardRef=z,De.isFragment=ne,De.isLazy=K,De.isMemo=V,De.isPortal=X,De.isProfiler=ae,De.isStrictMode=ce,De.isSuspense=je,De.isValidElementType=D,De.typeOf=C})()),De}var lr;function Ji(){return lr||(lr=1,process.env.NODE_ENV==="production"?Hn.exports=fd():Hn.exports=yd()),Hn.exports}var Ha,dr;function hd(){if(dr)return Ha;dr=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 x=Object.getOwnPropertyNames(d).map(function(u){return d[u]});if(x.join("")!=="0123456789")return!1;var m={};return"abcdefghijklmnopqrst".split("").forEach(function(u){m[u]=u}),Object.keys(Object.assign({},m)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Ha=o()?Object.assign:function(l,d){for(var c,x=r(l),m,u=1;u<arguments.length;u++){c=Object(arguments[u]);for(var b in c)n.call(c,b)&&(x[b]=c[b]);if(t){m=t(c);for(var v=0;v<m.length;v++)a.call(c,m[v])&&(x[m[v]]=c[m[v]])}}return x},Ha}var Ka,cr;function Rs(){if(cr)return Ka;cr=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Ka=t,Ka}var Ga,ur;function Qi(){return ur||(ur=1,Ga=Function.call.bind(Object.prototype.hasOwnProperty)),Ga}var Ja,pr;function gd(){if(pr)return Ja;pr=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var n=Rs(),a={},r=Qi();t=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function o(l,d,c,x,m){if(process.env.NODE_ENV!=="production"){for(var u in l)if(r(l,u)){var b;try{if(typeof l[u]!="function"){var v=Error((x||"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 v.name="Invariant Violation",v}b=l[u](d,u,x,c,null,n)}catch(p){b=p}if(b&&!(b instanceof Error)&&t((x||"React class")+": type specification of "+c+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof b+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),b instanceof Error&&!(b.message in a)){a[b.message]=!0;var w=m?m():"";t("Failed "+c+" type: "+b.message+(w??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(a={})},Ja=o,Ja}var Qa,mr;function xd(){if(mr)return Qa;mr=1;var t=Ji(),n=hd(),a=Rs(),r=Qi(),o=gd(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(c){var x="Warning: "+c;typeof console<"u"&&console.error(x);try{throw new Error(x)}catch{}});function d(){return null}return Qa=function(c,x){var m=typeof Symbol=="function"&&Symbol.iterator,u="@@iterator";function b(O){var T=O&&(m&&O[m]||O[u]);if(typeof T=="function")return T}var v="<<anonymous>>",w={array:R("array"),bigint:R("bigint"),bool:R("boolean"),func:R("function"),number:R("number"),object:R("object"),string:R("string"),symbol:R("symbol"),any:I(),arrayOf:D,element:C(),elementType:g(),instanceOf:f,node:L(),objectOf:A,oneOf:S,oneOfType:P,shape:j,exact:M};function p(O,T){return O===T?O!==0||1/O===1/T:O!==O&&T!==T}function y(O,T){this.message=O,this.data=T&&typeof T=="object"?T:{},this.stack=""}y.prototype=Error.prototype;function h(O){if(process.env.NODE_ENV!=="production")var T={},$=0;function U(ne,K,V,X,ae,ce,je){if(X=X||v,ce=ce||V,je!==a){if(x){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=X+":"+V;!T[ie]&&$<3&&(l("You are manually calling a React.PropTypes validation function for the `"+ce+"` prop on `"+X+"`. 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 K[V]==null?ne?K[V]===null?new y("The "+ae+" `"+ce+"` is marked as required "+("in `"+X+"`, but its value is `null`.")):new y("The "+ae+" `"+ce+"` is marked as required in "+("`"+X+"`, but its value is `undefined`.")):null:O(K,V,X,ae,ce)}var z=U.bind(null,!1);return z.isRequired=U.bind(null,!0),z}function R(O){function T($,U,z,ne,K,V){var X=$[U],ae=E(X);if(ae!==O){var ce=B(X);return new y("Invalid "+ne+" `"+K+"` of type "+("`"+ce+"` supplied to `"+z+"`, expected ")+("`"+O+"`."),{expectedType:O})}return null}return h(T)}function I(){return h(d)}function D(O){function T($,U,z,ne,K){if(typeof O!="function")return new y("Property `"+K+"` of component `"+z+"` has invalid PropType notation inside arrayOf.");var V=$[U];if(!Array.isArray(V)){var X=E(V);return new y("Invalid "+ne+" `"+K+"` of type "+("`"+X+"` supplied to `"+z+"`, expected an array."))}for(var ae=0;ae<V.length;ae++){var ce=O(V,ae,z,ne,K+"["+ae+"]",a);if(ce instanceof Error)return ce}return null}return h(T)}function C(){function O(T,$,U,z,ne){var K=T[$];if(!c(K)){var V=E(K);return new y("Invalid "+z+" `"+ne+"` of type "+("`"+V+"` supplied to `"+U+"`, expected a single ReactElement."))}return null}return h(O)}function g(){function O(T,$,U,z,ne){var K=T[$];if(!t.isValidElementType(K)){var V=E(K);return new y("Invalid "+z+" `"+ne+"` of type "+("`"+V+"` supplied to `"+U+"`, expected a single ReactElement type."))}return null}return h(O)}function f(O){function T($,U,z,ne,K){if(!($[U]instanceof O)){var V=O.name||v,X=q($[U]);return new y("Invalid "+ne+" `"+K+"` of type "+("`"+X+"` supplied to `"+z+"`, expected ")+("instance of `"+V+"`."))}return null}return h(T)}function S(O){if(!Array.isArray(O))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($,U,z,ne,K){for(var V=$[U],X=0;X<O.length;X++)if(p(V,O[X]))return null;var ae=JSON.stringify(O,function(je,re){var ie=B(re);return ie==="symbol"?String(re):re});return new y("Invalid "+ne+" `"+K+"` of value `"+String(V)+"` "+("supplied to `"+z+"`, expected one of "+ae+"."))}return h(T)}function A(O){function T($,U,z,ne,K){if(typeof O!="function")return new y("Property `"+K+"` of component `"+z+"` has invalid PropType notation inside objectOf.");var V=$[U],X=E(V);if(X!=="object")return new y("Invalid "+ne+" `"+K+"` of type "+("`"+X+"` supplied to `"+z+"`, expected an object."));for(var ae in V)if(r(V,ae)){var ce=O(V,ae,z,ne,K+"."+ae,a);if(ce instanceof Error)return ce}return null}return h(T)}function P(O){if(!Array.isArray(O))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var T=0;T<O.length;T++){var $=O[T];if(typeof $!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+Y($)+" at index "+T+"."),d}function U(z,ne,K,V,X){for(var ae=[],ce=0;ce<O.length;ce++){var je=O[ce],re=je(z,ne,K,V,X,a);if(re==null)return null;re.data&&r(re.data,"expectedType")&&ae.push(re.data.expectedType)}var ie=ae.length>0?", expected one of type ["+ae.join(", ")+"]":"";return new y("Invalid "+V+" `"+X+"` supplied to "+("`"+K+"`"+ie+"."))}return h(U)}function L(){function O(T,$,U,z,ne){return k(T[$])?null:new y("Invalid "+z+" `"+ne+"` supplied to "+("`"+U+"`, expected a ReactNode."))}return h(O)}function N(O,T,$,U,z){return new y((O||"React class")+": "+T+" type `"+$+"."+U+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+z+"`.")}function j(O){function T($,U,z,ne,K){var V=$[U],X=E(V);if(X!=="object")return new y("Invalid "+ne+" `"+K+"` of type `"+X+"` "+("supplied to `"+z+"`, expected `object`."));for(var ae in O){var ce=O[ae];if(typeof ce!="function")return N(z,ne,K,ae,B(ce));var je=ce(V,ae,z,ne,K+"."+ae,a);if(je)return je}return null}return h(T)}function M(O){function T($,U,z,ne,K){var V=$[U],X=E(V);if(X!=="object")return new y("Invalid "+ne+" `"+K+"` of type `"+X+"` "+("supplied to `"+z+"`, expected `object`."));var ae=n({},$[U],O);for(var ce in ae){var je=O[ce];if(r(O,ce)&&typeof je!="function")return N(z,ne,K,ce,B(je));if(!je)return new y("Invalid "+ne+" `"+K+"` key `"+ce+"` supplied to `"+z+"`.\nBad object: "+JSON.stringify($[U],null," ")+`
9
+ `+l)}}catch{}}throw r}}_request(n,a){typeof n=="string"?(a=a||{},a.url=n):a=n||{},a=Yt(this.defaults,a);const{transitional:r,paramsSerializer:o,headers:l}=a;r!==void 0&&ca.assertOptions(r,{silentJSONParsing:ct.transitional(ct.boolean),forcedJSONParsing:ct.transitional(ct.boolean),clarifyTimeoutError:ct.transitional(ct.boolean),legacyInterceptorReqResOrdering:ct.transitional(ct.boolean)},!1),o!=null&&(H.isFunction(o)?a.paramsSerializer={serialize:o}:ca.assertOptions(o,{encode:ct.function,serialize:ct.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),ca.assertOptions(a,{baseUrl:ct.spelling("baseURL"),withXsrfToken:ct.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let d=l&&H.merge(l.common,l[a.method]);l&&H.forEach(["delete","get","head","post","put","patch","common"],p=>{delete l[p]}),a.headers=et.concat(d,l);const c=[];let x=!0;this.interceptors.request.forEach(function(y){if(typeof y.runWhen=="function"&&y.runWhen(a)===!1)return;x=x&&y.synchronous;const h=a.transitional||ws;h&&h.legacyInterceptorReqResOrdering?c.unshift(y.fulfilled,y.rejected):c.push(y.fulfilled,y.rejected)});const m=[];this.interceptors.response.forEach(function(y){m.push(y.fulfilled,y.rejected)});let u,b=0,v;if(!x){const p=[ar.bind(this),void 0];for(p.unshift(...c),p.push(...m),v=p.length,u=Promise.resolve(a);b<v;)u=u.then(p[b++],p[b++]);return u}v=c.length;let w=a;for(;b<v;){const p=c[b++],y=c[b++];try{w=p(w)}catch(h){y.call(this,h);break}}try{u=ar.call(this,w)}catch(p){return Promise.reject(p)}for(b=0,v=m.length;b<v;)u=u.then(m[b++],m[b++]);return u}getUri(n){n=Yt(this.defaults,n);const a=qi(n.baseURL,n.url,n.allowAbsoluteUrls);return Ni(a,n.params,n.paramsSerializer)}};H.forEach(["delete","get","head","options"],function(n){Lt.prototype[n]=function(a,r){return this.request(Yt(r||{},{method:n,url:a,data:(r||{}).data}))}});H.forEach(["post","put","patch"],function(n){function a(r){return function(l,d,c){return this.request(Yt(c||{},{method:n,headers:r?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}Lt.prototype[n]=a(),Lt.prototype[n+"Form"]=a(!0)});let rd=class Hi{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 Hi(function(o){n=o}),cancel:n}}};function id(t){return function(a){return t.apply(null,a)}}function od(t){return H.isObject(t)&&t.isAxiosError===!0}const Ss={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(Ss).forEach(([t,n])=>{Ss[n]=t});function Ki(t){const n=new Lt(t),a=Ti(Lt.prototype.request,n);return H.extend(a,Lt.prototype,n,{allOwnKeys:!0}),H.extend(a,n,null,{allOwnKeys:!0}),a.create=function(o){return Ki(Yt(t,o))},a}const Ne=Ki($n);Ne.Axios=Lt;Ne.CanceledError=Nn;Ne.CancelToken=rd;Ne.isCancel=Bi;Ne.VERSION=Wi;Ne.toFormData=Oa;Ne.AxiosError=Se;Ne.Cancel=Ne.CanceledError;Ne.all=function(n){return Promise.all(n)};Ne.spread=id;Ne.isAxiosError=od;Ne.mergeConfig=Yt;Ne.AxiosHeaders=et;Ne.formToJSON=t=>Ui(H.isHTMLForm(t)?new FormData(t):t);Ne.getAdapter=Vi.getAdapter;Ne.HttpStatusCode=Ss;Ne.default=Ne;const{Axios:Py,AxiosError:ky,CanceledError:Ey,isCancel:My,CancelToken:Fy,VERSION:$y,all:Ny,Cancel:Uy,isAxiosError:By,spread:Ly,toFormData:qy,AxiosHeaders:zy,HttpStatusCode:Yy,formToJSON:Vy,getAdapter:Wy,mergeConfig:Hy}=Ne,ld=()=>new Promise(t=>setTimeout(()=>t(),800));let js=null;const dd=t=>{js=t,gt.defaults.baseURL=Ts()},Ts=()=>js||"https://npmapi.ubkerp.com/",gt=Ne.create({baseURL:Ts()}),tt=()=>Ts(),ze=async(t,n,a)=>{const r=await gt.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 gt.get(r,{headers:{Authorization:n}})).data}catch(a){throw a.response?.status===401&&console.error("401 Unauthorized"),a}},cd=async(t,n)=>{const a=await gt.post(t,"",{headers:{Authorization:n}});if(a.data?.Status=="Success")return a?.data?.data||a?.data;throw new Error(a.data?.msg)},ka=async(t,n,a)=>(await gt.post(t,n,{headers:{Authorization:a}}))?.data,On=async(t,n,a)=>{const r=n?.arg;return(await gt.post(t,r,{headers:{Authorization:a}}))?.data},qt=async(t,n,a)=>{const r=n?.arg,o=t.includes("?")?"&":"?";return(await gt.get(t+o,{params:r,headers:{Authorization:a}}))?.data},ud="api/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",Is=async(t,n,a)=>{const r=n?.arg,o=t.includes("?")?"&":"?";return(await gt.get(t+o,{params:r,headers:{Authorization:a}}))?.data},pt=async(t,n,a)=>(await ld(),(await gt.post(t,n,{headers:{Authorization:a}}))?.data),nt=async(t,n,a)=>(await gt.delete(`${t}/${n}`,{headers:{Authorization:a}})).data,pd=({token:t,menu:n})=>{const{isLoading:a,data:r}=G(t?["api/sdk/Menus",t]:null,([l,d])=>cd(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(fe,{children:e.jsx(Ai,{icon:`${tt()}icons/frontoffice/${l.icons}`,title:l.submenu_name,path:l.menu_key})})},`${d}office001`):null)})};function Gi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Le={},Wa,rr;function md(){return rr||(rr=1,Wa=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}),Wa}var Wn={exports:{}},Hn={exports:{}},Re={};var ir;function fd(){if(ir)return Re;ir=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,x=t?Symbol.for("react.async_mode"):60111,m=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,b=t?Symbol.for("react.suspense"):60113,v=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,p=t?Symbol.for("react.lazy"):60116,y=t?Symbol.for("react.block"):60121,h=t?Symbol.for("react.fundamental"):60117,R=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function D(g){if(typeof g=="object"&&g!==null){var f=g.$$typeof;switch(f){case n:switch(g=g.type,g){case x:case m:case r:case l:case o:case b:return g;default:switch(g=g&&g.$$typeof,g){case c:case u:case p:case w:case d:return g;default:return f}}case a:return f}}}function C(g){return D(g)===m}return Re.AsyncMode=x,Re.ConcurrentMode=m,Re.ContextConsumer=c,Re.ContextProvider=d,Re.Element=n,Re.ForwardRef=u,Re.Fragment=r,Re.Lazy=p,Re.Memo=w,Re.Portal=a,Re.Profiler=l,Re.StrictMode=o,Re.Suspense=b,Re.isAsyncMode=function(g){return C(g)||D(g)===x},Re.isConcurrentMode=C,Re.isContextConsumer=function(g){return D(g)===c},Re.isContextProvider=function(g){return D(g)===d},Re.isElement=function(g){return typeof g=="object"&&g!==null&&g.$$typeof===n},Re.isForwardRef=function(g){return D(g)===u},Re.isFragment=function(g){return D(g)===r},Re.isLazy=function(g){return D(g)===p},Re.isMemo=function(g){return D(g)===w},Re.isPortal=function(g){return D(g)===a},Re.isProfiler=function(g){return D(g)===l},Re.isStrictMode=function(g){return D(g)===o},Re.isSuspense=function(g){return D(g)===b},Re.isValidElementType=function(g){return typeof g=="string"||typeof g=="function"||g===r||g===m||g===l||g===o||g===b||g===v||typeof g=="object"&&g!==null&&(g.$$typeof===p||g.$$typeof===w||g.$$typeof===d||g.$$typeof===c||g.$$typeof===u||g.$$typeof===h||g.$$typeof===R||g.$$typeof===I||g.$$typeof===y)},Re.typeOf=D,Re}var De={};var or;function yd(){return or||(or=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,x=t?Symbol.for("react.async_mode"):60111,m=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,b=t?Symbol.for("react.suspense"):60113,v=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,p=t?Symbol.for("react.lazy"):60116,y=t?Symbol.for("react.block"):60121,h=t?Symbol.for("react.fundamental"):60117,R=t?Symbol.for("react.responder"):60118,I=t?Symbol.for("react.scope"):60119;function D(re){return typeof re=="string"||typeof re=="function"||re===r||re===m||re===l||re===o||re===b||re===v||typeof re=="object"&&re!==null&&(re.$$typeof===p||re.$$typeof===w||re.$$typeof===d||re.$$typeof===c||re.$$typeof===u||re.$$typeof===h||re.$$typeof===R||re.$$typeof===I||re.$$typeof===y)}function C(re){if(typeof re=="object"&&re!==null){var ie=re.$$typeof;switch(ie){case n:var W=re.type;switch(W){case x:case m:case r:case l:case o:case b:return W;default:var oe=W&&W.$$typeof;switch(oe){case c:case u:case p:case w:case d:return oe;default:return ie}}case a:return ie}}}var g=x,f=m,S=c,A=d,P=n,L=u,N=r,j=p,M=w,k=a,F=l,E=o,B=b,Y=!1;function q(re){return Y||(Y=!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.")),O(re)||C(re)===x}function O(re){return C(re)===m}function T(re){return C(re)===c}function $(re){return C(re)===d}function U(re){return typeof re=="object"&&re!==null&&re.$$typeof===n}function z(re){return C(re)===u}function ne(re){return C(re)===r}function K(re){return C(re)===p}function V(re){return C(re)===w}function X(re){return C(re)===a}function ae(re){return C(re)===l}function ce(re){return C(re)===o}function je(re){return C(re)===b}De.AsyncMode=g,De.ConcurrentMode=f,De.ContextConsumer=S,De.ContextProvider=A,De.Element=P,De.ForwardRef=L,De.Fragment=N,De.Lazy=j,De.Memo=M,De.Portal=k,De.Profiler=F,De.StrictMode=E,De.Suspense=B,De.isAsyncMode=q,De.isConcurrentMode=O,De.isContextConsumer=T,De.isContextProvider=$,De.isElement=U,De.isForwardRef=z,De.isFragment=ne,De.isLazy=K,De.isMemo=V,De.isPortal=X,De.isProfiler=ae,De.isStrictMode=ce,De.isSuspense=je,De.isValidElementType=D,De.typeOf=C})()),De}var lr;function Ji(){return lr||(lr=1,process.env.NODE_ENV==="production"?Hn.exports=fd():Hn.exports=yd()),Hn.exports}var Ha,dr;function hd(){if(dr)return Ha;dr=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 x=Object.getOwnPropertyNames(d).map(function(u){return d[u]});if(x.join("")!=="0123456789")return!1;var m={};return"abcdefghijklmnopqrst".split("").forEach(function(u){m[u]=u}),Object.keys(Object.assign({},m)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Ha=o()?Object.assign:function(l,d){for(var c,x=r(l),m,u=1;u<arguments.length;u++){c=Object(arguments[u]);for(var b in c)n.call(c,b)&&(x[b]=c[b]);if(t){m=t(c);for(var v=0;v<m.length;v++)a.call(c,m[v])&&(x[m[v]]=c[m[v]])}}return x},Ha}var Ka,cr;function Rs(){if(cr)return Ka;cr=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Ka=t,Ka}var Ga,ur;function Qi(){return ur||(ur=1,Ga=Function.call.bind(Object.prototype.hasOwnProperty)),Ga}var Ja,pr;function gd(){if(pr)return Ja;pr=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var n=Rs(),a={},r=Qi();t=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function o(l,d,c,x,m){if(process.env.NODE_ENV!=="production"){for(var u in l)if(r(l,u)){var b;try{if(typeof l[u]!="function"){var v=Error((x||"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 v.name="Invariant Violation",v}b=l[u](d,u,x,c,null,n)}catch(p){b=p}if(b&&!(b instanceof Error)&&t((x||"React class")+": type specification of "+c+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof b+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),b instanceof Error&&!(b.message in a)){a[b.message]=!0;var w=m?m():"";t("Failed "+c+" type: "+b.message+(w??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(a={})},Ja=o,Ja}var Qa,mr;function xd(){if(mr)return Qa;mr=1;var t=Ji(),n=hd(),a=Rs(),r=Qi(),o=gd(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(c){var x="Warning: "+c;typeof console<"u"&&console.error(x);try{throw new Error(x)}catch{}});function d(){return null}return Qa=function(c,x){var m=typeof Symbol=="function"&&Symbol.iterator,u="@@iterator";function b(O){var T=O&&(m&&O[m]||O[u]);if(typeof T=="function")return T}var v="<<anonymous>>",w={array:R("array"),bigint:R("bigint"),bool:R("boolean"),func:R("function"),number:R("number"),object:R("object"),string:R("string"),symbol:R("symbol"),any:I(),arrayOf:D,element:C(),elementType:g(),instanceOf:f,node:L(),objectOf:A,oneOf:S,oneOfType:P,shape:j,exact:M};function p(O,T){return O===T?O!==0||1/O===1/T:O!==O&&T!==T}function y(O,T){this.message=O,this.data=T&&typeof T=="object"?T:{},this.stack=""}y.prototype=Error.prototype;function h(O){if(process.env.NODE_ENV!=="production")var T={},$=0;function U(ne,K,V,X,ae,ce,je){if(X=X||v,ce=ce||V,je!==a){if(x){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=X+":"+V;!T[ie]&&$<3&&(l("You are manually calling a React.PropTypes validation function for the `"+ce+"` prop on `"+X+"`. 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 K[V]==null?ne?K[V]===null?new y("The "+ae+" `"+ce+"` is marked as required "+("in `"+X+"`, but its value is `null`.")):new y("The "+ae+" `"+ce+"` is marked as required in "+("`"+X+"`, but its value is `undefined`.")):null:O(K,V,X,ae,ce)}var z=U.bind(null,!1);return z.isRequired=U.bind(null,!0),z}function R(O){function T($,U,z,ne,K,V){var X=$[U],ae=E(X);if(ae!==O){var ce=B(X);return new y("Invalid "+ne+" `"+K+"` of type "+("`"+ce+"` supplied to `"+z+"`, expected ")+("`"+O+"`."),{expectedType:O})}return null}return h(T)}function I(){return h(d)}function D(O){function T($,U,z,ne,K){if(typeof O!="function")return new y("Property `"+K+"` of component `"+z+"` has invalid PropType notation inside arrayOf.");var V=$[U];if(!Array.isArray(V)){var X=E(V);return new y("Invalid "+ne+" `"+K+"` of type "+("`"+X+"` supplied to `"+z+"`, expected an array."))}for(var ae=0;ae<V.length;ae++){var ce=O(V,ae,z,ne,K+"["+ae+"]",a);if(ce instanceof Error)return ce}return null}return h(T)}function C(){function O(T,$,U,z,ne){var K=T[$];if(!c(K)){var V=E(K);return new y("Invalid "+z+" `"+ne+"` of type "+("`"+V+"` supplied to `"+U+"`, expected a single ReactElement."))}return null}return h(O)}function g(){function O(T,$,U,z,ne){var K=T[$];if(!t.isValidElementType(K)){var V=E(K);return new y("Invalid "+z+" `"+ne+"` of type "+("`"+V+"` supplied to `"+U+"`, expected a single ReactElement type."))}return null}return h(O)}function f(O){function T($,U,z,ne,K){if(!($[U]instanceof O)){var V=O.name||v,X=q($[U]);return new y("Invalid "+ne+" `"+K+"` of type "+("`"+X+"` supplied to `"+z+"`, expected ")+("instance of `"+V+"`."))}return null}return h(T)}function S(O){if(!Array.isArray(O))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($,U,z,ne,K){for(var V=$[U],X=0;X<O.length;X++)if(p(V,O[X]))return null;var ae=JSON.stringify(O,function(je,re){var ie=B(re);return ie==="symbol"?String(re):re});return new y("Invalid "+ne+" `"+K+"` of value `"+String(V)+"` "+("supplied to `"+z+"`, expected one of "+ae+"."))}return h(T)}function A(O){function T($,U,z,ne,K){if(typeof O!="function")return new y("Property `"+K+"` of component `"+z+"` has invalid PropType notation inside objectOf.");var V=$[U],X=E(V);if(X!=="object")return new y("Invalid "+ne+" `"+K+"` of type "+("`"+X+"` supplied to `"+z+"`, expected an object."));for(var ae in V)if(r(V,ae)){var ce=O(V,ae,z,ne,K+"."+ae,a);if(ce instanceof Error)return ce}return null}return h(T)}function P(O){if(!Array.isArray(O))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var T=0;T<O.length;T++){var $=O[T];if(typeof $!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+Y($)+" at index "+T+"."),d}function U(z,ne,K,V,X){for(var ae=[],ce=0;ce<O.length;ce++){var je=O[ce],re=je(z,ne,K,V,X,a);if(re==null)return null;re.data&&r(re.data,"expectedType")&&ae.push(re.data.expectedType)}var ie=ae.length>0?", expected one of type ["+ae.join(", ")+"]":"";return new y("Invalid "+V+" `"+X+"` supplied to "+("`"+K+"`"+ie+"."))}return h(U)}function L(){function O(T,$,U,z,ne){return k(T[$])?null:new y("Invalid "+z+" `"+ne+"` supplied to "+("`"+U+"`, expected a ReactNode."))}return h(O)}function N(O,T,$,U,z){return new y((O||"React class")+": "+T+" type `"+$+"."+U+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+z+"`.")}function j(O){function T($,U,z,ne,K){var V=$[U],X=E(V);if(X!=="object")return new y("Invalid "+ne+" `"+K+"` of type `"+X+"` "+("supplied to `"+z+"`, expected `object`."));for(var ae in O){var ce=O[ae];if(typeof ce!="function")return N(z,ne,K,ae,B(ce));var je=ce(V,ae,z,ne,K+"."+ae,a);if(je)return je}return null}return h(T)}function M(O){function T($,U,z,ne,K){var V=$[U],X=E(V);if(X!=="object")return new y("Invalid "+ne+" `"+K+"` of type `"+X+"` "+("supplied to `"+z+"`, expected `object`."));var ae=n({},$[U],O);for(var ce in ae){var je=O[ce];if(r(O,ce)&&typeof je!="function")return N(z,ne,K,ce,B(je));if(!je)return new y("Invalid "+ne+" `"+K+"` key `"+ce+"` supplied to `"+z+"`.\nBad object: "+JSON.stringify($[U],null," ")+`
10
10
  Valid keys: `+JSON.stringify(Object.keys(O),null," "));var re=je(V,ce,z,ne,K+"."+ce,a);if(re)return re}return null}return h(T)}function k(O){switch(typeof O){case"number":case"string":case"undefined":return!0;case"boolean":return!O;case"object":if(Array.isArray(O))return O.every(k);if(O===null||c(O))return!0;var T=b(O);if(T){var $=T.call(O),U;if(T!==O.entries){for(;!(U=$.next()).done;)if(!k(U.value))return!1}else for(;!(U=$.next()).done;){var z=U.value;if(z&&!k(z[1]))return!1}}else return!1;return!0;default:return!1}}function F(O,T){return O==="symbol"?!0:T?T["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&T instanceof Symbol:!1}function E(O){var T=typeof O;return Array.isArray(O)?"array":O instanceof RegExp?"object":F(T,O)?"symbol":T}function B(O){if(typeof O>"u"||O===null)return""+O;var T=E(O);if(T==="object"){if(O instanceof Date)return"date";if(O instanceof RegExp)return"regexp"}return T}function Y(O){var T=B(O);switch(T){case"array":case"object":return"an "+T;case"boolean":case"date":case"regexp":return"a "+T;default:return T}}function q(O){return!O.constructor||!O.constructor.name?v:O.constructor.name}return w.checkPropTypes=o,w.resetWarningCache=o.resetWarningCache,w.PropTypes=w,w},Qa}var Xa,fr;function bd(){if(fr)return Xa;fr=1;var t=Rs();function n(){}function a(){}return a.resetWarningCache=n,Xa=function(){function r(d,c,x,m,u,b){if(b!==t){var v=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 v.name="Invariant Violation",v}}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},Xa}var yr;function Xi(){if(yr)return Wn.exports;if(yr=1,process.env.NODE_ENV!=="production"){var t=Ji(),n=!0;Wn.exports=xd()(t.isElement,n)}else Wn.exports=bd()();return Wn.exports}var hr;function Sd(){if(hr)return Le;hr=1;var t=Le&&Le.__extends||(function(){var w=function(p,y){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,R){h.__proto__=R}||function(h,R){for(var I in R)Object.prototype.hasOwnProperty.call(R,I)&&(h[I]=R[I])},w(p,y)};return function(p,y){if(typeof y!="function"&&y!==null)throw new TypeError("Class extends value "+String(y)+" is not a constructor or null");w(p,y);function h(){this.constructor=p}p.prototype=y===null?Object.create(y):(h.prototype=y.prototype,new h)}})(),n=Le&&Le.__assign||function(){return n=Object.assign||function(w){for(var p,y=1,h=arguments.length;y<h;y++){p=arguments[y];for(var R in p)Object.prototype.hasOwnProperty.call(p,R)&&(w[R]=p[R])}return w},n.apply(this,arguments)},a=Le&&Le.__createBinding||(Object.create?(function(w,p,y,h){h===void 0&&(h=y);var R=Object.getOwnPropertyDescriptor(p,y);(!R||("get"in R?!p.__esModule:R.writable||R.configurable))&&(R={enumerable:!0,get:function(){return p[y]}}),Object.defineProperty(w,h,R)}):(function(w,p,y,h){h===void 0&&(h=y),w[h]=p[y]})),r=Le&&Le.__setModuleDefault||(Object.create?(function(w,p){Object.defineProperty(w,"default",{enumerable:!0,value:p})}):function(w,p){w.default=p}),o=Le&&Le.__importStar||function(w){if(w&&w.__esModule)return w;var p={};if(w!=null)for(var y in w)y!=="default"&&Object.prototype.hasOwnProperty.call(w,y)&&a(p,w,y);return r(p,w),p},l=Le&&Le.__rest||function(w,p){var y={};for(var h in w)Object.prototype.hasOwnProperty.call(w,h)&&p.indexOf(h)<0&&(y[h]=w[h]);if(w!=null&&typeof Object.getOwnPropertySymbols=="function")for(var R=0,h=Object.getOwnPropertySymbols(w);R<h.length;R++)p.indexOf(h[R])<0&&Object.prototype.propertyIsEnumerable.call(w,h[R])&&(y[h[R]]=w[h[R]]);return y},d=Le&&Le.__importDefault||function(w){return w&&w.__esModule?w:{default:w}};Object.defineProperty(Le,"__esModule",{value:!0});var c=o(i),x=d(md()),m=o(Xi());function u(w){return w&&w.replace(/&nbsp;|\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function b(w){var p=document.createTextNode("");w.appendChild(p);var y=document.activeElement===w;if(p!==null&&p.nodeValue!==null&&y){var h=window.getSelection();if(h!==null){var R=document.createRange();R.setStart(p,p.nodeValue.length),R.collapse(!0),h.removeAllRanges(),h.addRange(R)}w instanceof HTMLElement&&w.focus()}}var v=(function(w){t(p,w);function p(){var y=w!==null&&w.apply(this,arguments)||this;return y.lastHtml=y.props.html,y.el=typeof y.props.innerRef=="function"?{current:null}:c.createRef(),y.getEl=function(){return(y.props.innerRef&&typeof y.props.innerRef!="function"?y.props.innerRef:y.el).current},y.emitChange=function(h){var R=y.getEl();if(R){var I=R.innerHTML;if(y.props.onChange&&I!==y.lastHtml){var D=Object.assign({},h,{target:{value:I}});y.props.onChange(D)}y.lastHtml=I}},y}return p.prototype.render=function(){var y=this,h=this.props,R=h.tagName,I=h.html,D=h.innerRef,C=l(h,["tagName","html","innerRef"]);return c.createElement(R||"div",n(n({},C),{ref:typeof D=="function"?function(g){D(g),y.el.current=g}: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:I}}),this.props.children)},p.prototype.shouldComponentUpdate=function(y){var h=this.props,R=this.getEl();return!R||u(y.html)!==u(R.innerHTML)?!0:h.disabled!==y.disabled||h.tagName!==y.tagName||h.className!==y.className||h.innerRef!==y.innerRef||h.placeholder!==y.placeholder||!(0,x.default)(h.style,y.style)},p.prototype.componentDidUpdate=function(){var y=this.getEl();y&&(this.props.html!==y.innerHTML&&(y.innerHTML=this.props.html),this.lastHtml=this.props.html,b(y))},p.propTypes={html:m.string.isRequired,onChange:m.func,disabled:m.bool,tagName:m.string,className:m.string,style:m.object,innerRef:m.oneOfType([m.object,m.func])},p})(c.Component);return Le.default=v,Le}var jd=Sd();const Zi=Gi(jd),vd={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},_d={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:vd,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:{..._d,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})}),gr=[{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 Ds(t){const n=se().year(),a=[];for(let r=n;r>=n-t;r--)a.push({label:String(r),value:r});return a}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 Os(t){const n=se().year(),a=se().month();return t<n?gr:gr.slice(0,a+1)}function xr(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 wd(){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 eo=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 fn={},yn={},st={},hn={},Jt={},br;function Cd(){if(br)return Jt;br=1;var t=Jt&&Jt.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Jt,"__esModule",{value:!0});const n=t(i),a=Co,r=["string","number","boolean"];function o({header:l,body:d}){const c=n.default.createElement("tr",null,l.map(m=>n.default.createElement("th",{key:m},m))),x=d.map((m,u)=>Array.isArray(m)?n.default.createElement("tr",{key:u},m.map((b,v)=>n.default.createElement("th",{key:v}," ",b," "))):m!==null&&typeof m=="object"?n.default.createElement("tr",{key:u},Object.entries(m).map(([b,v],w)=>typeof v=="object"?(console.error(`typeof ${b} is incorrect, only accept ${r.join(", ")} `),n.default.createElement("th",{key:w})):n.default.createElement("th",{key:w},n.default.createElement(n.default.Fragment,null,v)))):(console.error(`
11
11
  data structure is incorrect,
12
12
  data structure type ->
@@ -56,6 +56,6 @@ Valid keys: `+JSON.stringify(Object.keys(O),null," "));var re=je(V,ce,z,ne,K+".
56
56
  .ubk-table-shell .ant-pagination .ant-pagination-next button:hover {
57
57
  color: #8f99ff;
58
58
  }
59
- `}),e.jsx(fe,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(Ea,{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:O.rowsPerPage,onChange:te=>U(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:k,onChange:te=>{F(te.target.value),T(ue=>({...ue,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(jt,{})}),he]}),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 ${me} to ${xe} of ${We} entries`}),e.jsx(s.Pagination,{current:O.page,pageSize:O.rowsPerPage,total:We||0,showSizeChanger:!1,onChange:U})]})]})]})},Od=({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:x,error:m}=G(t?[d,t]:null,([I,D])=>Q(I,D)),[u,b]=i.useState(!1),v=(I,D)=>{r({page:I,rowsPerPage:parseInt(D)})},w=async I=>{},p=I=>{console.log("dsdsdsdsd",I),b(I)},y=()=>{},h=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],R=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(I,D)=>I.name.localeCompare(D.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(I,D)=>(I.contact||"").localeCompare(D.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(I,D)=>(I.description||"").localeCompare(D.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(I,D)=>(I.source_name||"").localeCompare(D.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(I,D)=>new Date(I.date)-new Date(D.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(I,D)=>new Date(I.follow_up_date)-new Date(D.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Be,{parentCallback:v,data:{newData:x,columns:R,action:!0,Loading:c,error:m,open:u,viewDetails:y,deleteTodoMutation:w,DrawerUpdate:p,ActionView:h}})})},Pd={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"},le=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:{...Pd,opacity:a?.7:1,cursor:a?"not-allowed":"pointer",...r||{}}})})),it=({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(Z.DeleteOutlined,{}),size:"small"})})},at=t=>({optimisticData:n=>[...n.data,t],populateCache:(n,a)=>[...a.data,n]}),Je=t=>({optimisticData:n=>n.data.filter(a=>a.id!==t),populateCache:(n,a)=>a.data.filter(r=>r.id!==t)}),wr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function kd({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}`,x="api/branchapi/Transport/addroute",m="api/branchapi/Transport/editroute",u="api/branchapi/Transport/deleteroute",{isLoading:b,data:v,error:w,mutate:p}=G(t?[c,t]:null,([A,P])=>Q(A,P)),y=async(A,P)=>{try{await p(ze(A,P,t),at(P)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},h=A=>{A.preventDefault();const P=new FormData(A.target);y(x,P),A.target.reset()},R=(A,P)=>{a(L=>({...L,pagination:{current:A,pageSize:parseInt(P,10)}}))},I=async A=>{try{await p(nt(u,A,t),Je(A)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},D=A=>{d(A),o(!0)},C=async A=>{try{await pt(m,A,t),await p(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},g=async A=>{A.preventDefault();const P=new FormData(A.target);P.append("id",l?.id),C(P)},f=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(A,P)=>A.name.localeCompare(P.route_title)}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(A,P)=>A.fare-P.fare}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(A,P)=>A.note.localeCompare(P.note)}},{title:"Action",key:"action",render:(A,P)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>D(P),style:{padding:2}}),e.jsx(it,{id:P?.id,funcName:I})]})}],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:g,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(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:wr,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(fe,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsx("div",{children:e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Route"})}),e.jsx(fe,{px:3,pb:2,children:e.jsx("form",{onSubmit:h,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(le,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",style:wr,children:"Cancel"})]})]})})})]})}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Route List"})}),e.jsx(fe,{children:e.jsx(Be,{parentCallback:R,data:{newData:v,columns:f,columnstype:"antd",action:!1,Loading:b,error:w,deleteTodoMutation:I}})})]})})]})})]})}const Cr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Ed({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}`,x="api/branchapi/Transport/addvehicles",m="api/branchapi/Transport/editvehicle",u="api/branchapi/Transport/deletevehicle",{isLoading:b,data:v,error:w,mutate:p}=G(t?[c,t]:null,([A,P])=>Q(A,P)),y=async(A,P)=>{try{await p(ze(A,P,t),at(P)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},h=A=>{A.preventDefault();const P=new FormData(A.target);y(x,P),A.target.reset()},R=async A=>{try{await p(nt(u,A,t),Je(A)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},I=A=>{d(A),o(!0)},D=async A=>{try{await pt(m,A,t),await p(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},C=async A=>{A.preventDefault();const P=new FormData(A.target);P.append("id",l?.id),D(P)},g=(A,P)=>{a({page:A,rowsPerPage:parseInt(P,10)})},f=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(A,P)=>A.vehicle_no.localeCompare(P.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(A,P)=>A.vehicle_model.localeCompare(P.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(A,P)=>A.seating_capacity-P.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(A,P)=>A.manufacture_year-P.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(A,P)=>A.gps_url.localeCompare(P.gps_url)},render:(A,P)=>e.jsx("span",{title:P?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:P?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(A,P)=>A.note.localeCompare(P.note)}},{title:"Action",key:"action",render:(A,P)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>I(P),style:{padding:2}}),e.jsx(it,{id:P?.id,funcName:R})]})}],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:C,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(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Cr,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(fe,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(fe,{px:3,pb:2,children:e.jsx("form",{onSubmit:h,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(le,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",style:Cr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(fe,{children:e.jsx(Be,{parentCallback:g,data:{newData:v,columns:f,columnstype:"antd",action:!1,Loading:b,error:w,deleteTodoMutation:R}})})]})})]})})]})}var Md=Xi();const Za=Gi(Md),ao=()=>{};class Ps 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:ao,onFocus:()=>this.selectRef.focus(),required:a})]})}}Ps.defaultProps={onChange:ao};Ps.protoTypes={selectComponent:Za.func.isRequired,onChange:Za.func,required:Za.bool};const Fd={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},$d={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"})},so=t=>e.jsx(wi.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),Nd=t=>e.jsx(Ps,{...t,SelectComponent:wi,components:{Input:so},options:t.options}),ee=i.forwardRef(({...t},n)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:Fd,children:t?.label}),e.jsx(Nd,{components:{Input:so},menuPortalTarget:document.body,styles:$d,className:"input-cont",...t,ref:n})]})),Ud={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ar=({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 Bd({token:t}){const[n,a]=i.useState(!1),[r,o]=i.useState({pagination:{current:1,pageSize:50}}),[l,d]=i.useState(null),[c,x]=i.useState([]),m="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleDropdown",b="api/branchapi/Transport/getchechkedVehicleData",v="api/branchapi/Transport/assignedVehicleTable",w="api/branchapi/transport/assignvehicle",p="api/branchapi/Transport/deleteassignvehicle",y=l?`${b}?route_id=${l}`:null,{isLoading:h,data:R,mutate:I}=G(t?[`${v}?page=${r.pagination.current}&per_page=${r.pagination.pageSize}`,t]:null,([T,$])=>Q(T,$)),{data:D}=G(t&&m?[m,t]:null,([T,$])=>Q(T,$)),{data:C}=G(t&&u?[u,t]:null,([T,$])=>Q(T,$)),g=t&&y?[y,t]:null,{isLoading:f,data:S}=G(g,([T,$])=>Q(T,$)),{Status:A="Failed",pagination:{total_rows:P=0}={}}=R||{},{data:L=[]}=A==="Success"?R:{},N=i.useMemo(()=>{const T=D?.data??D??[];return Array.isArray(T)?T:[]},[D]),j=i.useMemo(()=>{const T=C?.data??C??[];return(Array.isArray(T)?T:[]).map(U=>{if(U==null)return null;if(typeof U=="string"||typeof U=="number")return{label:String(U),value:U};const z=U.value??U.vehicle_id??U.id??U.vehicleID,ne=U.label??U.vehicle_name??U.vehicle_no??U.vehicle_number??U.name??String(z??"");return z==null||ne===""?null:{label:String(ne),value:z}}).filter(Boolean)},[C]),M=i.useMemo(()=>{const T=S?.data??S??[];return(Array.isArray(T)?T:[]).map(U=>U?.value??U?.vehicle_id??U?.id??U).filter(U=>U!=null)},[S]);i.useEffect(()=>{x(M)},[M,n]);const k=async(T,$,U)=>{try{await I(ze(T,$,t),at($)),y&&G.mutate(g),a(z=>!z),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(z){_.error(z?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},F=T=>{T.preventDefault();const $=new FormData;$.append("route_id",l??""),c.length?c.forEach(U=>$.append("vehicle_ids[]",U)):$.append("vehicle_ids[]",""),k(w,$)},E=T=>{o($=>({...$,pagination:{current:T,pageSize:$.pagination.pageSize}}))},B=async T=>{try{await I(nt(p,T,t),Je(T)),y&&G.mutate(g),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},Y=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(T,$,U)=>e.jsx(e.Fragment,{children:$.children.map((z,ne,K)=>e.jsx("span",{children:`${z.vehicle_name} ${ne+1===K.length?"":","}`},`${ne}vehicle001`))})},{title:"Action",render:(T,$,U)=>e.jsx(e.Fragment,{children:e.jsx(it,{id:$?.route_id,funcName:B})})}],q=T=>{const $=["route_id","index"];for(let U=0;U<$.length;U++)if(T[$[U]])return T[$[U]]},O=T=>{const{children:$=[]}=T||{},U=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:z=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:z=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:z=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:z=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:z=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:z=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:z=>({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:Ar}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:U,rowKey:z=>q(z)+"cell01",dataSource:$,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(fe,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(fe,{px:3,pb:2,children:e.jsx("form",{onSubmit:F,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:N,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:j,value:c,onChange:T=>x(T),disabled:!l||f})},`check001${n}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),x([]),a(T=>!T)},style:Ud,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(fe,{style:{padding:"10px 16px"},children:e.jsx(s.Table,{components:{body:{cell:Ar}},columns:Y,bordered:!0,rowKey:T=>q(T),dataSource:Array.isArray(L)?L:[],loading:h,expandable:{expandedRowRender:O,childrenColumnName:"changed"},pagination:{current:r.pagination.current,pageSize:r.pagination.pageSize,total:P,showSizeChanger:!0,onChange:E,onShowSizeChange:(T,$)=>{o(U=>({...U,pagination:{current:1,pageSize:$}}))},showTotal:(T,$)=>`${$[0]}-${$[1]} of ${T} items`}})})]})})]})})]})}const Ld={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},qd={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},zd=(t,n,a)=>n?t>se(a).endOf("day")||t<se(n).endOf("day"):!1,Aa=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:Ld,children:r.Desplay}),e.jsx(s.DatePicker,{...r,style:{...qd,...r.style||{}},className:"form-group",disabledDate:o=>zd(o,r.sessionStart||r.minDate?.subtract(1,"day").format("YYYY-MM-DD"),r.sessionEnd||r.maxDate?.format("YYYY-MM-DD")),required:!0,ref:a})]})}),Tr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},es=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Qt=(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})},Yd=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Vd=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 Wd({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",x="api/branchapi/Transport/getvehicleListByRouteIdwithCount",m="api/branchapi/Transport/getStoppageDropdown",u="api/branchapi/Transport/routeShowdata",[b,v]=i.useState(null),[w,p]=i.useState(null),[y,h]=i.useState(null),[R,I]=i.useState(se()),[D,C]=i.useState(""),[g,f]=i.useState(0),[S,A]=i.useState(0),{data:P,isLoading:L}=G(t&&n?[`${l}?id=${n}`,t]:null,([W,oe])=>Q(W,oe)),N=i.useMemo(()=>{if(!P||P?.Status&&P.Status!=="Success")return null;const W=P?.data??P;return Array.isArray(W)?W[0]??null:W},[P]);i.useEffect(()=>{const W=N?.fk_route_id??N?.route_id;W!=null&&v(W),N?.vehicle_id!=null&&p(N.vehicle_id),N?.stop_id!=null&&h(N.stop_id),I(N?.start_date?se(N.start_date):se()),C(Vd(N?.service_push))},[N]);const j=t&&b?`${x}?route_id=${b}`:null,M=t&&b?`${u}?id=${b}`:null,k=t&&b?`${m}?route_id=${b}`:null,{data:F}=G(t&&c?[c,t]:null,([W,oe])=>Q(W,oe)),{data:E,isLoading:B}=G(j?[j,t]:null,([W,oe])=>Q(W,oe)),{data:Y,isLoading:q}=G(k?[k,t]:null,([W,oe])=>Q(W,oe)),{data:O}=G(M?[M,t]:null,([W,oe])=>Q(W,oe)),T=i.useMemo(()=>es(F),[F]),$=i.useMemo(()=>es(E),[E]),U=i.useMemo(()=>es(Y),[Y]),z=P?.data[0]?.rootCost,ne=Yd(),K=a||[N?.firstname,N?.lastname].filter(Boolean).join(" ")||"",V=(W,oe)=>{switch(oe){case"route_id":v(W?.value??null),p(null),h(null),f(Ce=>Ce+1),A(Ce=>Ce+1);break;case"vehicle_id":p(W?.value??null),h(null),A(Ce=>Ce+1);break;case"stop_id":h(W?.value??null);break}},X=async W=>{if(W.preventDefault(),!b||!w||!y){_.error("Please select Route, Vehicle and Stop",{duration:1200});return}const oe=new FormData;oe.append("id",String(n)),oe.append("student_id",String(N?.fk_student_id??N?.student_id??"")),oe.append("fk_route_id",String(b)),oe.append("vehicle_id",String(w)),oe.append("stop_id",String(y)),oe.append("rootCost",String(z??"")),oe.append("start_date",R?.isValid?.()?R.format("YYYY-MM-DD"):se().format("YYYY-MM-DD")),oe.append("puse_service",String(D??""));try{await pt(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(L||!(N&&!L&&(!b||!B&&!q)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(s.Spin,{})});if(!N)return e.jsxs("div",{style:{padding:"8px 0"},children:[e.jsx("p",{style:{color:"#666",fontSize:14,marginBottom:16},children:"Unable to load assignment details. Please try again."}),e.jsx(s.Button,{type:"text",onClick:r,style:Tr,children:"Close"})]});const ce=N.fk_route_id??N.route_id,je=Qt(T,ce,N.route_title),re=Qt($,N.vehicle_id,N.vehicle_name??N.vehicle_no),ie=Qt(U,N.stop_id,N.stop_name??N.stoppage_name);return e.jsx("form",{onSubmit:X,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"title",label:"Student",defaultValue:K,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:N.fk_student_id??N.student_id??""}),e.jsx(ee,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:Qt(T,b,je?.label)??null,onChange:W=>V(W,"route_id")}),e.jsx(ee,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:Qt($,w,re?.label)??null,onChange:W=>V(W,"vehicle_id")},`edit-vehicle-${g}`),e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:Qt(U,y,ie?.label)??null,onChange:W=>V(W,"stop_id")},`edit-stop-${S}`),e.jsx(J,{type:"text",label:"Route Cost",value:z!=null?`${ne}${z}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:z??""}),e.jsx(Aa,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:R,onChange:W=>I(W)}),e.jsx(J,{type:"text",label:"Pause Service",value:D,onChange:W=>C(W?.target?.value??""),placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:r,style:Tr,children:"Cancel"})]})]})},`edit-${n}-${g}`)}const Ir={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Hd=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[]},gn=t=>Hd(t),Kd=t=>t||"",Gd=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Jd=t=>{const n=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return n==="page"||n==="sendpage"?"page":"drawer"},Qd=(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 Xd({token:t,editType:n,onNavigate:a,editPagePath:r}){const l=Jd(n)==="drawer",d="api/branchapi/academy/classdropdownlist",c="api/branchapi/academy/sectionoftheClass",x="api/branchapi/Transport/routeStudentList",m="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleListByRouteIdwithCount",b="api/branchapi/Transport/getStoppageDropdown",v="api/branchapi/Transport/routeShowdata",w="api/branchapi/Transport/assignTransportRoutesStudent",p="api/branchapi/transport/removeStudentTransport",[y,h]=i.useState(null),[R,I]=i.useState(!1),[D,C]=i.useState(!1),[g,f]=i.useState(null),[S,A]=i.useState(null),[P,L]=i.useState(null),[N,j]=i.useState(null),[M,k]=i.useState(!1),[F,E]=i.useState(!1),[B,Y]=i.useState({page:1,rowsPerPage:50}),[q,O]=i.useState(null),[T,$]=i.useState(!1),[U,z]=i.useState(null),[ne,K]=i.useState(null),[V,X]=i.useState(null),[ae,ce]=i.useState(null),[je,re]=i.useState(null),[ie,W]=i.useState(null),[oe,Ce]=i.useState(null),[Pe,ke]=i.useState(se()),[Me,Oe]=i.useState(""),Ve=(ge,ve)=>{const dt=ge?.value??null;switch(ve){case"class_id":X(dt),ce(null),O(dt?`${c}?class_id=${encodeURIComponent(String(dt))}`:null),I(Nt=>!Nt);break;case"route_id":re(dt),W(null),Ce(null),K(dt),A(dt?`${u}?route_id=${encodeURIComponent(String(dt))}`:null),L(dt?`${v}?id=${encodeURIComponent(String(dt))}`:null),j(null),k(Nt=>!Nt),E(Nt=>!Nt);break;case"vehicle_id":W(dt),Ce(null),j(je?`${b}?route_id=${encodeURIComponent(String(je))}`:null),E(Nt=>!Nt);break;case"stop_id":Ce(dt);break}},We=ge=>{if(l){f(ge),C(!0);return}const ve=Qd(ge,r);if(typeof a=="function"){a(ve,ge);return}typeof window<"u"&&ve&&window.location.assign(ve)},Fe=()=>{C(!1),f(null)},Ye=g?`Edit — ${g.firstname??""} ${g.lastname??""}`.trim():"Edit Student Transport",{data:lt}=G(t&&d?[d,t]:null,([ge,ve])=>Q(ge,ve)),{data:me}=G(t&&q?[q,t]:null,([ge,ve])=>Q(ge,ve)),{data:xe}=G(t&&S?[S,t]:null,([ge,ve])=>Q(ge,ve)),{data:he}=G(t&&N?[N,t]:null,([ge,ve])=>Q(ge,ve)),{data:te}=G(t&&P?[P,t]:null,([ge,ve])=>Q(ge,ve)),{data:ue}=G(t&&m?[m,t]:null,([ge,ve])=>Q(ge,ve)),ye=t&&y?`${y}&page=${B.page}&per_page=${B.rowsPerPage}`:null,{isLoading:Te,error:Ie,data:yt,mutate:_t}=G(ye?[ye,t]:null,([ge,ve])=>Q(ge,ve)),wt=i.useMemo(()=>gn(lt),[lt]),Wt=i.useMemo(()=>gn(me),[me]),Ht=i.useMemo(()=>gn(xe),[xe]),Kt=i.useMemo(()=>gn(he),[he]),de=i.useMemo(()=>gn(ue),[ue]),be=te?.data?.[0]?.fare??te?.data?.fare??te?.fare??te?.data?.data?.[0]?.fare??te?.data?.data?.fare;console.log("aaaaaaaaaaaa",te),i.useEffect(()=>{be==null||be===""||Oe(String(be))},[be]);const Ke=async ge=>{try{await _t(nt(p,ge,t),Je(ge)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},bt=[{title:"Route Status",key:"route_status",render:(ge,ve)=>ve.fk_route_id?e.jsx("span",{children:ve.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(ge,ve)=>Kd(ve.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:(ge,ve)=>`${ve.firstname} ${ve.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(ge,ve)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:ve.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(it,{id:ve?.id,funcName:Ke}),e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>We(ve),style:{padding:2}})]}):e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.PlusOutlined,{}),onClick:()=>Ft(ve.student_id),style:{padding:2}})})}],pe=async(ge,ve)=>{try{await _t(ze(ge,ve,t),at(ve)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),$(!1),$t()}catch{_.error("Failed to add the new item.",{duration:1e3})}},_e=ge=>{if(ge.preventDefault(),!V||!ae){_.error("Please select Class and Section",{duration:1200});return}h(`${x}?cID=${encodeURIComponent(String(V))}&sID=${encodeURIComponent(String(ae))}`),Y(ve=>({...ve,page:1}))},$e=(ge,ve)=>{Y({page:ge,rowsPerPage:parseInt(ve,10)})},Ft=ge=>{z(ge),$(!0)},pn=ge=>{if(ge.preventDefault(),!U){_.error("Student is required",{duration:1200});return}if(!je||!ie||!oe){_.error("Please select Route, Vehicle and Stop",{duration:1300});return}const ve=new FormData;ve.append("student_id",String(U)),ve.append("fk_route_id",String(je)),ve.append("vehicle_id",String(ie)),ve.append("stop_id",String(oe)),ve.append("start_date",Pe?.isValid?.()?Pe.format("YYYY-MM-DD"):se().format("YYYY-MM-DD")),ve.append("rootCost",String(Me??"")),pe(w,ve)},$t=()=>{$(!1),A(null),L(null),j(null),K(null),re(null),W(null),Ce(null),ke(se()),Oe(""),k(ge=>!ge),E(ge=>!ge)},wo=Gd();return e.jsxs("div",{children:[l&&e.jsx(s.Drawer,{open:D,title:Ye,placement:"right",width:420,destroyOnClose:!0,onClose:Fe,children:g?.id&&e.jsx(Wd,{token:t,assignmentId:g.id,studentName:`${g.firstname??""} ${g.lastname??""}`.trim(),onClose:Fe,onSuccess:()=>_t()})}),e.jsx(s.Modal,{open:T,title:"Assign Student to Transport",onCancel:$t,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:pn,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20},children:[e.jsx(ee,{options:de,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:de.find(ge=>String(ge.value)===String(je))??null,onChange:ge=>Ve(ge,"route_id")}),e.jsx(ee,{options:Ht,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:Ht.find(ge=>String(ge.value)===String(ie))??null,onChange:ge=>Ve(ge,"vehicle_id")},`vehicle001${M}`),e.jsx(ee,{options:Kt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:Kt.find(ge=>String(ge.value)===String(oe))??null,onChange:ge=>Ve(ge,"stop_id")},`stop001${F}`),e.jsx(Aa,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:Pe,onChange:ge=>ke(ge)}),e.jsx(J,{type:"text",name:"rootCost",label:"Route Cost",value:Me,onChange:ge=>Oe(ge?.target?.value??"")}),e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:String(Me??"").trim()?`${wo}${Me} — Assign`:"Assign",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:$t,style:Ir,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(fe,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Search Students"})}),e.jsx(fe,{px:3,pb:2,children:e.jsx("form",{onSubmit:_e,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:wt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:ge=>Ve(ge,"class_id"),required:!0,allowSelectAll:!1,value:wt.find(ge=>String(ge.value)===String(V))??null}),e.jsx(ee,{options:Wt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:Wt.find(ge=>String(ge.value)===String(ae))??null,onChange:ge=>ce(ge?.value??null)},`section1${R}`),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:"Search",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{h(null),O(null),X(null),ce(null),I(ge=>!ge)},style:Ir,children:"Cancel"})]})]})})})]}),y&&e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Student List"})}),e.jsx(fe,{children:e.jsx(Be,{parentCallback:$e,data:{newData:yt,columns:bt,columnstype:"antd",action:!1,Loading:Te,error:Ie,deleteTodoMutation:Ke,pageController:B}})})]})})]})})]})}const Rr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Kn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function Zd({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),[m,u]=i.useState(""),[b,v]=i.useState(""),[w,p]=i.useState(!1),y=`api/branchapi/Transport/getdriverTable?page=${n.page}&per_page=${n.rowsPerPage}`,h="api/branchapi/Transport/add_driver",R="api/branchapi/Transport/edit_driver",I="api/branchapi/Transport/deletedriver",D="api/branchapi/staff/uploadDocuments",C=i.useMemo(()=>String(D).startsWith("http")?D:`${tt()??""}${String(D).replace(/^\/+/,"")}`,[D]),g=tt()??"",{isLoading:f,data:S,error:A,mutate:P}=G(t?[y,t]:null,([q,O])=>Q(q,O)),L=async(q,O)=>{try{await ze(q,O,t),await P(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),x("")}catch(T){_.error(T?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},N=q=>{q.preventDefault();const O=new FormData(q.target);L(h,O),q.target.reset()},j=async q=>{try{await P(nt(I,q,t),Je(q)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},M=q=>{d(q),x(q?.image??""),o(!0)},k=async q=>{try{await pt(R,q,t),await P(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(O){_.error(O?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},F=q=>{q.preventDefault();const O=new FormData(q.target);O.append("id",l?.id??""),k(O)},E=(q,O)=>{a({page:q,rowsPerPage:parseInt(O,10)})},B=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(q,O)=>String(q?.name??"").localeCompare(String(O?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(q,O)=>String(q?.Driver_licence??"").localeCompare(String(O?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(q,O)=>Number(q?.contact_number??0)-Number(O?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(q,O)=>String(q?.address??"").localeCompare(String(O?.address??""))}},{title:"Image",key:"image",width:100,render:(q,O)=>{const T=O?.image?`${g}staff/document/${O.image}`:"";return T?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(s.Image,{width:80,src:T,preview:{visible:!1,onVisibleChange:()=>{p(!0),u(T),v(O?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(q,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>M(O),style:{padding:2}}),e.jsx(it,{id:O?.id,funcName:j})]})}],Y=l?.name?`Edit ${l.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:r,title:Y,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{o(!1),d(null),x("")},children:e.jsx("form",{onSubmit:F,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:Kn,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:Kn,children:"Image"}),e.jsx(s.Upload,{maxCount:1,action:C,headers:t?{Authorization:t}:void 0,onChange:q=>{if(q?.file?.status!=="done")return;const O=q?.file?.response,T=O?.data??O?.filename??O?.file??O?.path??"";T&&x(String(T))},children:e.jsx(s.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(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:Rr,children:"Cancel"})]})]})})}),e.jsx(s.Modal,{zIndex:9999,open:w,title:b,footer:null,onCancel:()=>p(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:m})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(fe,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(fe,{px:3,pb:2,children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(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:Kn,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:Kn,children:"Image"}),e.jsx(s.Upload,{maxCount:1,action:C,headers:t?{Authorization:t}:void 0,onChange:q=>{if(q?.file?.status!=="done")return;const O=q?.file?.response,T=O?.data??O?.filename??O?.file??O?.path??"";T&&x(String(T))},children:e.jsx(s.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(le,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",onClick:()=>x(""),style:Rr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(fe,{children:e.jsx(Be,{parentCallback:E,data:{newData:S,columns:B,columnstype:"antd",action:!1,Loading:f,error:A,deleteTodoMutation:j}})})]})})]})})]})}const Dr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Xt={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Gn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Or=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],Jn=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function ec({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(!1),[c,x]=i.useState(null),[m,u]=i.useState(null),[b,v]=i.useState(null),[w,p]=i.useState(null),[y,h]=i.useState(se()),[R,I]=i.useState(se()),[D,C]=i.useState("pick"),[g,f]=i.useState(!1),[S,A]=i.useState(null),[P,L]=i.useState(null),[N,j]=i.useState(!1),[M,k]=i.useState(null),[F,E]=i.useState(null),[B,Y]=i.useState(null),[q,O]=i.useState(null),[T,$]=i.useState(se()),[U,z]=i.useState(se()),[ne,K]=i.useState("pick"),V=`api/branchapi/Transport/assignRouteTimeList?page=${n.page}&per_page=${n.rowsPerPage}`,X="api/branchapi/Transport/assignRouteTime",ae="api/branchapi/Transport/editAssignRouteTime",ce="api/branchapi/Transport/deleteAssignRouteTime",je="api/branchapi/Transport/driverDropdown",re="api/branchapi/transport/routeTimetableShowdata",ie="api/branchapi/Transport/getrouteDropdown",W="api/branchapi/Transport/getvehicleDropdown",{isLoading:oe,data:Ce,error:Pe,mutate:ke}=G(t?[V,t]:null,([de,be])=>Q(de,be)),{data:Me}=G(t&&ie?[ie,t]:null,([de,be])=>Q(de,be)),{data:Oe}=G(t&&je?[je,t]:null,([de,be])=>Q(de,be)),Ve=i.useMemo(()=>c?`${W}?route_id=${c}`:null,[c,W]),{data:We}=G(t&&Ve?[Ve,t]:null,([de,be])=>Q(de,be)),Fe=i.useMemo(()=>Jn(Me),[Me]),Ye=i.useMemo(()=>Jn(Oe),[Oe]),lt=i.useMemo(()=>Jn(We),[We]),me=(de,be)=>{a({page:de,rowsPerPage:parseInt(be,10)})},xe=async de=>{de.preventDefault();const be=new FormData(de.target);be.set("route_id",m?.value??c??""),be.set("driver_id",b?.value??""),be.set("vehicle_id",w?.value??""),be.set("start_time",y?y.format("h:mm a"):""),be.set("drop_time",R?R.format("h:mm a"):""),be.set("type",D);try{await ze(X,be,t),await ke(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),de.target.reset(),x(null),u(null),v(null),p(null),d(Ke=>!Ke),h(se()),I(se()),C("pick"),o(Ke=>!Ke)}catch(Ke){_.error(Ke?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},he=async de=>{try{await nt(ce,de,t),await ke(),_.success("Success! Deleted item.",{duration:1e3})}catch(be){_.error(be?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},te=de=>{A(de),f(!0);const be=de?.id??de?.route_time_id??de?.routeId??null;L(be);const Ke=de?.route_id??de?.routeId??de?.fk_route_id;k(Ke??null),E(Fe.find(bt=>bt?.value===(Ke??de?.route_id))??null),Y(Ye.find(bt=>bt?.value===(de?.driver_id??de?.driverId))??null),O(null),j(bt=>!bt),$(de?.start_time?se(de.start_time,["h:mm a","HH:mm"]):se()),z(de?.drop_time?se(de.drop_time,["h:mm a","HH:mm"]):se()),K(de?.type??"pick")},ue=i.useMemo(()=>{if(!P)return null;const de=String(re).includes("?")?"&":"?";return`${re}${de}id=${encodeURIComponent(String(P))}`},[P,re]),{data:ye,isLoading:Te}=G(t&&ue?[ue,t]:null,([de,be])=>Q(de,be)),Ie=i.useMemo(()=>{const de=ye?.data??ye;return Array.isArray(de)?de[0]??null:Array.isArray(de?.data)?de.data[0]??null:de??null},[ye]),yt=i.useMemo(()=>M?`${W}?route_id=${M}`:null,[M,W]),{data:_t}=G(t&&yt?[yt,t]:null,([de,be])=>Q(de,be)),wt=i.useMemo(()=>Jn(_t),[_t]);i.useEffect(()=>{if(!Ie)return;const de=Ie?.route_id??Ie?.fk_route_id??Ie?.routeId;k(de??null),E(Fe.find(be=>be?.value===de)??null),Y(Ye.find(be=>be?.value===Ie?.driver_id)??null),O(null),$(Ie?.start_time?se(Ie.start_time,["h:mm a","HH:mm"]):se()),z(Ie?.drop_time?se(Ie.drop_time,["h:mm a","HH:mm"]):se()),K(Ie?.type??"pick"),j(be=>!be)},[Ye,Ie,Fe]),i.useEffect(()=>{if(!Ie)return;const de=Ie?.vehicle_id??Ie?.vehicleId;de&&O(wt.find(be=>be?.value===de)??null)},[Ie,wt]);const Wt=async de=>{if(de.preventDefault(),!P)return;const be=new FormData(de.target);be.set("id",String(P)),be.set("route_id",F?.value??M??""),be.set("driver_id",B?.value??""),be.set("vehicle_id",q?.value??""),be.set("start_time",T?T.format("h:mm a"):""),be.set("drop_time",U?U.format("h:mm a"):""),be.set("type",ne);try{await pt(ae,be,t),await ke(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),f(!1),A(null)}catch(Ke){_.error(Ke?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Ht=[{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:(de,be)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>te(be),style:{padding:2}}),e.jsx(it,{id:be?.id??be?.routeId??be?.route_time_id,funcName:he})]})}],Kt=S?.route_title?`Edit ${S.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:g,title:Kt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{f(!1),A(null),L(null),k(null),E(null),Y(null),O(null)},children:e.jsx("form",{onSubmit:Wt,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:Te?.6:1},children:[e.jsx(ee,{options:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:F,onChange:de=>{k(de?.value??null),E(de??null),O(null),j(be=>!be)}}),e.jsx(ee,{options:Ye,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:B,onChange:de=>Y(de??null)}),e.jsx(ee,{options:wt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:q,onChange:de=>O(de??null)},`edit-vehicle-${N}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Start Time"}),e.jsx(s.TimePicker,{value:T,onChange:de=>$(de),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Gn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Drop Time"}),e.jsx(s.TimePicker,{value:U,onChange:de=>z(de),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Gn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(s.Radio.Group,{options:Or,optionType:"button",buttonStyle:"solid",value:ne,onChange:de=>K(de.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{f(!1),A(null)},style:Dr,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(fe,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(fe,{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:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:m,onChange:de=>{x(de?.value??null),u(de??null),p(null),d(be=>!be)},allowSelectAll:!1,required:!0}),e.jsx(ee,{options:Ye,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:b,onChange:de=>v(de??null),allowSelectAll:!1,required:!0}),e.jsx(ee,{options:lt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:w,onChange:de=>p(de??null),allowSelectAll:!1,required:!0},`vehicle-${l}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Start Time"}),e.jsx(s.TimePicker,{value:y,onChange:de=>h(de),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Gn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Drop Time"}),e.jsx(s.TimePicker,{value:R,onChange:de=>I(de),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Gn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(s.Radio.Group,{options:Or,optionType:"button",buttonStyle:"solid",value:D,onChange:de=>C(de.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:"Add",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",onClick:()=>{x(null),u(null),v(null),p(null),d(de=>!de),h(se()),I(se()),C("pick"),o(de=>!de)},style:Dr,children:"Cancel"})]})]})},`form-${r}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(fe,{children:e.jsx(Be,{parentCallback:me,data:{newData:Ce,columns:Ht,columnstype:"antd",action:!1,Loading:oe,error:Pe,deleteTodoMutation:he}})})]})})]})})]})}const tc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Pr={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},kr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Er=({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 Mr=2;function nc({token:t}){const[n,a]=i.useState([]),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,x]=i.useState({pagination:{current:1,pageSize:50}}),{isLoading:m,data:u,mutate:b}=G(t?[`api/branchapi/transport/getrouteStoppageData?page=${c.pagination.current}&per_page=${c.pagination.pageSize}`,t]:null,([k,F])=>Q(k,F)),{Status:v="Failed",pagination:{total_rows:w=0}={}}=u||{},{data:p=[]}=v==="Success"?u:{},{data:y}=G(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([k,F])=>Q(k,F)),h=i.useMemo(()=>{const k=y?.data??y??[];if(Array.isArray(k))return k;if(k&&typeof k=="object"){if(Array.isArray(k?.data))return k.data;if(Array.isArray(k?.data?.data))return k.data.data}return[]},[y]),{data:R}=G(t&&r?["api/branchapi/transport/getrouteStoppageData?route_id="+r,t]:null,([k,F])=>Q(k,F)),{Status:I="Failed"}=R||{},D=async(k,F)=>{try{await b(ze(k,F,t),at(F)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},C=k=>k?typeof k=="string"?k:k?.isValid?.()?k.format("h:mm a"):"":"",g=(k,F=[])=>{const E=(Array.isArray(k)?k:[]).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)})),B=E.filter(q=>q?.id!=null&&String(q.id).trim()!==""),Y=E.filter(q=>!(q?.id!=null&&String(q.id).trim()!==""));return{route_id:r??"",edit_stoppage:B,add_stoppage:Y,delete_stoppage:Array.isArray(F)?F:[]}},f=k=>{k.preventDefault();const F="/api/branchapi/transport/addstoppageToRoute",E=g(n,l);D(F,E)},S=()=>{a(k=>[...Array.isArray(k)?k:[],{idKey:Mr++,stop_name:"",pickup_time:se().format("h:mm a"),drop_time:se().format("h:mm a")}])},A=k=>{if(n.length===1)return;const F=n[k];F?.id!=null&&String(F.id).trim()!==""&&!F?.idKey&&d(E=>{const B=Array.isArray(E)?E:[];return B.some(q=>String(q)===String(F.id))?B:[...B,F.id]}),a(E=>{const B=[...E];return B.splice(k,1),B})},P=k=>{x(F=>({...F,pagination:{current:k,pageSize:F.pagination.pageSize}}))},L=async k=>{const F="/api/branchapi/Transport/deletevehicle";try{await b(nt(F,k,t),Je(k)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}};i.useEffect(()=>{if(I==="Success"){const k=Array.isArray(R?.data)?R.data:[];k.length>0?(a(k),d([])):r&&(a([{idKey:Mr++,stop_name:"",pickup_time:se().format("h:mm a"),drop_time:se().format("h:mm a")}]),d([]))}},[I,R,r]);const N=k=>{const{children:F=[]}=k||{},E=[{title:"Stop Name",dataIndex:"stop_name",onCell:B=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:B=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:B=>({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:Er}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:E,rowKey:B=>j(B)+"cell01",dataSource:F,pagination:!1})})})},j=k=>{const F=["id","index"];for(let E=0;E<F.length;E++)if(k[F[E]])return k[F[E]]},M=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(k,F,E)=>e.jsx(e.Fragment,{children:(Array.isArray(F.children)?F.children:[]).map((B,Y,q)=>e.jsx("span",{children:`${B.stop_name} ${Y+1===q.length?"":","}`},`${Y}vehicle001`))})},{title:"Action",render:(k,F,E)=>e.jsx(e.Fragment,{children:e.jsx(it,{id:F?.route_id,funcName:L})})}];return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(fe,{pt:5,pb:1,children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(fe,{px:3,pb:2,children:e.jsxs("form",{onSubmit:f,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:h,value:h.find(k=>String(k.value)===String(r))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:k=>{o(k?.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(Z.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(le,{type:"submit",value:"Add",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{o(null),a([]),d([])},style:tc,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:n.length>0&&n.map((k,F)=>{const E=k.pickup_time?se(k.pickup_time,"h:mm a"):null,B=k.drop_time?se(k.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:k.stop_name??"",type:"text",name:`stoppage[${F}][name]`,label:"Place Name*",required:"required",onChange:Y=>{const q=Y?.target?.value??"";a(O=>{const T=[...O];return T[F]={...T[F]??{},stop_name:q},T})}}),k?.id!=null&&String(k.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${F}][id]`,value:String(k.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Pr,children:"Pick Time"}),e.jsx(s.TimePicker,{value:E,use12Hours:!0,format:"h:mm a",name:`stoppage[${F}][pickTime]`,allowClear:!1,style:kr,onChange:Y=>{const q=Y?Y.format("h:mm a"):"";a(O=>{const T=[...O];return T[F]={...T[F]??{},pickup_time:q},T})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Pr,children:"Drop Time"}),e.jsx(s.TimePicker,{value:B,use12Hours:!0,format:"h:mm a",name:`stoppage[${F}][drop_time]`,allowClear:!1,style:kr,onChange:Y=>{const q=Y?Y.format("h:mm a"):"";a(O=>{const T=[...O];return T[F]={...T[F]??{},drop_time:q},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(F),children:e.jsx(Z.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},k.idKey?k.idKey+"exp":k.id+"exp")})})]})}),e.jsx(fe,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(fe,{style:{padding:"10px 16px"},children:e.jsx(s.Table,{components:{body:{cell:Er}},columns:M,bordered:!0,size:"small",rowKey:k=>j(k),dataSource:p,loading:m,expandable:{expandedRowRender:N,childrenColumnName:"changed"},pagination:{current:c.pagination.current,pageSize:c.pagination.pageSize,total:w,showSizeChanger:!0,onChange:P,onShowSizeChange:(k,F)=>{x(E=>({...E,pagination:{current:1,pageSize:F}}))},showTotal:(k,F)=>`${F[0]}-${F[1]} of ${k} items`}})})]})]})}const ac=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),r=String(n).replace(/^\/+/,"");return`${a}/${r}`};function sc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState(null),[o,l]=i.useState(null),[d,c]=i.useState(null),[x,m]=i.useState(null),[u,b]=i.useState(null),[v,w]=i.useState(null),[p,y]=i.useState(null),h="api/branchapi/library/bookCategorydropdown",R="api/branchapi/academy/classdropdownlist",I="api/branchapi/Academy/getClassSubjectdropdown",D="api/branchapi/library/addBook",C="api/branchapi/library/uploadcsv",{data:g}=G(n?[h,n]:null,([j,M])=>Q(j,M)),{data:f}=G(n&&R?[R,n]:null,([j,M])=>Q(j,M)),{data:S}=G(n&&I?[I,n]:null,([j,M])=>Q(j,M)),A=i.useMemo(()=>ac(tt(),C),[C]),P=async j=>{j.preventDefault();const M=new FormData(j.target);M.set("cat_id",u?.value??""),M.set("class_id",v?.value??""),M.set("subject_id",p?.value??"");try{await ze(D,M,n),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),j.target.reset(),b(null),w(null),y(null)}catch(k){_.error(k?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},L=async j=>{if(j.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",x?.value??"");try{const k=await Ne.post(A,M,{headers:{Authorization:n,"Content-type":"multipart/form-data"}});k?.data?.Status==="Failed"?_.error(String(k?.data?.msg??"Upload failed."),{duration:1e3}):(_.success(String(k?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),r(null),j.target.reset(),l(null),c(null),m(null))}catch(k){_.error(k?.response?.data?.msg??"Upload failed.",{duration:1e3})}},N=()=>{fetch("/books.csv").then(j=>{j.blob().then(M=>{const k=window.URL.createObjectURL(M);let F=document.createElement("a");F.href=k,F.download="/books.csv",F.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(Z.DownloadOutlined,{}),onClick:N,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:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:o,onChange:j=>l(j??null)}),e.jsx(ee,{options:f,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:x,onChange:j=>m(j??null)}),e.jsx(J,{type:"file",label:"Upload CSV",name:"csv",accept:".csv",onChange:j=>r(j.target.files?.[0]??null),required:!0}),e.jsx(le,{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:P,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(ee,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:u,onChange:j=>b(j??null)}),e.jsx(ee,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:v,onChange:j=>w(j??null)}),e.jsx(ee,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:p,onChange:j=>y(j??null)}),e.jsx(le,{type:"submit",value:"Save",color:"primary"})]})})})]})}const ts={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ns=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function rc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState([]),[o,l]=i.useState([]),d=i.useRef(),c={selectedRowKeys:a,onChange:(X,ae)=>{r(X),l(ae)}},x=ln.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),m=()=>{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}x?.()}},[u,b]=i.useState(!1),[v,w]=i.useState(null),[p,y]=i.useState(null),[h,R]=i.useState(null),[I,D]=i.useState(null),[C,g]=i.useState({page:1,rowsPerPage:10}),f=(X,ae)=>{g({page:X,rowsPerPage:parseInt(ae,10)})},S="api/branchapi/library/booktable",A="api/branchapi/library/deletebooks",P="api/branchapi/library/editbook",L=`${S}?page=${C.page}&per_page=${C.rowsPerPage}`,{isLoading:N,error:j,data:M,mutate:k}=G(n?[L,n]:null,([X,ae])=>Q(X,ae)),F="api/branchapi/library/bookCategorydropdown",E="api/branchapi/academy/classdropdownlist",B="api/branchapi/Academy/getClassSubjectdropdown",{data:Y}=G(n?[F,n]:null,([X,ae])=>Q(X,ae)),{data:q}=G(n&&E?[E,n]:null,([X,ae])=>Q(X,ae)),{data:O}=G(n&&B?[B,n]:null,([X,ae])=>Q(X,ae)),T=i.useMemo(()=>ns(Y),[Y]),$=i.useMemo(()=>ns(q),[q]),U=i.useMemo(()=>ns(O),[O]),z=async X=>{try{await nt(A,X,n),await k(),_.success("Success! Deleted item.",{duration:1e3})}catch(ae){_.error(ae?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ne=X=>{w(X??null);const ae=X?.cat_id??X?.fk_cat_id??X?.category_id,ce=X?.class_id??X?.fk_class_id,je=X?.subject_id??X?.fk_subject_id;y(T.find(re=>re?.value===ae)??null),R($.find(re=>re?.value===ce)??null),D(U.find(re=>re?.value===je)??null),b(!0)},K=async X=>{X.preventDefault();const ae=v?.id??v?.book_id??v?._id;if(!ae)return;const ce=new FormData(X.target);ce.set("id",String(ae)),ce.set("cat_id",p?.value??""),ce.set("class_id",h?.value??""),ce.set("subject_id",I?.value??"");try{await pt(P,ce,n),await k(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),b(!1),w(null)}catch(je){_.error(je?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},V=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:(X,ae)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>ne(ae),style:{padding:2}}),e.jsx(s.Button,{type:"text",size:"small",danger:!0,onClick:()=>z(ae?.id??ae?.book_id??ae?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[T,$,z,U]);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:()=>{b(!1),w(null)},children:e.jsx("form",{onSubmit:K,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(J,{label:"Book Name",name:"title",defaultValue:v?.book_title??"",required:!0}),e.jsx(J,{label:"Author",name:"author",defaultValue:v?.author??"",required:!0}),e.jsx(J,{label:"Publication",name:"publish",defaultValue:v?.publish??""}),e.jsx(J,{label:"Qty",name:"quantity",type:"number",defaultValue:v?.quantity??""}),e.jsx(J,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:v?.perunitcost??""}),e.jsx(J,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:v?.fine_amount??""}),e.jsx(J,{label:"Barcode",name:"barcode",defaultValue:v?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ts,children:"Category"}),e.jsx(ee,{options:T,value:p,onChange:X=>y(X??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ts,children:"Class"}),e.jsx(ee,{options:$,value:h,onChange:X=>R(X??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ts,children:"Subject"}),e.jsx(ee,{options:U,value:I,onChange:X=>D(X??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{b(!1),w(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:m,children:["Print Barcode (",o.length,")"]}):null,children:e.jsx(Be,{parentCallback:f,data:{newData:M,columns:V,columnstype:"antd",action:!1,Loading:N,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((X,ae)=>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:X.book_title}),e.jsx(Ci,{value:X.barcode?String(X.barcode):String(X.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},ae))})})})]})}const ic=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),r=String(n).replace(/^\/+/,"");return`${a}/${r}`},Ct=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function oc({token:t}){const n=t??localStorage.getItem("authToken")??"",a=JSON.parse(localStorage.getItem("genrall_settings")??"null")?.currency_symbol??"",[r,o]=i.useState("issue"),l=r==="return",[d,c]=i.useState(!1),[x,m]=i.useState(!1),[u,b]=i.useState(null),[v,w]=i.useState([]),[p,y]=i.useState([]),[h,R]=i.useState([]),[I,D]=i.useState(0),[C,g]=i.useState(!1),[f,S]=i.useState(null),[A,P]=i.useState(null),[L,N]=i.useState(null),[j,M]=i.useState(!1),[k,F]=i.useState("Cash"),[E,B]=i.useState(""),[Y,q]=i.useState(""),[O,T]=i.useState(0),$=i.useRef(null),[U]=s.Form.useForm(),[z]=s.Form.useForm(),ne="api/branchapi/library/bookCategorydropdown",K="api/branchapi/academy/classdropdownlist",V="api/branchapi/Academy/getClassSubjectdropdown",{data:X}=G(n?[ne,n]:null,([pe,_e])=>Q(pe,_e)),{data:ae}=G(n&&K?[K,n]:null,([pe,_e])=>Q(pe,_e)),{data:ce}=G(n&&V?[V,n]:null,([pe,_e])=>Q(pe,_e)),je=i.useMemo(()=>Ct(X),[X]),re=i.useMemo(()=>Ct(ae),[ae]),ie=i.useMemo(()=>Ct(ce),[ce]),W="api/branchapi/library/studentsearchByNameID",oe="api/branchapi/library/booksearchBybookname",Ce="api/branchapi/library/issuedBookList",Pe="api/branchapi/library/issueLibrarybook",ke="api/branchapi/library/returnedLibrarybook",{trigger:Me,data:Oe}=Ge(W,(pe,_e)=>qt(pe,_e,n)),{trigger:Ve,data:We}=Ge(oe,(pe,_e)=>qt(pe,_e,n)),{trigger:Fe,data:Ye}=Ge(Ce,(pe,_e)=>qt(pe,_e,n)),{trigger:lt}=Ge(l?ke:Pe,(pe,_e)=>ka(pe,_e,n)),me=i.useMemo(()=>Ct(Oe),[Oe]),xe=i.useMemo(()=>Ct(We),[We]),he=i.useMemo(()=>Ct(Ye),[Ye]),te=pe=>{const _e=se().format("YYYY-MM-DD");w($e=>$e.some(Ft=>String(Ft?.id)===String(pe?.id))?$e:[...$e,{...pe,return_date:pe?.return_date?pe.return_date:_e}])},ue=pe=>{w(_e=>_e.filter($e=>String($e?.id)!==String(pe)))},ye=async pe=>{if(n){if(!pe){b(null);return}d||await Me({id:pe})}},Te=async({search:pe})=>{if(!n||!d)return;const _e=await Me({id:pe}),$e=Ct(_e);$e.length===1&&(b($e[0]),await Fe({id:$e[0]?.student_id}),U.resetFields())},Ie=async(pe,_e)=>{b(_e??null),w([]),y([]),R([]),D(0),_e?.student_id&&await Fe({id:_e.student_id}),U.resetFields()},yt=async pe=>{n&&pe&&(x||await Ve({book:pe}))},_t=async({search_book:pe})=>{if(!n||!x)return;const _e=await Ve({book:pe,catID:f?.value??"",sID:L?.value??"",cID:A?.value??""}),$e=Ct(_e);$e.length&&(te($e[0]),z.resetFields())},wt=(pe,_e)=>{te(_e),z.resetFields()},Wt=async()=>{if(!u?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!v.length){_.error("Select at least one book.",{duration:1e3});return}const pe=await lt({member_id:u.member_id,fine:!1,books:v});pe?.Status==="Success"?(_.success(String(pe?.msg??"Success"),{duration:1e3}),w([]),b(null),y([]),R([]),D(0)):_.error(String(pe?.msg??"Failed"),{duration:1e3})},Ht=async()=>{if(!u?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!h.length){_.error("Select at least one book to return.",{duration:1e3});return}if(Number(I)>0){M(!0);return}const pe=await lt({member_id:u.member_id,fine:!1,books:JSON.stringify(h)});pe?.Status==="Success"?(_.success(String(pe?.msg??"Success"),{duration:1e3}),y([]),R([]),D(0),await Fe({id:u?.student_id})):_.error(String(pe?.msg??"Failed"),{duration:1e3})},Kt=async()=>{if(!u?.member_id)return;const pe=Math.max(0,Number(I)-Number(O||0)),_e={member_id:u.member_id,amount:pe,fine:!0,books:JSON.stringify(h),payment_type:k,notes:E,attchement:Y,discount:O||0},$e=await lt(_e);M(!1),$e?.Status==="Success"?(_.success(String($e?.msg??"Success"),{duration:1e3}),y([]),R([]),D(0),T(0),B(""),q(""),await Fe({id:u?.student_id})):_.error(String($e?.msg??"Failed"),{duration:1e3})},de=i.useMemo(()=>ic(tt(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),be=[{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:(pe,_e)=>e.jsx(s.Input,{value:_e?.return_date??"",onChange:$e=>{const Ft=$e.target.value;w(pn=>pn.map($t=>String($t?.id)===String(_e?.id)?{...$t,return_date:Ft}:$t))},placeholder:"YYYY-MM-DD"})},{title:"Action",key:"action",width:120,fixed:"right",render:(pe,_e)=>e.jsx(s.Button,{type:"text",danger:!0,onClick:()=>ue(_e?.id),children:"Remove"})}],Ke={selectedRowKeys:p,onChange:(pe,_e)=>{y(pe),R(_e);const $e=(_e??[]).reduce((Ft,pn)=>Ft+Number(pn?.totalfine??0),0);D($e)}},bt=[{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:"Due Date",dataIndex:"due_date",key:"due_date",width:140,responsive:["lg"]},{title:"Fine",dataIndex:"totalfine",key:"totalfine",width:120,fixed:"right",render:pe=>e.jsxs("span",{children:[a," ",pe]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:j,onCancel:()=>M(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(s.Radio.Group,{value:k,onChange:pe=>F(pe.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:E,onChange:pe=>B(pe.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(s.Upload,{action:de,headers:{Authorization:n},maxCount:1,onChange:pe=>{if(pe.file.status==="done"){const _e=pe.file.response?.data??pe.file.response?.file??"";q(String(_e??""))}},children:e.jsx(s.Button,{icon:e.jsx(Z.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(s.Input,{type:"number",value:O,onChange:pe=>T(pe.target.value),placeholder:"0"})]}),e.jsxs(s.Button,{type:"primary",onClick:Kt,children:["Collect ",a,Math.max(0,Number(I)-Number(O||0))]})]})}),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:r,onChange:pe=>{const _e=pe.target.value;o(_e),w([]),y([]),R([]),D(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(s.Col,{xs:24,md:14,children:e.jsx(s.Form,{form:U,onFinish:Te,layout:"vertical",children:e.jsx(s.Form.Item,{name:"search",label:"Search Student",children:e.jsx(s.Space.Compact,{style:{width:"100%"},children:d?e.jsx(s.Input,{autoFocus:!0,addonBefore:e.jsxs(s.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:d,onChange:pe=>c(pe.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(s.AutoComplete,{options:me,onSelect:Ie,onSearch:ye,style:{width:"100%"},allowClear:!0,children:e.jsx(s.Input,{addonBefore:e.jsxs(s.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:d,onChange:pe=>c(pe.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),u?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:"})," ",u?.value??""]}),e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Card No:"})," ",u?.library_card_no??""]}),e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Member ID:"})," ",u?.member_id??""]})]})]}):null,e.jsx(s.Divider,{}),l?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:bt,rowSelection:Ke,pagination:!1,rowKey:pe=>pe?.id??pe?.issue_id??pe?.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: ",a,I]}),e.jsx(s.Button,{type:"primary",onClick:Ht,disabled:!h.length,children:I>0?`Pay Now ${a}${Math.max(0,Number(I)-Number(O||0))}`:"Return Selected"})]})]}):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:z,onFinish:_t,layout:"vertical",children:e.jsx(s.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(s.Space.Compact,{style:{width:"100%"},children:x?e.jsx(s.Input,{autoFocus:!0,disabled:!u,addonBefore:e.jsxs(s.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:x,onChange:pe=>m(pe.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(s.AutoComplete,{disabled:!u,options:xe,onSelect:wt,onSearch:yt,style:{width:"100%"},allowClear:!0,children:e.jsx(s.Input,{addonBefore:e.jsxs(s.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:x,onChange:pe=>m(pe.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(Z.FilterOutlined,{}),onClick:()=>g(!0),children:"Filter"})})]}),e.jsx(s.Drawer,{open:C,onClose:()=>g(!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:je,value:f,onChange:pe=>S(pe??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(ee,{label:"Class",options:re,value:A,onChange:pe=>P(pe??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(ee,{label:"Subjects",options:ie,value:L,onChange:pe=>N(pe??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(s.Button,{type:"primary",onClick:()=>g(!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:v,columns:be,pagination:!1,rowKey:pe=>pe?.id??pe?.book_id??pe?.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(le,{type:"button",value:"Issue",onClick:Wt})})]})]}),e.jsx("div",{ref:$,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}const Fr=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function lc({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),[x,m]=i.useState(!1),[u,b]=i.useState(!1),[v,w]=i.useState(null),[p,y]=i.useState(!1),h="api/branchapi/academy/classdropdownlist",R="api/branchapi/academy/sectionoftheClass",I="api/branchapi/library/studenttableForLibrary",D="api/branchapi/library/addmembershipforStudent",C="api/branchapi/library/removemembershipforStudent",g=i.useMemo(()=>{if(!o?.value)return null;const O=R.includes("?")?"&":"?";return`${R}${O}class_id=${encodeURIComponent(String(o.value))}`},[R,o?.value]),f=i.useMemo(()=>{if(!o?.value||!d?.value)return null;const O=I.includes("?")?"&":"?";return`${I}${O}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,I]),{data:S}=G(n&&h?[h,n]:null,([O,T])=>Q(O,T)),{data:A}=G(n&&g?[g,n]:null,([O,T])=>Q(O,T)),{isLoading:P,error:L,data:N,mutate:j}=G(n&&f?[f,n]:null,([O,T])=>Q(O,T)),M=i.useMemo(()=>Fr(S),[S]),k=i.useMemo(()=>Fr(A),[A]),F=(O,T)=>{r({page:O,rowsPerPage:parseInt(T,10)})},E=O=>{const T=O?.id??O?.student_id??O?.member_id;w(T??null),b(!0),y($=>!$)},B=async O=>{if(O.preventDefault(),!v)return;const T=new FormData(O.target);T.set("id",String(v));try{await ze(D,T,n),_.success("Success! Added member.",{duration:1e3,icon:"🎉"}),b(!1),w(null),await j()}catch($){_.error($?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},Y=async O=>{try{await nt(C,O,n),_.success("Success! Removed member.",{duration:1e3}),await j()}catch(T){_.error(T?.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:(O,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(Z.UserAddOutlined,{}),onClick:()=>E(T)}):e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{}),onClick:()=>Y(T?.id??T?.student_id??T?.member_id)})}))}],[Y]);return e.jsxs("div",{style:{},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:u,title:"Add Member",onCancel:()=>{b(!1),w(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:B,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(le,{type:"submit",value:"Add",color:"primary"})})]})},`add-${p}`)}),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(ee,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:o,onChange:O=>{l(O??null),c(null),m(T=>!T)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(ee,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:O=>c(O??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${x}`),e.jsx(le,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!o?.value||!d?.value){_.error("Select class and section.",{duration:1e3});return}r(O=>({...O,page:1}))}})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Be,{parentCallback:F,data:{newData:N,columns:q,columnstype:"antd",action:!1,Loading:P,error:L}})})]})}function dc({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),[x,m]=i.useState(null),u="api/branchapi/library/BookCategorytable",b="api/branchapi/library/addBookCategory",v="api/branchapi/library/editBookCategory",w="api/branchapi/library/deleteBookCategory",p=i.useMemo(()=>{const L=u.includes("?")?"&":"?";return`${u}${L}page=${a.page}&per_page=${a.rowsPerPage}`},[u,a.page,a.rowsPerPage]),{isLoading:y,error:h,data:R,mutate:I}=G(n&&p?[p,n]:null,([L,N])=>Q(L,N)),D=(L,N)=>{r({page:L,rowsPerPage:parseInt(N,10)})},C=async L=>{const N=new FormData;N.set("title",L?.title??"");try{await ze(b,N,n),_.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),o.resetFields(),await I()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to add category.",{duration:1e3})}},g=L=>{m(L??null),l.setFieldsValue({title:L?.name??""}),c(!0)},f=()=>{c(!1),m(null),l.resetFields()},S=async L=>{const N=x?.id??x?.category_id??x?.cat_id;if(!N){_.error("Missing category id.",{duration:1e3});return}const j=new FormData;j.set("id",String(N)),j.set("title",L?.title??"");try{await pt(v,j,n),_.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),f(),await I()}catch(M){_.error(M?.response?.data?.msg??M?.message??"Failed to update category.",{duration:1e3})}},A=async L=>{const N=L?.id??L?.category_id??L?.cat_id;if(!N){_.error("Missing category id.",{duration:1e3});return}try{await nt(w,N,n),_.success("Success! Deleted category.",{duration:1e3}),await I()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to delete category.",{duration:1e3})}},P=i.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(L,N)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>g(N)}),e.jsx(s.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>A(N),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[A]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:d,title:"Edit Category",onCancel:f,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:f,children:"Cancel"}),e.jsx(le,{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:C,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(le,{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(Be,{parentCallback:D,data:{newData:R,columns:P,columnstype:"antd",action:!1,Loading:y,error:h}})})})]})]})}const as=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function cc({token:t}){const[n,a]=i.useState([se().format("YYYY-MM-DD"),se().format("YYYY-MM-DD")]),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,x]=i.useState(null),[m,u]=i.useState(!1),[b,v]=i.useState(!1),w="api/branchapi/academy/classdropdownlist",p="api/branchapi/academy/sectionoftheClass",y="api/branchapi/library/memberDropdown",h="api/report/libraryReport/libraryReport",R=i.useMemo(()=>{if(!r?.value)return null;const E=p.includes("?")?"&":"?";return`${p}${E}class_id=${encodeURIComponent(String(r.value))}`},[p,r?.value]),I=i.useMemo(()=>{if(!r?.value)return null;const E=y.includes("?")?"&":"?",B=`${y}${E}class=${encodeURIComponent(String(r.value))}`;return l?.value?`${B}&section=${encodeURIComponent(String(l.value))}`:B},[y,r?.value,l?.value]),{isLoading:D,error:C,data:g,mutate:f}=G(t&&w?[w,t]:null,([E,B])=>Q(E,B)),{data:S}=G(t&&R?[R,t]:null,([E,B])=>Q(E,B)),{data:A}=G(t&&I?[I,t]:null,([E,B])=>Q(E,B)),P=i.useMemo(()=>as(g),[g]),L=i.useMemo(()=>as(S),[S]),N=i.useMemo(()=>as(A),[A]),{trigger:j,data:M}=Ge(h,(E,B)=>Is(E,B,t));i.useEffect(()=>{(async()=>{v(!0);try{await j({duration:n})}finally{v(!1)}})()},[]);const k=async()=>{v(!0);try{await j({duration:n,class:r?.value??"",section:l?.value??"",student_id:c?.value??""})}finally{v(!1)}},F=[{title:"Name",dataIndex:"full_name",render:(E,B)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:B?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(E,B)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:B?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(E,B)=>e.jsxs(s.Typography.Text,{style:{fontSize:12},children:[B?.class??"","(",B?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(E,B)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:B?.book_title??""})},{title:"Issue Date",key:"date",render:(E,B,Y)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:B?.issue_date??""})},{title:"Due Return Date",key:"date",render:(E,B,Y)=>e.jsx(s.Tag,{color:"orange",children:B?.return_date??""})},{title:"Return Date",key:"date",render:(E,B,Y)=>B?.retured_by_user?e.jsx(s.Tag,{color:"green",children:B?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(E,B,Y)=>String(B?.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,B,Y)=>{const q=B?.late_fine?Number(B.late_fine):0;return q?e.jsx(s.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:q}):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:[se(n[0],"YYYY-MM-DD"),se(n[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(E,B)=>{Array.isArray(B)&&B.length===2&&a([B[0],B[1]])}})]})}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ee,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:r,onChange:E=>{o(E??null),d(null),x(null),u(B=>!B)},allowSelectAll:!1})}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:l,onChange:E=>{d(E??null),x(null)},allowSelectAll:!1},`section1${m}`)}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:E=>x(E??null),allowSelectAll:!1})}),e.jsx(s.Col,{xs:24,md:1,children:e.jsx(s.Button,{type:"primary",icon:e.jsx(Z.SearchOutlined,{}),onClick:k,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(s.Table,{columns:F,pagination:!1,dataSource:Array.isArray(M?.data)?M.data:[],size:"small",rowKey:(E,B)=>E?.id??E?.issue_id??E?.fees_receipt_id??B,loading:b,scroll:{x:"max-content"},summary:E=>{const B=E.reduce((q,O)=>q+Number(O?.late_fine??0),0),Y=E.reduce((q,O)=>q+Number(O?.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-Y)]})}),e.jsx(s.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",Y]})}),e.jsx(s.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",B.toLocaleString("en-IN")]})})]})}})})]})]})}const Ma=t=>t??localStorage.getItem("authToken")??"",uc=(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},Ue={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"}},pc=()=>uc(tt(),Ue.upload),mc=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,Ma(r))},Un=async(t,n,a)=>ze(t,n,Ma(a)),cn=async(t,n,a)=>pt(t,n,Ma(a)),Bn=async(t,n,a)=>nt(t,n,Ma(a)),fc=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",rn=({token:t,value:n,onChange:a})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:pc(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=fc(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},ua=Ue.vendor,Ln=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,x])=>mc({baseUrl:l,page:d,perPage:c},x)),yc=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:ua.list,page:n,perPage:a,token:t}),hc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},$r=[{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 gc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),{isLoading:m,error:u,data:b,mutate:v}=yc({token:t,page:n.page,perPage:n.rowsPerPage}),w=async C=>{try{await v(Un(ua.add,C,t),at(C)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(g){_.error(g?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},p=C=>{C.preventDefault();const g=new FormData(C.target);c&&g.set("image",c),w(g),C.target.reset(),x("")},y=(C,g)=>{a({page:C,rowsPerPage:parseInt(g,10)})},h=async C=>{try{await v(Bn(ua.remove,C,t),Je(C)),_.success("Success! Deleted item.",{duration:1e3})}catch(g){_.error(g?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},R=C=>{d(C),o(!0),x("")},I=async C=>{C.preventDefault();const g=new FormData(C.target);g.set("id",String(l?.id??"")),c&&g.set("image",c);try{await cn(ua.edit,g,t),await v(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(f){_.error(f?.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:(C,g)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>R(g),style:{padding:2}}),e.jsx(it,{id:g?.id,funcName:h})]})}],[h]);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),x("")},children:e.jsx("form",{onSubmit:I,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[$r.map(C=>e.jsx(J,{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(rn,{token:t,value:c,onChange:x})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:hc,children:"Cancel"})]})]})})}),e.jsxs(fe,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(fe,{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:[$r.map(C=>e.jsx(J,{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(rn,{token:t,value:c,onChange:x})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(fe,{pt:3,children:e.jsx(Be,{parentCallback:y,data:{newData:b,columns:D,columnstype:"antd",action:!1,Loading:m,error:u}})})]})]})]})}const xc=({token:t})=>e.jsx(gc,{token:t}),bc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Sc={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"},It=({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:bc,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:{...Sc,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})},pa=Ue.product,Nr=Ue.vendor.dropdown,Ur=Ue.category.dropdown,jc=Ue.subCategory.dropdown,Br=Ue.unit.dropdown,ro=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:pa.list,page:n,perPage:a,token:t}),vc=({token:t})=>G(t&&Nr?[Nr,t]:null,([a,r])=>Q(a,r)),_c=({token:t})=>G(t&&Ur?[Ur,t]:null,([a,r])=>Q(a,r)),wc=({token:t})=>G(t&&Br?[Br,t]:null,([a,r])=>Q(a,r)),Cc=({token:t,categoryId:n})=>{const a=t&&n?`${jc}?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:[]},Ac={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({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),[m,u]=i.useState(""),[b,v]=i.useState(""),[w,p]=i.useState(""),[y,h]=i.useState(""),{isLoading:R,error:I,data:D,mutate:C}=ro({token:t,page:n.page,perPage:n.rowsPerPage}),{data:g}=vc({token:t}),{data:f}=_c({token:t}),{data:S}=wc({token:t}),{data:A}=Cc({token:t,categoryId:m}),P=i.useMemo(()=>Qn(g),[g]),L=i.useMemo(()=>Qn(f),[f]),N=i.useMemo(()=>Qn(S),[S]),j=i.useMemo(()=>Qn(A),[A]),M=async O=>{try{await C(Un(pa.add,O,t),at(O)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(T){_.error(T?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},k=O=>{O.preventDefault();const T=new FormData(O.target);m&&T.set("fk_categoryID",String(m)),b&&T.set("fk_sub_categoryID",String(b)),w&&T.set("vendor_id",String(w)),y&&T.set("unit",String(y)),c&&T.set("image",c),M(T),O.target.reset(),x(""),u(""),v(""),p(""),h("")},F=(O,T)=>{a({page:O,rowsPerPage:parseInt(T,10)})},E=async O=>{try{await C(Bn(pa.remove,O,t),Je(O)),_.success("Success! Deleted item.",{duration:1e3})}catch(T){_.error(T?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},B=O=>{d(O),o(!0),x(""),u(O?.fk_categoryID??O?.category_id??""),v(O?.fk_sub_categoryID??O?.sub_category_id??""),p(O?.vendor_id??""),h(O?.unit??O?.unit_id??"")},Y=async O=>{O.preventDefault();const T=new FormData(O.target);T.set("id",String(l?.id??"")),m&&T.set("fk_categoryID",String(m)),b&&T.set("fk_sub_categoryID",String(b)),w&&T.set("vendor_id",String(w)),y&&T.set("unit",String(y)),c&&T.set("image",c);try{await cn(pa.edit,T,t),await C(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch($){_.error($?.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:(O,T)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>B(T),style:{padding:2}}),e.jsx(it,{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),x("")},children:e.jsx("form",{onSubmit:Y,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(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:O=>{const T=O?.value??"";u(T),v("")},defaultValue:m?L.find(O=>String(O?.value)===String(m)):null}),e.jsx(ee,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:O=>v(O?.value??""),defaultValue:b?j.find(O=>String(O?.value)===String(b)):null}),e.jsx(J,{type:"text",name:"barcode",label:"Barcode",defaultValue:l?.barcode??""}),e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:O=>h(O?.value??""),defaultValue:y?N.find(O=>String(O?.value)===String(y)):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(ee,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:O=>p(O?.value??""),defaultValue:w?P.find(O=>String(O?.value)===String(w)):null}),e.jsx(J,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:l?.hsn_code??""}),e.jsx(It,{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(rn,{token:t,value:c,onChange:x})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:Ac,children:"Cancel"})]})]})})}),e.jsxs(fe,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(fe,{px:3,pb:2,children:e.jsx("form",{onSubmit:k,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(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:O=>{const T=O?.value??"";u(T),v("")}}),e.jsx(ee,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:O=>v(O?.value??"")},`subcat_${m}`),e.jsx(J,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:O=>h(O?.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(ee,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:O=>p(O?.value??"")}),e.jsx(J,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(It,{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(rn,{token:t,value:c,onChange:x})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(fe,{pt:3,children:e.jsx(Be,{parentCallback:F,data:{newData:D,columns:q,columnstype:"antd",action:!1,Loading:R,error:I}})})]})]})]})}const Ic=({token:t})=>e.jsx(Tc,{token:t}),ma=Ue.category,Rc=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:ma.list,page:n,perPage:a,token:t}),Dc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Oc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:x,data:m,mutate:u}=Rc({token:t,page:n.page,perPage:n.rowsPerPage}),b=async I=>{try{await u(Un(ma.add,I,t),at(I)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){_.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},v=I=>{I.preventDefault();const D=new FormData(I.target);b(D),I.target.reset()},w=(I,D)=>{a({page:I,rowsPerPage:parseInt(D,10)})},p=async I=>{try{await u(Bn(ma.remove,I,t),Je(I)),_.success("Success! Deleted item.",{duration:1e3})}catch(D){_.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},y=I=>{d(I),o(!0)},h=async I=>{I.preventDefault();const D=new FormData(I.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(C){_.error(C?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},R=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(I,D)=>String(I?.name??"").localeCompare(String(D?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(I,D)=>String(I?.description??"").localeCompare(String(D?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(I,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(D),style:{padding:2}}),e.jsx(it,{id:D?.id,funcName:p})]})}],[p]);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:h,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(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Dc,children:"Cancel"})]})]})})}),e.jsxs(fe,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(fe,{px:3,pb:2,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(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(le,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(fe,{pt:3,children:e.jsx(Be,{parentCallback:w,data:{newData:m,columns:R,columnstype:"antd",action:!1,Loading:c,error:x}})})]})]})]})}const Pc=({token:t})=>e.jsx(Oc,{token:t}),fa=Ue.subCategory,Lr=Ue.category.dropdown,kc=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:fa.list,page:n,perPage:a,token:t}),Ec=({token:t})=>G(t&&Lr?[Lr,t]:null,([a,r])=>Q(a,r)),Mc=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Fc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function $c({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),{isLoading:m,error:u,data:b,mutate:v}=kc({token:t,page:n.page,perPage:n.rowsPerPage}),{data:w}=Ec({token:t}),p=i.useMemo(()=>Mc(w),[w]),y=async f=>{try{await v(Un(fa.add,f,t),at(f)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(S){_.error(S?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},h=f=>{f.preventDefault();const S=new FormData(f.target);S.set("status","active"),S.set("img",c||""),y(S),f.target.reset(),x("")},R=(f,S)=>{a({page:f,rowsPerPage:parseInt(S,10)})},I=async f=>{try{await v(Bn(fa.remove,f,t),Je(f)),_.success("Success! Deleted item.",{duration:1e3})}catch(S){_.error(S?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},D=f=>{d(f),o(!0)},C=async f=>{f.preventDefault();const S=new FormData(f.target);S.set("id",String(l?.id??"")),c&&S.set("img",c);try{await cn(fa.edit,S,t),await v(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(A){_.error(A?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},g=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(f,S)=>String(f?.name??"").localeCompare(String(S?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(f,S)=>String(f?.description??"").localeCompare(String(S?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(f,S)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>D(S),style:{padding:2}}),e.jsx(it,{id:S?.id,funcName:I})]})}],[I]);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),x("")},children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:l?.category_id?p.find(f=>String(f?.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(rn,{token:t,value:c,onChange:x})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:Fc,children:"Cancel"})]})]})})}),e.jsxs(fe,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(fe,{px:3,pb:2,children:e.jsx("form",{onSubmit:h,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:p,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(rn,{token:t,value:c,onChange:x})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(fe,{pt:3,children:e.jsx(Be,{parentCallback:R,data:{newData:b,columns:g,columnstype:"antd",action:!1,Loading:m,error:u}})})]})]})]})}const Nc=({token:t})=>e.jsx($c,{token:t}),ss=Ue.product,Uc=Ue.academy.classes,Bc=Ue.academy.sections,Lc=Ue.student.dropdown;function xn(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 Qe(t){return String(t??"")}function qc({token:t}){const[n,a]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,x]=i.useState(!1),[m,u]=i.useState(""),[b,v]=i.useState([]),[w,p]=i.useState({}),[y,h]=i.useState({}),[R,I]=i.useState(!1),[D,C]=i.useState(""),[g,f]=i.useState(0),[S,A]=i.useState(""),[P,L]=i.useState(se()),[N,j]=i.useState([]),M={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},k=!!(n&&r&&l),{data:F}=G(t?[Uc,t]:null,([me,xe])=>Q(me,xe)),E=i.useMemo(()=>xn(F),[F]),B=t&&n?`${Bc}?class_id=${encodeURIComponent(String(n))}`:null,{data:Y}=G(B?[B,t]:null,([me,xe])=>Q(me,xe)),q=i.useMemo(()=>xn(Y),[Y]),O=t&&n&&r?`${Lc}?class=${encodeURIComponent(String(n))}&section=${encodeURIComponent(String(r))}`:null,{data:T}=G(O?[O,t]:null,([me,xe])=>Q(me,xe)),$=i.useMemo(()=>xn(T),[T]),U=k?`${ss.list}?page=1&per_page=10000`:null,{data:z,isLoading:ne}=G(t&&U?[U,t]:null,([me,xe])=>Q(me,xe),{revalidateOnFocus:!1}),K=i.useMemo(()=>xn(z),[z]),V=i.useMemo(()=>{const me=new Map;return(Array.isArray(K)?K:[]).forEach(xe=>{me.set(Qe(xe?.id),xe)}),me},[K]),X=i.useMemo(()=>{const me=Object.entries(y||{});return me.length===0?[]:me.map(([xe,he])=>{const te=V.get(Qe(xe));return te?{id:te?.id,name:te?.name,barcode:te?.barcode,stock:Number(te?.quantity||0),price:Number(te?.price||0),quantity:Xn(he,Number(te?.quantity||0))}:null}).filter(Boolean)},[y,V]),ae=i.useMemo(()=>new Set(X.map(me=>Qe(me?.id))),[X]),ce=i.useMemo(()=>(Array.isArray(X)?X:[]).reduce((xe,he)=>xe+Number(he?.price||0)*Number(he?.quantity||1),0),[X]),je=i.useMemo(()=>{const me=Number(g||0);return!Number.isFinite(me)||me<=0?0:Math.min(me,ce)},[g,ce]),re=i.useMemo(()=>Math.max(0,ce-je),[je,ce]),ie=i.useMemo(()=>(Array.isArray(K)?K:[]).slice(0,30).map(me=>({value:Qe(me?.id),label:`${me?.name??""}${me?.barcode?` • ${me.barcode}`:""}${me?.quantity!==void 0&&me?.quantity!==null?` • Stock: ${me.quantity}`:""}`,product:me})),[K]),{trigger:W}=Ge(t&&k?ss.search:null,(me,{arg:xe})=>qt(me,{arg:xe},t));i.useEffect(()=>{if(!k){v([]);return}const me=String(m||"").trim();if(me.length<2){v(ie);return}let xe=!0;const he=setTimeout(async()=>{let te=[];try{if(W){const ye=await W({search:me});te=xn(ye)}}catch{te=[]}if(!Array.isArray(te)||te.length===0){const ye=me.toLowerCase();te=(Array.isArray(K)?K:[]).filter(Te=>{const Ie=String(Te?.name??"").toLowerCase(),yt=String(Te?.barcode??"").toLowerCase();return Ie.includes(ye)||yt.includes(ye)}).slice(0,30)}const ue=te.slice(0,30).map(ye=>({value:Qe(ye?.id),label:`${ye?.name??""}${ye?.barcode?` • ${ye.barcode}`:""}${ye?.quantity!==void 0&&ye?.quantity!==null?` • Stock: ${ye.quantity}`:""}`,product:ye}));xe&&v(ue)},250);return()=>{xe=!1,clearTimeout(he)}},[ie,k,W,K,m]),i.useEffect(()=>{h({}),p({}),u(""),v([]),I(!1),C(""),f(0),A(""),L(se()),j([])},[n,r,l]);const oe=i.useCallback((me,xe=1)=>{const he=me?.id;if(!he)return;const te=Number(me?.quantity||0);if(te<=0){_.error("Out of stock.",{duration:1e3});return}const ue=Xn(xe,te);h(ye=>{const Te=ye||{};return Object.prototype.hasOwnProperty.call(Te,Qe(he))?(_.error("Product already added.",{duration:1e3}),Te):{...Te,[Qe(he)]:ue}})},[h]),Ce=i.useCallback((me,xe,he)=>{h(te=>{const ue=te||{},ye=Qe(me);return Object.prototype.hasOwnProperty.call(ue,ye)?{...ue,[ye]:Xn(xe,he)}:ue})},[]),Pe=i.useCallback(me=>{h(xe=>{const he=xe||{},te=Qe(me);if(!Object.prototype.hasOwnProperty.call(he,te))return he;const ue={...he};return delete ue[te],ue})},[]),ke=i.useCallback((me,xe,he)=>{p(te=>({...te||{},[Qe(me)]:Xn(xe,he)}))},[]),Me=i.useCallback((me,xe)=>{xe?.product&&oe(xe.product,1),u(""),v(ie)},[oe,ie]),Oe=i.useCallback(me=>{if(me.key!=="Enter")return;me.preventDefault();const xe=Array.isArray(b)&&b.length>0?b[0]:null;if(xe?.product){oe(xe.product,1),u(""),v(ie);return}const he=String(m||"").trim().toLowerCase();if(he.length===0)return;const te=(Array.isArray(K)?K:[]).find(ue=>{const ye=String(ue?.name??"").toLowerCase(),Te=String(ue?.barcode??"").toLowerCase();return ye.includes(he)||Te.includes(he)});te&&(oe(te,1),u(""),v(ie))},[oe,ie,K,b,m]),Ve=()=>{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(!X||X.length===0){_.error("Add at least one product.",{duration:1e3});return}I(!0)},{trigger:We,isMutating:Fe}=Ge(t?ss.sellProduct:null,(me,{arg:xe})=>ka(me,{arg:xe},t)),Ye=async()=>{if(!D){_.error("Select payment type.",{duration:1e3});return}const me=(Array.isArray(X)?X:[]).map(he=>({id:he?.id,quantity:Number(he?.quantity||1),price:Number(he?.price||0),total_price:Number(he?.total_price||0),fk_vendor_id:he?.fk_vendor_id||"",fk_categoryID:he?.fk_categoryID||"",name:he?.name||"",class_id:he?.class_id||"",fk_sub_categoryID:he?.fk_sub_categoryID||"",description:he?.description||"",min_quantity:Number(he?.min_quantity||0),storecategory:Number(he?.storecategory||0),barcode:he?.barcode||""})),xe={amount:ce,class:n,section:r,student_id:l,payment_type:D,discount:je,notes:S||"",receipt_date:P?se(P).format("YYYY-MM-DD"):"",product:JSON.stringify(me),total_payable_amount:ce,attchement:N[0]?.originFileObj||""};try{const te=Array.isArray(N)&&N.length>0&&N[0]?.originFileObj?(()=>{const ye=new FormData;return Object.entries(xe).forEach(([Te,Ie])=>{if(Te==="products"){ye.append("product",JSON.stringify(Ie));return}ye.append(Te,String(Ie??""))}),ye.append("attachment",N[0].originFileObj),ye})():xe,ue=await We(te);ue?.Status==="Success"?(_.success("Success! Product sold.",{duration:1e3}),I(!1),h({}),p({}),u(""),v(ie),C(""),f(0),A(""),L(se()),j([])):_.error(ue?.msg??"Failed to submit.",{duration:1e3})}catch{_.error("Failed to submit.",{duration:1e3})}},lt=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:(me,xe)=>{const he=Qe(xe?.id),te=Number(xe?.quantity||0),ue=ae.has(he),ye=(ue?y?.[he]:w?.[he])??1;return e.jsx(s.InputNumber,{min:1,max:Number.isFinite(te)&&te>0?te:void 0,value:ye,onChange:Te=>{ue?Ce(he,Te,te):ke(he,Te,te)},disabled:te<=0})}},{title:"Amount",key:"amount",width:140,render:(me,xe)=>{const he=Qe(xe?.id),te=(ae.has(he)?y?.[he]:w?.[he])??1;return Number(xe?.price||0)*Number(te||1)}},{title:"Action",key:"action",width:120,render:(me,xe)=>{const he=Qe(xe?.id),te=Number(xe?.quantity||0),ue=ae.has(he),ye=(ue?y?.[he]:w?.[he])??1;return ue?e.jsx(s.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(Z.DeleteOutlined,{}),onClick:()=>Pe(he),style:{padding:2}}):e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.PlusOutlined,{}),disabled:te<=0,onClick:()=>oe(xe,ye),style:{padding:2}})}}],[oe,ae,y,w,Pe,ke,Ce]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(fe,{pt:5,pb:2,children:[e.jsxs(fe,{style:{padding:"12px 16px"},children:[e.jsx(fe,{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(ee,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:me=>{const xe=me?.value??"";a(xe),o(""),d(""),x(he=>!he)}}),e.jsx(ee,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:me=>{const xe=me?.value??"";o(xe),d("")}},`section_${c}`),e.jsx(ee,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:me=>d(me?.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(fe,{style:{marginTop:12},children:"Product Section"}),e.jsx(s.AutoComplete,{value:m,options:b,onSearch:u,onFocus:()=>{k&&String(m||"").trim().length<2&&v(ie)},onSelect:Me,disabled:!k,children:e.jsx(s.Input,{placeholder:"Search by product name or barcode",onKeyDown:Oe,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",ht(ce)]})]}),e.jsx(s.Table,{rowKey:me=>Qe(me?.id),columns:lt,dataSource:K,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:X.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(ce)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(le,{type:"button",value:"Submit",disabled:!k||X.length===0,onClick:Ve,style:{flex:1,minWidth:140}}),e.jsx(s.Button,{type:"text",style:M,onClick:()=>{h({}),p({}),u(""),v(ie)},disabled:X.length===0,children:"Clear"})]})]})]})})]}),e.jsx(s.Modal,{open:R,title:"Payment",onCancel:()=>I(!1),onOk:Ye,confirmLoading:Fe,okText:"Submit",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Payment Type"}),e.jsx(s.Select,{value:D||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(s.DatePicker,{value:P,onChange:me=>L(me),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:ce,value:g,onChange:me=>f(Number(me||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:N,beforeUpload:()=>!1,onChange:({fileList:me})=>j((me||[]).slice(-1)),maxCount:1,children:e.jsx(s.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(s.Input.TextArea,{value:S,onChange:me=>A(me.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(ce)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:ht(je)})]}),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 zc=({token:t})=>e.jsx(qc,{token:t}),ya=Ue.unit,Yc=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:ya.list,page:n,perPage:a,token:t}),Vc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Wc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:x,data:m,mutate:u}=Yc({token:t,page:n.page,perPage:n.rowsPerPage}),b=async I=>{try{await u(Un(ya.add,I,t),at(I)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){_.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},v=I=>{I.preventDefault();const D=new FormData(I.target);b(D),I.target.reset()},w=(I,D)=>{a({page:I,rowsPerPage:parseInt(D,10)})},p=async I=>{try{await u(Bn(ya.remove,I,t),Je(I)),_.success("Success! Deleted item.",{duration:1e3})}catch(D){_.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},y=I=>{d(I),o(!0)},h=async I=>{I.preventDefault();const D=new FormData(I.target);D.set("id",String(l?.id??""));try{await cn(ya.edit,D,t),await u(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(C){_.error(C?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},R=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(I,D)=>String(I?.name??"").localeCompare(String(D?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(I,D)=>String(I?.description??"").localeCompare(String(D?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(I,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(D),style:{padding:2}}),e.jsx(it,{id:D?.id,funcName:p})]})}],[p]);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:h,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(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Vc,children:"Cancel"})]})]})})}),e.jsxs(fe,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(fe,{px:3,pb:2,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(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(le,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(fe,{pt:3,children:e.jsx(Be,{parentCallback:w,data:{newData:m,columns:R,columnstype:"antd",action:!1,Loading:c,error:x}})})]})]})]})}const Hc=({token:t})=>e.jsx(Wc,{token:t}),Kc=Ue.product.sellReports,Gc=Ue.academy.classes,Jc=Ue.academy.sections,Qc=Ue.student.dropdown,qr=t=>{const n=Number(t??0);return Number.isFinite(n)?n.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function Xc({token:t}){const n=i.useRef(null),[a,r]=i.useState(null),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,m]=i.useState(""),[u,b]=i.useState(!1),v=j=>{const M=j?.data?.data??j?.data??j??[];return Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[]},{data:w}=G(t?[Gc,t]:null,([j,M])=>Q(j,M)),p=i.useMemo(()=>v(w),[w]),y=t&&o?`${Jc}?class_id=${encodeURIComponent(String(o))}`:null,{data:h}=G(y?[y,t]:null,([j,M])=>Q(j,M)),R=i.useMemo(()=>v(h),[h]),I=t&&o&&d?`${Qc}?class=${encodeURIComponent(String(o))}&section=${encodeURIComponent(String(d))}`:null,{data:D}=G(I?[I,t]:null,([j,M])=>Q(j,M)),C=i.useMemo(()=>v(D),[D]),{trigger:g,isMutating:f,data:S}=Ge(Kc,(j,{arg:M})=>Is(j,{arg:M},t));i.useEffect(()=>{const M=new Date().toISOString().slice(0,10);g({duration:[M,M]})},[g]);const A=i.useMemo(()=>{const j=S?.data??S??[];return Array.isArray(j)?j:[]},[S]),P=j=>{const M=Array.isArray(j?.product_details)?j.product_details:[];return M.length===0?null:e.jsx(s.Table,{size:"small",bordered:!0,pagination:!1,rowKey:k=>`${j?.receipt_id??"r"}_${k?.product_name??k?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:k=>qr(k)}],dataSource:M})},L=[{title:"Receipt No",dataIndex:"receipt_no",key:"receipt_no"},{title:"Date",dataIndex:"receipt_date",key:"receipt_date"},{title:"Amount",dataIndex:"receipt_amount",key:"receipt_amount",render:j=>qr(j)}],N=async()=>{if(!a||a.length!==2)return;const[j,M]=a;await g({duration:[j.format("YYYY-MM-DD"),M.format("YYYY-MM-DD")],class:o||"",section:d||"",student_id:x||""})};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(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:j=>{const M=j?.value??"";l(M),c(""),m(""),b(k=>!k)}}),e.jsx(ee,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:j=>{const M=j?.value??"";c(M),m("")}},`section_${u}`),e.jsx(ee,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:j=>m(j?.value??"")}),e.jsx(le,{type:"button",value:f?"Searching...":"Search",disabled:f,onClick:N,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(Ea,{data:{tableRef:n}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(jt,{})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:f,rowKey:j=>String(j?.receipt_id??j?.receipt_no??Math.random()),columns:L,expandable:{expandedRowRender:P},dataSource:A,pagination:{pageSize:20}})]})})})]})})}const Zc=({token:t})=>e.jsx(Xc,{token:t}),eu=Ue.product;function tu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState([]),[l,d]=i.useState([]),[c,x]=i.useState(!1),[m,u]=i.useState(!1),[b,v]=i.useState(null),[w,p]=i.useState(0),[y,h]=i.useState(null),[R,I]=i.useState(""),D=i.useRef(null),C=ln.useReactToPrint({contentRef:D,documentTitle:"Stock Barcodes"}),{isLoading:g,error:f,data:S,mutate:A}=ro({token:t,page:n.page,perPage:n.rowsPerPage}),P=(F,E)=>{a({page:F,rowsPerPage:parseInt(E,10)})},L={selectedRowKeys:r,onChange:(F,E)=>{o(F),d(E)}},N=F=>{v(F),p(Number(F?.quantity??0)),h(null),I(""),x(!0)},j=()=>{x(!1),v(null),p(0),h(null),I("")},M=async()=>{if(!b?.id)return;u(!0);const F=new FormData;F.append("product_id",String(b.id)),F.append("qty",String(w??0)),y&&F.append("tran_date",y.format("YYYY-MM-DD")),R&&F.append("remarks",R);try{const E=await cn(eu.addStock,F,t);E?.Status==="Success"?(_.success("Success! Updated quantity.",{duration:1e3}),j(),await A()):_.error(E?.msg??"Failed to update quantity.",{duration:1e3})}catch{_.error("Failed to update quantity.",{duration:1e3})}finally{u(!1)}},k=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",width:100},{title:"Unit",dataIndex:"unit_name",key:"unit_name",width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["lg"]},{title:"Action",key:"action",width:160,fixed:"right",render:(F,E)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(s.Button,{size:"small",onClick:()=>N(E),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:b?.name?`Update Stock: ${b.name}`:"Update Stock",open:c,onCancel:j,onOk:M,okButtonProps:{loading:m},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:w,onChange:F=>p(F??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{style:{width:"100%"},value:y,onChange:h})]}),e.jsx(It,{label:"Remarks",name:"remarks",rows:3,value:R,onChange:F=>I(F.target.value)})]})}),e.jsxs(fe,{pt:5,pb:2,children:[e.jsxs(fe,{children:["Manage Stock",e.jsx(le,{type:"button",value:"Print Barcodes",disabled:!l||l.length===0,onClick:()=>C?.(),style:{minWidth:170}})]}),e.jsx(fe,{style:{padding:"12px 16px"},children:e.jsx(s.Card,{style:{borderRadius:16},children:e.jsx(Be,{parentCallback:P,data:{newData:S,columns:k,columnstype:"antd",action:!1,Loading:g,error:f,rowSelection:L}})})})]}),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(F=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:F?.name??""}),e.jsx(Ci,{value:String(F?.barcode??F?.id??""),height:50,width:1.6,displayValue:!0})]},F?.id??F?.barcode??F?.name))})})})]})}const nu=({token:t})=>e.jsx(tu,{token:t}),au=Ue.report.stock,su=Ue.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?[su,t]:null,([p,y])=>Q(p,y)),c=i.useMemo(()=>ru(d),[d]),{trigger:x,isMutating:m,data:u}=Ge(au,(p,{arg:y})=>Is(p,{arg:y},t));i.useEffect(()=>{const y=new Date().toISOString().slice(0,10);x({duration:[y,y]})},[x]);const b=i.useMemo(()=>{const p=u?.data??u??[];return(Array.isArray(p)?p:[]).flatMap(h=>(Array.isArray(h?.ledger)?h.ledger:[]).map((R,I)=>({key:`${h.product_id??h.product_name??"p"}-${I}`,date:R?.date,product:h?.product_name,opening:R?.opening,inward:R?.inward,outward:R?.outward,closing:R?.closing})))},[u]),v=[{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:p=>e.jsx("span",{style:{color:Number(p)<0?"red":"green"},children:p})}],w=async()=>{if(!a||a.length!==2)return;const[p,y]=a;await x({duration:[p.format("YYYY-MM-DD"),y.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:p=>l(p.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),c.map(p=>e.jsx("option",{value:String(p?.value??""),children:String(p?.label??"")},String(p?.value??p?.id??p?.label)))]}),e.jsx(s.Button,{type:"primary",onClick:w,loading:m,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(Ea,{data:{tableRef:n}})})]}),e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(jt,{})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:m,rowKey:"key",columns:v,dataSource:b,pagination:{pageSize:50}})]})]})}const ou=({token:t})=>e.jsx(iu,{token:t}),Fa=t=>t??localStorage.getItem("authToken")??"",ks=(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"}},io=()=>ks(tt(),Ae.upload),lu=()=>ks(tt(),Ae.staff.uploadProfile),du=()=>ks(tt(),Ae.staff.uploadDocuments),cu=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,Fa(r))},xt=async(t,n,a)=>ze(t,n,Fa(a)),kt=async(t,n,a)=>pt(t,n,Fa(a)),qn=async(t,n,a)=>nt(t,n,Fa(a)),zt=Ae.staff,uu=Ae.master.shift.dropdown,pu=Ae.master.department.dropdown,mu=Ae.master.designation.dropdown,fu=Ae.roleDropdown,Zn=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},yu=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",bn={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"};function hu({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,x]=i.useState(r?.roleValue??null),[m,u]=i.useState(r?.departmentValue??null),[b,v]=i.useState(r?.designationValue??null),[w,p]=i.useState(r?.genderValue??null),[y,h]=i.useState(r?.shiftValue??(d?[]:null)),[R,I]=i.useState(r?.dob?se(r.dob):null),[D,C]=i.useState(r?.doj?se(r.doj):null),[g,f]=i.useState(r?.file??""),{data:S}=G(t?[uu,t]:null,([Y,q])=>Q(Y,q)),{data:A}=G(t?[pu,t]:null,([Y,q])=>Q(Y,q)),{data:P}=G(t?[mu,t]:null,([Y,q])=>Q(Y,q)),{data:L}=G(t?[fu,t]:null,([Y,q])=>Q(Y,q)),{data:N}=G(t?[zt.lastEmpNo,t]:null,([Y,q])=>Q(Y,q)),j=i.useMemo(()=>Zn(S),[S]),M=i.useMemo(()=>Zn(A),[A]),k=i.useMemo(()=>Zn(P),[P]),F=i.useMemo(()=>Zn(L),[L]),E=i.useMemo(()=>{const Y=N?.data?.emp_number??N?.emp_number??N?.data??"";return String(Y??"")},[N]),B=async Y=>{Y.preventDefault();const q=new FormData(Y.target);q.set("role",c?.value??c??""),q.set("department",m?.value??m??""),q.set("designation",b?.value??b??""),q.set("gender",w?.value??w??""),q.set("dob",R?R.format("YYYY-MM-DD"):""),q.set("doj",D?D.format("YYYY-MM-DD"):""),d?(q.delete("shift_id"),(Array.isArray(y)?y:[]).forEach(T=>{q.append("shift_id[]",T?.value??T??"")})):q.set("shift_id",y?.value??y??""),g&&q.set("file",g);try{const O=n==="edit"&&a,T=O?zt.editBasic:zt.addBasic;O&&q.set("staff_id",String(a));const $=O?await kt(T,q,t):await xt(T,q,t),U=$?.ID??$?.id??a??null;_.success("Success!",{duration:1e3}),o?.({staffId:U,basic:{roleValue:c,departmentValue:m,designationValue:b,genderValue:w,shiftValue:y,dob:R,doj:D,file:g}})}catch(O){_.error(O?.response?.data?.msg??O?.message??"Failed.",{duration:1e3})}};return 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(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(ee,{label:"Role",options:F,value:c,onChange:Y=>x(Y??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Department",options:M,value:m,onChange:Y=>u(Y??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Designation",options:k,value:b,onChange:Y=>v(Y??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:w,onChange:Y=>p(Y??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:bn,children:"DOB"}),e.jsx(s.DatePicker,{value:R,onChange:Y=>I(Y),style:zr,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:bn,children:"DOJ"}),e.jsx(s.DatePicker,{value:D,onChange:Y=>C(Y),style:zr,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:bn,children:"Shift"}),e.jsx(ee,{options:j,value:y,onChange:Y=>h(Y??(d?[]:null)),isMulti:d,closeMenuOnSelect:!d,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:bn,children:"Profile Picture"}),e.jsx(s.Upload,{maxCount:1,action:lu(),headers:t?{Authorization:t}:void 0,onChange:Y=>{if(Y?.file?.status==="done"){const q=yu(Y?.file?.response);q&&f(q)}Y?.file?.status==="removed"&&f("")},children:e.jsx(s.Button,{type:"link",style:{paddingLeft:0},children:g?"Change":"Upload"})})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:bn,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(le,{type:"submit",value:"Save & Next",color:"primary"})})]})})}const ea={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Yr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},gu=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Vr=t=>{if(!t)return null;const n=se(t);return n.isValid()?n:null};function xu({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(p=>({name:p?.name??"",from:Vr(p?.from),to:Vr(p?.to),image:p?.image??""}))),x=i.useMemo(()=>t?{Authorization:t}:void 0,[t]),m=(w,p)=>{c(y=>y.map((h,R)=>R===w?{...h,...p}:h))},u=()=>c(w=>[...w,{name:"",from:null,to:null,image:""}]),b=w=>c(p=>p.length<=1?p:p.filter((y,h)=>h!==w)),v=async w=>{if(w.preventDefault(),!a){_.error("Missing staff id.",{duration:1e3});return}const p=new FormData;p.append("staff_id",String(a)),d.forEach((y,h)=>{p.append(`experience[${h}][name]`,String(y?.name??"")),p.append(`experience[${h}][from]`,y?.from?y.from.format("YYYY-MM-DD"):""),p.append(`experience[${h}][to]`,y?.to?y.to.format("YYYY-MM-DD"):""),p.append(`experience[${h}][image]`,String(y?.image??""))});try{const y=n==="edit",h=y?zt.editExperience:zt.addExperience,R=y?await kt(h,p,t):await xt(h,p,t);_.success("Success!",{duration:1e3}),o?.({experience:d,result:R})}catch(y){_.error(y?.response?.data?.msg??y?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:v,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[d.map((w,p)=>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:w.name,onChange:y=>m(p,{name:y.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:w.from,onChange:y=>m(p,{from:y}),style:Yr})]}),e.jsxs("div",{children:[e.jsx("div",{style:ea,children:"To"}),e.jsx(s.DatePicker,{value:w.to,onChange:y=>m(p,{to:y}),style:Yr})]}),e.jsxs("div",{children:[e.jsx("div",{style:ea,children:"Document"}),e.jsx(s.Upload,{maxCount:1,action:du(),headers:x,onChange:y=>{if(y?.file?.status==="done"){const h=gu(y?.file?.response);h&&m(p,{image:h})}y?.file?.status==="removed"&&m(p,{image:""})},children:e.jsx(s.Button,{icon:e.jsx(Z.UploadOutlined,{}),children:"Upload"})}),!!w.image&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:w.image})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:e.jsx(s.Button,{type:"text",icon:e.jsx(Z.DeleteOutlined,{}),danger:!0,onClick:()=>b(p),disabled:d.length<=1})})]},`exp-${p}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(s.Button,{icon:e.jsx(Z.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(le,{type:"submit",value:"Save & Next",color:"primary"})]})]})]})})}const Wr=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:n??[]},Sn=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function bu({token:t,mode:n,staffId:a,initialValues:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(r?.type??"Permanent"),[x,m]=i.useState(r?.salary_type??Sn[0]?.value),[u,b]=i.useState(Number(r?.amount??0)),[v,w]=i.useState(Number(r?.basic_pay??0)),[p,y]=i.useState(r?.declarationPERyear??""),{data:h}=G(t?[ud,t]:null,([f,S])=>Q(f,S),{revalidateOnFocus:!1}),R=i.useMemo(()=>Wr(h?.Allowances),[h]),I=i.useMemo(()=>Wr(h?.Dedection),[h]),D=i.useMemo(()=>{const f=Number(v||0),S=(Array.isArray(R)?R:[]).map(j=>{const M=j?.amount_type??j?.amountType??j?.type,k=Number(j?.Amount??j?.amount??0),F=String(M).toLowerCase()==="flat"?k:Number(f)/100*Number(k||0);return{...j,value:Number.isFinite(F)?F:0}}),A=(Array.isArray(I)?I:[]).map(j=>{const M=j?.amount_type??j?.amountType??j?.type,k=Number(j?.Amount??j?.amount??0),F=String(M).toLowerCase()==="flat"?k:Number(f)/100*Number(k||0);return{...j,value:Number.isFinite(F)?F:0}}),P=S.reduce((j,M)=>j+Number(M?.value||0),0),L=A.reduce((j,M)=>j+Number(M?.value||0),0),N=Math.max(0,Number(f)+P-L);return{allowances:S,deductions:A,netAmount:N}},[R,I,v]),C=async f=>{if(f.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",x??""),S.append("amount",String(u||"")),S.append("Allowances",JSON.stringify([])),S.append("Dedection",JSON.stringify([]))):(S.append("basic_pay",String(v||"")),S.append("declarationPERyear",String(p??"")),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",P=A?zt.editPayroll:zt.addPayroll,L=A?await kt(P,S,t):await xt(P,S,t);_.success("Success!",{duration:1e3}),o?.({payroll:{staffType:d,salaryType:x,amount:u,basicPay:v,declaration:p},result:L})}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed.",{duration:1e3})}},g=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(f,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:f=>c(f?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),d==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(ee,{label:"Type",options:Sn,value:Sn.find(f=>f.value===x)??Sn[0],onChange:f=>m(f?.value??Sn[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(J,{type:"number",label:"Amount",value:u,onChange:f=>b(Number(f.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{type:"number",label:"Basic Pay",value:v,onChange:f=>w(Number(f.target.value||0)),required:!0}),e.jsx(J,{type:"text",label:"IT Declarations/Year",value:p,onChange:f=>y(f.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:(f,S)=>`${f?.title??"a"}-${S}`,columns:g,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:(f,S)=>`${f?.title??"d"}-${S}`,columns:g,dataSource:D.deductions,pagination:!1})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(Button,{onClick:l,children:"Back"}),e.jsx(le,{type:"submit",value:"Finish",color:"primary"})]})]})})}const Su=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function ju({token:t,mode:n="add",staffId:a,onFinished:r}){const[o,l]=i.useState(0),[d,c]=i.useState(a??null),[x,m]=i.useState(null),[u,b]=i.useState(null),[v,w]=i.useState(null),p=n==="edit"?a??d:null,y=i.useMemo(()=>p?`${Ae.staff.basicById}?staff_id=${encodeURIComponent(String(p))}`:null,[p]),h=i.useMemo(()=>p?`${Ae.staff.experienceById}?staff_id=${encodeURIComponent(String(p))}`:null,[p]),R=i.useMemo(()=>p?`${Ae.staff.payrollById}?staff_id=${encodeURIComponent(String(p))}`:null,[p]),{data:I}=G(t&&y?[y,t]:null,([P,L])=>Q(P,L)),{data:D}=G(t&&h?[h,t]:null,([P,L])=>Q(P,L)),{data:C}=G(t&&R?[R,t]:null,([P,L])=>Q(P,L)),g=i.useMemo(()=>{const P=Su(I)[0]??I?.data??I??null;return P?{emp_number:P?.emp_number??P?.empNo??"",f_name:P?.f_name??P?.firstname??P?.first_name??"",l_name:P?.l_name??P?.lastname??P?.last_name??"",pan_no:P?.pan_no??"",adhar_no:P?.adhar_no??"",email:P?.email??"",dob:P?.dob??"",doj:P?.doj??"",bloodGroup:P?.bloodGroup??P?.blood_group??"",contact_no:P?.contact_no??P?.phone??"",education:P?.education??"",address:P?.address??"",file:P?.file??P?.profile_picture??""}:null},[I]),f=i.useMemo(()=>{const P=D?.data??D??null;return(Array.isArray(P?.experience)?P.experience:Array.isArray(P)?P:[]).map(N=>({name:N?.name??"",from:N?.from??"",to:N?.to??"",image:N?.image??""}))},[D]),S=i.useMemo(()=>{const P=C?.data??C??null;return P?{type:P?.type??"Permanent",salary_type:P?.salary_type??"",amount:P?.amount??"",basic_pay:P?.basic_pay??"",declarationPERyear:P?.declarationPERyear??""}:null},[C]),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(hu,{token:t,mode:n,staffId:p,initialValues:g,onSubmitted:({staffId:P})=>{P&&c(P),l(1)}}),o===1&&e.jsx(xu,{token:t,mode:n,staffId:p??d,initialRows:f,onBack:()=>l(0),onSubmitted:()=>l(2)}),o===2&&e.jsx(bu,{token:t,mode:n,staffId:p??d,initialValues:S,onBack:()=>l(1),onSubmitted:()=>{_.success("Completed.",{duration:1e3}),r?.({staffId:p??d})}})]})})]})}function vu({token:t}){return e.jsx(ju,{token:t,mode:"add"})}const _u=({token:t})=>e.jsx(vu,{token:t}),ta=Ae.staff,wu=Ae.roleDropdown,Cu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Au=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Tu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(""),[l,d]=i.useState(""),{data:c}=G(t?[wu,t]:null,([R,I])=>Q(R,I)),x=i.useMemo(()=>Cu(c),[c]),m=i.useMemo(()=>{const R=n.page,I=n.rowsPerPage,D=r&&!l?`${ta.searchByRole}?role_id=${encodeURIComponent(String(r))}`:l?`${ta.searchByKeywords}?key=${encodeURIComponent(String(l))}`:ta.list,C=D.includes("?")?"&":"?";return`${D}${C}page=${encodeURIComponent(String(R))}&per_page=${encodeURIComponent(String(I))}`},[n.page,n.rowsPerPage,l,r]),{isLoading:u,error:b,data:v,mutate:w}=G(t?[m,t]:null,([R,I])=>Q(R,I)),p=i.useMemo(()=>Au(v),[v]),y=async R=>{const I=R?.id??R?.fk_staffID??R?.staff_id;if(I)try{await qn(ta.deactivate,I,t),_.success("Success! Staff deactivated.",{duration:1e3}),await w()}catch(D){_.error(D?.response?.data?.msg??D?.message??"Failed to deactivate staff.",{duration:1e3})}},h=i.useMemo(()=>[{title:"Name",key:"name",ellipsis:!0,render:(R,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:(R,I)=>e.jsx(s.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(Z.DeleteOutlined,{}),onClick:()=>y(I),style:{padding:2}})}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20,alignItems:"start"},children:[e.jsx(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(ee,{options:[{value:"",label:"All Roles"},...x],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:R=>{o(R?.value??""),a(I=>({...I,page:1}))}}),e.jsx(J,{type:"text",label:"Keyword",value:l,onChange:R=>d(R.target.value),placeholder:"Search by keywords"}),e.jsx(le,{type:"button",value:"Refresh",onClick:()=>w()})]})}),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:R=>String(R?.id??R?.fk_staffID??R?.staff_id??Math.random()),columns:h,dataSource:p,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(R,I)=>a({page:R,rowsPerPage:I}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]})}const Iu=({token:t})=>e.jsx(Tu,{token:t}),Ru=Ae.attendance,Du=Ae.roleDropdown,Hr=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"},Kr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Ou({token:t,open:n,onClose:a,roleId:r,onSaved:o}){const[l,d]=i.useState(null),[c,x]=i.useState(""),[m,u]=i.useState(se()),[b,v]=i.useState(se()),[w,p]=i.useState(se()),y=i.useMemo(()=>r?`${Ae.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(r))}`:null,[r]),{data:h}=G(t&&y?[y,t]:null,([f,S])=>Q(f,S)),R=i.useMemo(()=>Hr(h),[h]),{trigger:I,data:D}=Ge(t?Ae.attendance.staffShiftByStaffId:null,(f,{arg:S})=>qt(f,{arg:S},t)),C=i.useMemo(()=>Hr(D),[D]),g=async()=>{if(!l?.value){_.error("Select staff.",{duration:1e3});return}if(!c){_.error("Select shift.",{duration:1e3});return}const f=new FormData;f.set("staffID",String(l.value)),f.set("shift_id",String(c)),f.set("attendance_date",m?m.format("YYYY-MM-DD"):""),f.set("intime",b?b.format("h:mm a"):""),f.set("outime",w?w.format("h:mm a"):"");try{await xt(Ae.attendance.manualAttendance,f,t),_.success("Success!",{duration:1e3}),o?.(),a?.(),d(null),x(""),u(se()),v(se()),p(se())}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(ee,{label:"Staff",options:R,value:l,onChange:async f=>{if(d(f??null),x(""),f?.value&&I)try{await I({staff_id:f.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:f=>x(f.target.value),style:{display:"grid",gap:8},children:C.map(f=>e.jsx(s.Radio,{value:f?.value,children:f?.label??f?.name??f?.title??String(f?.value??"")},String(f?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:na,children:"Date"}),e.jsx(s.DatePicker,{value:m,onChange:f=>f&&u(f),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:b,onChange:f=>f&&v(f),use12Hours:!0,format:"h:mm a",style:Kr})]}),e.jsxs("div",{children:[e.jsx("div",{style:na,children:"End Time"}),e.jsx(s.TimePicker,{value:w,onChange:f=>f&&p(f),use12Hours:!0,format:"h:mm a",style:Kr})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(s.Button,{onClick:a,children:"Cancel"}),e.jsx(le,{type:"button",value:"Save",color:"primary",onClick:g})]})]})})})}const Pu=({tableRef:t,excelDisabled:n})=>{const a=new Date().getTime(),r=ln.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(Z.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(s.Col,{children:n?e.jsx(s.Button,{type:"text",icon:e.jsx(Z.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>_.error("You must save attendance before download",{duration:2e3})}):e.jsx(no.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:t?.current,children:e.jsx(s.Button,{type:"text",icon:e.jsx(Z.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},ku=(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:[]:[]},Eu=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},Mu=(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 Fu({token:t,url:n,columns:a,reload:r,setReload:o,saveBtnRef:l,setSaveBtnDisabled:d,date:c,type:x="staff"}){const m=i.useRef(null),[u,b]=i.useState({page:0,rowsPerPage:10}),[v,w]=i.useState(!1),[p,y]=i.useState(!1),[h,R]=i.useState(null),[I,D]=i.useState([]),[C,g]=i.useState({sunday:!1,holiday:!1}),[f,S]=i.useState(!0);i.useEffect(()=>{b(N=>({...N,page:0}))},[n]),i.useEffect(()=>{let N=!0;return(async()=>{if(!(!t||!n)){w(!0);try{const M=String(n).includes("?")?"&":"?",k=`${n}${M}page=${u.page+1}&per_page=${u.rowsPerPage}`,F=await Q(k,t);if(!N)return;R(F),F?.Status==="Success"?(d?.(!1),D(ku(F,x)),g(Mu(F,x))):(d?.(!0),D([]),g({sunday:!1,holiday:!1}))}catch{if(!N)return;d?.(!0),D([])}finally{N&&w(!1)}}})(),()=>{N=!1}},[u.page,u.rowsPerPage,r,d,t,x,n]);const A=i.useMemo(()=>Eu(h),[h]);i.useEffect(()=>{const N=(Array.isArray(I)?I:[]).find(j=>j?.attendence_type_id===null);S(!!N)},[I]);const P=async()=>{if(t){y(!0);try{if(x==="staff"){const N=(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 xt(Ae.attendance.addAttendanceToStaffByBranch,N,t),_.success("Attendance saved successfully",{duration:2e3}),o?.(j=>!j)}else _.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(N){_.error(N?.response?.data?.msg??N?.message??"Failed required dates",{duration:2e3})}finally{y(!1)}}},L=i.useMemo(()=>(Array.isArray(a)?a:[]).map(j=>j?.selector==="attendence_type_id"?{title:j?.name??"Attendance",dataIndex:j.selector,key:j.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)})}:j?.selector==="snum"?{title:j?.name??"Sl",key:j.selector,render:(M,k,F)=>F+1}:{title:j?.name??j?.selector,dataIndex:j?.selector,key:j?.selector}),[a]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{children:[e.jsx(Pu,{tableRef:m,excelDisabled:f}),e.jsx(s.Modal,{open:p,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..."})]})}),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:m,children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(N,j)=>String(N?.id??N?.staff_id??j),columns:L,dataSource:I,loading:v,pagination:{current:u.page+1,pageSize:u.rowsPerPage,total:A,showSizeChanger:!0,onChange:(N,j)=>b({page:N-1,rowsPerPage:j})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:P,ref:l,style:{display:"none"},children:"hidden"})]})]})]})}const $u=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Nu={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Uu({token:t}){const[n,a]=i.useState(""),[r,o]=i.useState(se().format("YYYY-MM-DD")),[l,d]=i.useState(!1),[c,x]=i.useState(null),[m,u]=i.useState(!1),[b,v]=i.useState(!0),[w,p]=i.useState(!1),y=i.useRef(null),{data:h}=G(t?[Du,t]:null,([D,C])=>Q(D,C)),R=i.useMemo(()=>$u(h),[h]),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(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(ee,{options:R,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:se(),onChange:D=>D&&o(D.format("YYYY-MM-DD")),style:Nu,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"button",value:"Search",color:"primary",onClick:()=>{!n||!r||(x(`${Ru.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:m?"primary":"default",onClick:()=>u(D=>!D),children:m?"Marked":"Mark As Holiday"}),e.jsx(s.Button,{size:"small",type:"default",disabled:b,onClick:()=>p(!0),children:"Give Attendance"})]}),c?e.jsx(Fu,{token:t,url:c,columns:I,reload:l,setReload:d,saveBtnRef:y,setSaveBtnDisabled:v,date:r,type:"staff",holidayChecked:m}):null]}),e.jsx(Ou,{token:t,open:w,onClose:()=>p(!1),roleId:n,onSaved:()=>d(D=>!D)})]})}const Bu=({token:t})=>e.jsx(Uu,{token:t}),Gr=Ae.attendanceReport.monthlyStaffReport,Lu=Ae.roleDropdown,qu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function zu({token:t}){const n=i.useRef(null),[a,r]=i.useState(!1),[o,l]=i.useState([]),[d,c]=i.useState({role:"",rolllabel:"",year:"",month:""}),x=i.useMemo(()=>Ds(5),[]),{data:m}=G(t?[Lu,t]:null,([N,j])=>Q(N,j)),u=i.useMemo(()=>qu(m),[m]),[b,v]=i.useState([]),[w,p]=i.useState(1),[y,h]=i.useState(!1),[R,I]=i.useState(!1),[D,C]=i.useState(null),g=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:f}=Ge(t&&Gr?`${Gr}?page=${w}&per_page=3`:null,(N,{arg:j})=>qt(N,{arg:j},t),{onSuccess:N=>{h(!1);const j=Array.isArray(N)?N:[];j.length>0&&v(M=>[...M||[],...j]),j.length>1?p(M=>M+1):I(!1)},onError:()=>{h(!1),I(!1)}});i.useEffect(()=>{R&&f&&D&&f(D)},[R,w,D,f]);const S=i.useMemo(()=>{const N=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(j,M)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:M?.full_name??""})}];return Array.isArray(b)&&b.length>0&&((b[0]?.monthly_data??[]).forEach((M,k)=>{N.push({title:k+1,align:"center",key:String(k+1),render:(F,E)=>{const B=E?.monthly_data?.[k]?.[0]?.data?.[0]??{},Y=B?.intime??"",q=B?.outtime??"",O=B?.attendance_type??"";return e.jsx(s.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",Y]}),e.jsxs("div",{children:["Out Time ",q]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:qe(O)})})}})}),N.push({title:"Total",key:"Total",render:(M,k)=>{const F=k?.monthly_data??[],E=F.filter(Y=>Y?.[0]?.data?.[0]?.attendance_type==="A").length,B=F.filter(Y=>Y?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",E," P : ",B]})})}})),N},[b]),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")}],[]),P=i.useMemo(()=>d.month?o.find(N=>N?.value==d.month)?.label??d.month??"--":"--",[d.month,o]),L=async N=>{if(N.preventDefault(),!d.role||!d.year||!d.month)return;p(1),h(!0),v([]);const j={session:g,year:d.year,month:d.month,day:"01",role:d.role};C(j),I(!0),await f?.(j)};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:L,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:N=>c(j=>({...j,role:N?.value??"",rolllabel:N?.label??""}))}),e.jsx(ee,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:N=>{const j=Os(N?.value);l(j),r(M=>!M),c(M=>({...M,year:N?.label??""}))}}),e.jsx(ee,{options:o,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:N=>c(j=>({...j,month:N?.value??""}))},`month-${a}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{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(jt,{})}),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:P})]})]})]}),e.jsx("div",{className:"d-print-none",style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(Ea,{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(N=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("div",{children:[N.label," :"]}),e.jsx("div",{children:N.el})]},N.label))})})]}),e.jsx(s.Skeleton,{active:!0,loading:y,paragraph:{rows:10},children:e.jsx(s.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:S,dataSource:b,pagination:!1,scroll:{x:"max-content"},rowKey:(N,j)=>String(N?.staff_id??N?.id??j)})})]})})]})}const Yu=({token:t})=>e.jsx(zu,{token:t}),Jr=Ae.payroll,Vu=Ae.roleDropdown,Wu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Hu=t=>t?.data?.data??t?.data??t??[];function Ku({token:t,receiptDetailsPath:n="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:a}){const[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,x]=i.useState([]),[m,u]=i.useState({role:"",roleLabel:"",year:"",month:""}),[b,v]=i.useState(null),w=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:p}=G(t?[Vu,t]:null,([S,A])=>Q(S,A)),y=i.useMemo(()=>Wu(p),[p]),h=i.useMemo(()=>Ds(5),[]),{isLoading:R,error:I,data:D}=G(t&&b?[b,t]:null,([S,A])=>Q(S,A)),C=i.useMemo(()=>{const S=Hu(D);return Array.isArray(S)?S:[]},[D]),g=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:C.length},[D,C.length]),f=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(S,A,P)=>P+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 P=A?.id??A?.staff_id??A?.staffId;return e.jsx(s.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{w(P)},children:eo(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(),!m.role||!m.year||!m.month)return;const A=`${Jr.payrollByRole}?page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.rowsPerPage))}&role=${encodeURIComponent(String(m.role))}&year=${encodeURIComponent(String(m.year))}&month=${encodeURIComponent(String(m.month))}`;v(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:y,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:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:S=>{const A=Os(S?.value);x(A),d(P=>!P),u(P=>({...P,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(le,{type:"submit",value:"Search",color:"primary",onClick:()=>o(S=>({...S,page:1}))})})]})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:R,rowKey:(S,A)=>String(S?.id??S?.staff_id??A),columns:f,dataSource:C,pagination:{current:r.page,pageSize:r.rowsPerPage,total:g,showSizeChanger:!0,onChange:(S,A)=>{o({page:S,rowsPerPage:A}),!(!m.role||!m.year||!m.month)&&v(`${Jr.payrollByRole}?page=${encodeURIComponent(String(S))}&per_page=${encodeURIComponent(String(A))}&role=${encodeURIComponent(String(m.role))}&year=${encodeURIComponent(String(m.year))}&month=${encodeURIComponent(String(m.month))}`)}},scroll:{x:"max-content"}})]})})}const Gu=({token:t})=>e.jsx(Ku,{token:t}),oo=Ae.leave,un=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,x])=>cu({baseUrl:l,page:d,perPage:c},x)),Ju=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:oo.requestTable,page:n,perPage:a}),Qu=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Xu=(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 Zu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),{isLoading:r,error:o,data:l,mutate:d}=Ju({token:t,page:n.page,perPage:n.rowsPerPage}),c=i.useMemo(()=>Qu(l),[l]),x=async(u,b)=>{try{const v=Xu(u,b),w=await kt(oo.approveRequest,v,t);w?.Status==="Success"?_.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):_.error(w?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to update request.",{duration:1e3})}},m=i.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(u,b)=>b?.full_name??b?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(u,b)=>b?.leave_from??b?.from_date??""},{title:"To",key:"leave_to",width:120,render:(u,b)=>b?.leave_to??b?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(u,b)=>b?.leavetype??b?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(u,b)=>b?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(u,b)=>b?.employee_remark??b?.reason??""},{title:"View",key:"document_file",width:140,render:(u,b)=>{const v=b?.document_file;return v?e.jsx(s.Button,{size:"small",onClick:()=>window.open(v,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(u,b)=>{const v=String(b?.status??"").toLowerCase();return v==="approved"?e.jsx(s.Tag,{color:"green",children:"Approved"}):v==="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:()=>x(b,"approved"),icon:e.jsx(Z.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(s.Button,{type:"text",size:"small",onClick:()=>x(b,"declined"),icon:e.jsx(Z.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,b)=>String(u?.id??u?.leave_id??b),columns:m,dataSource:c,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(u,b)=>a({page:u,rowsPerPage:b}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const ep=({token:t})=>e.jsx(Zu,{token:t}),tp=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",np=({token:t,value:n,onChange:a})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:io(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=tp(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},lo=Ae.leave,ap=Ae.master.leaveType.dropdown,sp=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:lo.table,page:n,perPage:a}),rp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},rs={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function ip({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:x,error:m,data:u,mutate:b}=sp({token:t,page:n.page,perPage:n.rowsPerPage}),{data:v}=G(t?[ap,t]:null,([C,g])=>Q(C,g)),w=i.useMemo(()=>rp(v),[v]),p=(C,g)=>a({page:C,rowsPerPage:parseInt(g,10)}),y=()=>{d(""),c.resetFields(),c.setFieldsValue({apply_date:se()}),o(!0)},h=()=>{o(!1),d(""),c.resetFields()},R=async C=>{const g=new FormData;g.set("apply_date",C?.apply_date?C.apply_date.format("YYYY-MM-DD"):""),g.set("leave_type",C?.leave_type?.value??C?.leave_type??""),g.set("from_date",C?.from_date?C.from_date.format("YYYY-MM-DD"):""),g.set("to_date",C?.to_date?C.to_date.format("YYYY-MM-DD"):""),g.set("reason",C?.reason??""),l&&g.set("file",l);try{await xt(lo.apply,g,t),_.success("Success! Leave request submitted.",{duration:1e3}),h(),await b()}catch(f){_.error(f?.response?.data?.msg??f?.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]),D=i.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(C,g)=>g?.leavetype??g?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(C,g)=>g?.date??g?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(C,g)=>g?.leave_from??g?.from_date??""},{title:"To",key:"leave_to",width:130,render:(C,g)=>g?.leave_to??g?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(C,g)=>g?.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:h,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:c,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:"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:rs})]})}),e.jsx(s.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(ee,{options:w,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:rs})]})}),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:rs})]})}),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(np,{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:h,children:"Cancel"}),e.jsx(le,{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(le,{type:"button",value:"Add Leave Request",onClick:y})}),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:x,rowKey:(C,g)=>String(C?.id??C?.leave_id??g),columns:D,dataSource:I,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(C,g)=>p(C,g),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const op=({token:t})=>e.jsx(ip,{token:t}),ha=Ae.master.leaveType,lp=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:ha.table,page:n,perPage:a});function dp({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,x]=i.useState(null),{isLoading:m,error:u,data:b,mutate:v}=lp({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,g)=>{a({page:C,rowsPerPage:parseInt(g,10)})},p=async C=>{const g=new FormData;g.set("title",C?.title??"");try{await v(xt(ha.add,g,t),at(g)),_.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to add leave type.",{duration:1e3})}},y=C=>{x(C??null),o.setFieldsValue({title:C?.leave_type_name??C?.name??""}),d(!0)},h=()=>{d(!1),x(null),o.resetFields()},R=async C=>{const g=c?.id??c?.leave_type_id;if(!g){_.error("Missing leave type id.",{duration:1e3});return}const f=new FormData;f.set("id",String(g)),f.set("title",C?.title??"");try{await kt(ha.edit,f,t),await v(),_.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),h()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update leave type.",{duration:1e3})}},I=async C=>{const g=C?.id??C?.leave_type_id;if(g)try{await v(qn(ha.remove,g,t),Je(g)),_.success("Success! Deleted leave type.",{duration:1e3})}catch(f){_.error(f?.response?.data?.msg??f?.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:(C,g)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(g)}),e.jsx(s.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>I(g),children:e.jsx(s.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(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Leave Type",onCancel:h,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:R,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:h,children:"Cancel"}),e.jsx(le,{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:p,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(le,{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(Be,{parentCallback:w,data:{newData:b,columns:D,columnstype:"antd",action:!1,Loading:m,error:u}})})]})}const cp=({token:t})=>e.jsx(dp,{token:t}),ga=Ae.master.department,up=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:ga.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,x]=i.useState(null),{isLoading:m,error:u,data:b,mutate:v}=up({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,g)=>{a({page:C,rowsPerPage:parseInt(g,10)})},p=async C=>{const g=new FormData;g.set("title",C?.title??"");try{await v(xt(ga.add,g,t),at(g)),_.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to add department.",{duration:1e3})}},y=C=>{x(C??null),o.setFieldsValue({title:C?.department_name??C?.name??""}),d(!0)},h=()=>{d(!1),x(null),o.resetFields()},R=async C=>{const g=c?.id??c?.department_id;if(!g){_.error("Missing department id.",{duration:1e3});return}const f=new FormData;f.set("id",String(g)),f.set("title",C?.title??"");try{await kt(ga.edit,f,t),await v(),_.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),h()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update department.",{duration:1e3})}},I=async C=>{const g=C?.id??C?.department_id;if(g)try{await v(qn(ga.remove,g,t),Je(g)),_.success("Success! Deleted department.",{duration:1e3})}catch(f){_.error(f?.response?.data?.msg??f?.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:(C,g)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(g)}),e.jsx(s.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>I(g),children:e.jsx(s.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(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Department",onCancel:h,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:R,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:h,children:"Cancel"}),e.jsx(le,{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:p,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(le,{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(Be,{parentCallback:w,data:{newData:b,columns:D,columnstype:"antd",action:!1,Loading:m,error:u}})})]})}const mp=({token:t})=>e.jsx(pp,{token:t}),xa=Ae.master.designation,fp=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:xa.table,page:n,perPage:a});function yp({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,x]=i.useState(null),{isLoading:m,error:u,data:b,mutate:v}=fp({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,g)=>{a({page:C,rowsPerPage:parseInt(g,10)})},p=async C=>{const g=new FormData;g.set("title",C?.title??"");try{await v(xt(xa.add,g,t),at(g)),_.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to add designation.",{duration:1e3})}},y=C=>{x(C??null),o.setFieldsValue({title:C?.designation??""}),d(!0)},h=()=>{d(!1),x(null),o.resetFields()},R=async C=>{const g=c?.id??c?.designation_id;if(!g){_.error("Missing designation id.",{duration:1e3});return}const f=new FormData;f.set("id",String(g)),f.set("title",C?.title??"");try{await kt(xa.edit,f,t),await v(),_.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),h()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update designation.",{duration:1e3})}},I=async C=>{const g=C?.id??C?.designation_id;if(g)try{await v(qn(xa.remove,g,t),Je(g)),_.success("Success! Deleted designation.",{duration:1e3})}catch(f){_.error(f?.response?.data?.msg??f?.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:(C,g)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(g)}),e.jsx(s.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>I(g),children:e.jsx(s.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(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Designation",onCancel:h,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:R,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:h,children:"Cancel"}),e.jsx(le,{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:p,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(le,{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(Be,{parentCallback:w,data:{newData:b,columns:D,columnstype:"antd",action:!1,Loading:m,error:u}})})]})}const hp=({token:t})=>e.jsx(yp,{token:t}),ba=Ae.master.shift,gp=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:ba.table,page:n,perPage:a}),Xe="hh:mm A",Zt=t=>{const n=String(t??"");if(!n)return null;const a=se(n,[Xe,"HH:mm","HH:mm:ss"],!0);return a.isValid()?a:null},en=t=>t?t.format(Xe):"",ut={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function xp({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,x]=i.useState(null),{isLoading:m,error:u,data:b,mutate:v}=gp({token:t,page:n.page,perPage:n.rowsPerPage}),w=(f,S)=>{a({page:f,rowsPerPage:parseInt(S,10)})},p=(f,S)=>{const A=new FormData;return S&&A.set("id",String(S)),A.set("name",f?.name??""),A.set("start_time",en(f?.start_time)),A.set("end_time",en(f?.end_time)),A.set("shift_start_from",en(f?.shift_start_from)),A.set("shift_start_to",en(f?.shift_start_to)),A.set("shift_end_from",en(f?.shift_end_from)),A.set("shift_end_to",en(f?.shift_end_to)),A},y=async f=>{try{const S=p(f);await v(xt(ba.add,S,t),at(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})}},h=f=>{x(f??null),o.setFieldsValue({name:f?.shift_name??f?.name??"",start_time:Zt(f?.start_time),end_time:Zt(f?.end_time),shift_start_from:Zt(f?.shift_start_from),shift_start_to:Zt(f?.shift_start_to),shift_end_from:Zt(f?.shift_end_from),shift_end_to:Zt(f?.shift_end_to)}),d(!0)},R=()=>{d(!1),x(null),o.resetFields()},I=async f=>{const S=c?.id??c?.shift_id;if(!S){_.error("Missing shift id.",{duration:1e3});return}try{const A=p(f,S);await kt(ba.edit,A,t),await v(),_.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),R()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update shift.",{duration:1e3})}},D=async f=>{const S=f?.id??f?.shift_id;if(S)try{await v(qn(ba.remove,S,t),Je(S)),_.success("Success! Deleted shift.",{duration:1e3})}catch(A){_.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:(f,S)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>h(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(Z.DeleteOutlined,{})})})]})}],[]),g=[{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:R,footer:null,destroyOnClose:!0,children:e.jsxs(s.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(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:g,children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"end_time",label:"End Time",rules:g,children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:R,children:"Cancel"}),e.jsx(le,{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:y,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:g,children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"end_time",label:"End Time",rules:g,children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(le,{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(Be,{parentCallback:w,data:{newData:b,columns:C,columnstype:"antd",action:!1,Loading:m,error:u}})})]})}const bp=({token:t})=>e.jsx(xp,{token:t}),Qr=Ae.attendance;function Sp({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 jp=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 _p({token:t}){const[n,a]=i.useState(se()),[r,o]=i.useState(!1),[l,d]=i.useState(0),c=i.useMemo(()=>`${r?Qr.dailyAttendanceMultipleShift:Qr.dailyAttendance}?attendance_date=${encodeURIComponent(n.format("YYYY-MM-DD"))}`,[n,r,l]),{isLoading:x,error:m,data:u}=G(t?[c,t]:null,([y,h])=>Q(y,h)),b=i.useMemo(()=>jp(u),[u]),v=i.useMemo(()=>r?u?.data?.data??u?.data??u??null:null,[u,r]),w=ln.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),p=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(y,h,R)=>R+1},{title:"Name",key:"name",render:(y,h)=>`${h?.name??""} ${h?.surname??""}`.trim(),ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(y,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[vp(h?.attendance),h?.late_time?e.jsx(s.Tag,{color:"red",children:"L"}):null]})},{title:"In Time",key:"intime",width:120,render:(y,h)=>h?.attendance_data?.[0]?.intime??""},{title:"Out Time",key:"outtime",width:120,render:(y,h)=>h?.attendance_data?.[0]?.outtime??""},{title:"Late",key:"late",width:100,render:(y,h)=>h?.late_time?e.jsx(s.Tag,{color:"red",children:h.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:y=>y&&a(y),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(le,{type:"button",value:"Search",onClick:()=>d(y=>y+1)})})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(Z.PrinterOutlined,{style:{color:"#5080f8",fontSize:18,cursor:"pointer"},onClick:w}),children:e.jsxs("div",{id:"ubk-hr-daily-attendance-print",children:[e.jsx("div",{className:"print-only",children:e.jsx(jt,{})}),r?e.jsx(Sp,{data:v}):e.jsx(s.Table,{bordered:!0,size:"small",loading:x,rowKey:(y,h)=>String(y?.id??y?.staff_id??h),columns:p,dataSource:b,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const wp=({token:t})=>e.jsx(_p,{token:t}),Xr=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},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:"":"";function Ap({token:t,staffId:n}){const[a,r]=i.useState(!1),[o,l]=i.useState(null),[d,c]=i.useState({value:"Cash",label:"Cash"}),[x,m]=i.useState(""),[u,b]=i.useState(""),v=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),w=P=>{const L=Number(P??0),N=Number.isFinite(L)?L.toLocaleString("en-IN"):"0";return`${v?`${v} `:""}${N}`},p=i.useMemo(()=>n?`${Ae.staff.basicById}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),y=i.useMemo(()=>n?`${Ae.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),{data:h}=G(t&&p?[p,t]:null,([P,L])=>Q(P,L)),{data:R,isLoading:I,mutate:D}=G(t&&y?[y,t]:null,([P,L])=>Q(P,L)),C=i.useMemo(()=>Xr(h)[0]??h?.data??h??null,[h]),g=i.useMemo(()=>Xr(R),[R]),f=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:(P,L)=>e.jsx("div",{style:{fontSize:11},children:ht(L?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(P,L)=>e.jsx("div",{style:{fontSize:11},children:ht(L?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(P,L)=>e.jsx("div",{style:{fontSize:11},children:ht(L?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(P,L)=>e.jsx("div",{style:{fontSize:11},children:ht(L?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(P,L)=>e.jsx("div",{style:{cursor:L?.status==="due"?"pointer":"default"},onClick:()=>{L?.status==="due"&&(l(L),r(!0))},children:eo(L?.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 P={...o,staff_id:n,payment_type:d?.value??"",notes:x,attchement:u};try{await ze(Ae.payroll.generatePayslip,{arg:P},t),_.success("Success!",{duration:1e3}),r(!1),l(null),m(""),b(""),await D()}catch(L){_.error(L?.response?.data?.msg??L?.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:C?`${C?.f_name??C?.firstname??""} ${C?.l_name??C?.lastname??""}`.trim():""}),e.jsx(s.Table,{bordered:!0,size:"small",loading:I,rowKey:(P,L)=>String(P?.id??`${P?.month}-${L}`),columns:f,dataSource:g,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(ee,{label:"Pay",options:S,value:d,onChange:P=>c(P??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:x,onChange:P=>m(P.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:io(),headers:t?{Authorization:t}:void 0,onChange:P=>{if(P?.file?.status==="done"){const L=Cp(P?.file?.response);L&&b(L)}P?.file?.status==="removed"&&b("")},children:e.jsx(s.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(s.Button,{onClick:()=>r(!1),children:"Cancel"}),e.jsx(le,{type:"button",value:o?.Total_Payable_Amount?`Pay ${w(o.Total_Payable_Amount)}`:"Pay",onClick:A})]})]})})]})}function Tp({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(Ap,{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 Et({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(Z.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(Z.FileExcelOutlined,{}),onClick:n},{key:"print",title:"Print",icon:e.jsx(Z.PrinterOutlined,{}),onClick:a},{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,n,a,r,o,l]),x=i.useMemo(()=>{const m=Array.isArray(d)&&d.length?new Set(d):null;return m?c.filter(u=>m.has(u.key)):c},[c,d]);return e.jsx(s.Space,{size:8,children:x.map(m=>e.jsx(s.Tooltip,{title:m.title,children:e.jsx(s.Button,{type:"text",icon:m.icon,onClick:m.onClick,disabled:!m.onClick})},m.key))})}const Es=t=>t??localStorage.getItem("authToken")??"",St={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"}},Rt=async(t,n)=>Q(t,Es(n)),Ip=async(t,n,a)=>ze(t,n,Es(a)),Rp=async(t,n,a)=>On(t,{arg:n},Es(a)),Pn=(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()}`},Zr=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}},Dp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},co=(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:[]},Op=t=>Array.isArray(t?.monthly_data)?t.monthly_data:Array.isArray(t?.month_data)?t.month_data:[],Pp=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)){Op(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},Ms=(t,n)=>{const{data:a,isLoading:r,error:o}=G(n&&t?[t,n]:null,([l,d])=>Rt(l,d));return{isLoading:r,error:o,data:a,options:i.useMemo(()=>Dp(a),[a])}},$a=t=>Ms(St.dropdowns.classes,t),Na=(t,n)=>{const a=t?`${St.dropdowns.sectionsByClass}?class_id=${encodeURIComponent(String(t))}`:null;return Ms(a,n)},kp=t=>Ms(St.dropdowns.sessions,t),Fs=t=>{const n=String(t??"").toUpperCase();return qe(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||"-")},uo=(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)},ei=t=>String(t??"").replace(/"/g,'""'),Ep=({rows:t,columns:n,fileName:a})=>{const r=Array.isArray(n)?n:[],o=Array.isArray(t)?t:[],l=r.map(c=>`"${ei(c?.title??c?.name??c?.key??c?.dataIndex)}"`).join(","),d=o.map((c,x)=>r.map(m=>{const u=m?.dataIndex??m?.selector??m?.key,b=u==="sl"?x+1:c?.[u];return`"${ei(b)}"`}).join(",")).join(`
59
+ `}),e.jsx(fe,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(Ea,{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:O.rowsPerPage,onChange:te=>U(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:k,onChange:te=>{F(te.target.value),T(ue=>({...ue,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(jt,{})}),he]}),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 ${me} to ${xe} of ${We} entries`}),e.jsx(s.Pagination,{current:O.page,pageSize:O.rowsPerPage,total:We||0,showSizeChanger:!1,onChange:U})]})]})]})},Od=({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:x,error:m}=G(t?[d,t]:null,([I,D])=>Q(I,D)),[u,b]=i.useState(!1),v=(I,D)=>{r({page:I,rowsPerPage:parseInt(D)})},w=async I=>{},p=I=>{console.log("dsdsdsdsd",I),b(I)},y=()=>{},h=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],R=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(I,D)=>I.name.localeCompare(D.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(I,D)=>(I.contact||"").localeCompare(D.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(I,D)=>(I.description||"").localeCompare(D.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(I,D)=>(I.source_name||"").localeCompare(D.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(I,D)=>new Date(I.date)-new Date(D.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(I,D)=>new Date(I.follow_up_date)-new Date(D.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Be,{parentCallback:v,data:{newData:x,columns:R,action:!0,Loading:c,error:m,open:u,viewDetails:y,deleteTodoMutation:w,DrawerUpdate:p,ActionView:h}})})},Pd={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"},le=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:{...Pd,opacity:a?.7:1,cursor:a?"not-allowed":"pointer",...r||{}}})})),it=({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(Z.DeleteOutlined,{}),size:"small"})})},at=t=>({optimisticData:n=>[...n.data,t],populateCache:(n,a)=>[...a.data,n]}),Je=t=>({optimisticData:n=>n.data.filter(a=>a.id!==t),populateCache:(n,a)=>a.data.filter(r=>r.id!==t)}),wr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function kd({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}`,x="api/branchapi/Transport/addroute",m="api/branchapi/Transport/editroute",u="api/branchapi/Transport/deleteroute",{isLoading:b,data:v,error:w,mutate:p}=G(t?[c,t]:null,([A,P])=>Q(A,P)),y=async(A,P)=>{try{await p(ze(A,P,t),at(P)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},h=A=>{A.preventDefault();const P=new FormData(A.target);y(x,P),A.target.reset()},R=(A,P)=>{a(L=>({...L,pagination:{current:A,pageSize:parseInt(P,10)}}))},I=async A=>{try{await p(nt(u,A,t),Je(A)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},D=A=>{d(A),o(!0)},C=async A=>{try{await pt(m,A,t),await p(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},g=async A=>{A.preventDefault();const P=new FormData(A.target);P.append("id",l?.id),C(P)},f=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(A,P)=>A.name.localeCompare(P.route_title)}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(A,P)=>A.fare-P.fare}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(A,P)=>A.note.localeCompare(P.note)}},{title:"Action",key:"action",render:(A,P)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>D(P),style:{padding:2}}),e.jsx(it,{id:P?.id,funcName:I})]})}],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:g,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(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:wr,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(fe,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsx("div",{children:e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Route"})}),e.jsx(fe,{px:3,pb:2,children:e.jsx("form",{onSubmit:h,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(le,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",style:wr,children:"Cancel"})]})]})})})]})}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Route List"})}),e.jsx(fe,{children:e.jsx(Be,{parentCallback:R,data:{newData:v,columns:f,columnstype:"antd",action:!1,Loading:b,error:w,deleteTodoMutation:I}})})]})})]})})]})}const Cr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Ed({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}`,x="api/branchapi/Transport/addvehicles",m="api/branchapi/Transport/editvehicle",u="api/branchapi/Transport/deletevehicle",{isLoading:b,data:v,error:w,mutate:p}=G(t?[c,t]:null,([A,P])=>Q(A,P)),y=async(A,P)=>{try{await p(ze(A,P,t),at(P)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},h=A=>{A.preventDefault();const P=new FormData(A.target);y(x,P),A.target.reset()},R=async A=>{try{await p(nt(u,A,t),Je(A)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},I=A=>{d(A),o(!0)},D=async A=>{try{await pt(m,A,t),await p(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},C=async A=>{A.preventDefault();const P=new FormData(A.target);P.append("id",l?.id),D(P)},g=(A,P)=>{a({page:A,rowsPerPage:parseInt(P,10)})},f=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(A,P)=>A.vehicle_no.localeCompare(P.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(A,P)=>A.vehicle_model.localeCompare(P.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(A,P)=>A.seating_capacity-P.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(A,P)=>A.manufacture_year-P.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(A,P)=>A.gps_url.localeCompare(P.gps_url)},render:(A,P)=>e.jsx("span",{title:P?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:P?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(A,P)=>A.note.localeCompare(P.note)}},{title:"Action",key:"action",render:(A,P)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>I(P),style:{padding:2}}),e.jsx(it,{id:P?.id,funcName:R})]})}],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:C,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(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Cr,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(fe,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(fe,{px:3,pb:2,children:e.jsx("form",{onSubmit:h,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(le,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",style:Cr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(fe,{children:e.jsx(Be,{parentCallback:g,data:{newData:v,columns:f,columnstype:"antd",action:!1,Loading:b,error:w,deleteTodoMutation:R}})})]})})]})})]})}var Md=Xi();const Za=Gi(Md),ao=()=>{};class Ps 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:ao,onFocus:()=>this.selectRef.focus(),required:a})]})}}Ps.defaultProps={onChange:ao};Ps.protoTypes={selectComponent:Za.func.isRequired,onChange:Za.func,required:Za.bool};const Fd={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},$d={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"})},so=t=>e.jsx(wi.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),Nd=t=>e.jsx(Ps,{...t,SelectComponent:wi,components:{Input:so},options:t.options}),ee=i.forwardRef(({...t},n)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:Fd,children:t?.label}),e.jsx(Nd,{components:{Input:so},menuPortalTarget:document.body,styles:$d,className:"input-cont",...t,ref:n})]})),Ud={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ar=({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 Bd({token:t}){const[n,a]=i.useState(!1),[r,o]=i.useState({pagination:{current:1,pageSize:50}}),[l,d]=i.useState(null),[c,x]=i.useState([]),m="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleDropdown",b="api/branchapi/Transport/getchechkedVehicleData",v="api/branchapi/Transport/assignedVehicleTable",w="api/branchapi/transport/assignvehicle",p="api/branchapi/Transport/deleteassignvehicle",y=l?`${b}?route_id=${l}`:null,{isLoading:h,data:R,mutate:I}=G(t?[`${v}?page=${r.pagination.current}&per_page=${r.pagination.pageSize}`,t]:null,([T,$])=>Q(T,$)),{data:D}=G(t&&m?[m,t]:null,([T,$])=>Q(T,$)),{data:C}=G(t&&u?[u,t]:null,([T,$])=>Q(T,$)),g=t&&y?[y,t]:null,{isLoading:f,data:S}=G(g,([T,$])=>Q(T,$)),{Status:A="Failed",pagination:{total_rows:P=0}={}}=R||{},{data:L=[]}=A==="Success"?R:{},N=i.useMemo(()=>{const T=D?.data??D??[];return Array.isArray(T)?T:[]},[D]),j=i.useMemo(()=>{const T=C?.data??C??[];return(Array.isArray(T)?T:[]).map(U=>{if(U==null)return null;if(typeof U=="string"||typeof U=="number")return{label:String(U),value:U};const z=U.value??U.vehicle_id??U.id??U.vehicleID,ne=U.label??U.vehicle_name??U.vehicle_no??U.vehicle_number??U.name??String(z??"");return z==null||ne===""?null:{label:String(ne),value:z}}).filter(Boolean)},[C]),M=i.useMemo(()=>{const T=S?.data??S??[];return(Array.isArray(T)?T:[]).map(U=>U?.value??U?.vehicle_id??U?.id??U).filter(U=>U!=null)},[S]);i.useEffect(()=>{x(M)},[M,n]);const k=async(T,$,U)=>{try{await I(ze(T,$,t),at($)),y&&G.mutate(g),a(z=>!z),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(z){_.error(z?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},F=T=>{T.preventDefault();const $=new FormData;$.append("route_id",l??""),c.length?c.forEach(U=>$.append("vehicle_ids[]",U)):$.append("vehicle_ids[]",""),k(w,$)},E=T=>{o($=>({...$,pagination:{current:T,pageSize:$.pagination.pageSize}}))},B=async T=>{try{await I(nt(p,T,t),Je(T)),y&&G.mutate(g),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},Y=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(T,$,U)=>e.jsx(e.Fragment,{children:$.children.map((z,ne,K)=>e.jsx("span",{children:`${z.vehicle_name} ${ne+1===K.length?"":","}`},`${ne}vehicle001`))})},{title:"Action",render:(T,$,U)=>e.jsx(e.Fragment,{children:e.jsx(it,{id:$?.route_id,funcName:B})})}],q=T=>{const $=["route_id","index"];for(let U=0;U<$.length;U++)if(T[$[U]])return T[$[U]]},O=T=>{const{children:$=[]}=T||{},U=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:z=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:z=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:z=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:z=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:z=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:z=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:z=>({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:Ar}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:U,rowKey:z=>q(z)+"cell01",dataSource:$,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(fe,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(fe,{px:3,pb:2,children:e.jsx("form",{onSubmit:F,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:N,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:j,value:c,onChange:T=>x(T),disabled:!l||f})},`check001${n}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),x([]),a(T=>!T)},style:Ud,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(fe,{style:{padding:"10px 16px"},children:e.jsx(s.Table,{components:{body:{cell:Ar}},columns:Y,bordered:!0,rowKey:T=>q(T),dataSource:Array.isArray(L)?L:[],loading:h,expandable:{expandedRowRender:O,childrenColumnName:"changed"},pagination:{current:r.pagination.current,pageSize:r.pagination.pageSize,total:P,showSizeChanger:!0,onChange:E,onShowSizeChange:(T,$)=>{o(U=>({...U,pagination:{current:1,pageSize:$}}))},showTotal:(T,$)=>`${$[0]}-${$[1]} of ${T} items`}})})]})})]})})]})}const Ld={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},qd={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},zd=(t,n,a)=>n?t>se(a).endOf("day")||t<se(n).endOf("day"):!1,Aa=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:Ld,children:r.Desplay}),e.jsx(s.DatePicker,{...r,style:{...qd,...r.style||{}},className:"form-group",disabledDate:o=>zd(o,r.sessionStart||r.minDate?.subtract(1,"day").format("YYYY-MM-DD"),r.sessionEnd||r.maxDate?.format("YYYY-MM-DD")),required:!0,ref:a})]})}),Tr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},es=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Qt=(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})},Yd=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Vd=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 Wd({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",x="api/branchapi/Transport/getvehicleListByRouteIdwithCount",m="api/branchapi/Transport/getStoppageDropdown",u="api/branchapi/Transport/routeShowdata",[b,v]=i.useState(null),[w,p]=i.useState(null),[y,h]=i.useState(null),[R,I]=i.useState(se()),[D,C]=i.useState(""),[g,f]=i.useState(0),[S,A]=i.useState(0),{data:P,isLoading:L}=G(t&&n?[`${l}?id=${n}`,t]:null,([W,oe])=>Q(W,oe)),N=i.useMemo(()=>{if(!P||P?.Status&&P.Status!=="Success")return null;const W=P?.data??P;return Array.isArray(W)?W[0]??null:W},[P]);i.useEffect(()=>{const W=N?.fk_route_id??N?.route_id;W!=null&&v(W),N?.vehicle_id!=null&&p(N.vehicle_id),N?.stop_id!=null&&h(N.stop_id),I(N?.start_date?se(N.start_date):se()),C(Vd(N?.service_push))},[N]);const j=t&&b?`${x}?route_id=${b}`:null,M=t&&b?`${u}?id=${b}`:null,k=t&&b?`${m}?route_id=${b}`:null,{data:F}=G(t&&c?[c,t]:null,([W,oe])=>Q(W,oe)),{data:E,isLoading:B}=G(j?[j,t]:null,([W,oe])=>Q(W,oe)),{data:Y,isLoading:q}=G(k?[k,t]:null,([W,oe])=>Q(W,oe)),{data:O}=G(M?[M,t]:null,([W,oe])=>Q(W,oe)),T=i.useMemo(()=>es(F),[F]),$=i.useMemo(()=>es(E),[E]),U=i.useMemo(()=>es(Y),[Y]),z=P?.data[0]?.rootCost,ne=Yd(),K=a||[N?.firstname,N?.lastname].filter(Boolean).join(" ")||"",V=(W,oe)=>{switch(oe){case"route_id":v(W?.value??null),p(null),h(null),f(Ce=>Ce+1),A(Ce=>Ce+1);break;case"vehicle_id":p(W?.value??null),h(null),A(Ce=>Ce+1);break;case"stop_id":h(W?.value??null);break}},X=async W=>{if(W.preventDefault(),!b||!w||!y){_.error("Please select Route, Vehicle and Stop",{duration:1200});return}const oe=new FormData;oe.append("id",String(n)),oe.append("student_id",String(N?.fk_student_id??N?.student_id??"")),oe.append("fk_route_id",String(b)),oe.append("vehicle_id",String(w)),oe.append("stop_id",String(y)),oe.append("rootCost",String(z??"")),oe.append("start_date",R?.isValid?.()?R.format("YYYY-MM-DD"):se().format("YYYY-MM-DD")),oe.append("puse_service",String(D??""));try{await pt(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(L||!(N&&!L&&(!b||!B&&!q)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(s.Spin,{})});if(!N)return e.jsxs("div",{style:{padding:"8px 0"},children:[e.jsx("p",{style:{color:"#666",fontSize:14,marginBottom:16},children:"Unable to load assignment details. Please try again."}),e.jsx(s.Button,{type:"text",onClick:r,style:Tr,children:"Close"})]});const ce=N.fk_route_id??N.route_id,je=Qt(T,ce,N.route_title),re=Qt($,N.vehicle_id,N.vehicle_name??N.vehicle_no),ie=Qt(U,N.stop_id,N.stop_name??N.stoppage_name);return e.jsx("form",{onSubmit:X,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(J,{type:"text",name:"title",label:"Student",defaultValue:K,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:N.fk_student_id??N.student_id??""}),e.jsx(ee,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:Qt(T,b,je?.label)??null,onChange:W=>V(W,"route_id")}),e.jsx(ee,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:Qt($,w,re?.label)??null,onChange:W=>V(W,"vehicle_id")},`edit-vehicle-${g}`),e.jsx(ee,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:Qt(U,y,ie?.label)??null,onChange:W=>V(W,"stop_id")},`edit-stop-${S}`),e.jsx(J,{type:"text",label:"Route Cost",value:z!=null?`${ne}${z}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:z??""}),e.jsx(Aa,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:R,onChange:W=>I(W)}),e.jsx(J,{type:"text",label:"Pause Service",value:D,onChange:W=>C(W?.target?.value??""),placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:r,style:Tr,children:"Cancel"})]})]})},`edit-${n}-${g}`)}const Ir={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Hd=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[]},gn=t=>Hd(t),Kd=t=>t||"",Gd=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Jd=t=>{const n=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return n==="page"||n==="sendpage"?"page":"drawer"},Qd=(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 Xd({token:t,editType:n,onNavigate:a,editPagePath:r}){const l=Jd(n)==="drawer",d="api/branchapi/academy/classdropdownlist",c="api/branchapi/academy/sectionoftheClass",x="api/branchapi/Transport/routeStudentList",m="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleListByRouteIdwithCount",b="api/branchapi/Transport/getStoppageDropdown",v="api/branchapi/Transport/routeShowdata",w="api/branchapi/Transport/assignTransportRoutesStudent",p="api/branchapi/transport/removeStudentTransport",[y,h]=i.useState(null),[R,I]=i.useState(!1),[D,C]=i.useState(!1),[g,f]=i.useState(null),[S,A]=i.useState(null),[P,L]=i.useState(null),[N,j]=i.useState(null),[M,k]=i.useState(!1),[F,E]=i.useState(!1),[B,Y]=i.useState({page:1,rowsPerPage:50}),[q,O]=i.useState(null),[T,$]=i.useState(!1),[U,z]=i.useState(null),[ne,K]=i.useState(null),[V,X]=i.useState(null),[ae,ce]=i.useState(null),[je,re]=i.useState(null),[ie,W]=i.useState(null),[oe,Ce]=i.useState(null),[Pe,ke]=i.useState(se()),[Me,Oe]=i.useState(""),Ve=(ge,ve)=>{const dt=ge?.value??null;switch(ve){case"class_id":X(dt),ce(null),O(dt?`${c}?class_id=${encodeURIComponent(String(dt))}`:null),I(Nt=>!Nt);break;case"route_id":re(dt),W(null),Ce(null),K(dt),A(dt?`${u}?route_id=${encodeURIComponent(String(dt))}`:null),L(dt?`${v}?id=${encodeURIComponent(String(dt))}`:null),j(null),k(Nt=>!Nt),E(Nt=>!Nt);break;case"vehicle_id":W(dt),Ce(null),j(je?`${b}?route_id=${encodeURIComponent(String(je))}`:null),E(Nt=>!Nt);break;case"stop_id":Ce(dt);break}},We=ge=>{if(l){f(ge),C(!0);return}const ve=Qd(ge,r);if(typeof a=="function"){a(ve,ge);return}typeof window<"u"&&ve&&window.location.assign(ve)},Fe=()=>{C(!1),f(null)},Ye=g?`Edit — ${g.firstname??""} ${g.lastname??""}`.trim():"Edit Student Transport",{data:lt}=G(t&&d?[d,t]:null,([ge,ve])=>Q(ge,ve)),{data:me}=G(t&&q?[q,t]:null,([ge,ve])=>Q(ge,ve)),{data:xe}=G(t&&S?[S,t]:null,([ge,ve])=>Q(ge,ve)),{data:he}=G(t&&N?[N,t]:null,([ge,ve])=>Q(ge,ve)),{data:te}=G(t&&P?[P,t]:null,([ge,ve])=>Q(ge,ve)),{data:ue}=G(t&&m?[m,t]:null,([ge,ve])=>Q(ge,ve)),ye=t&&y?`${y}&page=${B.page}&per_page=${B.rowsPerPage}`:null,{isLoading:Te,error:Ie,data:yt,mutate:_t}=G(ye?[ye,t]:null,([ge,ve])=>Q(ge,ve)),wt=i.useMemo(()=>gn(lt),[lt]),Wt=i.useMemo(()=>gn(me),[me]),Ht=i.useMemo(()=>gn(xe),[xe]),Kt=i.useMemo(()=>gn(he),[he]),de=i.useMemo(()=>gn(ue),[ue]),be=te?.data?.[0]?.fare??te?.data?.fare??te?.fare??te?.data?.data?.[0]?.fare??te?.data?.data?.fare;console.log("aaaaaaaaaaaa",te),i.useEffect(()=>{be==null||be===""||Oe(String(be))},[be]);const Ke=async ge=>{try{await _t(nt(p,ge,t),Je(ge)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},bt=[{title:"Route Status",key:"route_status",render:(ge,ve)=>ve.fk_route_id?e.jsx("span",{children:ve.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(ge,ve)=>Kd(ve.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:(ge,ve)=>`${ve.firstname} ${ve.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(ge,ve)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:ve.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(it,{id:ve?.id,funcName:Ke}),e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>We(ve),style:{padding:2}})]}):e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.PlusOutlined,{}),onClick:()=>Ft(ve.student_id),style:{padding:2}})})}],pe=async(ge,ve)=>{try{await _t(ze(ge,ve,t),at(ve)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),$(!1),$t()}catch{_.error("Failed to add the new item.",{duration:1e3})}},_e=ge=>{if(ge.preventDefault(),!V||!ae){_.error("Please select Class and Section",{duration:1200});return}h(`${x}?cID=${encodeURIComponent(String(V))}&sID=${encodeURIComponent(String(ae))}`),Y(ve=>({...ve,page:1}))},$e=(ge,ve)=>{Y({page:ge,rowsPerPage:parseInt(ve,10)})},Ft=ge=>{z(ge),$(!0)},pn=ge=>{if(ge.preventDefault(),!U){_.error("Student is required",{duration:1200});return}if(!je||!ie||!oe){_.error("Please select Route, Vehicle and Stop",{duration:1300});return}const ve=new FormData;ve.append("student_id",String(U)),ve.append("fk_route_id",String(je)),ve.append("vehicle_id",String(ie)),ve.append("stop_id",String(oe)),ve.append("start_date",Pe?.isValid?.()?Pe.format("YYYY-MM-DD"):se().format("YYYY-MM-DD")),ve.append("rootCost",String(Me??"")),pe(w,ve)},$t=()=>{$(!1),A(null),L(null),j(null),K(null),re(null),W(null),Ce(null),ke(se()),Oe(""),k(ge=>!ge),E(ge=>!ge)},wo=Gd();return e.jsxs("div",{children:[l&&e.jsx(s.Drawer,{open:D,title:Ye,placement:"right",width:420,destroyOnClose:!0,onClose:Fe,children:g?.id&&e.jsx(Wd,{token:t,assignmentId:g.id,studentName:`${g.firstname??""} ${g.lastname??""}`.trim(),onClose:Fe,onSuccess:()=>_t()})}),e.jsx(s.Modal,{open:T,title:"Assign Student to Transport",onCancel:$t,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:pn,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20},children:[e.jsx(ee,{options:de,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:de.find(ge=>String(ge.value)===String(je))??null,onChange:ge=>Ve(ge,"route_id")}),e.jsx(ee,{options:Ht,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:Ht.find(ge=>String(ge.value)===String(ie))??null,onChange:ge=>Ve(ge,"vehicle_id")},`vehicle001${M}`),e.jsx(ee,{options:Kt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:Kt.find(ge=>String(ge.value)===String(oe))??null,onChange:ge=>Ve(ge,"stop_id")},`stop001${F}`),e.jsx(Aa,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:Pe,onChange:ge=>ke(ge)}),e.jsx(J,{type:"text",name:"rootCost",label:"Route Cost",value:Me,onChange:ge=>Oe(ge?.target?.value??"")}),e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:String(Me??"").trim()?`${wo}${Me} — Assign`:"Assign",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:$t,style:Ir,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(fe,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Search Students"})}),e.jsx(fe,{px:3,pb:2,children:e.jsx("form",{onSubmit:_e,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:wt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:ge=>Ve(ge,"class_id"),required:!0,allowSelectAll:!1,value:wt.find(ge=>String(ge.value)===String(V))??null}),e.jsx(ee,{options:Wt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:Wt.find(ge=>String(ge.value)===String(ae))??null,onChange:ge=>ce(ge?.value??null)},`section1${R}`),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:"Search",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{h(null),O(null),X(null),ce(null),I(ge=>!ge)},style:Ir,children:"Cancel"})]})]})})})]}),y&&e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Student List"})}),e.jsx(fe,{children:e.jsx(Be,{parentCallback:$e,data:{newData:yt,columns:bt,columnstype:"antd",action:!1,Loading:Te,error:Ie,deleteTodoMutation:Ke,pageController:B}})})]})})]})})]})}const Rr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Kn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function Zd({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),[m,u]=i.useState(""),[b,v]=i.useState(""),[w,p]=i.useState(!1),y=`api/branchapi/Transport/getdriverTable?page=${n.page}&per_page=${n.rowsPerPage}`,h="api/branchapi/Transport/add_driver",R="api/branchapi/Transport/edit_driver",I="api/branchapi/Transport/deletedriver",D="api/branchapi/staff/uploadDocuments",C=i.useMemo(()=>String(D).startsWith("http")?D:`${tt()??""}${String(D).replace(/^\/+/,"")}`,[D]),g=tt()??"",{isLoading:f,data:S,error:A,mutate:P}=G(t?[y,t]:null,([q,O])=>Q(q,O)),L=async(q,O)=>{try{await ze(q,O,t),await P(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),x("")}catch(T){_.error(T?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},N=q=>{q.preventDefault();const O=new FormData(q.target);L(h,O),q.target.reset()},j=async q=>{try{await P(nt(I,q,t),Je(q)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},M=q=>{d(q),x(q?.image??""),o(!0)},k=async q=>{try{await pt(R,q,t),await P(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(O){_.error(O?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},F=q=>{q.preventDefault();const O=new FormData(q.target);O.append("id",l?.id??""),k(O)},E=(q,O)=>{a({page:q,rowsPerPage:parseInt(O,10)})},B=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(q,O)=>String(q?.name??"").localeCompare(String(O?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(q,O)=>String(q?.Driver_licence??"").localeCompare(String(O?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(q,O)=>Number(q?.contact_number??0)-Number(O?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(q,O)=>String(q?.address??"").localeCompare(String(O?.address??""))}},{title:"Image",key:"image",width:100,render:(q,O)=>{const T=O?.image?`${g}staff/document/${O.image}`:"";return T?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(s.Image,{width:80,src:T,preview:{visible:!1,onVisibleChange:()=>{p(!0),u(T),v(O?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(q,O)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>M(O),style:{padding:2}}),e.jsx(it,{id:O?.id,funcName:j})]})}],Y=l?.name?`Edit ${l.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:r,title:Y,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{o(!1),d(null),x("")},children:e.jsx("form",{onSubmit:F,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:Kn,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:Kn,children:"Image"}),e.jsx(s.Upload,{maxCount:1,action:C,headers:t?{Authorization:t}:void 0,onChange:q=>{if(q?.file?.status!=="done")return;const O=q?.file?.response,T=O?.data??O?.filename??O?.file??O?.path??"";T&&x(String(T))},children:e.jsx(s.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(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:Rr,children:"Cancel"})]})]})})}),e.jsx(s.Modal,{zIndex:9999,open:w,title:b,footer:null,onCancel:()=>p(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:m})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(fe,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(fe,{px:3,pb:2,children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(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:Kn,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:Kn,children:"Image"}),e.jsx(s.Upload,{maxCount:1,action:C,headers:t?{Authorization:t}:void 0,onChange:q=>{if(q?.file?.status!=="done")return;const O=q?.file?.response,T=O?.data??O?.filename??O?.file??O?.path??"";T&&x(String(T))},children:e.jsx(s.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(le,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",onClick:()=>x(""),style:Rr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(fe,{children:e.jsx(Be,{parentCallback:E,data:{newData:S,columns:B,columnstype:"antd",action:!1,Loading:f,error:A,deleteTodoMutation:j}})})]})})]})})]})}const Dr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Xt={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Gn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Or=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],Jn=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function ec({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(!1),[c,x]=i.useState(null),[m,u]=i.useState(null),[b,v]=i.useState(null),[w,p]=i.useState(null),[y,h]=i.useState(se()),[R,I]=i.useState(se()),[D,C]=i.useState("pick"),[g,f]=i.useState(!1),[S,A]=i.useState(null),[P,L]=i.useState(null),[N,j]=i.useState(!1),[M,k]=i.useState(null),[F,E]=i.useState(null),[B,Y]=i.useState(null),[q,O]=i.useState(null),[T,$]=i.useState(se()),[U,z]=i.useState(se()),[ne,K]=i.useState("pick"),V=`api/branchapi/Transport/assignRouteTimeList?page=${n.page}&per_page=${n.rowsPerPage}`,X="api/branchapi/Transport/assignRouteTime",ae="api/branchapi/Transport/editAssignRouteTime",ce="api/branchapi/Transport/deleteAssignRouteTime",je="api/branchapi/Transport/driverDropdown",re="api/branchapi/transport/routeTimetableShowdata",ie="api/branchapi/Transport/getrouteDropdown",W="api/branchapi/Transport/getvehicleDropdown",{isLoading:oe,data:Ce,error:Pe,mutate:ke}=G(t?[V,t]:null,([de,be])=>Q(de,be)),{data:Me}=G(t&&ie?[ie,t]:null,([de,be])=>Q(de,be)),{data:Oe}=G(t&&je?[je,t]:null,([de,be])=>Q(de,be)),Ve=i.useMemo(()=>c?`${W}?route_id=${c}`:null,[c,W]),{data:We}=G(t&&Ve?[Ve,t]:null,([de,be])=>Q(de,be)),Fe=i.useMemo(()=>Jn(Me),[Me]),Ye=i.useMemo(()=>Jn(Oe),[Oe]),lt=i.useMemo(()=>Jn(We),[We]),me=(de,be)=>{a({page:de,rowsPerPage:parseInt(be,10)})},xe=async de=>{de.preventDefault();const be=new FormData(de.target);be.set("route_id",m?.value??c??""),be.set("driver_id",b?.value??""),be.set("vehicle_id",w?.value??""),be.set("start_time",y?y.format("h:mm a"):""),be.set("drop_time",R?R.format("h:mm a"):""),be.set("type",D);try{await ze(X,be,t),await ke(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),de.target.reset(),x(null),u(null),v(null),p(null),d(Ke=>!Ke),h(se()),I(se()),C("pick"),o(Ke=>!Ke)}catch(Ke){_.error(Ke?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},he=async de=>{try{await nt(ce,de,t),await ke(),_.success("Success! Deleted item.",{duration:1e3})}catch(be){_.error(be?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},te=de=>{A(de),f(!0);const be=de?.id??de?.route_time_id??de?.routeId??null;L(be);const Ke=de?.route_id??de?.routeId??de?.fk_route_id;k(Ke??null),E(Fe.find(bt=>bt?.value===(Ke??de?.route_id))??null),Y(Ye.find(bt=>bt?.value===(de?.driver_id??de?.driverId))??null),O(null),j(bt=>!bt),$(de?.start_time?se(de.start_time,["h:mm a","HH:mm"]):se()),z(de?.drop_time?se(de.drop_time,["h:mm a","HH:mm"]):se()),K(de?.type??"pick")},ue=i.useMemo(()=>{if(!P)return null;const de=String(re).includes("?")?"&":"?";return`${re}${de}id=${encodeURIComponent(String(P))}`},[P,re]),{data:ye,isLoading:Te}=G(t&&ue?[ue,t]:null,([de,be])=>Q(de,be)),Ie=i.useMemo(()=>{const de=ye?.data??ye;return Array.isArray(de)?de[0]??null:Array.isArray(de?.data)?de.data[0]??null:de??null},[ye]),yt=i.useMemo(()=>M?`${W}?route_id=${M}`:null,[M,W]),{data:_t}=G(t&&yt?[yt,t]:null,([de,be])=>Q(de,be)),wt=i.useMemo(()=>Jn(_t),[_t]);i.useEffect(()=>{if(!Ie)return;const de=Ie?.route_id??Ie?.fk_route_id??Ie?.routeId;k(de??null),E(Fe.find(be=>be?.value===de)??null),Y(Ye.find(be=>be?.value===Ie?.driver_id)??null),O(null),$(Ie?.start_time?se(Ie.start_time,["h:mm a","HH:mm"]):se()),z(Ie?.drop_time?se(Ie.drop_time,["h:mm a","HH:mm"]):se()),K(Ie?.type??"pick"),j(be=>!be)},[Ye,Ie,Fe]),i.useEffect(()=>{if(!Ie)return;const de=Ie?.vehicle_id??Ie?.vehicleId;de&&O(wt.find(be=>be?.value===de)??null)},[Ie,wt]);const Wt=async de=>{if(de.preventDefault(),!P)return;const be=new FormData(de.target);be.set("id",String(P)),be.set("route_id",F?.value??M??""),be.set("driver_id",B?.value??""),be.set("vehicle_id",q?.value??""),be.set("start_time",T?T.format("h:mm a"):""),be.set("drop_time",U?U.format("h:mm a"):""),be.set("type",ne);try{await pt(ae,be,t),await ke(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),f(!1),A(null)}catch(Ke){_.error(Ke?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Ht=[{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:(de,be)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>te(be),style:{padding:2}}),e.jsx(it,{id:be?.id??be?.routeId??be?.route_time_id,funcName:he})]})}],Kt=S?.route_title?`Edit ${S.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(s.Drawer,{open:g,title:Kt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{f(!1),A(null),L(null),k(null),E(null),Y(null),O(null)},children:e.jsx("form",{onSubmit:Wt,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:Te?.6:1},children:[e.jsx(ee,{options:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:F,onChange:de=>{k(de?.value??null),E(de??null),O(null),j(be=>!be)}}),e.jsx(ee,{options:Ye,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:B,onChange:de=>Y(de??null)}),e.jsx(ee,{options:wt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:q,onChange:de=>O(de??null)},`edit-vehicle-${N}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Start Time"}),e.jsx(s.TimePicker,{value:T,onChange:de=>$(de),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Gn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Drop Time"}),e.jsx(s.TimePicker,{value:U,onChange:de=>z(de),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Gn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(s.Radio.Group,{options:Or,optionType:"button",buttonStyle:"solid",value:ne,onChange:de=>K(de.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{f(!1),A(null)},style:Dr,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(fe,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(fe,{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:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:m,onChange:de=>{x(de?.value??null),u(de??null),p(null),d(be=>!be)},allowSelectAll:!1,required:!0}),e.jsx(ee,{options:Ye,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:b,onChange:de=>v(de??null),allowSelectAll:!1,required:!0}),e.jsx(ee,{options:lt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:w,onChange:de=>p(de??null),allowSelectAll:!1,required:!0},`vehicle-${l}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Start Time"}),e.jsx(s.TimePicker,{value:y,onChange:de=>h(de),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Gn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Drop Time"}),e.jsx(s.TimePicker,{value:R,onChange:de=>I(de),use12Hours:!0,format:"h:mm a",allowClear:!1,style:Gn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:Xt,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(s.Radio.Group,{options:Or,optionType:"button",buttonStyle:"solid",value:D,onChange:de=>C(de.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:"Add",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"reset",onClick:()=>{x(null),u(null),v(null),p(null),d(de=>!de),h(se()),I(se()),C("pick"),o(de=>!de)},style:Dr,children:"Cancel"})]})]})},`form-${r}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(fe,{children:e.jsx(Be,{parentCallback:me,data:{newData:Ce,columns:Ht,columnstype:"antd",action:!1,Loading:oe,error:Pe,deleteTodoMutation:he}})})]})})]})})]})}const tc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Pr={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},kr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Er=({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 Mr=2;function nc({token:t}){const[n,a]=i.useState([]),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,x]=i.useState({pagination:{current:1,pageSize:50}}),{isLoading:m,data:u,mutate:b}=G(t?[`api/branchapi/transport/getrouteStoppageData?page=${c.pagination.current}&per_page=${c.pagination.pageSize}`,t]:null,([k,F])=>Q(k,F)),{Status:v="Failed",pagination:{total_rows:w=0}={}}=u||{},{data:p=[]}=v==="Success"?u:{},{data:y}=G(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([k,F])=>Q(k,F)),h=i.useMemo(()=>{const k=y?.data??y??[];if(Array.isArray(k))return k;if(k&&typeof k=="object"){if(Array.isArray(k?.data))return k.data;if(Array.isArray(k?.data?.data))return k.data.data}return[]},[y]),{data:R}=G(t&&r?["api/branchapi/transport/getrouteStoppageData?route_id="+r,t]:null,([k,F])=>Q(k,F)),{Status:I="Failed"}=R||{},D=async(k,F)=>{try{await b(ze(k,F,t),at(F)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},C=k=>k?typeof k=="string"?k:k?.isValid?.()?k.format("h:mm a"):"":"",g=(k,F=[])=>{const E=(Array.isArray(k)?k:[]).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)})),B=E.filter(q=>q?.id!=null&&String(q.id).trim()!==""),Y=E.filter(q=>!(q?.id!=null&&String(q.id).trim()!==""));return{route_id:r??"",edit_stoppage:B,add_stoppage:Y,delete_stoppage:Array.isArray(F)?F:[]}},f=k=>{k.preventDefault();const F="/api/branchapi/transport/addstoppageToRoute",E=g(n,l);D(F,E)},S=()=>{a(k=>[...Array.isArray(k)?k:[],{idKey:Mr++,stop_name:"",pickup_time:se().format("h:mm a"),drop_time:se().format("h:mm a")}])},A=k=>{if(n.length===1)return;const F=n[k];F?.id!=null&&String(F.id).trim()!==""&&!F?.idKey&&d(E=>{const B=Array.isArray(E)?E:[];return B.some(q=>String(q)===String(F.id))?B:[...B,F.id]}),a(E=>{const B=[...E];return B.splice(k,1),B})},P=k=>{x(F=>({...F,pagination:{current:k,pageSize:F.pagination.pageSize}}))},L=async k=>{const F="/api/branchapi/Transport/deletevehicle";try{await b(nt(F,k,t),Je(k)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}};i.useEffect(()=>{if(I==="Success"){const k=Array.isArray(R?.data)?R.data:[];k.length>0?(a(k),d([])):r&&(a([{idKey:Mr++,stop_name:"",pickup_time:se().format("h:mm a"),drop_time:se().format("h:mm a")}]),d([]))}},[I,R,r]);const N=k=>{const{children:F=[]}=k||{},E=[{title:"Stop Name",dataIndex:"stop_name",onCell:B=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:B=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:B=>({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:Er}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:E,rowKey:B=>j(B)+"cell01",dataSource:F,pagination:!1})})})},j=k=>{const F=["id","index"];for(let E=0;E<F.length;E++)if(k[F[E]])return k[F[E]]},M=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(k,F,E)=>e.jsx(e.Fragment,{children:(Array.isArray(F.children)?F.children:[]).map((B,Y,q)=>e.jsx("span",{children:`${B.stop_name} ${Y+1===q.length?"":","}`},`${Y}vehicle001`))})},{title:"Action",render:(k,F,E)=>e.jsx(e.Fragment,{children:e.jsx(it,{id:F?.route_id,funcName:L})})}];return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(fe,{pt:5,pb:1,children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(fe,{px:3,pb:2,children:e.jsxs("form",{onSubmit:f,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:h,value:h.find(k=>String(k.value)===String(r))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:k=>{o(k?.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(Z.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(le,{type:"submit",value:"Add",color:"primary"}),e.jsx(s.Button,{type:"text",htmlType:"button",onClick:()=>{o(null),a([]),d([])},style:tc,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:n.length>0&&n.map((k,F)=>{const E=k.pickup_time?se(k.pickup_time,"h:mm a"):null,B=k.drop_time?se(k.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:k.stop_name??"",type:"text",name:`stoppage[${F}][name]`,label:"Place Name*",required:"required",onChange:Y=>{const q=Y?.target?.value??"";a(O=>{const T=[...O];return T[F]={...T[F]??{},stop_name:q},T})}}),k?.id!=null&&String(k.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${F}][id]`,value:String(k.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Pr,children:"Pick Time"}),e.jsx(s.TimePicker,{value:E,use12Hours:!0,format:"h:mm a",name:`stoppage[${F}][pickTime]`,allowClear:!1,style:kr,onChange:Y=>{const q=Y?Y.format("h:mm a"):"";a(O=>{const T=[...O];return T[F]={...T[F]??{},pickup_time:q},T})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Pr,children:"Drop Time"}),e.jsx(s.TimePicker,{value:B,use12Hours:!0,format:"h:mm a",name:`stoppage[${F}][drop_time]`,allowClear:!1,style:kr,onChange:Y=>{const q=Y?Y.format("h:mm a"):"";a(O=>{const T=[...O];return T[F]={...T[F]??{},drop_time:q},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(F),children:e.jsx(Z.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},k.idKey?k.idKey+"exp":k.id+"exp")})})]})}),e.jsx(fe,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(fe,{style:{padding:"10px 16px"},children:e.jsx(s.Table,{components:{body:{cell:Er}},columns:M,bordered:!0,size:"small",rowKey:k=>j(k),dataSource:p,loading:m,expandable:{expandedRowRender:N,childrenColumnName:"changed"},pagination:{current:c.pagination.current,pageSize:c.pagination.pageSize,total:w,showSizeChanger:!0,onChange:P,onShowSizeChange:(k,F)=>{x(E=>({...E,pagination:{current:1,pageSize:F}}))},showTotal:(k,F)=>`${F[0]}-${F[1]} of ${k} items`}})})]})]})}const ac=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),r=String(n).replace(/^\/+/,"");return`${a}/${r}`};function sc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState(null),[o,l]=i.useState(null),[d,c]=i.useState(null),[x,m]=i.useState(null),[u,b]=i.useState(null),[v,w]=i.useState(null),[p,y]=i.useState(null),h="api/branchapi/library/bookCategorydropdown",R="api/branchapi/academy/classdropdownlist",I="api/branchapi/Academy/getClassSubjectdropdown",D="api/branchapi/library/addBook",C="api/branchapi/library/uploadcsv",{data:g}=G(n?[h,n]:null,([j,M])=>Q(j,M)),{data:f}=G(n&&R?[R,n]:null,([j,M])=>Q(j,M)),{data:S}=G(n&&I?[I,n]:null,([j,M])=>Q(j,M)),A=i.useMemo(()=>ac(tt(),C),[C]),P=async j=>{j.preventDefault();const M=new FormData(j.target);M.set("cat_id",u?.value??""),M.set("class_id",v?.value??""),M.set("subject_id",p?.value??"");try{await ze(D,M,n),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),j.target.reset(),b(null),w(null),y(null)}catch(k){_.error(k?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},L=async j=>{if(j.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",x?.value??"");try{const k=await Ne.post(A,M,{headers:{Authorization:n,"Content-type":"multipart/form-data"}});k?.data?.Status==="Failed"?_.error(String(k?.data?.msg??"Upload failed."),{duration:1e3}):(_.success(String(k?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),r(null),j.target.reset(),l(null),c(null),m(null))}catch(k){_.error(k?.response?.data?.msg??"Upload failed.",{duration:1e3})}},N=()=>{fetch("/books.csv").then(j=>{j.blob().then(M=>{const k=window.URL.createObjectURL(M);let F=document.createElement("a");F.href=k,F.download="/books.csv",F.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(Z.DownloadOutlined,{}),onClick:N,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:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:o,onChange:j=>l(j??null)}),e.jsx(ee,{options:f,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:x,onChange:j=>m(j??null)}),e.jsx(J,{type:"file",label:"Upload CSV",name:"csv",accept:".csv",onChange:j=>r(j.target.files?.[0]??null),required:!0}),e.jsx(le,{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:P,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(ee,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:u,onChange:j=>b(j??null)}),e.jsx(ee,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:v,onChange:j=>w(j??null)}),e.jsx(ee,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:p,onChange:j=>y(j??null)}),e.jsx(le,{type:"submit",value:"Save",color:"primary"})]})})})]})}const ts={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ns=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function rc({token:t}){const n=t??localStorage.getItem("authToken")??"",[a,r]=i.useState([]),[o,l]=i.useState([]),d=i.useRef(),c={selectedRowKeys:a,onChange:(X,ae)=>{r(X),l(ae)}},x=ln.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),m=()=>{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}x?.()}},[u,b]=i.useState(!1),[v,w]=i.useState(null),[p,y]=i.useState(null),[h,R]=i.useState(null),[I,D]=i.useState(null),[C,g]=i.useState({page:1,rowsPerPage:10}),f=(X,ae)=>{g({page:X,rowsPerPage:parseInt(ae,10)})},S="api/branchapi/library/booktable",A="api/branchapi/library/deletebooks",P="api/branchapi/library/editbook",L=`${S}?page=${C.page}&per_page=${C.rowsPerPage}`,{isLoading:N,error:j,data:M,mutate:k}=G(n?[L,n]:null,([X,ae])=>Q(X,ae)),F="api/branchapi/library/bookCategorydropdown",E="api/branchapi/academy/classdropdownlist",B="api/branchapi/Academy/getClassSubjectdropdown",{data:Y}=G(n?[F,n]:null,([X,ae])=>Q(X,ae)),{data:q}=G(n&&E?[E,n]:null,([X,ae])=>Q(X,ae)),{data:O}=G(n&&B?[B,n]:null,([X,ae])=>Q(X,ae)),T=i.useMemo(()=>ns(Y),[Y]),$=i.useMemo(()=>ns(q),[q]),U=i.useMemo(()=>ns(O),[O]),z=async X=>{try{await nt(A,X,n),await k(),_.success("Success! Deleted item.",{duration:1e3})}catch(ae){_.error(ae?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ne=X=>{w(X??null);const ae=X?.cat_id??X?.fk_cat_id??X?.category_id,ce=X?.class_id??X?.fk_class_id,je=X?.subject_id??X?.fk_subject_id;y(T.find(re=>re?.value===ae)??null),R($.find(re=>re?.value===ce)??null),D(U.find(re=>re?.value===je)??null),b(!0)},K=async X=>{X.preventDefault();const ae=v?.id??v?.book_id??v?._id;if(!ae)return;const ce=new FormData(X.target);ce.set("id",String(ae)),ce.set("cat_id",p?.value??""),ce.set("class_id",h?.value??""),ce.set("subject_id",I?.value??"");try{await pt(P,ce,n),await k(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),b(!1),w(null)}catch(je){_.error(je?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},V=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:(X,ae)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>ne(ae),style:{padding:2}}),e.jsx(s.Button,{type:"text",size:"small",danger:!0,onClick:()=>z(ae?.id??ae?.book_id??ae?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[T,$,z,U]);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:()=>{b(!1),w(null)},children:e.jsx("form",{onSubmit:K,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(J,{label:"Book Name",name:"title",defaultValue:v?.book_title??"",required:!0}),e.jsx(J,{label:"Author",name:"author",defaultValue:v?.author??"",required:!0}),e.jsx(J,{label:"Publication",name:"publish",defaultValue:v?.publish??""}),e.jsx(J,{label:"Qty",name:"quantity",type:"number",defaultValue:v?.quantity??""}),e.jsx(J,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:v?.perunitcost??""}),e.jsx(J,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:v?.fine_amount??""}),e.jsx(J,{label:"Barcode",name:"barcode",defaultValue:v?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ts,children:"Category"}),e.jsx(ee,{options:T,value:p,onChange:X=>y(X??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ts,children:"Class"}),e.jsx(ee,{options:$,value:h,onChange:X=>R(X??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ts,children:"Subject"}),e.jsx(ee,{options:U,value:I,onChange:X=>D(X??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{b(!1),w(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:m,children:["Print Barcode (",o.length,")"]}):null,children:e.jsx(Be,{parentCallback:f,data:{newData:M,columns:V,columnstype:"antd",action:!1,Loading:N,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((X,ae)=>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:X.book_title}),e.jsx(Ci,{value:X.barcode?String(X.barcode):String(X.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},ae))})})})]})}const ic=(t,n)=>{const a=String(t??"").replace(/\/+$/,""),r=String(n).replace(/^\/+/,"");return`${a}/${r}`},Ct=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function oc({token:t}){const n=t??localStorage.getItem("authToken")??"",a=JSON.parse(localStorage.getItem("genrall_settings")??"null")?.currency_symbol??"",[r,o]=i.useState("issue"),l=r==="return",[d,c]=i.useState(!1),[x,m]=i.useState(!1),[u,b]=i.useState(null),[v,w]=i.useState([]),[p,y]=i.useState([]),[h,R]=i.useState([]),[I,D]=i.useState(0),[C,g]=i.useState(!1),[f,S]=i.useState(null),[A,P]=i.useState(null),[L,N]=i.useState(null),[j,M]=i.useState(!1),[k,F]=i.useState("Cash"),[E,B]=i.useState(""),[Y,q]=i.useState(""),[O,T]=i.useState(0),$=i.useRef(null),[U]=s.Form.useForm(),[z]=s.Form.useForm(),ne="api/branchapi/library/bookCategorydropdown",K="api/branchapi/academy/classdropdownlist",V="api/branchapi/Academy/getClassSubjectdropdown",{data:X}=G(n?[ne,n]:null,([pe,_e])=>Q(pe,_e)),{data:ae}=G(n&&K?[K,n]:null,([pe,_e])=>Q(pe,_e)),{data:ce}=G(n&&V?[V,n]:null,([pe,_e])=>Q(pe,_e)),je=i.useMemo(()=>Ct(X),[X]),re=i.useMemo(()=>Ct(ae),[ae]),ie=i.useMemo(()=>Ct(ce),[ce]),W="api/branchapi/library/studentsearchByNameID",oe="api/branchapi/library/booksearchBybookname",Ce="api/branchapi/library/issuedBookList",Pe="api/branchapi/library/issueLibrarybook",ke="api/branchapi/library/returnedLibrarybook",{trigger:Me,data:Oe}=Ge(W,(pe,_e)=>qt(pe,_e,n)),{trigger:Ve,data:We}=Ge(oe,(pe,_e)=>qt(pe,_e,n)),{trigger:Fe,data:Ye}=Ge(Ce,(pe,_e)=>qt(pe,_e,n)),{trigger:lt}=Ge(l?ke:Pe,(pe,_e)=>ka(pe,_e,n)),me=i.useMemo(()=>Ct(Oe),[Oe]),xe=i.useMemo(()=>Ct(We),[We]),he=i.useMemo(()=>Ct(Ye),[Ye]),te=pe=>{const _e=se().format("YYYY-MM-DD");w($e=>$e.some(Ft=>String(Ft?.id)===String(pe?.id))?$e:[...$e,{...pe,return_date:pe?.return_date?pe.return_date:_e}])},ue=pe=>{w(_e=>_e.filter($e=>String($e?.id)!==String(pe)))},ye=async pe=>{if(n){if(!pe){b(null);return}d||await Me({id:pe})}},Te=async({search:pe})=>{if(!n||!d)return;const _e=await Me({id:pe}),$e=Ct(_e);$e.length===1&&(b($e[0]),await Fe({id:$e[0]?.student_id}),U.resetFields())},Ie=async(pe,_e)=>{b(_e??null),w([]),y([]),R([]),D(0),_e?.student_id&&await Fe({id:_e.student_id}),U.resetFields()},yt=async pe=>{n&&pe&&(x||await Ve({book:pe}))},_t=async({search_book:pe})=>{if(!n||!x)return;const _e=await Ve({book:pe,catID:f?.value??"",sID:L?.value??"",cID:A?.value??""}),$e=Ct(_e);$e.length&&(te($e[0]),z.resetFields())},wt=(pe,_e)=>{te(_e),z.resetFields()},Wt=async()=>{if(!u?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!v.length){_.error("Select at least one book.",{duration:1e3});return}const pe=await lt({member_id:u.member_id,fine:!1,books:v});pe?.Status==="Success"?(_.success(String(pe?.msg??"Success"),{duration:1e3}),w([]),b(null),y([]),R([]),D(0)):_.error(String(pe?.msg??"Failed"),{duration:1e3})},Ht=async()=>{if(!u?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!h.length){_.error("Select at least one book to return.",{duration:1e3});return}if(Number(I)>0){M(!0);return}const pe=await lt({member_id:u.member_id,fine:!1,books:JSON.stringify(h)});pe?.Status==="Success"?(_.success(String(pe?.msg??"Success"),{duration:1e3}),y([]),R([]),D(0),await Fe({id:u?.student_id})):_.error(String(pe?.msg??"Failed"),{duration:1e3})},Kt=async()=>{if(!u?.member_id)return;const pe=Math.max(0,Number(I)-Number(O||0)),_e={member_id:u.member_id,amount:pe,fine:!0,books:JSON.stringify(h),payment_type:k,notes:E,attchement:Y,discount:O||0},$e=await lt(_e);M(!1),$e?.Status==="Success"?(_.success(String($e?.msg??"Success"),{duration:1e3}),y([]),R([]),D(0),T(0),B(""),q(""),await Fe({id:u?.student_id})):_.error(String($e?.msg??"Failed"),{duration:1e3})},de=i.useMemo(()=>ic(tt(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),be=[{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:(pe,_e)=>e.jsx(s.Input,{value:_e?.return_date??"",onChange:$e=>{const Ft=$e.target.value;w(pn=>pn.map($t=>String($t?.id)===String(_e?.id)?{...$t,return_date:Ft}:$t))},placeholder:"YYYY-MM-DD"})},{title:"Action",key:"action",width:120,fixed:"right",render:(pe,_e)=>e.jsx(s.Button,{type:"text",danger:!0,onClick:()=>ue(_e?.id),children:"Remove"})}],Ke={selectedRowKeys:p,onChange:(pe,_e)=>{y(pe),R(_e);const $e=(_e??[]).reduce((Ft,pn)=>Ft+Number(pn?.totalfine??0),0);D($e)}},bt=[{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:"Due Date",dataIndex:"due_date",key:"due_date",width:140,responsive:["lg"]},{title:"Fine",dataIndex:"totalfine",key:"totalfine",width:120,fixed:"right",render:pe=>e.jsxs("span",{children:[a," ",pe]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:j,onCancel:()=>M(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(s.Radio.Group,{value:k,onChange:pe=>F(pe.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:E,onChange:pe=>B(pe.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(s.Upload,{action:de,headers:{Authorization:n},maxCount:1,onChange:pe=>{if(pe.file.status==="done"){const _e=pe.file.response?.data??pe.file.response?.file??"";q(String(_e??""))}},children:e.jsx(s.Button,{icon:e.jsx(Z.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(s.Input,{type:"number",value:O,onChange:pe=>T(pe.target.value),placeholder:"0"})]}),e.jsxs(s.Button,{type:"primary",onClick:Kt,children:["Collect ",a,Math.max(0,Number(I)-Number(O||0))]})]})}),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:r,onChange:pe=>{const _e=pe.target.value;o(_e),w([]),y([]),R([]),D(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(s.Col,{xs:24,md:14,children:e.jsx(s.Form,{form:U,onFinish:Te,layout:"vertical",children:e.jsx(s.Form.Item,{name:"search",label:"Search Student",children:e.jsx(s.Space.Compact,{style:{width:"100%"},children:d?e.jsx(s.Input,{autoFocus:!0,addonBefore:e.jsxs(s.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:d,onChange:pe=>c(pe.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(s.AutoComplete,{options:me,onSelect:Ie,onSearch:ye,style:{width:"100%"},allowClear:!0,children:e.jsx(s.Input,{addonBefore:e.jsxs(s.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:d,onChange:pe=>c(pe.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),u?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:"})," ",u?.value??""]}),e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Card No:"})," ",u?.library_card_no??""]}),e.jsxs(s.Col,{xs:24,md:8,children:[e.jsx(s.Typography.Text,{strong:!0,children:"Member ID:"})," ",u?.member_id??""]})]})]}):null,e.jsx(s.Divider,{}),l?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:bt,rowSelection:Ke,pagination:!1,rowKey:pe=>pe?.id??pe?.issue_id??pe?.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: ",a,I]}),e.jsx(s.Button,{type:"primary",onClick:Ht,disabled:!h.length,children:I>0?`Pay Now ${a}${Math.max(0,Number(I)-Number(O||0))}`:"Return Selected"})]})]}):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:z,onFinish:_t,layout:"vertical",children:e.jsx(s.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(s.Space.Compact,{style:{width:"100%"},children:x?e.jsx(s.Input,{autoFocus:!0,disabled:!u,addonBefore:e.jsxs(s.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:x,onChange:pe=>m(pe.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(s.AutoComplete,{disabled:!u,options:xe,onSelect:wt,onSearch:yt,style:{width:"100%"},allowClear:!0,children:e.jsx(s.Input,{addonBefore:e.jsxs(s.Space,{children:[e.jsx(Z.BarcodeOutlined,{}),e.jsx(s.Checkbox,{checked:x,onChange:pe=>m(pe.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(Z.FilterOutlined,{}),onClick:()=>g(!0),children:"Filter"})})]}),e.jsx(s.Drawer,{open:C,onClose:()=>g(!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:je,value:f,onChange:pe=>S(pe??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(ee,{label:"Class",options:re,value:A,onChange:pe=>P(pe??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(ee,{label:"Subjects",options:ie,value:L,onChange:pe=>N(pe??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(s.Button,{type:"primary",onClick:()=>g(!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:v,columns:be,pagination:!1,rowKey:pe=>pe?.id??pe?.book_id??pe?.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(le,{type:"button",value:"Issue",onClick:Wt})})]})]}),e.jsx("div",{ref:$,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}const Fr=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function lc({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),[x,m]=i.useState(!1),[u,b]=i.useState(!1),[v,w]=i.useState(null),[p,y]=i.useState(!1),h="api/branchapi/academy/classdropdownlist",R="api/branchapi/academy/sectionoftheClass",I="api/branchapi/library/studenttableForLibrary",D="api/branchapi/library/addmembershipforStudent",C="api/branchapi/library/removemembershipforStudent",g=i.useMemo(()=>{if(!o?.value)return null;const O=R.includes("?")?"&":"?";return`${R}${O}class_id=${encodeURIComponent(String(o.value))}`},[R,o?.value]),f=i.useMemo(()=>{if(!o?.value||!d?.value)return null;const O=I.includes("?")?"&":"?";return`${I}${O}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,I]),{data:S}=G(n&&h?[h,n]:null,([O,T])=>Q(O,T)),{data:A}=G(n&&g?[g,n]:null,([O,T])=>Q(O,T)),{isLoading:P,error:L,data:N,mutate:j}=G(n&&f?[f,n]:null,([O,T])=>Q(O,T)),M=i.useMemo(()=>Fr(S),[S]),k=i.useMemo(()=>Fr(A),[A]),F=(O,T)=>{r({page:O,rowsPerPage:parseInt(T,10)})},E=O=>{const T=O?.id??O?.student_id??O?.member_id;w(T??null),b(!0),y($=>!$)},B=async O=>{if(O.preventDefault(),!v)return;const T=new FormData(O.target);T.set("id",String(v));try{await ze(D,T,n),_.success("Success! Added member.",{duration:1e3,icon:"🎉"}),b(!1),w(null),await j()}catch($){_.error($?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},Y=async O=>{try{await nt(C,O,n),_.success("Success! Removed member.",{duration:1e3}),await j()}catch(T){_.error(T?.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:(O,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(Z.UserAddOutlined,{}),onClick:()=>E(T)}):e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{}),onClick:()=>Y(T?.id??T?.student_id??T?.member_id)})}))}],[Y]);return e.jsxs("div",{style:{},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:u,title:"Add Member",onCancel:()=>{b(!1),w(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:B,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(le,{type:"submit",value:"Add",color:"primary"})})]})},`add-${p}`)}),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(ee,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:o,onChange:O=>{l(O??null),c(null),m(T=>!T)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(ee,{options:k,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:O=>c(O??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${x}`),e.jsx(le,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!o?.value||!d?.value){_.error("Select class and section.",{duration:1e3});return}r(O=>({...O,page:1}))}})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Be,{parentCallback:F,data:{newData:N,columns:q,columnstype:"antd",action:!1,Loading:P,error:L}})})]})}function dc({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),[x,m]=i.useState(null),u="api/branchapi/library/BookCategorytable",b="api/branchapi/library/addBookCategory",v="api/branchapi/library/editBookCategory",w="api/branchapi/library/deleteBookCategory",p=i.useMemo(()=>{const L=u.includes("?")?"&":"?";return`${u}${L}page=${a.page}&per_page=${a.rowsPerPage}`},[u,a.page,a.rowsPerPage]),{isLoading:y,error:h,data:R,mutate:I}=G(n&&p?[p,n]:null,([L,N])=>Q(L,N)),D=(L,N)=>{r({page:L,rowsPerPage:parseInt(N,10)})},C=async L=>{const N=new FormData;N.set("title",L?.title??"");try{await ze(b,N,n),_.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),o.resetFields(),await I()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to add category.",{duration:1e3})}},g=L=>{m(L??null),l.setFieldsValue({title:L?.name??""}),c(!0)},f=()=>{c(!1),m(null),l.resetFields()},S=async L=>{const N=x?.id??x?.category_id??x?.cat_id;if(!N){_.error("Missing category id.",{duration:1e3});return}const j=new FormData;j.set("id",String(N)),j.set("title",L?.title??"");try{await pt(v,j,n),_.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),f(),await I()}catch(M){_.error(M?.response?.data?.msg??M?.message??"Failed to update category.",{duration:1e3})}},A=async L=>{const N=L?.id??L?.category_id??L?.cat_id;if(!N){_.error("Missing category id.",{duration:1e3});return}try{await nt(w,N,n),_.success("Success! Deleted category.",{duration:1e3}),await I()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to delete category.",{duration:1e3})}},P=i.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(L,N)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>g(N)}),e.jsx(s.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>A(N),children:e.jsx(s.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[A]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:d,title:"Edit Category",onCancel:f,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:f,children:"Cancel"}),e.jsx(le,{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:C,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(le,{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(Be,{parentCallback:D,data:{newData:R,columns:P,columnstype:"antd",action:!1,Loading:y,error:h}})})})]})]})}const as=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]};function cc({token:t}){const[n,a]=i.useState([se().format("YYYY-MM-DD"),se().format("YYYY-MM-DD")]),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,x]=i.useState(null),[m,u]=i.useState(!1),[b,v]=i.useState(!1),w="api/branchapi/academy/classdropdownlist",p="api/branchapi/academy/sectionoftheClass",y="api/branchapi/library/memberDropdown",h="api/report/libraryReport/libraryReport",R=i.useMemo(()=>{if(!r?.value)return null;const E=p.includes("?")?"&":"?";return`${p}${E}class_id=${encodeURIComponent(String(r.value))}`},[p,r?.value]),I=i.useMemo(()=>{if(!r?.value)return null;const E=y.includes("?")?"&":"?",B=`${y}${E}class=${encodeURIComponent(String(r.value))}`;return l?.value?`${B}&section=${encodeURIComponent(String(l.value))}`:B},[y,r?.value,l?.value]),{isLoading:D,error:C,data:g,mutate:f}=G(t&&w?[w,t]:null,([E,B])=>Q(E,B)),{data:S}=G(t&&R?[R,t]:null,([E,B])=>Q(E,B)),{data:A}=G(t&&I?[I,t]:null,([E,B])=>Q(E,B)),P=i.useMemo(()=>as(g),[g]),L=i.useMemo(()=>as(S),[S]),N=i.useMemo(()=>as(A),[A]),{trigger:j,data:M}=Ge(h,(E,B)=>Is(E,B,t));i.useEffect(()=>{(async()=>{v(!0);try{await j({duration:n})}finally{v(!1)}})()},[]);const k=async()=>{v(!0);try{await j({duration:n,class:r?.value??"",section:l?.value??"",student_id:c?.value??""})}finally{v(!1)}},F=[{title:"Name",dataIndex:"full_name",render:(E,B)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:B?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(E,B)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:B?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(E,B)=>e.jsxs(s.Typography.Text,{style:{fontSize:12},children:[B?.class??"","(",B?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(E,B)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:B?.book_title??""})},{title:"Issue Date",key:"date",render:(E,B,Y)=>e.jsx(s.Typography.Text,{style:{fontSize:12},children:B?.issue_date??""})},{title:"Due Return Date",key:"date",render:(E,B,Y)=>e.jsx(s.Tag,{color:"orange",children:B?.return_date??""})},{title:"Return Date",key:"date",render:(E,B,Y)=>B?.retured_by_user?e.jsx(s.Tag,{color:"green",children:B?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(E,B,Y)=>String(B?.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,B,Y)=>{const q=B?.late_fine?Number(B.late_fine):0;return q?e.jsx(s.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:q}):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:[se(n[0],"YYYY-MM-DD"),se(n[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(E,B)=>{Array.isArray(B)&&B.length===2&&a([B[0],B[1]])}})]})}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ee,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:r,onChange:E=>{o(E??null),d(null),x(null),u(B=>!B)},allowSelectAll:!1})}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:l,onChange:E=>{d(E??null),x(null)},allowSelectAll:!1},`section1${m}`)}),e.jsx(s.Col,{xs:24,md:5,children:e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:E=>x(E??null),allowSelectAll:!1})}),e.jsx(s.Col,{xs:24,md:1,children:e.jsx(s.Button,{type:"primary",icon:e.jsx(Z.SearchOutlined,{}),onClick:k,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(s.Table,{columns:F,pagination:!1,dataSource:Array.isArray(M?.data)?M.data:[],size:"small",rowKey:(E,B)=>E?.id??E?.issue_id??E?.fees_receipt_id??B,loading:b,scroll:{x:"max-content"},summary:E=>{const B=E.reduce((q,O)=>q+Number(O?.late_fine??0),0),Y=E.reduce((q,O)=>q+Number(O?.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-Y)]})}),e.jsx(s.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",Y]})}),e.jsx(s.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",B.toLocaleString("en-IN")]})})]})}})})]})]})}const Ma=t=>t??localStorage.getItem("authToken")??"",uc=(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},Ue={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"}},pc=()=>uc(tt(),Ue.upload),mc=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,Ma(r))},Un=async(t,n,a)=>ze(t,n,Ma(a)),cn=async(t,n,a)=>pt(t,n,Ma(a)),Bn=async(t,n,a)=>nt(t,n,Ma(a)),fc=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",rn=({token:t,value:n,onChange:a})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:pc(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=fc(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},ua=Ue.vendor,Ln=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,x])=>mc({baseUrl:l,page:d,perPage:c},x)),yc=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:ua.list,page:n,perPage:a,token:t}),hc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},$r=[{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 gc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),{isLoading:m,error:u,data:b,mutate:v}=yc({token:t,page:n.page,perPage:n.rowsPerPage}),w=async C=>{try{await v(Un(ua.add,C,t),at(C)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(g){_.error(g?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},p=C=>{C.preventDefault();const g=new FormData(C.target);c&&g.set("image",c),w(g),C.target.reset(),x("")},y=(C,g)=>{a({page:C,rowsPerPage:parseInt(g,10)})},h=async C=>{try{await v(Bn(ua.remove,C,t),Je(C)),_.success("Success! Deleted item.",{duration:1e3})}catch(g){_.error(g?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},R=C=>{d(C),o(!0),x("")},I=async C=>{C.preventDefault();const g=new FormData(C.target);g.set("id",String(l?.id??"")),c&&g.set("image",c);try{await cn(ua.edit,g,t),await v(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(f){_.error(f?.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:(C,g)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>R(g),style:{padding:2}}),e.jsx(it,{id:g?.id,funcName:h})]})}],[h]);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),x("")},children:e.jsx("form",{onSubmit:I,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[$r.map(C=>e.jsx(J,{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(rn,{token:t,value:c,onChange:x})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:hc,children:"Cancel"})]})]})})}),e.jsxs(fe,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(fe,{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:[$r.map(C=>e.jsx(J,{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(rn,{token:t,value:c,onChange:x})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(fe,{pt:3,children:e.jsx(Be,{parentCallback:y,data:{newData:b,columns:D,columnstype:"antd",action:!1,Loading:m,error:u}})})]})]})]})}const xc=({token:t})=>e.jsx(gc,{token:t}),bc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Sc={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"},It=({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:bc,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:{...Sc,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})},pa=Ue.product,Nr=Ue.vendor.dropdown,Ur=Ue.category.dropdown,jc=Ue.subCategory.dropdown,Br=Ue.unit.dropdown,ro=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:pa.list,page:n,perPage:a,token:t}),vc=({token:t})=>G(t&&Nr?[Nr,t]:null,([a,r])=>Q(a,r)),_c=({token:t})=>G(t&&Ur?[Ur,t]:null,([a,r])=>Q(a,r)),wc=({token:t})=>G(t&&Br?[Br,t]:null,([a,r])=>Q(a,r)),Cc=({token:t,categoryId:n})=>{const a=t&&n?`${jc}?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:[]},Ac={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({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),[m,u]=i.useState(""),[b,v]=i.useState(""),[w,p]=i.useState(""),[y,h]=i.useState(""),{isLoading:R,error:I,data:D,mutate:C}=ro({token:t,page:n.page,perPage:n.rowsPerPage}),{data:g}=vc({token:t}),{data:f}=_c({token:t}),{data:S}=wc({token:t}),{data:A}=Cc({token:t,categoryId:m}),P=i.useMemo(()=>Qn(g),[g]),L=i.useMemo(()=>Qn(f),[f]),N=i.useMemo(()=>Qn(S),[S]),j=i.useMemo(()=>Qn(A),[A]),M=async O=>{try{await C(Un(pa.add,O,t),at(O)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(T){_.error(T?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},k=O=>{O.preventDefault();const T=new FormData(O.target);m&&T.set("fk_categoryID",String(m)),b&&T.set("fk_sub_categoryID",String(b)),w&&T.set("vendor_id",String(w)),y&&T.set("unit",String(y)),c&&T.set("image",c),M(T),O.target.reset(),x(""),u(""),v(""),p(""),h("")},F=(O,T)=>{a({page:O,rowsPerPage:parseInt(T,10)})},E=async O=>{try{await C(Bn(pa.remove,O,t),Je(O)),_.success("Success! Deleted item.",{duration:1e3})}catch(T){_.error(T?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},B=O=>{d(O),o(!0),x(""),u(O?.fk_categoryID??O?.category_id??""),v(O?.fk_sub_categoryID??O?.sub_category_id??""),p(O?.vendor_id??""),h(O?.unit??O?.unit_id??"")},Y=async O=>{O.preventDefault();const T=new FormData(O.target);T.set("id",String(l?.id??"")),m&&T.set("fk_categoryID",String(m)),b&&T.set("fk_sub_categoryID",String(b)),w&&T.set("vendor_id",String(w)),y&&T.set("unit",String(y)),c&&T.set("image",c);try{await cn(pa.edit,T,t),await C(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch($){_.error($?.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:(O,T)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>B(T),style:{padding:2}}),e.jsx(it,{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),x("")},children:e.jsx("form",{onSubmit:Y,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(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:O=>{const T=O?.value??"";u(T),v("")},defaultValue:m?L.find(O=>String(O?.value)===String(m)):null}),e.jsx(ee,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:O=>v(O?.value??""),defaultValue:b?j.find(O=>String(O?.value)===String(b)):null}),e.jsx(J,{type:"text",name:"barcode",label:"Barcode",defaultValue:l?.barcode??""}),e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:O=>h(O?.value??""),defaultValue:y?N.find(O=>String(O?.value)===String(y)):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(ee,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:O=>p(O?.value??""),defaultValue:w?P.find(O=>String(O?.value)===String(w)):null}),e.jsx(J,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:l?.hsn_code??""}),e.jsx(It,{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(rn,{token:t,value:c,onChange:x})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:Ac,children:"Cancel"})]})]})})}),e.jsxs(fe,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(fe,{px:3,pb:2,children:e.jsx("form",{onSubmit:k,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(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:O=>{const T=O?.value??"";u(T),v("")}}),e.jsx(ee,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:O=>v(O?.value??"")},`subcat_${m}`),e.jsx(J,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:O=>h(O?.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(ee,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:O=>p(O?.value??"")}),e.jsx(J,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(It,{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(rn,{token:t,value:c,onChange:x})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(fe,{pt:3,children:e.jsx(Be,{parentCallback:F,data:{newData:D,columns:q,columnstype:"antd",action:!1,Loading:R,error:I}})})]})]})]})}const Ic=({token:t})=>e.jsx(Tc,{token:t}),ma=Ue.category,Rc=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:ma.list,page:n,perPage:a,token:t}),Dc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Oc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:x,data:m,mutate:u}=Rc({token:t,page:n.page,perPage:n.rowsPerPage}),b=async I=>{try{await u(Un(ma.add,I,t),at(I)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){_.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},v=I=>{I.preventDefault();const D=new FormData(I.target);b(D),I.target.reset()},w=(I,D)=>{a({page:I,rowsPerPage:parseInt(D,10)})},p=async I=>{try{await u(Bn(ma.remove,I,t),Je(I)),_.success("Success! Deleted item.",{duration:1e3})}catch(D){_.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},y=I=>{d(I),o(!0)},h=async I=>{I.preventDefault();const D=new FormData(I.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(C){_.error(C?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},R=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(I,D)=>String(I?.name??"").localeCompare(String(D?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(I,D)=>String(I?.description??"").localeCompare(String(D?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(I,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(D),style:{padding:2}}),e.jsx(it,{id:D?.id,funcName:p})]})}],[p]);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:h,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(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Dc,children:"Cancel"})]})]})})}),e.jsxs(fe,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(fe,{px:3,pb:2,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(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(le,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(fe,{pt:3,children:e.jsx(Be,{parentCallback:w,data:{newData:m,columns:R,columnstype:"antd",action:!1,Loading:c,error:x}})})]})]})]})}const Pc=({token:t})=>e.jsx(Oc,{token:t}),fa=Ue.subCategory,Lr=Ue.category.dropdown,kc=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:fa.list,page:n,perPage:a,token:t}),Ec=({token:t})=>G(t&&Lr?[Lr,t]:null,([a,r])=>Q(a,r)),Mc=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:[]},Fc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function $c({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),{isLoading:m,error:u,data:b,mutate:v}=kc({token:t,page:n.page,perPage:n.rowsPerPage}),{data:w}=Ec({token:t}),p=i.useMemo(()=>Mc(w),[w]),y=async f=>{try{await v(Un(fa.add,f,t),at(f)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(S){_.error(S?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},h=f=>{f.preventDefault();const S=new FormData(f.target);S.set("status","active"),S.set("img",c||""),y(S),f.target.reset(),x("")},R=(f,S)=>{a({page:f,rowsPerPage:parseInt(S,10)})},I=async f=>{try{await v(Bn(fa.remove,f,t),Je(f)),_.success("Success! Deleted item.",{duration:1e3})}catch(S){_.error(S?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},D=f=>{d(f),o(!0)},C=async f=>{f.preventDefault();const S=new FormData(f.target);S.set("id",String(l?.id??"")),c&&S.set("img",c);try{await cn(fa.edit,S,t),await v(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),x("")}catch(A){_.error(A?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},g=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(f,S)=>String(f?.name??"").localeCompare(String(S?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(f,S)=>String(f?.description??"").localeCompare(String(S?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(f,S)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>D(S),style:{padding:2}}),e.jsx(it,{id:S?.id,funcName:I})]})}],[I]);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),x("")},children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:l?.category_id?p.find(f=>String(f?.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(rn,{token:t,value:c,onChange:x})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null),x("")},style:Fc,children:"Cancel"})]})]})})}),e.jsxs(fe,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(fe,{px:3,pb:2,children:e.jsx("form",{onSubmit:h,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:p,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(rn,{token:t,value:c,onChange:x})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(fe,{pt:3,children:e.jsx(Be,{parentCallback:R,data:{newData:b,columns:g,columnstype:"antd",action:!1,Loading:m,error:u}})})]})]})]})}const Nc=({token:t})=>e.jsx($c,{token:t}),ss=Ue.product,Uc=Ue.academy.classes,Bc=Ue.academy.sections,Lc=Ue.student.dropdown;function xn(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 Qe(t){return String(t??"")}function qc({token:t}){const[n,a]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,x]=i.useState(!1),[m,u]=i.useState(""),[b,v]=i.useState([]),[w,p]=i.useState({}),[y,h]=i.useState({}),[R,I]=i.useState(!1),[D,C]=i.useState(""),[g,f]=i.useState(0),[S,A]=i.useState(""),[P,L]=i.useState(se()),[N,j]=i.useState([]),M={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},k=!!(n&&r&&l),{data:F}=G(t?[Uc,t]:null,([me,xe])=>Q(me,xe)),E=i.useMemo(()=>xn(F),[F]),B=t&&n?`${Bc}?class_id=${encodeURIComponent(String(n))}`:null,{data:Y}=G(B?[B,t]:null,([me,xe])=>Q(me,xe)),q=i.useMemo(()=>xn(Y),[Y]),O=t&&n&&r?`${Lc}?class=${encodeURIComponent(String(n))}&section=${encodeURIComponent(String(r))}`:null,{data:T}=G(O?[O,t]:null,([me,xe])=>Q(me,xe)),$=i.useMemo(()=>xn(T),[T]),U=k?`${ss.list}?page=1&per_page=10000`:null,{data:z,isLoading:ne}=G(t&&U?[U,t]:null,([me,xe])=>Q(me,xe),{revalidateOnFocus:!1}),K=i.useMemo(()=>xn(z),[z]),V=i.useMemo(()=>{const me=new Map;return(Array.isArray(K)?K:[]).forEach(xe=>{me.set(Qe(xe?.id),xe)}),me},[K]),X=i.useMemo(()=>{const me=Object.entries(y||{});return me.length===0?[]:me.map(([xe,he])=>{const te=V.get(Qe(xe));return te?{id:te?.id,name:te?.name,barcode:te?.barcode,stock:Number(te?.quantity||0),price:Number(te?.price||0),quantity:Xn(he,Number(te?.quantity||0))}:null}).filter(Boolean)},[y,V]),ae=i.useMemo(()=>new Set(X.map(me=>Qe(me?.id))),[X]),ce=i.useMemo(()=>(Array.isArray(X)?X:[]).reduce((xe,he)=>xe+Number(he?.price||0)*Number(he?.quantity||1),0),[X]),je=i.useMemo(()=>{const me=Number(g||0);return!Number.isFinite(me)||me<=0?0:Math.min(me,ce)},[g,ce]),re=i.useMemo(()=>Math.max(0,ce-je),[je,ce]),ie=i.useMemo(()=>(Array.isArray(K)?K:[]).slice(0,30).map(me=>({value:Qe(me?.id),label:`${me?.name??""}${me?.barcode?` • ${me.barcode}`:""}${me?.quantity!==void 0&&me?.quantity!==null?` • Stock: ${me.quantity}`:""}`,product:me})),[K]),{trigger:W}=Ge(t&&k?ss.search:null,(me,{arg:xe})=>qt(me,{arg:xe},t));i.useEffect(()=>{if(!k){v([]);return}const me=String(m||"").trim();if(me.length<2){v(ie);return}let xe=!0;const he=setTimeout(async()=>{let te=[];try{if(W){const ye=await W({search:me});te=xn(ye)}}catch{te=[]}if(!Array.isArray(te)||te.length===0){const ye=me.toLowerCase();te=(Array.isArray(K)?K:[]).filter(Te=>{const Ie=String(Te?.name??"").toLowerCase(),yt=String(Te?.barcode??"").toLowerCase();return Ie.includes(ye)||yt.includes(ye)}).slice(0,30)}const ue=te.slice(0,30).map(ye=>({value:Qe(ye?.id),label:`${ye?.name??""}${ye?.barcode?` • ${ye.barcode}`:""}${ye?.quantity!==void 0&&ye?.quantity!==null?` • Stock: ${ye.quantity}`:""}`,product:ye}));xe&&v(ue)},250);return()=>{xe=!1,clearTimeout(he)}},[ie,k,W,K,m]),i.useEffect(()=>{h({}),p({}),u(""),v([]),I(!1),C(""),f(0),A(""),L(se()),j([])},[n,r,l]);const oe=i.useCallback((me,xe=1)=>{const he=me?.id;if(!he)return;const te=Number(me?.quantity||0);if(te<=0){_.error("Out of stock.",{duration:1e3});return}const ue=Xn(xe,te);h(ye=>{const Te=ye||{};return Object.prototype.hasOwnProperty.call(Te,Qe(he))?(_.error("Product already added.",{duration:1e3}),Te):{...Te,[Qe(he)]:ue}})},[h]),Ce=i.useCallback((me,xe,he)=>{h(te=>{const ue=te||{},ye=Qe(me);return Object.prototype.hasOwnProperty.call(ue,ye)?{...ue,[ye]:Xn(xe,he)}:ue})},[]),Pe=i.useCallback(me=>{h(xe=>{const he=xe||{},te=Qe(me);if(!Object.prototype.hasOwnProperty.call(he,te))return he;const ue={...he};return delete ue[te],ue})},[]),ke=i.useCallback((me,xe,he)=>{p(te=>({...te||{},[Qe(me)]:Xn(xe,he)}))},[]),Me=i.useCallback((me,xe)=>{xe?.product&&oe(xe.product,1),u(""),v(ie)},[oe,ie]),Oe=i.useCallback(me=>{if(me.key!=="Enter")return;me.preventDefault();const xe=Array.isArray(b)&&b.length>0?b[0]:null;if(xe?.product){oe(xe.product,1),u(""),v(ie);return}const he=String(m||"").trim().toLowerCase();if(he.length===0)return;const te=(Array.isArray(K)?K:[]).find(ue=>{const ye=String(ue?.name??"").toLowerCase(),Te=String(ue?.barcode??"").toLowerCase();return ye.includes(he)||Te.includes(he)});te&&(oe(te,1),u(""),v(ie))},[oe,ie,K,b,m]),Ve=()=>{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(!X||X.length===0){_.error("Add at least one product.",{duration:1e3});return}I(!0)},{trigger:We,isMutating:Fe}=Ge(t?ss.sellProduct:null,(me,{arg:xe})=>ka(me,{arg:xe},t)),Ye=async()=>{if(!D){_.error("Select payment type.",{duration:1e3});return}const me=(Array.isArray(X)?X:[]).map(he=>({id:he?.id,quantity:Number(he?.quantity||1),price:Number(he?.price||0),total_price:Number(he?.total_price||0),fk_vendor_id:he?.fk_vendor_id||"",fk_categoryID:he?.fk_categoryID||"",name:he?.name||"",class_id:he?.class_id||"",fk_sub_categoryID:he?.fk_sub_categoryID||"",description:he?.description||"",min_quantity:Number(he?.min_quantity||0),storecategory:Number(he?.storecategory||0),barcode:he?.barcode||""})),xe={amount:ce,class:n,section:r,student_id:l,payment_type:D,discount:je,notes:S||"",receipt_date:P?se(P).format("YYYY-MM-DD"):"",product:JSON.stringify(me),total_payable_amount:ce,attchement:N[0]?.originFileObj||""};try{const te=Array.isArray(N)&&N.length>0&&N[0]?.originFileObj?(()=>{const ye=new FormData;return Object.entries(xe).forEach(([Te,Ie])=>{if(Te==="products"){ye.append("product",JSON.stringify(Ie));return}ye.append(Te,String(Ie??""))}),ye.append("attachment",N[0].originFileObj),ye})():xe,ue=await We(te);ue?.Status==="Success"?(_.success("Success! Product sold.",{duration:1e3}),I(!1),h({}),p({}),u(""),v(ie),C(""),f(0),A(""),L(se()),j([])):_.error(ue?.msg??"Failed to submit.",{duration:1e3})}catch{_.error("Failed to submit.",{duration:1e3})}},lt=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:(me,xe)=>{const he=Qe(xe?.id),te=Number(xe?.quantity||0),ue=ae.has(he),ye=(ue?y?.[he]:w?.[he])??1;return e.jsx(s.InputNumber,{min:1,max:Number.isFinite(te)&&te>0?te:void 0,value:ye,onChange:Te=>{ue?Ce(he,Te,te):ke(he,Te,te)},disabled:te<=0})}},{title:"Amount",key:"amount",width:140,render:(me,xe)=>{const he=Qe(xe?.id),te=(ae.has(he)?y?.[he]:w?.[he])??1;return Number(xe?.price||0)*Number(te||1)}},{title:"Action",key:"action",width:120,render:(me,xe)=>{const he=Qe(xe?.id),te=Number(xe?.quantity||0),ue=ae.has(he),ye=(ue?y?.[he]:w?.[he])??1;return ue?e.jsx(s.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(Z.DeleteOutlined,{}),onClick:()=>Pe(he),style:{padding:2}}):e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.PlusOutlined,{}),disabled:te<=0,onClick:()=>oe(xe,ye),style:{padding:2}})}}],[oe,ae,y,w,Pe,ke,Ce]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(fe,{pt:5,pb:2,children:[e.jsxs(fe,{style:{padding:"12px 16px"},children:[e.jsx(fe,{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(ee,{options:E,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:me=>{const xe=me?.value??"";a(xe),o(""),d(""),x(he=>!he)}}),e.jsx(ee,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:me=>{const xe=me?.value??"";o(xe),d("")}},`section_${c}`),e.jsx(ee,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:me=>d(me?.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(fe,{style:{marginTop:12},children:"Product Section"}),e.jsx(s.AutoComplete,{value:m,options:b,onSearch:u,onFocus:()=>{k&&String(m||"").trim().length<2&&v(ie)},onSelect:Me,disabled:!k,children:e.jsx(s.Input,{placeholder:"Search by product name or barcode",onKeyDown:Oe,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",ht(ce)]})]}),e.jsx(s.Table,{rowKey:me=>Qe(me?.id),columns:lt,dataSource:K,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:X.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(ce)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(le,{type:"button",value:"Submit",disabled:!k||X.length===0,onClick:Ve,style:{flex:1,minWidth:140}}),e.jsx(s.Button,{type:"text",style:M,onClick:()=>{h({}),p({}),u(""),v(ie)},disabled:X.length===0,children:"Clear"})]})]})]})})]}),e.jsx(s.Modal,{open:R,title:"Payment",onCancel:()=>I(!1),onOk:Ye,confirmLoading:Fe,okText:"Submit",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Payment Type"}),e.jsx(s.Select,{value:D||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(s.DatePicker,{value:P,onChange:me=>L(me),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:ce,value:g,onChange:me=>f(Number(me||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:N,beforeUpload:()=>!1,onChange:({fileList:me})=>j((me||[]).slice(-1)),maxCount:1,children:e.jsx(s.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(s.Input.TextArea,{value:S,onChange:me=>A(me.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(ce)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:ht(je)})]}),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 zc=({token:t})=>e.jsx(qc,{token:t}),ya=Ue.unit,Yc=({token:t,page:n=1,perPage:a=10})=>Ln({baseUrl:ya.list,page:n,perPage:a,token:t}),Vc={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Wc({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:x,data:m,mutate:u}=Yc({token:t,page:n.page,perPage:n.rowsPerPage}),b=async I=>{try{await u(Un(ya.add,I,t),at(I)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(D){_.error(D?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},v=I=>{I.preventDefault();const D=new FormData(I.target);b(D),I.target.reset()},w=(I,D)=>{a({page:I,rowsPerPage:parseInt(D,10)})},p=async I=>{try{await u(Bn(ya.remove,I,t),Je(I)),_.success("Success! Deleted item.",{duration:1e3})}catch(D){_.error(D?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},y=I=>{d(I),o(!0)},h=async I=>{I.preventDefault();const D=new FormData(I.target);D.set("id",String(l?.id??""));try{await cn(ya.edit,D,t),await u(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(C){_.error(C?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},R=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(I,D)=>String(I?.name??"").localeCompare(String(D?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(I,D)=>String(I?.description??"").localeCompare(String(D?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(I,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(D),style:{padding:2}}),e.jsx(it,{id:D?.id,funcName:p})]})}],[p]);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:h,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(le,{type:"submit",value:"Update",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Vc,children:"Cancel"})]})]})})}),e.jsxs(fe,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(fe,{px:3,pb:2,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(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(le,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(fe,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(Ee,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(fe,{pt:3,children:e.jsx(Be,{parentCallback:w,data:{newData:m,columns:R,columnstype:"antd",action:!1,Loading:c,error:x}})})]})]})]})}const Hc=({token:t})=>e.jsx(Wc,{token:t}),Kc=Ue.product.sellReports,Gc=Ue.academy.classes,Jc=Ue.academy.sections,Qc=Ue.student.dropdown,qr=t=>{const n=Number(t??0);return Number.isFinite(n)?n.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function Xc({token:t}){const n=i.useRef(null),[a,r]=i.useState(null),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,m]=i.useState(""),[u,b]=i.useState(!1),v=j=>{const M=j?.data?.data??j?.data??j??[];return Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[]},{data:w}=G(t?[Gc,t]:null,([j,M])=>Q(j,M)),p=i.useMemo(()=>v(w),[w]),y=t&&o?`${Jc}?class_id=${encodeURIComponent(String(o))}`:null,{data:h}=G(y?[y,t]:null,([j,M])=>Q(j,M)),R=i.useMemo(()=>v(h),[h]),I=t&&o&&d?`${Qc}?class=${encodeURIComponent(String(o))}&section=${encodeURIComponent(String(d))}`:null,{data:D}=G(I?[I,t]:null,([j,M])=>Q(j,M)),C=i.useMemo(()=>v(D),[D]),{trigger:g,isMutating:f,data:S}=Ge(Kc,(j,{arg:M})=>Is(j,{arg:M},t));i.useEffect(()=>{const M=new Date().toISOString().slice(0,10);g({duration:[M,M]})},[g]);const A=i.useMemo(()=>{const j=S?.data??S??[];return Array.isArray(j)?j:[]},[S]),P=j=>{const M=Array.isArray(j?.product_details)?j.product_details:[];return M.length===0?null:e.jsx(s.Table,{size:"small",bordered:!0,pagination:!1,rowKey:k=>`${j?.receipt_id??"r"}_${k?.product_name??k?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:k=>qr(k)}],dataSource:M})},L=[{title:"Receipt No",dataIndex:"receipt_no",key:"receipt_no"},{title:"Date",dataIndex:"receipt_date",key:"receipt_date"},{title:"Amount",dataIndex:"receipt_amount",key:"receipt_amount",render:j=>qr(j)}],N=async()=>{if(!a||a.length!==2)return;const[j,M]=a;await g({duration:[j.format("YYYY-MM-DD"),M.format("YYYY-MM-DD")],class:o||"",section:d||"",student_id:x||""})};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(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:j=>{const M=j?.value??"";l(M),c(""),m(""),b(k=>!k)}}),e.jsx(ee,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:j=>{const M=j?.value??"";c(M),m("")}},`section_${u}`),e.jsx(ee,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:j=>m(j?.value??"")}),e.jsx(le,{type:"button",value:f?"Searching...":"Search",disabled:f,onClick:N,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(Ea,{data:{tableRef:n}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(jt,{})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:f,rowKey:j=>String(j?.receipt_id??j?.receipt_no??Math.random()),columns:L,expandable:{expandedRowRender:P},dataSource:A,pagination:{pageSize:20}})]})})})]})})}const Zc=({token:t})=>e.jsx(Xc,{token:t}),eu=Ue.product;function tu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState([]),[l,d]=i.useState([]),[c,x]=i.useState(!1),[m,u]=i.useState(!1),[b,v]=i.useState(null),[w,p]=i.useState(0),[y,h]=i.useState(null),[R,I]=i.useState(""),D=i.useRef(null),C=ln.useReactToPrint({contentRef:D,documentTitle:"Stock Barcodes"}),{isLoading:g,error:f,data:S,mutate:A}=ro({token:t,page:n.page,perPage:n.rowsPerPage}),P=(F,E)=>{a({page:F,rowsPerPage:parseInt(E,10)})},L={selectedRowKeys:r,onChange:(F,E)=>{o(F),d(E)}},N=F=>{v(F),p(Number(F?.quantity??0)),h(null),I(""),x(!0)},j=()=>{x(!1),v(null),p(0),h(null),I("")},M=async()=>{if(!b?.id)return;u(!0);const F=new FormData;F.append("product_id",String(b.id)),F.append("qty",String(w??0)),y&&F.append("tran_date",y.format("YYYY-MM-DD")),R&&F.append("remarks",R);try{const E=await cn(eu.addStock,F,t);E?.Status==="Success"?(_.success("Success! Updated quantity.",{duration:1e3}),j(),await A()):_.error(E?.msg??"Failed to update quantity.",{duration:1e3})}catch{_.error("Failed to update quantity.",{duration:1e3})}finally{u(!1)}},k=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",width:100},{title:"Unit",dataIndex:"unit_name",key:"unit_name",width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["lg"]},{title:"Action",key:"action",width:160,fixed:"right",render:(F,E)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(s.Button,{size:"small",onClick:()=>N(E),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:b?.name?`Update Stock: ${b.name}`:"Update Stock",open:c,onCancel:j,onOk:M,okButtonProps:{loading:m},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:w,onChange:F=>p(F??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(s.DatePicker,{style:{width:"100%"},value:y,onChange:h})]}),e.jsx(It,{label:"Remarks",name:"remarks",rows:3,value:R,onChange:F=>I(F.target.value)})]})}),e.jsxs(fe,{pt:5,pb:2,children:[e.jsxs(fe,{children:["Manage Stock",e.jsx(le,{type:"button",value:"Print Barcodes",disabled:!l||l.length===0,onClick:()=>C?.(),style:{minWidth:170}})]}),e.jsx(fe,{style:{padding:"12px 16px"},children:e.jsx(s.Card,{style:{borderRadius:16},children:e.jsx(Be,{parentCallback:P,data:{newData:S,columns:k,columnstype:"antd",action:!1,Loading:g,error:f,rowSelection:L}})})})]}),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(F=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:F?.name??""}),e.jsx(Ci,{value:String(F?.barcode??F?.id??""),height:50,width:1.6,displayValue:!0})]},F?.id??F?.barcode??F?.name))})})})]})}const nu=({token:t})=>e.jsx(tu,{token:t}),au=Ue.report.stock,su=Ue.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?[su,t]:null,([p,y])=>Q(p,y)),c=i.useMemo(()=>ru(d),[d]),{trigger:x,isMutating:m,data:u}=Ge(au,(p,{arg:y})=>Is(p,{arg:y},t));i.useEffect(()=>{const y=new Date().toISOString().slice(0,10);x({duration:[y,y]})},[x]);const b=i.useMemo(()=>{const p=u?.data??u??[];return(Array.isArray(p)?p:[]).flatMap(h=>(Array.isArray(h?.ledger)?h.ledger:[]).map((R,I)=>({key:`${h.product_id??h.product_name??"p"}-${I}`,date:R?.date,product:h?.product_name,opening:R?.opening,inward:R?.inward,outward:R?.outward,closing:R?.closing})))},[u]),v=[{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:p=>e.jsx("span",{style:{color:Number(p)<0?"red":"green"},children:p})}],w=async()=>{if(!a||a.length!==2)return;const[p,y]=a;await x({duration:[p.format("YYYY-MM-DD"),y.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:p=>l(p.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),c.map(p=>e.jsx("option",{value:String(p?.value??""),children:String(p?.label??"")},String(p?.value??p?.id??p?.label)))]}),e.jsx(s.Button,{type:"primary",onClick:w,loading:m,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(Ea,{data:{tableRef:n}})})]}),e.jsxs("div",{ref:n,children:[e.jsx("div",{className:"print-only",children:e.jsx(jt,{})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:m,rowKey:"key",columns:v,dataSource:b,pagination:{pageSize:50}})]})]})}const ou=({token:t})=>e.jsx(iu,{token:t}),Fa=t=>t??localStorage.getItem("authToken")??"",ks=(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"}},io=()=>ks(tt(),Ae.upload),lu=()=>ks(tt(),Ae.staff.uploadProfile),du=()=>ks(tt(),Ae.staff.uploadDocuments),cu=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,Fa(r))},xt=async(t,n,a)=>ze(t,n,Fa(a)),kt=async(t,n,a)=>pt(t,n,Fa(a)),qn=async(t,n,a)=>nt(t,n,Fa(a)),zt=Ae.staff,uu=Ae.master.shift.dropdown,pu=Ae.master.department.dropdown,mu=Ae.master.designation.dropdown,fu=Ae.roleDropdown,Zn=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},yu=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",bn={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"};function hu({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,x]=i.useState(r?.roleValue??null),[m,u]=i.useState(r?.departmentValue??null),[b,v]=i.useState(r?.designationValue??null),[w,p]=i.useState(r?.genderValue??null),[y,h]=i.useState(r?.shiftValue??(d?[]:null)),[R,I]=i.useState(r?.dob?se(r.dob):null),[D,C]=i.useState(r?.doj?se(r.doj):null),[g,f]=i.useState(r?.file??""),{data:S}=G(t?[uu,t]:null,([Y,q])=>Q(Y,q)),{data:A}=G(t?[pu,t]:null,([Y,q])=>Q(Y,q)),{data:P}=G(t?[mu,t]:null,([Y,q])=>Q(Y,q)),{data:L}=G(t?[fu,t]:null,([Y,q])=>Q(Y,q)),{data:N}=G(t?[zt.lastEmpNo,t]:null,([Y,q])=>Q(Y,q)),j=i.useMemo(()=>Zn(S),[S]),M=i.useMemo(()=>Zn(A),[A]),k=i.useMemo(()=>Zn(P),[P]),F=i.useMemo(()=>Zn(L),[L]),E=i.useMemo(()=>{const Y=N?.data?.emp_number??N?.emp_number??N?.data??"";return String(Y??"")},[N]),B=async Y=>{Y.preventDefault();const q=new FormData(Y.target);q.set("role",c?.value??c??""),q.set("department",m?.value??m??""),q.set("designation",b?.value??b??""),q.set("gender",w?.value??w??""),q.set("dob",R?R.format("YYYY-MM-DD"):""),q.set("doj",D?D.format("YYYY-MM-DD"):""),d?(q.delete("shift_id"),(Array.isArray(y)?y:[]).forEach(T=>{q.append("shift_id[]",T?.value??T??"")})):q.set("shift_id",y?.value??y??""),g&&q.set("file",g);try{const O=n==="edit"&&a,T=O?zt.editBasic:zt.addBasic;O&&q.set("staff_id",String(a));const $=O?await kt(T,q,t):await xt(T,q,t),U=$?.ID??$?.id??a??null;_.success("Success!",{duration:1e3}),o?.({staffId:U,basic:{roleValue:c,departmentValue:m,designationValue:b,genderValue:w,shiftValue:y,dob:R,doj:D,file:g}})}catch(O){_.error(O?.response?.data?.msg??O?.message??"Failed.",{duration:1e3})}};return 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(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(ee,{label:"Role",options:F,value:c,onChange:Y=>x(Y??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Department",options:M,value:m,onChange:Y=>u(Y??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(ee,{label:"Designation",options:k,value:b,onChange:Y=>v(Y??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:w,onChange:Y=>p(Y??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:bn,children:"DOB"}),e.jsx(s.DatePicker,{value:R,onChange:Y=>I(Y),style:zr,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:bn,children:"DOJ"}),e.jsx(s.DatePicker,{value:D,onChange:Y=>C(Y),style:zr,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:bn,children:"Shift"}),e.jsx(ee,{options:j,value:y,onChange:Y=>h(Y??(d?[]:null)),isMulti:d,closeMenuOnSelect:!d,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:bn,children:"Profile Picture"}),e.jsx(s.Upload,{maxCount:1,action:lu(),headers:t?{Authorization:t}:void 0,onChange:Y=>{if(Y?.file?.status==="done"){const q=yu(Y?.file?.response);q&&f(q)}Y?.file?.status==="removed"&&f("")},children:e.jsx(s.Button,{type:"link",style:{paddingLeft:0},children:g?"Change":"Upload"})})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:bn,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(le,{type:"submit",value:"Save & Next",color:"primary"})})]})})}const ea={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Yr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},gu=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Vr=t=>{if(!t)return null;const n=se(t);return n.isValid()?n:null};function xu({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(p=>({name:p?.name??"",from:Vr(p?.from),to:Vr(p?.to),image:p?.image??""}))),x=i.useMemo(()=>t?{Authorization:t}:void 0,[t]),m=(w,p)=>{c(y=>y.map((h,R)=>R===w?{...h,...p}:h))},u=()=>c(w=>[...w,{name:"",from:null,to:null,image:""}]),b=w=>c(p=>p.length<=1?p:p.filter((y,h)=>h!==w)),v=async w=>{if(w.preventDefault(),!a){_.error("Missing staff id.",{duration:1e3});return}const p=new FormData;p.append("staff_id",String(a)),d.forEach((y,h)=>{p.append(`experience[${h}][name]`,String(y?.name??"")),p.append(`experience[${h}][from]`,y?.from?y.from.format("YYYY-MM-DD"):""),p.append(`experience[${h}][to]`,y?.to?y.to.format("YYYY-MM-DD"):""),p.append(`experience[${h}][image]`,String(y?.image??""))});try{const y=n==="edit",h=y?zt.editExperience:zt.addExperience,R=y?await kt(h,p,t):await xt(h,p,t);_.success("Success!",{duration:1e3}),o?.({experience:d,result:R})}catch(y){_.error(y?.response?.data?.msg??y?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:v,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[d.map((w,p)=>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:w.name,onChange:y=>m(p,{name:y.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:w.from,onChange:y=>m(p,{from:y}),style:Yr})]}),e.jsxs("div",{children:[e.jsx("div",{style:ea,children:"To"}),e.jsx(s.DatePicker,{value:w.to,onChange:y=>m(p,{to:y}),style:Yr})]}),e.jsxs("div",{children:[e.jsx("div",{style:ea,children:"Document"}),e.jsx(s.Upload,{maxCount:1,action:du(),headers:x,onChange:y=>{if(y?.file?.status==="done"){const h=gu(y?.file?.response);h&&m(p,{image:h})}y?.file?.status==="removed"&&m(p,{image:""})},children:e.jsx(s.Button,{icon:e.jsx(Z.UploadOutlined,{}),children:"Upload"})}),!!w.image&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:w.image})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:e.jsx(s.Button,{type:"text",icon:e.jsx(Z.DeleteOutlined,{}),danger:!0,onClick:()=>b(p),disabled:d.length<=1})})]},`exp-${p}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(s.Button,{icon:e.jsx(Z.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(le,{type:"submit",value:"Save & Next",color:"primary"})]})]})]})})}const Wr=(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[]},Sn=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function bu({token:t,mode:n,staffId:a,initialValues:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(r?.type??"Permanent"),[x,m]=i.useState(r?.salary_type??Sn[0]?.value),[u,b]=i.useState(Number(r?.amount??0)),[v,w]=i.useState(Number(r?.basic_pay)),[p,y]=i.useState(r?.declarationPERyear??""),{data:h}=G(t?[ud,t]:null,([f,S])=>Q(f,S),{revalidateOnFocus:!1}),R=i.useMemo(()=>Wr(h,["allowances","Allowances"]),[h]),I=i.useMemo(()=>Wr(h,["dedection","Dedection","deductions","Deductions"]),[h]),D=i.useMemo(()=>{const f=Number(v||0),S=(Array.isArray(R)?R:[]).map(j=>{const M=j?.amount_type??j?.amountType??j?.type??"",k=Number(j?.Amount??j?.amount??0),E=String(M).trim().toLowerCase()==="flat"?k:Number(f)/100*Number(k||0);return{...j,value:Number.isFinite(E)?E:0}}),A=(Array.isArray(I)?I:[]).map(j=>{const M=j?.amount_type??j?.amountType??j?.type??"",k=Number(j?.Amount??j?.amount??0),E=String(M).trim().toLowerCase()==="flat"?k:Number(f)/100*Number(k||0);return{...j,value:Number.isFinite(E)?E:0}}),P=S.reduce((j,M)=>j+Number(M?.value||0),0),L=A.reduce((j,M)=>j+Number(M?.value||0),0),N=Math.max(0,Number(f)+P-L);return{allowances:S,deductions:A,netAmount:N}},[R,I,v]),C=async f=>{if(f.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",x??""),S.append("amount",String(u||"")),S.append("Allowances",JSON.stringify([])),S.append("Dedection",JSON.stringify([]))):(S.append("basic_pay",String(v||"")),S.append("declarationPERyear",String(p??"")),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",P=A?zt.editPayroll:zt.addPayroll,L=A?await kt(P,S,t):await xt(P,S,t);o?.({payroll:{staffType:d,salaryType:x,amount:u,basicPay:v,declaration:p},result:L})}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed.",{duration:1e3})}},g=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(f,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:f=>c(f?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),d==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(ee,{label:"Type",options:Sn,value:Sn.find(f=>f.value===x)??Sn[0],onChange:f=>m(f?.value??Sn[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(J,{type:"number",label:"Amount",value:u,onChange:f=>b(Number(f.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{type:"number",label:"Basic Pay",value:v,onChange:f=>w(Number(f.target.value||0)),required:!0}),e.jsx(J,{type:"text",label:"IT Declarations/Year",value:p,onChange:f=>y(f.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:(f,S)=>`${f?.title??"a"}-${S}`,columns:g,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:(f,S)=>`${f?.title??"d"}-${S}`,columns:g,dataSource:D.deductions,pagination:!1})})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:e.jsx(le,{type:"submit",value:"Finish",color:"primary"})})]})})}const Su=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function ju({token:t,mode:n="add",staffId:a,onFinished:r}){const[o,l]=i.useState(0),[d,c]=i.useState(a??null),[x,m]=i.useState(null),[u,b]=i.useState(null),[v,w]=i.useState(null),p=n==="edit"?a??d:null,y=i.useMemo(()=>p?`${Ae.staff.basicById}?staff_id=${encodeURIComponent(String(p))}`:null,[p]),h=i.useMemo(()=>p?`${Ae.staff.experienceById}?staff_id=${encodeURIComponent(String(p))}`:null,[p]),R=i.useMemo(()=>p?`${Ae.staff.payrollById}?staff_id=${encodeURIComponent(String(p))}`:null,[p]),{data:I}=G(t&&y?[y,t]:null,([P,L])=>Q(P,L)),{data:D}=G(t&&h?[h,t]:null,([P,L])=>Q(P,L)),{data:C}=G(t&&R?[R,t]:null,([P,L])=>Q(P,L)),g=i.useMemo(()=>{const P=Su(I)[0]??I?.data??I??null;return P?{emp_number:P?.emp_number??P?.empNo??"",f_name:P?.f_name??P?.firstname??P?.first_name??"",l_name:P?.l_name??P?.lastname??P?.last_name??"",pan_no:P?.pan_no??"",adhar_no:P?.adhar_no??"",email:P?.email??"",dob:P?.dob??"",doj:P?.doj??"",bloodGroup:P?.bloodGroup??P?.blood_group??"",contact_no:P?.contact_no??P?.phone??"",education:P?.education??"",address:P?.address??"",file:P?.file??P?.profile_picture??""}:null},[I]),f=i.useMemo(()=>{const P=D?.data??D??null;return(Array.isArray(P?.experience)?P.experience:Array.isArray(P)?P:[]).map(N=>({name:N?.name??"",from:N?.from??"",to:N?.to??"",image:N?.image??""}))},[D]),S=i.useMemo(()=>{const P=C?.data??C??null;return P?{type:P?.type??"Permanent",salary_type:P?.salary_type??"",amount:P?.amount??"",basic_pay:P?.basic_pay??"",declarationPERyear:P?.declarationPERyear??""}:null},[C]),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(hu,{token:t,mode:n,staffId:p,initialValues:g,onSubmitted:({staffId:P})=>{P&&c(P),l(1)}}),o===1&&e.jsx(xu,{token:t,mode:n,staffId:p??d,initialRows:f,onBack:()=>l(0),onSubmitted:()=>l(2)}),o===2&&e.jsx(bu,{token:t,mode:n,staffId:p??d,initialValues:S,onBack:()=>l(1),onSubmitted:()=>{_.success("Completed.",{duration:1e3}),r?.({staffId:p??d}),l(0),n!=="edit"&&(c(null),m(null),b(null),w(null))}})]})})]})}function vu({token:t}){return e.jsx(ju,{token:t,mode:"add"})}const _u=({token:t})=>e.jsx(vu,{token:t}),ta=Ae.staff,wu=Ae.roleDropdown,Cu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Au=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Tu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(""),[l,d]=i.useState(""),{data:c}=G(t?[wu,t]:null,([R,I])=>Q(R,I)),x=i.useMemo(()=>Cu(c),[c]),m=i.useMemo(()=>{const R=n.page,I=n.rowsPerPage,D=r&&!l?`${ta.searchByRole}?role_id=${encodeURIComponent(String(r))}`:l?`${ta.searchByKeywords}?key=${encodeURIComponent(String(l))}`:ta.list,C=D.includes("?")?"&":"?";return`${D}${C}page=${encodeURIComponent(String(R))}&per_page=${encodeURIComponent(String(I))}`},[n.page,n.rowsPerPage,l,r]),{isLoading:u,error:b,data:v,mutate:w}=G(t?[m,t]:null,([R,I])=>Q(R,I)),p=i.useMemo(()=>Au(v),[v]),y=async R=>{const I=R?.id??R?.fk_staffID??R?.staff_id;if(I)try{await qn(ta.deactivate,I,t),_.success("Success! Staff deactivated.",{duration:1e3}),await w()}catch(D){_.error(D?.response?.data?.msg??D?.message??"Failed to deactivate staff.",{duration:1e3})}},h=i.useMemo(()=>[{title:"Name",key:"name",ellipsis:!0,render:(R,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:(R,I)=>e.jsx(s.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(Z.DeleteOutlined,{}),onClick:()=>y(I),style:{padding:2}})}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20,alignItems:"start"},children:[e.jsx(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(ee,{options:[{value:"",label:"All Roles"},...x],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:R=>{o(R?.value??""),a(I=>({...I,page:1}))}}),e.jsx(J,{type:"text",label:"Keyword",value:l,onChange:R=>d(R.target.value),placeholder:"Search by keywords"}),e.jsx(le,{type:"button",value:"Refresh",onClick:()=>w()})]})}),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:R=>String(R?.id??R?.fk_staffID??R?.staff_id??Math.random()),columns:h,dataSource:p,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(R,I)=>a({page:R,rowsPerPage:I}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]})}const Iu=({token:t})=>e.jsx(Tu,{token:t}),Ru=Ae.attendance,Du=Ae.roleDropdown,Hr=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"},Kr={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Ou({token:t,open:n,onClose:a,roleId:r,onSaved:o}){const[l,d]=i.useState(null),[c,x]=i.useState(""),[m,u]=i.useState(se()),[b,v]=i.useState(se()),[w,p]=i.useState(se()),y=i.useMemo(()=>r?`${Ae.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(r))}`:null,[r]),{data:h}=G(t&&y?[y,t]:null,([f,S])=>Q(f,S)),R=i.useMemo(()=>Hr(h),[h]),{trigger:I,data:D}=Ge(t?Ae.attendance.staffShiftByStaffId:null,(f,{arg:S})=>qt(f,{arg:S},t)),C=i.useMemo(()=>Hr(D),[D]),g=async()=>{if(!l?.value){_.error("Select staff.",{duration:1e3});return}if(!c){_.error("Select shift.",{duration:1e3});return}const f=new FormData;f.set("staffID",String(l.value)),f.set("shift_id",String(c)),f.set("attendance_date",m?m.format("YYYY-MM-DD"):""),f.set("intime",b?b.format("h:mm a"):""),f.set("outime",w?w.format("h:mm a"):"");try{await xt(Ae.attendance.manualAttendance,f,t),_.success("Success!",{duration:1e3}),o?.(),a?.(),d(null),x(""),u(se()),v(se()),p(se())}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(ee,{label:"Staff",options:R,value:l,onChange:async f=>{if(d(f??null),x(""),f?.value&&I)try{await I({staff_id:f.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:f=>x(f.target.value),style:{display:"grid",gap:8},children:C.map(f=>e.jsx(s.Radio,{value:f?.value,children:f?.label??f?.name??f?.title??String(f?.value??"")},String(f?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:na,children:"Date"}),e.jsx(s.DatePicker,{value:m,onChange:f=>f&&u(f),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:b,onChange:f=>f&&v(f),use12Hours:!0,format:"h:mm a",style:Kr})]}),e.jsxs("div",{children:[e.jsx("div",{style:na,children:"End Time"}),e.jsx(s.TimePicker,{value:w,onChange:f=>f&&p(f),use12Hours:!0,format:"h:mm a",style:Kr})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(s.Button,{onClick:a,children:"Cancel"}),e.jsx(le,{type:"button",value:"Save",color:"primary",onClick:g})]})]})})})}const Pu=({tableRef:t,excelDisabled:n})=>{const a=new Date().getTime(),r=ln.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(Z.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(s.Col,{children:n?e.jsx(s.Button,{type:"text",icon:e.jsx(Z.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>_.error("You must save attendance before download",{duration:2e3})}):e.jsx(no.DownloadTableExcel,{filename:a,sheet:"users",currentTableRef:t?.current,children:e.jsx(s.Button,{type:"text",icon:e.jsx(Z.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},ku=(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:[]:[]},Eu=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},Mu=(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 Fu({token:t,url:n,columns:a,reload:r,setReload:o,saveBtnRef:l,setSaveBtnDisabled:d,date:c,type:x="staff"}){const m=i.useRef(null),[u,b]=i.useState({page:0,rowsPerPage:10}),[v,w]=i.useState(!1),[p,y]=i.useState(!1),[h,R]=i.useState(null),[I,D]=i.useState([]),[C,g]=i.useState({sunday:!1,holiday:!1}),[f,S]=i.useState(!0);i.useEffect(()=>{b(N=>({...N,page:0}))},[n]),i.useEffect(()=>{let N=!0;return(async()=>{if(!(!t||!n)){w(!0);try{const M=String(n).includes("?")?"&":"?",k=`${n}${M}page=${u.page+1}&per_page=${u.rowsPerPage}`,F=await Q(k,t);if(!N)return;R(F),F?.Status==="Success"?(d?.(!1),D(ku(F,x)),g(Mu(F,x))):(d?.(!0),D([]),g({sunday:!1,holiday:!1}))}catch{if(!N)return;d?.(!0),D([])}finally{N&&w(!1)}}})(),()=>{N=!1}},[u.page,u.rowsPerPage,r,d,t,x,n]);const A=i.useMemo(()=>Eu(h),[h]);i.useEffect(()=>{const N=(Array.isArray(I)?I:[]).find(j=>j?.attendence_type_id===null);S(!!N)},[I]);const P=async()=>{if(t){y(!0);try{if(x==="staff"){const N=(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 xt(Ae.attendance.addAttendanceToStaffByBranch,N,t),_.success("Attendance saved successfully",{duration:2e3}),o?.(j=>!j)}else _.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(N){_.error(N?.response?.data?.msg??N?.message??"Failed required dates",{duration:2e3})}finally{y(!1)}}},L=i.useMemo(()=>(Array.isArray(a)?a:[]).map(j=>j?.selector==="attendence_type_id"?{title:j?.name??"Attendance",dataIndex:j.selector,key:j.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)})}:j?.selector==="snum"?{title:j?.name??"Sl",key:j.selector,render:(M,k,F)=>F+1}:{title:j?.name??j?.selector,dataIndex:j?.selector,key:j?.selector}),[a]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(s.Card,{children:[e.jsx(Pu,{tableRef:m,excelDisabled:f}),e.jsx(s.Modal,{open:p,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..."})]})}),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:m,children:e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(N,j)=>String(N?.id??N?.staff_id??j),columns:L,dataSource:I,loading:v,pagination:{current:u.page+1,pageSize:u.rowsPerPage,total:A,showSizeChanger:!0,onChange:(N,j)=>b({page:N-1,rowsPerPage:j})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:P,ref:l,style:{display:"none"},children:"hidden"})]})]})]})}const $u=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Nu={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Uu({token:t}){const[n,a]=i.useState(""),[r,o]=i.useState(se().format("YYYY-MM-DD")),[l,d]=i.useState(!1),[c,x]=i.useState(null),[m,u]=i.useState(!1),[b,v]=i.useState(!0),[w,p]=i.useState(!1),y=i.useRef(null),{data:h}=G(t?[Du,t]:null,([D,C])=>Q(D,C)),R=i.useMemo(()=>$u(h),[h]),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(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(ee,{options:R,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:se(),onChange:D=>D&&o(D.format("YYYY-MM-DD")),style:Nu,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"button",value:"Search",color:"primary",onClick:()=>{!n||!r||(x(`${Ru.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:m?"primary":"default",onClick:()=>u(D=>!D),children:m?"Marked":"Mark As Holiday"}),e.jsx(s.Button,{size:"small",type:"default",disabled:b,onClick:()=>p(!0),children:"Give Attendance"})]}),c?e.jsx(Fu,{token:t,url:c,columns:I,reload:l,setReload:d,saveBtnRef:y,setSaveBtnDisabled:v,date:r,type:"staff",holidayChecked:m}):null]}),e.jsx(Ou,{token:t,open:w,onClose:()=>p(!1),roleId:n,onSaved:()=>d(D=>!D)})]})}const Bu=({token:t})=>e.jsx(Uu,{token:t}),Gr=Ae.attendanceReport.monthlyStaffReport,Lu=Ae.roleDropdown,qu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function zu({token:t}){const n=i.useRef(null),[a,r]=i.useState(!1),[o,l]=i.useState([]),[d,c]=i.useState({role:"",rolllabel:"",year:"",month:""}),x=i.useMemo(()=>Ds(5),[]),{data:m}=G(t?[Lu,t]:null,([N,j])=>Q(N,j)),u=i.useMemo(()=>qu(m),[m]),[b,v]=i.useState([]),[w,p]=i.useState(1),[y,h]=i.useState(!1),[R,I]=i.useState(!1),[D,C]=i.useState(null),g=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:f}=Ge(t&&Gr?`${Gr}?page=${w}&per_page=3`:null,(N,{arg:j})=>qt(N,{arg:j},t),{onSuccess:N=>{h(!1);const j=Array.isArray(N)?N:[];j.length>0&&v(M=>[...M||[],...j]),j.length>1?p(M=>M+1):I(!1)},onError:()=>{h(!1),I(!1)}});i.useEffect(()=>{R&&f&&D&&f(D)},[R,w,D,f]);const S=i.useMemo(()=>{const N=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(j,M)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:M?.full_name??""})}];return Array.isArray(b)&&b.length>0&&((b[0]?.monthly_data??[]).forEach((M,k)=>{N.push({title:k+1,align:"center",key:String(k+1),render:(F,E)=>{const B=E?.monthly_data?.[k]?.[0]?.data?.[0]??{},Y=B?.intime??"",q=B?.outtime??"",O=B?.attendance_type??"";return e.jsx(s.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",Y]}),e.jsxs("div",{children:["Out Time ",q]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:qe(O)})})}})}),N.push({title:"Total",key:"Total",render:(M,k)=>{const F=k?.monthly_data??[],E=F.filter(Y=>Y?.[0]?.data?.[0]?.attendance_type==="A").length,B=F.filter(Y=>Y?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",E," P : ",B]})})}})),N},[b]),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")}],[]),P=i.useMemo(()=>d.month?o.find(N=>N?.value==d.month)?.label??d.month??"--":"--",[d.month,o]),L=async N=>{if(N.preventDefault(),!d.role||!d.year||!d.month)return;p(1),h(!0),v([]);const j={session:g,year:d.year,month:d.month,day:"01",role:d.role};C(j),I(!0),await f?.(j)};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:L,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:N=>c(j=>({...j,role:N?.value??"",rolllabel:N?.label??""}))}),e.jsx(ee,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:N=>{const j=Os(N?.value);l(j),r(M=>!M),c(M=>({...M,year:N?.label??""}))}}),e.jsx(ee,{options:o,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:N=>c(j=>({...j,month:N?.value??""}))},`month-${a}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{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(jt,{})}),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:P})]})]})]}),e.jsx("div",{className:"d-print-none",style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(Ea,{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(N=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("div",{children:[N.label," :"]}),e.jsx("div",{children:N.el})]},N.label))})})]}),e.jsx(s.Skeleton,{active:!0,loading:y,paragraph:{rows:10},children:e.jsx(s.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:S,dataSource:b,pagination:!1,scroll:{x:"max-content"},rowKey:(N,j)=>String(N?.staff_id??N?.id??j)})})]})})]})}const Yu=({token:t})=>e.jsx(zu,{token:t}),Jr=Ae.payroll,Vu=Ae.roleDropdown,Wu=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Hu=t=>t?.data?.data??t?.data??t??[];function Ku({token:t,receiptDetailsPath:n="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:a}){const[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,x]=i.useState([]),[m,u]=i.useState({role:"",roleLabel:"",year:"",month:""}),[b,v]=i.useState(null),w=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:p}=G(t?[Vu,t]:null,([S,A])=>Q(S,A)),y=i.useMemo(()=>Wu(p),[p]),h=i.useMemo(()=>Ds(5),[]),{isLoading:R,error:I,data:D}=G(t&&b?[b,t]:null,([S,A])=>Q(S,A)),C=i.useMemo(()=>{const S=Hu(D);return Array.isArray(S)?S:[]},[D]),g=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:C.length},[D,C.length]),f=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(S,A,P)=>P+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 P=A?.id??A?.staff_id??A?.staffId;return e.jsx(s.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{w(P)},children:eo(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(),!m.role||!m.year||!m.month)return;const A=`${Jr.payrollByRole}?page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.rowsPerPage))}&role=${encodeURIComponent(String(m.role))}&year=${encodeURIComponent(String(m.year))}&month=${encodeURIComponent(String(m.month))}`;v(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:y,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:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:S=>{const A=Os(S?.value);x(A),d(P=>!P),u(P=>({...P,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(le,{type:"submit",value:"Search",color:"primary",onClick:()=>o(S=>({...S,page:1}))})})]})}),e.jsx(s.Table,{bordered:!0,size:"small",loading:R,rowKey:(S,A)=>String(S?.id??S?.staff_id??A),columns:f,dataSource:C,pagination:{current:r.page,pageSize:r.rowsPerPage,total:g,showSizeChanger:!0,onChange:(S,A)=>{o({page:S,rowsPerPage:A}),!(!m.role||!m.year||!m.month)&&v(`${Jr.payrollByRole}?page=${encodeURIComponent(String(S))}&per_page=${encodeURIComponent(String(A))}&role=${encodeURIComponent(String(m.role))}&year=${encodeURIComponent(String(m.year))}&month=${encodeURIComponent(String(m.month))}`)}},scroll:{x:"max-content"}})]})})}const Gu=({token:t})=>e.jsx(Ku,{token:t}),oo=Ae.leave,un=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,x])=>cu({baseUrl:l,page:d,perPage:c},x)),Ju=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:oo.requestTable,page:n,perPage:a}),Qu=t=>{const n=t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},Xu=(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 Zu({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),{isLoading:r,error:o,data:l,mutate:d}=Ju({token:t,page:n.page,perPage:n.rowsPerPage}),c=i.useMemo(()=>Qu(l),[l]),x=async(u,b)=>{try{const v=Xu(u,b),w=await kt(oo.approveRequest,v,t);w?.Status==="Success"?_.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):_.error(w?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(v){_.error(v?.response?.data?.msg??v?.message??"Failed to update request.",{duration:1e3})}},m=i.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(u,b)=>b?.full_name??b?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(u,b)=>b?.leave_from??b?.from_date??""},{title:"To",key:"leave_to",width:120,render:(u,b)=>b?.leave_to??b?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(u,b)=>b?.leavetype??b?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(u,b)=>b?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(u,b)=>b?.employee_remark??b?.reason??""},{title:"View",key:"document_file",width:140,render:(u,b)=>{const v=b?.document_file;return v?e.jsx(s.Button,{size:"small",onClick:()=>window.open(v,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(u,b)=>{const v=String(b?.status??"").toLowerCase();return v==="approved"?e.jsx(s.Tag,{color:"green",children:"Approved"}):v==="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:()=>x(b,"approved"),icon:e.jsx(Z.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(s.Button,{type:"text",size:"small",onClick:()=>x(b,"declined"),icon:e.jsx(Z.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,b)=>String(u?.id??u?.leave_id??b),columns:m,dataSource:c,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(u,b)=>a({page:u,rowsPerPage:b}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const ep=({token:t})=>e.jsx(Zu,{token:t}),tp=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",np=({token:t,value:n,onChange:a})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:io(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=tp(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},lo=Ae.leave,ap=Ae.master.leaveType.dropdown,sp=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:lo.table,page:n,perPage:a}),rp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},rs={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function ip({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:x,error:m,data:u,mutate:b}=sp({token:t,page:n.page,perPage:n.rowsPerPage}),{data:v}=G(t?[ap,t]:null,([C,g])=>Q(C,g)),w=i.useMemo(()=>rp(v),[v]),p=(C,g)=>a({page:C,rowsPerPage:parseInt(g,10)}),y=()=>{d(""),c.resetFields(),c.setFieldsValue({apply_date:se()}),o(!0)},h=()=>{o(!1),d(""),c.resetFields()},R=async C=>{const g=new FormData;g.set("apply_date",C?.apply_date?C.apply_date.format("YYYY-MM-DD"):""),g.set("leave_type",C?.leave_type?.value??C?.leave_type??""),g.set("from_date",C?.from_date?C.from_date.format("YYYY-MM-DD"):""),g.set("to_date",C?.to_date?C.to_date.format("YYYY-MM-DD"):""),g.set("reason",C?.reason??""),l&&g.set("file",l);try{await xt(lo.apply,g,t),_.success("Success! Leave request submitted.",{duration:1e3}),h(),await b()}catch(f){_.error(f?.response?.data?.msg??f?.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]),D=i.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(C,g)=>g?.leavetype??g?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(C,g)=>g?.date??g?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(C,g)=>g?.leave_from??g?.from_date??""},{title:"To",key:"leave_to",width:130,render:(C,g)=>g?.leave_to??g?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(C,g)=>g?.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:h,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:c,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:"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:rs})]})}),e.jsx(s.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(ee,{options:w,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:rs})]})}),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:rs})]})}),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(np,{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:h,children:"Cancel"}),e.jsx(le,{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(le,{type:"button",value:"Add Leave Request",onClick:y})}),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:x,rowKey:(C,g)=>String(C?.id??C?.leave_id??g),columns:D,dataSource:I,pagination:{current:n.page,pageSize:n.rowsPerPage,onChange:(C,g)=>p(C,g),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const op=({token:t})=>e.jsx(ip,{token:t}),ha=Ae.master.leaveType,lp=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:ha.table,page:n,perPage:a});function dp({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,x]=i.useState(null),{isLoading:m,error:u,data:b,mutate:v}=lp({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,g)=>{a({page:C,rowsPerPage:parseInt(g,10)})},p=async C=>{const g=new FormData;g.set("title",C?.title??"");try{await v(xt(ha.add,g,t),at(g)),_.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to add leave type.",{duration:1e3})}},y=C=>{x(C??null),o.setFieldsValue({title:C?.leave_type_name??C?.name??""}),d(!0)},h=()=>{d(!1),x(null),o.resetFields()},R=async C=>{const g=c?.id??c?.leave_type_id;if(!g){_.error("Missing leave type id.",{duration:1e3});return}const f=new FormData;f.set("id",String(g)),f.set("title",C?.title??"");try{await kt(ha.edit,f,t),await v(),_.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),h()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update leave type.",{duration:1e3})}},I=async C=>{const g=C?.id??C?.leave_type_id;if(g)try{await v(qn(ha.remove,g,t),Je(g)),_.success("Success! Deleted leave type.",{duration:1e3})}catch(f){_.error(f?.response?.data?.msg??f?.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:(C,g)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(g)}),e.jsx(s.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>I(g),children:e.jsx(s.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(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Leave Type",onCancel:h,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:R,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:h,children:"Cancel"}),e.jsx(le,{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:p,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(le,{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(Be,{parentCallback:w,data:{newData:b,columns:D,columnstype:"antd",action:!1,Loading:m,error:u}})})]})}const cp=({token:t})=>e.jsx(dp,{token:t}),ga=Ae.master.department,up=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:ga.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,x]=i.useState(null),{isLoading:m,error:u,data:b,mutate:v}=up({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,g)=>{a({page:C,rowsPerPage:parseInt(g,10)})},p=async C=>{const g=new FormData;g.set("title",C?.title??"");try{await v(xt(ga.add,g,t),at(g)),_.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to add department.",{duration:1e3})}},y=C=>{x(C??null),o.setFieldsValue({title:C?.department_name??C?.name??""}),d(!0)},h=()=>{d(!1),x(null),o.resetFields()},R=async C=>{const g=c?.id??c?.department_id;if(!g){_.error("Missing department id.",{duration:1e3});return}const f=new FormData;f.set("id",String(g)),f.set("title",C?.title??"");try{await kt(ga.edit,f,t),await v(),_.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),h()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update department.",{duration:1e3})}},I=async C=>{const g=C?.id??C?.department_id;if(g)try{await v(qn(ga.remove,g,t),Je(g)),_.success("Success! Deleted department.",{duration:1e3})}catch(f){_.error(f?.response?.data?.msg??f?.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:(C,g)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(g)}),e.jsx(s.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>I(g),children:e.jsx(s.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(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Department",onCancel:h,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:R,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:h,children:"Cancel"}),e.jsx(le,{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:p,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(le,{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(Be,{parentCallback:w,data:{newData:b,columns:D,columnstype:"antd",action:!1,Loading:m,error:u}})})]})}const mp=({token:t})=>e.jsx(pp,{token:t}),xa=Ae.master.designation,fp=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:xa.table,page:n,perPage:a});function yp({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,x]=i.useState(null),{isLoading:m,error:u,data:b,mutate:v}=fp({token:t,page:n.page,perPage:n.rowsPerPage}),w=(C,g)=>{a({page:C,rowsPerPage:parseInt(g,10)})},p=async C=>{const g=new FormData;g.set("title",C?.title??"");try{await v(xt(xa.add,g,t),at(g)),_.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to add designation.",{duration:1e3})}},y=C=>{x(C??null),o.setFieldsValue({title:C?.designation??""}),d(!0)},h=()=>{d(!1),x(null),o.resetFields()},R=async C=>{const g=c?.id??c?.designation_id;if(!g){_.error("Missing designation id.",{duration:1e3});return}const f=new FormData;f.set("id",String(g)),f.set("title",C?.title??"");try{await kt(xa.edit,f,t),await v(),_.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),h()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update designation.",{duration:1e3})}},I=async C=>{const g=C?.id??C?.designation_id;if(g)try{await v(qn(xa.remove,g,t),Je(g)),_.success("Success! Deleted designation.",{duration:1e3})}catch(f){_.error(f?.response?.data?.msg??f?.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:(C,g)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(g)}),e.jsx(s.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>I(g),children:e.jsx(s.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(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{open:l,title:"Edit Designation",onCancel:h,footer:null,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:R,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:h,children:"Cancel"}),e.jsx(le,{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:p,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(le,{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(Be,{parentCallback:w,data:{newData:b,columns:D,columnstype:"antd",action:!1,Loading:m,error:u}})})]})}const hp=({token:t})=>e.jsx(yp,{token:t}),ba=Ae.master.shift,gp=({token:t,page:n=1,perPage:a=10})=>un({token:t,baseUrl:ba.table,page:n,perPage:a}),Xe="hh:mm A",Zt=t=>{const n=String(t??"");if(!n)return null;const a=se(n,[Xe,"HH:mm","HH:mm:ss"],!0);return a.isValid()?a:null},en=t=>t?t.format(Xe):"",ut={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function xp({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,x]=i.useState(null),{isLoading:m,error:u,data:b,mutate:v}=gp({token:t,page:n.page,perPage:n.rowsPerPage}),w=(f,S)=>{a({page:f,rowsPerPage:parseInt(S,10)})},p=(f,S)=>{const A=new FormData;return S&&A.set("id",String(S)),A.set("name",f?.name??""),A.set("start_time",en(f?.start_time)),A.set("end_time",en(f?.end_time)),A.set("shift_start_from",en(f?.shift_start_from)),A.set("shift_start_to",en(f?.shift_start_to)),A.set("shift_end_from",en(f?.shift_end_from)),A.set("shift_end_to",en(f?.shift_end_to)),A},y=async f=>{try{const S=p(f);await v(xt(ba.add,S,t),at(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})}},h=f=>{x(f??null),o.setFieldsValue({name:f?.shift_name??f?.name??"",start_time:Zt(f?.start_time),end_time:Zt(f?.end_time),shift_start_from:Zt(f?.shift_start_from),shift_start_to:Zt(f?.shift_start_to),shift_end_from:Zt(f?.shift_end_from),shift_end_to:Zt(f?.shift_end_to)}),d(!0)},R=()=>{d(!1),x(null),o.resetFields()},I=async f=>{const S=c?.id??c?.shift_id;if(!S){_.error("Missing shift id.",{duration:1e3});return}try{const A=p(f,S);await kt(ba.edit,A,t),await v(),_.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),R()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update shift.",{duration:1e3})}},D=async f=>{const S=f?.id??f?.shift_id;if(S)try{await v(qn(ba.remove,S,t),Je(S)),_.success("Success! Deleted shift.",{duration:1e3})}catch(A){_.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:(f,S)=>e.jsxs(s.Space,{size:6,children:[e.jsx(s.Button,{type:"text",size:"small",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>h(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(Z.DeleteOutlined,{})})})]})}],[]),g=[{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:R,footer:null,destroyOnClose:!0,children:e.jsxs(s.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(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:g,children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"end_time",label:"End Time",rules:g,children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(s.Button,{onClick:R,children:"Cancel"}),e.jsx(le,{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:y,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:g,children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"end_time",label:"End Time",rules:g,children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(s.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(s.TimePicker,{format:Xe,use12Hours:!0,style:ut})}),e.jsx(le,{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(Be,{parentCallback:w,data:{newData:b,columns:C,columnstype:"antd",action:!1,Loading:m,error:u}})})]})}const bp=({token:t})=>e.jsx(xp,{token:t}),Qr=Ae.attendance;function Sp({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 jp=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 _p({token:t}){const[n,a]=i.useState(se()),[r,o]=i.useState(!1),[l,d]=i.useState(0),c=i.useMemo(()=>`${r?Qr.dailyAttendanceMultipleShift:Qr.dailyAttendance}?attendance_date=${encodeURIComponent(n.format("YYYY-MM-DD"))}`,[n,r,l]),{isLoading:x,error:m,data:u}=G(t?[c,t]:null,([y,h])=>Q(y,h)),b=i.useMemo(()=>jp(u),[u]),v=i.useMemo(()=>r?u?.data?.data??u?.data??u??null:null,[u,r]),w=ln.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),p=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(y,h,R)=>R+1},{title:"Name",key:"name",render:(y,h)=>`${h?.name??""} ${h?.surname??""}`.trim(),ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(y,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[vp(h?.attendance),h?.late_time?e.jsx(s.Tag,{color:"red",children:"L"}):null]})},{title:"In Time",key:"intime",width:120,render:(y,h)=>h?.attendance_data?.[0]?.intime??""},{title:"Out Time",key:"outtime",width:120,render:(y,h)=>h?.attendance_data?.[0]?.outtime??""},{title:"Late",key:"late",width:100,render:(y,h)=>h?.late_time?e.jsx(s.Tag,{color:"red",children:h.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:y=>y&&a(y),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(le,{type:"button",value:"Search",onClick:()=>d(y=>y+1)})})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(Z.PrinterOutlined,{style:{color:"#5080f8",fontSize:18,cursor:"pointer"},onClick:w}),children:e.jsxs("div",{id:"ubk-hr-daily-attendance-print",children:[e.jsx("div",{className:"print-only",children:e.jsx(jt,{})}),r?e.jsx(Sp,{data:v}):e.jsx(s.Table,{bordered:!0,size:"small",loading:x,rowKey:(y,h)=>String(y?.id??y?.staff_id??h),columns:p,dataSource:b,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const wp=({token:t})=>e.jsx(_p,{token:t}),Xr=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},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:"":"";function Ap({token:t,staffId:n}){const[a,r]=i.useState(!1),[o,l]=i.useState(null),[d,c]=i.useState({value:"Cash",label:"Cash"}),[x,m]=i.useState(""),[u,b]=i.useState(""),v=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),w=P=>{const L=Number(P??0),N=Number.isFinite(L)?L.toLocaleString("en-IN"):"0";return`${v?`${v} `:""}${N}`},p=i.useMemo(()=>n?`${Ae.staff.basicById}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),y=i.useMemo(()=>n?`${Ae.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(n))}`:null,[n]),{data:h}=G(t&&p?[p,t]:null,([P,L])=>Q(P,L)),{data:R,isLoading:I,mutate:D}=G(t&&y?[y,t]:null,([P,L])=>Q(P,L)),C=i.useMemo(()=>Xr(h)[0]??h?.data??h??null,[h]),g=i.useMemo(()=>Xr(R),[R]),f=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:(P,L)=>e.jsx("div",{style:{fontSize:11},children:ht(L?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(P,L)=>e.jsx("div",{style:{fontSize:11},children:ht(L?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(P,L)=>e.jsx("div",{style:{fontSize:11},children:ht(L?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(P,L)=>e.jsx("div",{style:{fontSize:11},children:ht(L?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(P,L)=>e.jsx("div",{style:{cursor:L?.status==="due"?"pointer":"default"},onClick:()=>{L?.status==="due"&&(l(L),r(!0))},children:eo(L?.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 P={...o,staff_id:n,payment_type:d?.value??"",notes:x,attchement:u};try{await ze(Ae.payroll.generatePayslip,{arg:P},t),_.success("Success!",{duration:1e3}),r(!1),l(null),m(""),b(""),await D()}catch(L){_.error(L?.response?.data?.msg??L?.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:C?`${C?.f_name??C?.firstname??""} ${C?.l_name??C?.lastname??""}`.trim():""}),e.jsx(s.Table,{bordered:!0,size:"small",loading:I,rowKey:(P,L)=>String(P?.id??`${P?.month}-${L}`),columns:f,dataSource:g,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(ee,{label:"Pay",options:S,value:d,onChange:P=>c(P??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:x,onChange:P=>m(P.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:io(),headers:t?{Authorization:t}:void 0,onChange:P=>{if(P?.file?.status==="done"){const L=Cp(P?.file?.response);L&&b(L)}P?.file?.status==="removed"&&b("")},children:e.jsx(s.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(s.Button,{onClick:()=>r(!1),children:"Cancel"}),e.jsx(le,{type:"button",value:o?.Total_Payable_Amount?`Pay ${w(o.Total_Payable_Amount)}`:"Pay",onClick:A})]})]})})]})}function Tp({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(Ap,{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 Et({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(Z.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(Z.FileExcelOutlined,{}),onClick:n},{key:"print",title:"Print",icon:e.jsx(Z.PrinterOutlined,{}),onClick:a},{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,n,a,r,o,l]),x=i.useMemo(()=>{const m=Array.isArray(d)&&d.length?new Set(d):null;return m?c.filter(u=>m.has(u.key)):c},[c,d]);return e.jsx(s.Space,{size:8,children:x.map(m=>e.jsx(s.Tooltip,{title:m.title,children:e.jsx(s.Button,{type:"text",icon:m.icon,onClick:m.onClick,disabled:!m.onClick})},m.key))})}const Es=t=>t??localStorage.getItem("authToken")??"",St={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"}},Rt=async(t,n)=>Q(t,Es(n)),Ip=async(t,n,a)=>ze(t,n,Es(a)),Rp=async(t,n,a)=>On(t,{arg:n},Es(a)),Pn=(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()}`},Zr=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}},Dp=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},co=(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:[]},Op=t=>Array.isArray(t?.monthly_data)?t.monthly_data:Array.isArray(t?.month_data)?t.month_data:[],Pp=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)){Op(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},Ms=(t,n)=>{const{data:a,isLoading:r,error:o}=G(n&&t?[t,n]:null,([l,d])=>Rt(l,d));return{isLoading:r,error:o,data:a,options:i.useMemo(()=>Dp(a),[a])}},$a=t=>Ms(St.dropdowns.classes,t),Na=(t,n)=>{const a=t?`${St.dropdowns.sectionsByClass}?class_id=${encodeURIComponent(String(t))}`:null;return Ms(a,n)},kp=t=>Ms(St.dropdowns.sessions,t),Fs=t=>{const n=String(t??"").toUpperCase();return qe(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||"-")},uo=(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)},ei=t=>String(t??"").replace(/"/g,'""'),Ep=({rows:t,columns:n,fileName:a})=>{const r=Array.isArray(n)?n:[],o=Array.isArray(t)?t:[],l=r.map(c=>`"${ei(c?.title??c?.name??c?.key??c?.dataIndex)}"`).join(","),d=o.map((c,x)=>r.map(m=>{const u=m?.dataIndex??m?.selector??m?.key,b=u==="sl"?x+1:c?.[u];return`"${ei(b)}"`}).join(",")).join(`
60
60
  `);uo([l,d].filter(Boolean).join(`
61
61
  `),"text/csv;charset=utf-8;",a)},Mp=({value:t,fileName:n})=>{uo(JSON.stringify(t??null,null,2),"application/json;charset=utf-8;",n)};function po({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 on({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 Fp(){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(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 Dt({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 Ua({title:t,subtitle:n,printRef:a,exportRows:r,exportColumns:o,onRefresh:l,onAdd:d,filterSection:c,summary:x,chartContent:m,reportTitle:u,reportExtra:b,children:v,fileBaseName:w="attendance"}){const p=ln.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(Et,{actions:["add","export","print","download","refresh"],onAdd:d,onExport:()=>Ep({rows:r,columns:o,fileName:`${w}.csv`}),onPrint:p,onDownload:()=>Mp({value:r,fileName:`${w}.json`}),onRefresh:l}),children:c}),e.jsx(po,{summary:x}),m===!1?null:m||e.jsx(on,{summary:x}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:u}),extra:b,children:v})]})}const $p=[{label:"Present",value:"1"},{label:"Absent",value:"4"},{label:"Late",value:"3"},{label:"Leave",value:"2"}];function Np({rows:t,loading:n,sunday:a,holiday:r,holidayTitle:o,onChangeRows:l,onEmergency:d}){const c=(m,u)=>{const b=(Array.isArray(t)?t:[]).map((v,w)=>(v?.student_session_id??v?.student_id??v?.id??w)===m?{...v,...u}:v);l?.(b)},x=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(m,u,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:(m,u)=>u?.full_name??u?.student_name??u?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:180,render:(m,u,b)=>{const v=u?.student_session_id??u?.student_id??u?.id??b;return e.jsx(s.Select,{size:"small",style:{width:"100%"},options:$p,value:String(m??"1"),onChange:w=>c(v,{attendence_type_id:w})})}},{title:"Date",dataIndex:"date",key:"date",width:120,render:m=>m?se(m).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:(m,u)=>e.jsx(s.Tag,{color:"orange",style:{cursor:"pointer"},icon:e.jsx(Z.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:(m,u)=>String(m?.student_session_id??m?.student_id??m?.id??u),columns:x,dataSource:Array.isArray(t)?t:[],loading:n,pagination:{pageSize:25},scroll:{x:"max-content"}})}function Up({rows:t,loading:n,sunday:a,holiday:r,holidayTitle:o}){const l=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(d,c,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:(d,c)=>c?.full_name??c?.student_name??c?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:120,render:d=>Fs(d)},{title:"Date",dataIndex:"date",key:"date",width:120,render:d=>d?se(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 Bp({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),x=i.useMemo(()=>{const m=[{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,fixed:"left"},{title:"Name",key:"student_name",width:180,fixed:"left",render:(u,b)=>e.jsx(s.Button,{type:"link",style:{padding:0},onClick:()=>a?.(b),children:b?.student_name??b?.full_name??"--"})}];return[...new Array(c).keys()].forEach(u=>{m.push({title:String(u+1),key:`day-${u+1}`,width:52,align:"center",render:(b,v)=>{const p=v?.[`${v?.student_id}_${o.indexOf(v)}`]?.[u]??{},y=p?.attendance_date,h=l.find(R=>R?.date===y);return d.includes(y)?xr("sunday","W"):h?xr("holiday","H"):Fs(p?.attendence_type_id)}})}),m.push({title:"Total",key:"total",width:140,fixed:"right",render:(u,b)=>{let v=0,w=0,p=0;return[...new Array(c).keys()].forEach(y=>{const h=b?.[`${b?.student_id}_${o.indexOf(b)}`]?.[y]??{},R=String(h?.attendence_type_id??"");R==="1"&&(v+=1),R==="4"&&(w+=1),R==="3"&&(p+=1)}),e.jsxs("span",{children:["P: ",v," A: ",w," L: ",p]})}}),m},[l,a,o,d,c]);return e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(m,u)=>String(m?.student_id??u),columns:x,dataSource:o,loading:n,pagination:{pageSize:20},scroll:{x:"max-content"},locale:{emptyText:e.jsx(s.Empty,{description:"No monthly report found"})}})}function Lp({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?se(c).format("DD-MM-YYYY"):"--"},{title:"Status",key:"status",render:(c,x)=>Fs(x?.attendence_type_id??x?.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,x)=>String(c?.attendance_date??x),columns:d,dataSource:l,loading:a,pagination:{pageSize:20},scroll:{x:"max-content"}})})}function qp({open:t,onClose:n,onSubmit:a,loading:r}){const[o,l]=s.Modal.useModal(),[d,c]=i.useState(null),[x,m]=i.useState(""),u=async()=>{if(!d){await o.warning({title:"Select time"});return}await a?.({outtime:d.format("h:mm a"),message:x}),c(null),m("")};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:x,onChange:b=>m(b.target.value)})]})]})})]})}const mo=t=>Pp(t),ti=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 zp({token:t}){const{data:n}=G(t?[St.dashboard.monthlyGraph,t]:null,([l,d])=>Rt(l,d)),{data:a}=G(t?[St.dashboard.weeklyGraph,t]:null,([l,d])=>Rt(l,d)),r=i.useMemo(()=>ti(n),[n]),o=i.useMemo(()=>ti(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(po,{summary:r}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20},children:[e.jsx(on,{summary:r,title:"Monthly Attendance Chart"}),e.jsx(on,{summary:o,title:"Weekly Attendance Chart"})]})]})}const is=St.studentAttendance,Yp={width:"100%",height:40};function Vp({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,m]=i.useState(""),[u,b]=i.useState(""),[v,w]=i.useState(""),[p,y]=i.useState(se()),[h,R]=i.useState(0),[I,D]=i.useState([]),[C,g]=i.useState(!1),[f,S]=i.useState(null),[A,P]=i.useState(!1),[L,N]=i.useState(!1),j=$a(t),M=Na(a,t),k=i.useMemo(()=>!a||!d||h===0?null:Pn(is.list,{cID:a,sID:d,batch_id:u,date:p.format("YYYY-MM-DD")}),[u,a,p,h,d]),{data:F,isLoading:E,mutate:B}=G(t&&k?[k,t]:null,([V,X])=>Rt(V,X));i.useEffect(()=>{D(co(F,"student"))},[F]);const Y=F?.data?.data??F?.data??F??{},q=!!Y?.sunday,O=!!Y?.holiday?.holiday,T=Y?.holiday?.title??"",$=i.useMemo(()=>mo(I),[I]),U=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"}],[]),z=async()=>{if(I.length)try{N(!0),await Ip(is.save,{attendenceData:I,date:p.format("YYYY-MM-DD"),holiday:C?"YES":"NO"},t),_.success("Student attendance saved."),B?.()}catch(V){_.error(V?.message??"Failed to save attendance.")}finally{N(!1)}},ne=async({outtime:V,message:X})=>{if(f?.attendence_id)try{P(!0),await Rp(is.emergencyLeave,{outtime:V,message:X,id:f.attendence_id},t),_.success("Emergency leave updated."),S(null),B?.()}catch(ae){_.error(ae?.message??"Failed to update emergency leave.")}finally{P(!1)}},K=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(ee,{options:j.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:V=>{r(V?.value??""),l(V?.label??""),c(""),m(""),b(""),w("")},required:!0}),e.jsx(ee,{options:M.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:V=>{c(V?.value??""),m(V?.label??""),b(""),w("")},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:p,onChange:V=>V&&y(V),style:Yp,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"button",value:"Search",color:"primary",onClick:()=>R(V=>V+1)})})]}),e.jsx(Dt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:p.format("DD-MM-YYYY")}]})]});return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{}),e.jsx(Ua,{title:"Student Attendance",printRef:n,exportRows:I,exportColumns:U,onRefresh:()=>B?.(),filterSection:K,summary:$,chartContent:!1,reportTitle:"Student Attendance List",reportExtra:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(s.Button,{size:"small",type:C?"primary":"default",onClick:()=>g(V=>!V),children:C?"Marked":"Mark As Holiday"}),e.jsx(s.Button,{size:"small",type:"primary",onClick:z,loading:L,disabled:!I.length,children:"Save Attendance"})]}),fileBaseName:"student-attendance",children:e.jsxs("div",{ref:n,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(jt,{}),e.jsx(s.Typography.Title,{level:5,children:"Student Attendance"}),e.jsx(s.Card,{size:"small",style:{marginBottom:12},children:e.jsx(Dt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:p.format("DD-MM-YYYY")}]})})]}),e.jsx(Np,{rows:I,loading:E,sunday:q,holiday:O,holidayTitle:T,onChangeRows:D,onEmergency:S})]})}),e.jsx(qp,{open:!!f,onClose:()=>S(null),onSubmit:ne,loading:A})]})}const Wp=St.dailyAttendance,Hp={width:"100%",height:40};function Kp({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,m]=i.useState(""),[u,b]=i.useState(""),[v,w]=i.useState(se()),[p,y]=i.useState(0),h=$a(t),R=Na(a,t),I=i.useMemo(()=>!a||!d||p===0?null:Pn(Wp.list,{cID:a,sID:d,batch_id:u,date:v.format("YYYY-MM-DD")}),[u,a,v,p,d]),{data:D,isLoading:C,mutate:g}=G(t&&I?[I,t]:null,([k,F])=>Rt(k,F)),f=i.useMemo(()=>co(D,"student"),[D]),S=D?.data?.data??D?.data??D??{},A=!!S?.sunday,P=!!S?.holiday?.holiday,L=S?.holiday?.title??"",N=i.useMemo(()=>mo(f),[f]),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"}],[]),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(ee,{options:h.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:k=>{r(k?.value??""),l(k?.label??""),c(""),m(""),b(""),setBatchLabel("")},required:!0}),e.jsx(ee,{options:R.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:k=>{c(k?.value??""),m(k?.label??""),b(""),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:v,onChange:k=>k&&w(k),style:Hp,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"button",value:"Search",color:"primary",onClick:()=>y(k=>k+1)})})]}),e.jsx(Dt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:v.format("DD-MM-YYYY")}]})]});return e.jsx(Ua,{title:"Daily Attendance",subtitle:"Read-only daily attendance enquiry migrated from ERP AttendanceDashboard.",printRef:n,exportRows:f,exportColumns:j,onRefresh:()=>g?.(),filterSection:M,summary:N,chartContent:e.jsx(on,{summary:N,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(jt,{}),e.jsx(Dt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Date",value:v.format("DD-MM-YYYY")}]})]}),e.jsx(Up,{rows:f,loading:C,sunday:A,holiday:P,holidayTitle:L})]})})}const ni=St.monthlyReport,Gp=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]??{},x=String(c?.attendence_type_id??"");x==="1"&&(r.present+=1),x==="4"&&(r.absent+=1),x==="3"&&(r.late+=1),x==="2"&&(r.leave+=1)})}),r},Jp=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(x=>{const m=r?.[`${r?.student_id}_${o}`]?.[x]??{},u=String(m?.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 Qp({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,m]=i.useState(""),[u,b]=i.useState(""),[v,w]=i.useState(""),[p,y]=i.useState(String(new Date().getFullYear())),[h,R]=i.useState(String(new Date().getMonth()+1).padStart(2,"0")),[I,D]=i.useState(0),[C,g]=i.useState(null),f=$a(t),S=Na(a,t),A=i.useMemo(()=>Os(Number(p)),[p]),P=i.useMemo(()=>Ds(10),[]),L=i.useMemo(()=>!a||!d||!p||!h||I===0?null:Pn(ni.table,{session:Zr(),class_id:a,section_id:d,year:p,month:h,batch_id:u}),[u,a,h,I,d,p]),{data:N,isLoading:j,mutate:M}=G(t&&L?[L,t]:null,([$,U])=>Rt($,U)),k=N?.data?.data??N?.data??N??{},F=i.useMemo(()=>Gp(k),[k]),E=i.useMemo(()=>Jp(k),[k]),B=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"}],[]),Y=i.useMemo(()=>C?.student_id?Pn(ni.byStudent,{student_id:C.student_id,month:h,year:p,session:Zr()}):null,[h,C,p]),{data:q,isLoading:O}=G(t&&Y?[Y,t]:null,([$,U])=>Rt($,U)),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(ee,{options:f.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{r($?.value??""),l($?.label??""),c(""),m(""),b(""),w("")},required:!0}),e.jsx(ee,{options:S.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{c($?.value??""),m($?.label??""),b(""),w("")},required:!0},`section-${a}`),e.jsx(ee,{options:P,label:"Year",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:P.find($=>String($?.value)===String(p))??null,onChange:$=>y(String($?.value??"")),required:!0}),e.jsx(ee,{options:A,label:"Month",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:A.find($=>String($?.value)===String(h))??null,onChange:$=>R(String($?.value??"").padStart(2,"0")),required:!0},`month-${p}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"button",value:"Search",color:"primary",onClick:()=>D($=>$+1)})})]}),e.jsx(Dt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Month",value:A.find($=>String($?.value)===String(h))?.label??h},{label:"Year",value:p}]}),e.jsx(Fp,{})]});return e.jsxs(e.Fragment,{children:[e.jsx(Ua,{title:"Monthly Report",subtitle:"Monthly class-wise attendance matrix and student drilldown.",printRef:n,exportRows:E,exportColumns:B,onRefresh:()=>M?.(),filterSection:T,summary:F,chartContent:e.jsx(on,{summary:F,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(jt,{}),e.jsx(Dt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Month",value:A.find($=>String($?.value)===String(h))?.label??h},{label:"Year",value:p}]})]}),e.jsx(Bp,{data:k,loading:j,onViewStudent:g})]})}),e.jsx(Lp,{open:!!C,onClose:()=>g(null),loading:O,data:q,studentName:C?.student_name??C?.full_name})]})}const Xp=St.yearlyReport,Zp=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:[]},em=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 tm({token:t}){const n=i.useRef(null),[a,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[x,m]=i.useState(""),[u,b]=i.useState(""),[v,w]=i.useState(""),[p,y]=i.useState(""),[h,R]=i.useState(""),[I,D]=i.useState(0),C=$a(t),g=Na(a,t),f=kp(t),S=i.useMemo(()=>!a||!d||I===0?null:Pn(Xp.table,{class_id:a,section_id:d,session_id:u,batch_id:p}),[p,a,I,d,u]),{data:A,isLoading:P,mutate:L}=G(t&&S?[S,t]:null,([E,B])=>Rt(E,B)),N=i.useMemo(()=>Zp(A),[A]),j=i.useMemo(()=>em(N),[N]),M=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Present",dataIndex:"singleStudentPresentData"},{title:"Absent",dataIndex:"singleStudentAbsentData"}],[]),k=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(E,B,Y)=>Y+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}],[]),F=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(""),m(""),y(""),R("")},required:!0}),e.jsx(ee,{options:g.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{c(E?.value??""),m(E?.label??""),y(""),R("")},required:!0},`section-${a}`),e.jsx(ee,{options:f.options,label:"Session",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{b(E?.value??""),w(E?.label??"")},required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"button",value:"Search",color:"primary",onClick:()=>D(E=>E+1)})})]}),e.jsx(Dt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Session",value:v}]})]});return e.jsx(Ua,{title:"Yearly Report",subtitle:"Yearly attendance summary migrated from ERP AttendanceDashboard.",printRef:n,exportRows:N,exportColumns:M,onRefresh:()=>L?.(),filterSection:F,summary:j,chartContent:e.jsx(on,{summary:j,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(jt,{}),e.jsx(Dt,{items:[{label:"Class",value:o},{label:"Section",value:x},{label:"Session",value:v}]})]}),e.jsx(s.Table,{bordered:!0,size:"small",rowKey:(E,B)=>String(E?.student_id??E?.id??B),columns:k,dataSource:N,loading:P,pagination:{pageSize:25},scroll:{x:"max-content"}})]})})}function nm(){return null}const Ba=t=>t??localStorage.getItem("authToken")??"",am=(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},fo=()=>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"}},sm=()=>am(tt(),we.uploadNotes),rm=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,Ba(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",fo()),ze(t,o,Ba(a))},Ot=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",fo()),pt(t,o,Ba(a))},Pt=async(t,n,a)=>nt(t,n,Ba(a)),Sa=we.master.sections,zn=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,x])=>rm({baseUrl:l,page:d,perPage:c},x)),im=({token:t,page:n=1,perPage:a=10})=>zn({token:t,baseUrl:Sa.table,page:n,perPage:a}),om=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};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(),{data:x,isLoading:m,mutate:u}=im({token:t,page:n.page,perPage:n.perPage}),b=i.useMemo(()=>om(x),[x]),v=i.useMemo(()=>x?.pagination?.total_rows??x?.pagination?.total??b.length??0,[x,b]),w=async I=>{I.preventDefault();const D=new FormData(I.target);try{await mt(Sa.add,D,t),_.success("Success! Added new item.",{duration:1e3}),I.target.reset(),u()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to add the new item.",{duration:1500})}},p=async I=>{try{await Pt(Sa.remove,I,t),_.success("Success! Deleted item.",{duration:1e3}),u()}catch(D){_.error(D?.response?.data?.msg??D?.message??"Failed to delete the item.",{duration:1500})}},y=I=>{d(I),o(!0),c.setFieldsValue({section:I?.section??""})},h=async I=>{const D=new FormData;D.append("id",String(l?.id??"")),D.append("section",I.section??"");try{await Ot(Sa.edit,D,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),u()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to update the item.",{duration:1500})}},R=i.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(I,D)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>y(D)}),e.jsx(s.Popconfirm,{title:"Delete this section?",onConfirm:()=>p(D?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(Z.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:h,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(le,{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:w,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(le,{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:I=>I.id,columns:R,dataSource:b,loading:m,pagination:{current:n.page,pageSize:n.perPage,total:v,showSizeChanger:!0,onChange:(I,D)=>a({page:I,perPage:D})}})})]})}function dm({token:t}){return e.jsx(lm,{token:t})}const Tn=we.master.classes,cm=({token:t,page:n=1,perPage:a=10})=>zn({token:t,baseUrl:Tn.table,page:n,perPage:a}),um=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},pm=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function mm({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(),[x]=s.Form.useForm(),{data:m}=G(t?[we.master.sections.list,t]:null,([A,P])=>Q(A,P)),u=i.useMemo(()=>pm(m),[m]),b=i.useMemo(()=>u.map(A=>({label:A.label??A.section??String(A.value??""),value:String(A.value??A.id??"")})),[u]),{data:v,isLoading:w,mutate:p}=cm({token:t,page:n.page,perPage:n.perPage}),y=i.useMemo(()=>um(v),[v]),h=i.useMemo(()=>v?.pagination?.total_rows??v?.pagination?.total??y.length??0,[v,y]),{data:R}=G(t&&l?[`${Tn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([A,P])=>Q(A,P)),I=i.useMemo(()=>{const A=R?.data??R;return Array.isArray(A)?A:Array.isArray(A?.data)?A.data:A?[A]:[]},[R]),D=A=>{const P=A?.id??A?.class_id;P&&(d(P),o(!0))};i.useEffect(()=>{if(!r||!I.length)return;const A=I[0],P=I.map(j=>j?.section_id??j?.fk_sectionId??j?.sectionId??j?.section).filter(j=>j!=null&&String(j).trim()!=="").map(j=>String(j)),L=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)):[],N=P.length?P:L;x.setFieldsValue({name:A?.class??A?.name??"",section:N})},[r,I,x]);const C=async A=>{const P=new FormData;P.append("name",A.name??""),(A.section??[]).forEach(L=>P.append("section[]",String(L)));try{await mt(Tn.add,P,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),p()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},g=async A=>{const P=new FormData;P.append("id",String(l??"")),P.append("name",A.name??""),(A.section??[]).forEach(L=>P.append("section[]",String(L)));try{await Ot(Tn.edit,P,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to update the item.",{duration:1500})}},f=async A=>{try{await Pt(Tn.remove,A,t),_.success("Success! Deleted item.",{duration:1e3}),p()}catch(P){_.error(P?.response?.data?.msg??P?.message??"Failed to delete the item.",{duration:1500})}},S=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(A,P)=>A??P?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:A=>A??""},{title:"Actions",key:"actions",width:120,render:(A,P)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>D(P)}),e.jsx(s.Popconfirm,{title:"Delete this class?",onConfirm:()=>f(P?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(Z.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:x,layout:"vertical",onFinish:g,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:b})}),e.jsxs(s.Space,{children:[e.jsx(le,{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:C,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:b})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{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:y,loading:w,pagination:{current:n.page,pageSize:n.perPage,total:h,showSizeChanger:!0,onChange:(A,P)=>a({page:A,perPage:P})}})})]})}function fm({token:t}){return e.jsx(mm,{token:t})}const In=we.master.subjects,ym=({token:t,page:n=1,perPage:a=10})=>zn({token:t,baseUrl:In.table,page:n,perPage:a}),hm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},ai=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],si=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function gm({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(),[x]=s.Form.useForm(),{data:m,isLoading:u,mutate:b}=ym({token:t,page:n.page,perPage:n.perPage}),v=i.useMemo(()=>hm(m),[m]),w=i.useMemo(()=>m?.pagination?.total_rows??m?.pagination?.total??v.length??0,[m,v]),{data:p}=G(t&&l?[`${In.show}?id=${encodeURIComponent(String(l))}`,t]:null,([g,f])=>Q(g,f)),y=i.useMemo(()=>{const g=p?.data??p;return Array.isArray(g)?g[0]:g??null},[p]);i.useEffect(()=>{r&&y&&x.setFieldsValue({name:y?.name??"",subject_type:y?.subject_type??y?.type??"",type:"",subject_types:Array.isArray(y?.subject_types)?y.subject_types:typeof y?.subject_types=="string"?y.subject_types.split(",").map(g=>g.trim()).filter(Boolean):[],code:y?.code??""})},[r,y,x]);const h=async g=>{const f=g?.type??g?.subject_type??"",S={name:g?.name??"",subject_type:f,type:f,subject_types:Array.isArray(g?.subject_types)?g.subject_types:[],code:g?.code??""};try{await ze(In.add,S,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),b()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},R=async g=>{const f=new FormData,S=g?.type??g?.subject_type??"";f.append("id",String(l??"")),f.append("name",g.name??""),f.append("subject_type",g.subject_type??""),f.append("subject_type",S),f.append("type",S),f.append("code",g.code??"");try{await Ot(In.edit,f,t),_.success("Success! Updated item.",{duration:1e3}),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),b()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},I=async g=>{try{await Pt(In.remove,g,t),_.success("Success! Deleted item.",{duration:1e3}),b()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to delete the item.",{duration:1500})}},D=g=>{const f=g?.id;f&&(d(f),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:(g,f)=>{const S=[],A=f?.subject_types;Array.isArray(A)?A.forEach(M=>{const k=String(M??"").trim();k&&S.push(k)}):typeof A=="string"&&A.split(",").map(M=>M.trim()).filter(Boolean).forEach(M=>S.push(M));const P=["yes","1","true"].includes(String(f?.is_practical??"").toLowerCase()),L=["yes","1","true"].includes(String(f?.is_theory??"").toLowerCase());P&&S.push("Practical"),L&&S.push("Theory");const N=S.map(M=>String(M??"").trim()).filter(Boolean).map(M=>M.toLowerCase()==="practical"?"Practical":M.toLowerCase()==="theory"?"Theory":M),j=Array.from(new Set(N));return j.length?j.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(g,f)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>D(f)}),e.jsx(s.Popconfirm,{title:"Delete this subject?",onConfirm:()=>I(f?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(Z.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:x,layout:"vertical",onFinish:R,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:si})}),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:ai})}),e.jsx(s.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(J,{placeholder:"Subject Code"})}),e.jsxs(s.Space,{children:[e.jsx(le,{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: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",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:si})}),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:ai})}),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(le,{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:g=>g.id,columns:C,dataSource:v,loading:u,pagination:{current:n.page,pageSize:n.perPage,total:w,showSizeChanger:!0,onChange:(g,f)=>a({page:g,perPage:f})}})})]})}function xm({token:t}){return e.jsx(gm,{token:t})}const Rn=we.master.holidays,bm=({token:t,page:n=1,perPage:a=10})=>zn({token:t,baseUrl:Rn.table,page:n,perPage:a}),Sm=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 jm({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(),[x]=s.Form.useForm(),{data:m,isLoading:u,mutate:b}=bm({token:t,page:n.page,perPage:n.perPage}),v=i.useMemo(()=>Sm(m),[m]),w=i.useMemo(()=>m?.pagination?.total_rows??m?.pagination?.total??v.length??0,[m,v]),{data:p}=G(t&&l?[`${Rn.show}?id=${encodeURIComponent(String(l))}`,t]:null,([g,f])=>Q(g,f)),y=i.useMemo(()=>{const g=p?.data??p;return Array.isArray(g)?g[0]:g??null},[p]);i.useEffect(()=>{r&&y&&x.setFieldsValue({title:y?.holiday_title??"",description:y?.holiday_description??"",from:y?.start_date?se(y.start_date):null,to:y?.end_date?se(y.end_date):null})},[r,y,x]);const h=async g=>{const f=new FormData;f.append("title",g.title??""),f.append("description",g.description??""),f.append("from",g.from?se(g.from).format("YYYY-MM-DD"):""),f.append("to",g.to?se(g.to).format("YYYY-MM-DD"):"");try{await mt(Rn.add,f,t,{includeSession:!0}),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),b()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to add the new item.",{duration:1500})}},R=async g=>{const f=new FormData;f.append("id",String(l??"")),f.append("title",g.title??""),f.append("description",g.description??""),f.append("from",g.from?se(g.from).format("YYYY-MM-DD"):""),f.append("to",g.to?se(g.to).format("YYYY-MM-DD"):"");try{await Ot(Rn.edit,f,t,{includeSession:!0}),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),b()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update the item.",{duration:1500})}},I=async g=>{try{await Pt(Rn.remove,g,t),_.success("Success! Deleted item.",{duration:1e3}),b()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to delete the item.",{duration:1500})}},D=g=>{const f=g?.id;f&&(d(f),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:(g,f)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>D(f)}),e.jsx(s.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>I(f?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(Z.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:x,layout:"vertical",onFinish:R,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(le,{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: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:"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(It,{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(le,{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:g=>g.id,columns:C,dataSource:v,loading:u,pagination:{current:n.page,pageSize:n.perPage,total:w,showSizeChanger:!0,onChange:(g,f)=>a({page:g,perPage:f})}})})]})}function vm({token:t}){return e.jsx(jm,{token:t})}const ja=we.assignSubjects,_m=({token:t,page:n=1,perPage:a=50})=>zn({token:t,baseUrl:ja.list,page:n,perPage:a}),ri=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],wm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Cm({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,x]=i.useState(!1),[m,u]=i.useState(!1),[b,v]=i.useState(null),[w,p]=i.useState([]),{data:y}=G(t?[we.master.classes.dropdown,t]:null,([k,F])=>Q(k,F)),{data:h}=G(t?[we.master.subjects.dropdown,t]:null,([k,F])=>Q(k,F)),R=i.useMemo(()=>ri(y),[y]),I=i.useMemo(()=>ri(h),[h]),D=i.useMemo(()=>I.map(k=>({label:k.label??k.subject??String(k.value??""),value:k.value??k.id})),[I]),{data:C,isLoading:g,mutate:f}=_m({token:t,page:n.page,perPage:n.perPage}),S=i.useMemo(()=>wm(C),[C]),A=i.useMemo(()=>C?.pagination?.total_rows??C?.pagination?.total??S.length??0,[C,S]),{data:P}=G(t&&b?[`${ja.editByClass}?class_id=${encodeURIComponent(String(b))}`,t]:null,([k,F])=>Q(k,F));i.useEffect(()=>{if(!m)return;const k=P?.data??P,F=Array.isArray(k)?k:Array.isArray(k?.data)?k.data:[];p(F.map(E=>E.subject_id).filter(Boolean))},[m,P]);const L=async k=>{if(k.preventDefault(),!r?.value){_.error("Please select class",{duration:1200});return}if(!l.length){_.error("Please select subjects",{duration:1200});return}const F=new FormData;F.append("class_id",String(r.value)),l.forEach(E=>F.append("subject[]",String(E)));try{x(!0),await Ot(ja.assign,F,t),_.success("Success! Updated item.",{duration:1e3}),o(null),d([]),f()}catch(E){_.error(E?.response?.data?.msg??E?.message??"Failed to update the item.",{duration:1500})}finally{x(!1)}},N=k=>{k&&(v(k),u(!0))},j=async()=>{if(!b)return;if(!w.length){_.error("Please select subjects",{duration:1200});return}const k=new FormData;k.append("class_id",String(b)),w.forEach(F=>k.append("subject[]",String(F)));try{await Ot(ja.update,k,t),_.success("Success! Updated item.",{duration:1e3}),u(!1),v(null),f()}catch(F){_.error(F?.response?.data?.msg??F?.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:(k,F)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:(F?.subject_name??k??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(k,F)=>e.jsx(s.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>N(F?.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:m,onClose:()=>{u(!1),v(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:j,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:R.find(k=>String(k.value)===String(b))??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:w,onChange:p})]})]})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:"Assign Subject"}),children:e.jsx("form",{onSubmit:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(ee,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:r,onChange:k=>o(k??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(le,{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:k=>k.id,columns:M,dataSource:S,loading:g,pagination:{current:n.page,pageSize:n.perPage,total:A,showSizeChanger:!0,onChange:(k,F)=>a({page:k,perPage:F})}})})]})}function Am({token:t}){return e.jsx(Cm,{token:t})}const tn=we.assignByClass,yo=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[]},jn=t=>yo(t),Tm=t=>yo(t),vn=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function Im({token:t}){const[n,a]=i.useState(null),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,x]=i.useState("No"),[m,u]=i.useState([]),[b,v]=i.useState([]),[w,p]=i.useState(null),[y,h]=i.useState(null),[R,I]=i.useState(!1),[D,C]=i.useState(""),{data:g}=G(t?[tn.teacherDropdown,t]:null,([ie,W])=>Q(ie,W)),{data:f}=G(t?[we.master.classes.dropdown,t]:null,([ie,W])=>Q(ie,W)),{data:S}=G(t&&y?[y,t]:null,([ie,W])=>Q(ie,W)),{data:A}=G(t&&w?[w,t]:null,([ie,W])=>Q(ie,W)),P=i.useMemo(()=>jn(g),[g]),L=i.useMemo(()=>jn(f),[f]),N=i.useMemo(()=>jn(S),[S]),j=i.useMemo(()=>jn(A),[A]),{data:M}=G(t&&n&&r&&l?[`${tn.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(n))}&class_id=${encodeURIComponent(String(r))}&section_id=${encodeURIComponent(String(l))}`,t]:null,([ie,W])=>Q(ie,W)),k=M?.data??M??null;i.useEffect(()=>{k&&(u(Array.isArray(k?.subject_ids)?k.subject_ids:[]),x(k?.isClassTeacher||"No"),v([]))},[k]);const{data:F}=G(t?[tn.classWithSection,t]:null,([ie,W])=>Q(ie,W)),E=i.useMemo(()=>jn(F),[F]),[B,Y]=i.useState(null),[q,O]=i.useState({page:1,perPage:25});i.useEffect(()=>{B||E?.[0]&&Y(`${E[0].class_id}val${E[0].section_id}`)},[E,B]);const T=i.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),$=i.useMemo(()=>{if(!B)return null;const[ie,W]=String(B).split("val");if(!ie||!W)return null;const oe=q.page??1,Ce=q.perPage??25;return`${tn.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(oe))}&per_page=${encodeURIComponent(String(Ce))}&session_id=${encodeURIComponent(String(T))}&class_id=${encodeURIComponent(String(ie))}&section_id=${encodeURIComponent(String(W))}`},[B,q.page,q.perPage,T]),{data:U,isLoading:z,mutate:ne}=G(t&&$?[$,t]:null,([ie,W])=>Q(ie,W),{revalidateOnFocus:!1}),K=i.useMemo(()=>Tm(U),[U]),V=i.useMemo(()=>{const ie=U?.pagination??U?.data?.pagination??U?.data?.data?.pagination;return ie?.total_rows??ie?.total??K.length??0},[U,K]),X=async ie=>{if(ie.preventDefault(),C(""),!n||!r||!l){_.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(m)||m.length===0){C("error"),_.error("Please Select Subject",{duration:1200});return}const W=new FormData;W.append("teacher_id",String(n)),W.append("class_id",String(r)),W.append("section_id",String(l)),W.append("isClassTeacher",String(c??"No")),vn(m).forEach(oe=>W.append("subject_ids[]",String(oe))),vn(b).forEach(oe=>W.append("delete_subject[]",String(oe)));try{await mt(tn.assignClassToTeacher,W,t,{includeSession:!0}),_.success("Success! Added new item.",{duration:1e3}),C(""),ne()}catch(oe){_.error(oe?.response?.data?.msg??oe?.message??"Failed to add the new item.",{duration:1500})}},ae=async ie=>{try{await Pt(tn.deleteTeacherSub,ie,t),_.success("Success! Deleted item.",{duration:1e3}),ne()}catch(W){_.error(W?.response?.data?.msg??W?.message??"Failed to delete the item.",{duration:1500})}},ce=ie=>{const W=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,Pe)=>e.jsx(s.Popconfirm,{title:"Delete this subject?",onConfirm:()=>ae(Pe?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(s.Table,{columns:oe,bordered:!0,size:"small",dataSource:W,pagination:!1,rowKey:Ce=>Ce.id})})},je=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(ie,W)=>e.jsxs("div",{children:[W.teacher_name,W.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:je,bordered:!0,dataSource:Array.isArray(K)?K:[],loading:z,rowKey:W=>W.id,expandable:{expandedRowRender:ce},pagination:{current:q.page,pageSize:q.perPage,total:V,showSizeChanger:!0,onChange:(W,oe)=>O({page:W,perPage:oe})}})})),[E,q.page,q.perPage,K,z,V]);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:X,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:P.find(ie=>String(ie.value)===String(n))??null,onChange:ie=>a(ie?.value??null)}),e.jsx(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:L.find(ie=>String(ie.value)===String(r))??null,onChange:ie=>{const W=ie?.value??null;o(W),d(null),p(W?`${we.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(W))}`:null),h(W?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(W))}`:null),I(oe=>!oe)}}),e.jsx(ee,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:N.find(ie=>String(ie.value)===String(l))??null,onChange:ie=>d(ie?.value??null)},`section_${R}`),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(ee,{style:{width:"100%"},options:ie,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:ie.find(W=>String(W.value)===String(c??"No"))??ie[1],onChange:W=>x(W?.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(ie=>vn(m).some(W=>String(W)===String(ie.value))),onChange:(ie,W)=>{const Ce=(Array.isArray(ie)?ie:[]).map(Oe=>Oe?.value).filter(Oe=>Oe!=null&&Oe!=="");u(Ce);const Pe=Array.isArray(k?.subject_ids)?k.subject_ids.map(String):[],ke=W?.removedValue?.value,Me=W?.option?.value;(W?.action==="remove-value"||W?.action==="pop-value")&&ke!=null&&Pe.includes(String(ke))&&v(Oe=>Array.from(new Set([...vn(Oe).map(String),String(ke)]))),W?.action==="select-option"&&Me!=null&&Pe.includes(String(Me))&&v(Oe=>vn(Oe).filter(Ve=>String(Ve)!==String(Me)))}},`subjects_${R}`),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(le,{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:B??void 0,onChange:ie=>{Y(ie),O(W=>({...W,page:1}))},items:re,type:"card",size:"small"})})]})]})}function Rm({token:t}){return e.jsx(Im,{token:t})}const _n=we.timeGroup,Dm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]},At={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=se(String(t),["h:mm a","HH:mm:ss","HH:mm"],!0);return n.isValid()?n:null}function Tt(t){return t?se(t).format("h:mm a"):""}function Om({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(),[x]=s.Form.useForm(),m=`${_n.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:u,isLoading:b,mutate:v}=G(t?[m,t]:null,([f,S])=>Q(f,S)),w=i.useMemo(()=>Dm(u),[u]),p=i.useMemo(()=>u?.pagination?.total_rows??u?.pagination?.total??w.length??0,[u,w]),{data:y}=G(t&&l?[`${_n.show}?id=${encodeURIComponent(String(l))}`,t]:null,([f,S])=>Q(f,S)),h=i.useMemo(()=>{const f=y?.data??y;return Array.isArray(f)?f[0]:f??null},[y]);i.useEffect(()=>{r&&h&&x.setFieldsValue({title:h?.title??"",start_time_from:sa(h?.start_time_from),start_time_to:sa(h?.start_time_to),end_time_from:sa(h?.end_time_from),end_time_to:sa(h?.end_time_to)})},[r,h,x]);const R=async f=>{const S=new FormData;S.append("title",f.title??""),S.append("start_time_from",Tt(f.start_time_from)),S.append("start_time_to",Tt(f.start_time_to)),S.append("end_time_from",Tt(f.end_time_from)),S.append("end_time_to",Tt(f.end_time_to));try{await mt(_n.add,S,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),v()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},I=async f=>{const S=new FormData;S.append("id",String(l??"")),S.append("title",f.title??""),S.append("start_time_from",Tt(f.start_time_from)),S.append("start_time_to",Tt(f.start_time_to)),S.append("end_time_from",Tt(f.end_time_from)),S.append("end_time_to",Tt(f.end_time_to));try{await Ot(_n.edit,S,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),v()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},D=async f=>{try{await Pt(_n.remove,f,t),_.success("Success! Deleted item.",{duration:1e3}),v()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to delete the item.",{duration:1500})}},C=f=>{f?.id&&(d(f.id),o(!0))},g=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:(f,S)=>e.jsxs(s.Space,{children:[e.jsx(s.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>C(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(Z.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:x,layout:"vertical",onFinish:I,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:At})}),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:At})}),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:At})}),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:At})}),e.jsxs(s.Space,{children:[e.jsx(le,{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:R,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:At})}),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:At})}),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:At})}),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:At})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{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:f=>f.id,columns:g,dataSource:w,loading:b,pagination:{current:n.page,pageSize:n.perPage,total:p,showSizeChanger:!0,onChange:(f,S)=>a({page:f,perPage:S})}})})]})}function Pm({token:t}){return e.jsx(Om,{token:t})}const wn=we.assignTimeGroup,km=we.timeGroup.dropdown,Em=we.master.classes.dropdown,ii=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Mm=t=>{const n=t?.data?.data??t?.data??t??[];return Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[]};function Fm({token:t}){const[n,a]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,x]=i.useState(""),[m,u]=i.useState(""),[b,v]=i.useState(null),[w,p]=i.useState(!1),[y,h]=i.useState(!1),[R,I]=i.useState(null),[D,C]=i.useState([]),[g,f]=i.useState(""),[S,A]=i.useState(""),{data:P}=G(t?[km,t]:null,([K,V])=>Q(K,V)),{data:L}=G(t?[Em,t]:null,([K,V])=>Q(K,V)),N=i.useMemo(()=>ii(P?.data??P),[P]),j=i.useMemo(()=>ii(L),[L]),{data:M}=G(t&&b?[b,t]:null,([K,V])=>Q(K,V));i.useEffect(()=>{const K=Array.isArray(M?.data)?M.data.map(V=>V.fk_classId):[];K.length&&d(K)},[M]);const k=`${wn.table}?page=${encodeURIComponent(String(n.page))}&per_page=${encodeURIComponent(String(n.perPage))}`,{data:F,isLoading:E,mutate:B}=G(t?[k,t]:null,([K,V])=>Q(K,V)),Y=i.useMemo(()=>Mm(F),[F]),q=i.useMemo(()=>F?.pagination?.total_rows??F?.pagination?.total??Y.length??0,[F,Y]),{data:O}=G(t&&R?[`${wn.show}?id=${encodeURIComponent(String(R))}`,t]:null,([K,V])=>Q(K,V)),T=O?.data??O??null;i.useEffect(()=>{if(!y||!T)return;const K=Array.isArray(T?.class_ids)?T.class_ids:[];C(K);const V=Array.isArray(N)?N.find(X=>String(X.value)===String(T?.timegroup_id)):null;V&&A(`${V.start_time_from} -> ${V.end_time_from}`)},[y,T,N]);const $=async K=>{if(K.preventDefault(),x(""),!r?.value){_.error("Select Time Group",{duration:1200});return}if(!l.length){x("error"),_.error("Please Select Classes",{duration:1200});return}const V=new FormData;V.append("timegroup_id",String(r.value)),l.forEach(X=>V.append("class_ids[]",String(X)));try{await mt(wn.assign,V,t),_.success("Success! Added new item.",{duration:1e3}),d([]),o(null),u(""),B()}catch(X){_.error(X?.response?.data?.msg??X?.message??"Failed to add the new item.",{duration:1500})}},U=async()=>{if(f(""),!R)return;if(!D.length){f("error"),_.error("Please Select Classes",{duration:1200});return}const K=new FormData;K.append("id",String(R)),K.append("timegroup_id",String(T?.timegroup_id??"")),D.forEach(V=>K.append("class_ids[]",String(V)));try{await Ot(wn.assign,K,t),_.success("Success! Updated item.",{duration:1e3}),h(!1),I(null),B()}catch(V){_.error(V?.response?.data?.msg??V?.message??"Failed to update the item.",{duration:1500})}},z=K=>{K&&(I(K),h(!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:(K,V)=>V?.class_names?e.jsx(s.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>z(V?.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:y,onClose:()=>{h(!1),I(null)},width:520,extra:e.jsxs(s.Space,{children:[e.jsx(s.Button,{onClick:()=>h(!1),children:"Cancel"}),e.jsx(s.Button,{type:"primary",onClick:U,children:"Submit"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(ee,{options:Array.isArray(N)?N:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:N.find(K=>String(K.value)===String(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:g,value:D,placeholder:"Select Classes",onChange:K=>C(K),options:Array.isArray(j)?j:[]})]})]})}),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(ee,{options:Array.isArray(N)?N:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:r,onChange:K=>{o(K??null),d([]),x(""),K?.value?(v(`${wn.classIdByTimeGroup}?id=${encodeURIComponent(String(K.value))}`),u(`${K.start_time_from} -> ${K.end_time_from}`)):(v(null),u("")),p(V=>!V)}}),e.jsx("div",{style:{marginTop:6},children:m})]}),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:K=>d(K),options:Array.isArray(j)?j:[]},`class_${w}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{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:K=>K.id,columns:ne,dataSource:Y,loading:E,pagination:{current:n.page,pageSize:n.perPage,total:q,showSizeChanger:!0,onChange:(K,V)=>a({page:K,perPage:V})}})})]})}function $m({token:t}){return e.jsx(Fm,{token:t})}const vs=we.promoteStudents,Nm=({token:t})=>G(t?[vs.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[]},Um=(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 Bm({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}),[x,m]=i.useState(!1),[u,b]=i.useState([]),v=i.useMemo(()=>new Set(u),[u]),[w,p]=i.useState({}),[y,h]=i.useState({}),{data:R}=G(t?[we.master.classes.dropdown,t]:null,([U,z])=>Q(U,z)),I=i.useMemo(()=>ra(R),[R]),D=i.useMemo(()=>o.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(o.classId))}`:null,[o.classId]),{data:C}=G(t&&D?[D,t]:null,([U,z])=>Q(U,z)),g=i.useMemo(()=>ra(C),[C]),f=i.useMemo(()=>d.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:S}=G(t&&f?[f,t]:null,([U,z])=>Q(U,z),{revalidateOnFocus:!1}),A=i.useMemo(()=>ra(S),[S]),{data:P}=Nm({token:t}),L=i.useMemo(()=>ra(P),[P]),{trigger:N,data:j,isMutating:M}=Ge(t?vs.searchByClassSection:null,(U,{arg:z})=>qt(U,{arg:z},t)),k=i.useMemo(()=>{const U=j?.data?.data??j?.data??j??[];return Array.isArray(U)?U:Array.isArray(U?.data)?U.data:[]},[j]),F=i.useMemo(()=>Um(j,k.length??0),[j,k.length]),E=i.useMemo(()=>{const U=new Map;return(Array.isArray(k)?k:[]).forEach(z=>{z?.id!==void 0&&z?.id!==null&&U.set(String(z.id),z)}),U},[k]),B=i.useCallback((U,z)=>{const ne=String(U);h(K=>({...K,[ne]:{...K?.[ne]??{},...z}}))},[]),Y=i.useCallback((U,z)=>{const ne=String(U),K=z==="Leave";p(V=>({...V,[ne]:K}))},[]),q=U=>{const z=U?.class_id?.value??U?.class_id??null,ne=U?.section_id?.value??U?.section_id??null;if(!z||!ne){_.error("Please select Class and Section",{duration:1200});return}r(K=>({...K,page:1})),l({classId:z,sectionId:ne}),b([]),p({}),h({})},O=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 U=u.map(V=>String(V)).map(V=>{const X=E.get(V)??{},ae=!!w?.[V],ce=y?.[V]??{},je=String(ce.current_result??"Pass");if(ae){const W=String(ce.leave_date??"");return{student_id:V,current_result:je,next_session_status:"Leave",leave_date:W}}const re=String(ce.roll_no??X?.roll_no??""),ie=String(ce.section_id??"");return{student_id:V,roll_no:re,section_id:ie,current_result:je,next_session_status:"Continue"}});if(U.some(V=>V?.next_session_status==="Leave"&&!String(V?.leave_date??"").trim())){_.error("Leave date is required for Leave students.",{duration:1500});return}if(U.some(V=>V?.next_session_status==="Continue"&&!String(V?.section_id??"").trim())){_.error("Section is required for Continue students.",{duration:1500});return}const K={class_id:String(d.classId),session_id:String(d.sessionId),students:U};try{const V=await pt(vs.promote,K,t);if(V?.Status&&String(V.Status)!=="success")throw new Error(V?.msg||"Failed to update");_.success("Success! Updated.",{duration:1e3});const X=Number(V?.success_count??0)+Number(V?.leave_count??0),ae=a.page===Math.ceil((Number(F)||0)/a.perPage||1),ce=X>0&&X===k.length&&k.length===u.length,je=ae&&ce&&a.page>1?a.page-1:a.page;r(re=>({...re,page:je})),N?.({cID:o.classId,sID:o.sectionId,page:je,per_page:a.perPage}),b([]),p({}),h({})}catch(V){_.error(V?.response?.data?.msg??V?.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:(U,z)=>{const ne=String(z?.id??""),K=v.has(ne),V=!!w?.[ne],ae=(y?.[ne]??{}).roll_no??(V?"":z?.roll_no??"");return e.jsx(s.Input,{value:K?ae:z?.roll_no,style:K?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!K||V,onChange:ce=>B(ne,{roll_no:ce.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(U,z)=>`${z?.firstname??""} ${z?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(U,z)=>{const ne=String(z?.id??""),K=v.has(ne),V=!!w?.[ne],ae=(y?.[ne]??{}).section_id??"",ce=Array.isArray(A)?A:[];return e.jsx(s.Select,{options:ce,placeholder:K&&!V?"Select Section":"Section",disabled:!K||V,value:K&&!V&&ae||void 0,style:{width:"100%"},onChange:je=>B(ne,{section_id:je})},`section_${ne}_${x}_${V?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(U,z)=>{const ne=String(z?.id??""),K=v.has(ne),V=y?.[ne]??{},X=String(V.current_result??"Pass");return e.jsxs(s.Radio.Group,{value:X,disabled:!K,buttonStyle:"solid",onChange:ae=>B(ne,{current_result:ae.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:(U,z)=>{const ne=String(z?.id??""),K=v.has(ne),V=!!w?.[ne],X=y?.[ne]??{},ae=String(X.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(s.Radio.Group,{value:V?"Leave":"Continue",disabled:!K,buttonStyle:"solid",onChange:ce=>Y(ne,ce.target.value),children:[e.jsx(s.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(s.Radio.Button,{value:"Leave",children:"Leave"})]}),K&&V&&e.jsx(s.DatePicker,{style:{width:"100%"},value:ae?se(ae):null,onChange:ce=>B(ne,{leave_date:ce?ce.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[Y,w,y,v,x,A,B]),$=i.useMemo(()=>({selectedRowKeys:u,onChange:U=>b((Array.isArray(U)?U:[]).map(z=>String(z)))}),[u]);return i.useEffect(()=>{!o.classId||!o.sectionId||N&&N({cID:o.classId,sID:o.sectionId,page:a.page,per_page:a.perPage})},[a.page,a.perPage,N,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:q,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:U=>U,children:e.jsx(ee,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:U=>{const z=U?.value??null;n.setFieldValue("section_id",null),l({classId:z,sectionId:null})}})}),e.jsx(s.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:U=>U,children:e.jsx(ee,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{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(Et,{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(ee,{label:"Session",options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:L.find(U=>String(U.value)===String(d.sessionId))??null,onChange:U=>c(z=>({...z,sessionId:U?.value??null}))}),e.jsx(ee,{label:"Class",options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:I.find(U=>String(U.value)===String(d.classId))??null,onChange:U=>{const z=U?.value??null;c(ne=>({...ne,classId:z})),m(ne=>!ne)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"button",value:"Save",color:"primary",onClick:O})})]}),e.jsx(s.Table,{rowKey:U=>String(U.id),rowSelection:$,columns:T,dataSource:k,loading:M,pagination:{current:a.page,pageSize:a.perPage,total:F,showSizeChanger:!0,onChange:(U,z)=>{r({page:U,perPage:z}),b([]),p({}),h({})}}})]})})]})}function Lm({token:t}){return e.jsx(Bm,{token:t})}const nn=we.coscholastic,qm=({token:t})=>G(t?[nn.table,t]:null,([n,a])=>Q(n,a),{revalidateOnFocus:!1}),zm=({token:t})=>G(t?[nn.categoryDropdown,t]:null,([n,a])=>Q(n,a),{revalidateOnFocus:!1}),oi=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 Ym({token:t}){const[n,a]=i.useState(""),[r,o]=i.useState(null),[l,d]=i.useState(null),c=i.useRef(null),{data:x}=G(t?[we.master.classes.dropdown,t]:null,([S,A])=>Q(S,A)),m=i.useMemo(()=>oi(x),[x]),{data:u,isLoading:b,mutate:v}=qm({token:t}),w=i.useMemo(()=>{const S=u?.data?.data??u?.data??u??[];return Array.isArray(S)?S:Array.isArray(S?.data)?S.data:[]},[u]),{data:p,mutate:y}=zm({token:t}),h=i.useMemo(()=>oi(p),[p]),R=i.useMemo(()=>(Array.isArray(h)?h:[]).map(S=>({value:S?.value??S?.id,label:S?.label??S?.title??""})),[h]),I=async()=>{const S=String(n??"").trim();if(!S){_.error("Please enter category title",{duration:1200});return}try{await ze(nn.addCategory,{title:S},t),_.success("Success! Added category.",{duration:1e3}),a(""),y()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add category",{duration:1500})}},D=async S=>{try{await Pt(nn.deleteCategory,S,t),_.success("Success! Deleted category.",{duration:1e3}),y()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete category",{duration:1500})}},C=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 P=new FormData(S.target);P.append("scholastic_catid",String(r)),P.append("class_id",String(l));try{await mt(nn.addSkill,P,t),_.success("Success! Added new item.",{duration:1e3}),S.target.reset(),d(null),v()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},g=async S=>{try{await Pt(nn.deleteSkill,S,t),_.success("Success! Deleted item.",{duration:1e3}),v()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete the item.",{duration:1500})}},f=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:()=>g(A?.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(Z.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: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:R.find(S=>String(S.value)===String(r))??null,placeholder:"Select Category",onChange:S=>o(S?.value??null),options:R}),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(Z.PlusOutlined,{}),onClick:I}),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(Z.DeleteOutlined,{}),disabled:!r})})]})]}),e.jsx(ee,{label:"Class",options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:m.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(le,{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(Et,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(s.Table,{rowKey:S=>S.id,columns:f,dataSource:w,loading:b,pagination:!1})})]})}function Vm({token:t}){return e.jsx(Ym,{token:t})}const Wm=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:n,onChange:a})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(s.Upload,{maxCount:1,action:sm(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=Wm(o?.file?.response);l&&a?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})},li=we.notes,Hm=({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[]},Km=(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 Gm({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,x]=i.useState(!1),[m,u]=i.useState(""),{data:b}=G(t?[we.master.classes.dropdown,t]:null,([$,U])=>Q($,U)),v=i.useMemo(()=>ia(b),[b]),w=i.useMemo(()=>l.classId?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:p}=G(t&&w?[w,t]:null,([$,U])=>Q($,U)),y=i.useMemo(()=>ia(p),[p]),h=i.useMemo(()=>!l.classId||!l.sectionId?null:`${li.table}?class_id=${encodeURIComponent(String(l.classId))}&section_id=${encodeURIComponent(String(l.sectionId))}&page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.perPage))}`,[l.classId,l.sectionId,r.page,r.perPage]),{data:R,isLoading:I,mutate:D}=Hm({token:t,url:h}),C=i.useMemo(()=>{const $=R?.data?.data??R?.data??R??[];return Array.isArray($)?$:Array.isArray($?.data)?$.data:[]},[R]),g=i.useMemo(()=>R?.pagination?.total_rows??R?.pagination?.total??C.length??0,[R,C.length]),[f,S]=i.useState(null),[A,P]=i.useState(null),[L,N]=i.useState(null),[j,M]=i.useState(!1),{data:k}=G(t&&L?[L,t]:null,([$,U])=>Q($,U),{revalidateOnFocus:!1}),F=i.useMemo(()=>ia(k),[k]),{data:E}=G(t&&A?[A,t]:null,([$,U])=>Q($,U)),B=i.useMemo(()=>ia(E),[E]),Y=$=>{const U=$?.class_id?.value??null,z=$?.section_id?.value??null;!U||!z||(o(ne=>({...ne,page:1})),d({classId:U,sectionId:z}))},q=()=>{u(""),x(!0),S(null),P(null),N(null),M($=>!$),a.resetFields()},O=async $=>{const U=$?.class_id?.value??null,z=$?.section_id?.value??null,ne=$?.sub_id?.value??null,K=$?.status?.value??"publish",V=$?.title??"",X=$?.remark??"";if(!U||!z||!ne||!V||!X||!m){_.error("Please fill all fields",{duration:1200});return}const ae=new FormData;ae.append("class_id",String(U)),ae.append("section_id",String(z)),ae.append("sub_id",String(ne)),ae.append("title",String(V)),ae.append("remark",String(X)),ae.append("status",String(K)),ae.append("file",String(m));try{await mt(li.add,ae,t),_.success("Success! Added new item.",{duration:1e3}),x(!1),D()}catch(ce){_.error(ce?.response?.data?.msg??ce?.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:($,U)=>{const z=String(U?.status??"").toLowerCase();return e.jsx(s.Tag,{color:z==="publish"?"green":"red",children:U?.status??"-"})}},{title:"File",key:"file",align:"center",render:($,U)=>{const z=U?.file;if(!z)return"-";const ne=Km(tt(),`/student/note/${z}`);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:()=>x(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(s.Form,{form:a,layout:"vertical",onFinish:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:$=>$,children:e.jsx(ee,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const U=$?.value??null;S(U),a.setFieldValue("section_id",null),a.setFieldValue("sub_id",null),N(U?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(U))}`:null),P(U?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(U))}`:null),M(z=>!z)}},`class_${j}`)}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:$=>$,children:e.jsx(ee,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${j}_${f??"none"}`)}),e.jsx(s.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:$=>$,children:e.jsx(ee,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${j}_${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(ee,{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(ho,{token:t,value:m,onChange:u})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(le,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>x(!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(Et,{actions:["add","export","print","download","filter"],onAdd:q,onPrint:()=>window.print()})]}),children:e.jsx(s.Form,{form:n,layout:"vertical",onFinish:Y,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(ee,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:$=>{const U=$?.value??null;n.setFieldValue("section_id",null),d({classId:U,sectionId:null})}})}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:$=>$,children:e.jsx(ee,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{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:C,loading:I,pagination:{current:r.page,pageSize:r.perPage,total:g,showSizeChanger:!0,onChange:($,U)=>o({page:$,perPage:U})}})})]})}function Jm({token:t}){return e.jsx(Gm,{token:t})}const Qm=({token:t})=>G(t?[we.promoteStudents.sessionDropdown,t]:null,([n,a])=>Q(n,a),{revalidateOnFocus:!1}),di=we.transferCertificate,os=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[]},Xm={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Zm=(t,n)=>t.inputtype==="Select"?null:t.inputtype==="date"?se():"",ci=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}],ui=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 ef({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,x]=i.useState({classId:null,sectionId:null,sessionId:null}),[m,u]=i.useState(null),[b,v]=i.useState(!1),{data:w}=G(t?[we.master.classes.dropdown,t]:null,([T,$])=>Q(T,$)),p=i.useMemo(()=>os(w),[w]),{data:y}=G(t&&m?[m,t]:null,([T,$])=>Q(T,$)),h=i.useMemo(()=>os(y),[y]),{data:R}=Qm({token:t}),I=i.useMemo(()=>os(R),[R]),D=i.useMemo(()=>!c.classId||!c.sectionId||!c.sessionId?null:`${di.studentList}?class_id=${encodeURIComponent(String(c.classId))}&section_id=${encodeURIComponent(String(c.sectionId))}&session_id=${encodeURIComponent(String(c.sessionId))}&page=${encodeURIComponent(String(l.page))}&per_page=${encodeURIComponent(String(l.perPage))}`,[c.classId,c.sectionId,c.sessionId,l.page,l.perPage]),{data:C,isLoading:g,mutate:f}=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&&k(String($[0].transefer_certificate_id))}}),S=i.useMemo(()=>{const T=C?.data?.data??C?.data??C??[];return Array.isArray(T)?T:Array.isArray(T?.data)?T.data:[]},[C]),A=i.useMemo(()=>C?.pagination?.total_rows??C?.pagination?.total??S.length??0,[C,S.length]),[P,L]=i.useState(!1),[N,j]=i.useState(null),[M,k]=i.useState("1"),F=T=>{j(T);const $=M==="1"?ci(T):ui(T),U={};$.forEach(z=>{U[z.name]=z.value??Zm(z)}),o.setFieldsValue(U),L(!0)},E=async T=>{if(!T)return;if(typeof a=="function")return a(T);const $=`${n}?id=${encodeURIComponent(String(T))}`;window.location.href=$},B=T=>{const $=T?.class_id?.value??null,U=T?.section_id?.value??null,z=T?.session_id?.value??null;if(!$||!U||!z){_.error("Please select Class, Section and Session",{duration:1200});return}d(ne=>({...ne,page:1})),x({classId:$,sectionId:U,sessionId:z})},Y=async T=>{const $=new FormData;Object.entries(T??{}).forEach(([U,z])=>{if(z!=null){if(se.isDayjs(z)){$.append(U,z.format("YYYY-MM-DD"));return}$.append(U,String(z))}});try{await mt(di.addData,$,t),_.success("Success! Added new item.",{duration:1e3}),L(!1),j(null),f()}catch(U){_.error(U?.response?.data?.msg??U?.message??"Failed to add the new item.",{duration:1500})}},q=i.useMemo(()=>M==="1"?ci(N):ui(N),[M,N]),O=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(Z.EyeOutlined,{}):e.jsx(Z.CheckOutlined,{}),onClick:()=>{$?.transfer_certificate_data==="not_present"?F($?.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:P,onCancel:()=>L(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(s.Form,{form:o,layout:"vertical",onFinish:Y,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:q.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:Xm})},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(ee,{options:p,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(le,{type:"submit",value:"Submit",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>L(!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:B,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(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:T=>{const $=T?.value??null;u($?`${we.master.sections.byClass}?class_id=${encodeURIComponent(String($))}`:null),v(U=>!U),r.setFieldValue("section_id",null)}})}),e.jsx(s.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:T=>T,children:e.jsx(ee,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${b}`)}),e.jsx(s.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:T=>T,children:e.jsx(ee,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{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(Et,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(s.Table,{rowKey:T=>T.id,columns:O,dataSource:S,loading:g,pagination:{current:l.page,pageSize:l.perPage,total:A,showSizeChanger:!0,onChange:(T,$)=>d({page:T,perPage:$})}})})]})}function tf({token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:a}){return e.jsx(ef,{token:t,transferCertificateViewPath:n,onOpenTransferCertificateView:a})}const nf=({token:t,url:n})=>G(t&&n?[n,t]:null,([a,r])=>Q(a,r),{revalidateOnFocus:!1}),ls=we.syllabus,pi=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[]},af=(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 sf({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,x]=i.useState(!1),[m,u]=i.useState(null),[b,v]=i.useState(""),{data:w}=G(t?[we.master.classes.dropdown,t]:null,([E,B])=>Q(E,B)),p=i.useMemo(()=>pi(w),[w]),y=i.useMemo(()=>l.classId?`${ls.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:h,isLoading:R,mutate:I}=nf({token:t,url:y}),D=i.useMemo(()=>{const E=h?.data?.data??h?.data??h??[];return Array.isArray(E)?E:Array.isArray(E?.data)?E.data:[]},[h]),C=i.useMemo(()=>h?.pagination?.total_rows??h?.pagination?.total??D.length??0,[h,D.length]),[g,f]=i.useState(null),[S,A]=i.useState(!1),{data:P}=G(t&&g?[g,t]:null,([E,B])=>Q(E,B),{revalidateOnFocus:!1}),L=i.useMemo(()=>pi(P),[P]),N=E=>{const B=E?.class_id?.value??null;B&&(o(Y=>({...Y,page:1})),d({classId:B}))},j=()=>{u(null),v(""),f(null),A(E=>!E),a.resetFields(),x(!0)},M=E=>{u(E),v(E?.attchement??"");const B=E?.class_id;f(B?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(B))}`:null),A(Y=>!Y),a.setFieldsValue({class_id:p.find(Y=>String(Y.value)===String(B))??null,sub_id:L.find(Y=>String(Y.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??""}),x(!0)},k=async E=>{const B=E?.class_id?.value??null,Y=E?.sub_id?.value??null,q=E?.title??"",O=E?.description??"";if(!B||!Y||!q||!O||!b){_.error("Please fill all fields",{duration:1200});return}const T=new FormData;T.append("class_id",String(B)),T.append("sub_id",String(Y)),T.append("title",String(q)),T.append("description",String(O)),T.append("file",String(b));try{m?.id?(T.append("id",String(m.id)),await mt(ls.edit,T,t),_.success("Success! Updated item.",{duration:1e3})):(await mt(ls.add,T,t),_.success("Success! Added new item.",{duration:1e3})),x(!1),u(null),I()}catch($){_.error($?.response?.data?.msg??$?.message??"Failed to save",{duration:1500})}},F=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,B)=>{const Y=B?.attchement;if(!Y)return"-";const q=af(tt(),`uploads/student/note/${Y}`);return e.jsx("a",{href:q,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:(E,B)=>e.jsx(s.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>M(B)})}],[L,p]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(s.Modal,{title:m?"Edit Syllabus":"Add Syllabus",open:c,onCancel:()=>{x(!1),u(null),v("")},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:E=>E,children:e.jsx(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:E=>{const B=E?.value??null;a.setFieldValue("sub_id",null),f(B?`${we.master.subjects.dropdown}?class_id=${encodeURIComponent(String(B))}`:null),A(Y=>!Y)}},`class_${m?.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(ee,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${m?.id??"add"}_${S}_${g??"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(It,{placeholder:"Description"})}),e.jsx(s.Form.Item,{label:"File",required:!0,children:e.jsx(ho,{token:t,value:b,onChange:v})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(le,{type:"submit",value:"Save",color:"primary"}),e.jsx(s.Button,{type:"text",onClick:()=>x(!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(Et,{actions:["add","export","print","download","filter"],onAdd:j,onPrint:()=>window.print()})]}),children:e.jsx(s.Form,{form:n,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(s.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:E=>E,children:e.jsx(ee,{options:p,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{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:F,dataSource:D,loading:R,pagination:{current:r.page,pageSize:r.perPage,total:C,showSizeChanger:!0,onChange:(E,B)=>o({page:E,perPage:B})}})})]})}function rf({token:t}){return e.jsx(sf,{token:t})}const La=we.timetable,mi=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[]},fi=t=>{if(!t)return"";const n=se(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},of=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]},yi=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],lf=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"};function df({token:t}){const[n,a]=i.useState(null),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,x]=i.useState(""),[m,u]=i.useState(""),{data:b}=G(t?[we.master.classes.dropdown,t]:null,([f,S])=>Q(f,S)),v=i.useMemo(()=>mi(b),[b]),{data:w}=G(t&&n?[n,t]:null,([f,S])=>Q(f,S)),p=i.useMemo(()=>mi(w),[w]),{data:y,isLoading:h}=G(t&&l?[l,t]:null,([f,S])=>Q(f,S),{revalidateOnFocus:!1}),R=i.useMemo(()=>y?.days??y?.data?.days??y?.data?.data?.days??{},[y]),{dataSource:I,daySpanByFirstKey:D}=i.useMemo(()=>{const f=Object.entries(R||{}).slice().sort((P,L)=>yi.indexOf(String(P[0]).toLowerCase())-yi.indexOf(String(L[0]).toLowerCase())),S=new Map,A=[];for(const[P,L]of f){const N=(Array.isArray(L)?L:[]).slice().sort((M,k)=>Number(M?.order_no||0)-Number(k?.order_no||0)),j=N.length;for(let M=0;M<j;M+=1){const k=N[M],F=k?.id||`${P}-${k?.order_no}-${M}`;M===0&&S.set(F,j),A.push({key:F,_dayKey:P,...k})}}return{dataSource:A,daySpanByFirstKey:S}},[R]),C=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(f,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(Z.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(s.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:lf(f)})]}),props:{rowSpan:A}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:f=>e.jsx(s.Tag,{color:"#5080f8",style:{fontWeight:500},children:f})},{title:"Time",key:"time",width:180,render:(f,S)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Z.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(s.Typography.Text,{children:[fi(S?.time_from)," - ",fi(S?.time_to)]})]})},{title:"Subject",key:"subject",render:(f,S)=>{if(String(S?.is_break)==="1")return e.jsx(s.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const P=S?.subject_name||"-";return e.jsx(s.Tag,{color:of(P),style:{fontWeight:500},children:P})}},{title:"Teacher",key:"teacher",render:(f,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(s.Typography.Text,{children:A?"-":S?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(f,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(s.Typography.Text,{children:A?"-":S?.room_no||"-"})]})}}],[D]),g=f=>{f.preventDefault();const S=f.target.class_id?.value,A=f.target.section_id?.value;if(!S||!A)return;const P=v.find(M=>String(M.value)===String(S)),L=p.find(M=>String(M.value)===String(A));x(P?.label||""),u(L?.label||"");const j=`${La.byClassSection}/${S}/section/${A}`;d(j)};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(Et,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),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(ee,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:f=>{a(`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(f?.value??""))}`),o(S=>!S)}}),e.jsx(ee,{options:p,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(le,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(s.Card,{title:e.jsx(s.Typography.Title,{level:5,style:{margin:0},children:c||m?`Timetable: ${c} ${m}`:"Timetable"}),children:e.jsx(s.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:I,columns:C,rowKey:"key",loading:h,scroll:{x:"max-content"}})})]})}const cf=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[]},hi=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],uf=t=>{const n=String(t||"");return n?n.charAt(0).toUpperCase()+n.slice(1):"-"},gi=t=>{if(!t)return"";const n=se(t,"HH:mm:ss");return n.isValid()?n.format("h:mm a"):String(t)},pf=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 mf({token:t}){const[n,a]=i.useState(null),[r,o]=i.useState(null),{data:l}=G(t?[we.assignByClass.teacherDropdown,t]:null,([w,p])=>Q(w,p)),d=i.useMemo(()=>cf(l),[l]),{data:c,isLoading:x}=G(t&&r?[r,t]:null,([w,p])=>Q(w,p),{revalidateOnFocus:!1}),{dataSource:m,daySpanByFirstKey:u}=i.useMemo(()=>{const p=(Array.isArray(c?.data)&&c.data||Array.isArray(c?.data?.data)&&c.data.data||[]).slice().sort((I,D)=>{const C=hi.indexOf(String(I?.day_name||"").toLowerCase()),g=hi.indexOf(String(D?.day_name||"").toLowerCase());if(C!==g)return C-g;const f=Number(I?.order_no||0),S=Number(D?.order_no||0);return f!==S?f-S:String(I?.time_from||"").localeCompare(String(D?.time_from||""))}),y=new Map,h=[];let R=0;for(;R<p.length;){const I=String(p[R]?.day_name||"").toLowerCase();let D=R;for(;D<p.length&&String(p[D]?.day_name||"").toLowerCase()===I;)D+=1;const C=D-R;for(let g=R;g<D;g+=1){const f=p[g],S=f?.id||`${I}-${f?.order_no}-${g}`;g===R&&y.set(S,C),h.push({key:S,_dayKey:I,...f})}R=D}return{dataSource:h,daySpanByFirstKey:y}},[c]),b=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(w,p)=>{const y=u.get(p.key);return y===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(s.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:uf(w)})]}),props:{rowSpan:y}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:w=>e.jsx(s.Tag,{color:"#5080f8",style:{fontWeight:500},children:w})},{title:"Time",key:"time",width:180,render:(w,p)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Z.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(s.Typography.Text,{children:[gi(p?.time_from)," - ",gi(p?.time_to)]})]})},{title:"Subject",key:"subject",render:(w,p)=>{if(String(p?.is_break)==="1")return e.jsx(s.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const h=p?.subject_name||"-";return e.jsx(s.Tag,{color:pf(h),style:{fontWeight:500},children:h})}},{title:"Class",key:"class",width:160,render:(w,p)=>e.jsxs(s.Tag,{color:"purple",style:{fontWeight:500},children:[p?.class_name||p?.class_id||"-"," ",p?.section_name?`(${p.section_name})`:""]})},{title:"Room",key:"room_no",width:120,render:(w,p)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Z.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(s.Typography.Text,{children:p?.room_no||"-"})]})}],[u]),v=w=>{w.preventDefault();const p=w.target.teacher_id?.value;if(!p)return;a(p);const h=`${La.teacherTimetable}${encodeURIComponent(String(p))}`;o(h)};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(Et,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),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(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(le,{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:m,columns:b,rowKey:"key",loading:x,scroll:{x:"max-content"}})})]})}function xi(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 x=a.replace(/\s+/g," ").match(/^(\d{1,2})\s*:\s*(\d{1,2})(?:\s*:\s*(\d{1,2}))?\s*(am|pm)$/i);if(!x)return null;o=Number.parseInt(x[1],10),l=Number.parseInt(x[2],10),d=Number.parseInt(x[3]||"0",10);const m=x[4].toLowerCase();m==="pm"&&o<12&&(o+=12),m==="am"&&o===12&&(o=0)}else{const c=n.split(":").map(x=>x.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:se().hour(o).minute(l).second(d).millisecond(0)}function Cn(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[]},Dn={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},ff=t=>{const n=Dn[String(t)];return n?n.charAt(0).toUpperCase()+n.slice(1):String(t)},yf=({token:t,classId:n,sectionId:a,subjectId:r,value:o,onChange:l,disabled:d})=>{const c=t&&n&&a&&r?`${La.teachersBySubject}?subject_id=${encodeURIComponent(String(r))}&class_id=${encodeURIComponent(String(n))}&section_id=${encodeURIComponent(String(a))}`:null,{data:x,isLoading:m}=G(c?[c,t]:null,([b,v])=>Q(b,v),{revalidateOnFocus:!1}),u=i.useMemo(()=>va(x?.data??x).map(v=>({value:v?.value??v?.id,label:v?.label??v?.name??v?.teacher_name??""})),[x]);return e.jsx(s.Select,{placeholder:d?"-":"Select Teacher",loading:m,disabled:d,style:{width:"100%"},options:u,value:o?String(o):void 0,onChange:b=>l?.(b),showSearch:!0,optionFilterProp:"label"})};function hf({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:[]}),[x,m]=i.useState(!1),u=i.useMemo(()=>t?we.master.classes.dropdown:null,[t]),{data:b}=G(u?[u,t]:null,([j,M])=>Q(j,M)),v=i.useMemo(()=>va(b).map(j=>({value:j?.value??j?.id,label:j?.label??j?.title??""})),[b]),w=i.useMemo(()=>!t||!a.classId?null:`${we.master.sections.byClass}?class_id=${encodeURIComponent(String(a.classId))}`,[a.classId,t]),{data:p}=G(w?[w,t]:null,([j,M])=>Q(j,M)),y=i.useMemo(()=>va(p).map(j=>({value:j?.value??j?.id,label:j?.label??j?.title??""})),[p]),h=i.useMemo(()=>!t||!a.classId?null:`${we.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(a.classId))}`,[a.classId,t]),{data:R}=G(h?[h,t]:null,([j,M])=>Q(j,M)),I=i.useMemo(()=>va(R).map(j=>({value:j?.value??j?.id,label:j?.label??j?.title??""})),[R]),D=i.useMemo(()=>Array.isArray(d?.[a.dayKey])?d[a.dayKey]:[],[a.dayKey,d]),C=i.useCallback((j,M,k)=>{c(F=>{const E={...F},B=Array.isArray(E[j])?E[j].slice():[];return B[M]={...B[M]??{},...k},E[j]=B,E})},[]),g=i.useCallback((j,M)=>{c(k=>{const F={...k},E=Array.isArray(F[j])?F[j].slice():[];return E.splice(M,1),F[j]=E.map((B,Y)=>({...B,order_no:Y+1})),F})},[]),f=i.useCallback(j=>{c(M=>{const k={...M},F=Array.isArray(k[j])?k[j].slice():[];let E=null,B=null;const Y=F[F.length-1];if(Y?.time_to){const q=xi(Y.time_to),O=Number.parseInt(o.interval,10)||0,T=Number.parseInt(o.duration,10)||0,$=Cn(q,O),U=T>0?Cn($,T):null;E=$?.isValid?.()?$.format("HH:mm:ss"):null,B=U?.isValid?.()?U.format("HH:mm:ss"):null}return F.push({order_no:F.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:E,time_to:B,is_break:!1}),k[j]=F,k})},[o.duration,o.interval,o.roomNo]),S=i.useCallback(()=>{const j=o.startTime,M=o.endTime,k=Number.parseInt(o.duration,10),F=Number.parseInt(o.interval,10);if(!j||!j.isValid?.()){_.error("Start time is required",{duration:1500});return}if(!M||!M.isValid?.()){_.error("End time is required",{duration:1500});return}if(!M.isAfter(j)){_.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(k)||k<=0){_.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite(F)||F<0){_.error("Interval must be 0 or more",{duration:1500});return}const E=()=>{const B=[];let Y=j;for(let q=0;q<50;q+=1){const O=Cn(Y,k);if(!O||!O.isValid?.()||O.isAfter(M))break;B.push({order_no:B.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:Y.format("HH:mm:ss"),time_to:O.format("HH:mm:ss"),is_break:!1});const T=Cn(O,F);if(!T||!T.isValid?.()||T.isAfter(M)||T.isSame(M))break;Y=T}if(o.tiffinEnabled){const q=Math.max(0,Number.parseInt(o.tiffinAfterPeriod,10)||0),O=Math.max(0,Number.parseInt(o.tiffinDuration,10)||0),T=Math.min(q,B.length);if(T>0&&O>0){const $=B[T-1],U=$?.time_to?xi($.time_to):null,z=U?Cn(U,O):null;U?.isValid?.()&&z?.isValid?.()&&!z.isAfter(M)&&B.splice(T,0,{order_no:T+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:U.format("HH:mm:ss"),time_to:z.format("HH:mm:ss"),is_break:!0})}}return B.map((q,O)=>({...q,order_no:O+1}))};c(B=>{const Y={...B};return Object.keys(Dn).forEach(q=>{a.daysEnabled?.[q]&&(Y[q]=E())}),Y}),_.success("Generated schedule",{duration:1e3})},[o,a.daysEnabled]),A=i.useCallback(()=>{const j=localStorage.getItem("genrall_settings"),k=(j?JSON.parse(j):{})?.session_id??"1",F=a.classId,E=a.sectionId,B=Object.keys(Dn).map(Y=>{const q=(Array.isArray(d?.[Y])?d[Y]:[]).map((O,T)=>({order_no:T+1,subject_id:O?.is_break?0:O?.subject_id??null,teacher_id:O?.is_break?0:O?.teacher_id??null,room_no:O?.room_no??"",time_from:O?.time_from??null,time_to:O?.time_to??null,is_break:O?.is_break?1:0}));return{day:Dn[Y],class_id:F,section_id:E,session_id:k,args:q}});return{class_id:F,section_id:E,session_id:k,days:B}},[a.classId,a.sectionId,d]),P=i.useCallback(async()=>{if(!a.classId||!a.sectionId){_.error("Please select Class and Section",{duration:1500});return}const j=A(),M=Array.isArray(j?.days)?j.days:[];if(!M.some(E=>Array.isArray(E?.args)&&E.args.length>0)){_.error("No timetable rows to submit",{duration:1500});return}const F=E=>{const B=E?.is_break;return B===1||B==="1"||B===!0?!0:String(B??"").toLowerCase()==="true"};M.some(E=>(Array.isArray(E?.args)?E.args:[]).some(B=>String(B?.time_from??"").trim()&&String(B?.time_to??"").trim()?F(B)?!1:!String(B?.subject_id??"").trim()||!String(B?.teacher_id??"").trim():!0)),m(!0);try{const E=La.save,B=E==="api/timetable/save"?"timetable/save":null,Y=async T=>{const $=await ka(T,j,t);if($&&typeof $=="object")return $;throw new Error("No response from server")};let q;try{q=await Y(E)}catch{q=await Y(B)}const O=String(q?.msg??"");if(String(q?.Status)==="Success"){if(Array.isArray(q?.data)&&q.data.length===0&&O){_.error(O,{duration:3e3});return}_.success(O||"Weekly Time Table added successfully!",{duration:1200});return}_.error(O||"Failed to add time table",{duration:3e3})}catch(E){_.error(E?.response?.data?.msg??E?.message??"Failed to add time table",{duration:3e3})}finally{m(!1)}},[A,a.classId,a.sectionId,t]),L=i.useMemo(()=>[{title:"Period",dataIndex:"order_no",key:"order_no",width:80},{title:"Time From",dataIndex:"time_from",key:"time_from",width:120,render:j=>j?se(j,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:j=>j?se(j,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(j,M,k)=>e.jsx(s.Switch,{checked:!!M?.is_break,onChange:F=>{C(a.dayKey,k,{is_break:F,subject_id:F?"":M?.subject_id??"",teacher_id:F?"":M?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(j,M,k)=>e.jsx(s.Select,{placeholder:M?.is_break?"-":"Select Subject",disabled:!!M?.is_break,style:{width:"100%"},options:I,value:M?.subject_id?String(M.subject_id):void 0,onChange:F=>C(a.dayKey,k,{subject_id:F,teacher_id:""}),showSearch:!0,optionFilterProp:"label"})},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(j,M,k)=>e.jsx(yf,{token:t,classId:a.classId,sectionId:a.sectionId,subjectId:M?.subject_id,disabled:!!M?.is_break||!M?.subject_id,value:M?.teacher_id,onChange:F=>C(a.dayKey,k,{teacher_id:F})})},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(j,M,k)=>e.jsx(s.Input,{value:M?.room_no??"",onChange:F=>C(a.dayKey,k,{room_no:F.target.value})})},{title:"Action",key:"action",width:90,render:(j,M,k)=>e.jsx(s.Popconfirm,{title:"Delete this row?",onConfirm:()=>g(a.dayKey,k),children:e.jsx(s.Button,{danger:!0,type:"text",children:"Delete"})})}],[a.classId,a.dayKey,a.sectionId,g,I,t,C]),N=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:v,value:a.classId?String(a.classId):void 0,onChange:j=>{r(M=>({...M,classId:j,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:y,value:a.sectionId?String(a.sectionId):void 0,onChange:j=>r(M=>({...M,sectionId:j})),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:j=>l(M=>({...M,startTime:j})),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:j=>l(M=>({...M,endTime:j})),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:j=>l(M=>({...M,duration:j})),style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"Interval (min)",children:e.jsx(s.InputNumber,{min:0,value:o.interval,onChange:j=>l(M=>({...M,interval:j})),style:{width:"100%"}})}),e.jsx(s.Form.Item,{label:"Room No",children:e.jsx(s.Input,{value:o.roomNo,onChange:j=>l(M=>({...M,roomNo:j.target.value}))})}),e.jsx(s.Form.Item,{label:"Tiffin Break",children:e.jsxs(s.Space,{children:[e.jsx(s.Switch,{checked:o.tiffinEnabled,onChange:j=>l(M=>({...M,tiffinEnabled:j}))}),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:j=>l(M=>({...M,tiffinAfterPeriod:j})),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:j=>l(M=>({...M,tiffinDuration:j})),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:x,onClick:P,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:j=>r(M=>({...M,dayKey:j})),options:Object.keys(Dn).map(j=>({value:String(j),label:ff(j)}))}),e.jsx(s.Button,{onClick:()=>f(a.dayKey),children:"Add Row"})]}),children:e.jsx(s.Table,{rowKey:(j,M)=>`${a.dayKey}_${M}`,columns:L,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:N},{key:"routine",label:"Routine",children:e.jsx(df,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(mf,{token:t})}]})]})}function gf({token:t}){return e.jsx(hf,{token:t})}function xf(){return null}const Vt=t=>t??localStorage.getItem("authToken")??"",$s=(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},rt={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"}},Ns=t=>$s(tt(),t),bf=()=>$s(tt(),"uploads"),go=t=>$s(bf(),t),Sf=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,Vt(r))},jf=async(t,n)=>Q(t,Vt(n)),Yn=async(t,n,a)=>ze(t,n,Vt(a)),xo=async(t,n,a)=>pt(t,n,Vt(a)),Us=async(t,n,a)=>nt(t,n,Vt(a)),vf=async(t,n,a)=>ka(t,{arg:n},Vt(a)),bo=async(t,n,a)=>On(t,{arg:n},Vt(a)),So=({baseUrl:t,page:n=1,perPage:a=10,token:r})=>G(r&&t?[t,n,a,r]:null,([l,d,c,x])=>Sf({baseUrl:l,page:d,perPage:c},x)),ot=({url:t,token:n})=>G(n&&t?[t,n]:null,([r,o])=>jf(r,o)),_f={border:"1px solid #d9d9d9",borderRadius:8,padding:12,minHeight:320,background:"#fff"};function wf({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:_f,children:e.jsx(Zi,{html:l||"",onChange:d=>{const c=d?.target?.value??"";o(c),n?.(c)},style:{outline:"none",minHeight:280},placeholder:a})})}function Mt({title:t,actions:n,children:a,headerExtra:r}){return e.jsx("div",{style:{display:"grid",gap:20},children:a})}const Cf=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 Bs({token:t,title:n,fetchUrl:a,saveUrl:r,fieldName:o,initialHtmlFieldName:l}){const d=i.useRef(null),c=ot({url:a,token:t}),m=i.useMemo(()=>Cf(c.data),[c.data])?.[l??o]??"",[u,b]=i.useState("");i.useEffect(()=>{b(typeof m=="string"?m:"")},[m]);const v=()=>b(typeof m=="string"?m:""),w=()=>{const h=new Blob([String(u??"")],{type:"text/html"}),R=URL.createObjectURL(h),I=document.createElement("a");I.href=R,I.download=`${String(n??"legal").toLowerCase().replaceAll(" ","-")}.html`,I.click(),URL.revokeObjectURL(R)},p=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:v},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:w,disabled:!u}],[u,m]),y=async h=>{h.preventDefault();try{(await bo(r,{[o]:u??""},t))?.Status==="Success"?_.success("Updated successfully.",{duration:1e3}):_.success("Updated.",{duration:1e3}),c.mutate?.()}catch(R){_.error(R?.response?.data?.msg??R?.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(Mt,{title:n,actions:p,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:y,children:[e.jsx(wf,{value:u,onChange:b,placeholder:`Enter ${n} content...`}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"submit",value:"Update"})})]})})})]})}const Af=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Tf=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:");function an({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]),x=i.useMemo(()=>n?d||(Tf(n)?n:""):"",[d,n]);return e.jsxs("div",{style:{display:"grid",gap:8},children:[x?e.jsx("img",{src:x,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:m=>{if(m?.file?.status==="removed"&&a?.(""),m?.file?.status==="done"){const u=Af(m?.file?.response);u&&a?.(u)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:n?"Change":"Upload"})})]})}const vt=rt.organization,jo=()=>Ns(vt.uploadLogo),ds=()=>Ns(vt.uploadSignature),If=()=>Ns(vt.uploadFirebaseJson),Rf=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:[]:[],Df=({token:t})=>ot({url:vt.get,token:t}),Of=({token:t})=>ot({url:vt.currencyDropdown,token:t}),Pf=({token:t})=>ot({url:vt.countryCodeDropdown,token:t}),kf=({token:t})=>ot({url:vt.timezoneDropdown,token:t}),Ef=({token:t})=>ot({url:vt.boardsDropdown,token:t}),oa=t=>Rf(t?.data),bi={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Mf=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].map(t=>({value:t,label:t})),Si=[{value:"Yes",label:"Yes"},{value:"No",label:"No"}],ji=[{value:"yes",label:"Yes"},{value:"no",label:"No"}],Ff=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},$f=t=>t?.data?.inout_setting?.[0]??t?.inout_setting?.[0]??null,Nf=t=>t?.data?.notification_settings?.[0]??t?.notification_settings?.[0]??null;function Uf({token:t}){const n=i.useRef(null),a=Df({token:t}),r=Of({token:t}),o=Pf({token:t}),l=kf({token:t}),d=Ef({token:t}),c=i.useMemo(()=>Ff(a.data),[a.data]),x=i.useMemo(()=>$f(a.data),[a.data]),m=i.useMemo(()=>Nf(a.data),[a.data]),u=i.useMemo(()=>oa(r),[r.data]),b=i.useMemo(()=>oa(o),[o.data]),v=i.useMemo(()=>oa(l),[l.data]),w=i.useMemo(()=>oa(d),[d.data]),[p,y]=i.useState(null),[h,R]=i.useState(null),[I,D]=i.useState(null),[C,g]=i.useState(null),[f,S]=i.useState([]),[A,P]=i.useState("No"),[L,N]=i.useState("yes"),[j,M]=i.useState("no"),[k,F]=i.useState("Yes"),[E,B]=i.useState(""),[Y,q]=i.useState(""),[O,T]=i.useState(null),[$,U]=i.useState(null),[z,ne]=i.useState(null),[K,V]=i.useState(null),X=()=>{const W=(()=>{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(Pe=>({value:Pe,label:Pe})):[]}catch{return[]}})();S(W),y(u.find(oe=>oe?.value===c?.currency)??null),R(b.find(oe=>oe?.value===c?.country_code)??null),D(v.find(oe=>oe?.value===c?.time_zone)??null),g(w.find(oe=>oe?.value===c?.affliated_board_id)??null),B(c?.logo??""),q(c?.json_file??""),P(c?.attendance_salary_calculation??"No"),N(c?.salary_period??"yes"),M(c?.multiple_shift??"no"),F(c?.readmission_charges??"Yes"),T(x?.in_from?se(x.in_from,"h:mm A"):null),U(x?.in_to?se(x.in_to,"h:mm A"):null),ne(x?.out_from?se(x.out_from,"h:mm A"):null),V(x?.out_to?se(x.out_to,"h:mm A"):null)};i.useEffect(()=>{c&&X()},[c,u,b,v,w]);const ae=()=>{n.current?.reset?.(),X()},ce=()=>{const W=new FormData(n.current??void 0),oe=Object.fromEntries(W.entries());oe.weekly_off_day=f.map(Me=>Me?.value).filter(Boolean);const Ce=new Blob([JSON.stringify(oe,null,2)],{type:"application/json"}),Pe=URL.createObjectURL(Ce),ke=document.createElement("a");ke.href=Pe,ke.download="organization-setting.json",ke.click(),URL.revokeObjectURL(Pe)},je=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(Z.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:ae},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:ce,disabled:!c}],[c,f]),re=async W=>{W.preventDefault();try{const oe=new FormData(W.target);oe.set("currency",p?.value??""),oe.set("code",h?.value??""),oe.set("time_zone",I?.value??""),oe.set("affliated_board_id",C?.value??""),oe.set("board_name",C?.label??""),oe.set("attendance_salary_calculation",A),oe.set("salary_period",L),oe.set("multiple_shift",j),oe.set("readmission_charges",k),f.forEach(ke=>{ke?.value&&oe.append("weekly_off_day[]",ke.value)}),oe.set("logo",E??""),oe.set("json_file",Y??""),oe.set("server_key",m?.server_key??""),oe.set("in_time_start",O?se(O).format("h:mm A"):""),oe.set("in_time_end",$?se($).format("h:mm A"):""),oe.set("out_time_start",z?se(z).format("h:mm A"):""),oe.set("out_time_end",K?se(K).format("h:mm A"):""),await Yn(vt.save,oe,t);const Pe={...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(Pe)),_.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(Mt,{title:"Organization",actions:je,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:bi,children:[e.jsx(J,{type:"text",name:"name",label:"Organization Name*",required:!0,defaultValue:c?.name??""}),e.jsxs("div",{children:[e.jsx(ee,{label:"Currency*",options:u,value:p,onChange:W=>y(W)}),e.jsx("input",{type:"hidden",name:"currency",value:p?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Default Country Code*",options:b,value:h,onChange:W=>R(W)}),e.jsx("input",{type:"hidden",name:"code",value:h?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Time Zone*",options:v,value:I,onChange:W=>D(W)}),e.jsx("input",{type:"hidden",name:"time_zone",value:I?.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:Si,optionType:"button",buttonStyle:"solid",value:k,onChange:W=>F(W.target.value)}),e.jsx("input",{type:"hidden",name:"readmission_charges",value:k})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Weekly off Day",options:Mf,isMulti:!0,value:f,onChange:W=>S(W??[])}),f.map(W=>e.jsx("input",{type:"hidden",name:"weekly_off_day[]",value:W.value},W.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:O,onChange:W=>T(W),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_start",value:O?se(O).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:W=>U(W),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_end",value:$?se($).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:z,onChange:W=>ne(W),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_start",value:z?se(z).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:K,onChange:W=>V(W),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_end",value:K?se(K).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Period"}),e.jsx(s.Radio.Group,{options:ji,optionType:"button",buttonStyle:"solid",value:L,onChange:W=>N(W.target.value)}),e.jsx("input",{type:"hidden",name:"salary_period",value:L})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Deduction"}),e.jsx(s.Radio.Group,{options:Si,optionType:"button",buttonStyle:"solid",value:A,onChange:W=>P(W.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:ji,optionType:"button",buttonStyle:"solid",value:j,onChange:W=>M(W.target.value)}),e.jsx("input",{type:"hidden",name:"multiple_shift",value:j})]}),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:bi,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Logo Upload"}),e.jsx(an,{token:t,action:jo(),value:E,accept:"image/*",onChange:W=>B(W)}),e.jsx("input",{type:"hidden",name:"logo",value:E??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Select Affiliated Board",options:w,value:C,onChange:W=>g(W)}),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(It,{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(an,{token:t,action:If(),value:Y,accept:".json",onChange:W=>q(W)}),e.jsx("input",{type:"hidden",name:"json_file",value:Y??""})]})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"submit",value:"Save",color:"primary"})})]})})})]})}function Bf({token:t}){return e.jsx(Uf,{token:t})}const _a=rt.academicYear,Lf=({token:t,page:n=1,perPage:a=10})=>So({baseUrl:_a.table,token:t,page:n,perPage:a}),qf={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},zf=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 Vf({token:t}){const[n,a]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(()=>{const f=se(),S=se().add(1,"year");return`${f.format("YYYY")}-${S.format("YYYY")}`}),[c,x]=i.useState(se()),[m,u]=i.useState(se().add(1,"year")),{isLoading:b,data:v,mutate:w}=Lf({token:t,page:n.page,perPage:n.rowsPerPage}),p=i.useMemo(()=>zf(v),[v]),y=i.useMemo(()=>Yf(v,p.length),[v,p.length]),h=async()=>{if(!l){_.error("Session name is required.");return}if(m&&c&&se(m).isBefore(c)){_.error("End date must be after start date.");return}try{const f=new FormData;f.set("name",l),f.set("start_date",c?se(c).format("YYYY-MM-DD"):""),f.set("end_date",m?se(m).format("YYYY-MM-DD"):""),await Yn(_a.add,f,t),_.success("Academic year added.",{duration:1e3}),o(!1),w?.()}catch(f){_.error(f?.response?.data?.msg??f?.message??"Failed to add academic year.",{duration:1500})}},R=async f=>{try{const S=new FormData;S.set("session",String(f)),await xo(_a.setActive,S,t);const A=JSON.parse(localStorage.getItem("genrall_settings")??"null")??{};localStorage.setItem("genrall_settings",JSON.stringify({...A,session_id:String(f)})),_.success("Academic year activated.",{duration:1e3}),w?.()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to activate academic year.",{duration:1500})}},I=async f=>{try{await w(Us(_a.remove,f,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 f=new Blob([JSON.stringify(p,null,2)],{type:"application/json"}),S=URL.createObjectURL(f),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:()=>w?.()},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:D,disabled:p.length===0}],[p.length,w]),g=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:(f,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."):R(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:(f,S)=>e.jsx(s.Popconfirm,{title:"Delete academic year?",description:"This will remove the session.",onConfirm:()=>I(S.id),okText:"Yes",cancelText:"No",children:e.jsx(s.Button,{type:"link",danger:!0,children:"Delete"})})}],[t,p.length]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Mt,{title:"Academic Year",actions:C,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:p,columns:g,loading:b,pagination:{current:n.page,pageSize:n.rowsPerPage,total:y,showSizeChanger:!0,onChange:(f,S)=>a({page:f,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:qf,children:[e.jsx(J,{label:"Session Name*",value:l,onChange:f=>d(f.target.value)}),e.jsxs("div",{children:[e.jsx(Aa,{Desplay:"Start Date*",value:c,onChange:f=>x(f),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:c?se(c).format("YYYY-MM-DD"):""})]}),e.jsxs("div",{children:[e.jsx(Aa,{Desplay:"End Date*",value:m,onChange:f=>u(f),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:m?se(m).format("YYYY-MM-DD"):""})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(le,{value:"Submit",type:"button",onClick:h}),e.jsx(s.Button,{onClick:()=>o(!1),children:"Cancel"})]})]})})]})}function Wf({token:t}){return e.jsx(Vf,{token:t})}const vo=rt.feeReceiptSetting,Hf=({token:t})=>ot({url:vo.get,token:t}),cs={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:16,alignItems:"start"},Kf=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 Gf({token:t}){const n=i.useRef(null),a=Hf({token:t}),r=i.useMemo(()=>Kf(a.data),[a.data]),[o,l]=i.useState(""),[d,c]=i.useState(!1),[x,m]=i.useState(!1),[u,b]=i.useState(!1),[v,w]=i.useState("0"),[p,y]=i.useState("0"),[h,R]=i.useState("0"),[I,D]=i.useState(!1),[C,g]=i.useState(!1),[f,S]=i.useState(""),[A,P]=i.useState(!1),L=()=>{l(r?.number_of_receipt??""),c(String(r?.roll_number??"0")==="1"),m(String(r?.address??"0")==="1"),b(String(r?.gardian_name??"0")==="1"),w(String(r?.authorized_signatory??"0")),y(String(r?.parent_signatory??"0")),R(String(r?.dynamic_qr_code_device??"0")),D(String(r?.sequence_payment??"0")==="1"),g(String(r?.previois_fees??"0")==="1"),S(r?.upfront_payment_months??"")};i.useEffect(()=>{r&&L()},[r]);const N=()=>{n.current?.reset?.(),L()},j=()=>{const F={number_of_receipt:o,rollnumber:d?1:0,address:x?1:0,gardianname:u?1:0,authorizedsignatory:v,parentsignatory:p,dynamic_qr_code_device:h,sequence_payment:I?1:0,previois_fees:C?1:0,upfront_payment_months:f},E=new Blob([JSON.stringify(F,null,2)],{type:"application/json"}),B=URL.createObjectURL(E),Y=document.createElement("a");Y.href=B,Y.download="fee-receipt-setting.json",Y.click(),URL.revokeObjectURL(B)},M=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(Z.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:N},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:j,disabled:!r}],[r,o,d,x,u,v,p,h,I,C,f]),k=async F=>{F.preventDefault(),P(!0);try{const E=new FormData;E.set("number_of_receipt",String(o??"")),E.set("rollnumber",d?"1":"0"),E.set("address",x?"1":"0"),E.set("gardianname",u?"1":"0"),E.set("authorizedsignatory",String(v??"0")),E.set("parentsignatory",String(p??"0")),E.set("dynamic_qr_code_device",String(h??"0")),E.set("sequence_payment",I?"1":"0"),E.set("previois_fees",C?"1":"0"),E.set("upfront_payment_months",String(f??"")),await Yn(vo.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{P(!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(Mt,{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:k,children:[e.jsxs("div",{style:cs,children:[e.jsx(J,{type:"number",name:"number_of_receipt",label:"Number Of Receipt",value:o,onChange:F=>l(F.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:F=>c(F.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:x,onChange:F=>m(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(s.Checkbox,{checked:u,onChange:F=>b(F.target.checked),children:"Show Guardian Name in Fees Receipt"})]})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:cs,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:v,onChange:F=>w(F.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:p,onChange:F=>y(F.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:h,onChange:F=>R(F.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:cs,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:I,onChange:F=>D(F.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:C,onChange:F=>g(F.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:f,onChange:F=>S(F.target.value)})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"submit",value:A?"Updating...":"Done",disabled:A})})]})})})]})}function Jf({token:t}){return e.jsx(Gf,{token:t})}const kn=rt.marksheetSetting,Qf=({token:t})=>ot({url:kn.templateTypes,token:t}),Xf=({token:t})=>ot({url:kn.classDropdown,token:t}),Zf=({token:t})=>ot({url:kn.assignedTable,token:t}),ey={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:20,alignItems:"end"},vi=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:[]:[],ty=Array.from({length:12},(t,n)=>({value:String(n+1),label:`Design ${n+1}`})),ny=t=>t?Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t)?t:[]:[];function ay({token:t}){const n=i.useRef(null),a=Qf({token:t}),r=Xf({token:t}),o=Zf({token:t}),l=i.useMemo(()=>vi(a.data),[a.data]),d=i.useMemo(()=>vi(r.data),[r.data]),c=i.useMemo(()=>ny(o.data),[o.data]),[x,m]=i.useState(null),[u,b]=i.useState(null),[v,w]=i.useState([]),p=()=>{n.current?.reset?.(),m(null),b(null),w([])},y=()=>{const C=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),g=URL.createObjectURL(C),f=document.createElement("a");f.href=g,f.download="marksheet-templates.json",f.click(),URL.revokeObjectURL(g)},h=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:p},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:y,disabled:c.length===0}],[c.length]),R=async C=>{if(C.preventDefault(),!x?.value){_.error("Select marksheet type.",{duration:1200});return}if(!u?.value){_.error("Select design.",{duration:1200});return}if(!v?.length){_.error("Select at least one class.",{duration:1200});return}try{const g=new FormData;g.set("temp_id",String(x.value)),g.set("ui_id",String(u.value)),v.forEach(f=>g.append("class_id[]",String(f))),await Yn(kn.assign,g,t),_.success("Marksheet template assigned.",{duration:1e3}),o.mutate?.(),p()}catch(g){_.error(g?.response?.data?.msg??g?.message??"Failed to assign template.",{duration:1500})}},I=async C=>{try{await Us(kn.remove,C,t),_.success("Template removed.",{duration:1e3}),o.mutate?.()}catch(g){_.error(g?.response?.data?.msg??g?.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:(C,g)=>e.jsx(it,{id:g?.id,funcName:I})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Mt,{title:"Marksheet Setting",actions:h,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:R,children:[e.jsxs("div",{style:ey,children:[e.jsxs("div",{children:[e.jsx(ee,{label:"Select Marksheet Type",options:l,value:x,onChange:C=>m(C)}),e.jsx("input",{type:"hidden",name:"temp_id",value:x?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Select Design",options:ty,value:u,onChange:C=>b(C)}),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:v,onChange:C=>w(C)})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{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 sy({token:t}){return e.jsx(ay,{token:t})}const us={fetch:`${rt.legalPages.get}?page_name=terms`,save:rt.legalPages.termsSave,fieldName:"terms_data"};function ry({token:t}){return e.jsx(Bs,{token:t,title:"Terms",fetchUrl:us.fetch,saveUrl:us.save,fieldName:us.fieldName})}function iy({token:t}){return e.jsx(ry,{token:t})}const ps={fetch:`${rt.legalPages.get}?page_name=privacy`,save:rt.legalPages.privacySave,fieldName:"privacy_data"};function oy({token:t}){return e.jsx(Bs,{token:t,title:"Privacy",fetchUrl:ps.fetch,saveUrl:ps.save,fieldName:ps.fieldName})}function ly({token:t}){return e.jsx(oy,{token:t})}const ms={fetch:`${rt.legalPages.get}?page_name=about_us`,save:rt.legalPages.aboutSave,fieldName:"about_data"};function dy({token:t}){return e.jsx(Bs,{token:t,title:"About",fetchUrl:ms.fetch,saveUrl:ms.save,fieldName:ms.fieldName})}function cy({token:t}){return e.jsx(dy,{token:t})}const Ls=rt.feesInfo,uy=({token:t})=>ot({url:Ls.get,token:t}),py=({token:t})=>ot({url:Ls.statesDropdown,token:t}),fs={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},my=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,fy=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[]:[],yy=t=>t?go(`branch/logo/${t}`):"",ys=t=>t?go(`branch/signature/${t}`):"";function hy({token:t}){const n=i.useRef(null),a=uy({token:t}),r=py({token:t}),o=i.useMemo(()=>my(a.data),[a.data]),l=i.useMemo(()=>fy(r.data),[r.data]),[d,c]=i.useState(null),[x,m]=i.useState(""),[u,b]=i.useState(""),[v,w]=i.useState(""),[p,y]=i.useState(""),h=f=>{const S=new FormData(f),A=Object.fromEntries(S.entries());return A.state_id=d?.value??"",A.fees_receipt_logo=x,A.manager_signature=u,A.principal_signature=v,A.stamp=p,A},R=()=>{c(l.find(f=>String(f?.value)===String(o?.state_id??""))??null),m(o?.fees_receipt_logo??""),b(o?.manager_signature??""),w(o?.principal_signature??""),y(o?.stamp??"")};i.useEffect(()=>{o&&R()},[o,l]);const I=()=>{n.current?.reset?.(),R()},D=()=>{const f=h(n.current),S=new Blob([JSON.stringify(f,null,2)],{type:"application/json"}),A=URL.createObjectURL(S),P=document.createElement("a");P.href=A,P.download="fees-info.json",P.click(),URL.revokeObjectURL(A)},C=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(Z.SyncOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:I},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:D,disabled:!o}],[o,d,x,u,v,p]),g=async f=>{f.preventDefault();try{const S=h(f.target);await vf(Ls.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(Mt,{title:"Fees Info",actions:C,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:g,children:[e.jsxs("div",{style:fs,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(ee,{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:fs,children:[e.jsx(It,{name:"Bussiness_address",rows:3,label:"Business Address",defaultValue:o?.Bussiness_address??o?.bussiness_address??""}),e.jsx(It,{name:"note",rows:3,label:"Note",defaultValue:o?.note??""})]}),e.jsx(s.Divider,{}),e.jsxs("div",{style:fs,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Fees Receipt Logo"}),e.jsx(an,{token:t,action:jo(),value:x,previewUrl:yy(x),accept:"image/*",onChange:m}),e.jsx("input",{type:"hidden",name:"fees_receipt_logo",value:x})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Manager Signature"}),e.jsx(an,{token:t,action:ds(),value:u,previewUrl:ys(u),accept:"image/*",onChange:b}),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(an,{token:t,action:ds(),value:v,previewUrl:ys(v),accept:"image/*",onChange:w}),e.jsx("input",{type:"hidden",name:"principal_signature",value:v})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Stamp"}),e.jsx(an,{token:t,action:ds(),value:p,previewUrl:ys(p),accept:"image/*",onChange:y}),e.jsx("input",{type:"hidden",name:"stamp",value:p})]})]}),e.jsx(s.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"submit",value:"Save"})})]})})})]})}function gy({token:t}){return e.jsx(hy,{token:t})}const wa=rt.payrollSettings,xy=({token:t,page:n=1,perPage:a=10})=>So({baseUrl:wa.table,token:t,page:n,perPage:a}),by={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},An=[{value:"Allowances",label:"Allowances"},{value:"Dedection",label:"Dedection"}],hs=[{value:"Flat",label:"Flat"},{value:"Percentage",label:"Percentage"}],Sy=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],jy=(t,n=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??n;function vy({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,x]=i.useState(null),[m,u]=i.useState(An[0]),[b,v]=i.useState(null),[w,p]=i.useState(null),[y,h]=i.useState(null),R=xy({token:t,page:r.page,perPage:r.rowsPerPage}),I=i.useMemo(()=>Sy(R.data),[R.data]),D=i.useMemo(()=>jy(R.data,I.length),[R.data,I.length]),C=async N=>{N.preventDefault();try{const j=new FormData(N.target);j.set("type",m?.value??""),j.set("amount_type",b?.value??""),await Yn(wa.add,j,t),_.success("Payroll setting added.",{duration:1e3}),R.mutate?.(),N.target.reset(),v(null),u(An[0])}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to add payroll setting.",{duration:1500})}},g=N=>{x(N),p(An.find(j=>j.value===N?.type)??null),h(hs.find(j=>j.value===N?.amount_type)??null),d(!0)},f=async N=>{N.preventDefault();try{const j=new FormData(N.target);j.set("id",String(c?.id??"")),j.set("type",w?.value??""),j.set("amount_type",y?.value??""),await xo(wa.edit,j,t),_.success("Payroll setting updated.",{duration:1e3}),d(!1),R.mutate?.()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to update payroll setting.",{duration:1500})}},S=async N=>{try{await Us(wa.remove,N,t),_.success("Payroll setting deleted.",{duration:1e3}),R.mutate?.()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to delete payroll setting.",{duration:1500})}},A=()=>{const N=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),j=URL.createObjectURL(N),M=document.createElement("a");M.href=j,M.download="payroll-settings.json",M.click(),URL.revokeObjectURL(j)},P=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(Z.PlusOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(Z.ReloadOutlined,{}),onClick:()=>R.mutate?.()},{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"export",label:"Export",icon:e.jsx(Z.ExportOutlined,{}),onClick:A,disabled:I.length===0}],[I.length]),L=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title"},{title:"Type",dataIndex:"type",key:"type"},{title:"Amount Type",dataIndex:"amount_type",key:"amount_type"},{title:"Amount",dataIndex:"Amount",key:"Amount"},{title:"Action",key:"action",render:(N,j)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(s.Button,{type:"text",icon:e.jsx(Z.EditOutlined,{}),onClick:()=>g(j)}),e.jsx(s.Popconfirm,{title:"Delete payroll setting?",onConfirm:()=>S(j.id),children:e.jsx(s.Button,{type:"text",danger:!0,icon:e.jsx(Z.DeleteOutlined,{})})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Mt,{title:"Payroll Settings",actions:P,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:C,children:[e.jsxs("div",{style:by,children:[e.jsx(J,{name:"title",label:"Title",required:!0}),e.jsxs("div",{children:[e.jsx(ee,{label:"Type",options:An,value:m,onChange:u}),e.jsx("input",{type:"hidden",name:"type",value:m?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Amount Type",options:hs,value:b,onChange:v}),e.jsx("input",{type:"hidden",name:"amount_type",value:b?.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(le,{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:L,dataSource:I,loading:R.isLoading,pagination:{current:r.page,pageSize:r.rowsPerPage,total:D,showSizeChanger:!0,onChange:(N,j)=>o({page:N,rowsPerPage:Number(j)})}})})]})}),e.jsx(s.Drawer,{open:l,onClose:()=>d(!1),title:"Edit Payroll Setting",width:420,children:e.jsx("form",{ref:a,onSubmit:f,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(ee,{label:"Type",options:An,value:w,onChange:p}),e.jsx("input",{type:"hidden",name:"type",value:w?.value??""})]}),e.jsxs("div",{children:[e.jsx(ee,{label:"Amount Type",options:hs,value:y,onChange:h}),e.jsx("input",{type:"hidden",name:"amount_type",value:y?.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(le,{type:"submit",value:"Update"})})]})})})]})}function _y({token:t}){return e.jsx(vy,{token:t})}const _o=rt.paymentGateway,wy=({token:t})=>ot({url:_o.get,token:t}),Cy=[{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"]}],Ut={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}},_i=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 Ut;try{const a=JSON.parse(n.data||"{}"),r=a?.data&&typeof a.data=="object"?a.data:a;return{Razorpay:{...Ut.Razorpay,...r?.Razorpay??{}},PhonePe:{...Ut.PhonePe,...r?.PhonePe??r?.PineLab??r?.PineLabs??{}},Paytm:{...Ut.Paytm,...r?.Paytm??r?.HDFC??{}},SabPaisa:{...Ut.SabPaisa,...r?.SabPaisa??{}}}}catch{return Ut}};function Ay({token:t}){const n=i.useRef(null),a=wy({token:t}),[r,o]=i.useState(Ut);i.useEffect(()=>{a.data&&o(_i(a.data))},[a.data]);const l=(u,b,v)=>{o(w=>({...w,[u]:{...w[u],[b]:v}}))},d=()=>o(_i(a.data)),c=()=>{const u=new Blob([JSON.stringify(r,null,2)],{type:"application/json"}),b=URL.createObjectURL(u),v=document.createElement("a");v.href=b,v.download="payment-gateway-settings.json",v.click(),URL.revokeObjectURL(b)},x=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(Z.SaveOutlined,{}),onClick:()=>n.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(Z.SyncOutlined,{}),onClick:()=>n.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,a.data]),m=async u=>{u.preventDefault();try{await bo(_o.save,{data:r},t),_.success("Payment gateway settings saved.",{duration:1e3}),a.mutate?.()}catch(b){_.error(b?.response?.data?.msg??b?.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(Mt,{title:"Payment Gateway",actions:x,children:e.jsxs("form",{ref:n,onSubmit:m,style:{display:"grid",gap:20},children:[Cy.map(u=>{const b=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:!!b.isActive,onChange:v=>l(u.id,"isActive",v)})]}),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(v=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:v}),e.jsx(s.Input,{value:b[v]??"",type:v.toLowerCase().includes("secret")||v.toLowerCase().includes("password")?"password":"text",onChange:w=>l(u.id,v,w.target.value)})]},v))})]})},u.id)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(le,{type:"submit",value:"Save"})})]})})]})}function Ty({token:t}){return e.jsx(Ay,{token:t})}const Iy=({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(fe,{children:e.jsx(Ai,{icon:a?.icon??"",title:a?.title??"",path:a?.path??"",onClick:n})})},`${r}route001`))});exports.About=cy;exports.AcademicYear=Wf;exports.Academics=nm;exports.AddBook=sc;exports.AddDriver=Zd;exports.AddStaff=_u;exports.AdmissionEnquiry=Od;exports.ApplyLeave=op;exports.AprroveLeaveRequest=ep;exports.AssignByClass=Rm;exports.AssignStudentToTransport=Xd;exports.AssignSubjects=Am;exports.AssignTimeGroup=$m;exports.AssignVehicles=Bd;exports.AttendanceDashboard=zp;exports.BookList=rc;exports.BuySellProduct=zc;exports.Category=Pc;exports.Class=fm;exports.CoScholasticArea=Vm;exports.CreateTimeGroup=Pm;exports.DailyAttendance=Kp;exports.Department=mp;exports.Designation=hp;exports.ErpDashboard=Ao;exports.FeeReceiptSetting=Jf;exports.FeesInfo=gy;exports.GeneralSetting=xf;exports.Holidays=vm;exports.IssueReturn=oc;exports.LeaveType=cp;exports.LibraryAssignStudent=lc;exports.LibraryCategory=dc;exports.LibraryReport=cc;exports.ManageStock=nu;exports.MarksheetSetting=sy;exports.MenuSubmenu=pd;exports.MonthlyReport=Qp;exports.Notes=Jm;exports.Organization=Bf;exports.PaymentGateway=Ty;exports.Payroll=Gu;exports.PayrollReceiptDetails=Tp;exports.PayrollSettings=_y;exports.Privacy=ly;exports.Products=Ic;exports.PromoteStudents=Lm;exports.RoutePage=Iy;exports.RouteTimeTable=ec;exports.Sections=dm;exports.SellReports=Zc;exports.Shift=bp;exports.StaffAttendance=Bu;exports.StaffAttendanceReport=Yu;exports.StaffDailyAttendance=wp;exports.StaffDirectory=Iu;exports.StockReport=ou;exports.Stoppage=nc;exports.StudentAttendance=Vp;exports.SubCategory=Nc;exports.Subjects=xm;exports.Syllabus=rf;exports.Terms=iy;exports.TimeTable=gf;exports.TransferCertificate=tf;exports.TransportRoutes=kd;exports.TransportVehicles=Ed;exports.Unit=Hc;exports.Vendor=xc;exports.YearlyReport=tm;exports.setBaseUrl=dd;