@tachybase/module-hera 1.9.22 → 1.9.35

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 (118) hide show
  1. package/dist/client/index.js +15 -26
  2. package/dist/externalVersion.js +8 -10
  3. package/dist/node_modules/fs-extra/package.json +1 -1
  4. package/dist/server/actions/index.d.ts +0 -2
  5. package/dist/server/actions/index.js +1 -5
  6. package/dist/server/migrations/20250102010713-add-plugin-department.d.ts +6 -0
  7. package/dist/server/{middlewares/set-department-owners.js → migrations/20250102010713-add-plugin-department.js} +22 -41
  8. package/dist/server/plugin.js +0 -2
  9. package/package.json +14 -14
  10. package/dist/client/features/departments/common/DepartmentTable.schema.d.ts +0 -50
  11. package/dist/client/features/departments/common/DepartmentTable.view.d.ts +0 -4
  12. package/dist/client/features/departments/common/FilterKeys.context.d.ts +0 -10
  13. package/dist/client/features/departments/common/InternalDepartmentTable.d.ts +0 -5
  14. package/dist/client/features/departments/common/Request.povider.d.ts +0 -1
  15. package/dist/client/features/departments/common/UserDepartmentsFieldNotSupport.d.ts +0 -2
  16. package/dist/client/features/departments/common/scopes/useDepartmentFilterActionProps.d.ts +0 -5
  17. package/dist/client/features/departments/common/scopes/useFilterActionProps.d.ts +0 -5
  18. package/dist/client/features/departments/index.d.ts +0 -5
  19. package/dist/client/features/departments/main-tab/DepartmentIndex.d.ts +0 -5
  20. package/dist/client/features/departments/main-tab/DepartmentIndex.provider.d.ts +0 -3
  21. package/dist/client/features/departments/main-tab/DepartmentManagement.component.d.ts +0 -1
  22. package/dist/client/features/departments/main-tab/DepartmentManagement.schema.d.ts +0 -10
  23. package/dist/client/features/departments/main-tab/DepartmentManagement.view.d.ts +0 -1
  24. package/dist/client/features/departments/main-tab/collections/departments.collection.d.ts +0 -128
  25. package/dist/client/features/departments/main-tab/collections/users.collection.d.ts +0 -189
  26. package/dist/client/features/departments/main-tab/components/DepartmentSelect.d.ts +0 -1
  27. package/dist/client/features/departments/main-tab/components/InternalSuperiorDepartmentSelect.d.ts +0 -1
  28. package/dist/client/features/departments/main-tab/components/SuperiorDepartmentSelect.d.ts +0 -1
  29. package/dist/client/features/departments/main-tab/context/Department.context.d.ts +0 -23
  30. package/dist/client/features/departments/main-tab/context/DepartmentsExpanded.context.d.ts +0 -17
  31. package/dist/client/features/departments/main-tab/departments-block/AddNewDepartment.schema.d.ts +0 -67
  32. package/dist/client/features/departments/main-tab/departments-block/AddNewDepartment.view.d.ts +0 -1
  33. package/dist/client/features/departments/main-tab/departments-block/DepartmentOwnersField.component.d.ts +0 -5
  34. package/dist/client/features/departments/main-tab/departments-block/DepartmentsBlock.d.ts +0 -1
  35. package/dist/client/features/departments/main-tab/departments-block/DepartmentsSearch.component.d.ts +0 -1
  36. package/dist/client/features/departments/main-tab/departments-block/DepartmentsTree.component.d.ts +0 -8
  37. package/dist/client/features/departments/main-tab/departments-block/Request.provider.d.ts +0 -1
  38. package/dist/client/features/departments/main-tab/departments-block/UnknownOwerns.schema.d.ts +0 -136
  39. package/dist/client/features/departments/main-tab/departments-block/UnknownOwerns.view.d.ts +0 -1
  40. package/dist/client/features/departments/main-tab/departments-block/schemas/schemaDepartmentEdit.d.ts +0 -62
  41. package/dist/client/features/departments/main-tab/departments-block/schemas/schemaDepartmentNewSub.d.ts +0 -57
  42. package/dist/client/features/departments/main-tab/departments-block/scopes/useCreateDepartment.d.ts +0 -3
  43. package/dist/client/features/departments/main-tab/departments-block/scopes/useUpdateDepartment.d.ts +0 -3
  44. package/dist/client/features/departments/main-tab/departments-users-block/AddMembers.schema.d.ts +0 -148
  45. package/dist/client/features/departments/main-tab/departments-users-block/AddMembers.view.d.ts +0 -1
  46. package/dist/client/features/departments/main-tab/departments-users-block/DepartmentField.component.d.ts +0 -1
  47. package/dist/client/features/departments/main-tab/departments-users-block/DepartmentsUsersBlock.d.ts +0 -1
  48. package/dist/client/features/departments/main-tab/departments-users-block/DepartmentsUsersBlock.schema.d.ts +0 -676
  49. package/dist/client/features/departments/main-tab/departments-users-block/IsOwnerField.component.d.ts +0 -1
  50. package/dist/client/features/departments/main-tab/departments-users-block/MemberActions.schema.d.ts +0 -49
  51. package/dist/client/features/departments/main-tab/departments-users-block/MemberActions.view.d.ts +0 -1
  52. package/dist/client/features/departments/main-tab/departments-users-block/RowRemoveAction.schema.d.ts +0 -16
  53. package/dist/client/features/departments/main-tab/departments-users-block/RowRemoveAction.view.d.ts +0 -1
  54. package/dist/client/features/departments/main-tab/departments-users-block/UserDepartmentsField.component.d.ts +0 -1
  55. package/dist/client/features/departments/main-tab/departments-users-block/UserSelectDepartment.schema.d.ts +0 -42
  56. package/dist/client/features/departments/main-tab/departments-users-block/UserSelectDepartment.view.d.ts +0 -1
  57. package/dist/client/features/departments/main-tab/departments-users-block/scopes/useBulkRemoveMembersAction.d.ts +0 -3
  58. package/dist/client/features/departments/main-tab/departments-users-block/scopes/useDataSource.d.ts +0 -40
  59. package/dist/client/features/departments/main-tab/departments-users-block/scopes/useMembersDataSource.d.ts +0 -6
  60. package/dist/client/features/departments/main-tab/departments-users-block/scopes/usePropsAddMember.d.ts +0 -1
  61. package/dist/client/features/departments/main-tab/departments-users-block/scopes/useRefreshActionProps.d.ts +0 -3
  62. package/dist/client/features/departments/main-tab/departments-users-block/scopes/useRemoveMemberAction.d.ts +0 -3
  63. package/dist/client/features/departments/main-tab/departments-users-block/scopes/useShowTotal.d.ts +0 -1
  64. package/dist/client/features/departments/main-tab/hooks/useDeepTree.d.ts +0 -14
  65. package/dist/client/features/departments/main-tab/hooks/useGetDepTree.d.ts +0 -18
  66. package/dist/client/features/departments/main-tab/kit.d.ts +0 -4
  67. package/dist/client/features/departments/main-tab/providers/DepartmentsResource.provider.d.ts +0 -3
  68. package/dist/client/features/departments/main-tab/providers/UserResource.provider.d.ts +0 -3
  69. package/dist/client/features/departments/role-auth/DepartmentTitle.component.d.ts +0 -1
  70. package/dist/client/features/departments/role-auth/Departments.d.ts +0 -1
  71. package/dist/client/features/departments/role-auth/Departments.schema.d.ts +0 -227
  72. package/dist/client/features/departments/role-auth/kit.d.ts +0 -4
  73. package/dist/client/features/departments/role-auth/scopes/useAddDepartments.d.ts +0 -3
  74. package/dist/client/features/departments/role-auth/scopes/useBulkRemoveDepartments.d.ts +0 -3
  75. package/dist/client/features/departments/role-auth/scopes/useDataSource.d.ts +0 -40
  76. package/dist/client/features/departments/role-auth/scopes/useDisabled.d.ts +0 -3
  77. package/dist/client/features/departments/role-auth/scopes/useRemoveDepartment.d.ts +0 -3
  78. package/dist/client/features/departments/settings/DepartmentOwnersFieldSetting.d.ts +0 -2
  79. package/dist/client/features/departments/settings/UserDepartmentsFieldSetting.d.ts +0 -2
  80. package/dist/client/features/departments/settings/UserMainDepartmentFieldSetting.d.ts +0 -2
  81. package/dist/client/features/departments/settings/items/enableLinkItem.d.ts +0 -2
  82. package/dist/client/features/departments/settings/items/modeSelectItem.d.ts +0 -2
  83. package/dist/client/features/departments/settings/items/titleFieldItem.d.ts +0 -2
  84. package/dist/client/features/departments/utils/getDepartmentStr.d.ts +0 -1
  85. package/dist/client/features/departments/utils/getUserListByDepartment.d.ts +0 -1
  86. package/dist/server/actions/departments.d.ts +0 -5
  87. package/dist/server/actions/departments.js +0 -105
  88. package/dist/server/actions/users.d.ts +0 -4
  89. package/dist/server/actions/users.js +0 -142
  90. package/dist/server/collections/departmentRoles.d.ts +0 -2
  91. package/dist/server/collections/departmentRoles.js +0 -27
  92. package/dist/server/collections/departments.d.ts +0 -29
  93. package/dist/server/collections/departments.js +0 -162
  94. package/dist/server/collections/departmentsUsers.d.ts +0 -2
  95. package/dist/server/collections/departmentsUsers.js +0 -43
  96. package/dist/server/collections/roles.d.ts +0 -2
  97. package/dist/server/collections/roles.js +0 -39
  98. package/dist/server/collections/users.d.ts +0 -55
  99. package/dist/server/collections/users.js +0 -87
  100. package/dist/server/features/departments.d.ts +0 -7
  101. package/dist/server/features/departments.js +0 -132
  102. package/dist/server/middlewares/destroy-department-check.d.ts +0 -2
  103. package/dist/server/middlewares/destroy-department-check.js +0 -53
  104. package/dist/server/middlewares/index.d.ts +0 -6
  105. package/dist/server/middlewares/index.js +0 -31
  106. package/dist/server/middlewares/list-users-include-child-department.d.ts +0 -2
  107. package/dist/server/middlewares/list-users-include-child-department.js +0 -77
  108. package/dist/server/middlewares/reset-user-departments-cache.d.ts +0 -2
  109. package/dist/server/middlewares/reset-user-departments-cache.js +0 -39
  110. package/dist/server/middlewares/set-department-owners.d.ts +0 -2
  111. package/dist/server/middlewares/set-departments-roles.d.ts +0 -2
  112. package/dist/server/middlewares/set-departments-roles.js +0 -64
  113. package/dist/server/middlewares/set-main-department.d.ts +0 -2
  114. package/dist/server/middlewares/set-main-department.js +0 -105
  115. package/dist/server/middlewares/update-department-isleaf.d.ts +0 -2
  116. package/dist/server/middlewares/update-department-isleaf.js +0 -84
  117. package/dist/server/models/department.d.ts +0 -4
  118. package/dist/server/models/department.js +0 -38
@@ -1,25 +1,25 @@
1
1
  (function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.id="@tachybase/module-hera",e.appendChild(document.createTextNode('body{margin:0}.x-spreadsheet{-webkit-user-select:none;user-select:none;box-sizing:content-box;-webkit-font-smoothing:antialiased;background:#fff;font-family:Lato,Source Sans Pro,Roboto,Helvetica,Arial,sans-serif;font-size:13px;line-height:normal}.x-spreadsheet textarea{font:400 13px Arial,Lato,Source Sans Pro,Roboto,Helvetica,sans-serif}.x-spreadsheet-sheet{position:relative;overflow:hidden}.x-spreadsheet-table{vertical-align:bottom}.x-spreadsheet-tooltip{color:#fff;z-index:201;background:#000;border-radius:1px;padding:5px 10px;font-family:inherit;font-size:12px;position:absolute}.x-spreadsheet-tooltip:before{pointer-events:none;content:"";background:inherit;z-index:1;width:8px;height:8px;position:absolute;top:-4px;left:calc(50% - 4px);transform:rotate(45deg);box-shadow:1px 1px 3px -1px #0000004d}.x-spreadsheet-color-palette{padding:5px}.x-spreadsheet-color-palette table{border-collapse:separate;border-spacing:2px;background:#fff;margin:0;padding:0}.x-spreadsheet-color-palette table td{cursor:pointer;border:1px solid #0000;margin:0}.x-spreadsheet-color-palette table td:hover{border-color:#ddd}.x-spreadsheet-color-palette table td .x-spreadsheet-color-palette-cell{width:16px;height:16px}.x-spreadsheet-border-palette{padding:6px}.x-spreadsheet-border-palette table{border-collapse:separate;border-spacing:0;table-layout:fixed;background:#fff;margin:0;padding:0}.x-spreadsheet-border-palette table td{margin:0}.x-spreadsheet-border-palette .x-spreadsheet-border-palette-left{border-right:1px solid #eee;padding-right:6px}.x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell{cursor:pointer;text-align:center;width:30px;height:30px}.x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell .x-spreadsheet-icon-img{opacity:.8}.x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell:hover{background-color:#eee}.x-spreadsheet-border-palette .x-spreadsheet-border-palette-right{padding-left:6px}.x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-toolbar-btn{margin-top:0;margin-bottom:3px}.x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-line-type{position:relative;top:-3px;left:0}.x-spreadsheet-dropdown{position:relative}.x-spreadsheet-dropdown .x-spreadsheet-dropdown-content{z-index:200;background:#fff;position:absolute;box-shadow:1px 2px 5px 2px #33333326}.x-spreadsheet-dropdown.bottom-left .x-spreadsheet-dropdown-content{top:calc(100% + 5px);left:0}.x-spreadsheet-dropdown.bottom-right .x-spreadsheet-dropdown-content{top:calc(100% + 5px);right:0}.x-spreadsheet-dropdown.top-left .x-spreadsheet-dropdown-content{bottom:calc(100% + 5px);left:0}.x-spreadsheet-dropdown.top-right .x-spreadsheet-dropdown-content{bottom:calc(100% + 5px);right:0}.x-spreadsheet-dropdown .x-spreadsheet-dropdown-title{padding:0 5px;display:inline-block}.x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-left{margin-left:4px}.x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-right{width:10px;margin-right:4px}.x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-right .arrow-down{left:-130px}.x-spreadsheet-resizer{z-index:11;position:absolute}.x-spreadsheet-resizer .x-spreadsheet-resizer-hover{background-color:#4b89ff40}.x-spreadsheet-resizer .x-spreadsheet-resizer-line{position:absolute}.x-spreadsheet-resizer.horizontal{cursor:row-resize}.x-spreadsheet-resizer.horizontal .x-spreadsheet-resizer-line{border-bottom:2px dashed #4b89ff;bottom:0;left:0}.x-spreadsheet-resizer.vertical{cursor:col-resize}.x-spreadsheet-resizer.vertical .x-spreadsheet-resizer-line{border-right:2px dashed #4b89ff;top:0;right:0}.x-spreadsheet-scrollbar{opacity:.9;z-index:12;background-color:#f4f5f8;position:absolute;bottom:0;right:0}.x-spreadsheet-scrollbar.horizontal{right:15px;overflow:scroll hidden}.x-spreadsheet-scrollbar.horizontal>div{background:#ddd;height:1px}.x-spreadsheet-scrollbar.vertical{bottom:15px;overflow:hidden scroll}.x-spreadsheet-scrollbar.vertical>div{background:#ddd;width:1px}.x-spreadsheet-overlayer{z-index:10;position:absolute;top:0;left:0}.x-spreadsheet-overlayer .x-spreadsheet-overlayer-content{pointer-events:none;width:100%;height:100%;position:absolute;overflow:hidden}.x-spreadsheet-editor,.x-spreadsheet-selector{box-sizing:content-box;pointer-events:none;width:100%;height:100%;position:absolute;top:0;left:0;overflow:hidden}.x-spreadsheet-selector .hide-input{z-index:0;position:absolute}.x-spreadsheet-selector .hide-input input{width:0;padding:0;border:none!important}.x-spreadsheet-selector .x-spreadsheet-selector-area{z-index:5;background:#4b89ff1a;border:2px solid #4b89ff;position:absolute}.x-spreadsheet-selector .x-spreadsheet-selector-clipboard,.x-spreadsheet-selector .x-spreadsheet-selector-autofill{z-index:100;background:none;position:absolute}.x-spreadsheet-selector .x-spreadsheet-selector-clipboard{border:2px dashed #4b89ff}.x-spreadsheet-selector .x-spreadsheet-selector-autofill{border:1px dashed #00000073}.x-spreadsheet-selector .x-spreadsheet-selector-corner{pointer-events:auto;cursor:crosshair;background:#4b89ff;border:2px solid #fff;width:5px;height:5px;font-size:0;position:absolute;bottom:-5px;right:-5px}.x-spreadsheet-editor{z-index:20}.x-spreadsheet-editor .x-spreadsheet-editor-area{text-align:left;z-index:100;pointer-events:auto;border:2px solid #4b89ff;line-height:0;position:absolute}.x-spreadsheet-editor .x-spreadsheet-editor-area textarea{box-sizing:content-box;resize:none;text-align:start;color:inherit;white-space:normal;word-wrap:break-word;border:none;outline:none;margin:0;padding:0 3px;font:400 13px/22px Arial,Lato,Source Sans Pro,Roboto,Helvetica,sans-serif;overflow-y:hidden}.x-spreadsheet-editor .x-spreadsheet-editor-area .textline{visibility:hidden;position:fixed;top:0;left:0;overflow:hidden}.x-spreadsheet-item{-webkit-user-select:none;user-select:none;color:#000000e6;cursor:default;text-align:left;background:0;border:1px solid #0000;outline:none;height:26px;padding:2px 10px;line-height:26px;list-style:none;overflow:hidden}.x-spreadsheet-item.disabled{pointer-events:none;opacity:.5}.x-spreadsheet-item:hover,.x-spreadsheet-item.active{background:#0000000d}.x-spreadsheet-item.divider{border:none;border-bottom:1px solid #0000001a;height:0;margin:5px 0;padding:0}.x-spreadsheet-item .label{float:right;opacity:.65;font-size:1em}.x-spreadsheet-item.state,.x-spreadsheet-header.state{position:relative;padding-left:35px!important}.x-spreadsheet-item.state:before,.x-spreadsheet-header.state:before{content:"";background:#00000014;border-radius:2px;width:10px;height:10px;position:absolute;top:calc(50% - 5px);left:12px}.x-spreadsheet-item.state.checked:before,.x-spreadsheet-header.state.checked:before{background:#4b89ff}.x-spreadsheet-checkbox{backface-visibility:hidden;vertical-align:baseline;outline:0;font-size:1rem;font-style:normal;line-height:1em;display:inline-block;position:relative}.x-spreadsheet-checkbox>input{z-index:-1;outline:0;position:absolute;top:0;left:0;opacity:0!important}.x-spreadsheet-suggest,.x-spreadsheet-contextmenu,.x-spreadsheet-sort-filter{z-index:100;pointer-events:auto;background:#fff;width:260px;position:absolute;overflow:auto;box-shadow:1px 2px 5px 2px #33333326}.x-spreadsheet-suggest{width:200px}.x-spreadsheet-filter{border:1px solid #e9e9e9;margin:10px;font-size:12px}.x-spreadsheet-filter .x-spreadsheet-header{background:#f8f8f9;border-bottom:1px solid #e9e9e9;border-left:1px solid #0000;padding:.5em .75em}.x-spreadsheet-filter .x-spreadsheet-body{height:200px;overflow-y:auto}.x-spreadsheet-filter .x-spreadsheet-body .x-spreadsheet-item{height:20px;line-height:20px}.x-spreadsheet-sort-filter .x-spreadsheet-buttons{margin:10px}.x-spreadsheet-toolbar,.x-spreadsheet-bottombar{text-align:left;background:#f5f6f7;height:40px;padding:0 30px;display:flex}.x-spreadsheet-bottombar{border-top:1px solid #e0e2e4;position:relative}.x-spreadsheet-bottombar .x-spreadsheet-menu>li{vertical-align:middle;border-right:1px solid #e8eaed;height:40px;padding-top:0;padding-bottom:0;line-height:40px}.x-spreadsheet-menu{-webkit-user-select:none;user-select:none;margin:0;padding:0;list-style:none}.x-spreadsheet-menu>li{float:left;vertical-align:middle;text-align:left;color:#80868b;white-space:nowrap;cursor:pointer;margin:0;padding:.785em 1em;font-weight:700;line-height:1.25em;transition:all .3s}.x-spreadsheet-menu>li.active{color:#000000a6;background-color:#fff}.x-spreadsheet-menu>li .x-spreadsheet-icon{margin:0 6px}.x-spreadsheet-menu>li .x-spreadsheet-icon .x-spreadsheet-icon-img:hover{opacity:.85}.x-spreadsheet-menu>li .x-spreadsheet-dropdown{display:inline-block}.x-spreadsheet-toolbar{border-bottom:1px solid #e0e2e4}.x-spreadsheet-toolbar .x-spreadsheet-toolbar-btns{display:inline-flex}.x-spreadsheet-toolbar .x-spreadsheet-toolbar-more{text-align:left;padding:0 6px 6px}.x-spreadsheet-toolbar .x-spreadsheet-toolbar-more .x-spreadsheet-toolbar-divider{margin-top:0}.x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn{text-align:center;border:1px solid #0000;border-radius:2px;flex:none;min-width:26px;height:26px;margin:6px 1px 0;padding:0;line-height:26px;display:inline-block}.x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn.disabled{pointer-events:none;opacity:.5}.x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn:hover,.x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn.active{background:#00000014}.x-spreadsheet-toolbar-divider{vertical-align:middle;border-right:1px solid #e0e2e4;width:0;height:18px;margin:12px 3px 0;display:inline-block}.x-spreadsheet-print{z-index:100;flex-direction:column;width:100%;height:100%;display:flex;position:absolute;top:0;left:0}.x-spreadsheet-print-bar{background:#424242;height:60px;padding:0 30px;line-height:60px}.x-spreadsheet-print-bar .-title{color:#fff;float:left;font-size:1.2em;font-weight:700}.x-spreadsheet-print-bar .-right{float:right;margin-top:12px}.x-spreadsheet-print-content{background:#d0d0d0;flex-direction:row;flex:auto;height:calc(100% - 60px);display:flex}.x-spreadsheet-print-content .-sider{background:#fff;border-left:2px solid #ccc;flex:0 0 300px;width:300px}.x-spreadsheet-print-content .-content{flex:auto;height:100%;overflow:auto scroll}.x-spreadsheet-canvas-card-wraper{margin:40px 20px}.x-spreadsheet-canvas-card{page-break-before:auto;page-break-after:always;background:#fff;margin:auto;box-shadow:0 8px 10px 1px #00000024,0 3px 14px 3px #0000001f,0 4px 5px #0003}.x-spreadsheet-calendar{color:#000000a6;-webkit-user-select:none;user-select:none;background:#fff}.x-spreadsheet-calendar .calendar-header{text-align:center;float:left;background:#f9fafb;width:100%;font-weight:700;line-height:30px}.x-spreadsheet-calendar .calendar-header .calendar-header-left{float:left;padding-left:5px}.x-spreadsheet-calendar .calendar-header .calendar-header-right{float:right}.x-spreadsheet-calendar .calendar-header .calendar-header-right a{border-radius:2px;margin-right:2px;padding:3px 0}.x-spreadsheet-calendar .calendar-header .calendar-header-right a:hover{background:#00000014}.x-spreadsheet-calendar .calendar-body{border-collapse:collapse;border-spacing:0}.x-spreadsheet-calendar .calendar-body th,.x-spreadsheet-calendar .calendar-body td{width:100% / 7;text-align:center;min-width:32px;padding:0;font-weight:700;line-height:30px}.x-spreadsheet-calendar .calendar-body td>.cell:hover{background:#ecf6fd}.x-spreadsheet-calendar .calendar-body td>.cell.active,.x-spreadsheet-calendar .calendar-body td>.cell.active:hover{color:#2185d0;background:#ecf6fd}.x-spreadsheet-calendar .calendar-body td>.cell.disabled{pointer-events:none;opacity:.5}.x-spreadsheet-datepicker{z-index:10;width:auto;position:absolute;top:calc(100% + 5px);left:0;box-shadow:2px 2px 5px #0003}.x-spreadsheet-buttons{justify-content:flex-end;display:flex}.x-spreadsheet-buttons .x-spreadsheet-button{margin-left:8px}.x-spreadsheet-button{white-space:nowrap;text-align:center;cursor:pointer;color:#0009;vertical-align:baseline;zoom:1;-webkit-user-select:none;user-select:none;background:#e0e1e2;border-radius:3px;outline:none;min-height:1em;padding:.75em 1em;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;font-size:1em;font-weight:700;line-height:1em;text-decoration:none;transition:all .1s linear;display:inline-block}.x-spreadsheet-button.active,.x-spreadsheet-button:hover{color:#000c;background-color:#c0c1c2}.x-spreadsheet-button.primary{color:#fff;background-color:#2185d0}.x-spreadsheet-button.primary:hover,.x-spreadsheet-button.primary.active{color:#fff;background-color:#1678c2}.x-spreadsheet-form-input{color:#000000de;font-size:1em;font-weight:400;display:inline-flex;position:relative}.x-spreadsheet-form-input input{z-index:1;-webkit-tap-highlight-color:#fff0;text-align:left;background:#fff;border:1px solid #e9e9e9;border-radius:3px;outline:0;flex:1 0 auto;max-width:100%;height:30px;margin:0;padding:0 8px;line-height:30px;transition:box-shadow .1s,border-color .1s;box-shadow:inset 0 1px 2px #0a0a0a0f}.x-spreadsheet-form-input input:focus{border-color:#4b89ff;box-shadow:inset 0 1px 2px #4b89ff33}.x-spreadsheet-form-select{cursor:pointer;color:#000000de;-webkit-user-select:none;user-select:none;background:#fff;border:1px solid #e9e9e9;border-radius:2px;display:inline-block;position:relative;box-shadow:inset 0 1px 2px #0a0a0a0f}.x-spreadsheet-form-select .input-text{text-overflow:ellipsis;white-space:nowrap;width:auto;min-width:60px;height:30px;padding:0 8px;line-height:30px}.x-spreadsheet-form-fields{flex-flow:wrap;display:flex}.x-spreadsheet-form-fields .x-spreadsheet-form-field{flex:0 auto}.x-spreadsheet-form-fields .x-spreadsheet-form-field .label{margin:0 10px 0 0;display:inline-block}.x-spreadsheet-form-field{vertical-align:middle;margin-bottom:10px;margin-left:10px;display:block}.x-spreadsheet-form-field:first-child{margin-left:0}.x-spreadsheet-form-field.error .x-spreadsheet-form-select,.x-spreadsheet-form-field.error input{border-color:#f04134}.x-spreadsheet-form-field .tip{color:#f04134;font-size:.9em}.x-spreadsheet-dimmer{text-align:center;vertical-align:middle;opacity:0;-webkit-user-select:none;user-select:none;z-index:1000;background-color:#0009;width:100%;height:100%;transition:background-color .5s linear;animation-duration:.5s;animation-fill-mode:both;display:none;position:absolute;top:0!important;left:0!important}.x-spreadsheet-dimmer.active{opacity:1;display:block}form fieldset{border:none}form fieldset label{color:#666;margin-bottom:.5em;font-size:1em;display:block}form fieldset select{background-color:#fff;border:none;border-bottom:2px solid #ddd;border-radius:2px;width:100%;padding:.5em .85em;font-size:1.1em}.x-spreadsheet-modal,.x-spreadsheet-toast{z-index:1001;text-align:left;color:#000000de;background-color:#fff;background-clip:padding-box;border:1px solid #0000001a;border-radius:4px;min-width:360px;font-family:Lato,Source Sans Pro,Roboto,Helvetica,Arial,sans-serif;font-size:13px;line-height:1.25em;position:fixed;box-shadow:0 2px 8px #0003}.x-spreadsheet-toast{background-color:#ffffffd9}.x-spreadsheet-modal-header,.x-spreadsheet-toast-header{background-color:#ffffffd9;background-clip:padding-box;border-bottom:1px solid #0000000d;border-radius:4px 4px 0 0;font-weight:600}.x-spreadsheet-modal-header .x-spreadsheet-icon,.x-spreadsheet-toast-header .x-spreadsheet-icon{border-radius:18px;position:absolute;top:.65em;right:.8em}.x-spreadsheet-modal-header .x-spreadsheet-icon:hover,.x-spreadsheet-toast-header .x-spreadsheet-icon:hover{opacity:1;background:#00000014}.x-spreadsheet-toast-header{color:#f2711c}.x-spreadsheet-modal-header{background:#00000014;border-bottom:1px solid #e0e2e4;font-size:1.0785em}.x-spreadsheet-modal-header,.x-spreadsheet-modal-content,.x-spreadsheet-toast-header,.x-spreadsheet-toast-content{padding:.75em 1em}@media screen and (width >= 320px) and (width <= 480px){.x-spreadsheet-toolbar{display:none}}.x-spreadsheet-icon{text-align:center;vertical-align:middle;-webkit-user-select:none;user-select:none;width:18px;height:18px;margin:1px 1px 2px;line-height:0;display:inline-block;position:relative;overflow:hidden}.x-spreadsheet-icon .x-spreadsheet-icon-img{opacity:.56;width:262px;height:444px;position:absolute}.x-spreadsheet-icon .x-spreadsheet-icon-img.undo{top:0;left:0}.x-spreadsheet-icon .x-spreadsheet-icon-img.redo{top:0;left:-18px}.x-spreadsheet-icon .x-spreadsheet-icon-img.print{top:0;left:-36px}.x-spreadsheet-icon .x-spreadsheet-icon-img.paintformat{top:0;left:-54px}.x-spreadsheet-icon .x-spreadsheet-icon-img.clearformat{top:0;left:-72px}.x-spreadsheet-icon .x-spreadsheet-icon-img.font-bold{top:0;left:-90px}.x-spreadsheet-icon .x-spreadsheet-icon-img.font-italic{top:0;left:-108px}.x-spreadsheet-icon .x-spreadsheet-icon-img.underline{top:0;left:-126px}.x-spreadsheet-icon .x-spreadsheet-icon-img.strike{top:0;left:-144px}.x-spreadsheet-icon .x-spreadsheet-icon-img.color{top:0;left:-162px}.x-spreadsheet-icon .x-spreadsheet-icon-img.bgcolor{top:0;left:-180px}.x-spreadsheet-icon .x-spreadsheet-icon-img.merge{top:0;left:-198px}.x-spreadsheet-icon .x-spreadsheet-icon-img.align-left{top:0;left:-216px}.x-spreadsheet-icon .x-spreadsheet-icon-img.align-center{top:0;left:-234px}.x-spreadsheet-icon .x-spreadsheet-icon-img.align-right{top:-18px;left:0}.x-spreadsheet-icon .x-spreadsheet-icon-img.align-top{top:-18px;left:-18px}.x-spreadsheet-icon .x-spreadsheet-icon-img.align-middle{top:-18px;left:-36px}.x-spreadsheet-icon .x-spreadsheet-icon-img.align-bottom{top:-18px;left:-54px}.x-spreadsheet-icon .x-spreadsheet-icon-img.textwrap{top:-18px;left:-72px}.x-spreadsheet-icon .x-spreadsheet-icon-img.autofilter{top:-18px;left:-90px}.x-spreadsheet-icon .x-spreadsheet-icon-img.formula{top:-18px;left:-108px}.x-spreadsheet-icon .x-spreadsheet-icon-img.arrow-down{top:-18px;left:-126px}.x-spreadsheet-icon .x-spreadsheet-icon-img.arrow-right{top:-18px;left:-144px}.x-spreadsheet-icon .x-spreadsheet-icon-img.link{top:-18px;left:-162px}.x-spreadsheet-icon .x-spreadsheet-icon-img.chart{top:-18px;left:-180px}.x-spreadsheet-icon .x-spreadsheet-icon-img.freeze{top:-18px;left:-198px}.x-spreadsheet-icon .x-spreadsheet-icon-img.ellipsis{top:-18px;left:-216px}.x-spreadsheet-icon .x-spreadsheet-icon-img.add{top:-18px;left:-234px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-all{top:-36px;left:0}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-inside{top:-36px;left:-18px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-horizontal{top:-36px;left:-36px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-vertical{top:-36px;left:-54px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-outside{top:-36px;left:-72px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-left{top:-36px;left:-90px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-top{top:-36px;left:-108px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-right{top:-36px;left:-126px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-bottom{top:-36px;left:-144px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-none{top:-36px;left:-162px}.x-spreadsheet-icon .x-spreadsheet-icon-img.line-color{top:-36px;left:-180px}.x-spreadsheet-icon .x-spreadsheet-icon-img.line-type{top:-36px;left:-198px}.x-spreadsheet-icon .x-spreadsheet-icon-img.close{top:-36px;left:-234px}.x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-down{top:-54px;left:0}.x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-up{top:-54px;left:-18px}.x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-left{top:-54px;left:-36px}.x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-right{top:-54px;left:-54px}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- (function(S,k){typeof exports=="object"&&typeof module!="undefined"?k(exports,require("@tachybase/client"),require("@tachybase/components"),require("react/jsx-runtime"),require("react"),require("@tachybase/schema"),require("@ant-design/icons"),require("antd"),require("lodash"),require("@tachybase/evaluators/client"),require("react-dom"),require("ahooks"),require("@tachybase/utils/client"),require("@tachybase/module-acl/client"),require("react-router-dom"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/components","react/jsx-runtime","react","@tachybase/schema","@ant-design/icons","antd","lodash","@tachybase/evaluators/client","react-dom","ahooks","@tachybase/utils/client","@tachybase/module-acl/client","react-router-dom","dayjs"],k):(S=typeof globalThis!="undefined"?globalThis:S||self,k(S["@tachybase/module-hera"]={},S["@tachybase/client"],S["@tachybase/components"],S.jsxRuntime,S.react,S["@tachybase/schema"],S["@ant-design/icons"],S.antd,S.lodash,S["@tachybase/evaluators"],S["react-dom"],S.ahooks,S["@tachybase/utils"],S["@tachybase/module-acl"],S["react-router-dom"],S.dayjs))})(this,function(exports,client,components$1,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__,React,schema,icons,antd,_,client$1,ReactDOM,ahooks,client$2,PluginACLClient,reactRouterDom,dayjs){"use strict";var ee=Object.defineProperty,te=Object.defineProperties;var se=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var J=S=>{throw TypeError(S)};var q=(S,k,T)=>k in S?ee(S,k,{enumerable:!0,configurable:!0,writable:!0,value:T}):S[k]=T,w=(S,k)=>{for(var T in k||(k={}))ne.call(k,T)&&q(S,T,k[T]);if(Z)for(var T of Z(k))ie.call(k,T)&&q(S,T,k[T]);return S},R=(S,k)=>te(S,se(k));var C=(S,k,T)=>q(S,typeof k!="symbol"?k+"":k,T),Q=(S,k,T)=>k.has(S)||J("Cannot "+T);var F=(S,k,T)=>(Q(S,k,"read from private field"),T?T.call(S):k.get(S)),H=(S,k,T)=>k.has(S)?J("Cannot add the same private member more than once"):k instanceof WeakSet?k.add(S):k.set(S,T),V=(S,k,T,$)=>(Q(S,k,"write to private field"),$?$.call(S,T):k.set(S,T),T);var P=(S,k,T)=>new Promise(($,B)=>{var N=e=>{try{i(T.next(e))}catch(s){B(s)}},K=e=>{try{i(T.throw(e))}catch(s){B(s)}},i=e=>e.done?$(e.value):Promise.resolve(e.value).then(N,K);i((T=T.apply(S,k)).next())});var S,k,T,$,B,N;function _interopNamespaceDefault(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const s in i)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>i[s]})}}return e.default=i,Object.freeze(e)}const React__namespace=_interopNamespaceDefault(React);var commonjsGlobal=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function getDefaultExportFromCjs(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var FileSaver_min={exports:{}};(function(i,e){(function(s,n){n()})(commonjsGlobal,function(){function s(d,u){return typeof u=="undefined"?u={autoBom:!1}:typeof u!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(d.type)?new Blob(["\uFEFF",d],{type:d.type}):d}function n(d,u,p){var m=new XMLHttpRequest;m.open("GET",d),m.responseType="blob",m.onload=function(){c(m.response,u,p)},m.onerror=function(){console.error("could not download file")},m.send()}function r(d){var u=new XMLHttpRequest;u.open("HEAD",d,!1);try{u.send()}catch(p){}return 200<=u.status&&299>=u.status}function o(d){try{d.dispatchEvent(new MouseEvent("click"))}catch(p){var u=document.createEvent("MouseEvents");u.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),d.dispatchEvent(u)}}var a=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof commonjsGlobal=="object"&&commonjsGlobal.global===commonjsGlobal?commonjsGlobal:void 0,l=a.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),c=a.saveAs||(typeof window!="object"||window!==a?function(){}:"download"in HTMLAnchorElement.prototype&&!l?function(d,u,p){var m=a.URL||a.webkitURL,f=document.createElement("a");u=u||d.name||"download",f.download=u,f.rel="noopener",typeof d=="string"?(f.href=d,f.origin===location.origin?o(f):r(f.href)?n(d,u,p):o(f,f.target="_blank")):(f.href=m.createObjectURL(d),setTimeout(function(){m.revokeObjectURL(f.href)},4e4),setTimeout(function(){o(f)},0))}:"msSaveOrOpenBlob"in navigator?function(d,u,p){if(u=u||d.name||"download",typeof d!="string")navigator.msSaveOrOpenBlob(s(d,p),u);else if(r(d))n(d,u,p);else{var m=document.createElement("a");m.href=d,m.target="_blank",setTimeout(function(){o(m)})}}:function(d,u,p,m){if(m=m||open("","_blank"),m&&(m.document.title=m.document.body.innerText="downloading..."),typeof d=="string")return n(d,u,p);var f=d.type==="application/octet-stream",g=/constructor/i.test(a.HTMLElement)||a.safari,x=/CriOS\/[\d]+/.test(navigator.userAgent);if((x||f&&g||l)&&typeof FileReader!="undefined"){var y=new FileReader;y.onloadend=function(){var v=y.result;v=x?v:v.replace(/^data:[^;]*;/,"data:attachment/file;"),m?m.location.href=v:location=v,m=null},y.readAsDataURL(d)}else{var E=a.URL||a.webkitURL,b=E.createObjectURL(d);m?m.location=b:location.href=b,m=null,setTimeout(function(){E.revokeObjectURL(b)},4e4)}});a.saveAs=c.saveAs=c,i.exports=c})})(FileSaver_min);var FileSaver_minExports=FileSaver_min.exports;const NAMESPACE="@tachybase/module-hera";class Locale{constructor(e){C(this,"app");this.app=e}lang(e){return this.app.i18n.t(e,{ns:NAMESPACE})}}const useTranslation=()=>{const{i18n:i}=client.useApp();return{t:(s,n={})=>i.t(s,w({ns:NAMESPACE},n))}},tval=i=>client.tval(i,{ns:NAMESPACE});function lang(i){return client.i18n.t(i,{ns:NAMESPACE})}const LoadingSpin=({children:i,spinning:e})=>{const{t:s}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Spin,{tip:s("loading..."),indicator:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.LoadingOutlined,{style:{fontSize:24},spin:!0}),spinning:e,children:i})},PDFViewer=React.forwardRef((i,e)=>{const n=client.useApp().AttachmentPreviewManager.get(),{checkedComponent:r}=n["application/pdf"],o=client.useIsMobile(),[a,l]=React.useState(""),[c,d]=React.useState(null),{file:u,width:p=960}=i,{loading:m,data:f}=client.useRequest({url:u,responseType:"arraybuffer"},{refreshDeps:[u]});return React.useImperativeHandle(e,()=>({download(){const g=new Blob([f],{type:"application/pdf"});FileSaver_minExports.saveAs(g,schema.uid()+".pdf")},print(){c.print()}})),React.useEffect(()=>{if(m||!f)return;const g=new Blob([f],{type:"application/pdf"}),x=URL.createObjectURL(g);l(x)},[f,m]),React.useEffect(()=>{if(!a)return;const g=document.createElement("iframe");return g.style.display="none",g.src=a,g.onload=()=>{d(g.contentWindow)},document.body.appendChild(g),()=>{URL.revokeObjectURL(a),document.body.removeChild(g)}},[a]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(LoadingSpin,{spinning:m,children:r({file:{url:a},width:p,noTransformWrapper:!o})})});class Element{constructor(e,s=""){typeof e=="string"?(this.el=document.createElement(e),this.el.className=s):this.el=e,this.data={}}data(e,s){return s!==void 0?(this.data[e]=s,this):this.data[e]}on(e,s){const[n,...r]=e.split(".");let o=n;return o==="mousewheel"&&/Firefox/i.test(window.navigator.userAgent)&&(o="DOMMouseScroll"),this.el.addEventListener(o,a=>{s(a);for(let l=0;l<r.length;l+=1){const c=r[l];if(c==="left"&&a.button!==0||c==="right"&&a.button!==2)return;c==="stop"&&a.stopPropagation()}}),this}offset(e){if(e!==void 0)return Object.keys(e).forEach(a=>{this.css(a,`${e[a]}px`)}),this;const{offsetTop:s,offsetLeft:n,offsetHeight:r,offsetWidth:o}=this.el;return{top:s,left:n,height:r,width:o}}scroll(e){const{el:s}=this;return e!==void 0&&(e.left!==void 0&&(s.scrollLeft=e.left),e.top!==void 0&&(s.scrollTop=e.top)),{left:s.scrollLeft,top:s.scrollTop}}box(){return this.el.getBoundingClientRect()}parent(){return new Element(this.el.parentNode)}children(...e){return arguments.length===0?this.el.childNodes:(e.forEach(s=>this.child(s)),this)}removeChild(e){this.el.removeChild(e)}child(e){let s=e;return typeof e=="string"?s=document.createTextNode(e):e instanceof Element&&(s=e.el),this.el.appendChild(s),this}contains(e){return this.el.contains(e)}className(e){return e!==void 0?(this.el.className=e,this):this.el.className}addClass(e){return this.el.classList.add(e),this}hasClass(e){return this.el.classList.contains(e)}removeClass(e){return this.el.classList.remove(e),this}toggle(e="active"){return this.toggleClass(e)}toggleClass(e){return this.el.classList.toggle(e)}active(e=!0,s="active"){return e?this.addClass(s):this.removeClass(s),this}checked(e=!0){return this.active(e,"checked"),this}disabled(e=!0){return e?this.addClass("disabled"):this.removeClass("disabled"),this}attr(e,s){if(s!==void 0)this.el.setAttribute(e,s);else{if(typeof e=="string")return this.el.getAttribute(e);Object.keys(e).forEach(n=>{this.el.setAttribute(n,e[n])})}return this}removeAttr(e){return this.el.removeAttribute(e),this}html(e){return e!==void 0?(this.el.innerHTML=e,this):this.el.innerHTML}val(e){return e!==void 0?(this.el.value=e,this):this.el.value}focus(){this.el.focus()}cssRemoveKeys(...e){return e.forEach(s=>this.el.style.removeProperty(s)),this}css(e,s){return s===void 0&&typeof e!="string"?(Object.keys(e).forEach(n=>{this.el.style[n]=e[n]}),this):s!==void 0?(this.el.style[e]=s,this):this.el.style[e]}computedStyle(){return window.getComputedStyle(this.el,null)}show(){return this.css("display","block"),this}hide(){return this.css("display","none"),this}}const h=(i,e="")=>new Element(i,e),alphabets=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function stringAt(i){let e="",s=i;for(;s>=alphabets.length;)s/=alphabets.length,s-=1,e+=alphabets[parseInt(s,10)%alphabets.length];const n=i%alphabets.length;return e+=alphabets[n],e}function indexAt(i){let e=0;for(let s=0;s!==i.length;++s)e=26*e+i.charCodeAt(s)-64;return e-1}function expr2xy(i){let e="",s="";for(let n=0;n<i.length;n+=1)i.charAt(n)>="0"&&i.charAt(n)<="9"?s+=i.charAt(n):e+=i.charAt(n);return[indexAt(e),parseInt(s,10)-1]}function xy2expr(i,e){return`${stringAt(i)}${e+1}`}function expr2expr(i,e,s,n=()=>!0){if(e===0&&s===0)return i;const[r,o]=expr2xy(i);return n(r,o)?xy2expr(r+e,o+s):i}class CellRange{constructor(e,s,n,r,o=0,a=0){this.sri=e,this.sci=s,this.eri=n,this.eci=r,this.w=o,this.h=a}set(e,s,n,r){this.sri=e,this.sci=s,this.eri=n,this.eci=r}multiple(){return this.eri-this.sri>0||this.eci-this.sci>0}includes(...e){let[s,n]=[0,0];e.length===1?[n,s]=expr2xy(e[0]):e.length===2&&([s,n]=e);const{sri:r,sci:o,eri:a,eci:l}=this;return r<=s&&s<=a&&o<=n&&n<=l}each(e,s=()=>!0){const{sri:n,sci:r,eri:o,eci:a}=this;for(let l=n;l<=o;l+=1)if(s(l))for(let c=r;c<=a;c+=1)e(l,c)}contains(e){return this.sri<=e.sri&&this.sci<=e.sci&&this.eri>=e.eri&&this.eci>=e.eci}within(e){return this.sri>=e.sri&&this.sci>=e.sci&&this.eri<=e.eri&&this.eci<=e.eci}disjoint(e){return this.sri>e.eri||this.sci>e.eci||e.sri>this.eri||e.sci>this.eci}intersects(e){return this.sri<=e.eri&&this.sci<=e.eci&&e.sri<=this.eri&&e.sci<=this.eci}union(e){const{sri:s,sci:n,eri:r,eci:o}=this;return new CellRange(e.sri<s?e.sri:s,e.sci<n?e.sci:n,e.eri>r?e.eri:r,e.eci>o?e.eci:o)}difference(e){const s=[],n=(m,f,g,x)=>{s.push(new CellRange(m,f,g,x))},{sri:r,sci:o,eri:a,eci:l}=this,c=e.sri-r,d=e.sci-o,u=a-e.eri,p=l-e.eci;return c>0?(n(r,o,e.sri-1,l),u>0?(n(e.eri+1,o,a,l),d>0&&n(e.sri,o,e.eri,e.sci-1),p>0&&n(e.sri,e.eci+1,e.eri,l)):(d>0&&n(e.sri,o,a,e.sci-1),p>0&&n(e.sri,e.eci+1,a,l))):u>0&&(n(e.eri+1,o,a,l),d>0&&n(r,o,e.eri,e.sci-1),p>0&&n(r,e.eci+1,e.eri,l)),d>0?(n(r,o,a,e.sci-1),p>0?(n(r,e.eri+1,a,l),c>0&&n(r,e.sci,e.sri-1,e.eci),u>0&&n(e.sri+1,e.sci,a,e.eci)):(c>0&&n(r,e.sci,e.sri-1,l),u>0&&n(e.sri+1,e.sci,a,l))):p>0&&(n(a,e.eci+1,a,l),c>0&&n(r,o,e.sri-1,e.eci),u>0&&n(e.eri+1,o,a,e.eci)),s}size(){return[this.eri-this.sri+1,this.eci-this.sci+1]}toString(){const{sri:e,sci:s,eri:n,eci:r}=this;let o=xy2expr(s,e);return this.multiple()&&(o=`${o}:${xy2expr(r,n)}`),o}clone(){const{sri:e,sci:s,eri:n,eci:r,w:o,h:a}=this;return new CellRange(e,s,n,r,o,a)}equals(e){return this.eri===e.eri&&this.eci===e.eci&&this.sri===e.sri&&this.sci===e.sci}static valueOf(e){const s=e.split(":"),[n,r]=expr2xy(s[0]);let[o,a]=[r,n];return s.length>1&&([a,o]=expr2xy(s[1])),new CellRange(r,n,o,a)}}let Selector$1=class{constructor(){this.range=new CellRange(0,0,0,0),this.ri=0,this.ci=0}multiple(){return this.range.multiple()}setIndexes(e,s){this.ri=e,this.ci=s}size(){return this.range.size()}};class Scroll{constructor(){this.x=0,this.y=0,this.ri=0,this.ci=0}}class History{constructor(){this.undoItems=[],this.redoItems=[]}add(e){this.undoItems.push(JSON.stringify(e)),this.redoItems=[]}canUndo(){return this.undoItems.length>0}canRedo(){return this.redoItems.length>0}undo(e,s){const{undoItems:n,redoItems:r}=this;this.canUndo()&&(r.push(JSON.stringify(e)),s(JSON.parse(n.pop())))}redo(e,s){const{undoItems:n,redoItems:r}=this;this.canRedo()&&(n.push(JSON.stringify(e)),s(JSON.parse(r.pop())))}}class Clipboard{constructor(){this.range=null,this.state="clear"}copy(e){return this.range=e,this.state="copy",this}cut(e){return this.range=e,this.state="cut",this}isCopy(){return this.state==="copy"}isCut(){return this.state==="cut"}isClear(){return this.state==="clear"}clear(){this.range=null,this.state="clear"}}class Filter{constructor(e,s,n){this.ci=e,this.operator=s,this.value=n}set(e,s){this.operator=e,this.value=s}includes(e){const{operator:s,value:n}=this;return s==="all"?!0:s==="in"?n.includes(e):!1}vlength(){const{operator:e,value:s}=this;return e==="in"?s.length:0}getData(){const{ci:e,operator:s,value:n}=this;return{ci:e,operator:s,value:n}}}class Sort{constructor(e,s){this.ci=e,this.order=s}asc(){return this.order==="asc"}desc(){return this.order==="desc"}}class AutoFilter{constructor(){this.ref=null,this.filters=[],this.sort=null}setData({ref:e,filters:s,sort:n}){e!=null&&(this.ref=e,this.filters=s.map(r=>new Filter(r.ci,r.operator,r.value)),n&&(this.sort=new Sort(n.ci,n.order)))}getData(){if(this.active()){const{ref:e,filters:s,sort:n}=this;return{ref:e,filters:s.map(r=>r.getData()),sort:n}}return{}}addFilter(e,s,n){const r=this.getFilter(e);r==null?this.filters.push(new Filter(e,s,n)):r.set(s,n)}setSort(e,s){this.sort=s?new Sort(e,s):null}includes(e,s){return this.active()?this.hrange().includes(e,s):!1}getSort(e){const{sort:s}=this;return s&&s.ci===e?s:null}getFilter(e){const{filters:s}=this;for(let n=0;n<s.length;n+=1)if(s[n].ci===e)return s[n];return null}filteredRows(e){const s=new Set,n=new Set;if(this.active()){const{sri:r,eri:o}=this.range(),{filters:a}=this;for(let l=r+1;l<=o;l+=1)for(let c=0;c<a.length;c+=1){const d=a[c],u=e(l,d.ci),p=u?u.text:"";if(d.includes(p))n.add(l);else{s.add(l);break}}}return{rset:s,fset:n}}items(e,s){const n={};if(this.active()){const{sri:r,eri:o}=this.range();for(let a=r+1;a<=o;a+=1){const l=s(a,e);if(l===null||/^\s*$/.test(l.text))n[""]=(n[""]||0)+1;else{const c=l.text,d=(n[c]||0)+1;n[c]=d}}}return n}range(){return CellRange.valueOf(this.ref)}hrange(){const e=this.range();return e.eri=e.sri,e}clear(){this.ref=null,this.filters=[],this.sort=null}active(){return this.ref!==null}}class Merges{constructor(e=[]){this._=e}forEach(e){this._.forEach(e)}deleteWithin(e){this._=this._.filter(s=>!s.within(e))}getFirstIncludes(e,s){for(let n=0;n<this._.length;n+=1){const r=this._[n];if(r.includes(e,s))return r}return null}filterIntersects(e){return new Merges(this._.filter(s=>s.intersects(e)))}intersects(e){for(let s=0;s<this._.length;s+=1)if(this._[s].intersects(e))return!0;return!1}union(e){let s=e;return this._.forEach(n=>{n.intersects(s)&&(s=n.union(s))}),s}add(e){this.deleteWithin(e),this._.push(e)}shift(e,s,n,r){this._.forEach(o=>{const{sri:a,sci:l,eri:c,eci:d}=o,u=o;e==="row"?a>=s?(u.sri+=n,u.eri+=n):a<s&&s<=c&&(u.eri+=n,r(a,l,n,0)):e==="column"&&(l>=s?(u.sci+=n,u.eci+=n):l<s&&s<=d&&(u.eci+=n,r(a,l,0,n)))})}move(e,s,n){this._.forEach(r=>{const o=r;o.within(e)&&(o.eri+=s,o.sri+=s,o.sci+=n,o.eci+=n)})}setData(e){return this._=e.map(s=>CellRange.valueOf(s)),this}getData(){return this._.map(e=>e.toString())}}function cloneDeep(i){return JSON.parse(JSON.stringify(i))}const mergeDeep=(i={},...e)=>(e.forEach(s=>{Object.keys(s).forEach(n=>{const r=s[n];typeof r=="string"||typeof r=="number"||typeof r=="boolean"?i[n]=r:typeof r!="function"&&!Array.isArray(r)&&r instanceof Object?(i[n]=i[n]||{},mergeDeep(i[n],r)):i[n]=r})}),i);function equals(i,e){const s=Object.keys(i);if(s.length!==Object.keys(e).length)return!1;for(let n=0;n<s.length;n+=1){const r=s[n],o=i[r],a=e[r];if(a===void 0)return!1;if(typeof o=="string"||typeof o=="number"||typeof o=="boolean"){if(o!==a)return!1}else if(Array.isArray(o)){if(o.length!==a.length)return!1;for(let l=0;l<o.length;l+=1)if(!equals(o[l],a[l]))return!1}else if(typeof o!="function"&&!Array.isArray(o)&&o instanceof Object&&!equals(o,a))return!1}return!0}const sum=(i,e=s=>s)=>{let s=0,n=0;return Object.keys(i).forEach(r=>{s+=e(i[r],r),n+=1}),[s,n]};function deleteProperty(i,e){const s=i[`${e}`];return delete i[`${e}`],s}function rangeReduceIf(i,e,s,n,r,o){let a=s,l=n,c=i;for(;c<e&&!(a>r);c+=1)l=o(c),a+=l;return[c,a-l,l]}function rangeSum(i,e,s){let n=0;for(let r=i;r<e;r+=1)n+=s(r);return n}function rangeEach(i,e,s){for(let n=i;n<e;n+=1)s(n)}function arrayEquals(i,e){if(i.length!==e.length)return!1;for(let s=0;s<i.length;s+=1)if(i[s]!==e[s])return!1;return!0}function digits(i){const e=`${i}`;let s=0,n=!1;for(let r=0;r<e.length;r+=1)n===!0&&(s+=1),e.charAt(r)==="."&&(n=!0);return s}function numberCalc(i,e,s){if(Number.isNaN(e)||Number.isNaN(s))return e+i+s;const n=digits(e),r=digits(s),o=Number(e),a=Number(s);let l=0;if(i==="-")l=o-a;else if(i==="+")l=o+a;else if(i==="*")l=o*a;else if(i==="/")return l=o/a,digits(l)>5?l.toFixed(2):l;return l.toFixed(Math.max(n,r))}const helper_rslib_entry_={cloneDeep,merge:(...i)=>mergeDeep({},...i),equals,arrayEquals,sum,rangeEach,rangeSum,rangeReduceIf,deleteProperty,numberCalc};class Rows{constructor({len:e,height:s}){this._={},this.len=e,this.height=s}getHeight(e){if(this.isHide(e))return 0;const s=this.get(e);return s&&s.height?s.height:this.height}setHeight(e,s){const n=this.getOrNew(e);n.height=s}unhide(e){let s=e;for(;s>0&&(s-=1,this.isHide(s));)this.setHide(s,!1)}isHide(e){const s=this.get(e);return s&&s.hide}setHide(e,s){const n=this.getOrNew(e);s===!0?n.hide=!0:delete n.hide}setStyle(e,s){const n=this.getOrNew(e);n.style=s}sumHeight(e,s,n){return helper_rslib_entry_.rangeSum(e,s,r=>n&&n.has(r)?0:this.getHeight(r))}totalHeight(){return this.sumHeight(0,this.len)}get(e){return this._[e]}getOrNew(e){return this._[e]=this._[e]||{cells:{}},this._[e]}getCell(e,s){const n=this.get(e);return n!==void 0&&n.cells!==void 0&&n.cells[s]!==void 0?n.cells[s]:null}getCellMerge(e,s){const n=this.getCell(e,s);return n&&n.merge?n.merge:[0,0]}getCellOrNew(e,s){const n=this.getOrNew(e);return n.cells[s]=n.cells[s]||{},n.cells[s]}setCell(e,s,n,r="all"){const o=this.getOrNew(e);r==="all"?o.cells[s]=n:r==="text"?(o.cells[s]=o.cells[s]||{},o.cells[s].text=n.text):r==="format"&&(o.cells[s]=o.cells[s]||{},o.cells[s].style=n.style,n.merge&&(o.cells[s].merge=n.merge))}setCellText(e,s,n){const r=this.getCellOrNew(e,s);r.editable!==!1&&(r.text=n)}copyPaste(e,s,n,r=!1,o=()=>{}){const{sri:a,sci:l,eri:c,eci:d}=e,u=s.sri,p=s.sci,m=s.eri,f=s.eci,[g,x]=e.size(),[y,E]=s.size();let b=!0,v=0;(m<a||f<l)&&(b=!1,v=m<a?y:E);for(let A=a;A<=c;A+=1)if(this._[A]){for(let D=l;D<=d;D+=1)if(this._[A].cells&&this._[A].cells[D])for(let L=u;L<=m;L+=g)for(let I=p;I<=f;I+=x){const O=L+(A-a),z=I+(D-l),M=helper_rslib_entry_.cloneDeep(this._[A].cells[D]);if(r&&M&&M.text&&M.text.length>0){const{text:j}=M;let W=I-p+(L-u)+2;if(b||(W-=v+1),j[0]==="=")M.text=j.replace(/[a-zA-Z]{1,3}\d+/g,U=>{let[X,Y]=[0,0];return a===u?X=W-1:Y=W-1,/^\d+$/.test(U)?U:expr2expr(U,X,Y)});else if(g<=1&&x>1&&(u>c||m<a)||x<=1&&g>1&&(p>d||f<l)||g<=1&&x<=1){const U=/[\\.\d]+$/.exec(j);if(U!==null){const X=Number(U[0])+W-1;M.text=j.substring(0,U.index)+X}}}this.setCell(O,z,M,n),o(O,z,M)}}}cutPaste(e,s){const n={};this.each(r=>{this.eachCells(r,o=>{let a=parseInt(r,10),l=parseInt(o,10);e.includes(r,o)&&(a=s.sri+(a-e.sri),l=s.sci+(l-e.sci)),n[a]=n[a]||{cells:{}},n[a].cells[l]=this._[r].cells[o]})}),this._=n}paste(e,s){if(e.length<=0)return;const{sri:n,sci:r}=s;e.forEach((o,a)=>{const l=n+a;o.forEach((c,d)=>{const u=r+d;this.setCellText(l,u,c)})})}insert(e,s=1){const n={};this.each((r,o)=>{let a=parseInt(r,10);a>=e&&(a+=s,this.eachCells(r,(l,c)=>{c.text&&c.text[0]==="="&&(c.text=c.text.replace(/[a-zA-Z]{1,3}\d+/g,d=>expr2expr(d,0,s,(u,p)=>p>=e)))})),n[a]=o}),this._=n,this.len+=s}delete(e,s){const n=s-e+1,r={};this.each((o,a)=>{const l=parseInt(o,10);l<e?r[l]=a:o>s&&(r[l-n]=a,this.eachCells(o,(c,d)=>{d.text&&d.text[0]==="="&&(d.text=d.text.replace(/[a-zA-Z]{1,3}\d+/g,u=>expr2expr(u,0,-n,(p,m)=>m>s)))}))}),this._=r,this.len-=n}insertColumn(e,s=1){this.each((n,r)=>{const o={};this.eachCells(n,(a,l)=>{let c=parseInt(a,10);c>=e&&(c+=s,l.text&&l.text[0]==="="&&(l.text=l.text.replace(/[a-zA-Z]{1,3}\d+/g,d=>expr2expr(d,s,0,u=>u>=e)))),o[c]=l}),r.cells=o})}deleteColumn(e,s){const n=s-e+1;this.each((r,o)=>{const a={};this.eachCells(r,(l,c)=>{const d=parseInt(l,10);d<e?a[d]=c:d>s&&(a[d-n]=c,c.text&&c.text[0]==="="&&(c.text=c.text.replace(/[a-zA-Z]{1,3}\d+/g,u=>expr2expr(u,-n,0,p=>p>s))))}),o.cells=a})}deleteCells(e,s="all"){e.each((n,r)=>{this.deleteCell(n,r,s)})}deleteCell(e,s,n="all"){const r=this.get(e);if(r!==null){const o=this.getCell(e,s);o!==null&&o.editable!==!1&&(n==="all"?delete r.cells[s]:n==="text"?(o.text&&delete o.text,o.value&&delete o.value):n==="format"?(o.style!==void 0&&delete o.style,o.merge&&delete o.merge):n==="merge"&&o.merge&&delete o.merge)}}maxCell(){const e=Object.keys(this._),s=e[e.length-1],n=this._[s];if(n){const{cells:r}=n,o=Object.keys(r),a=o[o.length-1];return[parseInt(s,10),parseInt(a,10)]}return[0,0]}each(e){Object.entries(this._).forEach(([s,n])=>{e(s,n)})}eachCells(e,s){this._[e]&&this._[e].cells&&Object.entries(this._[e].cells).forEach(([n,r])=>{s(n,r)})}setData(e){e.len&&(this.len=e.len,delete e.len),this._=e}getData(){const{len:e}=this;return Object.assign({len:e},this._)}}class Cols{constructor({len:e,width:s,indexWidth:n,minWidth:r}){this._={},this.len=e,this.width=s,this.indexWidth=n,this.minWidth=r}setData(e){e.len&&(this.len=e.len,delete e.len),this._=e}getData(){const{len:e}=this;return Object.assign({len:e},this._)}getWidth(e){if(this.isHide(e))return 0;const s=this._[e];return s&&s.width?s.width:this.width}getOrNew(e){return this._[e]=this._[e]||{},this._[e]}setWidth(e,s){const n=this.getOrNew(e);n.width=s}unhide(e){let s=e;for(;s>0&&(s-=1,this.isHide(s));)this.setHide(s,!1)}isHide(e){const s=this._[e];return s&&s.hide}setHide(e,s){const n=this.getOrNew(e);s===!0?n.hide=!0:delete n.hide}setStyle(e,s){const n=this.getOrNew(e);n.style=s}sumWidth(e,s){return helper_rslib_entry_.rangeSum(e,s,n=>this.getWidth(n))}totalWidth(){return this.sumWidth(0,this.len)}}const en_rslib_entry_={toolbar:{undo:"Undo",redo:"Redo",print:"Print",paintformat:"Paint format",clearformat:"Clear format",format:"Format",fontName:"Font",fontSize:"Font size",fontBold:"Font bold",fontItalic:"Font italic",underline:"Underline",strike:"Strike",color:"Text color",bgcolor:"Fill color",border:"Borders",merge:"Merge cells",align:"Horizontal align",valign:"Vertical align",textwrap:"Text wrapping",freeze:"Freeze cell",autofilter:"Filter",formula:"Functions",more:"More"},contextmenu:{copy:"Copy",cut:"Cut",paste:"Paste",pasteValue:"Paste values only",pasteFormat:"Paste format only",hide:"Hide",insertRow:"Insert row",insertColumn:"Insert column",deleteSheet:"Delete",deleteRow:"Delete row",deleteColumn:"Delete column",deleteCell:"Delete cell",deleteCellText:"Delete cell text",validation:"Data validations",cellprintable:"Enable export",cellnonprintable:"Disable export",celleditable:"Enable editing",cellnoneditable:"Disable editing"},print:{size:"Paper size",orientation:"Page orientation",orientations:["Landscape","Portrait"]},format:{normal:"Normal",text:"Plain Text",number:"Number",percent:"Percent",rmb:"RMB",usd:"USD",eur:"EUR",date:"Date",time:"Time",datetime:"Date time",duration:"Duration"},formula:{sum:"Sum",average:"Average",max:"Max",min:"Min",_if:"IF",and:"AND",or:"OR",concat:"Concat"},validation:{required:"it must be required",notMatch:"it not match its validation rule",between:"it is between {} and {}",notBetween:"it is not between {} and {}",notIn:"it is not in list",equal:"it equal to {}",notEqual:"it not equal to {}",lessThan:"it less than {}",lessThanEqual:"it less than or equal to {}",greaterThan:"it greater than {}",greaterThanEqual:"it greater than or equal to {}"},error:{pasteForMergedCell:"Unable to do this for merged cells"},calendar:{weeks:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},button:{next:"Next",cancel:"Cancel",remove:"Remove",save:"Save",ok:"OK"},sort:{desc:"Sort Z -> A",asc:"Sort A -> Z"},filter:{empty:"empty"},dataValidation:{mode:"Mode",range:"Cell Range",criteria:"Criteria",modeType:{cell:"Cell",column:"Colun",row:"Row"},type:{list:"List",number:"Number",date:"Date",phone:"Phone",email:"Email"},operator:{be:"between",nbe:"not betwwen",lt:"less than",lte:"less than or equal to",gt:"greater than",gte:"greater than or equal to",eq:"equal to",neq:"not equal to"}}};let $languages=["en"];const $messages={en:en_rslib_entry_};function translate(i,e){if(e)for(const s of $languages){if(!e[s])break;let n=e[s];const r=i.match(/(?:\\.|[^.])+/g);for(let o=0;o<r.length;o+=1){const a=r[o],l=n[a];if(!l)break;if(o===r.length-1)return l;n=l}}}function t(i){let e=translate(i,$messages);return!e&&window&&window.x_spreadsheet&&window.x_spreadsheet.$messages&&(e=translate(i,window.x_spreadsheet.$messages)),e||""}function tf(i){return()=>t(i)}function locale(i,e,s=!1){s?$languages=[i]:$languages.unshift(i),e&&($messages[i]=e)}const rules={phone:/^[1-9]\d{10}$/,email:/w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/};function returnMessage(i,e,...s){let n="";return i||(n=t(`validation.${e}`,...s)),[i,n]}class Validator{constructor(e,s,n,r){this.required=s,this.value=n,this.type=e,this.operator=r,this.message=""}parseValue(e){const{type:s}=this;return s==="date"?new Date(e):s==="number"?Number(e):e}equals(e){let s=this.type===e.type&&this.required===e.required&&this.operator===e.operator;return s&&(s=Array.isArray(this.value)?helper_rslib_entry_.arrayEquals(this.value,e.value):this.value===e.value),s}values(){return this.value.split(",")}validate(e){const{required:s,operator:n,value:r,type:o}=this;if(s&&/^\s*$/.test(e))return returnMessage(!1,"required");if(/^\s*$/.test(e))return[!0];if(rules[o]&&!rules[o].test(e))return returnMessage(!1,"notMatch");if(o==="list")return returnMessage(this.values().includes(e),"notIn");if(n){const a=this.parseValue(e);if(n==="be"){const[l,c]=r;return returnMessage(a>=this.parseValue(l)&&a<=this.parseValue(c),"between",l,c)}if(n==="nbe"){const[l,c]=r;return returnMessage(a<this.parseValue(l)||a>this.parseValue(c),"notBetween",l,c)}if(n==="eq")return returnMessage(a===this.parseValue(r),"equal",r);if(n==="neq")return returnMessage(a!==this.parseValue(r),"notEqual",r);if(n==="lt")return returnMessage(a<this.parseValue(r),"lessThan",r);if(n==="lte")return returnMessage(a<=this.parseValue(r),"lessThanEqual",r);if(n==="gt")return returnMessage(a>this.parseValue(r),"greaterThan",r);if(n==="gte")return returnMessage(a>=this.parseValue(r),"greaterThanEqual",r)}return[!0]}}class Validation{constructor(e,s,n){this.refs=s,this.mode=e,this.validator=n}includes(e,s){const{refs:n}=this;for(let r=0;r<n.length;r+=1)if(CellRange.valueOf(n[r]).includes(e,s))return!0;return!1}addRef(e){this.remove(CellRange.valueOf(e)),this.refs.push(e)}remove(e){const s=[];this.refs.forEach(n=>{const r=CellRange.valueOf(n);r.intersects(e)?r.difference(e).forEach(a=>s.push(a.toString())):s.push(n)}),this.refs=s}getData(){const{refs:e,mode:s,validator:n}=this,{type:r,required:o,operator:a,value:l}=n;return{refs:e,mode:s,type:r,required:o,operator:a,value:l}}static valueOf({refs:e,mode:s,type:n,required:r,operator:o,value:a}){return new Validation(s,e,new Validator(n,r,a,o))}}class Validations{constructor(){this._=[],this.errors=new Map}getError(e,s){return this.errors.get(`${e}_${s}`)}validate(e,s,n){const r=this.get(e,s),o=`${e}_${s}`,{errors:a}=this;if(r!==null){const[l,c]=r.validator.validate(n);l?a.delete(o):a.set(o,c)}else a.delete(o);return!0}add(e,s,{type:n,required:r,value:o,operator:a}){const l=new Validator(n,r,o,a),c=this.getByValidator(l);c!==null?c.addRef(s):this._.push(new Validation(e,[s],l))}getByValidator(e){for(let s=0;s<this._.length;s+=1){const n=this._[s];if(n.validator.equals(e))return n}return null}get(e,s){for(let n=0;n<this._.length;n+=1){const r=this._[n];if(r.includes(e,s))return r}return null}remove(e){this.each(s=>{s.remove(e)})}each(e){this._.forEach(s=>e(s))}getData(){return this._.filter(e=>e.refs.length>0).map(e=>e.getData())}setData(e){this._=e.map(s=>Validation.valueOf(s))}}const defaultSettings={mode:"edit",view:{height:()=>document.documentElement.clientHeight,width:()=>document.documentElement.clientWidth},showGrid:!0,showToolbar:!0,showContextmenu:!0,showBottomBar:!0,row:{len:100,height:25},col:{len:26,width:100,indexWidth:60,minWidth:60},style:{bgcolor:"#ffffff",align:"left",valign:"middle",textwrap:!1,strike:!1,underline:!1,color:"#0a0a0a",font:{name:"Arial",size:10,bold:!1,italic:!1},format:"normal"}},toolbarHeight=41,bottombarHeight=41;function canPaste(i,e,s=()=>{}){const{merges:n}=this,r=e.clone(),[o,a]=i.size(),[l,c]=e.size();return o>l&&(r.eri=e.sri+o-1),a>c&&(r.eci=e.sci+a-1),n.intersects(r)?(s(t("error.pasteForMergedCell")),!1):!0}function copyPaste(i,e,s,n=!1){const{rows:r,merges:o}=this;(s==="all"||s==="format")&&(r.deleteCells(e,s),o.deleteWithin(e)),r.copyPaste(i,e,s,n,(a,l,c)=>{if(c&&c.merge){const[d,u]=c.merge;if(d<=0&&u<=0)return;o.add(new CellRange(a,l,a+d,l+u))}})}function cutPaste(i,e){const{clipboard:s,rows:n,merges:r}=this;n.cutPaste(i,e),r.move(i,e.sri-i.sri,e.sci-i.sci),s.clear()}function setStyleBorder(i,e,s){const{styles:n,rows:r}=this,o=r.getCellOrNew(i,e);let a={};o.style!==void 0&&(a=helper_rslib_entry_.cloneDeep(n[o.style])),a=helper_rslib_entry_.merge(a,{border:s}),o.style=this.addStyle(a)}function setStyleBorders({mode:i,style:e,color:s}){const{styles:n,selector:r,rows:o}=this,{sri:a,sci:l,eri:c,eci:d}=r.range,u=!this.isSingleSelected();if(!(!u&&(i==="inside"||i==="horizontal"||i==="vertical")))if(i!=="outside"||u){if(i==="none")r.range.each((p,m)=>{const f=o.getCell(p,m);if(f&&f.style!==void 0){const g=helper_rslib_entry_.cloneDeep(n[f.style]);delete g.border,f.style=this.addStyle(g)}});else if(i==="all"||i==="inside"||i==="outside"||i==="horizontal"||i==="vertical"){const p=[];for(let m=a;m<=c;m+=1)for(let f=l;f<=d;f+=1){const g=[];for(let D=0;D<p.length;D+=1){const[L,I,O,z]=p[D];if(m===L+O+1&&g.push(D),L<=m&&m<=L+O&&f===I){f+=z+1;break}}if(g.forEach(D=>p.splice(D,1)),f>d)break;const x=o.getCell(m,f);let[y,E]=[0,0];x&&x.merge&&([y,E]=x.merge,p.push([m,f,y,E]));const b=y>0&&m+y===c,v=E>0&&f+E===d;let A={};i==="all"?A={bottom:[e,s],top:[e,s],left:[e,s],right:[e,s]}:i==="inside"?(!v&&f<d&&(A.right=[e,s]),!b&&m<c&&(A.bottom=[e,s])):i==="horizontal"?!b&&m<c&&(A.bottom=[e,s]):i==="vertical"?!v&&f<d&&(A.right=[e,s]):i==="outside"&&u&&(a===m&&(A.top=[e,s]),(b||c===m)&&(A.bottom=[e,s]),l===f&&(A.left=[e,s]),(v||d===f)&&(A.right=[e,s])),Object.keys(A).length>0&&setStyleBorder.call(this,m,f,A),f+=E}}else if(i==="top"||i==="bottom")for(let p=l;p<=d;p+=1)i==="top"&&(setStyleBorder.call(this,a,p,{top:[e,s]}),p+=o.getCellMerge(a,p)[1]),i==="bottom"&&(setStyleBorder.call(this,c,p,{bottom:[e,s]}),p+=o.getCellMerge(c,p)[1]);else if(i==="left"||i==="right")for(let p=a;p<=c;p+=1)i==="left"&&(setStyleBorder.call(this,p,l,{left:[e,s]}),p+=o.getCellMerge(p,l)[0]),i==="right"&&(setStyleBorder.call(this,p,d,{right:[e,s]}),p+=o.getCellMerge(p,d)[0])}else setStyleBorder.call(this,a,l,{top:[e,s],bottom:[e,s],left:[e,s],right:[e,s]})}function getCellRowByY(i,e){const{rows:s}=this,n=this.freezeTotalHeight();let r=s.height;n+s.height<i&&(r-=e);const o=this.exceptRowSet;let a=0,l=r,{height:c}=s;for(;a<s.len&&!(l>i);a+=1)o.has(a)||(c=s.getHeight(a),l+=c);return l-=c,l<=0?{ri:-1,top:0,height:c}:{ri:a-1,top:l,height:c}}function getCellColByX(i,e){const{cols:s}=this,n=this.freezeTotalWidth();let r=s.indexWidth;n+s.indexWidth<i&&(r-=e);const[o,a,l]=helper_rslib_entry_.rangeReduceIf(0,s.len,r,s.indexWidth,i,c=>s.getWidth(c));return a<=0?{ci:-1,left:0,width:s.indexWidth}:{ci:o-1,left:a,width:l}}class DataProxy{constructor(e,s){this.settings=helper_rslib_entry_.merge(defaultSettings,s||{}),this.name=e||"sheet",this.freeze=[0,0],this.styles=[],this.merges=new Merges,this.rows=new Rows(this.settings.row),this.cols=new Cols(this.settings.col),this.validations=new Validations,this.hyperlinks={},this.comments={},this.selector=new Selector$1,this.scroll=new Scroll,this.history=new History,this.clipboard=new Clipboard,this.autoFilter=new AutoFilter,this.change=()=>{},this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map}addValidation(e,s,n){this.changeData(()=>{this.validations.add(e,s,n)})}removeValidation(){const{range:e}=this.selector;this.changeData(()=>{this.validations.remove(e)})}getSelectedValidator(){const{ri:e,ci:s}=this.selector,n=this.validations.get(e,s);return n?n.validator:null}getSelectedValidation(){const{ri:e,ci:s,range:n}=this.selector,r=this.validations.get(e,s),o={ref:n.toString()};return r!==null&&(o.mode=r.mode,o.validator=r.validator),o}canUndo(){return this.history.canUndo()}canRedo(){return this.history.canRedo()}undo(){this.history.undo(this.getData(),e=>{this.setData(e)})}redo(){this.history.redo(this.getData(),e=>{this.setData(e)})}copy(){this.clipboard.copy(this.selector.range)}copyToSystemClipboard(e){let s=[];const{sri:n,eri:r,sci:o,eci:a}=this.selector.range;for(let l=n;l<=r;l+=1){const c=[];for(let d=o;d<=a;d+=1){const u=this.getCell(l,d);c.push(u&&u.text||"")}s.push(c)}s=s.map(l=>l.join(" ")).join(`
3
- `),e&&(e.clipboardData.clearData(),e.clipboardData.setData("text/plain",s),e.preventDefault()),navigator.clipboard&&navigator.clipboard.writeText(s).then(()=>{},l=>{console.log("text copy to the system clipboard error ",s,l)})}cut(){this.clipboard.cut(this.selector.range)}paste(e="all",s=()=>{}){const{clipboard:n,selector:r}=this;return n.isClear()||!canPaste.call(this,n.range,r.range,s)?!1:(this.changeData(()=>{n.isCopy()?copyPaste.call(this,n.range,r.range,e):n.isCut()&&cutPaste.call(this,n.range,r.range)}),!0)}pasteFromSystemClipboard(e,s){const{selector:n}=this;navigator.clipboard.readText().then(r=>{const o=this.parseClipboardContent(r);let a=n.ri;o.forEach(l=>{let c=n.ci;l.forEach(d=>{this.setCellText(a,c,d,"input"),c+=1}),a+=1}),e(),s(this.rows.getData())})}parseClipboardContent(e){const s=[],n=e.split(`
4
- `);let r=0;return n.forEach(o=>{s[r]=o.split(" "),r+=1}),s}pasteFromText(e){let s=[];if(s=/\r\n/.test(e)?e.split(`\r
5
- `).map(n=>n.replace(/"/g,"").split(" ")):e.split(`
6
- `).map(n=>n.replace(/"/g,"").split(" ")),s.length){const{rows:n,selector:r}=this;this.changeData(()=>{n.paste(s,r.range)})}}autofill(e,s,n=()=>{}){const r=this.selector.range;return canPaste.call(this,r,e,n)?(this.changeData(()=>{copyPaste.call(this,r,e,s,!0)}),!0):!1}clearClipboard(){this.clipboard.clear()}calSelectedRangeByEnd(e,s){const{selector:n,rows:r,cols:o,merges:a}=this;let{sri:l,sci:c,eri:d,eci:u}=n.range;const p=n.ri,m=n.ci;let[f,g]=[e,s];return e<0&&(f=r.len-1),s<0&&(g=o.len-1),f>p?[l,d]=[p,f]:[l,d]=[f,p],g>m?[c,u]=[m,g]:[c,u]=[g,m],n.range=a.union(new CellRange(l,c,d,u)),n.range=a.union(n.range),n.range}calSelectedRangeByStart(e,s){const{selector:n,rows:r,cols:o,merges:a}=this;let l=a.getFirstIncludes(e,s);return l===null&&(l=new CellRange(e,s,e,s),e===-1&&(l.sri=0,l.eri=r.len-1),s===-1&&(l.sci=0,l.eci=o.len-1)),n.range=l,l}setSelectedCellAttr(e,s){this.changeData(()=>{const{selector:n,styles:r,rows:o}=this;if(e==="merge")s?this.merge():this.unmerge();else if(e==="border")setStyleBorders.call(this,s);else if(e==="formula"){const{ri:a,ci:l,range:c}=n;if(n.multiple()){const[d,u]=n.size(),{sri:p,sci:m,eri:f,eci:g}=c;if(d>1)for(let x=m;x<=g;x+=1){const y=o.getCellOrNew(f+1,x);y.text=`=${s}(${xy2expr(x,p)}:${xy2expr(x,f)})`}else if(u>1){const x=o.getCellOrNew(a,g+1);x.text=`=${s}(${xy2expr(m,a)}:${xy2expr(g,a)})`}}else{const d=o.getCellOrNew(a,l);d.text=`=${s}()`}}else n.range.each((a,l)=>{const c=o.getCellOrNew(a,l);let d={};if(c.style!==void 0&&(d=helper_rslib_entry_.cloneDeep(r[c.style])),e==="format")d.format=s,c.style=this.addStyle(d);else if(e==="font-bold"||e==="font-italic"||e==="font-name"||e==="font-size"){const u={};u[e.split("-")[1]]=s,d.font=Object.assign(d.font||{},u),c.style=this.addStyle(d)}else e==="strike"||e==="textwrap"||e==="underline"||e==="align"||e==="valign"||e==="color"||e==="bgcolor"?(d[e]=s,c.style=this.addStyle(d)):c[e]=s})})}setSelectedCellText(e,s="input"){const{autoFilter:n,selector:r,rows:o}=this,{ri:a,ci:l}=r;let c=a;this.unsortedRowMap.has(a)&&(c=this.unsortedRowMap.get(a));const d=o.getCell(c,l),u=d?d.text:"";if(this.setCellText(c,l,e,s),n.active()){const p=n.getFilter(l);if(p){const m=p.value.findIndex(f=>f===u);m>=0&&p.value.splice(m,1,e)}}}getSelectedCell(){const{ri:e,ci:s}=this.selector;let n=e;return this.unsortedRowMap.has(e)&&(n=this.unsortedRowMap.get(e)),this.rows.getCell(n,s)}xyInSelectedRect(e,s){const{left:n,top:r,width:o,height:a}=this.getSelectedRect(),l=e-this.cols.indexWidth,c=s-this.rows.height;return l>n&&l<n+o&&c>r&&c<r+a}getSelectedRect(){return this.getRect(this.selector.range)}getClipboardRect(){const{clipboard:e}=this;return e.isClear()?{left:-100,top:-100}:this.getRect(e.range)}getRect(e){const{scroll:s,rows:n,cols:r,exceptRowSet:o}=this,{sri:a,sci:l,eri:c,eci:d}=e;if(a<0&&l<0)return{left:0,l:0,top:0,t:0,scroll:s};const u=r.sumWidth(0,l),p=n.sumHeight(0,a,o),m=n.sumHeight(a,c+1,o),f=r.sumWidth(l,d+1);let g=u-s.x,x=p-s.y;const y=this.freezeTotalHeight(),E=this.freezeTotalWidth();return E>0&&E>u&&(g=u),y>0&&y>p&&(x=p),{l:u,t:p,left:g,top:x,height:m,width:f,scroll:s}}getCellRectByXY(e,s){const{scroll:n,merges:r,rows:o,cols:a}=this;let{ri:l,top:c,height:d}=getCellRowByY.call(this,s,n.y),{ci:u,left:p,width:m}=getCellColByX.call(this,e,n.x);if(u===-1&&(m=a.totalWidth()),l===-1&&(d=o.totalHeight()),l>=0||u>=0){const f=r.getFirstIncludes(l,u);f&&(l=f.sri,u=f.sci,{left:p,top:c,width:m,height:d}=this.cellRect(l,u))}return{ri:l,ci:u,left:p,top:c,width:m,height:d}}isSingleSelected(){const{sri:e,sci:s,eri:n,eci:r}=this.selector.range,o=this.getCell(e,s);if(o&&o.merge){const[a,l]=o.merge;if(e+a===n&&s+l===r)return!0}return!this.selector.multiple()}canUnmerge(){const{sri:e,sci:s,eri:n,eci:r}=this.selector.range,o=this.getCell(e,s);if(o&&o.merge){const[a,l]=o.merge;if(e+a===n&&s+l===r)return!0}return!1}merge(){const{selector:e,rows:s}=this;if(this.isSingleSelected())return;const[n,r]=e.size();if(n>1||r>1){const{sri:o,sci:a}=e.range;this.changeData(()=>{const l=s.getCellOrNew(o,a);l.merge=[n-1,r-1],this.merges.add(e.range),this.rows.deleteCells(e.range),this.rows.setCell(o,a,l)})}}unmerge(){const{selector:e}=this;if(!this.isSingleSelected())return;const{sri:s,sci:n}=e.range;this.changeData(()=>{this.rows.deleteCell(s,n,"merge"),this.merges.deleteWithin(e.range)})}canAutofilter(){return!this.autoFilter.active()}autofilter(){const{autoFilter:e,selector:s}=this;this.changeData(()=>{e.active()?(e.clear(),this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map):e.ref=s.range.toString()})}setAutoFilter(e,s,n,r){const{autoFilter:o}=this;o.addFilter(e,n,r),o.setSort(e,s),this.resetAutoFilter()}resetAutoFilter(){const{autoFilter:e,rows:s}=this;if(!e.active())return;const{sort:n}=e,{rset:r,fset:o}=e.filteredRows((c,d)=>s.getCell(c,d)),a=Array.from(o),l=Array.from(o);n&&a.sort((c,d)=>n.order==="asc"?c-d:n.order==="desc"?d-c:0),this.exceptRowSet=r,this.sortedRowMap=new Map,this.unsortedRowMap=new Map,a.forEach((c,d)=>{this.sortedRowMap.set(l[d],c),this.unsortedRowMap.set(c,l[d])})}deleteCell(e="all"){const{selector:s}=this;this.changeData(()=>{this.rows.deleteCells(s.range,e),(e==="all"||e==="format")&&this.merges.deleteWithin(s.range)})}insert(e,s=1){this.changeData(()=>{const{sri:n,sci:r}=this.selector.range,{rows:o,merges:a,cols:l}=this;let c=n;e==="row"?o.insert(n,s):e==="column"&&(o.insertColumn(r,s),c=r,l.len+=s,Object.keys(l._).reverse().forEach(d=>{const u=parseInt(d,10);u>=r&&(l._[u+s]=l._[u],delete l._[u])})),a.shift(e,c,s,(d,u,p,m)=>{const f=o.getCell(d,u);f.merge[0]+=p,f.merge[1]+=m})})}delete(e){this.changeData(()=>{const{rows:s,merges:n,selector:r,cols:o}=this,{range:a}=r,{sri:l,sci:c,eri:d,eci:u}=r.range,[p,m]=r.range.size();let f=l,g=p;e==="row"?s.delete(l,d):e==="column"&&(s.deleteColumn(c,u),f=a.sci,g=m,o.len-=u-c+1,Object.keys(o._).forEach(x=>{const y=parseInt(x,10);y>=c&&(y>u&&(o._[y-(u-c+1)]=o._[y]),delete o._[y])})),n.shift(e,f,-g,(x,y,E,b)=>{const v=s.getCell(x,y);v.merge[0]+=E,v.merge[1]+=b,v.merge[0]===0&&v.merge[1]===0&&delete v.merge})})}scrollx(e,s){const{scroll:n,freeze:r,cols:o}=this,[,a]=r,[l,c,d]=helper_rslib_entry_.rangeReduceIf(a,o.len,0,0,e,p=>o.getWidth(p));let u=c;e>0&&(u+=d),n.x!==u&&(n.ci=e>0?l:0,n.x=u,s())}scrolly(e,s){const{scroll:n,freeze:r,rows:o}=this,[a]=r,[l,c,d]=helper_rslib_entry_.rangeReduceIf(a,o.len,0,0,e,p=>o.getHeight(p));let u=c;e>0&&(u+=d),n.y!==u&&(n.ri=e>0?l:0,n.y=u,s())}cellRect(e,s){const{rows:n,cols:r}=this,o=r.sumWidth(0,s),a=n.sumHeight(0,e),l=n.getCell(e,s);let c=r.getWidth(s),d=n.getHeight(e);if(l!==null&&l.merge){const[u,p]=l.merge;if(u>0)for(let m=1;m<=u;m+=1)d+=n.getHeight(e+m);if(p>0)for(let m=1;m<=p;m+=1)c+=r.getWidth(s+m)}return{left:o,top:a,width:c,height:d,cell:l}}getCell(e,s){return this.rows.getCell(e,s)}getCellTextOrDefault(e,s){const n=this.getCell(e,s);return n&&n.text?n.text:""}getCellStyle(e,s){const n=this.getCell(e,s);return n&&n.style!==void 0?this.styles[n.style]:null}getCellStyleOrDefault(e,s){const{styles:n,rows:r}=this,o=r.getCell(e,s),a=o&&o.style!==void 0?n[o.style]:{};return helper_rslib_entry_.merge(this.defaultStyle(),a)}getSelectedCellStyle(){const{ri:e,ci:s}=this.selector;return this.getCellStyleOrDefault(e,s)}setCellText(e,s,n,r){const{rows:o,history:a,validations:l}=this;r==="finished"?(o.setCellText(e,s,""),a.add(this.getData()),o.setCellText(e,s,n)):(o.setCellText(e,s,n),this.change(this.getData())),l.validate(e,s,n)}freezeIsActive(){const[e,s]=this.freeze;return e>0||s>0}setFreeze(e,s){this.changeData(()=>{this.freeze=[e,s]})}freezeTotalWidth(){return this.cols.sumWidth(0,this.freeze[1])}freezeTotalHeight(){return this.rows.sumHeight(0,this.freeze[0])}setRowHeight(e,s){this.changeData(()=>{this.rows.setHeight(e,s)})}setColWidth(e,s){this.changeData(()=>{this.cols.setWidth(e,s)})}viewHeight(){const{view:e,showToolbar:s,showBottomBar:n}=this.settings;let r=e.height();return n&&(r-=bottombarHeight),s&&(r-=toolbarHeight),r}viewWidth(){return this.settings.view.width()}freezeViewRange(){const[e,s]=this.freeze;return new CellRange(0,0,e-1,s-1,this.freezeTotalWidth(),this.freezeTotalHeight())}contentRange(){const{rows:e,cols:s}=this,[n,r]=e.maxCell(),o=e.sumHeight(0,n+1),a=s.sumWidth(0,r+1);return new CellRange(0,0,n,r,a,o)}exceptRowTotalHeight(e,s){const{exceptRowSet:n,rows:r}=this,o=Array.from(n);let a=0;return o.forEach(l=>{if(l<e||l>s){const c=r.getHeight(l);a+=c}}),a}viewRange(){const{scroll:e,rows:s,cols:n,freeze:r,exceptRowSet:o}=this;let{ri:a,ci:l}=e;a<=0&&([a]=r),l<=0&&([,l]=r);let[c,d]=[0,0],[u,p]=[s.len,n.len];for(let m=a;m<s.len&&(o.has(m)||(d+=s.getHeight(m),u=m),!(d>this.viewHeight()));m+=1);for(let m=l;m<n.len&&(c+=n.getWidth(m),p=m,!(c>this.viewWidth()));m+=1);return new CellRange(a,l,u,p,c,d)}eachMergesInView(e,s){this.merges.filterIntersects(e).forEach(n=>s(n))}hideRowsOrCols(){const{rows:e,cols:s,selector:n}=this,[r,o]=n.size(),{sri:a,sci:l,eri:c,eci:d}=n.range;if(r===e.len)for(let u=l;u<=d;u+=1)s.setHide(u,!0);else if(o===s.len)for(let u=a;u<=c;u+=1)e.setHide(u,!0)}unhideRowsOrCols(e,s){this[`${e}s`].unhide(s)}rowEach(e,s,n){let r=0;const{rows:o}=this,a=this.exceptRowSet,l=[...a];let c=0;for(let d=0;d<l.length;d+=1)l[d]<e&&(c+=1);for(let d=e+c;d<=s+c;d+=1)if(a.has(d))c+=1;else{const u=o.getHeight(d);if(u>0&&(n(d,r,u),r+=u,r>this.viewHeight()))break}}colEach(e,s,n){let r=0;const{cols:o}=this;for(let a=e;a<=s;a+=1){const l=o.getWidth(a);if(l>0&&(n(a,r,l),r+=l,r>this.viewWidth()))break}}defaultStyle(){return this.settings.style}addStyle(e){const{styles:s}=this;for(let n=0;n<s.length;n+=1){const r=s[n];if(helper_rslib_entry_.equals(r,e))return n}return s.push(e),s.length-1}changeData(e){this.history.add(this.getData()),e(),this.change(this.getData())}setData(e){return Object.keys(e).forEach(s=>{if(s==="merges"||s==="rows"||s==="cols"||s==="validations")this[s].setData(e[s]);else if(s==="freeze"){const[n,r]=expr2xy(e[s]);this.freeze=[r,n]}else s==="autofilter"?this.autoFilter.setData(e[s]):e[s]!==void 0&&(this[s]=e[s])}),this}getData(){const{name:e,freeze:s,styles:n,merges:r,rows:o,cols:a,validations:l,autoFilter:c}=this;return{name:e,freeze:xy2expr(s[1],s[0]),styles:n,merges:r.getData(),rows:o.getData(),cols:a.getData(),validations:l.getData(),autofilter:c.getData()}}}function bind(i,e,s){i.addEventListener(e,s)}function unbind(i,e,s){i.removeEventListener(e,s)}function unbindClickoutside(i){i.xclickoutside&&(unbind(window.document.body,"click",i.xclickoutside),delete i.xclickoutside)}function bindClickoutside(i,e){i.xclickoutside=s=>{s.detail===2||i.contains(s.target)||(e?e(i):(i.hide(),unbindClickoutside(i)))},bind(window.document.body,"click",i.xclickoutside)}function mouseMoveUp(i,e,s){bind(i,"mousemove",e);const n=i;n.xEvtUp=r=>{unbind(i,"mousemove",e),unbind(i,"mouseup",i.xEvtUp),s(r)},bind(i,"mouseup",i.xEvtUp)}function calTouchDirection(i,e,s,n){let r="";Math.abs(i)>Math.abs(e)?(r=i>0?"right":"left",n(r,i,s)):(r=e>0?"down":"up",n(r,e,s))}function bindTouch(i,{move:e,end:s}){let n=0,r=0;bind(i,"touchstart",o=>{const{pageX:a,pageY:l}=o.touches[0];n=a,r=l}),bind(i,"touchmove",o=>{if(!e)return;const{pageX:a,pageY:l}=o.changedTouches[0],c=a-n,d=l-r;(Math.abs(c)>10||Math.abs(d)>10)&&(calTouchDirection(c,d,o,e),n=a,r=l),o.preventDefault()}),bind(i,"touchend",o=>{if(!s)return;const{pageX:a,pageY:l}=o.changedTouches[0],c=a-n,d=l-r;calTouchDirection(c,d,o,s)})}function createEventEmitter(){const i=new Map;function e(a,l){const c=()=>{const u=i.get(a);return Array.isArray(u)&&u.push(l)||!1},d=()=>i.set(a,[].concat(l));return i.has(a)&&c()||d()}function s(a,l){const c=()=>{const d=i.get(a);for(const u of d)u.call(null,...l)};return i.has(a)&&c()}function n(a,l){const c=()=>{const d=i.get(a),u=d.indexOf(l);return u>=0&&d.splice(u,1)&&i.get(a).length===0&&i.delete(a)};return i.has(a)&&c()}function r(a,l){const c=(...d)=>{l.call(null,...d),n(a,c)};return e(a,c)}function o(){i.clear()}return{get current(){return i},on:e,once:r,fire:s,removeListener:n,removeAllListeners:o}}const cssPrefix="x-spreadsheet";class Resizer{constructor(e=!1,s){this.moving=!1,this.vertical=e,this.el=h("div",`${cssPrefix}-resizer ${e?"vertical":"horizontal"}`).children(this.unhideHoverEl=h("div",`${cssPrefix}-resizer-hover`).on("dblclick.stop",n=>this.mousedblclickHandler(n)).css("position","absolute").hide(),this.hoverEl=h("div",`${cssPrefix}-resizer-hover`).on("mousedown.stop",n=>this.mousedownHandler(n)),this.lineEl=h("div",`${cssPrefix}-resizer-line`).hide()).hide(),this.cRect=null,this.finishedFn=null,this.minDistance=s,this.unhideFn=()=>{}}showUnhide(e){this.unhideIndex=e,this.unhideHoverEl.show()}hideUnhide(){this.unhideHoverEl.hide()}show(e,s){const{moving:n,vertical:r,hoverEl:o,lineEl:a,el:l,unhideHoverEl:c}=this;if(n)return;this.cRect=e;const{left:d,top:u,width:p,height:m}=e;l.offset({left:r?d+p-5:d,top:r?u:u+m-5}).show(),o.offset({width:r?5:p,height:r?m:5}),a.offset({width:r?0:s.width,height:r?s.height:0}),c.offset({left:r?5-p:d,top:r?u:5-m,width:r?5:p,height:r?m:5})}hide(){this.el.offset({left:0,top:0}).hide(),this.hideUnhide()}mousedblclickHandler(){this.unhideIndex&&this.unhideFn(this.unhideIndex)}mousedownHandler(e){let s=e;const{el:n,lineEl:r,cRect:o,vertical:a,minDistance:l}=this;let c=a?o.width:o.height;r.show(),mouseMoveUp(window,d=>{this.moving=!0,s!==null&&d.buttons===1&&(a?(c+=d.movementX,c>l&&n.css("left",`${o.left+c}px`)):(c+=d.movementY,c>l&&n.css("top",`${o.top+c}px`)),s=d)},()=>{s=null,r.hide(),this.moving=!1,this.hide(),this.finishedFn&&(c<l&&(c=l),this.finishedFn(o,c))})}}class Scrollbar{constructor(e){this.vertical=e,this.moveFn=null,this.el=h("div",`${cssPrefix}-scrollbar ${e?"vertical":"horizontal"}`).child(this.contentEl=h("div","")).on("mousemove.stop",()=>{}).on("scroll.stop",s=>{const{scrollTop:n,scrollLeft:r}=s.target;this.moveFn&&this.moveFn(this.vertical?n:r,s)})}move(e){return this.el.scroll(e),this}scroll(){return this.el.scroll()}set(e,s){const n=e-1;if(s>n){const r=this.vertical?"height":"width";this.el.css(r,`${n-15}px`).show(),this.contentEl.css(this.vertical?"width":"height","1px").css(r,`${s}px`)}else this.el.hide();return this}}const selectorHeightBorderWidth=3;let startZIndex=10;class SelectorElement{constructor(e=!1,s=!0){this.useHideInput=e,this.autoFocus=s,this.inputChange=()=>{},this.cornerEl=h("div",`${cssPrefix}-selector-corner`),this.areaEl=h("div",`${cssPrefix}-selector-area`).child(this.cornerEl).hide(),this.clipboardEl=h("div",`${cssPrefix}-selector-clipboard`).hide(),this.autofillEl=h("div",`${cssPrefix}-selector-autofill`).hide(),this.el=h("div",`${cssPrefix}-selector`).css("z-index",`${startZIndex}`).children(this.areaEl,this.clipboardEl,this.autofillEl).hide(),e&&(this.hideInput=h("input","").on("compositionend",n=>{this.inputChange(n.target.value)}),this.el.child(this.hideInputDiv=h("div","hide-input").child(this.hideInput)),this.el.child(this.hideInputDiv=h("div","hide-input").child(this.hideInput))),startZIndex+=1}setOffset(e){return this.el.offset(e).show(),this}hide(){return this.el.hide(),this}setAreaOffset(e){const{left:s,top:n,width:r,height:o}=e,a={width:r-selectorHeightBorderWidth+.8,height:o-selectorHeightBorderWidth+.8,left:s-.8,top:n-.8};this.areaEl.offset(a).show(),this.useHideInput&&(this.hideInputDiv.offset(a),this.autoFocus?this.hideInput.val("").focus():this.hideInput.val(""))}setClipboardOffset(e){const{left:s,top:n,width:r,height:o}=e;this.clipboardEl.offset({left:s,top:n,width:r-5,height:o-5})}showAutofill(e){const{left:s,top:n,width:r,height:o}=e;this.autofillEl.offset({width:r-selectorHeightBorderWidth,height:o-selectorHeightBorderWidth,left:s,top:n}).show()}hideAutofill(){this.autofillEl.hide()}showClipboard(){this.clipboardEl.show()}hideClipboard(){this.clipboardEl.hide()}}function calBRAreaOffset(i){const{data:e}=this,{left:s,top:n,width:r,height:o,scroll:a,l,t:c}=i,d=e.freezeTotalWidth(),u=e.freezeTotalHeight();let p=s-d;d>l&&(p-=a.x);let m=n-u;return u>c&&(m-=a.y),{left:p,top:m,width:r,height:o}}function calTAreaOffset(i){const{data:e}=this,{left:s,width:n,height:r,l:o,t:a,scroll:l}=i,c=e.freezeTotalWidth();let d=s-c;return c>o&&(d-=l.x),{left:d,top:a,width:n,height:r}}function calLAreaOffset(i){const{data:e}=this,{top:s,width:n,height:r,l:o,t:a,scroll:l}=i,c=e.freezeTotalHeight();let d=s-c;return c>a&&(d-=l.y),{left:o,top:d,width:n,height:r}}function setBRAreaOffset(i){const{br:e}=this;e.setAreaOffset(calBRAreaOffset.call(this,i))}function setTLAreaOffset(i){const{tl:e}=this;e.setAreaOffset(i)}function setTAreaOffset(i){const{t:e}=this;e.setAreaOffset(calTAreaOffset.call(this,i))}function setLAreaOffset(i){const{l:e}=this;e.setAreaOffset(calLAreaOffset.call(this,i))}function setLClipboardOffset(i){const{l:e}=this;e.setClipboardOffset(calLAreaOffset.call(this,i))}function setBRClipboardOffset(i){const{br:e}=this;e.setClipboardOffset(calBRAreaOffset.call(this,i))}function setTLClipboardOffset(i){const{tl:e}=this;e.setClipboardOffset(i)}function setTClipboardOffset(i){const{t:e}=this;e.setClipboardOffset(calTAreaOffset.call(this,i))}function setAllAreaOffset(i){setBRAreaOffset.call(this,i),setTLAreaOffset.call(this,i),setTAreaOffset.call(this,i),setLAreaOffset.call(this,i)}function setAllClipboardOffset(i){setBRClipboardOffset.call(this,i),setTLClipboardOffset.call(this,i),setTClipboardOffset.call(this,i),setLClipboardOffset.call(this,i)}class Selector{constructor(e){const{autoFocus:s}=e.settings;this.inputChange=()=>{},this.data=e,this.br=new SelectorElement(!0,s),this.t=new SelectorElement,this.l=new SelectorElement,this.tl=new SelectorElement,this.br.inputChange=n=>{this.inputChange(n)},this.br.el.show(),this.offset=null,this.areaOffset=null,this.indexes=null,this.range=null,this.arange=null,this.el=h("div",`${cssPrefix}-selectors`).children(this.tl.el,this.t.el,this.l.el,this.br.el).hide(),this.lastri=-1,this.lastci=-1,startZIndex+=1}resetData(e){this.data=e,this.range=e.selector.range,this.resetAreaOffset()}hide(){this.el.hide()}resetOffset(){const{data:e,tl:s,t:n,l:r,br:o}=this,a=e.freezeTotalHeight(),l=e.freezeTotalWidth();a>0||l>0?(s.setOffset({width:l,height:a}),n.setOffset({left:l,height:a}),r.setOffset({top:a,width:l}),o.setOffset({left:l,top:a})):(s.hide(),n.hide(),r.hide(),o.setOffset({left:0,top:0}))}resetAreaOffset(){const e=this.data.getSelectedRect(),s=this.data.getClipboardRect();setAllAreaOffset.call(this,e),setAllClipboardOffset.call(this,s),this.resetOffset()}resetBRTAreaOffset(){const e=this.data.getSelectedRect(),s=this.data.getClipboardRect();setBRAreaOffset.call(this,e),setTAreaOffset.call(this,e),setBRClipboardOffset.call(this,s),setTClipboardOffset.call(this,s),this.resetOffset()}resetBRLAreaOffset(){const e=this.data.getSelectedRect(),s=this.data.getClipboardRect();setBRAreaOffset.call(this,e),setLAreaOffset.call(this,e),setBRClipboardOffset.call(this,s),setLClipboardOffset.call(this,s),this.resetOffset()}set(e,s,n=!0){const{data:r}=this,o=r.calSelectedRangeByStart(e,s),{sri:a,sci:l}=o;if(n){let[c,d]=[e,s];e<0&&(c=0),s<0&&(d=0),r.selector.setIndexes(c,d),this.indexes=[c,d]}this.moveIndexes=[a,l],this.range=o,this.resetAreaOffset(),this.el.show()}setEnd(e,s,n=!0){const{data:r,lastri:o,lastci:a}=this;if(n){if(e===o&&s===a)return;this.lastri=e,this.lastci=s}this.range=r.calSelectedRangeByEnd(e,s),setAllAreaOffset.call(this,this.data.getSelectedRect())}reset(){const{eri:e,eci:s}=this.data.selector.range;this.setEnd(e,s)}showAutofill(e,s){if(e===-1&&s===-1)return;const{sri:n,sci:r,eri:o,eci:a}=this.range,[l,c]=[e,s],d=n-e,u=r-s,p=o-e,m=a-s;if(u>0)this.arange=new CellRange(n,c,o,r-1);else if(d>0)this.arange=new CellRange(l,r,n-1,a);else if(m<0)this.arange=new CellRange(n,a+1,o,c);else if(p<0)this.arange=new CellRange(o+1,r,l,a);else{this.arange=null;return}if(this.arange!==null){const f=this.data.getRect(this.arange);f.width+=2,f.height+=2;const{br:g,l:x,t:y,tl:E}=this;g.showAutofill(calBRAreaOffset.call(this,f)),x.showAutofill(calLAreaOffset.call(this,f)),y.showAutofill(calTAreaOffset.call(this,f)),E.showAutofill(f)}}hideAutofill(){["br","l","t","tl"].forEach(e=>{this[e].hideAutofill()})}showClipboard(){const e=this.data.getClipboardRect();setAllClipboardOffset.call(this,e),["br","l","t","tl"].forEach(s=>{this[s].showClipboard()})}hideClipboard(){["br","l","t","tl"].forEach(e=>{this[e].hideClipboard()})}}function inputMovePrev(i){i.preventDefault(),i.stopPropagation();const{filterItems:e}=this;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex-=1,this.itemIndex<0&&(this.itemIndex=e.length-1),e[this.itemIndex].toggle())}function inputMoveNext(i){i.stopPropagation();const{filterItems:e}=this;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex+=1,this.itemIndex>e.length-1&&(this.itemIndex=0),e[this.itemIndex].toggle())}function inputEnter(i){i.preventDefault();const{filterItems:e}=this;e.length<=0||(i.stopPropagation(),this.itemIndex<0&&(this.itemIndex=0),e[this.itemIndex].el.click(),this.hide())}function inputKeydownHandler(i){const{keyCode:e}=i;switch(i.ctrlKey&&i.stopPropagation(),e){case 37:i.stopPropagation();break;case 38:inputMovePrev.call(this,i);break;case 39:i.stopPropagation();break;case 40:inputMoveNext.call(this,i);break;case 13:inputEnter.call(this,i);break;case 9:inputEnter.call(this,i);break;default:i.stopPropagation();break}}class Suggest{constructor(e,s,n="200px"){this.filterItems=[],this.items=e,this.el=h("div",`${cssPrefix}-suggest`).css("width",n).hide(),this.itemClick=s,this.itemIndex=-1}setOffset(e){this.el.cssRemoveKeys("top","bottom").offset(e)}hide(){const{el:e}=this;this.filterItems=[],this.itemIndex=-1,e.hide(),unbindClickoutside(this.el.parent())}setItems(e){this.items=e}search(e){let{items:s}=this;if(/^\s*$/.test(e)||(s=s.filter(r=>(r.key||r).startsWith(e.toUpperCase()))),s=s.map(r=>{let{title:o}=r;o?typeof o=="function"&&(o=o()):o=r;const a=h("div",`${cssPrefix}-item`).child(o).on("click.stop",()=>{this.itemClick(r),this.hide()});return r.label&&a.child(h("div","label").html(r.label)),a}),this.filterItems=s,s.length<=0)return;const{el:n}=this;n.html("").children(...s).show(),bindClickoutside(n.parent(),()=>{this.hide()})}bindInputEvents(e){e.on("keydown",s=>inputKeydownHandler.call(this,s))}}class Icon extends Element{constructor(e){super("div",`${cssPrefix}-icon`),this.iconNameEl=h("div",`${cssPrefix}-icon-img ${e}`),this.child(this.iconNameEl)}setName(e){this.iconNameEl.className(`${cssPrefix}-icon-img ${e}`)}}function addMonth(i,e){i.setMonth(i.getMonth()+e)}function weekday(i,e){const s=new Date(i);return s.setDate(e-i.getDay()+1),s}function monthDays(i,e,s){const n=new Date(i,e,1,23,59,59),r=[[],[],[],[],[],[]];for(let o=0;o<6;o+=1)for(let a=0;a<7;a+=1){const l=7*o+a,c=weekday(n,l),d=c.getMonth()!==e,u=c.getMonth()===s.getMonth()&&c.getDate()===s.getDate();r[o][a]={d:c,disabled:d,active:u}}return r}class Calendar{constructor(e){this.value=e,this.cvalue=new Date(e),this.headerLeftEl=h("div","calendar-header-left"),this.bodyEl=h("tbody",""),this.buildAll(),this.el=h("div","x-spreadsheet-calendar").children(h("div","calendar-header").children(this.headerLeftEl,h("div","calendar-header-right").children(h("a","calendar-prev").on("click.stop",()=>this.prev()).child(new Icon("chevron-left")),h("a","calendar-next").on("click.stop",()=>this.next()).child(new Icon("chevron-right")))),h("table","calendar-body").children(h("thead","").child(h("tr","").children(...t("calendar.weeks").map(s=>h("th","cell").child(s)))),this.bodyEl)),this.selectChange=()=>{}}setValue(e){this.value=e,this.cvalue=new Date(e),this.buildAll()}prev(){const{value:e}=this;addMonth(e,-1),this.buildAll()}next(){const{value:e}=this;addMonth(e,1),this.buildAll()}buildAll(){this.buildHeaderLeft(),this.buildBody()}buildHeaderLeft(){const{value:e}=this;this.headerLeftEl.html(`${t("calendar.months")[e.getMonth()]} ${e.getFullYear()}`)}buildBody(){const{value:e,cvalue:s,bodyEl:n}=this,o=monthDays(e.getFullYear(),e.getMonth(),s).map(a=>{const l=a.map(c=>{let d="cell";return c.disabled&&(d+=" disabled"),c.active&&(d+=" active"),h("td","").child(h("div",d).on("click.stop",()=>{this.selectChange(c.d)}).child(c.d.getDate().toString()))});return h("tr","").children(...l)});n.html("").children(...o)}}class Datepicker{constructor(){this.calendar=new Calendar(new Date),this.el=h("div",`${cssPrefix}-datepicker`).child(this.calendar.el).hide()}setValue(e){const{calendar:s}=this;return typeof e=="string"?/^\d{4}-\d{1,2}-\d{1,2}$/.test(e)&&s.setValue(new Date(e.replace(new RegExp("-","g"),"/"))):e instanceof Date&&s.setValue(e),this}change(e){this.calendar.selectChange=s=>{e(s),this.hide()}}show(){this.el.show()}hide(){this.el.hide()}}function resetTextareaSize(){const{inputText:i}=this;if(!/^\s*$/.test(i)){const{textlineEl:e,textEl:s,areaOffset:n}=this,r=i.split(`
7
- `),o=Math.max(...r.map(p=>p.length)),l=e.offset().width/i.length,c=(o+1)*l+5,d=this.viewFn().width-n.left-l;let u=r.length;if(c>n.width){let p=c;c>d&&(p=d,u+=parseInt(c/d,10),u+=c%d>0?1:0),s.css("width",`${p}px`)}u*=this.rowHeight,u>n.height&&s.css("height",`${u}px`)}}function insertText({target:i},e){const{value:s,selectionEnd:n}=i,r=`${s.slice(0,n)}${e}${s.slice(n)}`;i.value=r,i.setSelectionRange(n+1,n+1),this.inputText=r,this.textlineEl.html(r),resetTextareaSize.call(this)}function keydownEventHandler(i){const{keyCode:e,altKey:s}=i;e!==13&&e!==9&&i.stopPropagation(),e===13&&s&&(insertText.call(this,i,`
8
- `),i.stopPropagation()),e===13&&!s&&i.preventDefault()}function inputEventHandler(i){const e=i.target.value,{suggest:s,textlineEl:n,validator:r}=this,{cell:o}=this;if(o!==null)if("editable"in o&&o.editable===!0||o.editable===void 0){if(this.inputText=e,r)r.type==="list"?s.search(e):s.hide();else{const a=e.lastIndexOf("=");a!==-1?s.search(e.substring(a+1)):s.hide()}n.html(e),resetTextareaSize.call(this),this.change("input",e)}else i.target.value=o.text||"";else{if(this.inputText=e,r)r.type==="list"?s.search(e):s.hide();else{const a=e.lastIndexOf("=");a!==-1?s.search(e.substring(a+1)):s.hide()}n.html(e),resetTextareaSize.call(this),this.change("input",e)}}function setTextareaRange(i){const{el:e}=this.textEl;setTimeout(()=>{e.focus(),e.setSelectionRange(i,i)},0)}function setText(i,e){const{textEl:s,textlineEl:n}=this;s.el.blur(),s.val(i),n.html(i),setTextareaRange.call(this,e)}function suggestItemClick(i){const{inputText:e,validator:s}=this;let n=0;if(s&&s.type==="list")this.inputText=i,n=this.inputText.length;else{const r=e.lastIndexOf("="),o=e.substring(0,r+1);let a=e.substring(r+1);a=a.indexOf(")")!==-1?a.substring(a.indexOf(")")):"",this.inputText=`${o+i.key}(`,n=this.inputText.length,this.inputText+=`)${a}`}setText.call(this,this.inputText,n)}function resetSuggestItems(){this.suggest.setItems(this.formulas)}function dateFormat(i){let e=i.getMonth()+1,s=i.getDate();return e<10&&(e=`0${e}`),s<10&&(s=`0${s}`),`${i.getFullYear()}-${e}-${s}`}class Editor{constructor(e,s,n){this.viewFn=s,this.rowHeight=n,this.formulas=e,this.suggest=new Suggest(e,r=>{suggestItemClick.call(this,r)}),this.datepicker=new Datepicker,this.datepicker.change(r=>{this.setText(dateFormat(r)),this.clear()}),this.areaEl=h("div",`${cssPrefix}-editor-area`).children(this.textEl=h("textarea","").on("input",r=>inputEventHandler.call(this,r)).on("paste.stop",()=>{}).on("keydown",r=>keydownEventHandler.call(this,r)),this.textlineEl=h("div","textline"),this.suggest.el,this.datepicker.el).on("mousemove.stop",()=>{}).on("mousedown.stop",()=>{}),this.el=h("div",`${cssPrefix}-editor`).child(this.areaEl).hide(),this.suggest.bindInputEvents(this.textEl),this.areaOffset=null,this.freeze={w:0,h:0},this.cell=null,this.inputText="",this.change=()=>{}}setFreezeLengths(e,s){this.freeze.w=e,this.freeze.h=s}clear(){this.inputText!==""&&this.change("finished",this.inputText),this.cell=null,this.areaOffset=null,this.inputText="",this.el.hide(),this.textEl.val(""),this.textlineEl.html(""),resetSuggestItems.call(this),this.datepicker.hide()}setOffset(e,s="top"){const{textEl:n,areaEl:r,suggest:o,freeze:a,el:l}=this;if(e){this.areaOffset=e;const{left:c,top:d,width:u,height:p,l:m,t:f}=e,g={left:0,top:0};a.w>m&&a.h>f||(a.w<m&&a.h<f?(g.left=a.w,g.top=a.h):a.w>m?g.top=a.h:a.h>f&&(g.left=a.w)),l.offset(g),r.offset({left:c-g.left-.8,top:d-g.top-.8}),n.offset({width:u-9+.8,height:p-3+.8});const x={left:0};x[s]=p,o.setOffset(x),o.hide()}}setCell(e,s){if(e&&e.editable===!1)return;const{el:n,datepicker:r,suggest:o}=this;n.show(),this.cell=e;const a=e&&e.text||"";if(this.setText(a),this.validator=s,s){const{type:l}=s;l==="date"&&(r.show(),/^\s*$/.test(a)||r.setValue(a)),l==="list"&&(o.setItems(s.values()),o.search(""))}}setText(e){this.inputText=e,setText.call(this,e,e.length),resetTextareaSize.call(this)}}class Button extends Element{constructor(e,s=""){super("div",`${cssPrefix}-button ${s}`),this.child(t(`button.${e}`))}}function dpr(){return window.devicePixelRatio||1}function thinLineWidth(){return dpr()-.5}function npx(i){return parseInt(i*dpr(),10)}function npxLine(i){const e=npx(i);return e>0?e-.5:.5}class DrawBox{constructor(e,s,n,r,o=0){this.x=e,this.y=s,this.width=n,this.height=r,this.padding=o,this.bgcolor="#ffffff",this.borderTop=null,this.borderRight=null,this.borderBottom=null,this.borderLeft=null}setBorders({top:e,bottom:s,left:n,right:r}){e&&(this.borderTop=e),r&&(this.borderRight=r),s&&(this.borderBottom=s),n&&(this.borderLeft=n)}innerWidth(){return this.width-2*this.padding-2}innerHeight(){return this.height-2*this.padding-2}textx(e){const{width:s,padding:n}=this;let{x:r}=this;return e==="left"?r+=n:e==="center"?r+=s/2:e==="right"&&(r+=s-n),r}texty(e,s){const{height:n,padding:r}=this;let{y:o}=this;return e==="top"?o+=r:e==="middle"?o+=n/2-s/2:e==="bottom"&&(o+=n-r-s),o}topxys(){const{x:e,y:s,width:n}=this;return[[e,s],[e+n,s]]}rightxys(){const{x:e,y:s,width:n,height:r}=this;return[[e+n,s],[e+n,s+r]]}bottomxys(){const{x:e,y:s,width:n,height:r}=this;return[[e,s+r],[e+n,s+r]]}leftxys(){const{x:e,y:s,height:n}=this;return[[e,s],[e,s+n]]}}function drawFontLine(i,e,s,n,r,o,a){const l={x:0,y:0};i==="underline"?r==="bottom"?l.y=0:r==="top"?l.y=-(o+2):l.y=-o/2:i==="strike"&&(r==="bottom"?l.y=o/2:r==="top"&&(l.y=-(o/2+2))),n==="center"?l.x=a/2:n==="right"&&(l.x=a),this.line([e-l.x,s-l.y],[e-l.x+a,s-l.y])}class Draw{constructor(e,s,n){this.el=e,this.ctx=e.getContext("2d"),this.resize(s,n),this.ctx.scale(dpr(),dpr())}resize(e,s){this.el.style.width=`${e}px`,this.el.style.height=`${s}px`,this.el.width=npx(e),this.el.height=npx(s)}clear(){const{width:e,height:s}=this.el;return this.ctx.clearRect(0,0,e,s),this}attr(e){return Object.assign(this.ctx,e),this}save(){return this.ctx.save(),this.ctx.beginPath(),this}restore(){return this.ctx.restore(),this}beginPath(){return this.ctx.beginPath(),this}translate(e,s){return this.ctx.translate(npx(e),npx(s)),this}scale(e,s){return this.ctx.scale(e,s),this}clearRect(e,s,n,r){return this.ctx.clearRect(e,s,n,r),this}fillRect(e,s,n,r){return this.ctx.fillRect(npx(e)-.5,npx(s)-.5,npx(n),npx(r)),this}fillText(e,s,n){return this.ctx.fillText(e,npx(s),npx(n)),this}text(e,s,n={},r=!0){const{ctx:o}=this,{align:a,valign:l,font:c,color:d,strike:u,underline:p}=n,m=s.textx(a);o.save(),o.beginPath(),this.attr({textAlign:a,textBaseline:l,font:`${c.italic?"italic":""} ${c.bold?"bold":""} ${npx(c.size)}px ${c.name}`,fillStyle:d,strokeStyle:d});const f=`${e}`.split(`
9
- `),g=s.innerWidth(),x=[];f.forEach(b=>{const v=o.measureText(b).width;if(r&&v>npx(g)){let A={w:0,len:0,start:0};for(let D=0;D<b.length;D+=1)A.w>=npx(g)&&(x.push(b.substr(A.start,A.len)),A={w:0,len:0,start:D}),A.len+=1,A.w+=o.measureText(b[D]).width+1;A.len>0&&x.push(b.substr(A.start,A.len))}else x.push(b)});const y=(x.length-1)*(c.size+2);let E=s.texty(l,y);return x.forEach(b=>{const v=o.measureText(b).width;this.fillText(b,m,E),u&&drawFontLine.call(this,"strike",m,E,a,l,c.size,v),p&&drawFontLine.call(this,"underline",m,E,a,l,c.size,v),E+=c.size+2}),o.restore(),this}border(e,s){const{ctx:n}=this;return n.lineWidth=thinLineWidth,n.strokeStyle=s,e==="medium"?n.lineWidth=npx(2)-.5:e==="thick"?n.lineWidth=npx(3):e==="dashed"?n.setLineDash([npx(3),npx(2)]):e==="dotted"?n.setLineDash([npx(1),npx(1)]):e==="double"&&n.setLineDash([npx(2),0]),this}line(...e){const{ctx:s}=this;if(e.length>1){s.beginPath();const[n,r]=e[0];s.moveTo(npxLine(n),npxLine(r));for(let o=1;o<e.length;o+=1){const[a,l]=e[o];s.lineTo(npxLine(a),npxLine(l))}s.stroke()}return this}strokeBorders(e){const{ctx:s}=this;s.save();const{borderTop:n,borderRight:r,borderBottom:o,borderLeft:a}=e;n&&(this.border(...n),this.line(...e.topxys())),r&&(this.border(...r),this.line(...e.rightxys())),o&&(this.border(...o),this.line(...e.bottomxys())),a&&(this.border(...a),this.line(...e.leftxys())),s.restore()}dropdown(e){const{ctx:s}=this,{x:n,y:r,width:o,height:a}=e,l=n+o-15,c=r+a-15;s.save(),s.beginPath(),s.moveTo(npx(l),npx(c)),s.lineTo(npx(l+8),npx(c)),s.lineTo(npx(l+4),npx(c+6)),s.closePath(),s.fillStyle="rgba(0, 0, 0, .45)",s.fill(),s.restore()}error(e){const{ctx:s}=this,{x:n,y:r,width:o}=e,a=n+o-1;s.save(),s.beginPath(),s.moveTo(npx(a-8),npx(r-1)),s.lineTo(npx(a),npx(r-1)),s.lineTo(npx(a),npx(r+8)),s.closePath(),s.fillStyle="rgba(255, 0, 0, .65)",s.fill(),s.restore()}frozen(e){const{ctx:s}=this,{x:n,y:r,width:o}=e,a=n+o-1;s.save(),s.beginPath(),s.moveTo(npx(a-8),npx(r-1)),s.lineTo(npx(a),npx(r-1)),s.lineTo(npx(a),npx(r+8)),s.closePath(),s.fillStyle="rgba(0, 255, 0, .85)",s.fill(),s.restore()}rect(e,s){const{ctx:n}=this,{x:r,y:o,width:a,height:l,bgcolor:c}=e;n.save(),n.beginPath(),n.fillStyle=c||"#fff",n.rect(npxLine(r+1),npxLine(o+1),npx(a-2),npx(l-2)),n.clip(),n.fill(),s(),n.restore()}}const baseFonts=[{key:"Arial",title:"Arial"},{key:"Helvetica",title:"Helvetica"},{key:"Source Sans Pro",title:"Source Sans Pro"},{key:"Comic Sans MS",title:"Comic Sans MS"},{key:"Courier New",title:"Courier New"},{key:"Verdana",title:"Verdana"},{key:"Lato",title:"Lato"}],fontSizes=[{pt:7.5,px:10},{pt:8,px:11},{pt:9,px:12},{pt:10,px:13},{pt:10.5,px:14},{pt:11,px:15},{pt:12,px:16},{pt:14,px:18.7},{pt:15,px:20},{pt:16,px:21.3},{pt:18,px:24},{pt:22,px:29.3},{pt:24,px:32},{pt:26,px:34.7},{pt:36,px:48},{pt:42,px:56}];function getFontSizePxByPt(i){for(let e=0;e<fontSizes.length;e+=1){const s=fontSizes[e];if(s.pt===i)return s.px}return i}const infixExprToSuffixExpr=i=>{const e=[],s=[];let n=[],r=0,o="",a=1,l="";for(let c=0;c<i.length;c+=1){const d=i.charAt(c);if(d!==" "){if(d>="a"&&d<="z")n.push(d.toUpperCase());else if(d>="0"&&d<="9"||d>="A"&&d<="Z"||d===".")n.push(d);else if(d==='"'){for(c+=1;i.charAt(c)!=='"';)n.push(i.charAt(c)),c+=1;s.push(`"${n.join("")}`),n=[]}else if(d==="-"&&/[+\-*/,(]/.test(l))n.push(d);else{if(d!=="("&&n.length>0&&s.push(n.join("")),d===")"){let u=e.pop();if(r===2)try{const[p,m]=expr2xy(s.pop()),[f,g]=expr2xy(s.pop());let x=0;for(let y=f;y<=p;y+=1)for(let E=g;E<=m;E+=1)s.push(xy2expr(y,E)),x+=1;s.push([u,x])}catch(p){}else if(r===1||r===3)r===3&&s.push(o),s.push([u,a]),a=1;else for(;u!=="("&&(s.push(u),!(e.length<=0));)u=e.pop();r=0}else if(d==="="||d===">"||d==="<"){const u=i.charAt(c+1);o=d,(u==="="||u==="-")&&(o+=u,c+=1),r=3}else if(d===":")r=2;else if(d===",")r===3&&s.push(o),r=1,a+=1;else if(d==="("&&n.length>0)e.push(n.join(""));else{if(e.length>0&&(d==="+"||d==="-")){let u=e[e.length-1];if(u!=="("&&s.push(e.pop()),u==="*"||u==="/")for(;e.length>0&&(u=e[e.length-1],u!=="(");)s.push(e.pop())}else if(e.length>0){const u=e[e.length-1];(u==="*"||u==="/")&&s.push(e.pop())}e.push(d)}n=[]}l=d}}for(n.length>0&&s.push(n.join(""));e.length>0;)s.push(e.pop());return s},evalSubExpr=(i,e)=>{const[s]=i;let n=i;if(s==='"')return i.substring(1);let r=1;if(s==="-"&&(n=i.substring(1),r=-1),n[0]>="0"&&n[0]<="9")return r*Number(n);const[o,a]=expr2xy(n);return r*e(o,a)},evalSuffixExpr=(i,e,s,n)=>{const r=[];for(let o=0;o<i.length;o+=1){const a=i[o],l=a[0];if(a==="+"){const c=r.pop();r.push(numberCalc("+",r.pop(),c))}else if(a==="-")if(r.length===1){const c=r.pop();r.push(numberCalc("*",c,-1))}else{const c=r.pop();r.push(numberCalc("-",r.pop(),c))}else if(a==="*")r.push(numberCalc("*",r.pop(),r.pop()));else if(a==="/"){const c=r.pop();r.push(numberCalc("/",r.pop(),c))}else if(l==="="||l===">"||l==="<"){let c=r.pop();Number.isNaN(c)||(c=Number(c));let d=r.pop();Number.isNaN(d)||(d=Number(d));let u=!1;l==="="?u=d===c:a===">"?u=d>c:a===">="?u=d>=c:a==="<"?u=d<c:a==="<="&&(u=d<=c),r.push(u)}else if(Array.isArray(a)){const[c,d]=a,u=[];for(let p=0;p<d;p+=1)u.push(r.pop());r.push(e[c].render(u.reverse()))}else{if(n.includes(a))return 0;(l>="a"&&l<="z"||l>="A"&&l<="Z")&&n.push(a),r.push(evalSubExpr(a,s)),n.pop()}}return r[0]},cell_rslib_entry_cellRender=(i,e,s,n=[])=>{if(i[0]==="="){const r=infixExprToSuffixExpr(i.substring(1));return r.length<=0?i:evalSuffixExpr(r,e,(o,a)=>cell_rslib_entry_cellRender(s(o,a),e,s,n),n)}return i},cell_rslib_entry_={render:cell_rslib_entry_cellRender},baseFormulas=[{key:"SUM",title:tf("formula.sum"),render:i=>i.reduce((e,s)=>numberCalc("+",e,s),0)},{key:"AVERAGE",title:tf("formula.average"),render:i=>i.reduce((e,s)=>Number(e)+Number(s),0)/i.length},{key:"MAX",title:tf("formula.max"),render:i=>Math.max(...i.map(e=>Number(e)))},{key:"MIN",title:tf("formula.min"),render:i=>Math.min(...i.map(e=>Number(e)))},{key:"IF",title:tf("formula._if"),render:([i,e,s])=>i?e:s},{key:"AND",title:tf("formula.and"),render:i=>i.every(e=>e)},{key:"OR",title:tf("formula.or"),render:i=>i.some(e=>e)},{key:"CONCAT",title:tf("formula.concat"),render:i=>i.join("")}],formulas=baseFormulas,formulam={};baseFormulas.forEach(i=>{formulam[i.key]=i});const formatStringRender=i=>i,formatNumberRender=i=>{if(/^(-?\d*.?\d*)$/.test(i)){const e=Number(i).toFixed(2).toString(),[s,...n]=e.split("\\.");return[s.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"),...n]}return i},baseFormats=[{key:"normal",title:tf("format.normal"),type:"string",render:formatStringRender},{key:"text",title:tf("format.text"),type:"string",render:formatStringRender},{key:"number",title:tf("format.number"),type:"number",label:"1,000.12",render:formatNumberRender},{key:"percent",title:tf("format.percent"),type:"number",label:"10.12%",render:i=>`${i}%`},{key:"rmb",title:tf("format.rmb"),type:"number",label:"¥10.00",render:i=>`¥${formatNumberRender(i)}`},{key:"usd",title:tf("format.usd"),type:"number",label:"$10.00",render:i=>`$${formatNumberRender(i)}`},{key:"eur",title:tf("format.eur"),type:"number",label:"€10.00",render:i=>`€${formatNumberRender(i)}`},{key:"date",title:tf("format.date"),type:"date",label:"26/09/2008",render:formatStringRender},{key:"time",title:tf("format.time"),type:"date",label:"15:59:00",render:formatStringRender},{key:"datetime",title:tf("format.datetime"),type:"date",label:"26/09/2008 15:59:00",render:formatStringRender},{key:"duration",title:tf("format.duration"),type:"date",label:"24:01:00",render:formatStringRender}],formatm={};baseFormats.forEach(i=>{formatm[i.key]=i});const cellPaddingWidth=5,tableFixedHeaderCleanStyle={fillStyle:"#f4f5f8"},tableGridStyle={fillStyle:"#fff",lineWidth:thinLineWidth,strokeStyle:"#e6e6e6"};function tableFixedHeaderStyle(){return{textAlign:"center",textBaseline:"middle",font:`500 ${npx(12)}px Source Sans Pro`,fillStyle:"#585757",lineWidth:thinLineWidth(),strokeStyle:"#e6e6e6"}}function getDrawBox(i,e,s,n=0){const{left:r,top:o,width:a,height:l}=i.cellRect(e,s);return new DrawBox(r,o+n,a,l,cellPaddingWidth)}function renderCell(i,e,s,n,r=0){const{sortedRowMap:o,rows:a,cols:l}=e;if(a.isHide(s)||l.isHide(n))return;let c=s;o.has(s)&&(c=o.get(s));const d=e.getCell(c,n);if(d===null)return;let u=!1;"editable"in d&&d.editable===!1&&(u=!0);const p=e.getCellStyleOrDefault(c,n),m=getDrawBox(e,s,n,r);m.bgcolor=p.bgcolor,p.border!==void 0&&(m.setBorders(p.border),i.strokeBorders(m)),i.rect(m,()=>{let f="";f=e.settings.evalPaused?d.text||"":cell_rslib_entry_.render(d.text||"",formulam,(y,E)=>e.getCellTextOrDefault(E,y)),p.format&&(f=formatm[p.format].render(f));const g=Object.assign({},p.font);g.size=getFontSizePxByPt(g.size),i.text(f,m,{align:p.align,valign:p.valign,font:g,color:p.color,strike:p.strike,underline:p.underline},p.textwrap),e.validations.getError(s,n)&&i.error(m),u&&i.frozen(m)})}function renderAutofilter(i){const{data:e,draw:s}=this;if(i){const{autoFilter:n}=e;if(!n.active())return;const r=n.hrange();i.intersects(r)&&r.each((o,a)=>{const l=getDrawBox(e,o,a);s.dropdown(l)})}}function renderContent(i,e,s,n,r){const{draw:o,data:a}=this;o.save(),o.translate(e,s).translate(n,r);const{exceptRowSet:l}=a,c=p=>{const m=l.has(p);if(m){const f=a.rows.getHeight(p);o.translate(0,-f)}return!m},d=a.exceptRowTotalHeight(i.sri,i.eri);o.save(),o.translate(0,-d),i.each((p,m)=>{renderCell(o,a,p,m)},p=>c(p)),o.restore();const u=new Set;o.save(),o.translate(0,-d),a.eachMergesInView(i,({sri:p,sci:m,eri:f})=>{if(l.has(p)){if(!u.has(p)){u.add(p);const g=a.rows.sumHeight(p,f+1);o.translate(0,-g)}}else renderCell(o,a,p,m)}),o.restore(),renderAutofilter.call(this,i),o.restore()}function renderSelectedHeaderCell(i,e,s,n){const{draw:r}=this;r.save(),r.attr({fillStyle:"rgba(75, 137, 255, 0.08)"}).fillRect(i,e,s,n),r.restore()}function renderFixedHeaders(i,e,s,n,r,o){const{draw:a,data:l}=this,c=e.h,d=e.w,u=o+n,p=r+s;a.save(),a.attr(tableFixedHeaderCleanStyle),(i==="all"||i==="left")&&a.fillRect(0,u,s,c),(i==="all"||i==="top")&&a.fillRect(p,0,d,n);const{sri:m,sci:f,eri:g,eci:x}=l.selector.range;a.attr(tableFixedHeaderStyle()),(i==="all"||i==="left")&&(l.rowEach(e.sri,e.eri,(y,E,b)=>{const v=u+E,A=y;a.line([0,v],[s,v]),m<=A&&A<g+1&&renderSelectedHeaderCell.call(this,0,v,s,b),a.fillText(A+1,s/2,v+b/2),y>0&&l.rows.isHide(y-1)&&(a.save(),a.attr({strokeStyle:"#c6c6c6"}),a.line([5,v+5],[s-5,v+5]),a.restore())}),a.line([0,c+u],[s,c+u]),a.line([s,u],[s,c+u])),(i==="all"||i==="top")&&(l.colEach(e.sci,e.eci,(y,E,b)=>{const v=p+E,A=y;a.line([v,0],[v,n]),f<=A&&A<x+1&&renderSelectedHeaderCell.call(this,v,0,b,n),a.fillText(stringAt(A),v+b/2,n/2),y>0&&l.cols.isHide(y-1)&&(a.save(),a.attr({strokeStyle:"#c6c6c6"}),a.line([v+5,5],[v+5,n-5]),a.restore())}),a.line([d+p,0],[d+p,n]),a.line([0,n],[d+p,n])),a.restore()}function renderFixedLeftTopCell(i,e){const{draw:s}=this;s.save(),s.attr({fillStyle:"#f4f5f8"}).fillRect(0,0,i,e),s.restore()}function renderContentGrid({sri:i,sci:e,eri:s,eci:n,w:r,h:o},a,l,c,d){const{draw:u,data:p}=this,{settings:m}=p;if(u.save(),u.attr(tableGridStyle).translate(a+c,l+d),!m.showGrid){u.restore();return}p.rowEach(i,s,(f,g,x)=>{f!==i&&u.line([0,g],[r,g]),f===s&&u.line([0,g+x],[r,g+x])}),p.colEach(e,n,(f,g,x)=>{f!==e&&u.line([g,0],[g,o]),f===n&&u.line([g+x,0],[g+x,o])}),u.restore()}function renderFreezeHighlightLine(i,e,s,n){const{draw:r,data:o}=this,a=o.viewWidth()-i,l=o.viewHeight()-e;r.save().translate(i,e).attr({strokeStyle:"rgba(75, 137, 255, .6)"}),r.line([0,n],[a,n]),r.line([s,0],[s,l]),r.restore()}class Table{constructor(e,s){this.el=e,this.draw=new Draw(e,s.viewWidth(),s.viewHeight()),this.data=s}resetData(e){this.data=e,this.render()}render(){const{data:e}=this,{rows:s,cols:n}=e,r=n.indexWidth,o=s.height;this.draw.resize(e.viewWidth(),e.viewHeight()),this.clear();const a=e.viewRange(),l=e.freezeTotalWidth(),c=e.freezeTotalHeight(),{x:d,y:u}=e.scroll;renderContentGrid.call(this,a,r,o,l,c),renderContent.call(this,a,r,o,-d,-u),renderFixedHeaders.call(this,"all",a,r,o,l,c),renderFixedLeftTopCell.call(this,r,o);const[p,m]=e.freeze;if(p>0||m>0){if(p>0){const g=a.clone();g.sri=0,g.eri=p-1,g.h=c,renderContentGrid.call(this,g,r,o,l,0),renderContent.call(this,g,r,o,-d,0),renderFixedHeaders.call(this,"top",g,r,o,l,0)}if(m>0){const g=a.clone();g.sci=0,g.eci=m-1,g.w=l,renderContentGrid.call(this,g,r,o,0,c),renderFixedHeaders.call(this,"left",g,r,o,0,c),renderContent.call(this,g,r,o,0,-u)}const f=e.freezeViewRange();renderContentGrid.call(this,f,r,o,0,0),renderFixedHeaders.call(this,"all",f,r,o,0,0),renderContent.call(this,f,r,o,0,0),renderFreezeHighlightLine.call(this,r,o,l,c)}}clear(){this.draw.clear()}}const table_rslib_entry_=Table,PAGER_SIZES=[["A3",11.69,16.54],["A4",8.27,11.69],["A5",5.83,8.27],["B4",9.84,13.9],["B5",6.93,9.84]],PAGER_ORIENTATIONS=["landscape","portrait"];function inches2px(i){return parseInt(96*i,10)}function btnClick(i){i==="cancel"?this.el.hide():this.toPrint()}function pagerSizeChange(i){const{paper:e}=this,{value:s}=i.target,n=PAGER_SIZES[s];e.w=inches2px(n[1]),e.h=inches2px(n[2]),this.preview()}function pagerOrientationChange(i){const{paper:e}=this,{value:s}=i.target,n=PAGER_ORIENTATIONS[s];e.orientation=n,this.preview()}let Print$1=class{constructor(e){this.paper={w:inches2px(PAGER_SIZES[0][1]),h:inches2px(PAGER_SIZES[0][2]),padding:50,orientation:PAGER_ORIENTATIONS[0],get width(){return this.orientation==="landscape"?this.h:this.w},get height(){return this.orientation==="landscape"?this.w:this.h}},this.data=e,this.el=h("div",`${cssPrefix}-print`).children(h("div",`${cssPrefix}-print-bar`).children(h("div","-title").child("Print settings"),h("div","-right").children(h("div",`${cssPrefix}-buttons`).children(new Button("cancel").on("click",btnClick.bind(this,"cancel")),new Button("next","primary").on("click",btnClick.bind(this,"next"))))),h("div",`${cssPrefix}-print-content`).children(this.contentEl=h("div","-content"),h("div","-sider").child(h("form","").children(h("fieldset","").children(h("label","").child(`${t("print.size")}`),h("select","").children(...PAGER_SIZES.map((s,n)=>h("option","").attr("value",n).child(`${s[0]} ( ${s[1]}''x${s[2]}'' )`))).on("change",pagerSizeChange.bind(this))),h("fieldset","").children(h("label","").child(`${t("print.orientation")}`),h("select","").children(...PAGER_ORIENTATIONS.map((s,n)=>h("option","").attr("value",n).child(`${t("print.orientations")[n]}`))).on("change",pagerOrientationChange.bind(this))))))).hide()}resetData(e){this.data=e}preview(){const{data:e,paper:s}=this,{width:n,height:r,padding:o}=s,a=n-2*o,l=r-2*o,c=e.contentRange(),d=parseInt(c.h/l,10)+1,u=a/c.w;let p=o;const m=o;u>1&&(p+=(a-c.w)/2);let f=0,g=0;this.contentEl.html(""),this.canvases=[];const x={sri:0,sci:0,eri:0,eci:0};for(let y=0;y<d;y+=1){let E=0,b=0;const v=h("div",`${cssPrefix}-canvas-card`),A=h("canvas",`${cssPrefix}-canvas`);this.canvases.push(A.el);const D=new Draw(A.el,n,r);for(D.save(),D.translate(p,m),u<1&&D.scale(u,u);f<=c.eri;f+=1){const I=e.rows.getHeight(f);if(E+=I,E<l)for(let O=0;O<=c.eci;O+=1)renderCell(D,e,f,O,g),x.eci=O;else{b=-(E-I);break}}x.eri=f,D.restore(),D.save(),D.translate(p,m),u<1&&D.scale(u,u);const L=g;e.eachMergesInView(x,({sri:I,sci:O})=>{renderCell(D,e,I,O,L)}),D.restore(),x.sri=x.eri,x.sci=x.eci,g+=b,this.contentEl.child(h("div",`${cssPrefix}-canvas-card-wraper`).child(v.child(A)))}this.el.show()}toPrint(){this.el.hide();const{paper:e}=this,s=h("iframe","").hide(),{el:n}=s;window.document.body.appendChild(n);const{contentWindow:r}=n,o=r.document,a=document.createElement("style");a.innerHTML=`
2
+ (function(C,k){typeof exports=="object"&&typeof module!="undefined"?k(exports,require("@tachybase/client"),require("@tachybase/components"),require("react/jsx-runtime"),require("react"),require("@tachybase/schema"),require("@ant-design/icons"),require("antd"),require("lodash"),require("@tachybase/evaluators/client"),require("react-dom"),require("ahooks"),require("@tachybase/utils/client"),require("react-router-dom"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/components","react/jsx-runtime","react","@tachybase/schema","@ant-design/icons","antd","lodash","@tachybase/evaluators/client","react-dom","ahooks","@tachybase/utils/client","react-router-dom","dayjs"],k):(C=typeof globalThis!="undefined"?globalThis:C||self,k(C["@tachybase/module-hera"]={},C["@tachybase/client"],C["@tachybase/components"],C.jsxRuntime,C.react,C["@tachybase/schema"],C["@ant-design/icons"],C.antd,C.lodash,C["@tachybase/evaluators"],C["react-dom"],C.ahooks,C["@tachybase/utils"],C["react-router-dom"],C.dayjs))})(this,function(exports,client,components$1,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__,React,schema,icons,antd,_,client$1,ReactDOM,ahooks,client$2,reactRouterDom,dayjs){"use strict";var ee=Object.defineProperty,te=Object.defineProperties;var se=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var ie=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable;var J=C=>{throw TypeError(C)};var q=(C,k,P)=>k in C?ee(C,k,{enumerable:!0,configurable:!0,writable:!0,value:P}):C[k]=P,A=(C,k)=>{for(var P in k||(k={}))ie.call(k,P)&&q(C,P,k[P]);if(Z)for(var P of Z(k))ne.call(k,P)&&q(C,P,k[P]);return C},I=(C,k)=>te(C,se(k));var b=(C,k,P)=>q(C,typeof k!="symbol"?k+"":k,P),Q=(C,k,P)=>k.has(C)||J("Cannot "+P);var T=(C,k,P)=>(Q(C,k,"read from private field"),P?P.call(C):k.get(C)),U=(C,k,P)=>k.has(C)?J("Cannot add the same private member more than once"):k instanceof WeakSet?k.add(C):k.set(C,P),N=(C,k,P,j)=>(Q(C,k,"write to private field"),j?j.call(C,P):k.set(C,P),P);var R=(C,k,P)=>new Promise((j,L)=>{var O=e=>{try{n(P.next(e))}catch(s){L(s)}},$=e=>{try{n(P.throw(e))}catch(s){L(s)}},n=e=>e.done?j(e.value):Promise.resolve(e.value).then(O,$);n((P=P.apply(C,k)).next())});var C,k,P,j,L,O;function _interopNamespaceDefault(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const s in n)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>n[s]})}}return e.default=n,Object.freeze(e)}const React__namespace=_interopNamespaceDefault(React);var commonjsGlobal=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function getDefaultExportFromCjs(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var FileSaver_min={exports:{}};(function(n,e){(function(s,i){i()})(commonjsGlobal,function(){function s(d,u){return typeof u=="undefined"?u={autoBom:!1}:typeof u!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(d.type)?new Blob(["\uFEFF",d],{type:d.type}):d}function i(d,u,f){var m=new XMLHttpRequest;m.open("GET",d),m.responseType="blob",m.onload=function(){c(m.response,u,f)},m.onerror=function(){console.error("could not download file")},m.send()}function r(d){var u=new XMLHttpRequest;u.open("HEAD",d,!1);try{u.send()}catch(f){}return 200<=u.status&&299>=u.status}function o(d){try{d.dispatchEvent(new MouseEvent("click"))}catch(f){var u=document.createEvent("MouseEvents");u.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),d.dispatchEvent(u)}}var l=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof commonjsGlobal=="object"&&commonjsGlobal.global===commonjsGlobal?commonjsGlobal:void 0,a=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),c=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(d,u,f){var m=l.URL||l.webkitURL,p=document.createElement("a");u=u||d.name||"download",p.download=u,p.rel="noopener",typeof d=="string"?(p.href=d,p.origin===location.origin?o(p):r(p.href)?i(d,u,f):o(p,p.target="_blank")):(p.href=m.createObjectURL(d),setTimeout(function(){m.revokeObjectURL(p.href)},4e4),setTimeout(function(){o(p)},0))}:"msSaveOrOpenBlob"in navigator?function(d,u,f){if(u=u||d.name||"download",typeof d!="string")navigator.msSaveOrOpenBlob(s(d,f),u);else if(r(d))i(d,u,f);else{var m=document.createElement("a");m.href=d,m.target="_blank",setTimeout(function(){o(m)})}}:function(d,u,f,m){if(m=m||open("","_blank"),m&&(m.document.title=m.document.body.innerText="downloading..."),typeof d=="string")return i(d,u,f);var p=d.type==="application/octet-stream",g=/constructor/i.test(l.HTMLElement)||l.safari,x=/CriOS\/[\d]+/.test(navigator.userAgent);if((x||p&&g||a)&&typeof FileReader!="undefined"){var E=new FileReader;E.onloadend=function(){var w=E.result;w=x?w:w.replace(/^data:[^;]*;/,"data:attachment/file;"),m?m.location.href=w:location=w,m=null},E.readAsDataURL(d)}else{var v=l.URL||l.webkitURL,y=v.createObjectURL(d);m?m.location=y:location.href=y,m=null,setTimeout(function(){v.revokeObjectURL(y)},4e4)}});l.saveAs=c.saveAs=c,n.exports=c})})(FileSaver_min);var FileSaver_minExports=FileSaver_min.exports;const NAMESPACE="@tachybase/module-hera";class Locale{constructor(e){b(this,"app");this.app=e}lang(e){return this.app.i18n.t(e,{ns:NAMESPACE})}}const useTranslation=()=>{const{i18n:n}=client.useApp();return{t:(s,i={})=>n.t(s,A({ns:NAMESPACE},i))}},tval=n=>client.tval(n,{ns:NAMESPACE});function lang(n){return client.i18n.t(n,{ns:NAMESPACE})}const LoadingSpin=({children:n,spinning:e})=>{const{t:s}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Spin,{tip:s("loading..."),indicator:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.LoadingOutlined,{style:{fontSize:24},spin:!0}),spinning:e,children:n})},PDFViewer=React.forwardRef((n,e)=>{const i=client.useApp().AttachmentPreviewManager.get(),{checkedComponent:r}=i["application/pdf"],o=client.useIsMobile(),[l,a]=React.useState(""),[c,d]=React.useState(null),{file:u,width:f=960}=n,{loading:m,data:p}=client.useRequest({url:u,responseType:"arraybuffer"},{refreshDeps:[u]});return React.useImperativeHandle(e,()=>({download(){const g=new Blob([p],{type:"application/pdf"});FileSaver_minExports.saveAs(g,schema.uid()+".pdf")},print(){c.print()}})),React.useEffect(()=>{if(m||!p)return;const g=new Blob([p],{type:"application/pdf"}),x=URL.createObjectURL(g);a(x)},[p,m]),React.useEffect(()=>{if(!l)return;const g=document.createElement("iframe");return g.style.display="none",g.src=l,g.onload=()=>{d(g.contentWindow)},document.body.appendChild(g),()=>{URL.revokeObjectURL(l),document.body.removeChild(g)}},[l]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(LoadingSpin,{spinning:m,children:r({file:{url:l},width:f,noTransformWrapper:!o})})});class Element{constructor(e,s=""){typeof e=="string"?(this.el=document.createElement(e),this.el.className=s):this.el=e,this.data={}}data(e,s){return s!==void 0?(this.data[e]=s,this):this.data[e]}on(e,s){const[i,...r]=e.split(".");let o=i;return o==="mousewheel"&&/Firefox/i.test(window.navigator.userAgent)&&(o="DOMMouseScroll"),this.el.addEventListener(o,l=>{s(l);for(let a=0;a<r.length;a+=1){const c=r[a];if(c==="left"&&l.button!==0||c==="right"&&l.button!==2)return;c==="stop"&&l.stopPropagation()}}),this}offset(e){if(e!==void 0)return Object.keys(e).forEach(l=>{this.css(l,`${e[l]}px`)}),this;const{offsetTop:s,offsetLeft:i,offsetHeight:r,offsetWidth:o}=this.el;return{top:s,left:i,height:r,width:o}}scroll(e){const{el:s}=this;return e!==void 0&&(e.left!==void 0&&(s.scrollLeft=e.left),e.top!==void 0&&(s.scrollTop=e.top)),{left:s.scrollLeft,top:s.scrollTop}}box(){return this.el.getBoundingClientRect()}parent(){return new Element(this.el.parentNode)}children(...e){return arguments.length===0?this.el.childNodes:(e.forEach(s=>this.child(s)),this)}removeChild(e){this.el.removeChild(e)}child(e){let s=e;return typeof e=="string"?s=document.createTextNode(e):e instanceof Element&&(s=e.el),this.el.appendChild(s),this}contains(e){return this.el.contains(e)}className(e){return e!==void 0?(this.el.className=e,this):this.el.className}addClass(e){return this.el.classList.add(e),this}hasClass(e){return this.el.classList.contains(e)}removeClass(e){return this.el.classList.remove(e),this}toggle(e="active"){return this.toggleClass(e)}toggleClass(e){return this.el.classList.toggle(e)}active(e=!0,s="active"){return e?this.addClass(s):this.removeClass(s),this}checked(e=!0){return this.active(e,"checked"),this}disabled(e=!0){return e?this.addClass("disabled"):this.removeClass("disabled"),this}attr(e,s){if(s!==void 0)this.el.setAttribute(e,s);else{if(typeof e=="string")return this.el.getAttribute(e);Object.keys(e).forEach(i=>{this.el.setAttribute(i,e[i])})}return this}removeAttr(e){return this.el.removeAttribute(e),this}html(e){return e!==void 0?(this.el.innerHTML=e,this):this.el.innerHTML}val(e){return e!==void 0?(this.el.value=e,this):this.el.value}focus(){this.el.focus()}cssRemoveKeys(...e){return e.forEach(s=>this.el.style.removeProperty(s)),this}css(e,s){return s===void 0&&typeof e!="string"?(Object.keys(e).forEach(i=>{this.el.style[i]=e[i]}),this):s!==void 0?(this.el.style[e]=s,this):this.el.style[e]}computedStyle(){return window.getComputedStyle(this.el,null)}show(){return this.css("display","block"),this}hide(){return this.css("display","none"),this}}const h=(n,e="")=>new Element(n,e),alphabets=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function stringAt(n){let e="",s=n;for(;s>=alphabets.length;)s/=alphabets.length,s-=1,e+=alphabets[parseInt(s,10)%alphabets.length];const i=n%alphabets.length;return e+=alphabets[i],e}function indexAt(n){let e=0;for(let s=0;s!==n.length;++s)e=26*e+n.charCodeAt(s)-64;return e-1}function expr2xy(n){let e="",s="";for(let i=0;i<n.length;i+=1)n.charAt(i)>="0"&&n.charAt(i)<="9"?s+=n.charAt(i):e+=n.charAt(i);return[indexAt(e),parseInt(s,10)-1]}function xy2expr(n,e){return`${stringAt(n)}${e+1}`}function expr2expr(n,e,s,i=()=>!0){if(e===0&&s===0)return n;const[r,o]=expr2xy(n);return i(r,o)?xy2expr(r+e,o+s):n}class CellRange{constructor(e,s,i,r,o=0,l=0){this.sri=e,this.sci=s,this.eri=i,this.eci=r,this.w=o,this.h=l}set(e,s,i,r){this.sri=e,this.sci=s,this.eri=i,this.eci=r}multiple(){return this.eri-this.sri>0||this.eci-this.sci>0}includes(...e){let[s,i]=[0,0];e.length===1?[i,s]=expr2xy(e[0]):e.length===2&&([s,i]=e);const{sri:r,sci:o,eri:l,eci:a}=this;return r<=s&&s<=l&&o<=i&&i<=a}each(e,s=()=>!0){const{sri:i,sci:r,eri:o,eci:l}=this;for(let a=i;a<=o;a+=1)if(s(a))for(let c=r;c<=l;c+=1)e(a,c)}contains(e){return this.sri<=e.sri&&this.sci<=e.sci&&this.eri>=e.eri&&this.eci>=e.eci}within(e){return this.sri>=e.sri&&this.sci>=e.sci&&this.eri<=e.eri&&this.eci<=e.eci}disjoint(e){return this.sri>e.eri||this.sci>e.eci||e.sri>this.eri||e.sci>this.eci}intersects(e){return this.sri<=e.eri&&this.sci<=e.eci&&e.sri<=this.eri&&e.sci<=this.eci}union(e){const{sri:s,sci:i,eri:r,eci:o}=this;return new CellRange(e.sri<s?e.sri:s,e.sci<i?e.sci:i,e.eri>r?e.eri:r,e.eci>o?e.eci:o)}difference(e){const s=[],i=(m,p,g,x)=>{s.push(new CellRange(m,p,g,x))},{sri:r,sci:o,eri:l,eci:a}=this,c=e.sri-r,d=e.sci-o,u=l-e.eri,f=a-e.eci;return c>0?(i(r,o,e.sri-1,a),u>0?(i(e.eri+1,o,l,a),d>0&&i(e.sri,o,e.eri,e.sci-1),f>0&&i(e.sri,e.eci+1,e.eri,a)):(d>0&&i(e.sri,o,l,e.sci-1),f>0&&i(e.sri,e.eci+1,l,a))):u>0&&(i(e.eri+1,o,l,a),d>0&&i(r,o,e.eri,e.sci-1),f>0&&i(r,e.eci+1,e.eri,a)),d>0?(i(r,o,l,e.sci-1),f>0?(i(r,e.eri+1,l,a),c>0&&i(r,e.sci,e.sri-1,e.eci),u>0&&i(e.sri+1,e.sci,l,e.eci)):(c>0&&i(r,e.sci,e.sri-1,a),u>0&&i(e.sri+1,e.sci,l,a))):f>0&&(i(l,e.eci+1,l,a),c>0&&i(r,o,e.sri-1,e.eci),u>0&&i(e.eri+1,o,l,e.eci)),s}size(){return[this.eri-this.sri+1,this.eci-this.sci+1]}toString(){const{sri:e,sci:s,eri:i,eci:r}=this;let o=xy2expr(s,e);return this.multiple()&&(o=`${o}:${xy2expr(r,i)}`),o}clone(){const{sri:e,sci:s,eri:i,eci:r,w:o,h:l}=this;return new CellRange(e,s,i,r,o,l)}equals(e){return this.eri===e.eri&&this.eci===e.eci&&this.sri===e.sri&&this.sci===e.sci}static valueOf(e){const s=e.split(":"),[i,r]=expr2xy(s[0]);let[o,l]=[r,i];return s.length>1&&([l,o]=expr2xy(s[1])),new CellRange(r,i,o,l)}}let Selector$1=class{constructor(){this.range=new CellRange(0,0,0,0),this.ri=0,this.ci=0}multiple(){return this.range.multiple()}setIndexes(e,s){this.ri=e,this.ci=s}size(){return this.range.size()}};class Scroll{constructor(){this.x=0,this.y=0,this.ri=0,this.ci=0}}class History{constructor(){this.undoItems=[],this.redoItems=[]}add(e){this.undoItems.push(JSON.stringify(e)),this.redoItems=[]}canUndo(){return this.undoItems.length>0}canRedo(){return this.redoItems.length>0}undo(e,s){const{undoItems:i,redoItems:r}=this;this.canUndo()&&(r.push(JSON.stringify(e)),s(JSON.parse(i.pop())))}redo(e,s){const{undoItems:i,redoItems:r}=this;this.canRedo()&&(i.push(JSON.stringify(e)),s(JSON.parse(r.pop())))}}class Clipboard{constructor(){this.range=null,this.state="clear"}copy(e){return this.range=e,this.state="copy",this}cut(e){return this.range=e,this.state="cut",this}isCopy(){return this.state==="copy"}isCut(){return this.state==="cut"}isClear(){return this.state==="clear"}clear(){this.range=null,this.state="clear"}}class Filter{constructor(e,s,i){this.ci=e,this.operator=s,this.value=i}set(e,s){this.operator=e,this.value=s}includes(e){const{operator:s,value:i}=this;return s==="all"?!0:s==="in"?i.includes(e):!1}vlength(){const{operator:e,value:s}=this;return e==="in"?s.length:0}getData(){const{ci:e,operator:s,value:i}=this;return{ci:e,operator:s,value:i}}}class Sort{constructor(e,s){this.ci=e,this.order=s}asc(){return this.order==="asc"}desc(){return this.order==="desc"}}class AutoFilter{constructor(){this.ref=null,this.filters=[],this.sort=null}setData({ref:e,filters:s,sort:i}){e!=null&&(this.ref=e,this.filters=s.map(r=>new Filter(r.ci,r.operator,r.value)),i&&(this.sort=new Sort(i.ci,i.order)))}getData(){if(this.active()){const{ref:e,filters:s,sort:i}=this;return{ref:e,filters:s.map(r=>r.getData()),sort:i}}return{}}addFilter(e,s,i){const r=this.getFilter(e);r==null?this.filters.push(new Filter(e,s,i)):r.set(s,i)}setSort(e,s){this.sort=s?new Sort(e,s):null}includes(e,s){return this.active()?this.hrange().includes(e,s):!1}getSort(e){const{sort:s}=this;return s&&s.ci===e?s:null}getFilter(e){const{filters:s}=this;for(let i=0;i<s.length;i+=1)if(s[i].ci===e)return s[i];return null}filteredRows(e){const s=new Set,i=new Set;if(this.active()){const{sri:r,eri:o}=this.range(),{filters:l}=this;for(let a=r+1;a<=o;a+=1)for(let c=0;c<l.length;c+=1){const d=l[c],u=e(a,d.ci),f=u?u.text:"";if(d.includes(f))i.add(a);else{s.add(a);break}}}return{rset:s,fset:i}}items(e,s){const i={};if(this.active()){const{sri:r,eri:o}=this.range();for(let l=r+1;l<=o;l+=1){const a=s(l,e);if(a===null||/^\s*$/.test(a.text))i[""]=(i[""]||0)+1;else{const c=a.text,d=(i[c]||0)+1;i[c]=d}}}return i}range(){return CellRange.valueOf(this.ref)}hrange(){const e=this.range();return e.eri=e.sri,e}clear(){this.ref=null,this.filters=[],this.sort=null}active(){return this.ref!==null}}class Merges{constructor(e=[]){this._=e}forEach(e){this._.forEach(e)}deleteWithin(e){this._=this._.filter(s=>!s.within(e))}getFirstIncludes(e,s){for(let i=0;i<this._.length;i+=1){const r=this._[i];if(r.includes(e,s))return r}return null}filterIntersects(e){return new Merges(this._.filter(s=>s.intersects(e)))}intersects(e){for(let s=0;s<this._.length;s+=1)if(this._[s].intersects(e))return!0;return!1}union(e){let s=e;return this._.forEach(i=>{i.intersects(s)&&(s=i.union(s))}),s}add(e){this.deleteWithin(e),this._.push(e)}shift(e,s,i,r){this._.forEach(o=>{const{sri:l,sci:a,eri:c,eci:d}=o,u=o;e==="row"?l>=s?(u.sri+=i,u.eri+=i):l<s&&s<=c&&(u.eri+=i,r(l,a,i,0)):e==="column"&&(a>=s?(u.sci+=i,u.eci+=i):a<s&&s<=d&&(u.eci+=i,r(l,a,0,i)))})}move(e,s,i){this._.forEach(r=>{const o=r;o.within(e)&&(o.eri+=s,o.sri+=s,o.sci+=i,o.eci+=i)})}setData(e){return this._=e.map(s=>CellRange.valueOf(s)),this}getData(){return this._.map(e=>e.toString())}}function cloneDeep(n){return JSON.parse(JSON.stringify(n))}const mergeDeep=(n={},...e)=>(e.forEach(s=>{Object.keys(s).forEach(i=>{const r=s[i];typeof r=="string"||typeof r=="number"||typeof r=="boolean"?n[i]=r:typeof r!="function"&&!Array.isArray(r)&&r instanceof Object?(n[i]=n[i]||{},mergeDeep(n[i],r)):n[i]=r})}),n);function equals(n,e){const s=Object.keys(n);if(s.length!==Object.keys(e).length)return!1;for(let i=0;i<s.length;i+=1){const r=s[i],o=n[r],l=e[r];if(l===void 0)return!1;if(typeof o=="string"||typeof o=="number"||typeof o=="boolean"){if(o!==l)return!1}else if(Array.isArray(o)){if(o.length!==l.length)return!1;for(let a=0;a<o.length;a+=1)if(!equals(o[a],l[a]))return!1}else if(typeof o!="function"&&!Array.isArray(o)&&o instanceof Object&&!equals(o,l))return!1}return!0}const sum=(n,e=s=>s)=>{let s=0,i=0;return Object.keys(n).forEach(r=>{s+=e(n[r],r),i+=1}),[s,i]};function deleteProperty(n,e){const s=n[`${e}`];return delete n[`${e}`],s}function rangeReduceIf(n,e,s,i,r,o){let l=s,a=i,c=n;for(;c<e&&!(l>r);c+=1)a=o(c),l+=a;return[c,l-a,a]}function rangeSum(n,e,s){let i=0;for(let r=n;r<e;r+=1)i+=s(r);return i}function rangeEach(n,e,s){for(let i=n;i<e;i+=1)s(i)}function arrayEquals(n,e){if(n.length!==e.length)return!1;for(let s=0;s<n.length;s+=1)if(n[s]!==e[s])return!1;return!0}function digits(n){const e=`${n}`;let s=0,i=!1;for(let r=0;r<e.length;r+=1)i===!0&&(s+=1),e.charAt(r)==="."&&(i=!0);return s}function numberCalc(n,e,s){if(Number.isNaN(e)||Number.isNaN(s))return e+n+s;const i=digits(e),r=digits(s),o=Number(e),l=Number(s);let a=0;if(n==="-")a=o-l;else if(n==="+")a=o+l;else if(n==="*")a=o*l;else if(n==="/")return a=o/l,digits(a)>5?a.toFixed(2):a;return a.toFixed(Math.max(i,r))}const helper_rslib_entry_={cloneDeep,merge:(...n)=>mergeDeep({},...n),equals,arrayEquals,sum,rangeEach,rangeSum,rangeReduceIf,deleteProperty,numberCalc};class Rows{constructor({len:e,height:s}){this._={},this.len=e,this.height=s}getHeight(e){if(this.isHide(e))return 0;const s=this.get(e);return s&&s.height?s.height:this.height}setHeight(e,s){const i=this.getOrNew(e);i.height=s}unhide(e){let s=e;for(;s>0&&(s-=1,this.isHide(s));)this.setHide(s,!1)}isHide(e){const s=this.get(e);return s&&s.hide}setHide(e,s){const i=this.getOrNew(e);s===!0?i.hide=!0:delete i.hide}setStyle(e,s){const i=this.getOrNew(e);i.style=s}sumHeight(e,s,i){return helper_rslib_entry_.rangeSum(e,s,r=>i&&i.has(r)?0:this.getHeight(r))}totalHeight(){return this.sumHeight(0,this.len)}get(e){return this._[e]}getOrNew(e){return this._[e]=this._[e]||{cells:{}},this._[e]}getCell(e,s){const i=this.get(e);return i!==void 0&&i.cells!==void 0&&i.cells[s]!==void 0?i.cells[s]:null}getCellMerge(e,s){const i=this.getCell(e,s);return i&&i.merge?i.merge:[0,0]}getCellOrNew(e,s){const i=this.getOrNew(e);return i.cells[s]=i.cells[s]||{},i.cells[s]}setCell(e,s,i,r="all"){const o=this.getOrNew(e);r==="all"?o.cells[s]=i:r==="text"?(o.cells[s]=o.cells[s]||{},o.cells[s].text=i.text):r==="format"&&(o.cells[s]=o.cells[s]||{},o.cells[s].style=i.style,i.merge&&(o.cells[s].merge=i.merge))}setCellText(e,s,i){const r=this.getCellOrNew(e,s);r.editable!==!1&&(r.text=i)}copyPaste(e,s,i,r=!1,o=()=>{}){const{sri:l,sci:a,eri:c,eci:d}=e,u=s.sri,f=s.sci,m=s.eri,p=s.eci,[g,x]=e.size(),[E,v]=s.size();let y=!0,w=0;(m<l||p<a)&&(y=!1,w=m<l?E:v);for(let S=l;S<=c;S+=1)if(this._[S]){for(let D=a;D<=d;D+=1)if(this._[S].cells&&this._[S].cells[D])for(let F=u;F<=m;F+=g)for(let B=f;B<=p;B+=x){const M=F+(S-l),K=B+(D-a),W=helper_rslib_entry_.cloneDeep(this._[S].cells[D]);if(r&&W&&W.text&&W.text.length>0){const{text:X}=W;let V=B-f+(F-u)+2;if(y||(V-=w+1),X[0]==="=")W.text=X.replace(/[a-zA-Z]{1,3}\d+/g,z=>{let[H,Y]=[0,0];return l===u?H=V-1:Y=V-1,/^\d+$/.test(z)?z:expr2expr(z,H,Y)});else if(g<=1&&x>1&&(u>c||m<l)||x<=1&&g>1&&(f>d||p<a)||g<=1&&x<=1){const z=/[\\.\d]+$/.exec(X);if(z!==null){const H=Number(z[0])+V-1;W.text=X.substring(0,z.index)+H}}}this.setCell(M,K,W,i),o(M,K,W)}}}cutPaste(e,s){const i={};this.each(r=>{this.eachCells(r,o=>{let l=parseInt(r,10),a=parseInt(o,10);e.includes(r,o)&&(l=s.sri+(l-e.sri),a=s.sci+(a-e.sci)),i[l]=i[l]||{cells:{}},i[l].cells[a]=this._[r].cells[o]})}),this._=i}paste(e,s){if(e.length<=0)return;const{sri:i,sci:r}=s;e.forEach((o,l)=>{const a=i+l;o.forEach((c,d)=>{const u=r+d;this.setCellText(a,u,c)})})}insert(e,s=1){const i={};this.each((r,o)=>{let l=parseInt(r,10);l>=e&&(l+=s,this.eachCells(r,(a,c)=>{c.text&&c.text[0]==="="&&(c.text=c.text.replace(/[a-zA-Z]{1,3}\d+/g,d=>expr2expr(d,0,s,(u,f)=>f>=e)))})),i[l]=o}),this._=i,this.len+=s}delete(e,s){const i=s-e+1,r={};this.each((o,l)=>{const a=parseInt(o,10);a<e?r[a]=l:o>s&&(r[a-i]=l,this.eachCells(o,(c,d)=>{d.text&&d.text[0]==="="&&(d.text=d.text.replace(/[a-zA-Z]{1,3}\d+/g,u=>expr2expr(u,0,-i,(f,m)=>m>s)))}))}),this._=r,this.len-=i}insertColumn(e,s=1){this.each((i,r)=>{const o={};this.eachCells(i,(l,a)=>{let c=parseInt(l,10);c>=e&&(c+=s,a.text&&a.text[0]==="="&&(a.text=a.text.replace(/[a-zA-Z]{1,3}\d+/g,d=>expr2expr(d,s,0,u=>u>=e)))),o[c]=a}),r.cells=o})}deleteColumn(e,s){const i=s-e+1;this.each((r,o)=>{const l={};this.eachCells(r,(a,c)=>{const d=parseInt(a,10);d<e?l[d]=c:d>s&&(l[d-i]=c,c.text&&c.text[0]==="="&&(c.text=c.text.replace(/[a-zA-Z]{1,3}\d+/g,u=>expr2expr(u,-i,0,f=>f>s))))}),o.cells=l})}deleteCells(e,s="all"){e.each((i,r)=>{this.deleteCell(i,r,s)})}deleteCell(e,s,i="all"){const r=this.get(e);if(r!==null){const o=this.getCell(e,s);o!==null&&o.editable!==!1&&(i==="all"?delete r.cells[s]:i==="text"?(o.text&&delete o.text,o.value&&delete o.value):i==="format"?(o.style!==void 0&&delete o.style,o.merge&&delete o.merge):i==="merge"&&o.merge&&delete o.merge)}}maxCell(){const e=Object.keys(this._),s=e[e.length-1],i=this._[s];if(i){const{cells:r}=i,o=Object.keys(r),l=o[o.length-1];return[parseInt(s,10),parseInt(l,10)]}return[0,0]}each(e){Object.entries(this._).forEach(([s,i])=>{e(s,i)})}eachCells(e,s){this._[e]&&this._[e].cells&&Object.entries(this._[e].cells).forEach(([i,r])=>{s(i,r)})}setData(e){e.len&&(this.len=e.len,delete e.len),this._=e}getData(){const{len:e}=this;return Object.assign({len:e},this._)}}class Cols{constructor({len:e,width:s,indexWidth:i,minWidth:r}){this._={},this.len=e,this.width=s,this.indexWidth=i,this.minWidth=r}setData(e){e.len&&(this.len=e.len,delete e.len),this._=e}getData(){const{len:e}=this;return Object.assign({len:e},this._)}getWidth(e){if(this.isHide(e))return 0;const s=this._[e];return s&&s.width?s.width:this.width}getOrNew(e){return this._[e]=this._[e]||{},this._[e]}setWidth(e,s){const i=this.getOrNew(e);i.width=s}unhide(e){let s=e;for(;s>0&&(s-=1,this.isHide(s));)this.setHide(s,!1)}isHide(e){const s=this._[e];return s&&s.hide}setHide(e,s){const i=this.getOrNew(e);s===!0?i.hide=!0:delete i.hide}setStyle(e,s){const i=this.getOrNew(e);i.style=s}sumWidth(e,s){return helper_rslib_entry_.rangeSum(e,s,i=>this.getWidth(i))}totalWidth(){return this.sumWidth(0,this.len)}}const en_rslib_entry_={toolbar:{undo:"Undo",redo:"Redo",print:"Print",paintformat:"Paint format",clearformat:"Clear format",format:"Format",fontName:"Font",fontSize:"Font size",fontBold:"Font bold",fontItalic:"Font italic",underline:"Underline",strike:"Strike",color:"Text color",bgcolor:"Fill color",border:"Borders",merge:"Merge cells",align:"Horizontal align",valign:"Vertical align",textwrap:"Text wrapping",freeze:"Freeze cell",autofilter:"Filter",formula:"Functions",more:"More"},contextmenu:{copy:"Copy",cut:"Cut",paste:"Paste",pasteValue:"Paste values only",pasteFormat:"Paste format only",hide:"Hide",insertRow:"Insert row",insertColumn:"Insert column",deleteSheet:"Delete",deleteRow:"Delete row",deleteColumn:"Delete column",deleteCell:"Delete cell",deleteCellText:"Delete cell text",validation:"Data validations",cellprintable:"Enable export",cellnonprintable:"Disable export",celleditable:"Enable editing",cellnoneditable:"Disable editing"},print:{size:"Paper size",orientation:"Page orientation",orientations:["Landscape","Portrait"]},format:{normal:"Normal",text:"Plain Text",number:"Number",percent:"Percent",rmb:"RMB",usd:"USD",eur:"EUR",date:"Date",time:"Time",datetime:"Date time",duration:"Duration"},formula:{sum:"Sum",average:"Average",max:"Max",min:"Min",_if:"IF",and:"AND",or:"OR",concat:"Concat"},validation:{required:"it must be required",notMatch:"it not match its validation rule",between:"it is between {} and {}",notBetween:"it is not between {} and {}",notIn:"it is not in list",equal:"it equal to {}",notEqual:"it not equal to {}",lessThan:"it less than {}",lessThanEqual:"it less than or equal to {}",greaterThan:"it greater than {}",greaterThanEqual:"it greater than or equal to {}"},error:{pasteForMergedCell:"Unable to do this for merged cells"},calendar:{weeks:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},button:{next:"Next",cancel:"Cancel",remove:"Remove",save:"Save",ok:"OK"},sort:{desc:"Sort Z -> A",asc:"Sort A -> Z"},filter:{empty:"empty"},dataValidation:{mode:"Mode",range:"Cell Range",criteria:"Criteria",modeType:{cell:"Cell",column:"Colun",row:"Row"},type:{list:"List",number:"Number",date:"Date",phone:"Phone",email:"Email"},operator:{be:"between",nbe:"not betwwen",lt:"less than",lte:"less than or equal to",gt:"greater than",gte:"greater than or equal to",eq:"equal to",neq:"not equal to"}}};let $languages=["en"];const $messages={en:en_rslib_entry_};function translate(n,e){if(e)for(const s of $languages){if(!e[s])break;let i=e[s];const r=n.match(/(?:\\.|[^.])+/g);for(let o=0;o<r.length;o+=1){const l=r[o],a=i[l];if(!a)break;if(o===r.length-1)return a;i=a}}}function t(n){let e=translate(n,$messages);return!e&&window&&window.x_spreadsheet&&window.x_spreadsheet.$messages&&(e=translate(n,window.x_spreadsheet.$messages)),e||""}function tf(n){return()=>t(n)}function locale(n,e,s=!1){s?$languages=[n]:$languages.unshift(n),e&&($messages[n]=e)}const rules={phone:/^[1-9]\d{10}$/,email:/w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/};function returnMessage(n,e,...s){let i="";return n||(i=t(`validation.${e}`,...s)),[n,i]}class Validator{constructor(e,s,i,r){this.required=s,this.value=i,this.type=e,this.operator=r,this.message=""}parseValue(e){const{type:s}=this;return s==="date"?new Date(e):s==="number"?Number(e):e}equals(e){let s=this.type===e.type&&this.required===e.required&&this.operator===e.operator;return s&&(s=Array.isArray(this.value)?helper_rslib_entry_.arrayEquals(this.value,e.value):this.value===e.value),s}values(){return this.value.split(",")}validate(e){const{required:s,operator:i,value:r,type:o}=this;if(s&&/^\s*$/.test(e))return returnMessage(!1,"required");if(/^\s*$/.test(e))return[!0];if(rules[o]&&!rules[o].test(e))return returnMessage(!1,"notMatch");if(o==="list")return returnMessage(this.values().includes(e),"notIn");if(i){const l=this.parseValue(e);if(i==="be"){const[a,c]=r;return returnMessage(l>=this.parseValue(a)&&l<=this.parseValue(c),"between",a,c)}if(i==="nbe"){const[a,c]=r;return returnMessage(l<this.parseValue(a)||l>this.parseValue(c),"notBetween",a,c)}if(i==="eq")return returnMessage(l===this.parseValue(r),"equal",r);if(i==="neq")return returnMessage(l!==this.parseValue(r),"notEqual",r);if(i==="lt")return returnMessage(l<this.parseValue(r),"lessThan",r);if(i==="lte")return returnMessage(l<=this.parseValue(r),"lessThanEqual",r);if(i==="gt")return returnMessage(l>this.parseValue(r),"greaterThan",r);if(i==="gte")return returnMessage(l>=this.parseValue(r),"greaterThanEqual",r)}return[!0]}}class Validation{constructor(e,s,i){this.refs=s,this.mode=e,this.validator=i}includes(e,s){const{refs:i}=this;for(let r=0;r<i.length;r+=1)if(CellRange.valueOf(i[r]).includes(e,s))return!0;return!1}addRef(e){this.remove(CellRange.valueOf(e)),this.refs.push(e)}remove(e){const s=[];this.refs.forEach(i=>{const r=CellRange.valueOf(i);r.intersects(e)?r.difference(e).forEach(l=>s.push(l.toString())):s.push(i)}),this.refs=s}getData(){const{refs:e,mode:s,validator:i}=this,{type:r,required:o,operator:l,value:a}=i;return{refs:e,mode:s,type:r,required:o,operator:l,value:a}}static valueOf({refs:e,mode:s,type:i,required:r,operator:o,value:l}){return new Validation(s,e,new Validator(i,r,l,o))}}class Validations{constructor(){this._=[],this.errors=new Map}getError(e,s){return this.errors.get(`${e}_${s}`)}validate(e,s,i){const r=this.get(e,s),o=`${e}_${s}`,{errors:l}=this;if(r!==null){const[a,c]=r.validator.validate(i);a?l.delete(o):l.set(o,c)}else l.delete(o);return!0}add(e,s,{type:i,required:r,value:o,operator:l}){const a=new Validator(i,r,o,l),c=this.getByValidator(a);c!==null?c.addRef(s):this._.push(new Validation(e,[s],a))}getByValidator(e){for(let s=0;s<this._.length;s+=1){const i=this._[s];if(i.validator.equals(e))return i}return null}get(e,s){for(let i=0;i<this._.length;i+=1){const r=this._[i];if(r.includes(e,s))return r}return null}remove(e){this.each(s=>{s.remove(e)})}each(e){this._.forEach(s=>e(s))}getData(){return this._.filter(e=>e.refs.length>0).map(e=>e.getData())}setData(e){this._=e.map(s=>Validation.valueOf(s))}}const defaultSettings={mode:"edit",view:{height:()=>document.documentElement.clientHeight,width:()=>document.documentElement.clientWidth},showGrid:!0,showToolbar:!0,showContextmenu:!0,showBottomBar:!0,row:{len:100,height:25},col:{len:26,width:100,indexWidth:60,minWidth:60},style:{bgcolor:"#ffffff",align:"left",valign:"middle",textwrap:!1,strike:!1,underline:!1,color:"#0a0a0a",font:{name:"Arial",size:10,bold:!1,italic:!1},format:"normal"}},toolbarHeight=41,bottombarHeight=41;function canPaste(n,e,s=()=>{}){const{merges:i}=this,r=e.clone(),[o,l]=n.size(),[a,c]=e.size();return o>a&&(r.eri=e.sri+o-1),l>c&&(r.eci=e.sci+l-1),i.intersects(r)?(s(t("error.pasteForMergedCell")),!1):!0}function copyPaste(n,e,s,i=!1){const{rows:r,merges:o}=this;(s==="all"||s==="format")&&(r.deleteCells(e,s),o.deleteWithin(e)),r.copyPaste(n,e,s,i,(l,a,c)=>{if(c&&c.merge){const[d,u]=c.merge;if(d<=0&&u<=0)return;o.add(new CellRange(l,a,l+d,a+u))}})}function cutPaste(n,e){const{clipboard:s,rows:i,merges:r}=this;i.cutPaste(n,e),r.move(n,e.sri-n.sri,e.sci-n.sci),s.clear()}function setStyleBorder(n,e,s){const{styles:i,rows:r}=this,o=r.getCellOrNew(n,e);let l={};o.style!==void 0&&(l=helper_rslib_entry_.cloneDeep(i[o.style])),l=helper_rslib_entry_.merge(l,{border:s}),o.style=this.addStyle(l)}function setStyleBorders({mode:n,style:e,color:s}){const{styles:i,selector:r,rows:o}=this,{sri:l,sci:a,eri:c,eci:d}=r.range,u=!this.isSingleSelected();if(!(!u&&(n==="inside"||n==="horizontal"||n==="vertical")))if(n!=="outside"||u){if(n==="none")r.range.each((f,m)=>{const p=o.getCell(f,m);if(p&&p.style!==void 0){const g=helper_rslib_entry_.cloneDeep(i[p.style]);delete g.border,p.style=this.addStyle(g)}});else if(n==="all"||n==="inside"||n==="outside"||n==="horizontal"||n==="vertical"){const f=[];for(let m=l;m<=c;m+=1)for(let p=a;p<=d;p+=1){const g=[];for(let D=0;D<f.length;D+=1){const[F,B,M,K]=f[D];if(m===F+M+1&&g.push(D),F<=m&&m<=F+M&&p===B){p+=K+1;break}}if(g.forEach(D=>f.splice(D,1)),p>d)break;const x=o.getCell(m,p);let[E,v]=[0,0];x&&x.merge&&([E,v]=x.merge,f.push([m,p,E,v]));const y=E>0&&m+E===c,w=v>0&&p+v===d;let S={};n==="all"?S={bottom:[e,s],top:[e,s],left:[e,s],right:[e,s]}:n==="inside"?(!w&&p<d&&(S.right=[e,s]),!y&&m<c&&(S.bottom=[e,s])):n==="horizontal"?!y&&m<c&&(S.bottom=[e,s]):n==="vertical"?!w&&p<d&&(S.right=[e,s]):n==="outside"&&u&&(l===m&&(S.top=[e,s]),(y||c===m)&&(S.bottom=[e,s]),a===p&&(S.left=[e,s]),(w||d===p)&&(S.right=[e,s])),Object.keys(S).length>0&&setStyleBorder.call(this,m,p,S),p+=v}}else if(n==="top"||n==="bottom")for(let f=a;f<=d;f+=1)n==="top"&&(setStyleBorder.call(this,l,f,{top:[e,s]}),f+=o.getCellMerge(l,f)[1]),n==="bottom"&&(setStyleBorder.call(this,c,f,{bottom:[e,s]}),f+=o.getCellMerge(c,f)[1]);else if(n==="left"||n==="right")for(let f=l;f<=c;f+=1)n==="left"&&(setStyleBorder.call(this,f,a,{left:[e,s]}),f+=o.getCellMerge(f,a)[0]),n==="right"&&(setStyleBorder.call(this,f,d,{right:[e,s]}),f+=o.getCellMerge(f,d)[0])}else setStyleBorder.call(this,l,a,{top:[e,s],bottom:[e,s],left:[e,s],right:[e,s]})}function getCellRowByY(n,e){const{rows:s}=this,i=this.freezeTotalHeight();let r=s.height;i+s.height<n&&(r-=e);const o=this.exceptRowSet;let l=0,a=r,{height:c}=s;for(;l<s.len&&!(a>n);l+=1)o.has(l)||(c=s.getHeight(l),a+=c);return a-=c,a<=0?{ri:-1,top:0,height:c}:{ri:l-1,top:a,height:c}}function getCellColByX(n,e){const{cols:s}=this,i=this.freezeTotalWidth();let r=s.indexWidth;i+s.indexWidth<n&&(r-=e);const[o,l,a]=helper_rslib_entry_.rangeReduceIf(0,s.len,r,s.indexWidth,n,c=>s.getWidth(c));return l<=0?{ci:-1,left:0,width:s.indexWidth}:{ci:o-1,left:l,width:a}}class DataProxy{constructor(e,s){this.settings=helper_rslib_entry_.merge(defaultSettings,s||{}),this.name=e||"sheet",this.freeze=[0,0],this.styles=[],this.merges=new Merges,this.rows=new Rows(this.settings.row),this.cols=new Cols(this.settings.col),this.validations=new Validations,this.hyperlinks={},this.comments={},this.selector=new Selector$1,this.scroll=new Scroll,this.history=new History,this.clipboard=new Clipboard,this.autoFilter=new AutoFilter,this.change=()=>{},this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map}addValidation(e,s,i){this.changeData(()=>{this.validations.add(e,s,i)})}removeValidation(){const{range:e}=this.selector;this.changeData(()=>{this.validations.remove(e)})}getSelectedValidator(){const{ri:e,ci:s}=this.selector,i=this.validations.get(e,s);return i?i.validator:null}getSelectedValidation(){const{ri:e,ci:s,range:i}=this.selector,r=this.validations.get(e,s),o={ref:i.toString()};return r!==null&&(o.mode=r.mode,o.validator=r.validator),o}canUndo(){return this.history.canUndo()}canRedo(){return this.history.canRedo()}undo(){this.history.undo(this.getData(),e=>{this.setData(e)})}redo(){this.history.redo(this.getData(),e=>{this.setData(e)})}copy(){this.clipboard.copy(this.selector.range)}copyToSystemClipboard(e){let s=[];const{sri:i,eri:r,sci:o,eci:l}=this.selector.range;for(let a=i;a<=r;a+=1){const c=[];for(let d=o;d<=l;d+=1){const u=this.getCell(a,d);c.push(u&&u.text||"")}s.push(c)}s=s.map(a=>a.join(" ")).join(`
3
+ `),e&&(e.clipboardData.clearData(),e.clipboardData.setData("text/plain",s),e.preventDefault()),navigator.clipboard&&navigator.clipboard.writeText(s).then(()=>{},a=>{console.log("text copy to the system clipboard error ",s,a)})}cut(){this.clipboard.cut(this.selector.range)}paste(e="all",s=()=>{}){const{clipboard:i,selector:r}=this;return i.isClear()||!canPaste.call(this,i.range,r.range,s)?!1:(this.changeData(()=>{i.isCopy()?copyPaste.call(this,i.range,r.range,e):i.isCut()&&cutPaste.call(this,i.range,r.range)}),!0)}pasteFromSystemClipboard(e,s){const{selector:i}=this;navigator.clipboard.readText().then(r=>{const o=this.parseClipboardContent(r);let l=i.ri;o.forEach(a=>{let c=i.ci;a.forEach(d=>{this.setCellText(l,c,d,"input"),c+=1}),l+=1}),e(),s(this.rows.getData())})}parseClipboardContent(e){const s=[],i=e.split(`
4
+ `);let r=0;return i.forEach(o=>{s[r]=o.split(" "),r+=1}),s}pasteFromText(e){let s=[];if(s=/\r\n/.test(e)?e.split(`\r
5
+ `).map(i=>i.replace(/"/g,"").split(" ")):e.split(`
6
+ `).map(i=>i.replace(/"/g,"").split(" ")),s.length){const{rows:i,selector:r}=this;this.changeData(()=>{i.paste(s,r.range)})}}autofill(e,s,i=()=>{}){const r=this.selector.range;return canPaste.call(this,r,e,i)?(this.changeData(()=>{copyPaste.call(this,r,e,s,!0)}),!0):!1}clearClipboard(){this.clipboard.clear()}calSelectedRangeByEnd(e,s){const{selector:i,rows:r,cols:o,merges:l}=this;let{sri:a,sci:c,eri:d,eci:u}=i.range;const f=i.ri,m=i.ci;let[p,g]=[e,s];return e<0&&(p=r.len-1),s<0&&(g=o.len-1),p>f?[a,d]=[f,p]:[a,d]=[p,f],g>m?[c,u]=[m,g]:[c,u]=[g,m],i.range=l.union(new CellRange(a,c,d,u)),i.range=l.union(i.range),i.range}calSelectedRangeByStart(e,s){const{selector:i,rows:r,cols:o,merges:l}=this;let a=l.getFirstIncludes(e,s);return a===null&&(a=new CellRange(e,s,e,s),e===-1&&(a.sri=0,a.eri=r.len-1),s===-1&&(a.sci=0,a.eci=o.len-1)),i.range=a,a}setSelectedCellAttr(e,s){this.changeData(()=>{const{selector:i,styles:r,rows:o}=this;if(e==="merge")s?this.merge():this.unmerge();else if(e==="border")setStyleBorders.call(this,s);else if(e==="formula"){const{ri:l,ci:a,range:c}=i;if(i.multiple()){const[d,u]=i.size(),{sri:f,sci:m,eri:p,eci:g}=c;if(d>1)for(let x=m;x<=g;x+=1){const E=o.getCellOrNew(p+1,x);E.text=`=${s}(${xy2expr(x,f)}:${xy2expr(x,p)})`}else if(u>1){const x=o.getCellOrNew(l,g+1);x.text=`=${s}(${xy2expr(m,l)}:${xy2expr(g,l)})`}}else{const d=o.getCellOrNew(l,a);d.text=`=${s}()`}}else i.range.each((l,a)=>{const c=o.getCellOrNew(l,a);let d={};if(c.style!==void 0&&(d=helper_rslib_entry_.cloneDeep(r[c.style])),e==="format")d.format=s,c.style=this.addStyle(d);else if(e==="font-bold"||e==="font-italic"||e==="font-name"||e==="font-size"){const u={};u[e.split("-")[1]]=s,d.font=Object.assign(d.font||{},u),c.style=this.addStyle(d)}else e==="strike"||e==="textwrap"||e==="underline"||e==="align"||e==="valign"||e==="color"||e==="bgcolor"?(d[e]=s,c.style=this.addStyle(d)):c[e]=s})})}setSelectedCellText(e,s="input"){const{autoFilter:i,selector:r,rows:o}=this,{ri:l,ci:a}=r;let c=l;this.unsortedRowMap.has(l)&&(c=this.unsortedRowMap.get(l));const d=o.getCell(c,a),u=d?d.text:"";if(this.setCellText(c,a,e,s),i.active()){const f=i.getFilter(a);if(f){const m=f.value.findIndex(p=>p===u);m>=0&&f.value.splice(m,1,e)}}}getSelectedCell(){const{ri:e,ci:s}=this.selector;let i=e;return this.unsortedRowMap.has(e)&&(i=this.unsortedRowMap.get(e)),this.rows.getCell(i,s)}xyInSelectedRect(e,s){const{left:i,top:r,width:o,height:l}=this.getSelectedRect(),a=e-this.cols.indexWidth,c=s-this.rows.height;return a>i&&a<i+o&&c>r&&c<r+l}getSelectedRect(){return this.getRect(this.selector.range)}getClipboardRect(){const{clipboard:e}=this;return e.isClear()?{left:-100,top:-100}:this.getRect(e.range)}getRect(e){const{scroll:s,rows:i,cols:r,exceptRowSet:o}=this,{sri:l,sci:a,eri:c,eci:d}=e;if(l<0&&a<0)return{left:0,l:0,top:0,t:0,scroll:s};const u=r.sumWidth(0,a),f=i.sumHeight(0,l,o),m=i.sumHeight(l,c+1,o),p=r.sumWidth(a,d+1);let g=u-s.x,x=f-s.y;const E=this.freezeTotalHeight(),v=this.freezeTotalWidth();return v>0&&v>u&&(g=u),E>0&&E>f&&(x=f),{l:u,t:f,left:g,top:x,height:m,width:p,scroll:s}}getCellRectByXY(e,s){const{scroll:i,merges:r,rows:o,cols:l}=this;let{ri:a,top:c,height:d}=getCellRowByY.call(this,s,i.y),{ci:u,left:f,width:m}=getCellColByX.call(this,e,i.x);if(u===-1&&(m=l.totalWidth()),a===-1&&(d=o.totalHeight()),a>=0||u>=0){const p=r.getFirstIncludes(a,u);p&&(a=p.sri,u=p.sci,{left:f,top:c,width:m,height:d}=this.cellRect(a,u))}return{ri:a,ci:u,left:f,top:c,width:m,height:d}}isSingleSelected(){const{sri:e,sci:s,eri:i,eci:r}=this.selector.range,o=this.getCell(e,s);if(o&&o.merge){const[l,a]=o.merge;if(e+l===i&&s+a===r)return!0}return!this.selector.multiple()}canUnmerge(){const{sri:e,sci:s,eri:i,eci:r}=this.selector.range,o=this.getCell(e,s);if(o&&o.merge){const[l,a]=o.merge;if(e+l===i&&s+a===r)return!0}return!1}merge(){const{selector:e,rows:s}=this;if(this.isSingleSelected())return;const[i,r]=e.size();if(i>1||r>1){const{sri:o,sci:l}=e.range;this.changeData(()=>{const a=s.getCellOrNew(o,l);a.merge=[i-1,r-1],this.merges.add(e.range),this.rows.deleteCells(e.range),this.rows.setCell(o,l,a)})}}unmerge(){const{selector:e}=this;if(!this.isSingleSelected())return;const{sri:s,sci:i}=e.range;this.changeData(()=>{this.rows.deleteCell(s,i,"merge"),this.merges.deleteWithin(e.range)})}canAutofilter(){return!this.autoFilter.active()}autofilter(){const{autoFilter:e,selector:s}=this;this.changeData(()=>{e.active()?(e.clear(),this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map):e.ref=s.range.toString()})}setAutoFilter(e,s,i,r){const{autoFilter:o}=this;o.addFilter(e,i,r),o.setSort(e,s),this.resetAutoFilter()}resetAutoFilter(){const{autoFilter:e,rows:s}=this;if(!e.active())return;const{sort:i}=e,{rset:r,fset:o}=e.filteredRows((c,d)=>s.getCell(c,d)),l=Array.from(o),a=Array.from(o);i&&l.sort((c,d)=>i.order==="asc"?c-d:i.order==="desc"?d-c:0),this.exceptRowSet=r,this.sortedRowMap=new Map,this.unsortedRowMap=new Map,l.forEach((c,d)=>{this.sortedRowMap.set(a[d],c),this.unsortedRowMap.set(c,a[d])})}deleteCell(e="all"){const{selector:s}=this;this.changeData(()=>{this.rows.deleteCells(s.range,e),(e==="all"||e==="format")&&this.merges.deleteWithin(s.range)})}insert(e,s=1){this.changeData(()=>{const{sri:i,sci:r}=this.selector.range,{rows:o,merges:l,cols:a}=this;let c=i;e==="row"?o.insert(i,s):e==="column"&&(o.insertColumn(r,s),c=r,a.len+=s,Object.keys(a._).reverse().forEach(d=>{const u=parseInt(d,10);u>=r&&(a._[u+s]=a._[u],delete a._[u])})),l.shift(e,c,s,(d,u,f,m)=>{const p=o.getCell(d,u);p.merge[0]+=f,p.merge[1]+=m})})}delete(e){this.changeData(()=>{const{rows:s,merges:i,selector:r,cols:o}=this,{range:l}=r,{sri:a,sci:c,eri:d,eci:u}=r.range,[f,m]=r.range.size();let p=a,g=f;e==="row"?s.delete(a,d):e==="column"&&(s.deleteColumn(c,u),p=l.sci,g=m,o.len-=u-c+1,Object.keys(o._).forEach(x=>{const E=parseInt(x,10);E>=c&&(E>u&&(o._[E-(u-c+1)]=o._[E]),delete o._[E])})),i.shift(e,p,-g,(x,E,v,y)=>{const w=s.getCell(x,E);w.merge[0]+=v,w.merge[1]+=y,w.merge[0]===0&&w.merge[1]===0&&delete w.merge})})}scrollx(e,s){const{scroll:i,freeze:r,cols:o}=this,[,l]=r,[a,c,d]=helper_rslib_entry_.rangeReduceIf(l,o.len,0,0,e,f=>o.getWidth(f));let u=c;e>0&&(u+=d),i.x!==u&&(i.ci=e>0?a:0,i.x=u,s())}scrolly(e,s){const{scroll:i,freeze:r,rows:o}=this,[l]=r,[a,c,d]=helper_rslib_entry_.rangeReduceIf(l,o.len,0,0,e,f=>o.getHeight(f));let u=c;e>0&&(u+=d),i.y!==u&&(i.ri=e>0?a:0,i.y=u,s())}cellRect(e,s){const{rows:i,cols:r}=this,o=r.sumWidth(0,s),l=i.sumHeight(0,e),a=i.getCell(e,s);let c=r.getWidth(s),d=i.getHeight(e);if(a!==null&&a.merge){const[u,f]=a.merge;if(u>0)for(let m=1;m<=u;m+=1)d+=i.getHeight(e+m);if(f>0)for(let m=1;m<=f;m+=1)c+=r.getWidth(s+m)}return{left:o,top:l,width:c,height:d,cell:a}}getCell(e,s){return this.rows.getCell(e,s)}getCellTextOrDefault(e,s){const i=this.getCell(e,s);return i&&i.text?i.text:""}getCellStyle(e,s){const i=this.getCell(e,s);return i&&i.style!==void 0?this.styles[i.style]:null}getCellStyleOrDefault(e,s){const{styles:i,rows:r}=this,o=r.getCell(e,s),l=o&&o.style!==void 0?i[o.style]:{};return helper_rslib_entry_.merge(this.defaultStyle(),l)}getSelectedCellStyle(){const{ri:e,ci:s}=this.selector;return this.getCellStyleOrDefault(e,s)}setCellText(e,s,i,r){const{rows:o,history:l,validations:a}=this;r==="finished"?(o.setCellText(e,s,""),l.add(this.getData()),o.setCellText(e,s,i)):(o.setCellText(e,s,i),this.change(this.getData())),a.validate(e,s,i)}freezeIsActive(){const[e,s]=this.freeze;return e>0||s>0}setFreeze(e,s){this.changeData(()=>{this.freeze=[e,s]})}freezeTotalWidth(){return this.cols.sumWidth(0,this.freeze[1])}freezeTotalHeight(){return this.rows.sumHeight(0,this.freeze[0])}setRowHeight(e,s){this.changeData(()=>{this.rows.setHeight(e,s)})}setColWidth(e,s){this.changeData(()=>{this.cols.setWidth(e,s)})}viewHeight(){const{view:e,showToolbar:s,showBottomBar:i}=this.settings;let r=e.height();return i&&(r-=bottombarHeight),s&&(r-=toolbarHeight),r}viewWidth(){return this.settings.view.width()}freezeViewRange(){const[e,s]=this.freeze;return new CellRange(0,0,e-1,s-1,this.freezeTotalWidth(),this.freezeTotalHeight())}contentRange(){const{rows:e,cols:s}=this,[i,r]=e.maxCell(),o=e.sumHeight(0,i+1),l=s.sumWidth(0,r+1);return new CellRange(0,0,i,r,l,o)}exceptRowTotalHeight(e,s){const{exceptRowSet:i,rows:r}=this,o=Array.from(i);let l=0;return o.forEach(a=>{if(a<e||a>s){const c=r.getHeight(a);l+=c}}),l}viewRange(){const{scroll:e,rows:s,cols:i,freeze:r,exceptRowSet:o}=this;let{ri:l,ci:a}=e;l<=0&&([l]=r),a<=0&&([,a]=r);let[c,d]=[0,0],[u,f]=[s.len,i.len];for(let m=l;m<s.len&&(o.has(m)||(d+=s.getHeight(m),u=m),!(d>this.viewHeight()));m+=1);for(let m=a;m<i.len&&(c+=i.getWidth(m),f=m,!(c>this.viewWidth()));m+=1);return new CellRange(l,a,u,f,c,d)}eachMergesInView(e,s){this.merges.filterIntersects(e).forEach(i=>s(i))}hideRowsOrCols(){const{rows:e,cols:s,selector:i}=this,[r,o]=i.size(),{sri:l,sci:a,eri:c,eci:d}=i.range;if(r===e.len)for(let u=a;u<=d;u+=1)s.setHide(u,!0);else if(o===s.len)for(let u=l;u<=c;u+=1)e.setHide(u,!0)}unhideRowsOrCols(e,s){this[`${e}s`].unhide(s)}rowEach(e,s,i){let r=0;const{rows:o}=this,l=this.exceptRowSet,a=[...l];let c=0;for(let d=0;d<a.length;d+=1)a[d]<e&&(c+=1);for(let d=e+c;d<=s+c;d+=1)if(l.has(d))c+=1;else{const u=o.getHeight(d);if(u>0&&(i(d,r,u),r+=u,r>this.viewHeight()))break}}colEach(e,s,i){let r=0;const{cols:o}=this;for(let l=e;l<=s;l+=1){const a=o.getWidth(l);if(a>0&&(i(l,r,a),r+=a,r>this.viewWidth()))break}}defaultStyle(){return this.settings.style}addStyle(e){const{styles:s}=this;for(let i=0;i<s.length;i+=1){const r=s[i];if(helper_rslib_entry_.equals(r,e))return i}return s.push(e),s.length-1}changeData(e){this.history.add(this.getData()),e(),this.change(this.getData())}setData(e){return Object.keys(e).forEach(s=>{if(s==="merges"||s==="rows"||s==="cols"||s==="validations")this[s].setData(e[s]);else if(s==="freeze"){const[i,r]=expr2xy(e[s]);this.freeze=[r,i]}else s==="autofilter"?this.autoFilter.setData(e[s]):e[s]!==void 0&&(this[s]=e[s])}),this}getData(){const{name:e,freeze:s,styles:i,merges:r,rows:o,cols:l,validations:a,autoFilter:c}=this;return{name:e,freeze:xy2expr(s[1],s[0]),styles:i,merges:r.getData(),rows:o.getData(),cols:l.getData(),validations:a.getData(),autofilter:c.getData()}}}function bind(n,e,s){n.addEventListener(e,s)}function unbind(n,e,s){n.removeEventListener(e,s)}function unbindClickoutside(n){n.xclickoutside&&(unbind(window.document.body,"click",n.xclickoutside),delete n.xclickoutside)}function bindClickoutside(n,e){n.xclickoutside=s=>{s.detail===2||n.contains(s.target)||(e?e(n):(n.hide(),unbindClickoutside(n)))},bind(window.document.body,"click",n.xclickoutside)}function mouseMoveUp(n,e,s){bind(n,"mousemove",e);const i=n;i.xEvtUp=r=>{unbind(n,"mousemove",e),unbind(n,"mouseup",n.xEvtUp),s(r)},bind(n,"mouseup",n.xEvtUp)}function calTouchDirection(n,e,s,i){let r="";Math.abs(n)>Math.abs(e)?(r=n>0?"right":"left",i(r,n,s)):(r=e>0?"down":"up",i(r,e,s))}function bindTouch(n,{move:e,end:s}){let i=0,r=0;bind(n,"touchstart",o=>{const{pageX:l,pageY:a}=o.touches[0];i=l,r=a}),bind(n,"touchmove",o=>{if(!e)return;const{pageX:l,pageY:a}=o.changedTouches[0],c=l-i,d=a-r;(Math.abs(c)>10||Math.abs(d)>10)&&(calTouchDirection(c,d,o,e),i=l,r=a),o.preventDefault()}),bind(n,"touchend",o=>{if(!s)return;const{pageX:l,pageY:a}=o.changedTouches[0],c=l-i,d=a-r;calTouchDirection(c,d,o,s)})}function createEventEmitter(){const n=new Map;function e(l,a){const c=()=>{const u=n.get(l);return Array.isArray(u)&&u.push(a)||!1},d=()=>n.set(l,[].concat(a));return n.has(l)&&c()||d()}function s(l,a){const c=()=>{const d=n.get(l);for(const u of d)u.call(null,...a)};return n.has(l)&&c()}function i(l,a){const c=()=>{const d=n.get(l),u=d.indexOf(a);return u>=0&&d.splice(u,1)&&n.get(l).length===0&&n.delete(l)};return n.has(l)&&c()}function r(l,a){const c=(...d)=>{a.call(null,...d),i(l,c)};return e(l,c)}function o(){n.clear()}return{get current(){return n},on:e,once:r,fire:s,removeListener:i,removeAllListeners:o}}const cssPrefix="x-spreadsheet";class Resizer{constructor(e=!1,s){this.moving=!1,this.vertical=e,this.el=h("div",`${cssPrefix}-resizer ${e?"vertical":"horizontal"}`).children(this.unhideHoverEl=h("div",`${cssPrefix}-resizer-hover`).on("dblclick.stop",i=>this.mousedblclickHandler(i)).css("position","absolute").hide(),this.hoverEl=h("div",`${cssPrefix}-resizer-hover`).on("mousedown.stop",i=>this.mousedownHandler(i)),this.lineEl=h("div",`${cssPrefix}-resizer-line`).hide()).hide(),this.cRect=null,this.finishedFn=null,this.minDistance=s,this.unhideFn=()=>{}}showUnhide(e){this.unhideIndex=e,this.unhideHoverEl.show()}hideUnhide(){this.unhideHoverEl.hide()}show(e,s){const{moving:i,vertical:r,hoverEl:o,lineEl:l,el:a,unhideHoverEl:c}=this;if(i)return;this.cRect=e;const{left:d,top:u,width:f,height:m}=e;a.offset({left:r?d+f-5:d,top:r?u:u+m-5}).show(),o.offset({width:r?5:f,height:r?m:5}),l.offset({width:r?0:s.width,height:r?s.height:0}),c.offset({left:r?5-f:d,top:r?u:5-m,width:r?5:f,height:r?m:5})}hide(){this.el.offset({left:0,top:0}).hide(),this.hideUnhide()}mousedblclickHandler(){this.unhideIndex&&this.unhideFn(this.unhideIndex)}mousedownHandler(e){let s=e;const{el:i,lineEl:r,cRect:o,vertical:l,minDistance:a}=this;let c=l?o.width:o.height;r.show(),mouseMoveUp(window,d=>{this.moving=!0,s!==null&&d.buttons===1&&(l?(c+=d.movementX,c>a&&i.css("left",`${o.left+c}px`)):(c+=d.movementY,c>a&&i.css("top",`${o.top+c}px`)),s=d)},()=>{s=null,r.hide(),this.moving=!1,this.hide(),this.finishedFn&&(c<a&&(c=a),this.finishedFn(o,c))})}}class Scrollbar{constructor(e){this.vertical=e,this.moveFn=null,this.el=h("div",`${cssPrefix}-scrollbar ${e?"vertical":"horizontal"}`).child(this.contentEl=h("div","")).on("mousemove.stop",()=>{}).on("scroll.stop",s=>{const{scrollTop:i,scrollLeft:r}=s.target;this.moveFn&&this.moveFn(this.vertical?i:r,s)})}move(e){return this.el.scroll(e),this}scroll(){return this.el.scroll()}set(e,s){const i=e-1;if(s>i){const r=this.vertical?"height":"width";this.el.css(r,`${i-15}px`).show(),this.contentEl.css(this.vertical?"width":"height","1px").css(r,`${s}px`)}else this.el.hide();return this}}const selectorHeightBorderWidth=3;let startZIndex=10;class SelectorElement{constructor(e=!1,s=!0){this.useHideInput=e,this.autoFocus=s,this.inputChange=()=>{},this.cornerEl=h("div",`${cssPrefix}-selector-corner`),this.areaEl=h("div",`${cssPrefix}-selector-area`).child(this.cornerEl).hide(),this.clipboardEl=h("div",`${cssPrefix}-selector-clipboard`).hide(),this.autofillEl=h("div",`${cssPrefix}-selector-autofill`).hide(),this.el=h("div",`${cssPrefix}-selector`).css("z-index",`${startZIndex}`).children(this.areaEl,this.clipboardEl,this.autofillEl).hide(),e&&(this.hideInput=h("input","").on("compositionend",i=>{this.inputChange(i.target.value)}),this.el.child(this.hideInputDiv=h("div","hide-input").child(this.hideInput)),this.el.child(this.hideInputDiv=h("div","hide-input").child(this.hideInput))),startZIndex+=1}setOffset(e){return this.el.offset(e).show(),this}hide(){return this.el.hide(),this}setAreaOffset(e){const{left:s,top:i,width:r,height:o}=e,l={width:r-selectorHeightBorderWidth+.8,height:o-selectorHeightBorderWidth+.8,left:s-.8,top:i-.8};this.areaEl.offset(l).show(),this.useHideInput&&(this.hideInputDiv.offset(l),this.autoFocus?this.hideInput.val("").focus():this.hideInput.val(""))}setClipboardOffset(e){const{left:s,top:i,width:r,height:o}=e;this.clipboardEl.offset({left:s,top:i,width:r-5,height:o-5})}showAutofill(e){const{left:s,top:i,width:r,height:o}=e;this.autofillEl.offset({width:r-selectorHeightBorderWidth,height:o-selectorHeightBorderWidth,left:s,top:i}).show()}hideAutofill(){this.autofillEl.hide()}showClipboard(){this.clipboardEl.show()}hideClipboard(){this.clipboardEl.hide()}}function calBRAreaOffset(n){const{data:e}=this,{left:s,top:i,width:r,height:o,scroll:l,l:a,t:c}=n,d=e.freezeTotalWidth(),u=e.freezeTotalHeight();let f=s-d;d>a&&(f-=l.x);let m=i-u;return u>c&&(m-=l.y),{left:f,top:m,width:r,height:o}}function calTAreaOffset(n){const{data:e}=this,{left:s,width:i,height:r,l:o,t:l,scroll:a}=n,c=e.freezeTotalWidth();let d=s-c;return c>o&&(d-=a.x),{left:d,top:l,width:i,height:r}}function calLAreaOffset(n){const{data:e}=this,{top:s,width:i,height:r,l:o,t:l,scroll:a}=n,c=e.freezeTotalHeight();let d=s-c;return c>l&&(d-=a.y),{left:o,top:d,width:i,height:r}}function setBRAreaOffset(n){const{br:e}=this;e.setAreaOffset(calBRAreaOffset.call(this,n))}function setTLAreaOffset(n){const{tl:e}=this;e.setAreaOffset(n)}function setTAreaOffset(n){const{t:e}=this;e.setAreaOffset(calTAreaOffset.call(this,n))}function setLAreaOffset(n){const{l:e}=this;e.setAreaOffset(calLAreaOffset.call(this,n))}function setLClipboardOffset(n){const{l:e}=this;e.setClipboardOffset(calLAreaOffset.call(this,n))}function setBRClipboardOffset(n){const{br:e}=this;e.setClipboardOffset(calBRAreaOffset.call(this,n))}function setTLClipboardOffset(n){const{tl:e}=this;e.setClipboardOffset(n)}function setTClipboardOffset(n){const{t:e}=this;e.setClipboardOffset(calTAreaOffset.call(this,n))}function setAllAreaOffset(n){setBRAreaOffset.call(this,n),setTLAreaOffset.call(this,n),setTAreaOffset.call(this,n),setLAreaOffset.call(this,n)}function setAllClipboardOffset(n){setBRClipboardOffset.call(this,n),setTLClipboardOffset.call(this,n),setTClipboardOffset.call(this,n),setLClipboardOffset.call(this,n)}class Selector{constructor(e){const{autoFocus:s}=e.settings;this.inputChange=()=>{},this.data=e,this.br=new SelectorElement(!0,s),this.t=new SelectorElement,this.l=new SelectorElement,this.tl=new SelectorElement,this.br.inputChange=i=>{this.inputChange(i)},this.br.el.show(),this.offset=null,this.areaOffset=null,this.indexes=null,this.range=null,this.arange=null,this.el=h("div",`${cssPrefix}-selectors`).children(this.tl.el,this.t.el,this.l.el,this.br.el).hide(),this.lastri=-1,this.lastci=-1,startZIndex+=1}resetData(e){this.data=e,this.range=e.selector.range,this.resetAreaOffset()}hide(){this.el.hide()}resetOffset(){const{data:e,tl:s,t:i,l:r,br:o}=this,l=e.freezeTotalHeight(),a=e.freezeTotalWidth();l>0||a>0?(s.setOffset({width:a,height:l}),i.setOffset({left:a,height:l}),r.setOffset({top:l,width:a}),o.setOffset({left:a,top:l})):(s.hide(),i.hide(),r.hide(),o.setOffset({left:0,top:0}))}resetAreaOffset(){const e=this.data.getSelectedRect(),s=this.data.getClipboardRect();setAllAreaOffset.call(this,e),setAllClipboardOffset.call(this,s),this.resetOffset()}resetBRTAreaOffset(){const e=this.data.getSelectedRect(),s=this.data.getClipboardRect();setBRAreaOffset.call(this,e),setTAreaOffset.call(this,e),setBRClipboardOffset.call(this,s),setTClipboardOffset.call(this,s),this.resetOffset()}resetBRLAreaOffset(){const e=this.data.getSelectedRect(),s=this.data.getClipboardRect();setBRAreaOffset.call(this,e),setLAreaOffset.call(this,e),setBRClipboardOffset.call(this,s),setLClipboardOffset.call(this,s),this.resetOffset()}set(e,s,i=!0){const{data:r}=this,o=r.calSelectedRangeByStart(e,s),{sri:l,sci:a}=o;if(i){let[c,d]=[e,s];e<0&&(c=0),s<0&&(d=0),r.selector.setIndexes(c,d),this.indexes=[c,d]}this.moveIndexes=[l,a],this.range=o,this.resetAreaOffset(),this.el.show()}setEnd(e,s,i=!0){const{data:r,lastri:o,lastci:l}=this;if(i){if(e===o&&s===l)return;this.lastri=e,this.lastci=s}this.range=r.calSelectedRangeByEnd(e,s),setAllAreaOffset.call(this,this.data.getSelectedRect())}reset(){const{eri:e,eci:s}=this.data.selector.range;this.setEnd(e,s)}showAutofill(e,s){if(e===-1&&s===-1)return;const{sri:i,sci:r,eri:o,eci:l}=this.range,[a,c]=[e,s],d=i-e,u=r-s,f=o-e,m=l-s;if(u>0)this.arange=new CellRange(i,c,o,r-1);else if(d>0)this.arange=new CellRange(a,r,i-1,l);else if(m<0)this.arange=new CellRange(i,l+1,o,c);else if(f<0)this.arange=new CellRange(o+1,r,a,l);else{this.arange=null;return}if(this.arange!==null){const p=this.data.getRect(this.arange);p.width+=2,p.height+=2;const{br:g,l:x,t:E,tl:v}=this;g.showAutofill(calBRAreaOffset.call(this,p)),x.showAutofill(calLAreaOffset.call(this,p)),E.showAutofill(calTAreaOffset.call(this,p)),v.showAutofill(p)}}hideAutofill(){["br","l","t","tl"].forEach(e=>{this[e].hideAutofill()})}showClipboard(){const e=this.data.getClipboardRect();setAllClipboardOffset.call(this,e),["br","l","t","tl"].forEach(s=>{this[s].showClipboard()})}hideClipboard(){["br","l","t","tl"].forEach(e=>{this[e].hideClipboard()})}}function inputMovePrev(n){n.preventDefault(),n.stopPropagation();const{filterItems:e}=this;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex-=1,this.itemIndex<0&&(this.itemIndex=e.length-1),e[this.itemIndex].toggle())}function inputMoveNext(n){n.stopPropagation();const{filterItems:e}=this;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex+=1,this.itemIndex>e.length-1&&(this.itemIndex=0),e[this.itemIndex].toggle())}function inputEnter(n){n.preventDefault();const{filterItems:e}=this;e.length<=0||(n.stopPropagation(),this.itemIndex<0&&(this.itemIndex=0),e[this.itemIndex].el.click(),this.hide())}function inputKeydownHandler(n){const{keyCode:e}=n;switch(n.ctrlKey&&n.stopPropagation(),e){case 37:n.stopPropagation();break;case 38:inputMovePrev.call(this,n);break;case 39:n.stopPropagation();break;case 40:inputMoveNext.call(this,n);break;case 13:inputEnter.call(this,n);break;case 9:inputEnter.call(this,n);break;default:n.stopPropagation();break}}class Suggest{constructor(e,s,i="200px"){this.filterItems=[],this.items=e,this.el=h("div",`${cssPrefix}-suggest`).css("width",i).hide(),this.itemClick=s,this.itemIndex=-1}setOffset(e){this.el.cssRemoveKeys("top","bottom").offset(e)}hide(){const{el:e}=this;this.filterItems=[],this.itemIndex=-1,e.hide(),unbindClickoutside(this.el.parent())}setItems(e){this.items=e}search(e){let{items:s}=this;if(/^\s*$/.test(e)||(s=s.filter(r=>(r.key||r).startsWith(e.toUpperCase()))),s=s.map(r=>{let{title:o}=r;o?typeof o=="function"&&(o=o()):o=r;const l=h("div",`${cssPrefix}-item`).child(o).on("click.stop",()=>{this.itemClick(r),this.hide()});return r.label&&l.child(h("div","label").html(r.label)),l}),this.filterItems=s,s.length<=0)return;const{el:i}=this;i.html("").children(...s).show(),bindClickoutside(i.parent(),()=>{this.hide()})}bindInputEvents(e){e.on("keydown",s=>inputKeydownHandler.call(this,s))}}class Icon extends Element{constructor(e){super("div",`${cssPrefix}-icon`),this.iconNameEl=h("div",`${cssPrefix}-icon-img ${e}`),this.child(this.iconNameEl)}setName(e){this.iconNameEl.className(`${cssPrefix}-icon-img ${e}`)}}function addMonth(n,e){n.setMonth(n.getMonth()+e)}function weekday(n,e){const s=new Date(n);return s.setDate(e-n.getDay()+1),s}function monthDays(n,e,s){const i=new Date(n,e,1,23,59,59),r=[[],[],[],[],[],[]];for(let o=0;o<6;o+=1)for(let l=0;l<7;l+=1){const a=7*o+l,c=weekday(i,a),d=c.getMonth()!==e,u=c.getMonth()===s.getMonth()&&c.getDate()===s.getDate();r[o][l]={d:c,disabled:d,active:u}}return r}class Calendar{constructor(e){this.value=e,this.cvalue=new Date(e),this.headerLeftEl=h("div","calendar-header-left"),this.bodyEl=h("tbody",""),this.buildAll(),this.el=h("div","x-spreadsheet-calendar").children(h("div","calendar-header").children(this.headerLeftEl,h("div","calendar-header-right").children(h("a","calendar-prev").on("click.stop",()=>this.prev()).child(new Icon("chevron-left")),h("a","calendar-next").on("click.stop",()=>this.next()).child(new Icon("chevron-right")))),h("table","calendar-body").children(h("thead","").child(h("tr","").children(...t("calendar.weeks").map(s=>h("th","cell").child(s)))),this.bodyEl)),this.selectChange=()=>{}}setValue(e){this.value=e,this.cvalue=new Date(e),this.buildAll()}prev(){const{value:e}=this;addMonth(e,-1),this.buildAll()}next(){const{value:e}=this;addMonth(e,1),this.buildAll()}buildAll(){this.buildHeaderLeft(),this.buildBody()}buildHeaderLeft(){const{value:e}=this;this.headerLeftEl.html(`${t("calendar.months")[e.getMonth()]} ${e.getFullYear()}`)}buildBody(){const{value:e,cvalue:s,bodyEl:i}=this,o=monthDays(e.getFullYear(),e.getMonth(),s).map(l=>{const a=l.map(c=>{let d="cell";return c.disabled&&(d+=" disabled"),c.active&&(d+=" active"),h("td","").child(h("div",d).on("click.stop",()=>{this.selectChange(c.d)}).child(c.d.getDate().toString()))});return h("tr","").children(...a)});i.html("").children(...o)}}class Datepicker{constructor(){this.calendar=new Calendar(new Date),this.el=h("div",`${cssPrefix}-datepicker`).child(this.calendar.el).hide()}setValue(e){const{calendar:s}=this;return typeof e=="string"?/^\d{4}-\d{1,2}-\d{1,2}$/.test(e)&&s.setValue(new Date(e.replace(new RegExp("-","g"),"/"))):e instanceof Date&&s.setValue(e),this}change(e){this.calendar.selectChange=s=>{e(s),this.hide()}}show(){this.el.show()}hide(){this.el.hide()}}function resetTextareaSize(){const{inputText:n}=this;if(!/^\s*$/.test(n)){const{textlineEl:e,textEl:s,areaOffset:i}=this,r=n.split(`
7
+ `),o=Math.max(...r.map(f=>f.length)),a=e.offset().width/n.length,c=(o+1)*a+5,d=this.viewFn().width-i.left-a;let u=r.length;if(c>i.width){let f=c;c>d&&(f=d,u+=parseInt(c/d,10),u+=c%d>0?1:0),s.css("width",`${f}px`)}u*=this.rowHeight,u>i.height&&s.css("height",`${u}px`)}}function insertText({target:n},e){const{value:s,selectionEnd:i}=n,r=`${s.slice(0,i)}${e}${s.slice(i)}`;n.value=r,n.setSelectionRange(i+1,i+1),this.inputText=r,this.textlineEl.html(r),resetTextareaSize.call(this)}function keydownEventHandler(n){const{keyCode:e,altKey:s}=n;e!==13&&e!==9&&n.stopPropagation(),e===13&&s&&(insertText.call(this,n,`
8
+ `),n.stopPropagation()),e===13&&!s&&n.preventDefault()}function inputEventHandler(n){const e=n.target.value,{suggest:s,textlineEl:i,validator:r}=this,{cell:o}=this;if(o!==null)if("editable"in o&&o.editable===!0||o.editable===void 0){if(this.inputText=e,r)r.type==="list"?s.search(e):s.hide();else{const l=e.lastIndexOf("=");l!==-1?s.search(e.substring(l+1)):s.hide()}i.html(e),resetTextareaSize.call(this),this.change("input",e)}else n.target.value=o.text||"";else{if(this.inputText=e,r)r.type==="list"?s.search(e):s.hide();else{const l=e.lastIndexOf("=");l!==-1?s.search(e.substring(l+1)):s.hide()}i.html(e),resetTextareaSize.call(this),this.change("input",e)}}function setTextareaRange(n){const{el:e}=this.textEl;setTimeout(()=>{e.focus(),e.setSelectionRange(n,n)},0)}function setText(n,e){const{textEl:s,textlineEl:i}=this;s.el.blur(),s.val(n),i.html(n),setTextareaRange.call(this,e)}function suggestItemClick(n){const{inputText:e,validator:s}=this;let i=0;if(s&&s.type==="list")this.inputText=n,i=this.inputText.length;else{const r=e.lastIndexOf("="),o=e.substring(0,r+1);let l=e.substring(r+1);l=l.indexOf(")")!==-1?l.substring(l.indexOf(")")):"",this.inputText=`${o+n.key}(`,i=this.inputText.length,this.inputText+=`)${l}`}setText.call(this,this.inputText,i)}function resetSuggestItems(){this.suggest.setItems(this.formulas)}function dateFormat(n){let e=n.getMonth()+1,s=n.getDate();return e<10&&(e=`0${e}`),s<10&&(s=`0${s}`),`${n.getFullYear()}-${e}-${s}`}class Editor{constructor(e,s,i){this.viewFn=s,this.rowHeight=i,this.formulas=e,this.suggest=new Suggest(e,r=>{suggestItemClick.call(this,r)}),this.datepicker=new Datepicker,this.datepicker.change(r=>{this.setText(dateFormat(r)),this.clear()}),this.areaEl=h("div",`${cssPrefix}-editor-area`).children(this.textEl=h("textarea","").on("input",r=>inputEventHandler.call(this,r)).on("paste.stop",()=>{}).on("keydown",r=>keydownEventHandler.call(this,r)),this.textlineEl=h("div","textline"),this.suggest.el,this.datepicker.el).on("mousemove.stop",()=>{}).on("mousedown.stop",()=>{}),this.el=h("div",`${cssPrefix}-editor`).child(this.areaEl).hide(),this.suggest.bindInputEvents(this.textEl),this.areaOffset=null,this.freeze={w:0,h:0},this.cell=null,this.inputText="",this.change=()=>{}}setFreezeLengths(e,s){this.freeze.w=e,this.freeze.h=s}clear(){this.inputText!==""&&this.change("finished",this.inputText),this.cell=null,this.areaOffset=null,this.inputText="",this.el.hide(),this.textEl.val(""),this.textlineEl.html(""),resetSuggestItems.call(this),this.datepicker.hide()}setOffset(e,s="top"){const{textEl:i,areaEl:r,suggest:o,freeze:l,el:a}=this;if(e){this.areaOffset=e;const{left:c,top:d,width:u,height:f,l:m,t:p}=e,g={left:0,top:0};l.w>m&&l.h>p||(l.w<m&&l.h<p?(g.left=l.w,g.top=l.h):l.w>m?g.top=l.h:l.h>p&&(g.left=l.w)),a.offset(g),r.offset({left:c-g.left-.8,top:d-g.top-.8}),i.offset({width:u-9+.8,height:f-3+.8});const x={left:0};x[s]=f,o.setOffset(x),o.hide()}}setCell(e,s){if(e&&e.editable===!1)return;const{el:i,datepicker:r,suggest:o}=this;i.show(),this.cell=e;const l=e&&e.text||"";if(this.setText(l),this.validator=s,s){const{type:a}=s;a==="date"&&(r.show(),/^\s*$/.test(l)||r.setValue(l)),a==="list"&&(o.setItems(s.values()),o.search(""))}}setText(e){this.inputText=e,setText.call(this,e,e.length),resetTextareaSize.call(this)}}class Button extends Element{constructor(e,s=""){super("div",`${cssPrefix}-button ${s}`),this.child(t(`button.${e}`))}}function dpr(){return window.devicePixelRatio||1}function thinLineWidth(){return dpr()-.5}function npx(n){return parseInt(n*dpr(),10)}function npxLine(n){const e=npx(n);return e>0?e-.5:.5}class DrawBox{constructor(e,s,i,r,o=0){this.x=e,this.y=s,this.width=i,this.height=r,this.padding=o,this.bgcolor="#ffffff",this.borderTop=null,this.borderRight=null,this.borderBottom=null,this.borderLeft=null}setBorders({top:e,bottom:s,left:i,right:r}){e&&(this.borderTop=e),r&&(this.borderRight=r),s&&(this.borderBottom=s),i&&(this.borderLeft=i)}innerWidth(){return this.width-2*this.padding-2}innerHeight(){return this.height-2*this.padding-2}textx(e){const{width:s,padding:i}=this;let{x:r}=this;return e==="left"?r+=i:e==="center"?r+=s/2:e==="right"&&(r+=s-i),r}texty(e,s){const{height:i,padding:r}=this;let{y:o}=this;return e==="top"?o+=r:e==="middle"?o+=i/2-s/2:e==="bottom"&&(o+=i-r-s),o}topxys(){const{x:e,y:s,width:i}=this;return[[e,s],[e+i,s]]}rightxys(){const{x:e,y:s,width:i,height:r}=this;return[[e+i,s],[e+i,s+r]]}bottomxys(){const{x:e,y:s,width:i,height:r}=this;return[[e,s+r],[e+i,s+r]]}leftxys(){const{x:e,y:s,height:i}=this;return[[e,s],[e,s+i]]}}function drawFontLine(n,e,s,i,r,o,l){const a={x:0,y:0};n==="underline"?r==="bottom"?a.y=0:r==="top"?a.y=-(o+2):a.y=-o/2:n==="strike"&&(r==="bottom"?a.y=o/2:r==="top"&&(a.y=-(o/2+2))),i==="center"?a.x=l/2:i==="right"&&(a.x=l),this.line([e-a.x,s-a.y],[e-a.x+l,s-a.y])}class Draw{constructor(e,s,i){this.el=e,this.ctx=e.getContext("2d"),this.resize(s,i),this.ctx.scale(dpr(),dpr())}resize(e,s){this.el.style.width=`${e}px`,this.el.style.height=`${s}px`,this.el.width=npx(e),this.el.height=npx(s)}clear(){const{width:e,height:s}=this.el;return this.ctx.clearRect(0,0,e,s),this}attr(e){return Object.assign(this.ctx,e),this}save(){return this.ctx.save(),this.ctx.beginPath(),this}restore(){return this.ctx.restore(),this}beginPath(){return this.ctx.beginPath(),this}translate(e,s){return this.ctx.translate(npx(e),npx(s)),this}scale(e,s){return this.ctx.scale(e,s),this}clearRect(e,s,i,r){return this.ctx.clearRect(e,s,i,r),this}fillRect(e,s,i,r){return this.ctx.fillRect(npx(e)-.5,npx(s)-.5,npx(i),npx(r)),this}fillText(e,s,i){return this.ctx.fillText(e,npx(s),npx(i)),this}text(e,s,i={},r=!0){const{ctx:o}=this,{align:l,valign:a,font:c,color:d,strike:u,underline:f}=i,m=s.textx(l);o.save(),o.beginPath(),this.attr({textAlign:l,textBaseline:a,font:`${c.italic?"italic":""} ${c.bold?"bold":""} ${npx(c.size)}px ${c.name}`,fillStyle:d,strokeStyle:d});const p=`${e}`.split(`
9
+ `),g=s.innerWidth(),x=[];p.forEach(y=>{const w=o.measureText(y).width;if(r&&w>npx(g)){let S={w:0,len:0,start:0};for(let D=0;D<y.length;D+=1)S.w>=npx(g)&&(x.push(y.substr(S.start,S.len)),S={w:0,len:0,start:D}),S.len+=1,S.w+=o.measureText(y[D]).width+1;S.len>0&&x.push(y.substr(S.start,S.len))}else x.push(y)});const E=(x.length-1)*(c.size+2);let v=s.texty(a,E);return x.forEach(y=>{const w=o.measureText(y).width;this.fillText(y,m,v),u&&drawFontLine.call(this,"strike",m,v,l,a,c.size,w),f&&drawFontLine.call(this,"underline",m,v,l,a,c.size,w),v+=c.size+2}),o.restore(),this}border(e,s){const{ctx:i}=this;return i.lineWidth=thinLineWidth,i.strokeStyle=s,e==="medium"?i.lineWidth=npx(2)-.5:e==="thick"?i.lineWidth=npx(3):e==="dashed"?i.setLineDash([npx(3),npx(2)]):e==="dotted"?i.setLineDash([npx(1),npx(1)]):e==="double"&&i.setLineDash([npx(2),0]),this}line(...e){const{ctx:s}=this;if(e.length>1){s.beginPath();const[i,r]=e[0];s.moveTo(npxLine(i),npxLine(r));for(let o=1;o<e.length;o+=1){const[l,a]=e[o];s.lineTo(npxLine(l),npxLine(a))}s.stroke()}return this}strokeBorders(e){const{ctx:s}=this;s.save();const{borderTop:i,borderRight:r,borderBottom:o,borderLeft:l}=e;i&&(this.border(...i),this.line(...e.topxys())),r&&(this.border(...r),this.line(...e.rightxys())),o&&(this.border(...o),this.line(...e.bottomxys())),l&&(this.border(...l),this.line(...e.leftxys())),s.restore()}dropdown(e){const{ctx:s}=this,{x:i,y:r,width:o,height:l}=e,a=i+o-15,c=r+l-15;s.save(),s.beginPath(),s.moveTo(npx(a),npx(c)),s.lineTo(npx(a+8),npx(c)),s.lineTo(npx(a+4),npx(c+6)),s.closePath(),s.fillStyle="rgba(0, 0, 0, .45)",s.fill(),s.restore()}error(e){const{ctx:s}=this,{x:i,y:r,width:o}=e,l=i+o-1;s.save(),s.beginPath(),s.moveTo(npx(l-8),npx(r-1)),s.lineTo(npx(l),npx(r-1)),s.lineTo(npx(l),npx(r+8)),s.closePath(),s.fillStyle="rgba(255, 0, 0, .65)",s.fill(),s.restore()}frozen(e){const{ctx:s}=this,{x:i,y:r,width:o}=e,l=i+o-1;s.save(),s.beginPath(),s.moveTo(npx(l-8),npx(r-1)),s.lineTo(npx(l),npx(r-1)),s.lineTo(npx(l),npx(r+8)),s.closePath(),s.fillStyle="rgba(0, 255, 0, .85)",s.fill(),s.restore()}rect(e,s){const{ctx:i}=this,{x:r,y:o,width:l,height:a,bgcolor:c}=e;i.save(),i.beginPath(),i.fillStyle=c||"#fff",i.rect(npxLine(r+1),npxLine(o+1),npx(l-2),npx(a-2)),i.clip(),i.fill(),s(),i.restore()}}const baseFonts=[{key:"Arial",title:"Arial"},{key:"Helvetica",title:"Helvetica"},{key:"Source Sans Pro",title:"Source Sans Pro"},{key:"Comic Sans MS",title:"Comic Sans MS"},{key:"Courier New",title:"Courier New"},{key:"Verdana",title:"Verdana"},{key:"Lato",title:"Lato"}],fontSizes=[{pt:7.5,px:10},{pt:8,px:11},{pt:9,px:12},{pt:10,px:13},{pt:10.5,px:14},{pt:11,px:15},{pt:12,px:16},{pt:14,px:18.7},{pt:15,px:20},{pt:16,px:21.3},{pt:18,px:24},{pt:22,px:29.3},{pt:24,px:32},{pt:26,px:34.7},{pt:36,px:48},{pt:42,px:56}];function getFontSizePxByPt(n){for(let e=0;e<fontSizes.length;e+=1){const s=fontSizes[e];if(s.pt===n)return s.px}return n}const infixExprToSuffixExpr=n=>{const e=[],s=[];let i=[],r=0,o="",l=1,a="";for(let c=0;c<n.length;c+=1){const d=n.charAt(c);if(d!==" "){if(d>="a"&&d<="z")i.push(d.toUpperCase());else if(d>="0"&&d<="9"||d>="A"&&d<="Z"||d===".")i.push(d);else if(d==='"'){for(c+=1;n.charAt(c)!=='"';)i.push(n.charAt(c)),c+=1;s.push(`"${i.join("")}`),i=[]}else if(d==="-"&&/[+\-*/,(]/.test(a))i.push(d);else{if(d!=="("&&i.length>0&&s.push(i.join("")),d===")"){let u=e.pop();if(r===2)try{const[f,m]=expr2xy(s.pop()),[p,g]=expr2xy(s.pop());let x=0;for(let E=p;E<=f;E+=1)for(let v=g;v<=m;v+=1)s.push(xy2expr(E,v)),x+=1;s.push([u,x])}catch(f){}else if(r===1||r===3)r===3&&s.push(o),s.push([u,l]),l=1;else for(;u!=="("&&(s.push(u),!(e.length<=0));)u=e.pop();r=0}else if(d==="="||d===">"||d==="<"){const u=n.charAt(c+1);o=d,(u==="="||u==="-")&&(o+=u,c+=1),r=3}else if(d===":")r=2;else if(d===",")r===3&&s.push(o),r=1,l+=1;else if(d==="("&&i.length>0)e.push(i.join(""));else{if(e.length>0&&(d==="+"||d==="-")){let u=e[e.length-1];if(u!=="("&&s.push(e.pop()),u==="*"||u==="/")for(;e.length>0&&(u=e[e.length-1],u!=="(");)s.push(e.pop())}else if(e.length>0){const u=e[e.length-1];(u==="*"||u==="/")&&s.push(e.pop())}e.push(d)}i=[]}a=d}}for(i.length>0&&s.push(i.join(""));e.length>0;)s.push(e.pop());return s},evalSubExpr=(n,e)=>{const[s]=n;let i=n;if(s==='"')return n.substring(1);let r=1;if(s==="-"&&(i=n.substring(1),r=-1),i[0]>="0"&&i[0]<="9")return r*Number(i);const[o,l]=expr2xy(i);return r*e(o,l)},evalSuffixExpr=(n,e,s,i)=>{const r=[];for(let o=0;o<n.length;o+=1){const l=n[o],a=l[0];if(l==="+"){const c=r.pop();r.push(numberCalc("+",r.pop(),c))}else if(l==="-")if(r.length===1){const c=r.pop();r.push(numberCalc("*",c,-1))}else{const c=r.pop();r.push(numberCalc("-",r.pop(),c))}else if(l==="*")r.push(numberCalc("*",r.pop(),r.pop()));else if(l==="/"){const c=r.pop();r.push(numberCalc("/",r.pop(),c))}else if(a==="="||a===">"||a==="<"){let c=r.pop();Number.isNaN(c)||(c=Number(c));let d=r.pop();Number.isNaN(d)||(d=Number(d));let u=!1;a==="="?u=d===c:l===">"?u=d>c:l===">="?u=d>=c:l==="<"?u=d<c:l==="<="&&(u=d<=c),r.push(u)}else if(Array.isArray(l)){const[c,d]=l,u=[];for(let f=0;f<d;f+=1)u.push(r.pop());r.push(e[c].render(u.reverse()))}else{if(i.includes(l))return 0;(a>="a"&&a<="z"||a>="A"&&a<="Z")&&i.push(l),r.push(evalSubExpr(l,s)),i.pop()}}return r[0]},cell_rslib_entry_cellRender=(n,e,s,i=[])=>{if(n[0]==="="){const r=infixExprToSuffixExpr(n.substring(1));return r.length<=0?n:evalSuffixExpr(r,e,(o,l)=>cell_rslib_entry_cellRender(s(o,l),e,s,i),i)}return n},cell_rslib_entry_={render:cell_rslib_entry_cellRender},baseFormulas=[{key:"SUM",title:tf("formula.sum"),render:n=>n.reduce((e,s)=>numberCalc("+",e,s),0)},{key:"AVERAGE",title:tf("formula.average"),render:n=>n.reduce((e,s)=>Number(e)+Number(s),0)/n.length},{key:"MAX",title:tf("formula.max"),render:n=>Math.max(...n.map(e=>Number(e)))},{key:"MIN",title:tf("formula.min"),render:n=>Math.min(...n.map(e=>Number(e)))},{key:"IF",title:tf("formula._if"),render:([n,e,s])=>n?e:s},{key:"AND",title:tf("formula.and"),render:n=>n.every(e=>e)},{key:"OR",title:tf("formula.or"),render:n=>n.some(e=>e)},{key:"CONCAT",title:tf("formula.concat"),render:n=>n.join("")}],formulas=baseFormulas,formulam={};baseFormulas.forEach(n=>{formulam[n.key]=n});const formatStringRender=n=>n,formatNumberRender=n=>{if(/^(-?\d*.?\d*)$/.test(n)){const e=Number(n).toFixed(2).toString(),[s,...i]=e.split("\\.");return[s.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"),...i]}return n},baseFormats=[{key:"normal",title:tf("format.normal"),type:"string",render:formatStringRender},{key:"text",title:tf("format.text"),type:"string",render:formatStringRender},{key:"number",title:tf("format.number"),type:"number",label:"1,000.12",render:formatNumberRender},{key:"percent",title:tf("format.percent"),type:"number",label:"10.12%",render:n=>`${n}%`},{key:"rmb",title:tf("format.rmb"),type:"number",label:"¥10.00",render:n=>`¥${formatNumberRender(n)}`},{key:"usd",title:tf("format.usd"),type:"number",label:"$10.00",render:n=>`$${formatNumberRender(n)}`},{key:"eur",title:tf("format.eur"),type:"number",label:"€10.00",render:n=>`€${formatNumberRender(n)}`},{key:"date",title:tf("format.date"),type:"date",label:"26/09/2008",render:formatStringRender},{key:"time",title:tf("format.time"),type:"date",label:"15:59:00",render:formatStringRender},{key:"datetime",title:tf("format.datetime"),type:"date",label:"26/09/2008 15:59:00",render:formatStringRender},{key:"duration",title:tf("format.duration"),type:"date",label:"24:01:00",render:formatStringRender}],formatm={};baseFormats.forEach(n=>{formatm[n.key]=n});const cellPaddingWidth=5,tableFixedHeaderCleanStyle={fillStyle:"#f4f5f8"},tableGridStyle={fillStyle:"#fff",lineWidth:thinLineWidth,strokeStyle:"#e6e6e6"};function tableFixedHeaderStyle(){return{textAlign:"center",textBaseline:"middle",font:`500 ${npx(12)}px Source Sans Pro`,fillStyle:"#585757",lineWidth:thinLineWidth(),strokeStyle:"#e6e6e6"}}function getDrawBox(n,e,s,i=0){const{left:r,top:o,width:l,height:a}=n.cellRect(e,s);return new DrawBox(r,o+i,l,a,cellPaddingWidth)}function renderCell(n,e,s,i,r=0){const{sortedRowMap:o,rows:l,cols:a}=e;if(l.isHide(s)||a.isHide(i))return;let c=s;o.has(s)&&(c=o.get(s));const d=e.getCell(c,i);if(d===null)return;let u=!1;"editable"in d&&d.editable===!1&&(u=!0);const f=e.getCellStyleOrDefault(c,i),m=getDrawBox(e,s,i,r);m.bgcolor=f.bgcolor,f.border!==void 0&&(m.setBorders(f.border),n.strokeBorders(m)),n.rect(m,()=>{let p="";p=e.settings.evalPaused?d.text||"":cell_rslib_entry_.render(d.text||"",formulam,(E,v)=>e.getCellTextOrDefault(v,E)),f.format&&(p=formatm[f.format].render(p));const g=Object.assign({},f.font);g.size=getFontSizePxByPt(g.size),n.text(p,m,{align:f.align,valign:f.valign,font:g,color:f.color,strike:f.strike,underline:f.underline},f.textwrap),e.validations.getError(s,i)&&n.error(m),u&&n.frozen(m)})}function renderAutofilter(n){const{data:e,draw:s}=this;if(n){const{autoFilter:i}=e;if(!i.active())return;const r=i.hrange();n.intersects(r)&&r.each((o,l)=>{const a=getDrawBox(e,o,l);s.dropdown(a)})}}function renderContent(n,e,s,i,r){const{draw:o,data:l}=this;o.save(),o.translate(e,s).translate(i,r);const{exceptRowSet:a}=l,c=f=>{const m=a.has(f);if(m){const p=l.rows.getHeight(f);o.translate(0,-p)}return!m},d=l.exceptRowTotalHeight(n.sri,n.eri);o.save(),o.translate(0,-d),n.each((f,m)=>{renderCell(o,l,f,m)},f=>c(f)),o.restore();const u=new Set;o.save(),o.translate(0,-d),l.eachMergesInView(n,({sri:f,sci:m,eri:p})=>{if(a.has(f)){if(!u.has(f)){u.add(f);const g=l.rows.sumHeight(f,p+1);o.translate(0,-g)}}else renderCell(o,l,f,m)}),o.restore(),renderAutofilter.call(this,n),o.restore()}function renderSelectedHeaderCell(n,e,s,i){const{draw:r}=this;r.save(),r.attr({fillStyle:"rgba(75, 137, 255, 0.08)"}).fillRect(n,e,s,i),r.restore()}function renderFixedHeaders(n,e,s,i,r,o){const{draw:l,data:a}=this,c=e.h,d=e.w,u=o+i,f=r+s;l.save(),l.attr(tableFixedHeaderCleanStyle),(n==="all"||n==="left")&&l.fillRect(0,u,s,c),(n==="all"||n==="top")&&l.fillRect(f,0,d,i);const{sri:m,sci:p,eri:g,eci:x}=a.selector.range;l.attr(tableFixedHeaderStyle()),(n==="all"||n==="left")&&(a.rowEach(e.sri,e.eri,(E,v,y)=>{const w=u+v,S=E;l.line([0,w],[s,w]),m<=S&&S<g+1&&renderSelectedHeaderCell.call(this,0,w,s,y),l.fillText(S+1,s/2,w+y/2),E>0&&a.rows.isHide(E-1)&&(l.save(),l.attr({strokeStyle:"#c6c6c6"}),l.line([5,w+5],[s-5,w+5]),l.restore())}),l.line([0,c+u],[s,c+u]),l.line([s,u],[s,c+u])),(n==="all"||n==="top")&&(a.colEach(e.sci,e.eci,(E,v,y)=>{const w=f+v,S=E;l.line([w,0],[w,i]),p<=S&&S<x+1&&renderSelectedHeaderCell.call(this,w,0,y,i),l.fillText(stringAt(S),w+y/2,i/2),E>0&&a.cols.isHide(E-1)&&(l.save(),l.attr({strokeStyle:"#c6c6c6"}),l.line([w+5,5],[w+5,i-5]),l.restore())}),l.line([d+f,0],[d+f,i]),l.line([0,i],[d+f,i])),l.restore()}function renderFixedLeftTopCell(n,e){const{draw:s}=this;s.save(),s.attr({fillStyle:"#f4f5f8"}).fillRect(0,0,n,e),s.restore()}function renderContentGrid({sri:n,sci:e,eri:s,eci:i,w:r,h:o},l,a,c,d){const{draw:u,data:f}=this,{settings:m}=f;if(u.save(),u.attr(tableGridStyle).translate(l+c,a+d),!m.showGrid){u.restore();return}f.rowEach(n,s,(p,g,x)=>{p!==n&&u.line([0,g],[r,g]),p===s&&u.line([0,g+x],[r,g+x])}),f.colEach(e,i,(p,g,x)=>{p!==e&&u.line([g,0],[g,o]),p===i&&u.line([g+x,0],[g+x,o])}),u.restore()}function renderFreezeHighlightLine(n,e,s,i){const{draw:r,data:o}=this,l=o.viewWidth()-n,a=o.viewHeight()-e;r.save().translate(n,e).attr({strokeStyle:"rgba(75, 137, 255, .6)"}),r.line([0,i],[l,i]),r.line([s,0],[s,a]),r.restore()}class Table{constructor(e,s){this.el=e,this.draw=new Draw(e,s.viewWidth(),s.viewHeight()),this.data=s}resetData(e){this.data=e,this.render()}render(){const{data:e}=this,{rows:s,cols:i}=e,r=i.indexWidth,o=s.height;this.draw.resize(e.viewWidth(),e.viewHeight()),this.clear();const l=e.viewRange(),a=e.freezeTotalWidth(),c=e.freezeTotalHeight(),{x:d,y:u}=e.scroll;renderContentGrid.call(this,l,r,o,a,c),renderContent.call(this,l,r,o,-d,-u),renderFixedHeaders.call(this,"all",l,r,o,a,c),renderFixedLeftTopCell.call(this,r,o);const[f,m]=e.freeze;if(f>0||m>0){if(f>0){const g=l.clone();g.sri=0,g.eri=f-1,g.h=c,renderContentGrid.call(this,g,r,o,a,0),renderContent.call(this,g,r,o,-d,0),renderFixedHeaders.call(this,"top",g,r,o,a,0)}if(m>0){const g=l.clone();g.sci=0,g.eci=m-1,g.w=a,renderContentGrid.call(this,g,r,o,0,c),renderFixedHeaders.call(this,"left",g,r,o,0,c),renderContent.call(this,g,r,o,0,-u)}const p=e.freezeViewRange();renderContentGrid.call(this,p,r,o,0,0),renderFixedHeaders.call(this,"all",p,r,o,0,0),renderContent.call(this,p,r,o,0,0),renderFreezeHighlightLine.call(this,r,o,a,c)}}clear(){this.draw.clear()}}const table_rslib_entry_=Table,PAGER_SIZES=[["A3",11.69,16.54],["A4",8.27,11.69],["A5",5.83,8.27],["B4",9.84,13.9],["B5",6.93,9.84]],PAGER_ORIENTATIONS=["landscape","portrait"];function inches2px(n){return parseInt(96*n,10)}function btnClick(n){n==="cancel"?this.el.hide():this.toPrint()}function pagerSizeChange(n){const{paper:e}=this,{value:s}=n.target,i=PAGER_SIZES[s];e.w=inches2px(i[1]),e.h=inches2px(i[2]),this.preview()}function pagerOrientationChange(n){const{paper:e}=this,{value:s}=n.target,i=PAGER_ORIENTATIONS[s];e.orientation=i,this.preview()}let Print$1=class{constructor(e){this.paper={w:inches2px(PAGER_SIZES[0][1]),h:inches2px(PAGER_SIZES[0][2]),padding:50,orientation:PAGER_ORIENTATIONS[0],get width(){return this.orientation==="landscape"?this.h:this.w},get height(){return this.orientation==="landscape"?this.w:this.h}},this.data=e,this.el=h("div",`${cssPrefix}-print`).children(h("div",`${cssPrefix}-print-bar`).children(h("div","-title").child("Print settings"),h("div","-right").children(h("div",`${cssPrefix}-buttons`).children(new Button("cancel").on("click",btnClick.bind(this,"cancel")),new Button("next","primary").on("click",btnClick.bind(this,"next"))))),h("div",`${cssPrefix}-print-content`).children(this.contentEl=h("div","-content"),h("div","-sider").child(h("form","").children(h("fieldset","").children(h("label","").child(`${t("print.size")}`),h("select","").children(...PAGER_SIZES.map((s,i)=>h("option","").attr("value",i).child(`${s[0]} ( ${s[1]}''x${s[2]}'' )`))).on("change",pagerSizeChange.bind(this))),h("fieldset","").children(h("label","").child(`${t("print.orientation")}`),h("select","").children(...PAGER_ORIENTATIONS.map((s,i)=>h("option","").attr("value",i).child(`${t("print.orientations")[i]}`))).on("change",pagerOrientationChange.bind(this))))))).hide()}resetData(e){this.data=e}preview(){const{data:e,paper:s}=this,{width:i,height:r,padding:o}=s,l=i-2*o,a=r-2*o,c=e.contentRange(),d=parseInt(c.h/a,10)+1,u=l/c.w;let f=o;const m=o;u>1&&(f+=(l-c.w)/2);let p=0,g=0;this.contentEl.html(""),this.canvases=[];const x={sri:0,sci:0,eri:0,eci:0};for(let E=0;E<d;E+=1){let v=0,y=0;const w=h("div",`${cssPrefix}-canvas-card`),S=h("canvas",`${cssPrefix}-canvas`);this.canvases.push(S.el);const D=new Draw(S.el,i,r);for(D.save(),D.translate(f,m),u<1&&D.scale(u,u);p<=c.eri;p+=1){const B=e.rows.getHeight(p);if(v+=B,v<a)for(let M=0;M<=c.eci;M+=1)renderCell(D,e,p,M,g),x.eci=M;else{y=-(v-B);break}}x.eri=p,D.restore(),D.save(),D.translate(f,m),u<1&&D.scale(u,u);const F=g;e.eachMergesInView(x,({sri:B,sci:M})=>{renderCell(D,e,B,M,F)}),D.restore(),x.sri=x.eri,x.sci=x.eci,g+=y,this.contentEl.child(h("div",`${cssPrefix}-canvas-card-wraper`).child(w.child(S)))}this.el.show()}toPrint(){this.el.hide();const{paper:e}=this,s=h("iframe","").hide(),{el:i}=s;window.document.body.appendChild(i);const{contentWindow:r}=i,o=r.document,l=document.createElement("style");l.innerHTML=`
10
10
  @page { size: ${e.width}px ${e.height}px; };
11
11
  canvas {
12
12
  page-break-before: auto;
13
13
  page-break-after: always;
14
14
  image-rendering: pixelated;
15
15
  };
16
- `,o.head.appendChild(a),this.canvases.forEach(l=>{const c=l.cloneNode(!1);c.getContext("2d").drawImage(l,0,0),o.body.appendChild(c)}),r.print()}};const menuItems$1=[{key:"copy",title:tf("contextmenu.copy"),label:"Ctrl+C"},{key:"cut",title:tf("contextmenu.cut"),label:"Ctrl+X"},{key:"paste",title:tf("contextmenu.paste"),label:"Ctrl+V"},{key:"paste-value",title:tf("contextmenu.pasteValue"),label:"Ctrl+Shift+V"},{key:"paste-format",title:tf("contextmenu.pasteFormat"),label:"Ctrl+Alt+V"},{key:"divider"},{key:"insert-row",title:tf("contextmenu.insertRow")},{key:"insert-column",title:tf("contextmenu.insertColumn")},{key:"divider"},{key:"delete-row",title:tf("contextmenu.deleteRow")},{key:"delete-column",title:tf("contextmenu.deleteColumn")},{key:"delete-cell-text",title:tf("contextmenu.deleteCellText")},{key:"hide",title:tf("contextmenu.hide")},{key:"divider"},{key:"validation",title:tf("contextmenu.validation")},{key:"divider"},{key:"cell-printable",title:tf("contextmenu.cellprintable")},{key:"cell-non-printable",title:tf("contextmenu.cellnonprintable")},{key:"divider"},{key:"cell-editable",title:tf("contextmenu.celleditable")},{key:"cell-non-editable",title:tf("contextmenu.cellnoneditable")}];function buildMenuItem$1(i){return i.key==="divider"?h("div",`${cssPrefix}-item divider`):h("div",`${cssPrefix}-item`).on("click",()=>{this.itemClick(i.key),this.hide()}).children(i.title(),h("div","label").child(i.label||""))}function buildMenu$2(){return menuItems$1.map(i=>buildMenuItem$1.call(this,i))}let ContextMenu$1=class{constructor(e,s=!1){this.menuItems=buildMenu$2.call(this),this.el=h("div",`${cssPrefix}-contextmenu`).children(...this.menuItems).hide(),this.viewFn=e,this.itemClick=()=>{},this.isHide=s,this.setMode("range")}setMode(e){const s=this.menuItems[12];e==="row-col"?s.show():s.hide()}hide(){const{el:e}=this;e.hide(),unbindClickoutside(e)}setPosition(e,s){if(this.isHide)return;const{el:n}=this,{width:r}=n.show().offset(),o=this.viewFn(),a=o.height/2;let l=e;o.width-e<=r&&(l-=r),n.css("left",`${l}px`),s>a?n.css("bottom",`${o.height-s}px`).css("max-height",`${s}px`).css("top","auto"):n.css("top",`${s}px`).css("max-height",`${o.height-s}px`).css("bottom","auto"),bindClickoutside(n)}};function tooltip(i,e){if(e.classList.contains("active"))return;const{left:s,top:n,width:r,height:o}=e.getBoundingClientRect(),a=h("div",`${cssPrefix}-tooltip`).html(i).show();document.body.appendChild(a.el);const l=a.box();a.css("left",`${s+r/2-l.width/2}px`).css("top",`${n+o+2}px`),bind(e,"mouseleave",()=>{document.body.contains(a.el)&&document.body.removeChild(a.el)}),bind(e,"click",()=>{document.body.contains(a.el)&&document.body.removeChild(a.el)})}class Item{constructor(e,s,n){this.tip="",e&&(this.tip=t(`toolbar.${e.replace(/-[a-z]/g,r=>r[1].toUpperCase())}`)),s&&(this.tip+=` (${s})`),this.tag=e,this.shortcut=s,this.value=n,this.el=this.element(),this.change=()=>{}}element(){const{tip:e}=this;return h("div",`${cssPrefix}-toolbar-btn`).on("mouseenter",s=>{this.tip&&tooltip(this.tip,s.target)}).attr("data-tooltip",e)}setState(){}}class DropdownItem extends Item{dropdown(){}getValue(e){return e}element(){const{tag:e}=this;return this.dd=this.dropdown(),this.dd.change=s=>this.change(e,this.getValue(s)),super.element().child(this.dd)}setState(e){e&&(this.value=e,this.dd.setTitle(e))}}class Dropdown extends Element{constructor(e,s,n,r,...o){super("div",`${cssPrefix}-dropdown ${r}`),this.title=e,this.change=()=>{},this.headerClick=()=>{},typeof e=="string"?this.title=h("div",`${cssPrefix}-dropdown-title`).child(e):n&&this.title.addClass("arrow-left"),this.contentEl=h("div",`${cssPrefix}-dropdown-content`).css("width",s).hide(),this.setContentChildren(...o),this.headerEl=h("div",`${cssPrefix}-dropdown-header`),this.headerEl.on("click",()=>{this.contentEl.css("display")!=="block"?this.show():this.hide()}).children(this.title,n?h("div",`${cssPrefix}-icon arrow-right`).child(h("div",`${cssPrefix}-icon-img arrow-down`)):""),this.children(this.headerEl,this.contentEl)}setContentChildren(...e){this.contentEl.html(""),e.length>0&&this.contentEl.children(...e)}setTitle(e){this.title.html(e),this.hide()}show(){const{contentEl:e}=this;e.show(),this.parent().active(),bindClickoutside(this.parent(),()=>{this.hide()})}hide(){this.parent().active(!1),this.contentEl.hide(),unbindClickoutside(this.parent())}}function buildItemWithIcon(i){return h("div",`${cssPrefix}-item`).child(new Icon(i))}class DropdownAlign extends Dropdown{constructor(e,s){const n=new Icon(`align-${s}`),r=e.map(o=>buildItemWithIcon(`align-${o}`).on("click",()=>{this.setTitle(o),this.change(o)}));super(n,"auto",!0,"bottom-left",...r)}setTitle(e){this.title.setName(`align-${e}`),this.hide()}}class Align extends DropdownItem{constructor(e){super("align","",e)}dropdown(){const{value:e}=this;return new DropdownAlign(["left","center","right"],e)}}class Valign extends DropdownItem{constructor(e){super("valign","",e)}dropdown(){const{value:e}=this;return new DropdownAlign(["top","middle","bottom"],e)}}class ToggleItem extends Item{element(){const{tag:e}=this;return super.element().child(new Icon(e)).on("click",()=>this.click())}click(){this.change(this.tag,this.toggle())}setState(e){this.el.active(e)}toggle(){return this.el.toggle()}active(){return this.el.hasClass("active")}}class Autofilter extends ToggleItem{constructor(){super("autofilter")}setState(){}}class Bold extends ToggleItem{constructor(){super("font-bold","Ctrl+B")}}class Italic extends ToggleItem{constructor(){super("font-italic","Ctrl+I")}}class Strike extends ToggleItem{constructor(){super("strike","Ctrl+U")}}class Underline extends ToggleItem{constructor(){super("underline","Ctrl+U")}}const themeColorPlaceHolders=["#ffffff","#000100","#e7e5e6","#445569","#5b9cd6","#ed7d31","#a5a5a5","#ffc001","#4371c6","#71ae47"],themeColors=[["#f2f2f2","#7f7f7f","#d0cecf","#d5dce4","#deeaf6","#fce5d5","#ededed","#fff2cd","#d9e2f3","#e3efd9"],["#d8d8d8","#595959","#afabac","#adb8ca","#bdd7ee","#f7ccac","#dbdbdb","#ffe59a","#b3c6e7","#c5e0b3"],["#bfbfbf","#3f3f3f","#756f6f","#8596b0","#9cc2e6","#f4b184","#c9c9c9","#fed964","#8eaada","#a7d08c"],["#a5a5a5","#262626","#3a3839","#333f4f","#2e75b5","#c45a10","#7b7b7b","#bf8e01","#2f5596","#538136"],["#7f7f7f","#0c0c0c","#171516","#222a35","#1f4e7a","#843c0a","#525252","#7e6000","#203864","#365624"]],standardColors=["#c00000","#fe0000","#fdc101","#ffff01","#93d051","#00b04e","#01b0f1","#0170c1","#012060","#7030a0"];function buildTd$1(i){return h("td","").child(h("div",`${cssPrefix}-color-palette-cell`).on("click.stop",()=>this.change(i)).css("background-color",i))}class ColorPalette{constructor(){this.el=h("div",`${cssPrefix}-color-palette`),this.change=()=>{};const e=h("table","").children(h("tbody","").children(h("tr",`${cssPrefix}-theme-color-placeholders`).children(...themeColorPlaceHolders.map(s=>buildTd$1.call(this,s))),...themeColors.map(s=>h("tr",`${cssPrefix}-theme-colors`).children(...s.map(n=>buildTd$1.call(this,n)))),h("tr",`${cssPrefix}-standard-colors`).children(...standardColors.map(s=>buildTd$1.call(this,s)))));this.el.child(e)}}class DropdownColor extends Dropdown{constructor(e,s){const n=new Icon(e).css("height","16px").css("border-bottom",`3px solid ${s}`),r=new ColorPalette;r.change=o=>{this.setTitle(o),this.change(o)},super(n,"auto",!1,"bottom-left",r.el)}setTitle(e){this.title.css("border-color",e),this.hide()}}const lineTypes=[["thin",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" style="user-select: none;"></line></svg>'],["medium",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="2" style="user-select: none;"><line x1="0" y1="1.0" x2="50" y2="1.0" stroke-width="2" stroke="black" style="user-select: none;"></line></svg>'],["thick",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="3" style="user-select: none;"><line x1="0" y1="1.5" x2="50" y2="1.5" stroke-width="3" stroke="black" style="user-select: none;"></line></svg>'],["dashed",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" stroke-dasharray="2" style="user-select: none;"></line></svg>'],["dotted",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" stroke-dasharray="1" style="user-select: none;"></line></svg>']];class DropdownLineType extends Dropdown{constructor(e){const s=new Icon("line-type");let n=0;const r=lineTypes.map((o,a)=>h("div",`${cssPrefix}-item state ${e===o[0]?"checked":""}`).on("click",()=>{r[n].toggle("checked"),r[a].toggle("checked"),n=a,this.hide(),this.change(o)}).child(h("div",`${cssPrefix}-line-type`).html(o[1])));super(s,"auto",!1,"bottom-left",...r)}}function buildTable(...i){return h("table","").child(h("tbody","").children(...i))}function buildTd(i){return h("td","").child(h("div",`${cssPrefix}-border-palette-cell`).child(new Icon(`border-${i}`)).on("click",()=>{this.mode=i;const{mode:e,style:s,color:n}=this;this.change({mode:e,style:s,color:n})}))}class BorderPalette{constructor(){this.color="#000",this.style="thin",this.mode="all",this.change=()=>{},this.ddColor=new DropdownColor("line-color",this.color),this.ddColor.change=s=>{this.color=s},this.ddType=new DropdownLineType(this.style),this.ddType.change=([s])=>{this.style=s},this.el=h("div",`${cssPrefix}-border-palette`);const e=buildTable(h("tr","").children(h("td",`${cssPrefix}-border-palette-left`).child(buildTable(h("tr","").children(...["all","inside","horizontal","vertical","outside"].map(s=>buildTd.call(this,s))),h("tr","").children(...["left","top","right","bottom","none"].map(s=>buildTd.call(this,s))))),h("td",`${cssPrefix}-border-palette-right`).children(h("div",`${cssPrefix}-toolbar-btn`).child(this.ddColor.el),h("div",`${cssPrefix}-toolbar-btn`).child(this.ddType.el))));this.el.child(e)}}class DropdownBorder extends Dropdown{constructor(){const e=new Icon("border-all"),s=new BorderPalette;s.change=n=>{this.change(n),this.hide()},super(e,"auto",!1,"bottom-left",s.el)}}class Border extends DropdownItem{constructor(){super("border")}dropdown(){return new DropdownBorder}}class IconItem extends Item{element(){return super.element().child(new Icon(this.tag)).on("click",()=>this.change(this.tag))}setState(e){this.el.disabled(e)}}class Clearformat extends IconItem{constructor(){super("clearformat")}}class Paintformat extends ToggleItem{constructor(){super("paintformat")}setState(){}}class TextColor extends DropdownItem{constructor(e){super("color",void 0,e)}dropdown(){const{tag:e,value:s}=this;return new DropdownColor(e,s)}}class FillColor extends DropdownItem{constructor(e){super("bgcolor",void 0,e)}dropdown(){const{tag:e,value:s}=this;return new DropdownColor(e,s)}}class DropdownFontSize extends Dropdown{constructor(){const e=fontSizes.map(s=>h("div",`${cssPrefix}-item`).on("click",()=>{this.setTitle(`${s.pt}`),this.change(s)}).child(`${s.pt}`));super("10","60px",!0,"bottom-left",...e)}}let Format$2=class extends DropdownItem{constructor(){super("font-size")}getValue(e){return e.pt}dropdown(){return new DropdownFontSize}};class DropdownFont extends Dropdown{constructor(){const e=baseFonts.map(s=>h("div",`${cssPrefix}-item`).on("click",()=>{this.setTitle(s.title),this.change(s)}).child(s.title));super(baseFonts[0].title,"160px",!0,"bottom-left",...e)}}class Font extends DropdownItem{constructor(){super("font-name")}getValue(e){return e.key}dropdown(){return new DropdownFont}}class DropdownFormat extends Dropdown{constructor(){let e=baseFormats.slice(0);e.splice(2,0,{key:"divider"}),e.splice(8,0,{key:"divider"}),e=e.map(s=>{const n=h("div",`${cssPrefix}-item`);return s.key==="divider"?n.addClass("divider"):(n.child(s.title()).on("click",()=>{this.setTitle(s.title()),this.change(s)}),s.label&&n.child(h("div","label").html(s.label))),n}),super("Normal","220px",!0,"bottom-left",...e)}setTitle(e){for(let s=0;s<baseFormats.length;s+=1)baseFormats[s].key===e&&this.title.html(baseFormats[s].title());this.hide()}}let Format$1=class extends DropdownItem{constructor(){super("format")}getValue(e){return e.key}dropdown(){return new DropdownFormat}};class DropdownFormula extends Dropdown{constructor(){const e=baseFormulas.map(s=>h("div",`${cssPrefix}-item`).on("click",()=>{this.hide(),this.change(s)}).child(s.key));super(new Icon("formula"),"180px",!0,"bottom-left",...e)}}class Format extends DropdownItem{constructor(){super("formula")}getValue(e){return e.key}dropdown(){return new DropdownFormula}}class Freeze extends ToggleItem{constructor(){super("freeze")}}class Merge extends ToggleItem{constructor(){super("merge")}setState(e,s){this.el.active(e).disabled(s)}}class Redo extends IconItem{constructor(){super("redo","Ctrl+Y")}}class Undo extends IconItem{constructor(){super("undo","Ctrl+Z")}}class Print extends IconItem{constructor(){super("print","Ctrl+P")}}class Textwrap extends ToggleItem{constructor(){super("textwrap")}}let DropdownMore$1=class extends Dropdown{constructor(){const e=new Icon("ellipsis"),s=h("div",`${cssPrefix}-toolbar-more`);super(e,"auto",!1,"bottom-right",s),this.moreBtns=s,this.contentEl.css("max-width","420px")}};class More extends DropdownItem{constructor(){super("more"),this.el.hide()}dropdown(){return new DropdownMore$1}show(){this.el.show()}hide(){this.el.hide()}}function buildDivider(){return h("div",`${cssPrefix}-toolbar-divider`)}function initBtns2(){this.btns2=[],this.items.forEach(i=>{if(Array.isArray(i))i.forEach(({el:e})=>{const s=e.box(),{marginLeft:n,marginRight:r}=e.computedStyle();this.btns2.push([e,s.width+parseInt(n,10)+parseInt(r,10)])});else{const e=i.box(),{marginLeft:s,marginRight:n}=i.computedStyle();this.btns2.push([i,e.width+parseInt(s,10)+parseInt(n,10)])}})}function moreResize(){const{el:i,btns:e,moreEl:s,btns2:n}=this,{moreBtns:r,contentEl:o}=s.dd;i.css("width",`${this.widthFn()}px`);const a=i.box();let l=160,c=12;const d=[],u=[];n.forEach(([p,m],f)=>{l+=m,f===n.length-1||l<a.width?d.push(p):(c+=m,u.push(p))}),e.html("").children(...d),r.html("").children(...u),o.css("width",`${c}px`),u.length>0?s.show():s.hide()}function genBtn(i){const e=new Item;e.el.on("click",()=>{i.onClick&&i.onClick(this.data.getData(),this.data)}),e.tip=i.tip||"";let{el:s}=i;if(i.icon&&(s=h("img").attr("src",i.icon)),s){const n=h("div",`${cssPrefix}-icon`);n.child(s),e.el.child(n)}return e}class Toolbar{constructor(e,s,n=!1){this.data=e,this.change=()=>{},this.widthFn=s,this.isHide=n;const r=e.defaultStyle();this.items=[[this.undoEl=new Undo,this.redoEl=new Redo,new Print,this.paintformatEl=new Paintformat,this.clearformatEl=new Clearformat],buildDivider(),[this.formatEl=new Format$1],buildDivider(),[this.fontEl=new Font,this.fontSizeEl=new Format$2],buildDivider(),[this.boldEl=new Bold,this.italicEl=new Italic,this.underlineEl=new Underline,this.strikeEl=new Strike,this.textColorEl=new TextColor(r.color)],buildDivider(),[this.fillColorEl=new FillColor(r.bgcolor),this.borderEl=new Border,this.mergeEl=new Merge],buildDivider(),[this.alignEl=new Align(r.align),this.valignEl=new Valign(r.valign),this.textwrapEl=new Textwrap],buildDivider(),[this.freezeEl=new Freeze,this.autofilterEl=new Autofilter,this.formulaEl=new Format]];const{extendToolbar:o={}}=e.settings;if(o.left&&o.left.length>0){this.items.unshift(buildDivider());const a=o.left.map(genBtn.bind(this));this.items.unshift(a)}if(o.right&&o.right.length>0){this.items.push(buildDivider());const a=o.right.map(genBtn.bind(this));this.items.push(a)}this.items.push([this.moreEl=new More]),this.el=h("div",`${cssPrefix}-toolbar`),this.btns=h("div",`${cssPrefix}-toolbar-btns`),this.items.forEach(a=>{Array.isArray(a)?a.forEach(l=>{this.btns.child(l.el),l.change=(...c)=>{this.change(...c)}}):this.btns.child(a.el)}),this.el.child(this.btns),n?this.el.hide():(this.reset(),setTimeout(()=>{initBtns2.call(this),moreResize.call(this)},0),bind(window,"resize",()=>{moreResize.call(this)}))}paintformatActive(){return this.paintformatEl.active()}paintformatToggle(){this.paintformatEl.toggle()}trigger(e){this[`${e}El`].click()}resetData(e){this.data=e,this.reset()}reset(){if(this.isHide)return;const{data:e}=this,s=e.getSelectedCellStyle();this.undoEl.setState(!e.canUndo()),this.redoEl.setState(!e.canRedo()),this.mergeEl.setState(e.canUnmerge(),!e.selector.multiple()),this.autofilterEl.setState(!e.canAutofilter());const{font:n,format:r}=s;this.formatEl.setState(r),this.fontEl.setState(n.name),this.fontSizeEl.setState(n.size),this.boldEl.setState(n.bold),this.italicEl.setState(n.italic),this.underlineEl.setState(s.underline),this.strikeEl.setState(s.strike),this.textColorEl.setState(s.color),this.fillColorEl.setState(s.bgcolor),this.alignEl.setState(s.align),this.valignEl.setState(s.valign),this.textwrapEl.setState(s.textwrap),this.freezeEl.setState(e.freezeIsActive())}}class Modal{constructor(e,s,n="600px"){this.title=e,this.el=h("div",`${cssPrefix}-modal`).css("width",n).children(h("div",`${cssPrefix}-modal-header`).children(new Icon("close").on("click.stop",()=>this.hide()),this.title),h("div",`${cssPrefix}-modal-content`).children(...s)).hide()}show(){this.dimmer=h("div",`${cssPrefix}-dimmer active`),document.body.appendChild(this.dimmer.el);const{width:e,height:s}=this.el.show().box(),{clientHeight:n,clientWidth:r}=document.documentElement;this.el.offset({left:(r-e)/2,top:(n-s)/3}),window.xkeydownEsc=o=>{o.keyCode===27&&this.hide()},bind(window,"keydown",window.xkeydownEsc)}hide(){this.el.hide(),document.body.removeChild(this.dimmer.el),unbind(window,"keydown",window.xkeydownEsc),delete window.xkeydownEsc}}class FormInput{constructor(e,s){this.vchange=()=>{},this.el=h("div",`${cssPrefix}-form-input`),this.input=h("input","").css("width",e).on("input",n=>this.vchange(n)).attr("placeholder",s),this.el.child(this.input)}focus(){setTimeout(()=>{this.input.el.focus()},10)}hint(e){this.input.attr("placeholder",e)}val(e){return this.input.val(e)}}class FormSelect{constructor(e,s,n,r=a=>a,o=()=>{}){this.key=e,this.getTitle=r,this.vchange=()=>{},this.el=h("div",`${cssPrefix}-form-select`),this.suggest=new Suggest(s.map(a=>({key:a,title:this.getTitle(a)})),a=>{this.itemClick(a.key),o(a.key),this.vchange(a.key)},n,this.el),this.el.children(this.itemEl=h("div","input-text").html(this.getTitle(e)),this.suggest.el).on("click",()=>this.show())}show(){this.suggest.search("")}itemClick(e){this.key=e,this.itemEl.html(this.getTitle(e))}val(e){return e!==void 0?(this.key=e,this.itemEl.html(this.getTitle(e)),this):this.key}}const patterns={number:/(^\d+$)|(^\d+(\.\d{0,4})?$)/,date:/^\d{4}-\d{1,2}-\d{1,2}$/};class FormField{constructor(e,s,n,r){this.label="",this.rule=s,n&&(this.label=h("label","label").css("width",`${r}px`).html(n)),this.tip=h("div","tip").child("tip").hide(),this.input=e,this.input.vchange=()=>this.validate(),this.el=h("div",`${cssPrefix}-form-field`).children(this.label,e.el,this.tip)}isShow(){return this.el.css("display")!=="none"}show(){this.el.show()}hide(){return this.el.hide(),this}val(e){return this.input.val(e)}hint(e){this.input.hint(e)}validate(){const{input:e,rule:s,tip:n,el:r}=this,o=e.val();return s.required&&/^\s*$/.test(o)?(n.html(t("validation.required")),r.addClass("error"),!1):(s.type||s.pattern)&&!(s.pattern||patterns[s.type]).test(o)?(n.html(t("validation.notMatch")),r.addClass("error"),!1):(r.removeClass("error"),!0)}}const fieldLabelWidth=100;class ModalValidation extends Modal{constructor(){const e=new FormField(new FormSelect("cell",["cell"],"100%",d=>t(`dataValidation.modeType.${d}`)),{required:!0},`${t("dataValidation.range")}:`,fieldLabelWidth),s=new FormField(new FormInput("120px","E3 or E3:F12"),{required:!0,pattern:/^([A-Z]{1,2}[1-9]\d*)(:[A-Z]{1,2}[1-9]\d*)?$/}),n=new FormField(new FormSelect("list",["list","number","date","phone","email"],"100%",d=>t(`dataValidation.type.${d}`),d=>this.criteriaSelected(d)),{required:!0},`${t("dataValidation.criteria")}:`,fieldLabelWidth),r=new FormField(new FormSelect("be",["be","nbe","eq","neq","lt","lte","gt","gte"],"160px",d=>t(`dataValidation.operator.${d}`),d=>this.criteriaOperatorSelected(d)),{required:!0}).hide(),o=new FormField(new FormInput("70px","10"),{required:!0}).hide(),a=new FormField(new FormInput("70px","100"),{required:!0,type:"number"}).hide(),l=new FormField(new FormInput("120px","a,b,c"),{required:!0}),c=new FormField(new FormInput("70px","10"),{required:!0,type:"number"}).hide();super(t("contextmenu.validation"),[h("div",`${cssPrefix}-form-fields`).children(e.el,s.el),h("div",`${cssPrefix}-form-fields`).children(n.el,r.el,o.el,a.el,c.el,l.el),h("div",`${cssPrefix}-buttons`).children(new Button("cancel").on("click",()=>this.btnClick("cancel")),new Button("remove").on("click",()=>this.btnClick("remove")),new Button("save","primary").on("click",()=>this.btnClick("save")))]),this.mf=e,this.rf=s,this.cf=n,this.of=r,this.minvf=o,this.maxvf=a,this.vf=c,this.svf=l,this.change=()=>{}}showVf(e){const s=e==="date"?"2018-11-12":"10",{vf:n}=this;n.input.hint(s),n.show()}criteriaSelected(e){const{of:s,minvf:n,maxvf:r,vf:o,svf:a}=this;e==="date"||e==="number"?(s.show(),n.rule.type=e,r.rule.type=e,e==="date"?(n.hint("2018-11-12"),r.hint("2019-11-12")):(n.hint("10"),r.hint("100")),n.show(),r.show(),o.hide(),a.hide()):(e==="list"?a.show():a.hide(),o.hide(),s.hide(),n.hide(),r.hide())}criteriaOperatorSelected(e){if(!e)return;const{minvf:s,maxvf:n,vf:r}=this;if(e==="be"||e==="nbe")s.show(),n.show(),r.hide();else{const o=this.cf.val();r.rule.type=o,o==="date"?r.hint("2018-11-12"):r.hint("10"),r.show(),s.hide(),n.hide()}}btnClick(e){if(e==="cancel")this.hide();else if(e==="remove")this.change("remove"),this.hide();else if(e==="save"){const s=["mf","rf","cf","of","svf","vf","minvf","maxvf"];for(let c=0;c<s.length;c+=1){const d=this[s[c]];if(d.isShow()&&!d.validate())return}const n=this.mf.val(),r=this.rf.val(),o=this.cf.val(),a=this.of.val();let l=this.svf.val();(o==="number"||o==="date")&&(l=a==="be"||a==="nbe"?[this.minvf.val(),this.maxvf.val()]:this.vf.val()),this.change("save",n,r,{type:o,operator:a,required:!1,value:l}),this.hide()}}setValue(e){if(e){const{mf:s,rf:n,cf:r,of:o,svf:a,vf:l,minvf:c,maxvf:d}=this,{mode:u,ref:p,validator:m}=e,{type:f,operator:g,value:x}=m||{type:"list"};s.val(u||"cell"),n.val(p),r.val(f),o.val(g),Array.isArray(x)?(c.val(x[0]),d.val(x[1])):(a.val(x||""),l.val(x||"")),this.criteriaSelected(f),this.criteriaOperatorSelected(g)}this.show()}}function buildMenu$1(i){return h("div",`${cssPrefix}-item ${i}`)}function buildSortItem(i){return buildMenu$1("state").child(t(`sort.${i}`)).on("click.stop",()=>this.itemClick(i))}function buildFilterBody(i){const{filterbEl:e,filterValues:s}=this;e.html(""),Object.keys(i).forEach((r,o)=>{const a=i[r],l=s.includes(r)?"checked":"";e.child(h("div",`${cssPrefix}-item state ${l}`).on("click.stop",()=>this.filterClick(o,r)).children(r===""?t("filter.empty"):r,h("div","label").html(`(${a})`)))})}function resetFilterHeader(){const{filterhEl:i,filterValues:e,values:s}=this;i.html(`${e.length} / ${s.length}`),i.checked(e.length===s.length)}class SortFilter{constructor(){this.filterbEl=h("div",`${cssPrefix}-body`),this.filterhEl=h("div",`${cssPrefix}-header state`).on("click.stop",()=>this.filterClick(0,"all")),this.el=h("div",`${cssPrefix}-sort-filter`).children(this.sortAscEl=buildSortItem.call(this,"asc"),this.sortDescEl=buildSortItem.call(this,"desc"),buildMenu$1("divider"),h("div",`${cssPrefix}-filter`).children(this.filterhEl,this.filterbEl),h("div",`${cssPrefix}-buttons`).children(new Button("cancel").on("click",()=>this.btnClick("cancel")),new Button("ok","primary").on("click",()=>this.btnClick("ok")))).hide(),this.ci=null,this.sortDesc=null,this.values=null,this.filterValues=[]}btnClick(e){if(e==="ok"){const{ci:s,sort:n,filterValues:r}=this;this.ok&&this.ok(s,n,"in",r)}this.hide()}itemClick(e){this.sort=e;const{sortAscEl:s,sortDescEl:n}=this;s.checked(e==="asc"),n.checked(e==="desc")}filterClick(e,s){const{filterbEl:n,filterValues:r,values:o}=this,a=n.children();s==="all"?a.length===r.length?(this.filterValues=[],a.forEach(l=>h(l).checked(!1))):(this.filterValues=Array.from(o),a.forEach(l=>h(l).checked(!0))):h(a[e]).toggle("checked")?r.push(s):r.splice(r.findIndex(c=>c===s),1),resetFilterHeader.call(this)}set(e,s,n,r){this.ci=e;const{sortAscEl:o,sortDescEl:a}=this;r!==null?(this.sort=r.order,o.checked(r.asc()),a.checked(r.desc())):(this.sortDesc=null,o.checked(!1),a.checked(!1)),this.values=Object.keys(s),this.filterValues=n?Array.from(n.value):Object.keys(s),buildFilterBody.call(this,s,n),resetFilterHeader.call(this)}setOffset(e){this.el.offset(e).show();let s=1;bindClickoutside(this.el,()=>{s<=0&&this.hide(),s-=1})}show(){this.el.show()}hide(){this.el.hide(),unbindClickoutside(this.el)}}function xtoast(i,e){const s=h("div",`${cssPrefix}-toast`),n=h("div",`${cssPrefix}-dimmer active`),r=()=>{document.body.removeChild(s.el),document.body.removeChild(n.el)};s.children(h("div",`${cssPrefix}-toast-header`).children(new Icon("close").on("click.stop",()=>r()),i),h("div",`${cssPrefix}-toast-content`).html(e)),document.body.appendChild(s.el),document.body.appendChild(n.el);const{width:o,height:a}=s.box(),{clientHeight:l,clientWidth:c}=document.documentElement;s.offset({left:(c-o)/2,top:(l-a)/3})}function throttle$2(i,e){let s;return(...n)=>{const r=this,o=n;s||(s=setTimeout(()=>{s=null,i.apply(r,o)},e))}}function scrollbarMove(){const{data:i,verticalScrollbar:e,horizontalScrollbar:s}=this,{l:n,t:r,left:o,top:a,width:l,height:c}=i.getSelectedRect(),d=this.getTableOffset();if(Math.abs(o)+l>d.width)s.move({left:n+l-d.width});else{const u=i.freezeTotalWidth();o<u&&s.move({left:n-1-u})}if(Math.abs(a)+c>d.height)e.move({top:r+c-d.height-1});else{const u=i.freezeTotalHeight();a<u&&e.move({top:r-1-u})}}function selectorSet(i,e,s,n=!0,r=!1){if(e===-1&&s===-1)return;const{table:o,selector:a,toolbar:l,data:c,contextMenu:d}=this,u=c.getCell(e,s);i?(a.setEnd(e,s,r),this.trigger("cells-selected",u,a.range)):(a.set(e,s,n),this.trigger("cell-selected",u,e,s)),d.setMode(e===-1||s===-1?"row-col":"range"),l.reset(),o.render()}function selectorMove(i,e){const{selector:s,data:n}=this,{rows:r,cols:o}=n;let[a,l]=s.indexes;const{eri:c,eci:d}=s.range;i&&([a,l]=s.moveIndexes),e==="left"?l>0&&(l-=1):e==="right"?(d!==l&&(l=d),l<o.len-1&&(l+=1)):e==="up"?a>0&&(a-=1):e==="down"?(c!==a&&(a=c),a<r.len-1&&(a+=1)):e==="row-first"?l=0:e==="row-last"?l=o.len-1:e==="col-first"?a=0:e==="col-last"&&(a=r.len-1),i&&(s.moveIndexes=[a,l]),selectorSet.call(this,i,a,l),scrollbarMove.call(this)}function overlayerMousemove(i){if(i.buttons!==0||i.target.className===`${cssPrefix}-resizer-hover`)return;const{offsetX:e,offsetY:s}=i,{rowResizer:n,colResizer:r,tableEl:o,data:a}=this,{rows:l,cols:c}=a;if(e>c.indexWidth&&s>l.height){n.hide(),r.hide();return}const d=o.box(),u=a.getCellRectByXY(i.offsetX,i.offsetY);u.ri>=0&&u.ci===-1?(u.width=c.indexWidth,n.show(u,{width:d.width}),l.isHide(u.ri-1)?n.showUnhide(u.ri):n.hideUnhide()):n.hide(),u.ri===-1&&u.ci>=0?(u.height=l.height,r.show(u,{height:d.height}),c.isHide(u.ci-1)?r.showUnhide(u.ci):r.hideUnhide()):r.hide()}function overlayerMousescroll(i){const{verticalScrollbar:e,horizontalScrollbar:s,data:n}=this,{top:r}=e.scroll(),{left:o}=s.scroll(),{rows:a,cols:l}=n,{deltaY:c,deltaX:d}=i,u=(y,E)=>{let b=y,v=0;do v=E(b),b+=1;while(v<=0);return v},p=y=>{if(y>0){const E=n.scroll.ri+1;if(E<a.len){const b=u(E,v=>a.getHeight(v));e.move({top:r+b-1})}}else{const E=n.scroll.ri-1;if(E>=0){const b=u(E,v=>a.getHeight(v));e.move({top:E===0?0:r-b})}}},m=y=>{if(y>0){const E=n.scroll.ci+1;if(E<l.len){const b=u(E,v=>l.getWidth(v));s.move({left:o+b-1})}}else{const E=n.scroll.ci-1;if(E>=0){const b=u(E,v=>l.getWidth(v));s.move({left:E===0?0:o-b})}}},f=Math.abs(c),g=Math.abs(d),x=Math.max(f,g);/Firefox/i.test(window.navigator.userAgent)&&throttle$2(p(i.detail),50),x===g&&throttle$2(m(d),50),x===f&&throttle$2(p(c),50)}function overlayerTouch(i,e){const{verticalScrollbar:s,horizontalScrollbar:n}=this,{top:r}=s.scroll(),{left:o}=n.scroll();i==="left"||i==="right"?n.move({left:o-e}):(i==="up"||i==="down")&&s.move({top:r-e})}function verticalScrollbarSet(){const{data:i,verticalScrollbar:e}=this,{height:s}=this.getTableOffset(),n=i.exceptRowTotalHeight(0,-1);e.set(s,i.rows.totalHeight()-n)}function horizontalScrollbarSet(){const{data:i,horizontalScrollbar:e}=this,{width:s}=this.getTableOffset();i&&e.set(s,i.cols.totalWidth())}function sheetFreeze(){const{selector:i,data:e,editor:s}=this,[n,r]=e.freeze;if(n>0||r>0){const o=e.freezeTotalWidth(),a=e.freezeTotalHeight();s.setFreezeLengths(o,a)}i.resetAreaOffset()}function sheetReset(){const{tableEl:i,overlayerEl:e,overlayerCEl:s,table:n,toolbar:r,selector:o,el:a}=this,l=this.getTableOffset(),c=this.getRect();i.attr(c),e.offset(c),s.offset(l),a.css("width",`${c.width}px`),verticalScrollbarSet.call(this),horizontalScrollbarSet.call(this),sheetFreeze.call(this),n.render(),r.reset(),o.reset()}function clearClipboard(){const{data:i,selector:e}=this;i.clearClipboard(),e.hideClipboard()}function copy$2(i){const{data:e,selector:s}=this;e.settings.mode!=="read"&&(e.copy(),e.copyToSystemClipboard(i),s.showClipboard())}function cut(){const{data:i,selector:e}=this;i.settings.mode!=="read"&&(i.cut(),e.showClipboard())}function paste(i,e){const{data:s}=this;if(s.settings.mode!=="read"){if(s.clipboard.isClear()){const n=()=>sheetReset.call(this),r=o=>{this.trigger("pasted-clipboard",o)};s.pasteFromSystemClipboard(n,r)}else if(s.paste(i,n=>xtoast("Tip",n)))sheetReset.call(this);else if(e){const n=e.clipboardData.getData("text/plain");this.data.pasteFromText(n),sheetReset.call(this)}}}function hideRowsOrCols(){this.data.hideRowsOrCols(),sheetReset.call(this)}function unhideRowsOrCols(i,e){this.data.unhideRowsOrCols(i,e),sheetReset.call(this)}function autofilter(){const{data:i}=this;i.autofilter(),sheetReset.call(this)}function toolbarChangePaintformatPaste(){const{toolbar:i}=this;i.paintformatActive()&&(paste.call(this,"format"),clearClipboard.call(this),i.paintformatToggle())}function overlayerMousedown(i){const{selector:e,data:s,table:n,sortFilter:r}=this,{offsetX:o,offsetY:a}=i,l=i.target.className===`${cssPrefix}-selector-corner`,c=s.getCellRectByXY(o,a),{left:d,top:u,width:p,height:m}=c;let{ri:f,ci:g}=c;const{autoFilter:x}=s;if(x.includes(f,g)&&d+p-20<o&&u+m-20<a){const y=x.items(g,(E,b)=>s.rows.getCell(E,b));r.hide(),r.set(g,y,x.getFilter(g),x.getSort(g)),r.setOffset({left:d,top:u+m+2});return}i.shiftKey||(l?e.showAutofill(f,g):selectorSet.call(this,!1,f,g),mouseMoveUp(window,y=>{({ri:f,ci:g}=s.getCellRectByXY(y.offsetX,y.offsetY)),l?e.showAutofill(f,g):y.buttons===1&&!y.shiftKey&&selectorSet.call(this,!0,f,g,!0,!0)},()=>{l&&e.arange&&s.settings.mode!=="read"&&s.autofill(e.arange,"all",y=>xtoast("Tip",y))&&n.render(),e.hideAutofill(),toolbarChangePaintformatPaste.call(this)})),!l&&i.buttons===1&&i.shiftKey&&selectorSet.call(this,!0,f,g)}function editorSetOffset(){const{editor:i,data:e}=this,s=e.getSelectedRect(),n=this.getTableOffset();let r="top";s.top>n.height/2&&(r="bottom"),i.setOffset(s,r)}function editorSet(){const{editor:i,data:e}=this;e.settings.mode!=="read"&&(editorSetOffset.call(this),i.setCell(e.getSelectedCell(),e.getSelectedValidator()),clearClipboard.call(this))}function verticalScrollbarMove(i){const{data:e,table:s,selector:n}=this;e.scrolly(i,()=>{n.resetBRLAreaOffset(),editorSetOffset.call(this),s.render()})}function horizontalScrollbarMove(i){const{data:e,table:s,selector:n}=this;e.scrollx(i,()=>{n.resetBRTAreaOffset(),editorSetOffset.call(this),s.render()})}function rowResizerFinished(i,e){const{ri:s}=i,{table:n,selector:r,data:o}=this,{sri:a,eri:l}=r.range;if(s>=a&&s<=l)for(let c=a;c<=l;c+=1)o.rows.setHeight(c,e);else o.rows.setHeight(s,e);n.render(),r.resetAreaOffset(),verticalScrollbarSet.call(this),editorSetOffset.call(this)}function colResizerFinished(i,e){const{ci:s}=i,{table:n,selector:r,data:o}=this,{sci:a,eci:l}=r.range;if(s>=a&&s<=l)for(let c=a;c<=l;c+=1)o.cols.setWidth(c,e);else o.cols.setWidth(s,e);n.render(),r.resetAreaOffset(),horizontalScrollbarSet.call(this),editorSetOffset.call(this)}function dataSetCellText(i,e="finished"){const{data:s,table:n}=this;if(s.settings.mode==="read")return;s.setSelectedCellText(i,e);const{ri:r,ci:o}=s.selector;e==="finished"?n.render():this.trigger("cell-edited",i,r,o)}function insertDeleteRowColumn(i){const{data:e}=this;e.settings.mode!=="read"&&(i==="insert-row"?e.insert("row"):i==="delete-row"?e.delete("row"):i==="insert-column"?e.insert("column"):i==="delete-column"?e.delete("column"):i==="delete-cell"?e.deleteCell():i==="delete-cell-format"?e.deleteCell("format"):i==="delete-cell-text"?e.deleteCell("text"):i==="cell-printable"?e.setSelectedCellAttr("printable",!0):i==="cell-non-printable"?e.setSelectedCellAttr("printable",!1):i==="cell-editable"?e.setSelectedCellAttr("editable",!0):i==="cell-non-editable"&&e.setSelectedCellAttr("editable",!1),clearClipboard.call(this),sheetReset.call(this))}function toolbarChange(i,e){const{data:s}=this;if(i==="undo")this.undo();else if(i==="redo")this.redo();else if(i==="print")this.print.preview();else if(i==="paintformat")e===!0?copy$2.call(this):clearClipboard.call(this);else if(i==="clearformat")insertDeleteRowColumn.call(this,"delete-cell-format");else if(i!=="link"){if(i!=="chart")if(i==="autofilter")autofilter.call(this);else if(i==="freeze")if(e){const{ri:n,ci:r}=s.selector;this.freeze(n,r)}else this.freeze(0,0);else s.setSelectedCellAttr(i,e),i==="formula"&&!s.selector.multiple()&&editorSet.call(this),sheetReset.call(this)}}function sortFilterChange(i,e,s,n){this.data.setAutoFilter(i,e,s,n),sheetReset.call(this)}function sheetInitEvents(){const{selector:i,overlayerEl:e,rowResizer:s,colResizer:n,verticalScrollbar:r,horizontalScrollbar:o,editor:a,contextMenu:l,toolbar:c,modalValidation:d,sortFilter:u}=this;e.on("mousemove",p=>{overlayerMousemove.call(this,p)}).on("mousedown",p=>{a.clear(),l.hide(),p.buttons===2?(this.data.xyInSelectedRect(p.offsetX,p.offsetY)||overlayerMousedown.call(this,p),l.setPosition(p.offsetX,p.offsetY),p.stopPropagation()):p.detail===2?editorSet.call(this):overlayerMousedown.call(this,p)}).on("mousewheel.stop",p=>{overlayerMousescroll.call(this,p)}).on("mouseout",p=>{const{offsetX:m,offsetY:f}=p;f<=0&&n.hide(),m<=0&&s.hide()}),i.inputChange=p=>{dataSetCellText.call(this,p,"input"),editorSet.call(this)},bindTouch(e.el,{move:(p,m)=>{overlayerTouch.call(this,p,m)}}),c.change=(p,m)=>toolbarChange.call(this,p,m),u.ok=(p,m,f,g)=>sortFilterChange.call(this,p,m,f,g),s.finishedFn=(p,m)=>{rowResizerFinished.call(this,p,m)},n.finishedFn=(p,m)=>{colResizerFinished.call(this,p,m)},s.unhideFn=p=>{unhideRowsOrCols.call(this,"row",p)},n.unhideFn=p=>{unhideRowsOrCols.call(this,"col",p)},r.moveFn=(p,m)=>{verticalScrollbarMove.call(this,p,m)},o.moveFn=(p,m)=>{horizontalScrollbarMove.call(this,p,m)},a.change=(p,m)=>{dataSetCellText.call(this,m,p)},d.change=(p,...m)=>{p==="save"?this.data.addValidation(...m):this.data.removeValidation()},l.itemClick=p=>{p==="validation"?d.setValue(this.data.getSelectedValidation()):p==="copy"?copy$2.call(this):p==="cut"?cut.call(this):p==="paste"?paste.call(this,"all"):p==="paste-value"?paste.call(this,"text"):p==="paste-format"?paste.call(this,"format"):p==="hide"?hideRowsOrCols.call(this):insertDeleteRowColumn.call(this,p)},bind(window,"resize",()=>{this.reload()}),bind(window,"click",p=>{this.focusing=e.contains(p.target)}),bind(window,"paste",p=>{this.focusing&&(paste.call(this,"all",p),p.preventDefault())}),bind(window,"copy",p=>{this.focusing&&(copy$2.call(this,p),p.preventDefault())}),bind(window,"keydown",p=>{if(!this.focusing)return;const m=p.keyCode||p.which,{key:f,ctrlKey:g,shiftKey:x,metaKey:y}=p;if(g||y)switch(m){case 90:this.undo(),p.preventDefault();break;case 89:this.redo(),p.preventDefault();break;case 67:break;case 88:cut.call(this),p.preventDefault();break;case 85:c.trigger("underline"),p.preventDefault();break;case 86:break;case 37:selectorMove.call(this,x,"row-first"),p.preventDefault();break;case 38:selectorMove.call(this,x,"col-first"),p.preventDefault();break;case 39:selectorMove.call(this,x,"row-last"),p.preventDefault();break;case 40:selectorMove.call(this,x,"col-last"),p.preventDefault();break;case 32:selectorSet.call(this,!1,-1,this.data.selector.ci,!1),p.preventDefault();break;case 66:c.trigger("bold");break;case 73:c.trigger("italic");break}else{switch(m){case 32:x&&selectorSet.call(this,!1,this.data.selector.ri,-1,!1);break;case 27:l.hide(),clearClipboard.call(this);break;case 37:selectorMove.call(this,x,"left"),p.preventDefault();break;case 38:selectorMove.call(this,x,"up"),p.preventDefault();break;case 39:selectorMove.call(this,x,"right"),p.preventDefault();break;case 40:selectorMove.call(this,x,"down"),p.preventDefault();break;case 9:a.clear(),selectorMove.call(this,!1,x?"left":"right"),p.preventDefault();break;case 13:a.clear(),selectorMove.call(this,!1,x?"up":"down"),p.preventDefault();break;case 8:insertDeleteRowColumn.call(this,"delete-cell-text"),p.preventDefault();break}f==="Delete"?(insertDeleteRowColumn.call(this,"delete-cell-text"),p.preventDefault()):m>=65&&m<=90||m>=48&&m<=57||m>=96&&m<=105||p.key==="="?(dataSetCellText.call(this,p.key,"input"),editorSet.call(this)):m===113&&editorSet.call(this)}})}class Sheet{constructor(e,s){this.eventMap=createEventEmitter();const{view:n,showToolbar:r,showContextmenu:o}=s.settings;this.el=h("div",`${cssPrefix}-sheet`),this.toolbar=new Toolbar(s,n.width,!r),this.print=new Print$1(s),e.children(this.toolbar.el,this.el,this.print.el),this.data=s,this.tableEl=h("canvas",`${cssPrefix}-table`),this.rowResizer=new Resizer(!1,s.rows.height),this.colResizer=new Resizer(!0,s.cols.minWidth),this.verticalScrollbar=new Scrollbar(!0),this.horizontalScrollbar=new Scrollbar(!1),this.editor=new Editor(formulas,()=>this.getTableOffset(),s.rows.height),this.modalValidation=new ModalValidation,this.contextMenu=new ContextMenu$1(()=>this.getRect(),!o),this.selector=new Selector(s),this.overlayerCEl=h("div",`${cssPrefix}-overlayer-content`).children(this.editor.el,this.selector.el),this.overlayerEl=h("div",`${cssPrefix}-overlayer`).child(this.overlayerCEl),this.sortFilter=new SortFilter,this.el.children(this.tableEl,this.overlayerEl.el,this.rowResizer.el,this.colResizer.el,this.verticalScrollbar.el,this.horizontalScrollbar.el,this.contextMenu.el,this.modalValidation.el,this.sortFilter.el),this.table=new table_rslib_entry_(this.tableEl.el,s),sheetInitEvents.call(this),sheetReset.call(this),selectorSet.call(this,!1,0,0)}on(e,s){return this.eventMap.on(e,s),this}trigger(e,...s){const{eventMap:n}=this;n.fire(e,s)}resetData(e){this.editor.clear(),this.data=e,verticalScrollbarSet.call(this),horizontalScrollbarSet.call(this),this.toolbar.resetData(e),this.print.resetData(e),this.selector.resetData(e),this.table.resetData(e)}loadData(e){return this.data.setData(e),sheetReset.call(this),this}freeze(e,s){const{data:n}=this;return n.setFreeze(e,s),sheetReset.call(this),this}undo(){this.data.undo(),sheetReset.call(this)}redo(){this.data.redo(),sheetReset.call(this)}reload(){return sheetReset.call(this),this}getRect(){const{data:e}=this;return{width:e.viewWidth(),height:e.viewHeight()}}getTableOffset(){const{rows:e,cols:s}=this.data,{width:n,height:r}=this.getRect();return{width:n-s.indexWidth,height:r-e.height,left:s.indexWidth,top:e.height}}}class DropdownMore extends Dropdown{constructor(e){const s=new Icon("ellipsis");super(s,"auto",!1,"top-left"),this.contentClick=e}reset(e){const s=e.map((n,r)=>h("div",`${cssPrefix}-item`).css("width","150px").css("font-weight","normal").on("click",()=>{this.contentClick(r),this.hide()}).child(n));this.setContentChildren(...s)}setTitle(){}}const menuItems=[{key:"delete",title:tf("contextmenu.deleteSheet")}];function buildMenuItem(i){return h("div",`${cssPrefix}-item`).child(i.title()).on("click",()=>{this.itemClick(i.key),this.hide()})}function buildMenu(){return menuItems.map(i=>buildMenuItem.call(this,i))}class ContextMenu{constructor(){this.el=h("div",`${cssPrefix}-contextmenu`).css("width","160px").children(...buildMenu.call(this)).hide(),this.itemClick=()=>{}}hide(){const{el:e}=this;e.hide(),unbindClickoutside(e)}setOffset(e){const{el:s}=this;s.offset(e),s.show(),bindClickoutside(s)}}class Bottombar{constructor(e=()=>{},s=()=>{},n=()=>{},r=()=>{}){this.swapFunc=s,this.updateFunc=r,this.dataNames=[],this.activeEl=null,this.deleteEl=null,this.items=[],this.moreEl=new DropdownMore(o=>{this.clickSwap2(this.items[o])}),this.contextMenu=new ContextMenu,this.contextMenu.itemClick=n,this.el=h("div",`${cssPrefix}-bottombar`).children(this.contextMenu.el,this.menuEl=h("ul",`${cssPrefix}-menu`).child(h("li","").children(new Icon("add").on("click",()=>{e()}),h("span","").child(this.moreEl))))}addItem(e,s,n){this.dataNames.push(e);const r=h("li",s?"active":"").child(e);r.on("click",()=>{this.clickSwap2(r)}).on("contextmenu",o=>{if(n.mode==="read")return;const{offsetLeft:a,offsetHeight:l}=o.target;this.contextMenu.setOffset({left:a,bottom:l+1}),this.deleteEl=r}).on("dblclick",()=>{if(n.mode==="read")return;const o=r.html(),a=new FormInput("auto","");a.val(o),a.input.on("blur",({target:l})=>{const{value:c}=l,d=this.dataNames.findIndex(u=>u===o);this.renameItem(d,c)}),r.html("").child(a.el),a.focus()}),s&&this.clickSwap(r),this.items.push(r),this.menuEl.child(r),this.moreEl.reset(this.dataNames)}renameItem(e,s){this.dataNames.splice(e,1,s),this.moreEl.reset(this.dataNames),this.items[e].html("").child(s),this.updateFunc(e,s)}clear(){this.items.forEach(e=>{this.menuEl.removeChild(e.el)}),this.items=[],this.dataNames=[],this.moreEl.reset(this.dataNames)}deleteItem(){const{activeEl:e,deleteEl:s}=this;if(this.items.length>1){const n=this.items.findIndex(r=>r===s);if(this.items.splice(n,1),this.dataNames.splice(n,1),this.menuEl.removeChild(s.el),this.moreEl.reset(this.dataNames),e===s){const[r]=this.items;return this.activeEl=r,this.activeEl.toggle(),[n,0]}return[n,-1]}return[-1]}clickSwap2(e){const s=this.items.findIndex(n=>n===e);this.clickSwap(e),this.activeEl.toggle(),this.swapFunc(s)}clickSwap(e){this.activeEl!==null&&this.activeEl.toggle(),this.activeEl=e}}const K=class K{constructor(e,s={}){H(this,S);H(this,k,1);H(this,T);H(this,$);H(this,B);H(this,N);V(this,S,w({showBottomBar:!0},s)),V(this,T,[]),V(this,N,F(this,S).showBottomBar?new Bottombar(()=>{if(F(this,S).mode==="read")return;const r=this.addSheet();F(this,B).resetData(r)},r=>{const o=F(this,T)[r];F(this,B).resetData(o)},()=>{this.deleteSheet()},(r,o)=>{F(this,T)[r].name=o,F(this,B).trigger("change")}):null),V(this,$,this.addSheet());const n=h("div",`${cssPrefix}`).on("contextmenu",r=>r.preventDefault());e.appendChild(n.el),V(this,B,new Sheet(n,F(this,$))),F(this,N)!==null&&n.child(F(this,N).el)}static makeSheet(e,s={}){if(K.targets.has(e)){const r=K.targets.get(e);if(r)return r}const n=new K(e,s);K.targets.set(e,n)}on(e,s){return F(this,B).on(e,s),this}reRender(){return F(this,B).table.render(),this}cell(e,s,n=0){return F(this,T)[n].getCell(e,s)}cellStyle(e,s,n=0){return F(this,T)[n].getCellStyle(e,s)}cellText(e,s,n,r=0){return F(this,T)[r].setCellText(e,s,n,"finished"),this}deleteSheet(){if(F(this,N)===null)return;const[e,s]=F(this,N).deleteItem();e>=0&&(F(this,T).splice(e,1),s>=0&&F(this,B).resetData(F(this,T)[s]),F(this,B).trigger("change"))}loadData(e){const s=Array.isArray(e)?e:[e];if(F(this,N)!==null&&F(this,N).clear(),V(this,T,[]),s.length>0)for(let n=0;n<s.length;n+=1){const r=s[n],o=this.addSheet(r.name,n===0);o.setData(r),n===0&&F(this,B).resetData(o)}return this}getData(){return F(this,T).map(e=>e.getData())}validate(){const{validations:e}=F(this,$);return e.errors.size<=0}change(e){return F(this,B).on("change",e),this}static locale(e,s){locale(e,s)}addSheet(e,s=!0){const n=e||`sheet${F(this,k)}`,r=new DataProxy(n,F(this,S));return r.change=(...o)=>{F(this,B).trigger("change",...o)},F(this,T).push(r),F(this,N)!==null&&F(this,N).addItem(n,s,F(this,S)),V(this,k,F(this,k)+1),r}};S=new WeakMap,k=new WeakMap,T=new WeakMap,$=new WeakMap,B=new WeakMap,N=new WeakMap,C(K,"targets",new WeakMap);let Spreadsheet=K;var __webpack_exports__Spreadsheet=Spreadsheet;const ExcelSheet=React.forwardRef(({data:i,className:e},s)=>{const n=React.useRef(null),r=React.useRef(null),o=()=>{if(!n.current)throw new Error("Workbook is not initialized");return n.current.getData()};return React.useImperativeHandle(s,()=>({getData:o})),React.useEffect(()=>{if(r.current){const a=__webpack_exports__Spreadsheet.makeSheet(r.current,{view:{height:()=>{var l;return(l=r.current)==null?void 0:l.offsetHeight},width:()=>{var l;return(l=r.current)==null?void 0:l.offsetWidth}}});a.loadData(i),n.current=a}},[i]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{ref:r,id:"sheet988",className:client.cx(client.css`
16
+ `,o.head.appendChild(l),this.canvases.forEach(a=>{const c=a.cloneNode(!1);c.getContext("2d").drawImage(a,0,0),o.body.appendChild(c)}),r.print()}};const menuItems$1=[{key:"copy",title:tf("contextmenu.copy"),label:"Ctrl+C"},{key:"cut",title:tf("contextmenu.cut"),label:"Ctrl+X"},{key:"paste",title:tf("contextmenu.paste"),label:"Ctrl+V"},{key:"paste-value",title:tf("contextmenu.pasteValue"),label:"Ctrl+Shift+V"},{key:"paste-format",title:tf("contextmenu.pasteFormat"),label:"Ctrl+Alt+V"},{key:"divider"},{key:"insert-row",title:tf("contextmenu.insertRow")},{key:"insert-column",title:tf("contextmenu.insertColumn")},{key:"divider"},{key:"delete-row",title:tf("contextmenu.deleteRow")},{key:"delete-column",title:tf("contextmenu.deleteColumn")},{key:"delete-cell-text",title:tf("contextmenu.deleteCellText")},{key:"hide",title:tf("contextmenu.hide")},{key:"divider"},{key:"validation",title:tf("contextmenu.validation")},{key:"divider"},{key:"cell-printable",title:tf("contextmenu.cellprintable")},{key:"cell-non-printable",title:tf("contextmenu.cellnonprintable")},{key:"divider"},{key:"cell-editable",title:tf("contextmenu.celleditable")},{key:"cell-non-editable",title:tf("contextmenu.cellnoneditable")}];function buildMenuItem$1(n){return n.key==="divider"?h("div",`${cssPrefix}-item divider`):h("div",`${cssPrefix}-item`).on("click",()=>{this.itemClick(n.key),this.hide()}).children(n.title(),h("div","label").child(n.label||""))}function buildMenu$2(){return menuItems$1.map(n=>buildMenuItem$1.call(this,n))}let ContextMenu$1=class{constructor(e,s=!1){this.menuItems=buildMenu$2.call(this),this.el=h("div",`${cssPrefix}-contextmenu`).children(...this.menuItems).hide(),this.viewFn=e,this.itemClick=()=>{},this.isHide=s,this.setMode("range")}setMode(e){const s=this.menuItems[12];e==="row-col"?s.show():s.hide()}hide(){const{el:e}=this;e.hide(),unbindClickoutside(e)}setPosition(e,s){if(this.isHide)return;const{el:i}=this,{width:r}=i.show().offset(),o=this.viewFn(),l=o.height/2;let a=e;o.width-e<=r&&(a-=r),i.css("left",`${a}px`),s>l?i.css("bottom",`${o.height-s}px`).css("max-height",`${s}px`).css("top","auto"):i.css("top",`${s}px`).css("max-height",`${o.height-s}px`).css("bottom","auto"),bindClickoutside(i)}};function tooltip(n,e){if(e.classList.contains("active"))return;const{left:s,top:i,width:r,height:o}=e.getBoundingClientRect(),l=h("div",`${cssPrefix}-tooltip`).html(n).show();document.body.appendChild(l.el);const a=l.box();l.css("left",`${s+r/2-a.width/2}px`).css("top",`${i+o+2}px`),bind(e,"mouseleave",()=>{document.body.contains(l.el)&&document.body.removeChild(l.el)}),bind(e,"click",()=>{document.body.contains(l.el)&&document.body.removeChild(l.el)})}class Item{constructor(e,s,i){this.tip="",e&&(this.tip=t(`toolbar.${e.replace(/-[a-z]/g,r=>r[1].toUpperCase())}`)),s&&(this.tip+=` (${s})`),this.tag=e,this.shortcut=s,this.value=i,this.el=this.element(),this.change=()=>{}}element(){const{tip:e}=this;return h("div",`${cssPrefix}-toolbar-btn`).on("mouseenter",s=>{this.tip&&tooltip(this.tip,s.target)}).attr("data-tooltip",e)}setState(){}}class DropdownItem extends Item{dropdown(){}getValue(e){return e}element(){const{tag:e}=this;return this.dd=this.dropdown(),this.dd.change=s=>this.change(e,this.getValue(s)),super.element().child(this.dd)}setState(e){e&&(this.value=e,this.dd.setTitle(e))}}class Dropdown extends Element{constructor(e,s,i,r,...o){super("div",`${cssPrefix}-dropdown ${r}`),this.title=e,this.change=()=>{},this.headerClick=()=>{},typeof e=="string"?this.title=h("div",`${cssPrefix}-dropdown-title`).child(e):i&&this.title.addClass("arrow-left"),this.contentEl=h("div",`${cssPrefix}-dropdown-content`).css("width",s).hide(),this.setContentChildren(...o),this.headerEl=h("div",`${cssPrefix}-dropdown-header`),this.headerEl.on("click",()=>{this.contentEl.css("display")!=="block"?this.show():this.hide()}).children(this.title,i?h("div",`${cssPrefix}-icon arrow-right`).child(h("div",`${cssPrefix}-icon-img arrow-down`)):""),this.children(this.headerEl,this.contentEl)}setContentChildren(...e){this.contentEl.html(""),e.length>0&&this.contentEl.children(...e)}setTitle(e){this.title.html(e),this.hide()}show(){const{contentEl:e}=this;e.show(),this.parent().active(),bindClickoutside(this.parent(),()=>{this.hide()})}hide(){this.parent().active(!1),this.contentEl.hide(),unbindClickoutside(this.parent())}}function buildItemWithIcon(n){return h("div",`${cssPrefix}-item`).child(new Icon(n))}class DropdownAlign extends Dropdown{constructor(e,s){const i=new Icon(`align-${s}`),r=e.map(o=>buildItemWithIcon(`align-${o}`).on("click",()=>{this.setTitle(o),this.change(o)}));super(i,"auto",!0,"bottom-left",...r)}setTitle(e){this.title.setName(`align-${e}`),this.hide()}}class Align extends DropdownItem{constructor(e){super("align","",e)}dropdown(){const{value:e}=this;return new DropdownAlign(["left","center","right"],e)}}class Valign extends DropdownItem{constructor(e){super("valign","",e)}dropdown(){const{value:e}=this;return new DropdownAlign(["top","middle","bottom"],e)}}class ToggleItem extends Item{element(){const{tag:e}=this;return super.element().child(new Icon(e)).on("click",()=>this.click())}click(){this.change(this.tag,this.toggle())}setState(e){this.el.active(e)}toggle(){return this.el.toggle()}active(){return this.el.hasClass("active")}}class Autofilter extends ToggleItem{constructor(){super("autofilter")}setState(){}}class Bold extends ToggleItem{constructor(){super("font-bold","Ctrl+B")}}class Italic extends ToggleItem{constructor(){super("font-italic","Ctrl+I")}}class Strike extends ToggleItem{constructor(){super("strike","Ctrl+U")}}class Underline extends ToggleItem{constructor(){super("underline","Ctrl+U")}}const themeColorPlaceHolders=["#ffffff","#000100","#e7e5e6","#445569","#5b9cd6","#ed7d31","#a5a5a5","#ffc001","#4371c6","#71ae47"],themeColors=[["#f2f2f2","#7f7f7f","#d0cecf","#d5dce4","#deeaf6","#fce5d5","#ededed","#fff2cd","#d9e2f3","#e3efd9"],["#d8d8d8","#595959","#afabac","#adb8ca","#bdd7ee","#f7ccac","#dbdbdb","#ffe59a","#b3c6e7","#c5e0b3"],["#bfbfbf","#3f3f3f","#756f6f","#8596b0","#9cc2e6","#f4b184","#c9c9c9","#fed964","#8eaada","#a7d08c"],["#a5a5a5","#262626","#3a3839","#333f4f","#2e75b5","#c45a10","#7b7b7b","#bf8e01","#2f5596","#538136"],["#7f7f7f","#0c0c0c","#171516","#222a35","#1f4e7a","#843c0a","#525252","#7e6000","#203864","#365624"]],standardColors=["#c00000","#fe0000","#fdc101","#ffff01","#93d051","#00b04e","#01b0f1","#0170c1","#012060","#7030a0"];function buildTd$1(n){return h("td","").child(h("div",`${cssPrefix}-color-palette-cell`).on("click.stop",()=>this.change(n)).css("background-color",n))}class ColorPalette{constructor(){this.el=h("div",`${cssPrefix}-color-palette`),this.change=()=>{};const e=h("table","").children(h("tbody","").children(h("tr",`${cssPrefix}-theme-color-placeholders`).children(...themeColorPlaceHolders.map(s=>buildTd$1.call(this,s))),...themeColors.map(s=>h("tr",`${cssPrefix}-theme-colors`).children(...s.map(i=>buildTd$1.call(this,i)))),h("tr",`${cssPrefix}-standard-colors`).children(...standardColors.map(s=>buildTd$1.call(this,s)))));this.el.child(e)}}class DropdownColor extends Dropdown{constructor(e,s){const i=new Icon(e).css("height","16px").css("border-bottom",`3px solid ${s}`),r=new ColorPalette;r.change=o=>{this.setTitle(o),this.change(o)},super(i,"auto",!1,"bottom-left",r.el)}setTitle(e){this.title.css("border-color",e),this.hide()}}const lineTypes=[["thin",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" style="user-select: none;"></line></svg>'],["medium",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="2" style="user-select: none;"><line x1="0" y1="1.0" x2="50" y2="1.0" stroke-width="2" stroke="black" style="user-select: none;"></line></svg>'],["thick",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="3" style="user-select: none;"><line x1="0" y1="1.5" x2="50" y2="1.5" stroke-width="3" stroke="black" style="user-select: none;"></line></svg>'],["dashed",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" stroke-dasharray="2" style="user-select: none;"></line></svg>'],["dotted",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" stroke-dasharray="1" style="user-select: none;"></line></svg>']];class DropdownLineType extends Dropdown{constructor(e){const s=new Icon("line-type");let i=0;const r=lineTypes.map((o,l)=>h("div",`${cssPrefix}-item state ${e===o[0]?"checked":""}`).on("click",()=>{r[i].toggle("checked"),r[l].toggle("checked"),i=l,this.hide(),this.change(o)}).child(h("div",`${cssPrefix}-line-type`).html(o[1])));super(s,"auto",!1,"bottom-left",...r)}}function buildTable(...n){return h("table","").child(h("tbody","").children(...n))}function buildTd(n){return h("td","").child(h("div",`${cssPrefix}-border-palette-cell`).child(new Icon(`border-${n}`)).on("click",()=>{this.mode=n;const{mode:e,style:s,color:i}=this;this.change({mode:e,style:s,color:i})}))}class BorderPalette{constructor(){this.color="#000",this.style="thin",this.mode="all",this.change=()=>{},this.ddColor=new DropdownColor("line-color",this.color),this.ddColor.change=s=>{this.color=s},this.ddType=new DropdownLineType(this.style),this.ddType.change=([s])=>{this.style=s},this.el=h("div",`${cssPrefix}-border-palette`);const e=buildTable(h("tr","").children(h("td",`${cssPrefix}-border-palette-left`).child(buildTable(h("tr","").children(...["all","inside","horizontal","vertical","outside"].map(s=>buildTd.call(this,s))),h("tr","").children(...["left","top","right","bottom","none"].map(s=>buildTd.call(this,s))))),h("td",`${cssPrefix}-border-palette-right`).children(h("div",`${cssPrefix}-toolbar-btn`).child(this.ddColor.el),h("div",`${cssPrefix}-toolbar-btn`).child(this.ddType.el))));this.el.child(e)}}class DropdownBorder extends Dropdown{constructor(){const e=new Icon("border-all"),s=new BorderPalette;s.change=i=>{this.change(i),this.hide()},super(e,"auto",!1,"bottom-left",s.el)}}class Border extends DropdownItem{constructor(){super("border")}dropdown(){return new DropdownBorder}}class IconItem extends Item{element(){return super.element().child(new Icon(this.tag)).on("click",()=>this.change(this.tag))}setState(e){this.el.disabled(e)}}class Clearformat extends IconItem{constructor(){super("clearformat")}}class Paintformat extends ToggleItem{constructor(){super("paintformat")}setState(){}}class TextColor extends DropdownItem{constructor(e){super("color",void 0,e)}dropdown(){const{tag:e,value:s}=this;return new DropdownColor(e,s)}}class FillColor extends DropdownItem{constructor(e){super("bgcolor",void 0,e)}dropdown(){const{tag:e,value:s}=this;return new DropdownColor(e,s)}}class DropdownFontSize extends Dropdown{constructor(){const e=fontSizes.map(s=>h("div",`${cssPrefix}-item`).on("click",()=>{this.setTitle(`${s.pt}`),this.change(s)}).child(`${s.pt}`));super("10","60px",!0,"bottom-left",...e)}}let Format$2=class extends DropdownItem{constructor(){super("font-size")}getValue(e){return e.pt}dropdown(){return new DropdownFontSize}};class DropdownFont extends Dropdown{constructor(){const e=baseFonts.map(s=>h("div",`${cssPrefix}-item`).on("click",()=>{this.setTitle(s.title),this.change(s)}).child(s.title));super(baseFonts[0].title,"160px",!0,"bottom-left",...e)}}class Font extends DropdownItem{constructor(){super("font-name")}getValue(e){return e.key}dropdown(){return new DropdownFont}}class DropdownFormat extends Dropdown{constructor(){let e=baseFormats.slice(0);e.splice(2,0,{key:"divider"}),e.splice(8,0,{key:"divider"}),e=e.map(s=>{const i=h("div",`${cssPrefix}-item`);return s.key==="divider"?i.addClass("divider"):(i.child(s.title()).on("click",()=>{this.setTitle(s.title()),this.change(s)}),s.label&&i.child(h("div","label").html(s.label))),i}),super("Normal","220px",!0,"bottom-left",...e)}setTitle(e){for(let s=0;s<baseFormats.length;s+=1)baseFormats[s].key===e&&this.title.html(baseFormats[s].title());this.hide()}}let Format$1=class extends DropdownItem{constructor(){super("format")}getValue(e){return e.key}dropdown(){return new DropdownFormat}};class DropdownFormula extends Dropdown{constructor(){const e=baseFormulas.map(s=>h("div",`${cssPrefix}-item`).on("click",()=>{this.hide(),this.change(s)}).child(s.key));super(new Icon("formula"),"180px",!0,"bottom-left",...e)}}class Format extends DropdownItem{constructor(){super("formula")}getValue(e){return e.key}dropdown(){return new DropdownFormula}}class Freeze extends ToggleItem{constructor(){super("freeze")}}class Merge extends ToggleItem{constructor(){super("merge")}setState(e,s){this.el.active(e).disabled(s)}}class Redo extends IconItem{constructor(){super("redo","Ctrl+Y")}}class Undo extends IconItem{constructor(){super("undo","Ctrl+Z")}}class Print extends IconItem{constructor(){super("print","Ctrl+P")}}class Textwrap extends ToggleItem{constructor(){super("textwrap")}}let DropdownMore$1=class extends Dropdown{constructor(){const e=new Icon("ellipsis"),s=h("div",`${cssPrefix}-toolbar-more`);super(e,"auto",!1,"bottom-right",s),this.moreBtns=s,this.contentEl.css("max-width","420px")}};class More extends DropdownItem{constructor(){super("more"),this.el.hide()}dropdown(){return new DropdownMore$1}show(){this.el.show()}hide(){this.el.hide()}}function buildDivider(){return h("div",`${cssPrefix}-toolbar-divider`)}function initBtns2(){this.btns2=[],this.items.forEach(n=>{if(Array.isArray(n))n.forEach(({el:e})=>{const s=e.box(),{marginLeft:i,marginRight:r}=e.computedStyle();this.btns2.push([e,s.width+parseInt(i,10)+parseInt(r,10)])});else{const e=n.box(),{marginLeft:s,marginRight:i}=n.computedStyle();this.btns2.push([n,e.width+parseInt(s,10)+parseInt(i,10)])}})}function moreResize(){const{el:n,btns:e,moreEl:s,btns2:i}=this,{moreBtns:r,contentEl:o}=s.dd;n.css("width",`${this.widthFn()}px`);const l=n.box();let a=160,c=12;const d=[],u=[];i.forEach(([f,m],p)=>{a+=m,p===i.length-1||a<l.width?d.push(f):(c+=m,u.push(f))}),e.html("").children(...d),r.html("").children(...u),o.css("width",`${c}px`),u.length>0?s.show():s.hide()}function genBtn(n){const e=new Item;e.el.on("click",()=>{n.onClick&&n.onClick(this.data.getData(),this.data)}),e.tip=n.tip||"";let{el:s}=n;if(n.icon&&(s=h("img").attr("src",n.icon)),s){const i=h("div",`${cssPrefix}-icon`);i.child(s),e.el.child(i)}return e}class Toolbar{constructor(e,s,i=!1){this.data=e,this.change=()=>{},this.widthFn=s,this.isHide=i;const r=e.defaultStyle();this.items=[[this.undoEl=new Undo,this.redoEl=new Redo,new Print,this.paintformatEl=new Paintformat,this.clearformatEl=new Clearformat],buildDivider(),[this.formatEl=new Format$1],buildDivider(),[this.fontEl=new Font,this.fontSizeEl=new Format$2],buildDivider(),[this.boldEl=new Bold,this.italicEl=new Italic,this.underlineEl=new Underline,this.strikeEl=new Strike,this.textColorEl=new TextColor(r.color)],buildDivider(),[this.fillColorEl=new FillColor(r.bgcolor),this.borderEl=new Border,this.mergeEl=new Merge],buildDivider(),[this.alignEl=new Align(r.align),this.valignEl=new Valign(r.valign),this.textwrapEl=new Textwrap],buildDivider(),[this.freezeEl=new Freeze,this.autofilterEl=new Autofilter,this.formulaEl=new Format]];const{extendToolbar:o={}}=e.settings;if(o.left&&o.left.length>0){this.items.unshift(buildDivider());const l=o.left.map(genBtn.bind(this));this.items.unshift(l)}if(o.right&&o.right.length>0){this.items.push(buildDivider());const l=o.right.map(genBtn.bind(this));this.items.push(l)}this.items.push([this.moreEl=new More]),this.el=h("div",`${cssPrefix}-toolbar`),this.btns=h("div",`${cssPrefix}-toolbar-btns`),this.items.forEach(l=>{Array.isArray(l)?l.forEach(a=>{this.btns.child(a.el),a.change=(...c)=>{this.change(...c)}}):this.btns.child(l.el)}),this.el.child(this.btns),i?this.el.hide():(this.reset(),setTimeout(()=>{initBtns2.call(this),moreResize.call(this)},0),bind(window,"resize",()=>{moreResize.call(this)}))}paintformatActive(){return this.paintformatEl.active()}paintformatToggle(){this.paintformatEl.toggle()}trigger(e){this[`${e}El`].click()}resetData(e){this.data=e,this.reset()}reset(){if(this.isHide)return;const{data:e}=this,s=e.getSelectedCellStyle();this.undoEl.setState(!e.canUndo()),this.redoEl.setState(!e.canRedo()),this.mergeEl.setState(e.canUnmerge(),!e.selector.multiple()),this.autofilterEl.setState(!e.canAutofilter());const{font:i,format:r}=s;this.formatEl.setState(r),this.fontEl.setState(i.name),this.fontSizeEl.setState(i.size),this.boldEl.setState(i.bold),this.italicEl.setState(i.italic),this.underlineEl.setState(s.underline),this.strikeEl.setState(s.strike),this.textColorEl.setState(s.color),this.fillColorEl.setState(s.bgcolor),this.alignEl.setState(s.align),this.valignEl.setState(s.valign),this.textwrapEl.setState(s.textwrap),this.freezeEl.setState(e.freezeIsActive())}}class Modal{constructor(e,s,i="600px"){this.title=e,this.el=h("div",`${cssPrefix}-modal`).css("width",i).children(h("div",`${cssPrefix}-modal-header`).children(new Icon("close").on("click.stop",()=>this.hide()),this.title),h("div",`${cssPrefix}-modal-content`).children(...s)).hide()}show(){this.dimmer=h("div",`${cssPrefix}-dimmer active`),document.body.appendChild(this.dimmer.el);const{width:e,height:s}=this.el.show().box(),{clientHeight:i,clientWidth:r}=document.documentElement;this.el.offset({left:(r-e)/2,top:(i-s)/3}),window.xkeydownEsc=o=>{o.keyCode===27&&this.hide()},bind(window,"keydown",window.xkeydownEsc)}hide(){this.el.hide(),document.body.removeChild(this.dimmer.el),unbind(window,"keydown",window.xkeydownEsc),delete window.xkeydownEsc}}class FormInput{constructor(e,s){this.vchange=()=>{},this.el=h("div",`${cssPrefix}-form-input`),this.input=h("input","").css("width",e).on("input",i=>this.vchange(i)).attr("placeholder",s),this.el.child(this.input)}focus(){setTimeout(()=>{this.input.el.focus()},10)}hint(e){this.input.attr("placeholder",e)}val(e){return this.input.val(e)}}class FormSelect{constructor(e,s,i,r=l=>l,o=()=>{}){this.key=e,this.getTitle=r,this.vchange=()=>{},this.el=h("div",`${cssPrefix}-form-select`),this.suggest=new Suggest(s.map(l=>({key:l,title:this.getTitle(l)})),l=>{this.itemClick(l.key),o(l.key),this.vchange(l.key)},i,this.el),this.el.children(this.itemEl=h("div","input-text").html(this.getTitle(e)),this.suggest.el).on("click",()=>this.show())}show(){this.suggest.search("")}itemClick(e){this.key=e,this.itemEl.html(this.getTitle(e))}val(e){return e!==void 0?(this.key=e,this.itemEl.html(this.getTitle(e)),this):this.key}}const patterns={number:/(^\d+$)|(^\d+(\.\d{0,4})?$)/,date:/^\d{4}-\d{1,2}-\d{1,2}$/};class FormField{constructor(e,s,i,r){this.label="",this.rule=s,i&&(this.label=h("label","label").css("width",`${r}px`).html(i)),this.tip=h("div","tip").child("tip").hide(),this.input=e,this.input.vchange=()=>this.validate(),this.el=h("div",`${cssPrefix}-form-field`).children(this.label,e.el,this.tip)}isShow(){return this.el.css("display")!=="none"}show(){this.el.show()}hide(){return this.el.hide(),this}val(e){return this.input.val(e)}hint(e){this.input.hint(e)}validate(){const{input:e,rule:s,tip:i,el:r}=this,o=e.val();return s.required&&/^\s*$/.test(o)?(i.html(t("validation.required")),r.addClass("error"),!1):(s.type||s.pattern)&&!(s.pattern||patterns[s.type]).test(o)?(i.html(t("validation.notMatch")),r.addClass("error"),!1):(r.removeClass("error"),!0)}}const fieldLabelWidth=100;class ModalValidation extends Modal{constructor(){const e=new FormField(new FormSelect("cell",["cell"],"100%",d=>t(`dataValidation.modeType.${d}`)),{required:!0},`${t("dataValidation.range")}:`,fieldLabelWidth),s=new FormField(new FormInput("120px","E3 or E3:F12"),{required:!0,pattern:/^([A-Z]{1,2}[1-9]\d*)(:[A-Z]{1,2}[1-9]\d*)?$/}),i=new FormField(new FormSelect("list",["list","number","date","phone","email"],"100%",d=>t(`dataValidation.type.${d}`),d=>this.criteriaSelected(d)),{required:!0},`${t("dataValidation.criteria")}:`,fieldLabelWidth),r=new FormField(new FormSelect("be",["be","nbe","eq","neq","lt","lte","gt","gte"],"160px",d=>t(`dataValidation.operator.${d}`),d=>this.criteriaOperatorSelected(d)),{required:!0}).hide(),o=new FormField(new FormInput("70px","10"),{required:!0}).hide(),l=new FormField(new FormInput("70px","100"),{required:!0,type:"number"}).hide(),a=new FormField(new FormInput("120px","a,b,c"),{required:!0}),c=new FormField(new FormInput("70px","10"),{required:!0,type:"number"}).hide();super(t("contextmenu.validation"),[h("div",`${cssPrefix}-form-fields`).children(e.el,s.el),h("div",`${cssPrefix}-form-fields`).children(i.el,r.el,o.el,l.el,c.el,a.el),h("div",`${cssPrefix}-buttons`).children(new Button("cancel").on("click",()=>this.btnClick("cancel")),new Button("remove").on("click",()=>this.btnClick("remove")),new Button("save","primary").on("click",()=>this.btnClick("save")))]),this.mf=e,this.rf=s,this.cf=i,this.of=r,this.minvf=o,this.maxvf=l,this.vf=c,this.svf=a,this.change=()=>{}}showVf(e){const s=e==="date"?"2018-11-12":"10",{vf:i}=this;i.input.hint(s),i.show()}criteriaSelected(e){const{of:s,minvf:i,maxvf:r,vf:o,svf:l}=this;e==="date"||e==="number"?(s.show(),i.rule.type=e,r.rule.type=e,e==="date"?(i.hint("2018-11-12"),r.hint("2019-11-12")):(i.hint("10"),r.hint("100")),i.show(),r.show(),o.hide(),l.hide()):(e==="list"?l.show():l.hide(),o.hide(),s.hide(),i.hide(),r.hide())}criteriaOperatorSelected(e){if(!e)return;const{minvf:s,maxvf:i,vf:r}=this;if(e==="be"||e==="nbe")s.show(),i.show(),r.hide();else{const o=this.cf.val();r.rule.type=o,o==="date"?r.hint("2018-11-12"):r.hint("10"),r.show(),s.hide(),i.hide()}}btnClick(e){if(e==="cancel")this.hide();else if(e==="remove")this.change("remove"),this.hide();else if(e==="save"){const s=["mf","rf","cf","of","svf","vf","minvf","maxvf"];for(let c=0;c<s.length;c+=1){const d=this[s[c]];if(d.isShow()&&!d.validate())return}const i=this.mf.val(),r=this.rf.val(),o=this.cf.val(),l=this.of.val();let a=this.svf.val();(o==="number"||o==="date")&&(a=l==="be"||l==="nbe"?[this.minvf.val(),this.maxvf.val()]:this.vf.val()),this.change("save",i,r,{type:o,operator:l,required:!1,value:a}),this.hide()}}setValue(e){if(e){const{mf:s,rf:i,cf:r,of:o,svf:l,vf:a,minvf:c,maxvf:d}=this,{mode:u,ref:f,validator:m}=e,{type:p,operator:g,value:x}=m||{type:"list"};s.val(u||"cell"),i.val(f),r.val(p),o.val(g),Array.isArray(x)?(c.val(x[0]),d.val(x[1])):(l.val(x||""),a.val(x||"")),this.criteriaSelected(p),this.criteriaOperatorSelected(g)}this.show()}}function buildMenu$1(n){return h("div",`${cssPrefix}-item ${n}`)}function buildSortItem(n){return buildMenu$1("state").child(t(`sort.${n}`)).on("click.stop",()=>this.itemClick(n))}function buildFilterBody(n){const{filterbEl:e,filterValues:s}=this;e.html(""),Object.keys(n).forEach((r,o)=>{const l=n[r],a=s.includes(r)?"checked":"";e.child(h("div",`${cssPrefix}-item state ${a}`).on("click.stop",()=>this.filterClick(o,r)).children(r===""?t("filter.empty"):r,h("div","label").html(`(${l})`)))})}function resetFilterHeader(){const{filterhEl:n,filterValues:e,values:s}=this;n.html(`${e.length} / ${s.length}`),n.checked(e.length===s.length)}class SortFilter{constructor(){this.filterbEl=h("div",`${cssPrefix}-body`),this.filterhEl=h("div",`${cssPrefix}-header state`).on("click.stop",()=>this.filterClick(0,"all")),this.el=h("div",`${cssPrefix}-sort-filter`).children(this.sortAscEl=buildSortItem.call(this,"asc"),this.sortDescEl=buildSortItem.call(this,"desc"),buildMenu$1("divider"),h("div",`${cssPrefix}-filter`).children(this.filterhEl,this.filterbEl),h("div",`${cssPrefix}-buttons`).children(new Button("cancel").on("click",()=>this.btnClick("cancel")),new Button("ok","primary").on("click",()=>this.btnClick("ok")))).hide(),this.ci=null,this.sortDesc=null,this.values=null,this.filterValues=[]}btnClick(e){if(e==="ok"){const{ci:s,sort:i,filterValues:r}=this;this.ok&&this.ok(s,i,"in",r)}this.hide()}itemClick(e){this.sort=e;const{sortAscEl:s,sortDescEl:i}=this;s.checked(e==="asc"),i.checked(e==="desc")}filterClick(e,s){const{filterbEl:i,filterValues:r,values:o}=this,l=i.children();s==="all"?l.length===r.length?(this.filterValues=[],l.forEach(a=>h(a).checked(!1))):(this.filterValues=Array.from(o),l.forEach(a=>h(a).checked(!0))):h(l[e]).toggle("checked")?r.push(s):r.splice(r.findIndex(c=>c===s),1),resetFilterHeader.call(this)}set(e,s,i,r){this.ci=e;const{sortAscEl:o,sortDescEl:l}=this;r!==null?(this.sort=r.order,o.checked(r.asc()),l.checked(r.desc())):(this.sortDesc=null,o.checked(!1),l.checked(!1)),this.values=Object.keys(s),this.filterValues=i?Array.from(i.value):Object.keys(s),buildFilterBody.call(this,s,i),resetFilterHeader.call(this)}setOffset(e){this.el.offset(e).show();let s=1;bindClickoutside(this.el,()=>{s<=0&&this.hide(),s-=1})}show(){this.el.show()}hide(){this.el.hide(),unbindClickoutside(this.el)}}function xtoast(n,e){const s=h("div",`${cssPrefix}-toast`),i=h("div",`${cssPrefix}-dimmer active`),r=()=>{document.body.removeChild(s.el),document.body.removeChild(i.el)};s.children(h("div",`${cssPrefix}-toast-header`).children(new Icon("close").on("click.stop",()=>r()),n),h("div",`${cssPrefix}-toast-content`).html(e)),document.body.appendChild(s.el),document.body.appendChild(i.el);const{width:o,height:l}=s.box(),{clientHeight:a,clientWidth:c}=document.documentElement;s.offset({left:(c-o)/2,top:(a-l)/3})}function throttle$2(n,e){let s;return(...i)=>{const r=this,o=i;s||(s=setTimeout(()=>{s=null,n.apply(r,o)},e))}}function scrollbarMove(){const{data:n,verticalScrollbar:e,horizontalScrollbar:s}=this,{l:i,t:r,left:o,top:l,width:a,height:c}=n.getSelectedRect(),d=this.getTableOffset();if(Math.abs(o)+a>d.width)s.move({left:i+a-d.width});else{const u=n.freezeTotalWidth();o<u&&s.move({left:i-1-u})}if(Math.abs(l)+c>d.height)e.move({top:r+c-d.height-1});else{const u=n.freezeTotalHeight();l<u&&e.move({top:r-1-u})}}function selectorSet(n,e,s,i=!0,r=!1){if(e===-1&&s===-1)return;const{table:o,selector:l,toolbar:a,data:c,contextMenu:d}=this,u=c.getCell(e,s);n?(l.setEnd(e,s,r),this.trigger("cells-selected",u,l.range)):(l.set(e,s,i),this.trigger("cell-selected",u,e,s)),d.setMode(e===-1||s===-1?"row-col":"range"),a.reset(),o.render()}function selectorMove(n,e){const{selector:s,data:i}=this,{rows:r,cols:o}=i;let[l,a]=s.indexes;const{eri:c,eci:d}=s.range;n&&([l,a]=s.moveIndexes),e==="left"?a>0&&(a-=1):e==="right"?(d!==a&&(a=d),a<o.len-1&&(a+=1)):e==="up"?l>0&&(l-=1):e==="down"?(c!==l&&(l=c),l<r.len-1&&(l+=1)):e==="row-first"?a=0:e==="row-last"?a=o.len-1:e==="col-first"?l=0:e==="col-last"&&(l=r.len-1),n&&(s.moveIndexes=[l,a]),selectorSet.call(this,n,l,a),scrollbarMove.call(this)}function overlayerMousemove(n){if(n.buttons!==0||n.target.className===`${cssPrefix}-resizer-hover`)return;const{offsetX:e,offsetY:s}=n,{rowResizer:i,colResizer:r,tableEl:o,data:l}=this,{rows:a,cols:c}=l;if(e>c.indexWidth&&s>a.height){i.hide(),r.hide();return}const d=o.box(),u=l.getCellRectByXY(n.offsetX,n.offsetY);u.ri>=0&&u.ci===-1?(u.width=c.indexWidth,i.show(u,{width:d.width}),a.isHide(u.ri-1)?i.showUnhide(u.ri):i.hideUnhide()):i.hide(),u.ri===-1&&u.ci>=0?(u.height=a.height,r.show(u,{height:d.height}),c.isHide(u.ci-1)?r.showUnhide(u.ci):r.hideUnhide()):r.hide()}function overlayerMousescroll(n){const{verticalScrollbar:e,horizontalScrollbar:s,data:i}=this,{top:r}=e.scroll(),{left:o}=s.scroll(),{rows:l,cols:a}=i,{deltaY:c,deltaX:d}=n,u=(E,v)=>{let y=E,w=0;do w=v(y),y+=1;while(w<=0);return w},f=E=>{if(E>0){const v=i.scroll.ri+1;if(v<l.len){const y=u(v,w=>l.getHeight(w));e.move({top:r+y-1})}}else{const v=i.scroll.ri-1;if(v>=0){const y=u(v,w=>l.getHeight(w));e.move({top:v===0?0:r-y})}}},m=E=>{if(E>0){const v=i.scroll.ci+1;if(v<a.len){const y=u(v,w=>a.getWidth(w));s.move({left:o+y-1})}}else{const v=i.scroll.ci-1;if(v>=0){const y=u(v,w=>a.getWidth(w));s.move({left:v===0?0:o-y})}}},p=Math.abs(c),g=Math.abs(d),x=Math.max(p,g);/Firefox/i.test(window.navigator.userAgent)&&throttle$2(f(n.detail),50),x===g&&throttle$2(m(d),50),x===p&&throttle$2(f(c),50)}function overlayerTouch(n,e){const{verticalScrollbar:s,horizontalScrollbar:i}=this,{top:r}=s.scroll(),{left:o}=i.scroll();n==="left"||n==="right"?i.move({left:o-e}):(n==="up"||n==="down")&&s.move({top:r-e})}function verticalScrollbarSet(){const{data:n,verticalScrollbar:e}=this,{height:s}=this.getTableOffset(),i=n.exceptRowTotalHeight(0,-1);e.set(s,n.rows.totalHeight()-i)}function horizontalScrollbarSet(){const{data:n,horizontalScrollbar:e}=this,{width:s}=this.getTableOffset();n&&e.set(s,n.cols.totalWidth())}function sheetFreeze(){const{selector:n,data:e,editor:s}=this,[i,r]=e.freeze;if(i>0||r>0){const o=e.freezeTotalWidth(),l=e.freezeTotalHeight();s.setFreezeLengths(o,l)}n.resetAreaOffset()}function sheetReset(){const{tableEl:n,overlayerEl:e,overlayerCEl:s,table:i,toolbar:r,selector:o,el:l}=this,a=this.getTableOffset(),c=this.getRect();n.attr(c),e.offset(c),s.offset(a),l.css("width",`${c.width}px`),verticalScrollbarSet.call(this),horizontalScrollbarSet.call(this),sheetFreeze.call(this),i.render(),r.reset(),o.reset()}function clearClipboard(){const{data:n,selector:e}=this;n.clearClipboard(),e.hideClipboard()}function copy$2(n){const{data:e,selector:s}=this;e.settings.mode!=="read"&&(e.copy(),e.copyToSystemClipboard(n),s.showClipboard())}function cut(){const{data:n,selector:e}=this;n.settings.mode!=="read"&&(n.cut(),e.showClipboard())}function paste(n,e){const{data:s}=this;if(s.settings.mode!=="read"){if(s.clipboard.isClear()){const i=()=>sheetReset.call(this),r=o=>{this.trigger("pasted-clipboard",o)};s.pasteFromSystemClipboard(i,r)}else if(s.paste(n,i=>xtoast("Tip",i)))sheetReset.call(this);else if(e){const i=e.clipboardData.getData("text/plain");this.data.pasteFromText(i),sheetReset.call(this)}}}function hideRowsOrCols(){this.data.hideRowsOrCols(),sheetReset.call(this)}function unhideRowsOrCols(n,e){this.data.unhideRowsOrCols(n,e),sheetReset.call(this)}function autofilter(){const{data:n}=this;n.autofilter(),sheetReset.call(this)}function toolbarChangePaintformatPaste(){const{toolbar:n}=this;n.paintformatActive()&&(paste.call(this,"format"),clearClipboard.call(this),n.paintformatToggle())}function overlayerMousedown(n){const{selector:e,data:s,table:i,sortFilter:r}=this,{offsetX:o,offsetY:l}=n,a=n.target.className===`${cssPrefix}-selector-corner`,c=s.getCellRectByXY(o,l),{left:d,top:u,width:f,height:m}=c;let{ri:p,ci:g}=c;const{autoFilter:x}=s;if(x.includes(p,g)&&d+f-20<o&&u+m-20<l){const E=x.items(g,(v,y)=>s.rows.getCell(v,y));r.hide(),r.set(g,E,x.getFilter(g),x.getSort(g)),r.setOffset({left:d,top:u+m+2});return}n.shiftKey||(a?e.showAutofill(p,g):selectorSet.call(this,!1,p,g),mouseMoveUp(window,E=>{({ri:p,ci:g}=s.getCellRectByXY(E.offsetX,E.offsetY)),a?e.showAutofill(p,g):E.buttons===1&&!E.shiftKey&&selectorSet.call(this,!0,p,g,!0,!0)},()=>{a&&e.arange&&s.settings.mode!=="read"&&s.autofill(e.arange,"all",E=>xtoast("Tip",E))&&i.render(),e.hideAutofill(),toolbarChangePaintformatPaste.call(this)})),!a&&n.buttons===1&&n.shiftKey&&selectorSet.call(this,!0,p,g)}function editorSetOffset(){const{editor:n,data:e}=this,s=e.getSelectedRect(),i=this.getTableOffset();let r="top";s.top>i.height/2&&(r="bottom"),n.setOffset(s,r)}function editorSet(){const{editor:n,data:e}=this;e.settings.mode!=="read"&&(editorSetOffset.call(this),n.setCell(e.getSelectedCell(),e.getSelectedValidator()),clearClipboard.call(this))}function verticalScrollbarMove(n){const{data:e,table:s,selector:i}=this;e.scrolly(n,()=>{i.resetBRLAreaOffset(),editorSetOffset.call(this),s.render()})}function horizontalScrollbarMove(n){const{data:e,table:s,selector:i}=this;e.scrollx(n,()=>{i.resetBRTAreaOffset(),editorSetOffset.call(this),s.render()})}function rowResizerFinished(n,e){const{ri:s}=n,{table:i,selector:r,data:o}=this,{sri:l,eri:a}=r.range;if(s>=l&&s<=a)for(let c=l;c<=a;c+=1)o.rows.setHeight(c,e);else o.rows.setHeight(s,e);i.render(),r.resetAreaOffset(),verticalScrollbarSet.call(this),editorSetOffset.call(this)}function colResizerFinished(n,e){const{ci:s}=n,{table:i,selector:r,data:o}=this,{sci:l,eci:a}=r.range;if(s>=l&&s<=a)for(let c=l;c<=a;c+=1)o.cols.setWidth(c,e);else o.cols.setWidth(s,e);i.render(),r.resetAreaOffset(),horizontalScrollbarSet.call(this),editorSetOffset.call(this)}function dataSetCellText(n,e="finished"){const{data:s,table:i}=this;if(s.settings.mode==="read")return;s.setSelectedCellText(n,e);const{ri:r,ci:o}=s.selector;e==="finished"?i.render():this.trigger("cell-edited",n,r,o)}function insertDeleteRowColumn(n){const{data:e}=this;e.settings.mode!=="read"&&(n==="insert-row"?e.insert("row"):n==="delete-row"?e.delete("row"):n==="insert-column"?e.insert("column"):n==="delete-column"?e.delete("column"):n==="delete-cell"?e.deleteCell():n==="delete-cell-format"?e.deleteCell("format"):n==="delete-cell-text"?e.deleteCell("text"):n==="cell-printable"?e.setSelectedCellAttr("printable",!0):n==="cell-non-printable"?e.setSelectedCellAttr("printable",!1):n==="cell-editable"?e.setSelectedCellAttr("editable",!0):n==="cell-non-editable"&&e.setSelectedCellAttr("editable",!1),clearClipboard.call(this),sheetReset.call(this))}function toolbarChange(n,e){const{data:s}=this;if(n==="undo")this.undo();else if(n==="redo")this.redo();else if(n==="print")this.print.preview();else if(n==="paintformat")e===!0?copy$2.call(this):clearClipboard.call(this);else if(n==="clearformat")insertDeleteRowColumn.call(this,"delete-cell-format");else if(n!=="link"){if(n!=="chart")if(n==="autofilter")autofilter.call(this);else if(n==="freeze")if(e){const{ri:i,ci:r}=s.selector;this.freeze(i,r)}else this.freeze(0,0);else s.setSelectedCellAttr(n,e),n==="formula"&&!s.selector.multiple()&&editorSet.call(this),sheetReset.call(this)}}function sortFilterChange(n,e,s,i){this.data.setAutoFilter(n,e,s,i),sheetReset.call(this)}function sheetInitEvents(){const{selector:n,overlayerEl:e,rowResizer:s,colResizer:i,verticalScrollbar:r,horizontalScrollbar:o,editor:l,contextMenu:a,toolbar:c,modalValidation:d,sortFilter:u}=this;e.on("mousemove",f=>{overlayerMousemove.call(this,f)}).on("mousedown",f=>{l.clear(),a.hide(),f.buttons===2?(this.data.xyInSelectedRect(f.offsetX,f.offsetY)||overlayerMousedown.call(this,f),a.setPosition(f.offsetX,f.offsetY),f.stopPropagation()):f.detail===2?editorSet.call(this):overlayerMousedown.call(this,f)}).on("mousewheel.stop",f=>{overlayerMousescroll.call(this,f)}).on("mouseout",f=>{const{offsetX:m,offsetY:p}=f;p<=0&&i.hide(),m<=0&&s.hide()}),n.inputChange=f=>{dataSetCellText.call(this,f,"input"),editorSet.call(this)},bindTouch(e.el,{move:(f,m)=>{overlayerTouch.call(this,f,m)}}),c.change=(f,m)=>toolbarChange.call(this,f,m),u.ok=(f,m,p,g)=>sortFilterChange.call(this,f,m,p,g),s.finishedFn=(f,m)=>{rowResizerFinished.call(this,f,m)},i.finishedFn=(f,m)=>{colResizerFinished.call(this,f,m)},s.unhideFn=f=>{unhideRowsOrCols.call(this,"row",f)},i.unhideFn=f=>{unhideRowsOrCols.call(this,"col",f)},r.moveFn=(f,m)=>{verticalScrollbarMove.call(this,f,m)},o.moveFn=(f,m)=>{horizontalScrollbarMove.call(this,f,m)},l.change=(f,m)=>{dataSetCellText.call(this,m,f)},d.change=(f,...m)=>{f==="save"?this.data.addValidation(...m):this.data.removeValidation()},a.itemClick=f=>{f==="validation"?d.setValue(this.data.getSelectedValidation()):f==="copy"?copy$2.call(this):f==="cut"?cut.call(this):f==="paste"?paste.call(this,"all"):f==="paste-value"?paste.call(this,"text"):f==="paste-format"?paste.call(this,"format"):f==="hide"?hideRowsOrCols.call(this):insertDeleteRowColumn.call(this,f)},bind(window,"resize",()=>{this.reload()}),bind(window,"click",f=>{this.focusing=e.contains(f.target)}),bind(window,"paste",f=>{this.focusing&&(paste.call(this,"all",f),f.preventDefault())}),bind(window,"copy",f=>{this.focusing&&(copy$2.call(this,f),f.preventDefault())}),bind(window,"keydown",f=>{if(!this.focusing)return;const m=f.keyCode||f.which,{key:p,ctrlKey:g,shiftKey:x,metaKey:E}=f;if(g||E)switch(m){case 90:this.undo(),f.preventDefault();break;case 89:this.redo(),f.preventDefault();break;case 67:break;case 88:cut.call(this),f.preventDefault();break;case 85:c.trigger("underline"),f.preventDefault();break;case 86:break;case 37:selectorMove.call(this,x,"row-first"),f.preventDefault();break;case 38:selectorMove.call(this,x,"col-first"),f.preventDefault();break;case 39:selectorMove.call(this,x,"row-last"),f.preventDefault();break;case 40:selectorMove.call(this,x,"col-last"),f.preventDefault();break;case 32:selectorSet.call(this,!1,-1,this.data.selector.ci,!1),f.preventDefault();break;case 66:c.trigger("bold");break;case 73:c.trigger("italic");break}else{switch(m){case 32:x&&selectorSet.call(this,!1,this.data.selector.ri,-1,!1);break;case 27:a.hide(),clearClipboard.call(this);break;case 37:selectorMove.call(this,x,"left"),f.preventDefault();break;case 38:selectorMove.call(this,x,"up"),f.preventDefault();break;case 39:selectorMove.call(this,x,"right"),f.preventDefault();break;case 40:selectorMove.call(this,x,"down"),f.preventDefault();break;case 9:l.clear(),selectorMove.call(this,!1,x?"left":"right"),f.preventDefault();break;case 13:l.clear(),selectorMove.call(this,!1,x?"up":"down"),f.preventDefault();break;case 8:insertDeleteRowColumn.call(this,"delete-cell-text"),f.preventDefault();break}p==="Delete"?(insertDeleteRowColumn.call(this,"delete-cell-text"),f.preventDefault()):m>=65&&m<=90||m>=48&&m<=57||m>=96&&m<=105||f.key==="="?(dataSetCellText.call(this,f.key,"input"),editorSet.call(this)):m===113&&editorSet.call(this)}})}class Sheet{constructor(e,s){this.eventMap=createEventEmitter();const{view:i,showToolbar:r,showContextmenu:o}=s.settings;this.el=h("div",`${cssPrefix}-sheet`),this.toolbar=new Toolbar(s,i.width,!r),this.print=new Print$1(s),e.children(this.toolbar.el,this.el,this.print.el),this.data=s,this.tableEl=h("canvas",`${cssPrefix}-table`),this.rowResizer=new Resizer(!1,s.rows.height),this.colResizer=new Resizer(!0,s.cols.minWidth),this.verticalScrollbar=new Scrollbar(!0),this.horizontalScrollbar=new Scrollbar(!1),this.editor=new Editor(formulas,()=>this.getTableOffset(),s.rows.height),this.modalValidation=new ModalValidation,this.contextMenu=new ContextMenu$1(()=>this.getRect(),!o),this.selector=new Selector(s),this.overlayerCEl=h("div",`${cssPrefix}-overlayer-content`).children(this.editor.el,this.selector.el),this.overlayerEl=h("div",`${cssPrefix}-overlayer`).child(this.overlayerCEl),this.sortFilter=new SortFilter,this.el.children(this.tableEl,this.overlayerEl.el,this.rowResizer.el,this.colResizer.el,this.verticalScrollbar.el,this.horizontalScrollbar.el,this.contextMenu.el,this.modalValidation.el,this.sortFilter.el),this.table=new table_rslib_entry_(this.tableEl.el,s),sheetInitEvents.call(this),sheetReset.call(this),selectorSet.call(this,!1,0,0)}on(e,s){return this.eventMap.on(e,s),this}trigger(e,...s){const{eventMap:i}=this;i.fire(e,s)}resetData(e){this.editor.clear(),this.data=e,verticalScrollbarSet.call(this),horizontalScrollbarSet.call(this),this.toolbar.resetData(e),this.print.resetData(e),this.selector.resetData(e),this.table.resetData(e)}loadData(e){return this.data.setData(e),sheetReset.call(this),this}freeze(e,s){const{data:i}=this;return i.setFreeze(e,s),sheetReset.call(this),this}undo(){this.data.undo(),sheetReset.call(this)}redo(){this.data.redo(),sheetReset.call(this)}reload(){return sheetReset.call(this),this}getRect(){const{data:e}=this;return{width:e.viewWidth(),height:e.viewHeight()}}getTableOffset(){const{rows:e,cols:s}=this.data,{width:i,height:r}=this.getRect();return{width:i-s.indexWidth,height:r-e.height,left:s.indexWidth,top:e.height}}}class DropdownMore extends Dropdown{constructor(e){const s=new Icon("ellipsis");super(s,"auto",!1,"top-left"),this.contentClick=e}reset(e){const s=e.map((i,r)=>h("div",`${cssPrefix}-item`).css("width","150px").css("font-weight","normal").on("click",()=>{this.contentClick(r),this.hide()}).child(i));this.setContentChildren(...s)}setTitle(){}}const menuItems=[{key:"delete",title:tf("contextmenu.deleteSheet")}];function buildMenuItem(n){return h("div",`${cssPrefix}-item`).child(n.title()).on("click",()=>{this.itemClick(n.key),this.hide()})}function buildMenu(){return menuItems.map(n=>buildMenuItem.call(this,n))}class ContextMenu{constructor(){this.el=h("div",`${cssPrefix}-contextmenu`).css("width","160px").children(...buildMenu.call(this)).hide(),this.itemClick=()=>{}}hide(){const{el:e}=this;e.hide(),unbindClickoutside(e)}setOffset(e){const{el:s}=this;s.offset(e),s.show(),bindClickoutside(s)}}class Bottombar{constructor(e=()=>{},s=()=>{},i=()=>{},r=()=>{}){this.swapFunc=s,this.updateFunc=r,this.dataNames=[],this.activeEl=null,this.deleteEl=null,this.items=[],this.moreEl=new DropdownMore(o=>{this.clickSwap2(this.items[o])}),this.contextMenu=new ContextMenu,this.contextMenu.itemClick=i,this.el=h("div",`${cssPrefix}-bottombar`).children(this.contextMenu.el,this.menuEl=h("ul",`${cssPrefix}-menu`).child(h("li","").children(new Icon("add").on("click",()=>{e()}),h("span","").child(this.moreEl))))}addItem(e,s,i){this.dataNames.push(e);const r=h("li",s?"active":"").child(e);r.on("click",()=>{this.clickSwap2(r)}).on("contextmenu",o=>{if(i.mode==="read")return;const{offsetLeft:l,offsetHeight:a}=o.target;this.contextMenu.setOffset({left:l,bottom:a+1}),this.deleteEl=r}).on("dblclick",()=>{if(i.mode==="read")return;const o=r.html(),l=new FormInput("auto","");l.val(o),l.input.on("blur",({target:a})=>{const{value:c}=a,d=this.dataNames.findIndex(u=>u===o);this.renameItem(d,c)}),r.html("").child(l.el),l.focus()}),s&&this.clickSwap(r),this.items.push(r),this.menuEl.child(r),this.moreEl.reset(this.dataNames)}renameItem(e,s){this.dataNames.splice(e,1,s),this.moreEl.reset(this.dataNames),this.items[e].html("").child(s),this.updateFunc(e,s)}clear(){this.items.forEach(e=>{this.menuEl.removeChild(e.el)}),this.items=[],this.dataNames=[],this.moreEl.reset(this.dataNames)}deleteItem(){const{activeEl:e,deleteEl:s}=this;if(this.items.length>1){const i=this.items.findIndex(r=>r===s);if(this.items.splice(i,1),this.dataNames.splice(i,1),this.menuEl.removeChild(s.el),this.moreEl.reset(this.dataNames),e===s){const[r]=this.items;return this.activeEl=r,this.activeEl.toggle(),[i,0]}return[i,-1]}return[-1]}clickSwap2(e){const s=this.items.findIndex(i=>i===e);this.clickSwap(e),this.activeEl.toggle(),this.swapFunc(s)}clickSwap(e){this.activeEl!==null&&this.activeEl.toggle(),this.activeEl=e}}const $=class ${constructor(e,s={}){U(this,C);U(this,k,1);U(this,P);U(this,j);U(this,L);U(this,O);N(this,C,A({showBottomBar:!0},s)),N(this,P,[]),N(this,O,T(this,C).showBottomBar?new Bottombar(()=>{if(T(this,C).mode==="read")return;const r=this.addSheet();T(this,L).resetData(r)},r=>{const o=T(this,P)[r];T(this,L).resetData(o)},()=>{this.deleteSheet()},(r,o)=>{T(this,P)[r].name=o,T(this,L).trigger("change")}):null),N(this,j,this.addSheet());const i=h("div",`${cssPrefix}`).on("contextmenu",r=>r.preventDefault());e.appendChild(i.el),N(this,L,new Sheet(i,T(this,j))),T(this,O)!==null&&i.child(T(this,O).el)}static makeSheet(e,s={}){if($.targets.has(e)){const r=$.targets.get(e);if(r)return r}const i=new $(e,s);$.targets.set(e,i)}on(e,s){return T(this,L).on(e,s),this}reRender(){return T(this,L).table.render(),this}cell(e,s,i=0){return T(this,P)[i].getCell(e,s)}cellStyle(e,s,i=0){return T(this,P)[i].getCellStyle(e,s)}cellText(e,s,i,r=0){return T(this,P)[r].setCellText(e,s,i,"finished"),this}deleteSheet(){if(T(this,O)===null)return;const[e,s]=T(this,O).deleteItem();e>=0&&(T(this,P).splice(e,1),s>=0&&T(this,L).resetData(T(this,P)[s]),T(this,L).trigger("change"))}loadData(e){const s=Array.isArray(e)?e:[e];if(T(this,O)!==null&&T(this,O).clear(),N(this,P,[]),s.length>0)for(let i=0;i<s.length;i+=1){const r=s[i],o=this.addSheet(r.name,i===0);o.setData(r),i===0&&T(this,L).resetData(o)}return this}getData(){return T(this,P).map(e=>e.getData())}validate(){const{validations:e}=T(this,j);return e.errors.size<=0}change(e){return T(this,L).on("change",e),this}static locale(e,s){locale(e,s)}addSheet(e,s=!0){const i=e||`sheet${T(this,k)}`,r=new DataProxy(i,T(this,C));return r.change=(...o)=>{T(this,L).trigger("change",...o)},T(this,P).push(r),T(this,O)!==null&&T(this,O).addItem(i,s,T(this,C)),N(this,k,T(this,k)+1),r}};C=new WeakMap,k=new WeakMap,P=new WeakMap,j=new WeakMap,L=new WeakMap,O=new WeakMap,b($,"targets",new WeakMap);let Spreadsheet=$;var __webpack_exports__Spreadsheet=Spreadsheet;const ExcelSheet=React.forwardRef(({data:n,className:e},s)=>{const i=React.useRef(null),r=React.useRef(null),o=()=>{if(!i.current)throw new Error("Workbook is not initialized");return i.current.getData()};return React.useImperativeHandle(s,()=>({getData:o})),React.useEffect(()=>{if(r.current){const l=__webpack_exports__Spreadsheet.makeSheet(r.current,{view:{height:()=>{var a;return(a=r.current)==null?void 0:a.offsetHeight},width:()=>{var a;return(a=r.current)==null?void 0:a.offsetWidth}}});l.loadData(n),i.current=l}},[n]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{ref:r,id:"sheet988",className:client.cx(client.css`
17
17
  width: 100%;
18
18
  height: 100%;
19
19
  `,e)})});ExcelSheet.displayName="ExcelSheet";/*!
20
20
  * Signature Pad v4.2.0 | https://github.com/szimek/signature_pad
21
21
  * (c) 2024 Szymon Nowak | Released under the MIT license
22
- */class Point{constructor(e,s,n,r){if(isNaN(e)||isNaN(s))throw new Error(`Point is invalid: (${e}, ${s})`);this.x=+e,this.y=+s,this.pressure=n||0,this.time=r||Date.now()}distanceTo(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))}equals(e){return this.x===e.x&&this.y===e.y&&this.pressure===e.pressure&&this.time===e.time}velocityFrom(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):0}}class Bezier{static fromPoints(e,s){const n=this.calculateControlPoints(e[0],e[1],e[2]).c2,r=this.calculateControlPoints(e[1],e[2],e[3]).c1;return new Bezier(e[1],n,r,e[2],s.start,s.end)}static calculateControlPoints(e,s,n){const r=e.x-s.x,o=e.y-s.y,a=s.x-n.x,l=s.y-n.y,c={x:(e.x+s.x)/2,y:(e.y+s.y)/2},d={x:(s.x+n.x)/2,y:(s.y+n.y)/2},u=Math.sqrt(r*r+o*o),p=Math.sqrt(a*a+l*l),m=c.x-d.x,f=c.y-d.y,g=p/(u+p),x={x:d.x+m*g,y:d.y+f*g},y=s.x-x.x,E=s.y-x.y;return{c1:new Point(c.x+y,c.y+E),c2:new Point(d.x+y,d.y+E)}}constructor(e,s,n,r,o,a){this.startPoint=e,this.control2=s,this.control1=n,this.endPoint=r,this.startWidth=o,this.endWidth=a}length(){let s=0,n,r;for(let o=0;o<=10;o+=1){const a=o/10,l=this.point(a,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),c=this.point(a,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(o>0){const d=l-n,u=c-r;s+=Math.sqrt(d*d+u*u)}n=l,r=c}return s}point(e,s,n,r,o){return s*(1-e)*(1-e)*(1-e)+3*n*(1-e)*(1-e)*e+3*r*(1-e)*e*e+o*e*e*e}}class SignatureEventTarget{constructor(){try{this._et=new EventTarget}catch(e){this._et=document}}addEventListener(e,s,n){this._et.addEventListener(e,s,n)}dispatchEvent(e){return this._et.dispatchEvent(e)}removeEventListener(e,s,n){this._et.removeEventListener(e,s,n)}}function throttle$1(i,e=250){let s=0,n=null,r,o,a;const l=()=>{s=Date.now(),n=null,r=i.apply(o,a),n||(o=null,a=[])};return function(...d){const u=Date.now(),p=e-(u-s);return o=this,a=d,p<=0||p>e?(n&&(clearTimeout(n),n=null),s=u,r=i.apply(o,a),n||(o=null,a=[])):n||(n=window.setTimeout(l,p)),r}}let SignaturePad$1=class G extends SignatureEventTarget{constructor(e,s={}){super(),this.canvas=e,this._drawingStroke=!1,this._isEmpty=!0,this._lastPoints=[],this._data=[],this._lastVelocity=0,this._lastWidth=0,this._handleMouseDown=n=>{n.buttons===1&&this._strokeBegin(n)},this._handleMouseMove=n=>{this._strokeMoveUpdate(n)},this._handleMouseUp=n=>{n.buttons===1&&this._strokeEnd(n)},this._handleTouchStart=n=>{if(n.cancelable&&n.preventDefault(),n.targetTouches.length===1){const r=n.changedTouches[0];this._strokeBegin(r)}},this._handleTouchMove=n=>{n.cancelable&&n.preventDefault();const r=n.targetTouches[0];this._strokeMoveUpdate(r)},this._handleTouchEnd=n=>{if(n.target===this.canvas){n.cancelable&&n.preventDefault();const o=n.changedTouches[0];this._strokeEnd(o)}},this._handlePointerStart=n=>{n.preventDefault(),this._strokeBegin(n)},this._handlePointerMove=n=>{this._strokeMoveUpdate(n)},this._handlePointerEnd=n=>{this._drawingStroke&&(n.preventDefault(),this._strokeEnd(n))},this.velocityFilterWeight=s.velocityFilterWeight||.7,this.minWidth=s.minWidth||.5,this.maxWidth=s.maxWidth||2.5,this.throttle="throttle"in s?s.throttle:16,this.minDistance="minDistance"in s?s.minDistance:5,this.dotSize=s.dotSize||0,this.penColor=s.penColor||"black",this.backgroundColor=s.backgroundColor||"rgba(0,0,0,0)",this.compositeOperation=s.compositeOperation||"source-over",this.canvasContextOptions="canvasContextOptions"in s?s.canvasContextOptions:{},this._strokeMoveUpdate=this.throttle?throttle$1(G.prototype._strokeUpdate,this.throttle):G.prototype._strokeUpdate,this._ctx=e.getContext("2d",this.canvasContextOptions),this.clear(),this.on()}clear(){const{_ctx:e,canvas:s}=this;e.fillStyle=this.backgroundColor,e.clearRect(0,0,s.width,s.height),e.fillRect(0,0,s.width,s.height),this._data=[],this._reset(this._getPointGroupOptions()),this._isEmpty=!0}fromDataURL(e,s={}){return new Promise((n,r)=>{const o=new Image,a=s.ratio||window.devicePixelRatio||1,l=s.width||this.canvas.width/a,c=s.height||this.canvas.height/a,d=s.xOffset||0,u=s.yOffset||0;this._reset(this._getPointGroupOptions()),o.onload=()=>{this._ctx.drawImage(o,d,u,l,c),n()},o.onerror=p=>{r(p)},o.crossOrigin="anonymous",o.src=e,this._isEmpty=!1})}toDataURL(e="image/png",s){switch(e){case"image/svg+xml":return typeof s!="object"&&(s=void 0),`data:image/svg+xml;base64,${btoa(this.toSVG(s))}`;default:return typeof s!="number"&&(s=void 0),this.canvas.toDataURL(e,s)}}on(){this.canvas.style.touchAction="none",this.canvas.style.msTouchAction="none",this.canvas.style.userSelect="none";const e=/Macintosh/.test(navigator.userAgent)&&"ontouchstart"in document;window.PointerEvent&&!e?this._handlePointerEvents():(this._handleMouseEvents(),"ontouchstart"in window&&this._handleTouchEvents())}off(){this.canvas.style.touchAction="auto",this.canvas.style.msTouchAction="auto",this.canvas.style.userSelect="auto",this.canvas.removeEventListener("pointerdown",this._handlePointerStart),this.canvas.removeEventListener("pointermove",this._handlePointerMove),this.canvas.ownerDocument.removeEventListener("pointerup",this._handlePointerEnd),this.canvas.removeEventListener("mousedown",this._handleMouseDown),this.canvas.removeEventListener("mousemove",this._handleMouseMove),this.canvas.ownerDocument.removeEventListener("mouseup",this._handleMouseUp),this.canvas.removeEventListener("touchstart",this._handleTouchStart),this.canvas.removeEventListener("touchmove",this._handleTouchMove),this.canvas.removeEventListener("touchend",this._handleTouchEnd)}isEmpty(){return this._isEmpty}fromData(e,{clear:s=!0}={}){s&&this.clear(),this._fromData(e,this._drawCurve.bind(this),this._drawDot.bind(this)),this._data=this._data.concat(e)}toData(){return this._data}_getPointGroupOptions(e){return{penColor:e&&"penColor"in e?e.penColor:this.penColor,dotSize:e&&"dotSize"in e?e.dotSize:this.dotSize,minWidth:e&&"minWidth"in e?e.minWidth:this.minWidth,maxWidth:e&&"maxWidth"in e?e.maxWidth:this.maxWidth,velocityFilterWeight:e&&"velocityFilterWeight"in e?e.velocityFilterWeight:this.velocityFilterWeight,compositeOperation:e&&"compositeOperation"in e?e.compositeOperation:this.compositeOperation}}_strokeBegin(e){if(!this.dispatchEvent(new CustomEvent("beginStroke",{detail:e,cancelable:!0})))return;this._drawingStroke=!0;const n=this._getPointGroupOptions(),r=Object.assign(Object.assign({},n),{points:[]});this._data.push(r),this._reset(n),this._strokeUpdate(e)}_strokeUpdate(e){if(!this._drawingStroke)return;if(this._data.length===0){this._strokeBegin(e);return}this.dispatchEvent(new CustomEvent("beforeUpdateStroke",{detail:e}));const s=e.clientX,n=e.clientY,r=e.pressure!==void 0?e.pressure:e.force!==void 0?e.force:0,o=this._createPoint(s,n,r),a=this._data[this._data.length-1],l=a.points,c=l.length>0&&l[l.length-1],d=c?o.distanceTo(c)<=this.minDistance:!1,u=this._getPointGroupOptions(a);if(!c||!(c&&d)){const p=this._addPoint(o,u);c?p&&this._drawCurve(p,u):this._drawDot(o,u),l.push({time:o.time,x:o.x,y:o.y,pressure:o.pressure})}this.dispatchEvent(new CustomEvent("afterUpdateStroke",{detail:e}))}_strokeEnd(e){this._drawingStroke&&(this._strokeUpdate(e),this._drawingStroke=!1,this.dispatchEvent(new CustomEvent("endStroke",{detail:e})))}_handlePointerEvents(){this._drawingStroke=!1,this.canvas.addEventListener("pointerdown",this._handlePointerStart),this.canvas.addEventListener("pointermove",this._handlePointerMove),this.canvas.ownerDocument.addEventListener("pointerup",this._handlePointerEnd)}_handleMouseEvents(){this._drawingStroke=!1,this.canvas.addEventListener("mousedown",this._handleMouseDown),this.canvas.addEventListener("mousemove",this._handleMouseMove),this.canvas.ownerDocument.addEventListener("mouseup",this._handleMouseUp)}_handleTouchEvents(){this.canvas.addEventListener("touchstart",this._handleTouchStart),this.canvas.addEventListener("touchmove",this._handleTouchMove),this.canvas.addEventListener("touchend",this._handleTouchEnd)}_reset(e){this._lastPoints=[],this._lastVelocity=0,this._lastWidth=(e.minWidth+e.maxWidth)/2,this._ctx.fillStyle=e.penColor,this._ctx.globalCompositeOperation=e.compositeOperation}_createPoint(e,s,n){const r=this.canvas.getBoundingClientRect();return new Point(e-r.left,s-r.top,n,new Date().getTime())}_addPoint(e,s){const{_lastPoints:n}=this;if(n.push(e),n.length>2){n.length===3&&n.unshift(n[0]);const r=this._calculateCurveWidths(n[1],n[2],s),o=Bezier.fromPoints(n,r);return n.shift(),o}return null}_calculateCurveWidths(e,s,n){const r=n.velocityFilterWeight*s.velocityFrom(e)+(1-n.velocityFilterWeight)*this._lastVelocity,o=this._strokeWidth(r,n),a={end:o,start:this._lastWidth};return this._lastVelocity=r,this._lastWidth=o,a}_strokeWidth(e,s){return Math.max(s.maxWidth/(e+1),s.minWidth)}_drawCurveSegment(e,s,n){const r=this._ctx;r.moveTo(e,s),r.arc(e,s,n,0,2*Math.PI,!1),this._isEmpty=!1}_drawCurve(e,s){const n=this._ctx,r=e.endWidth-e.startWidth,o=Math.ceil(e.length())*2;n.beginPath(),n.fillStyle=s.penColor;for(let a=0;a<o;a+=1){const l=a/o,c=l*l,d=c*l,u=1-l,p=u*u,m=p*u;let f=m*e.startPoint.x;f+=3*p*l*e.control1.x,f+=3*u*c*e.control2.x,f+=d*e.endPoint.x;let g=m*e.startPoint.y;g+=3*p*l*e.control1.y,g+=3*u*c*e.control2.y,g+=d*e.endPoint.y;const x=Math.min(e.startWidth+d*r,s.maxWidth);this._drawCurveSegment(f,g,x)}n.closePath(),n.fill()}_drawDot(e,s){const n=this._ctx,r=s.dotSize>0?s.dotSize:(s.minWidth+s.maxWidth)/2;n.beginPath(),this._drawCurveSegment(e.x,e.y,r),n.closePath(),n.fillStyle=s.penColor,n.fill()}_fromData(e,s,n){for(const r of e){const{points:o}=r,a=this._getPointGroupOptions(r);if(o.length>1)for(let l=0;l<o.length;l+=1){const c=o[l],d=new Point(c.x,c.y,c.pressure,c.time);l===0&&this._reset(a);const u=this._addPoint(d,a);u&&s(u,a)}else this._reset(a),n(o[0],a)}}toSVG({includeBackgroundColor:e=!1}={}){const s=this._data,n=Math.max(window.devicePixelRatio||1,1),r=0,o=0,a=this.canvas.width/n,l=this.canvas.height/n,c=document.createElementNS("http://www.w3.org/2000/svg","svg");if(c.setAttribute("xmlns","http://www.w3.org/2000/svg"),c.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),c.setAttribute("viewBox",`${r} ${o} ${a} ${l}`),c.setAttribute("width",a.toString()),c.setAttribute("height",l.toString()),e&&this.backgroundColor){const d=document.createElement("rect");d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.setAttribute("fill",this.backgroundColor),c.appendChild(d)}return this._fromData(s,(d,{penColor:u})=>{const p=document.createElement("path");if(!isNaN(d.control1.x)&&!isNaN(d.control1.y)&&!isNaN(d.control2.x)&&!isNaN(d.control2.y)){const m=`M ${d.startPoint.x.toFixed(3)},${d.startPoint.y.toFixed(3)} C ${d.control1.x.toFixed(3)},${d.control1.y.toFixed(3)} ${d.control2.x.toFixed(3)},${d.control2.y.toFixed(3)} ${d.endPoint.x.toFixed(3)},${d.endPoint.y.toFixed(3)}`;p.setAttribute("d",m),p.setAttribute("stroke-width",(d.endWidth*2.25).toFixed(3)),p.setAttribute("stroke",u),p.setAttribute("fill","none"),p.setAttribute("stroke-linecap","round"),c.appendChild(p)}},(d,{penColor:u,dotSize:p,minWidth:m,maxWidth:f})=>{const g=document.createElement("circle"),x=p>0?p:(m+f)/2;g.setAttribute("r",x.toString()),g.setAttribute("cx",d.x.toString()),g.setAttribute("cy",d.y.toString()),g.setAttribute("fill",u),c.appendChild(g)}),c.outerHTML}};function throttle(i,e,s){var n=s||{},r=n.noTrailing,o=r===void 0?!1:r,a=n.noLeading,l=a===void 0?!1:a,c=n.debounceMode,d=c===void 0?void 0:c,u,p=!1,m=0;function f(){u&&clearTimeout(u)}function g(y){var E=y||{},b=E.upcomingOnly,v=b===void 0?!1:b;f(),p=!v}function x(){for(var y=arguments.length,E=new Array(y),b=0;b<y;b++)E[b]=arguments[b];var v=this,A=Date.now()-m;if(p)return;function D(){m=Date.now(),e.apply(v,E)}function L(){u=void 0}!l&&d&&!u&&D(),f(),d===void 0&&A>i?l?(m=Date.now(),o||(u=setTimeout(d?L:D,i))):D():o!==!0&&(u=setTimeout(d?L:D,d===void 0?i-A:i))}return x.cancel=g,x}function debounce(i,e,s){var n={},r=n.atBegin,o=r===void 0?!1:r;return throttle(i,e,{debounceMode:o!==!1})}class SignaturePad extends React__namespace.PureComponent{constructor(s){super(s);C(this,"canvasRef",React__namespace.createRef());C(this,"signaturePad");C(this,"callResizeHandler");this.state={canvasWidth:0,canvasHeight:0},this.callResizeHandler=debounce(this.props.debounceInterval,this.handleResize.bind(this))}componentDidMount(){const s=this.canvasRef.current;s&&((!this.props.width||!this.props.height)&&(s.style.width="100%",window.addEventListener("resize",this.callResizeHandler)),this.signaturePad=new SignaturePad$1(s,this.props.options),this.scaleCanvas(s))}componentWillUnmount(){(!this.props.width||!this.props.height)&&window.removeEventListener("resize",this.callResizeHandler),this.signaturePad.off()}get instance(){return this.signaturePad}get canvas(){return this.canvasRef}set dotSize(s){this.signaturePad.dotSize=s}get dotSize(){return this.signaturePad.dotSize}set minWidth(s){this.signaturePad.minWidth=s}get minWidth(){return this.signaturePad.minWidth}set maxWidth(s){this.signaturePad.maxWidth=s}get maxWidth(){return this.signaturePad.maxWidth}set throttle(s){this.signaturePad.throttle=s}get throttle(){return this.signaturePad.throttle}set backgroundColor(s){this.signaturePad.backgroundColor=s}get backgroundColor(){return this.signaturePad.backgroundColor}set penColor(s){this.signaturePad.penColor=s}get penColor(){return this.signaturePad.penColor}set velocityFilterWeight(s){this.signaturePad.velocityFilterWeight=s}get velocityFilterWeight(){return this.signaturePad.velocityFilterWeight}isEmpty(){return this.signaturePad.isEmpty()}clear(){this.signaturePad.clear()}fromDataURL(s,n={}){this.signaturePad.fromDataURL(s,n)}toDataURL(s,n){return this.signaturePad.toDataURL(s,n)}toSVG(s){return this.signaturePad.toSVG(s)}fromData(s){this.signaturePad.fromData(s)}toData(){return this.signaturePad.toData()}off(){this.signaturePad.off()}on(){this.signaturePad.on()}handleResize(){const s=this.canvasRef.current;s&&this.scaleCanvas(s)}scaleCanvas(s){const n=Math.max(window.devicePixelRatio||1,1),r=(this.props.width||s.offsetWidth)*n,o=(this.props.height||s.offsetHeight)*n,{canvasWidth:a,canvasHeight:l}=this.state;if(r===a&&o===l)return;let c;this.props.redrawOnResize&&this.signaturePad&&!this.signaturePad.isEmpty()&&(c=this.signaturePad.toDataURL()),s.width=r,s.height=o,this.setState({canvasWidth:r,canvasHeight:o});const d=s.getContext("2d");d&&d.scale(n,n),c?this.signaturePad.fromDataURL(c):this.signaturePad&&this.signaturePad.clear()}render(){const{canvasProps:s}=this.props;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("canvas",w({"data-testid":"canvas-element",ref:this.canvasRef},s))}}C(SignaturePad,"displayName","react-signature-pad-wrapper"),C(SignaturePad,"defaultProps",{redrawOnResize:!1,debounceInterval:150});const SignatureInput=schema.connect(i=>{const{onChange:e,value:s}=i,n=React.useRef(null);React.useEffect(()=>{s&&n.current.fromDataURL(s)},[]);const r=()=>{n.current&&(n.current.clear(),e&&e(""))},o=()=>{if(n.current){const l=n.current.toDataURL();e&&e(l)}},a={pointerEvents:i.disabled?"none":"auto",opacity:i.disabled?.8:1};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{style:a,children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(SignaturePad,{ref:n,options:{penColor:"black",backgroundColor:"lightgrey"}}),!i.disabled&&__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:r,children:"清空"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:o,children:"确认"})]})]})},schema.mapProps((i,e)=>w({},i))),ErrorBoundaryContext=React.createContext(null),initialState={didCatch:!1,error:null};class ErrorBoundary extends React.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=initialState}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(e!==null){for(var s,n,r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];(s=(n=this.props).onReset)===null||s===void 0||s.call(n,{args:o,reason:"imperative-api"}),this.setState(initialState)}}componentDidCatch(e,s){var n,r;(n=(r=this.props).onError)===null||n===void 0||n.call(r,e,s)}componentDidUpdate(e,s){const{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&s.error!==null&&hasArrayChanged(e.resetKeys,r)){var o,a;(o=(a=this.props).onReset)===null||o===void 0||o.call(a,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(initialState)}}render(){const{children:e,fallbackRender:s,FallbackComponent:n,fallback:r}=this.props,{didCatch:o,error:a}=this.state;let l=e;if(o){const c={error:a,resetErrorBoundary:this.resetErrorBoundary};if(typeof s=="function")l=s(c);else if(n)l=React.createElement(n,c);else if(r!==void 0)l=r;else throw a}return React.createElement(ErrorBoundaryContext.Provider,{value:{didCatch:o,error:a,resetErrorBoundary:this.resetErrorBoundary}},l)}}function hasArrayChanged(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return i.length!==e.length||i.some((s,n)=>!Object.is(s,e[n]))}const ErrorBoundaryFallBack=()=>{const{t:i}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{children:i("Something went wrong. Please contact the developer to resolve the issue.")})},CustomAssociatedField=i=>{if(i.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"string",name:i.component,"x-component":i.component,"x-component-props":i}})})},useCustomComponent=i=>{const e=client.useApp();return _.filter(e.components,s=>s.__componentType===i).map(s=>({label:s.__componentLabel,value:s.displayName}))};var CustomComponentType=(i=>(i.CUSTOM_FORM_ITEM="FORM_ITEM",i.CUSTOM_FIELD="FIELD",i.CUSTOM_ASSOCIATED_FIELD="ASSOCIATED_FIELD",i))(CustomComponentType||{});const CustomComponentStub=i=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{children:"请选择组件"}),CustomComponentDispatcher=i=>{if(i.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"void",name:i.component,"x-component":i.component,"x-component-props":i}})})},customComponentDispatcherSettings=new client.SchemaSettings({name:"customComponentDispatcherSettings",items:[{name:"component",type:"select",useComponentProps(){var o;const i=useCustomComponent(CustomComponentType.CUSTOM_FORM_ITEM),{t:e}=useTranslation(),s=schema.useField(),n=schema.useFieldSchema(),{dn:r}=client.useDesignable();return{title:e("component"),value:((o=s.componentProps)==null?void 0:o.component)||"CustomComponentStub",options:[{label:"未选择组件",value:"CustomComponentStub"},...i],onChange(a){const l={"x-uid":n["x-uid"]};n["x-component-props"].component=a,n["x-acl-ignore"]=!0,l["x-component-props"]=n["x-component-props"],l["x-acl-ignore"]=!0,s.componentProps.component=a,r.emit("patch",{schema:l})}}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0}}]}),CustomField=i=>{if(i.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"string",name:i.component,"x-component":i.component,"x-component-props":i}})})},viewerSchema={type:"void",title:'{{ t("View record") }}',"x-component":"AssociationField.Viewer","x-component-props":{className:"tb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"RecordBlockInitializers",properties:{}}}}}}}},useInsertSchema=i=>{const e=schema.useFieldSchema(),{insertAfterBegin:s}=client.useDesignable();return React.useCallback(r=>{e.reduceProperties((a,l)=>l["x-component"]==="AssociationField."+i?l:a,null)||s(_.cloneDeep(r))},[i])},AssociatedFieldImplement=schema.observer(i=>{var v,A,D;const{collection:e,fieldExp:s,dateFieldExp:n,sourceCollection:r,sourceField:o}=i,[a,l]=React.useState(!1),c=useInsertSchema("Viewer"),d=schema.useField(),u=schema.useForm(),p=schema.useFieldSchema(),{designable:m}=client.useDesignable(),f=s==null?void 0:s.replace(/{{(.*?)}}/,"$1"),g=n==null?void 0:n.replace(/{{(.*?)}}/,"$1"),{data:x,loading:y,run:E}=client.useRequest({url:`/${r}:get`,params:{appends:[o],filter:{contract_id:(v=u.values[f])==null?void 0:v.id,start_date:{$lte:u.values[g]},end_date:{$gte:u.values[g]}}}},{manual:!0});if(React.useEffect(()=>{var L;(L=u.values[f])!=null&&L.id&&u.values[g]&&E()},[(A=u.values[f])==null?void 0:A.id,u.values[g]]),y||!x)return null;if(!((D=x.data)!=null&&D[o+"_id"]))return u.setValues({[p.name]:null}),null;const b=x.data[o];return u.setValues({[p.name]:b}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{onClick:L=>{L.stopPropagation(),L.preventDefault(),m&&c(viewerSchema),l(!0)},children:b.name}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.CollectionProvider_deprecated,{name:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionContextProvider,{value:{visible:a,setVisible:l,openMode:"drawer",snapshot:!1},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RecordProvider,{record:b,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.FormProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(schema.RecursionField,{schema:p,onlyRenderProperties:!0,basePath:d.address,filterProperties:L=>L["x-component"]==="AssociationField.Viewer"})})})})})]})}),AssociatedField=schema.connect(AssociatedFieldImplement),transformFormula$1=i=>i?i.split(/([+\-*/?:()%])/).filter(s=>s):[],CalcResult=props=>{const form=schema.useForm(),fieldSchema=schema.useFieldSchema(),field=schema.useField(),{formula,prefix,suffix,decimal,panel}=props,path=field.path.entire,fieldPath=path==null?void 0:path.replace(`.${fieldSchema.name}`,""),engine=client$1.evaluators.get("math.js"),evaluate=engine.evaluate.bind(engine),defaultValue=fieldSchema.name==="subtotal"?"¥0.00":[],[value,setValue]=React.useState(defaultValue),transformFormulaArray=transformFormula$1(formula);let calculateData=[];const newFormulaArray=i=>{var n;calculateData=[];let e=0;const s={};if(transformFormulaArray.length!==0){for(let r=0;r<transformFormulaArray.length;r++){const o=transformFormulaArray[r];if(!o)continue;const a=!isNaN(Number(o)),l=["+","-","*","/","?",":","(",")","%"].includes(o);if(!a&&!l){let c;const d=/\${(.*?)}/g;if((n=o.match(d))!=null&&n.length){const m=o.match(d)[0].replace(/\${|}/g,""),f=o.split(".")[1];path===fieldPath?c=_.chain(i).get(m).get(f,0).value():c=_.chain(i).get(fieldPath).get(m).get(f,0).value()}else path===fieldPath?c=_.chain(i).get(o,0).value():c=_.chain(i).get(fieldPath).get(o,0).value();c||(c=0),e+=1;const u="var"+e,p=c;s[u]=p,calculateData.push("{{"+u+"}}")}else calculateData.push(o)}return[calculateData.join(""),s]}},fun=()=>P(this,null,function*(){if(!panel&&transformFormulaArray.length){const[i,e]=newFormulaArray(form.values);let s;try{const n=prefix||"",r=suffix||"",o=evaluate(i,e),a=isNaN(o)?o:Number(o).toFixed(decimal||0);s=n+a+r}catch(n){s=`${i}`,console.warn("code: ",i," scopes: ",e,"error: ",s," error message ",n.message)}setValue(s.toString())}else if(panel){let items=[],childrenType="";(yield import("react/jsx-runtime")).default,(yield import("dayjs")).default,childrenType="normal";try{eval(panel)}catch(i){items=[],items.push({key:"1",label:"数据异常",children:"请检查字段配置内容,error:"+i})}const showItems=items.map(i=>({label:i.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{children:i.children})}));if(childrenType==="normal"){const i=__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{items:showItems});setValue(i)}else if(childrenType==="jsx"&&Array.isArray(items)){const i=__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:items.map(e=>e.children)});setValue(i)}}});return React.useEffect(()=>{fun()},[]),schema.useFormEffects(()=>{schema.onFormValuesChange(i=>{fun()})}),typeof value=="string"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value}):value},Expression=i=>{var u;const{value:e="",useCurrentFields:s,onChange:n}=i,r=client.useCompile(),{interfaces:o,getCollectionFields:a}=client.useCollectionManager_deprecated(),l=(u=s==null?void 0:s())!=null?u:[],c=client.useAssociatedFields();console.log(c,"associatedFields",l);const d=l.map(p=>{var m,f;return{label:r(p.uiSchema.title),value:p.name,children:(f=(m=a(p.target))==null?void 0:m.filter(g=>g.uiSchema).map(g=>({label:g.uiSchema?r(g.uiSchema.title):"",value:g.name})))!=null?f:[]}});return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Variable.Input,{value:e,onChange:n,scope:d,changeOnSelect:!0})},ModalHeader=i=>{const{title:e,onOk:s,onCancel:n}=i;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{className:client.css`
22
+ */class Point{constructor(e,s,i,r){if(isNaN(e)||isNaN(s))throw new Error(`Point is invalid: (${e}, ${s})`);this.x=+e,this.y=+s,this.pressure=i||0,this.time=r||Date.now()}distanceTo(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))}equals(e){return this.x===e.x&&this.y===e.y&&this.pressure===e.pressure&&this.time===e.time}velocityFrom(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):0}}class Bezier{static fromPoints(e,s){const i=this.calculateControlPoints(e[0],e[1],e[2]).c2,r=this.calculateControlPoints(e[1],e[2],e[3]).c1;return new Bezier(e[1],i,r,e[2],s.start,s.end)}static calculateControlPoints(e,s,i){const r=e.x-s.x,o=e.y-s.y,l=s.x-i.x,a=s.y-i.y,c={x:(e.x+s.x)/2,y:(e.y+s.y)/2},d={x:(s.x+i.x)/2,y:(s.y+i.y)/2},u=Math.sqrt(r*r+o*o),f=Math.sqrt(l*l+a*a),m=c.x-d.x,p=c.y-d.y,g=f/(u+f),x={x:d.x+m*g,y:d.y+p*g},E=s.x-x.x,v=s.y-x.y;return{c1:new Point(c.x+E,c.y+v),c2:new Point(d.x+E,d.y+v)}}constructor(e,s,i,r,o,l){this.startPoint=e,this.control2=s,this.control1=i,this.endPoint=r,this.startWidth=o,this.endWidth=l}length(){let s=0,i,r;for(let o=0;o<=10;o+=1){const l=o/10,a=this.point(l,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),c=this.point(l,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(o>0){const d=a-i,u=c-r;s+=Math.sqrt(d*d+u*u)}i=a,r=c}return s}point(e,s,i,r,o){return s*(1-e)*(1-e)*(1-e)+3*i*(1-e)*(1-e)*e+3*r*(1-e)*e*e+o*e*e*e}}class SignatureEventTarget{constructor(){try{this._et=new EventTarget}catch(e){this._et=document}}addEventListener(e,s,i){this._et.addEventListener(e,s,i)}dispatchEvent(e){return this._et.dispatchEvent(e)}removeEventListener(e,s,i){this._et.removeEventListener(e,s,i)}}function throttle$1(n,e=250){let s=0,i=null,r,o,l;const a=()=>{s=Date.now(),i=null,r=n.apply(o,l),i||(o=null,l=[])};return function(...d){const u=Date.now(),f=e-(u-s);return o=this,l=d,f<=0||f>e?(i&&(clearTimeout(i),i=null),s=u,r=n.apply(o,l),i||(o=null,l=[])):i||(i=window.setTimeout(a,f)),r}}let SignaturePad$1=class G extends SignatureEventTarget{constructor(e,s={}){super(),this.canvas=e,this._drawingStroke=!1,this._isEmpty=!0,this._lastPoints=[],this._data=[],this._lastVelocity=0,this._lastWidth=0,this._handleMouseDown=i=>{i.buttons===1&&this._strokeBegin(i)},this._handleMouseMove=i=>{this._strokeMoveUpdate(i)},this._handleMouseUp=i=>{i.buttons===1&&this._strokeEnd(i)},this._handleTouchStart=i=>{if(i.cancelable&&i.preventDefault(),i.targetTouches.length===1){const r=i.changedTouches[0];this._strokeBegin(r)}},this._handleTouchMove=i=>{i.cancelable&&i.preventDefault();const r=i.targetTouches[0];this._strokeMoveUpdate(r)},this._handleTouchEnd=i=>{if(i.target===this.canvas){i.cancelable&&i.preventDefault();const o=i.changedTouches[0];this._strokeEnd(o)}},this._handlePointerStart=i=>{i.preventDefault(),this._strokeBegin(i)},this._handlePointerMove=i=>{this._strokeMoveUpdate(i)},this._handlePointerEnd=i=>{this._drawingStroke&&(i.preventDefault(),this._strokeEnd(i))},this.velocityFilterWeight=s.velocityFilterWeight||.7,this.minWidth=s.minWidth||.5,this.maxWidth=s.maxWidth||2.5,this.throttle="throttle"in s?s.throttle:16,this.minDistance="minDistance"in s?s.minDistance:5,this.dotSize=s.dotSize||0,this.penColor=s.penColor||"black",this.backgroundColor=s.backgroundColor||"rgba(0,0,0,0)",this.compositeOperation=s.compositeOperation||"source-over",this.canvasContextOptions="canvasContextOptions"in s?s.canvasContextOptions:{},this._strokeMoveUpdate=this.throttle?throttle$1(G.prototype._strokeUpdate,this.throttle):G.prototype._strokeUpdate,this._ctx=e.getContext("2d",this.canvasContextOptions),this.clear(),this.on()}clear(){const{_ctx:e,canvas:s}=this;e.fillStyle=this.backgroundColor,e.clearRect(0,0,s.width,s.height),e.fillRect(0,0,s.width,s.height),this._data=[],this._reset(this._getPointGroupOptions()),this._isEmpty=!0}fromDataURL(e,s={}){return new Promise((i,r)=>{const o=new Image,l=s.ratio||window.devicePixelRatio||1,a=s.width||this.canvas.width/l,c=s.height||this.canvas.height/l,d=s.xOffset||0,u=s.yOffset||0;this._reset(this._getPointGroupOptions()),o.onload=()=>{this._ctx.drawImage(o,d,u,a,c),i()},o.onerror=f=>{r(f)},o.crossOrigin="anonymous",o.src=e,this._isEmpty=!1})}toDataURL(e="image/png",s){switch(e){case"image/svg+xml":return typeof s!="object"&&(s=void 0),`data:image/svg+xml;base64,${btoa(this.toSVG(s))}`;default:return typeof s!="number"&&(s=void 0),this.canvas.toDataURL(e,s)}}on(){this.canvas.style.touchAction="none",this.canvas.style.msTouchAction="none",this.canvas.style.userSelect="none";const e=/Macintosh/.test(navigator.userAgent)&&"ontouchstart"in document;window.PointerEvent&&!e?this._handlePointerEvents():(this._handleMouseEvents(),"ontouchstart"in window&&this._handleTouchEvents())}off(){this.canvas.style.touchAction="auto",this.canvas.style.msTouchAction="auto",this.canvas.style.userSelect="auto",this.canvas.removeEventListener("pointerdown",this._handlePointerStart),this.canvas.removeEventListener("pointermove",this._handlePointerMove),this.canvas.ownerDocument.removeEventListener("pointerup",this._handlePointerEnd),this.canvas.removeEventListener("mousedown",this._handleMouseDown),this.canvas.removeEventListener("mousemove",this._handleMouseMove),this.canvas.ownerDocument.removeEventListener("mouseup",this._handleMouseUp),this.canvas.removeEventListener("touchstart",this._handleTouchStart),this.canvas.removeEventListener("touchmove",this._handleTouchMove),this.canvas.removeEventListener("touchend",this._handleTouchEnd)}isEmpty(){return this._isEmpty}fromData(e,{clear:s=!0}={}){s&&this.clear(),this._fromData(e,this._drawCurve.bind(this),this._drawDot.bind(this)),this._data=this._data.concat(e)}toData(){return this._data}_getPointGroupOptions(e){return{penColor:e&&"penColor"in e?e.penColor:this.penColor,dotSize:e&&"dotSize"in e?e.dotSize:this.dotSize,minWidth:e&&"minWidth"in e?e.minWidth:this.minWidth,maxWidth:e&&"maxWidth"in e?e.maxWidth:this.maxWidth,velocityFilterWeight:e&&"velocityFilterWeight"in e?e.velocityFilterWeight:this.velocityFilterWeight,compositeOperation:e&&"compositeOperation"in e?e.compositeOperation:this.compositeOperation}}_strokeBegin(e){if(!this.dispatchEvent(new CustomEvent("beginStroke",{detail:e,cancelable:!0})))return;this._drawingStroke=!0;const i=this._getPointGroupOptions(),r=Object.assign(Object.assign({},i),{points:[]});this._data.push(r),this._reset(i),this._strokeUpdate(e)}_strokeUpdate(e){if(!this._drawingStroke)return;if(this._data.length===0){this._strokeBegin(e);return}this.dispatchEvent(new CustomEvent("beforeUpdateStroke",{detail:e}));const s=e.clientX,i=e.clientY,r=e.pressure!==void 0?e.pressure:e.force!==void 0?e.force:0,o=this._createPoint(s,i,r),l=this._data[this._data.length-1],a=l.points,c=a.length>0&&a[a.length-1],d=c?o.distanceTo(c)<=this.minDistance:!1,u=this._getPointGroupOptions(l);if(!c||!(c&&d)){const f=this._addPoint(o,u);c?f&&this._drawCurve(f,u):this._drawDot(o,u),a.push({time:o.time,x:o.x,y:o.y,pressure:o.pressure})}this.dispatchEvent(new CustomEvent("afterUpdateStroke",{detail:e}))}_strokeEnd(e){this._drawingStroke&&(this._strokeUpdate(e),this._drawingStroke=!1,this.dispatchEvent(new CustomEvent("endStroke",{detail:e})))}_handlePointerEvents(){this._drawingStroke=!1,this.canvas.addEventListener("pointerdown",this._handlePointerStart),this.canvas.addEventListener("pointermove",this._handlePointerMove),this.canvas.ownerDocument.addEventListener("pointerup",this._handlePointerEnd)}_handleMouseEvents(){this._drawingStroke=!1,this.canvas.addEventListener("mousedown",this._handleMouseDown),this.canvas.addEventListener("mousemove",this._handleMouseMove),this.canvas.ownerDocument.addEventListener("mouseup",this._handleMouseUp)}_handleTouchEvents(){this.canvas.addEventListener("touchstart",this._handleTouchStart),this.canvas.addEventListener("touchmove",this._handleTouchMove),this.canvas.addEventListener("touchend",this._handleTouchEnd)}_reset(e){this._lastPoints=[],this._lastVelocity=0,this._lastWidth=(e.minWidth+e.maxWidth)/2,this._ctx.fillStyle=e.penColor,this._ctx.globalCompositeOperation=e.compositeOperation}_createPoint(e,s,i){const r=this.canvas.getBoundingClientRect();return new Point(e-r.left,s-r.top,i,new Date().getTime())}_addPoint(e,s){const{_lastPoints:i}=this;if(i.push(e),i.length>2){i.length===3&&i.unshift(i[0]);const r=this._calculateCurveWidths(i[1],i[2],s),o=Bezier.fromPoints(i,r);return i.shift(),o}return null}_calculateCurveWidths(e,s,i){const r=i.velocityFilterWeight*s.velocityFrom(e)+(1-i.velocityFilterWeight)*this._lastVelocity,o=this._strokeWidth(r,i),l={end:o,start:this._lastWidth};return this._lastVelocity=r,this._lastWidth=o,l}_strokeWidth(e,s){return Math.max(s.maxWidth/(e+1),s.minWidth)}_drawCurveSegment(e,s,i){const r=this._ctx;r.moveTo(e,s),r.arc(e,s,i,0,2*Math.PI,!1),this._isEmpty=!1}_drawCurve(e,s){const i=this._ctx,r=e.endWidth-e.startWidth,o=Math.ceil(e.length())*2;i.beginPath(),i.fillStyle=s.penColor;for(let l=0;l<o;l+=1){const a=l/o,c=a*a,d=c*a,u=1-a,f=u*u,m=f*u;let p=m*e.startPoint.x;p+=3*f*a*e.control1.x,p+=3*u*c*e.control2.x,p+=d*e.endPoint.x;let g=m*e.startPoint.y;g+=3*f*a*e.control1.y,g+=3*u*c*e.control2.y,g+=d*e.endPoint.y;const x=Math.min(e.startWidth+d*r,s.maxWidth);this._drawCurveSegment(p,g,x)}i.closePath(),i.fill()}_drawDot(e,s){const i=this._ctx,r=s.dotSize>0?s.dotSize:(s.minWidth+s.maxWidth)/2;i.beginPath(),this._drawCurveSegment(e.x,e.y,r),i.closePath(),i.fillStyle=s.penColor,i.fill()}_fromData(e,s,i){for(const r of e){const{points:o}=r,l=this._getPointGroupOptions(r);if(o.length>1)for(let a=0;a<o.length;a+=1){const c=o[a],d=new Point(c.x,c.y,c.pressure,c.time);a===0&&this._reset(l);const u=this._addPoint(d,l);u&&s(u,l)}else this._reset(l),i(o[0],l)}}toSVG({includeBackgroundColor:e=!1}={}){const s=this._data,i=Math.max(window.devicePixelRatio||1,1),r=0,o=0,l=this.canvas.width/i,a=this.canvas.height/i,c=document.createElementNS("http://www.w3.org/2000/svg","svg");if(c.setAttribute("xmlns","http://www.w3.org/2000/svg"),c.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),c.setAttribute("viewBox",`${r} ${o} ${l} ${a}`),c.setAttribute("width",l.toString()),c.setAttribute("height",a.toString()),e&&this.backgroundColor){const d=document.createElement("rect");d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.setAttribute("fill",this.backgroundColor),c.appendChild(d)}return this._fromData(s,(d,{penColor:u})=>{const f=document.createElement("path");if(!isNaN(d.control1.x)&&!isNaN(d.control1.y)&&!isNaN(d.control2.x)&&!isNaN(d.control2.y)){const m=`M ${d.startPoint.x.toFixed(3)},${d.startPoint.y.toFixed(3)} C ${d.control1.x.toFixed(3)},${d.control1.y.toFixed(3)} ${d.control2.x.toFixed(3)},${d.control2.y.toFixed(3)} ${d.endPoint.x.toFixed(3)},${d.endPoint.y.toFixed(3)}`;f.setAttribute("d",m),f.setAttribute("stroke-width",(d.endWidth*2.25).toFixed(3)),f.setAttribute("stroke",u),f.setAttribute("fill","none"),f.setAttribute("stroke-linecap","round"),c.appendChild(f)}},(d,{penColor:u,dotSize:f,minWidth:m,maxWidth:p})=>{const g=document.createElement("circle"),x=f>0?f:(m+p)/2;g.setAttribute("r",x.toString()),g.setAttribute("cx",d.x.toString()),g.setAttribute("cy",d.y.toString()),g.setAttribute("fill",u),c.appendChild(g)}),c.outerHTML}};function throttle(n,e,s){var i=s||{},r=i.noTrailing,o=r===void 0?!1:r,l=i.noLeading,a=l===void 0?!1:l,c=i.debounceMode,d=c===void 0?void 0:c,u,f=!1,m=0;function p(){u&&clearTimeout(u)}function g(E){var v=E||{},y=v.upcomingOnly,w=y===void 0?!1:y;p(),f=!w}function x(){for(var E=arguments.length,v=new Array(E),y=0;y<E;y++)v[y]=arguments[y];var w=this,S=Date.now()-m;if(f)return;function D(){m=Date.now(),e.apply(w,v)}function F(){u=void 0}!a&&d&&!u&&D(),p(),d===void 0&&S>n?a?(m=Date.now(),o||(u=setTimeout(d?F:D,n))):D():o!==!0&&(u=setTimeout(d?F:D,d===void 0?n-S:n))}return x.cancel=g,x}function debounce(n,e,s){var i={},r=i.atBegin,o=r===void 0?!1:r;return throttle(n,e,{debounceMode:o!==!1})}class SignaturePad extends React__namespace.PureComponent{constructor(s){super(s);b(this,"canvasRef",React__namespace.createRef());b(this,"signaturePad");b(this,"callResizeHandler");this.state={canvasWidth:0,canvasHeight:0},this.callResizeHandler=debounce(this.props.debounceInterval,this.handleResize.bind(this))}componentDidMount(){const s=this.canvasRef.current;s&&((!this.props.width||!this.props.height)&&(s.style.width="100%",window.addEventListener("resize",this.callResizeHandler)),this.signaturePad=new SignaturePad$1(s,this.props.options),this.scaleCanvas(s))}componentWillUnmount(){(!this.props.width||!this.props.height)&&window.removeEventListener("resize",this.callResizeHandler),this.signaturePad.off()}get instance(){return this.signaturePad}get canvas(){return this.canvasRef}set dotSize(s){this.signaturePad.dotSize=s}get dotSize(){return this.signaturePad.dotSize}set minWidth(s){this.signaturePad.minWidth=s}get minWidth(){return this.signaturePad.minWidth}set maxWidth(s){this.signaturePad.maxWidth=s}get maxWidth(){return this.signaturePad.maxWidth}set throttle(s){this.signaturePad.throttle=s}get throttle(){return this.signaturePad.throttle}set backgroundColor(s){this.signaturePad.backgroundColor=s}get backgroundColor(){return this.signaturePad.backgroundColor}set penColor(s){this.signaturePad.penColor=s}get penColor(){return this.signaturePad.penColor}set velocityFilterWeight(s){this.signaturePad.velocityFilterWeight=s}get velocityFilterWeight(){return this.signaturePad.velocityFilterWeight}isEmpty(){return this.signaturePad.isEmpty()}clear(){this.signaturePad.clear()}fromDataURL(s,i={}){this.signaturePad.fromDataURL(s,i)}toDataURL(s,i){return this.signaturePad.toDataURL(s,i)}toSVG(s){return this.signaturePad.toSVG(s)}fromData(s){this.signaturePad.fromData(s)}toData(){return this.signaturePad.toData()}off(){this.signaturePad.off()}on(){this.signaturePad.on()}handleResize(){const s=this.canvasRef.current;s&&this.scaleCanvas(s)}scaleCanvas(s){const i=Math.max(window.devicePixelRatio||1,1),r=(this.props.width||s.offsetWidth)*i,o=(this.props.height||s.offsetHeight)*i,{canvasWidth:l,canvasHeight:a}=this.state;if(r===l&&o===a)return;let c;this.props.redrawOnResize&&this.signaturePad&&!this.signaturePad.isEmpty()&&(c=this.signaturePad.toDataURL()),s.width=r,s.height=o,this.setState({canvasWidth:r,canvasHeight:o});const d=s.getContext("2d");d&&d.scale(i,i),c?this.signaturePad.fromDataURL(c):this.signaturePad&&this.signaturePad.clear()}render(){const{canvasProps:s}=this.props;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("canvas",A({"data-testid":"canvas-element",ref:this.canvasRef},s))}}b(SignaturePad,"displayName","react-signature-pad-wrapper"),b(SignaturePad,"defaultProps",{redrawOnResize:!1,debounceInterval:150});const SignatureInput=schema.connect(n=>{const{onChange:e,value:s}=n,i=React.useRef(null);React.useEffect(()=>{s&&i.current.fromDataURL(s)},[]);const r=()=>{i.current&&(i.current.clear(),e&&e(""))},o=()=>{if(i.current){const a=i.current.toDataURL();e&&e(a)}},l={pointerEvents:n.disabled?"none":"auto",opacity:n.disabled?.8:1};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{style:l,children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(SignaturePad,{ref:i,options:{penColor:"black",backgroundColor:"lightgrey"}}),!n.disabled&&__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:r,children:"清空"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:o,children:"确认"})]})]})},schema.mapProps((n,e)=>A({},n))),ErrorBoundaryContext=React.createContext(null),initialState={didCatch:!1,error:null};class ErrorBoundary extends React.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=initialState}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(e!==null){for(var s,i,r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];(s=(i=this.props).onReset)===null||s===void 0||s.call(i,{args:o,reason:"imperative-api"}),this.setState(initialState)}}componentDidCatch(e,s){var i,r;(i=(r=this.props).onError)===null||i===void 0||i.call(r,e,s)}componentDidUpdate(e,s){const{didCatch:i}=this.state,{resetKeys:r}=this.props;if(i&&s.error!==null&&hasArrayChanged(e.resetKeys,r)){var o,l;(o=(l=this.props).onReset)===null||o===void 0||o.call(l,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(initialState)}}render(){const{children:e,fallbackRender:s,FallbackComponent:i,fallback:r}=this.props,{didCatch:o,error:l}=this.state;let a=e;if(o){const c={error:l,resetErrorBoundary:this.resetErrorBoundary};if(typeof s=="function")a=s(c);else if(i)a=React.createElement(i,c);else if(r!==void 0)a=r;else throw l}return React.createElement(ErrorBoundaryContext.Provider,{value:{didCatch:o,error:l,resetErrorBoundary:this.resetErrorBoundary}},a)}}function hasArrayChanged(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return n.length!==e.length||n.some((s,i)=>!Object.is(s,e[i]))}const ErrorBoundaryFallBack=()=>{const{t:n}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{children:n("Something went wrong. Please contact the developer to resolve the issue.")})},CustomAssociatedField=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"string",name:n.component,"x-component":n.component,"x-component-props":n}})})},useCustomComponent=n=>{const e=client.useApp();return _.filter(e.components,s=>s.__componentType===n).map(s=>({label:s.__componentLabel,value:s.displayName}))};var CustomComponentType=(n=>(n.CUSTOM_FORM_ITEM="FORM_ITEM",n.CUSTOM_FIELD="FIELD",n.CUSTOM_ASSOCIATED_FIELD="ASSOCIATED_FIELD",n))(CustomComponentType||{});const CustomComponentStub=n=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{children:"请选择组件"}),CustomComponentDispatcher=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"void",name:n.component,"x-component":n.component,"x-component-props":n}})})},customComponentDispatcherSettings=new client.SchemaSettings({name:"customComponentDispatcherSettings",items:[{name:"component",type:"select",useComponentProps(){var o;const n=useCustomComponent(CustomComponentType.CUSTOM_FORM_ITEM),{t:e}=useTranslation(),s=schema.useField(),i=schema.useFieldSchema(),{dn:r}=client.useDesignable();return{title:e("component"),value:((o=s.componentProps)==null?void 0:o.component)||"CustomComponentStub",options:[{label:"未选择组件",value:"CustomComponentStub"},...n],onChange(l){const a={"x-uid":i["x-uid"]};i["x-component-props"].component=l,i["x-acl-ignore"]=!0,a["x-component-props"]=i["x-component-props"],a["x-acl-ignore"]=!0,s.componentProps.component=l,r.emit("patch",{schema:a})}}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0}}]}),CustomField=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"string",name:n.component,"x-component":n.component,"x-component-props":n}})})},viewerSchema={type:"void",title:'{{ t("View record") }}',"x-component":"AssociationField.Viewer","x-component-props":{className:"tb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"RecordBlockInitializers",properties:{}}}}}}}},useInsertSchema=n=>{const e=schema.useFieldSchema(),{insertAfterBegin:s}=client.useDesignable();return React.useCallback(r=>{e.reduceProperties((l,a)=>a["x-component"]==="AssociationField."+n?a:l,null)||s(_.cloneDeep(r))},[n])},AssociatedFieldImplement=schema.observer(n=>{var w,S,D;const{collection:e,fieldExp:s,dateFieldExp:i,sourceCollection:r,sourceField:o}=n,[l,a]=React.useState(!1),c=useInsertSchema("Viewer"),d=schema.useField(),u=schema.useForm(),f=schema.useFieldSchema(),{designable:m}=client.useDesignable(),p=s==null?void 0:s.replace(/{{(.*?)}}/,"$1"),g=i==null?void 0:i.replace(/{{(.*?)}}/,"$1"),{data:x,loading:E,run:v}=client.useRequest({url:`/${r}:get`,params:{appends:[o],filter:{contract_id:(w=u.values[p])==null?void 0:w.id,start_date:{$lte:u.values[g]},end_date:{$gte:u.values[g]}}}},{manual:!0});if(React.useEffect(()=>{var F;(F=u.values[p])!=null&&F.id&&u.values[g]&&v()},[(S=u.values[p])==null?void 0:S.id,u.values[g]]),E||!x)return null;if(!((D=x.data)!=null&&D[o+"_id"]))return u.setValues({[f.name]:null}),null;const y=x.data[o];return u.setValues({[f.name]:y}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{onClick:F=>{F.stopPropagation(),F.preventDefault(),m&&c(viewerSchema),a(!0)},children:y.name}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.CollectionProvider_deprecated,{name:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionContextProvider,{value:{visible:l,setVisible:a,openMode:"drawer",snapshot:!1},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RecordProvider,{record:y,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.FormProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(schema.RecursionField,{schema:f,onlyRenderProperties:!0,basePath:d.address,filterProperties:F=>F["x-component"]==="AssociationField.Viewer"})})})})})]})}),AssociatedField=schema.connect(AssociatedFieldImplement),transformFormula$1=n=>n?n.split(/([+\-*/?:()%])/).filter(s=>s):[],CalcResult=props=>{const form=schema.useForm(),fieldSchema=schema.useFieldSchema(),field=schema.useField(),{formula,prefix,suffix,decimal,panel}=props,path=field.path.entire,fieldPath=path==null?void 0:path.replace(`.${fieldSchema.name}`,""),engine=client$1.evaluators.get("math.js"),evaluate=engine.evaluate.bind(engine),defaultValue=fieldSchema.name==="subtotal"?"¥0.00":[],[value,setValue]=React.useState(defaultValue),transformFormulaArray=transformFormula$1(formula);let calculateData=[];const newFormulaArray=n=>{var i;calculateData=[];let e=0;const s={};if(transformFormulaArray.length!==0){for(let r=0;r<transformFormulaArray.length;r++){const o=transformFormulaArray[r];if(!o)continue;const l=!isNaN(Number(o)),a=["+","-","*","/","?",":","(",")","%"].includes(o);if(!l&&!a){let c;const d=/\${(.*?)}/g;if((i=o.match(d))!=null&&i.length){const m=o.match(d)[0].replace(/\${|}/g,""),p=o.split(".")[1];path===fieldPath?c=_.chain(n).get(m).get(p,0).value():c=_.chain(n).get(fieldPath).get(m).get(p,0).value()}else path===fieldPath?c=_.chain(n).get(o,0).value():c=_.chain(n).get(fieldPath).get(o,0).value();c||(c=0),e+=1;const u="var"+e,f=c;s[u]=f,calculateData.push("{{"+u+"}}")}else calculateData.push(o)}return[calculateData.join(""),s]}},fun=()=>R(this,null,function*(){if(!panel&&transformFormulaArray.length){const[n,e]=newFormulaArray(form.values);let s;try{const i=prefix||"",r=suffix||"",o=evaluate(n,e),l=isNaN(o)?o:Number(o).toFixed(decimal||0);s=i+l+r}catch(i){s=`${n}`,console.warn("code: ",n," scopes: ",e,"error: ",s," error message ",i.message)}setValue(s.toString())}else if(panel){let items=[],childrenType="";(yield import("react/jsx-runtime")).default,(yield import("dayjs")).default,childrenType="normal";try{eval(panel)}catch(n){items=[],items.push({key:"1",label:"数据异常",children:"请检查字段配置内容,error:"+n})}const showItems=items.map(n=>({label:n.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{children:n.children})}));if(childrenType==="normal"){const n=__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{items:showItems});setValue(n)}else if(childrenType==="jsx"&&Array.isArray(items)){const n=__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:items.map(e=>e.children)});setValue(n)}}});return React.useEffect(()=>{fun()},[]),schema.useFormEffects(()=>{schema.onFormValuesChange(n=>{fun()})}),typeof value=="string"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value}):value},Expression=n=>{var u;const{value:e="",useCurrentFields:s,onChange:i}=n,r=client.useCompile(),{interfaces:o,getCollectionFields:l}=client.useCollectionManager_deprecated(),a=(u=s==null?void 0:s())!=null?u:[],c=client.useAssociatedFields();console.log(c,"associatedFields",a);const d=a.map(f=>{var m,p;return{label:r(f.uiSchema.title),value:f.name,children:(p=(m=l(f.target))==null?void 0:m.filter(g=>g.uiSchema).map(g=>({label:g.uiSchema?r(g.uiSchema.title):"",value:g.name})))!=null?p:[]}});return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Variable.Input,{value:e,onChange:i,scope:d,changeOnSelect:!0})},ModalHeader=n=>{const{title:e,onOk:s,onCancel:i}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{className:client.css`
23
23
  display: flex;
24
24
  flex-direction: row;
25
25
  justify-content: space-between;
@@ -40,27 +40,16 @@
40
40
  flex-direction: row;
41
41
  justify-content: space-around;
42
42
  margin-right: 20px;
43
- `,type:"primary",onClick:s,children:"确认"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:n,children:"取消"})]})]})},ModalFullScreen=i=>{const{className:e,title:s,open:n,children:r,onOk:o,onCancel:a}=i;return n?ReactDOM.createPortal(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{className:client.cx(client.css`
43
+ `,type:"primary",onClick:s,children:"确认"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:i,children:"取消"})]})]})},ModalFullScreen=n=>{const{className:e,title:s,open:i,children:r,onOk:o,onCancel:l}=n;return i?ReactDOM.createPortal(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{className:client.cx(client.css`
44
44
  position: fixed;
45
45
  top: 0;
46
46
  left: 0;
47
47
  right: 0;
48
48
  bottom: 0;
49
49
  z-index: 1000;
50
- display: ${n?"flex":"none"};
50
+ display: ${i?"flex":"none"};
51
51
  flex-direction: column;
52
- `,e),children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ModalHeader,{title:s,onOk:o,onCancel:a}),r]}),document.body):null};ModalFullScreen.displayName="ModalFullScreen";const ExcelFileComponent=i=>{const{title:e,disabled:s,value:n,onChange:r}=i,o=React.useRef(),[a,l]=React.useState(!1),c=()=>{l(!0)},d=()=>{l(!1)},u=()=>{const p=o.current.getData();r(p),l(!1)};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{type:"primary",onClick:c,children:s?"查看":"编辑"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ModalFullScreen,{title:e!=null?e:"Excel",open:a,onOk:u,onCancel:d,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ExcelSheet,{ref:o,data:n||[]})})]})},ExcelFile=schema.connect(ExcelFileComponent,schema.mapProps(i=>w({},i))),GroupBlockContext=React.createContext({}),GroupSvg=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("svg",{viewBox:"0 0 1024 1024",width:"1em",height:"1em",fill:"currentColor",children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("path",{d:"M833.179846 36.584242h-73.160824a36.516572 36.516572 0 0 0 0 73.160824h73.160824c20.173491 0 36.516572 16.343081 36.516572 36.580412v768.060967a36.580412 36.580412 0 0 1-36.516572 36.580412H174.860114a36.580412 36.580412 0 0 1-36.580412-36.580412V146.325478c0-20.173491 16.343081-36.580412 36.580412-36.580412h73.160824a36.516572 36.516572 0 1 0 0-73.160824H174.860114A109.805076 109.805076 0 0 0 65.118879 146.325478v768.060967c0 60.584312 49.156923 109.741235 109.741235 109.741235h658.383572a109.805076 109.805076 0 0 0 109.677395-109.741235V146.325478A109.805076 109.805076 0 0 0 833.179846 36.584242z",fill:"#2C2C2C"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("path",{d:"M357.826013 146.325478h292.451774a36.516572 36.516572 0 0 0 36.580412-36.580412V36.584242A36.516572 36.516572 0 0 0 650.277787 0.00383H357.826013a36.516572 36.516572 0 0 0-36.580412 36.580412v73.160824c0 20.173491 16.343081 36.580412 36.580412 36.580412z m-36.708092 622.888443a36.580412 36.580412 0 0 0 36.580412-36.580412V512.065755a36.516572 36.516572 0 1 0-73.096984 0v220.567754c0 20.173491 16.279241 36.580412 36.516572 36.580412z m146.321647-330.308989v293.728577a36.580412 36.580412 0 1 0 73.160824 0V438.904932a36.580412 36.580412 0 1 0-73.160824 0z m182.838219-146.321647v440.050224a36.644252 36.644252 0 0 0 73.160824 0V292.583285a36.644252 36.644252 0 0 0-73.160824 0z",fill:"#2C2C2C"})]}),GroupIcon=i=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Icon,w({type:"",component:GroupSvg},i)),InternalGroupBlockProvider=i=>{const e=schema.useField(),{resource:s,service:n}=client.useBlockRequestContext(),[r,o]=React.useState(!1);return n.loading&&!e.loaded?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Spin,{}):(e.loaded=!0,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(GroupBlockContext.Provider,{value:{props:{resource:i.resource},field:e,service:n,resource:s,visible:r,setVisible:o},children:i.children}))},GroupBlockProvider=i=>{const e=w({},i.params);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.BlockProvider,R(w({name:"group"},i),{params:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(InternalGroupBlockProvider,R(w({},i),{params:e}))}))},createGroupBlockSchema=i=>{const{collection:e,groupField:s}=i,n=[];e==null||e.fields.forEach(o=>{(o.interface==="number"||o.interface==="formula"&&o.dataType==="double")&&n.push({label:o.uiSchema.title,field:[o.name],aggregation:"sum",display:!0})});const r={title:e.title,type:"void","x-acl-action":`${e.name}:list`,"x-decorator":"GroupBlockProvider","x-decorator-props":{collection:e.name,resource_deprecated:"charts",action:"query",groupField:s,params:{collection:e.name,measures:n}},"x-toolbar":"GroupBlockToolbar","x-settings":"groupBlockSettings","x-component":"CardItem",properties:{[client$2.uid()]:{type:"void","x-component":"GroupBlock"}}};return n.length||delete r["x-decorator-props"].resource_deprecated,e.template==="view"&&!n.length&&(delete r["x-decorator-props"].action,delete r["x-decorator-props"].groupField),r},GroupBlockInitializer=()=>{const{insert:i}=client.useSchemaInitializer(),e=client.useCollectionManager(),s=client.useSchemaInitializerItem();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockInitializer,R(w({},s),{icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(GroupIcon,{}),onCreateBlockSchema:r=>P(this,[r],function*({item:n}){const o=e.getCollection(n.name);i(createGroupBlockSchema({collection:o}))})}))},groupBlockSettings=new client.SchemaSettings({name:"groupBlockSettings",items:[{name:"Configure",Component:"GroupBlockConfigure"},{name:"remove",type:"remove"}]}),GroupBlockToolbar=i=>{const e=schema.useFieldSchema();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaToolbar,w({title:e.title,settings:e["x-settings"]},i))},GroupBlockConfigure=schema.connect(i=>{var p;const{t:e}=useTranslation(),s=schema.useFieldSchema(),{dn:n}=client.useDesignable(),{service:r}=client.useBlockRequestContext(),o=(p=s["x-decorator-props"])==null?void 0:p.params,a=o==null?void 0:o.measures,l=transformers.option.filter(m=>m.value==="decimal")[0].childrens,c=a.map(m=>({label:m.label,value:m.field[0]})),{scope:d}=React.useContext(GroupBlockContext),u=modalSchema(e,o,c,l);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponentOptions,{scope:w({},d),components:{ArrayItems:components$1.ArrayItems,FormItem:components$1.FormItem,Space:components$1.Space,PullRequestOutlined:icons.PullRequestOutlined},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:e("Configure"),onSubmit:m=>{s["x-decorator-props"].params.config=[...m.configField],n.emit("patch",{schema:{"x-uid":s["x-uid"],"x-decorator-props":s["x-decorator-props"]}}),n.refresh(),r==null||r.refresh()},schema:u},"configure")})}),fieldType=[{label:"字段配置",value:"field"},{label:"请求配置",value:"custom"}],styleOption=[{label:"描述",value:"describe"},{label:"表格",value:"table"}],modalSchema=(i,e,s,n)=>({title:i("Configure Group"),type:"object",properties:{configField:{title:"Config Field",type:"array","x-decorator":"FormItem","x-component":"ArrayItems",default:e.config,items:{type:"object","x-decorator":"ArrayItems.Item",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},type:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("type")}}'},enum:fieldType,required:!0},field:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("field")}}'},"x-visbile":!1,required:!1,enum:s,"x-reactions":{dependencies:[".type"],fulfill:{schema:{required:"{{$deps[0]==='field'}}","x-visible":"{{$deps[0]==='field'}}"}}}},reqUrl:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("reqUrl")}}',addonBefore:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.PullRequestOutlined,{})},required:!1,"x-visible":!1,"x-reactions":{dependencies:[".type"],fulfill:{schema:{required:"{{$deps[0]==='custom'}}","x-visible":"{{$deps[0]==='custom'}}"}}}},format:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("format")}}'},enum:transformers.option,required:!0},digits:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("digits")}}'},enum:n,"x-visible":!1,"x-reactions":{dependencies:[".format"],fulfill:{schema:{"x-visible":"{{$deps[0]==='decimal'}}"}}}},style:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("style")}}'},enum:styleOption,required:!0},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:"Add","x-component":"ArrayItems.Addition"}}}}}),CurrencyFormat=(i,e="en-US",s=!1)=>{const n={"zh-CN":"CNY","en-US":"USD","ja-JP":"JPY","ko-KR":"KRW","pt-BR":"BRL","ru-RU":"RUB","tr-TR":"TRY","es-ES":"EUR"}[e];return s&&i&&(i=-i),new Intl.NumberFormat(e,{style:"currency",currency:n}).format(i)},transformers={option:[{label:"Percent",value:"pertent",component:(i,e="en-US")=>new Intl.NumberFormat(e,{style:"percent",minimumFractionDigits:2,maximumFractionDigits:2}).format(i)},{label:"Currency",value:"currency",component:CurrencyFormat},{label:"CurrencyNegative",value:"currencyNegative",component:(i,e="en-US")=>CurrencyFormat(i,e,!0)},{label:"Exponential",value:"exponential",component:i=>(+i).toExponential()},{label:"Abbreviation",value:"abbreviation",component:(i,e="en-US")=>new Intl.NumberFormat(e,{notation:"compact"}).format(i)},{label:"Decimal",value:"decimal",childrens:[{label:"1.0",value:"OneDigits",component:i=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:1,maximumFractionDigits:1}).format(i)},{label:"1.00",value:"TwoDigits",component:i=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}).format(i)},{label:"1.000",value:"ThreeDigits",component:i=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:3,maximumFractionDigits:3}).format(i)},{label:"1.0000",value:"FourDigits",component:i=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:4,maximumFractionDigits:4}).format(i)},{label:"1.00000",value:"FiveDigits",component:i=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:5,maximumFractionDigits:5}).format(i)}]}]},GroupBlock=i=>{const e=schema.useField(),n=schema.useFieldSchema().parent["x-decorator-props"].params,{service:r}=client.useBlockRequestContext(),{getDataBlocks:o}=client.useFilterBlock();if(r.params.length||o().map(a=>{Object.keys(a.defaultFilter).length&&o().forEach(l=>{l.uid!==a.uid&&l.collection.name===a.collection.name&&(r.params=a.defaultFilter)})}),r.loading&&!e.loaded)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Spin,{});if(!(!(n!=null&&n.config)||!("map"in n.config)))return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{style:{fontWeight:600},children:"汇总:"}),n==null?void 0:n.config.map((a,l)=>{if(a)return React.createElement(InternalGroupBlock,R(w({},i),{configItem:a,service:r,key:l}))})]})},fieldTransformers=(i,e,s)=>{const{option:n}=transformers,r=s.auth.getLocale();if(i){const o=i.format,a=i==null?void 0:i.digits;if(o&&o!=="decimal"){const l=n.find(c=>c.value===o).component;return e=String(e).includes(",")?String(e).replace(/,/g,""):e,l(e,r)}else if(o&&o==="decimal"&&a){const l=n.filter(c=>c.value==="decimal")[0].childrens.filter(c=>c.value===a)[0].component;return e=String(e).includes(",")?String(e).replace(/,/g,""):e,l(e)}}},InternalGroupBlock=i=>{const{configItem:e,service:s}=i,r=schema.useFieldSchema().parent["x-decorator-props"].params,[o,a]=React.useState({}),l=client.useAPIClient();if(ahooks.useAsyncEffect(()=>P(this,null,function*(){var d;const c=s!=null&&s.params[0]?s.params[0].filter:s==null?void 0:s.params;e.reqUrl&&a((d=yield l.request({url:e.reqUrl,method:"POST",data:{filter:w({},c),collection:r.collection}}))!=null?d:{})}),[s.params,s.params[0]]),e.style==="describe"){const c=describeItem(e,o,s,r,l);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{style:{marginBottom:"10px"},items:c})}else if(e.style==="table"){const{columns:c,options:d}=tableItem(e,o,s,r,l);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Table,{style:{marginBottom:"10px"},columns:c,dataSource:d,pagination:!1})}},describeItem=(i,e,s,n,r)=>{var a,l,c;const o=[];if(i.type==="field"){const d=(a=s.data)==null?void 0:a.data;if(d){let u=d.map(m=>m[i.field])[0];u=fieldTransformers(i,u,r);const p=n.measures.find(m=>m.field[0]===i.field).label;o.push({key:i.field,label:p,children:u})}}else if(i.type==="custom"&&Object.keys(e).length&&(l=e==null?void 0:e.data)!=null&&l.data){const d=w({},(c=e==null?void 0:e.data)==null?void 0:c.data),u=d.labels;d.values.forEach((p,m)=>{let f="";u.forEach((g,x)=>{x!==0&&(f+=`${g}${fieldTransformers(i,p[x],r)} `)}),o.push({key:m,label:p[0],children:f})})}return o},tableItem=(i,e,s,n,r)=>{var l,c,d;const o=[],a=[];if(i.type==="custom"){if(Object.keys(e).length&&((l=e==null?void 0:e.data)!=null&&l.data)){const u=w({},(c=e==null?void 0:e.data)==null?void 0:c.data);u.labels.forEach((p,m)=>{o.push({title:p,dataIndex:"value"+m,key:m})}),u.values.forEach((p,m)=>{const f={key:m};o.forEach((g,x)=>{const y=typeof p[x]=="string"?p[x]:fieldTransformers(i,p[x],r);f[g.dataIndex]=y}),a.push(f)})}}else if(i.type==="field"){const u=(d=s.data)==null?void 0:d.data;if(u){let p=u.map(f=>f[i.field])[0];p=fieldTransformers(i,p,r);const m=n.measures.find(f=>f.field[0]===i.field).label;o.push({title:"名称",dataIndex:"name",key:"name"},{title:"数量",dataIndex:"number",key:"number"}),a.push({key:m,name:m,number:p})}}return{columns:o,options:a}};class PluginGroupBlock extends client.Plugin{load(){return P(this,null,function*(){this.app.schemaInitializerManager.addItem("page:addBlock","dataBlocks.groupBlock",{title:tval("Group"),Component:"GroupBlockInitializer"}),this.schemaSettingsManager.add(groupBlockSettings),this.app.addComponents({GroupBlock,GroupBlockConfigure,GroupBlockInitializer,GroupBlockProvider,GroupBlockToolbar})})}}const SchemaSettingsAppends=()=>{const i=schema.useFieldSchema(),{fieldSchema:e}=client.useColumnSchema(),s=e!=null?e:i,{t:n}=useTranslation(),r=client.useCollection(),{dn:o}=client.useDesignable();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:"设置加载关联字段",scope:{fieldFilter(a){return["belongsTo","hasOne"].includes(a.type)}},schema:{type:"object",title:"设置加载关联字段",properties:{appends:{default:_.get(s,"x-component-props.appends",[]),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{placeholder:n("Select context"),popupMatchSelectWidth:!1,collection:`${r.dataSource&&r.dataSource!=="main"?`${r.dataSource}:`:""}${r.name}`,multiple:!0,allowClear:!1}}}},onSubmit:({appends:a})=>{_.set(s["x-component-props"],"appends",a!=null?a:[]),o.emit("patch",{schema:{"x-uid":s["x-uid"],"x-component-props":s["x-component-props"]}}),o.refresh()}},"appends")},customFieldComponentFieldSettings=new client.SchemaSettings({name:"fieldSettings:component:CustomField",items:[{name:"appends",Component:SchemaSettingsAppends}]});class PluginCustomComponents extends client.Plugin{load(){return P(this,null,function*(){this.schemaSettingsManager.add(customFieldComponentFieldSettings)})}}const UserDepartmentsFieldNotSupport=schema.connect(()=>{const{t:i}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{style:{color:"#ccc"},children:i("This field is currently not supported for use in form blocks.")})},schema.mapReadPretty(client.AssociationField.ReadPretty)),ContextDepartments=React.createContext({user:{},department:{},setShowChildren:()=>{}}),ProviderContextDepartments=ContextDepartments.Provider;function useContextDepartments(){return React.useContext(ContextDepartments)}const ProviderDepartmentIndex=({children:i})=>{const[e,s]=React.useState(null),[n,r]=React.useState(null),[o,a]=React.useState(!1),l=client.useRequest({resource:"users",action:"list",params:{appends:["departments","departments.parent(recursively=true)","mainDepartment","mainDepartment.parent(recursively=true)"],filter:n?{"departments.id":n.id,showChildren:o}:{},pageSize:50}},{manual:!0,refreshDeps:[n]}),c=client.useRequest({resource:"departments",action:"list",params:{pagination:!1,filter:{parentId:null}}}),d={user:e,setUser:s,department:n,setDepartment:r,showChildren:o,setShowChildren:a,usersResource:{service:l},departmentsResource:{service:c}};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ProviderContextDepartments,{value:d,children:i})},useDepartmentFilterActionProps=()=>{var r,o;const i=client.useCollection(),e=client.useFilterFieldOptions(i.fields),s=client.useResourceActionContext();return client.useFilterFieldProps({options:e,params:((o=(r=s.state)==null?void 0:r.params)==null?void 0:o[0])||s.params,service:s})},useDepTree=i=>{const{label:e}=i||{},[s,n]=React.useState([]),[r,o]=React.useState({}),[a,l]=React.useState([]),[c,d]=React.useState([]),u=React.useCallback(x=>{const y={},E=v=>{let A=v?w({},v):null;for(;A;){const D=A.parentId||"root";y[0]?y[D].childrenMap[A.id]=A:y[D]=R(w({},A.parent||{id:D}),{childrenMap:{[A.id]:A}}),A=A.parent}},b=v=>{const A={};v.children&&v.children.length&&v.children.forEach(D=>{A[D.id]=D,b(D)}),y[v.id]=R(w({},v),{childrenMap:A})};return x&&x.length&&x.forEach(v=>{E(v),b(v)}),y},[]),p=React.useCallback(x=>{const y=E=>{var b;return!x[E]||x[E].isLeaf?null:Object.values(((b=x[E])==null?void 0:b.childrenMap)||{}).map(v=>R(w({},v),{title:e?React.createElement(e,{node:v}):v.title,children:y(v.id)}))};return y("root")},[]),m=React.useCallback(x=>{const y=u(x);o(y);const E=p(y)||[];n(E)},[n,u,p]),f=(x,y)=>{const E=u(y),b=w(w({},E),r);return y.forEach(v=>{b[x].childrenMap[v.id]=v}),o(b),p(b)},g=React.useCallback(x=>{if(!r[x])return[];const y=[];return y.push(...Object.keys(r[x].childrenMap).map(E=>Number(E))),Object.keys(r[x].childrenMap).forEach(E=>{y.push(...g(E))}),y},[r]);return{initData:m,treeData:s,setTreeData:n,nodeMap:r,updateTreeData:f,constructTreeData:p,getChildrenIds:g,loadedKeys:c,setLoadedKeys:d,expandedKeys:a,setExpandedKeys:l}},useGetDepTree=i=>{const{resource:e="departments",resourceOf:s,params:n={}}=i||{},r=client.useAPIClient().resource(e,s),o=useDepTree(i),{setTreeData:a,updateTreeData:l,initData:c}=o,d=f=>P(this,[f],function*({key:p,children:m}){var x;if(m!=null&&m.length)return;const{data:g}=yield r.list(R(w({},n),{pagination:!1,appends:["parent(recursively=true)"],filter:{parentId:p}}));(x=g==null?void 0:g.data)!=null&&x.length&&a(l(p,g==null?void 0:g.data))}),u=p=>P(this,null,function*(){const{data:m}=yield r.list(R(w({},n),{pagination:!1,filter:{title:{$includes:p}},appends:["parent(recursively=true)"],pageSize:100}));c(m==null?void 0:m.data)});return R(w({},o),{loadData:d,getByKeyword:u})},getDepartmentStr=i=>{const e=i.title,s=i.parent;return s?getDepartmentStr(s)+"/"+e:e},InternalSuperiorDepartmentSelect=i=>{const e=schema.useField(),[s,n]=React.useState({label:null,value:null}),{treeData:r,initData:o,getByKeyword:a,loadData:l,loadedKeys:c,setLoadedKeys:d,originData:u}=i,p=m=>P(this,null,function*(){if(!m){o(u);return}yield a(m)});return React.useEffect(()=>{o(u)},[u,o]),React.useEffect(()=>{if(!e.value){n({label:null,value:null});return}n({label:getDepartmentStr(e.value)||e.value.label,value:e.value.id})},[e.value]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.TreeSelect,{value:s,onSelect:(m,f)=>{e.setValue(f)},onChange:m=>{m||e.setValue(null)},treeData:r,treeLoadedKeys:c,onTreeLoad:m=>d(m),loadData:m=>l({key:m.id,children:m.children}),fieldNames:{value:"id"},showSearch:!0,allowClear:!0,treeNodeFilterProp:"title",onSearch:p,labelInValue:!0})},DepartmentSelect=()=>{const i=useGetDepTree(),{departmentsResource:e}=useContextDepartments(),{service:s}=e||{},{data:n}=s||{};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(InternalSuperiorDepartmentSelect,R(w({},i),{originData:n==null?void 0:n.data}))},SuperiorDepartmentSelect=()=>{const i=useGetDepTree(),{setTreeData:e,getChildrenIds:s}=i,n=client.useRecord(),{departmentsResource:r}=useContextDepartments(),{service:{data:o}}=r||{};return React.useEffect(()=>{if(!n.id)return;const a=s(n.id);a.push(n.id),e(l=>{const c=d=>d.map(u=>(a.includes(u.id)&&(u.disabled=!0),u.children&&(u.children=c(u.children)),u));return c(l)})},[e,n.id,s]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(InternalSuperiorDepartmentSelect,w({},R(w({},i),{originData:o==null?void 0:o.data})))},ContextDepartmentsExpanded=React.createContext({}),ProviderContextDepartmentsExpanded=ContextDepartmentsExpanded.Provider;function useContextDepartmentsExpanded(){return React.useContext(ContextDepartmentsExpanded)}const getSchemaAddNewDepartment=()=>({type:"void",properties:{newDepartment:{type:"void",title:tval("New department"),"x-component":"Action","x-component-props":{type:"text",icon:"PlusOutlined",style:{width:"100%",textAlign:"left"}},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form",title:tval("New department"),properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem",required:!0},parent:{"x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"departments.parent","x-component-props":{component:"DepartmentSelect"}},roles:{"x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"departments.roles"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useCreateDepartment }}"}}}}}}}}}}),AddNewDepartment=()=>{const i=getSchemaAddNewDepartment();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:i})},schemaUnknownOwerns={type:"void",properties:{drawer:{title:'{{t("Select Owners")}}',"x-component":"Action.Drawer",properties:{resource:{type:"void","x-decorator":"FormItem","x-component":"RequestProvider",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{username:{$includes:""}},{nickname:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox",onChange:"{{ handleSelect }}"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{username:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},phone:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{phone:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},email:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{email:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},confirm:{title:'{{t("Confirm")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSelectOwners }}"}}}}}}}},ProviderRequest$1=i=>{const{field:e,record:s,children:n}=i;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ResourceActionProvider,{collection:"users",request:{resource:`departments/${s.id}/members`,action:"list",params:{filter:e.value.length?{id:{$notIn:e.value.map(r=>r.id)}}:{}}},children:n})},ViewUnKnownOwerns=i=>{const{record:e,field:s,handleSelect:n,useSelectOwners:r}=i,o=({children:a})=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ProviderRequest$1,{field:s,record:e,children:a});return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:schemaUnknownOwerns,components:{RequestProvider:o},scope:{department:e,handleSelect:n,useSelectOwners:r}})},DepartmentOwnersField=()=>{const[i,e]=React.useState(!1),s=client.useRecord(),n=schema.useField(),[r,o]=React.useState([]),a=React.useRef([]),l=(d,u)=>{a.current=u},c=()=>{const{setVisible:d}=client.useActionContext();return{run(){const u=n.value||[];n.setValue([...u,...a.current]),a.current=[],d(!1)}}};return React.useEffect(()=>{if(n.value){const d=n.value.map(u=>({value:u.id,label:u.nickname||u.username}));o(d)}},[n.value]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(client.ActionContextProvider,{value:{visible:i,setVisible:e},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Select,{open:!1,mode:"multiple",value:r,labelInValue:!0,onChange:d=>{if(d){const u=d.map(({label:p,value:m})=>({id:m,nickname:p}));n.setValue(u)}else{n.setValue([]);return}},onDropdownVisibleChange:d=>e(d)}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ViewUnKnownOwerns,{record:s,field:n,handleSelect:l,useSelectOwners:c})]})},useStyles=client.createStyles(({css:i})=>({searchDropdown:i`
53
- .ant-dropdown-menu {
54
- max-height: 500px;
55
- overflow-y: scroll;
56
- }
57
- `})),DepartmentsSearch=()=>{const{t:i}=useTranslation(),{token:e}=antd.theme.useToken(),{styles:s}=useStyles(),n=10,r=client.useAPIClient(),{setDepartment:o,setUser:a}=useContextDepartments(),[l,c]=React.useState(!1),[d,u]=React.useState(""),[p,m]=React.useState([]),[f,g]=React.useState([]),[x,y]=React.useState(!0),[E,b]=React.useState(!0),v=client.useRequest(M=>r.resource("departments").aggregateSearch(M).then(j=>{var W;return(W=j==null?void 0:j.data)==null?void 0:W.data}),{manual:!0,onSuccess:(M,j)=>{const{values:W}=j[0]||{},{type:U}=W||{};M&&((!U||U==="user"&&M.users.length<n)&&y(!1),(!U||U==="department"&&M.departments.length<n)&&b(!1),m(X=>[...X,...M.users]),g(X=>[...X,...M.departments]))}}),{run:A}=v,D=M=>{u(M),m([]),g([]),y(!0),b(!0),M&&(A({values:{keyword:M,limit:n}}),c(!0))},L=M=>{M.target.value||(a(null),u(""),c(!1),v.mutate({}),m([]),g([]))},I=M=>{const j=M.title,W=M.parent;return W?I(W)+" / "+j:j},O=M=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{type:"link",style:{padding:"0 8px"},onClick:j=>{c(!0),A({values:w({keyword:d,limit:n},M)})},children:i("Load more")}),z=()=>{const M=[];return!p.length&&!f.length?[{key:"0",label:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Empty,{description:i("No results"),image:antd.Empty.PRESENTED_IMAGE_SIMPLE}),disabled:!0}]:(p.length&&(M.push({key:"0",type:"group",label:i("Users"),children:p.map(j=>({key:j.username,label:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{onClick:()=>{},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{children:j.nickname||j.username}),",",__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{style:{fontSize:e.fontSizeSM,color:e.colorTextDescription},children:`${j.username}${j.phone?" | "+j.phone:""}${j.email?" | "+j.email:""}`})]})}))}),x&&M.push({type:"group",key:"0-loadMore",label:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(O,{type:"user",last:p[p.length-1].id})})),f.length&&(M.push({key:"1",type:"group",label:i("Departments"),children:f.map(j=>({key:j.id,label:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{onClick:()=>{o(j)},children:I(j)})}))}),E&&M.push({type:"group",key:"1-loadMore",label:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(O,{type:"department",last:f[f.length-1].id})})),M)};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Dropdown,{menu:{items:z()},overlayClassName:s.searchDropdown,trigger:["click"],open:l,onOpenChange:M=>c(M),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input.Search,{allowClear:!0,onClick:()=>{d||c(!1)},onFocus:()=>o(null),onSearch:D,onChange:L,placeholder:i("Search for departments, users"),style:{marginBottom:"20px"}})})},schemaDepartmentEdit={type:"object",properties:{[schema.uid()]:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(i){const e=client.useAPIClient(),s=client.useActionContext(),n=client.useRecord(),r=client.useRequest(()=>e.resource("departments").get({filterByTk:n.id,appends:["parent(recursively=true)","roles","owners"]}).then(o=>o==null?void 0:o.data),R(w({},i),{manual:!0}));return React.useEffect(()=>{s.visible&&r.run()},[s.visible]),r}},title:'{{t("Edit department")}}',properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem"},parent:{"x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"departments.parent","x-component-props":{component:"SuperiorDepartmentSelect"}},roles:{"x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"departments.roles"},owners:{title:'{{t("Owners")}}',"x-component":"DepartmentOwnersField","x-decorator":"FormItem"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useUpdateDepartment }}"}}}}}}}},schemaDepartmentNewSub={type:"object",properties:{[schema.uid()]:{title:'{{t("New sub department")}}',type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(i){const e=client.useActionContext(),s=client.useRecord();return client.useRequest(()=>Promise.resolve({data:{parent:w({},s)}}),R(w({},i),{refreshDeps:[e.visible]}))}},properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem"},parent:{"x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"departments.parent","x-component-props":{component:"DepartmentSelect"}},roles:{"x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"departments.roles"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useCreateDepartment }}"}}}}}}}},DepartmentsTree=()=>{const{data:i,loading:e}=client.useResourceActionContext(),{department:s,setDepartment:n,setUser:r}=useContextDepartments(),{treeData:o,nodeMap:a,loadData:l,loadedKeys:c,setLoadedKeys:d,initData:u,expandedKeys:p,setExpandedKeys:m}=useContextDepartmentsExpanded(),f=y=>P(this,null,function*(){if(!y.length)return;const E=a[y[0]];n(E),r(null)}),g=y=>{m(y)},x=y=>{d(y)};return React.useEffect(()=>{u(i==null?void 0:i.data)},[i,u,e]),React.useEffect(()=>{if(!s)return;const y=b=>b.parent?[b.parent.id,...y(b.parent)]:[],E=y(s);m(b=>Array.from(new Set([...b,...E])))},[s,m]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{className:client.css`
58
- height: 57vh;
59
- overflow: auto;
60
- .ant-tree-node-content-wrapper {
61
- overflow: hidden;
62
- }
63
- `,children:o!=null&&o.length?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Tree.DirectoryTree,{loadData:l,treeData:o,loadedKeys:c,onSelect:f,selectedKeys:[s==null?void 0:s.id],onExpand:g,onLoad:x,expandedKeys:p,expandAction:!1,showIcon:!1,fieldNames:{key:"id"}}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Empty,{image:antd.Empty.PRESENTED_IMAGE_SIMPLE})})},DepartmentsTreeItem=({node:i,setVisible:e,setDrawer:s})=>{const{t:n}=useTranslation(),{refreshAsync:r}=client.useResourceActionContext(),{setLoadedKeys:o,expandedKeys:a,setExpandedKeys:l}=useContextDepartmentsExpanded(),{modal:c,message:d}=antd.App.useApp(),u=client.useAPIClient(),p=()=>{c.confirm({title:n("Delete department"),content:n("Are you sure you want to delete it?"),onOk:()=>P(this,null,function*(){yield u.resource("departments").destroy({filterByTk:i.id}),d.success(n("Deleted successfully")),l(x=>x.filter(y=>y!==i.id));const g=[...a];o([]),l([]),yield r(),l(g)})})},m=g=>{s({schema:g,node:i}),e(!0)},f=({key:g,domeEvent:x})=>{switch(x==null||x.stopPropagation(),g){case"new-sub":m(schemaDepartmentNewSub);break;case"edit":m(schemaDepartmentEdit);break;case"delete":p()}};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{style:{display:"flex",justifyContent:"space-between",overflow:"hidden"},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i.title}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Dropdown,{menu:{items:[{label:n("New sub department"),key:"new-sub"},{label:n("Edit department"),key:"edit"},{label:n("Delete department"),key:"delete"}],onClick:f},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{style:{marginLeft:"15px"},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.MoreOutlined,{})})})]})};DepartmentsTree.Item=DepartmentsTreeItem;const useCreateDepartment=()=>{const i=schema.useForm(),e=schema.useField(),{setVisible:s}=client.useActionContext(),{refreshAsync:n}=client.useResourceActionContext(),r=client.useAPIClient(),{expandedKeys:o,setLoadedKeys:a,setExpandedKeys:l}=useContextDepartmentsExpanded();return{run(){return P(this,null,function*(){try{yield i.submit(),e.data=e.data||{},e.data.loading=!0,yield r.resource("departments").create({values:i.values}),s(!1),yield i.reset(),e.data.loading=!1;const d=[...o];a([]),l([]),yield n(),l(d)}catch(d){e.data&&(e.data.loading=!1)}})}}},useUpdateDepartment=()=>{const i=schema.useField(),e=schema.useForm(),{setVisible:s}=client.useActionContext(),{refreshAsync:n}=client.useResourceActionContext(),r=client.useAPIClient(),{id:o}=client.useRecord(),{expandedKeys:a,setLoadedKeys:l,setExpandedKeys:c}=useContextDepartmentsExpanded(),{department:d,setDepartment:u}=useContextDepartments();return{run(){return P(this,null,function*(){yield e.submit(),i.data=i.data||{},i.data.loading=!0;try{yield r.resource("departments").update({filterByTk:o,values:e.values}),u(w({department:d},e.values)),s(!1),yield e.reset();const m=[...a];l([]),c([]),yield n(),c(m)}catch(m){console.log(m)}finally{i.data.loading=!1}})}}},DepartmentsBlock=()=>{const{t:i}=useTranslation(),[e,s]=React.useState(!1),[n,r]=React.useState({}),{department:o,setDepartment:a}=useContextDepartments(),{token:l}=antd.theme.useToken(),d=useGetDepTree({label:({node:p})=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(DepartmentsTree.Item,{node:p,setVisible:s,setDrawer:r})}),u=n.schema||{};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponentOptions,{scope:{useCreateDepartment,useUpdateDepartment},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(ProviderContextDepartmentsExpanded,{value:d,children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Row,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(DepartmentsSearch,{}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{type:"text",icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.UserOutlined,{}),style:{textAlign:"left",marginBottom:"5px",background:o?"":l.colorBgTextHover},onClick:()=>{a(null)},block:!0,children:i("All users")}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(AddNewDepartment,{})]}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Divider,{style:{margin:"12px 0"}}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(DepartmentsTree,{}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionContextProvider,{value:{visible:e,setVisible:s},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RecordProvider,{record:n.node||{},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:u,components:{DepartmentOwnersField}})})})]})})},schemaAddMembers={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form",title:'{{t("Add members")}}',properties:{resource:{type:"void","x-decorator":"FormItem","x-component":"ResourceActionProvider","x-component-props":{collection:"users",request:{resource:"users",action:"listExcludeDept",params:{departmentId:"{{ department?.id }}"}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{username:{$includes:""}},{nickname:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox",onChange:"{{ handleSelect }}"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{username:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},phone:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{phone:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},email:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{email:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useAddMembersAction }}"}}}}}}}};function usePropsAddMembers(){const{department:i}=useContextDepartments(),{refresh:e}=client.useResourceActionContext(),s=React.useRef([]),n=client.useAPIClient();return{department:i,useAddMembersAction:()=>({run(){return P(this,null,function*(){const l=s.current;l!=null&&l.length&&(yield n.resource("departments.members",i.id).add({values:l}),s.current=[],e())})}}),handleSelect:a=>{s.current=a}}}const ViewAddMembers=()=>{const{department:i,useAddMembersAction:e,handleSelect:s}=usePropsAddMembers();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:schemaAddMembers,scope:{useAddMembersAction:e,department:i,handleSelect:s}})},DepartmentField=()=>{const{setDepartment:i}=useContextDepartments(),s=schema.useField().value||[],n=s.reduce((r,o)=>(r[o.id]=o,r),{});return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.EllipsisWithTooltip,{ellipsis:!0,children:s.map((r,o)=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{onClick:a=>{a.preventDefault(),i(n[r.id])},children:getDepartmentStr(r)}),o!==s.length-1?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("span",{style:{marginRight:4,color:"#aaa"},children:","}):""]},o))})},getSchemaDepartmentsUsersBlock=(i,e,s)=>{const n=e?{}:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},showChildren:{type:"boolean","x-component":"Select",enum:[{label:tval("Only display direct members of the department"),value:!1},{label:tval("Show all members"),value:!0}],"x-component-props":{defaultValue:!1,onChange:s},"x-align":"left"},actions:{type:"void","x-component":"MemberActions"}}}},r=i?{isOwner:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column","x-component-props":{style:{minWidth:100}},title:tval("Owner"),properties:{isOwner:{type:"boolean","x-component":"IsOwnerField"}}}}:{},o=i?{remove:{type:"void","x-component":"RowRemoveAction"}}:{};return{type:"void",properties:R(w({},n),{table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ useMembersDataSource }}",pagination:{showTotal:"{{ useShowTotal }}"}},properties:R(w({nickname:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},username:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},departments:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{departments:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},mainDepartment:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{mainDepartment:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}},r),{phone:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{phone:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},email:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{email:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:w({update:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2",title:'{{t("Configure")}}',properties:{departments:{title:'{{t("Departments")}}',"x-decorator":"FormItem","x-component":"UserDepartmentsField"}}}}}},o)}}}})}})}},IsOwnerField=()=>{var s;const{department:i}=useContextDepartments(),e=(s=client.useRecord().departments)==null?void 0:s.find(n=>(n==null?void 0:n.id)===(i==null?void 0:i.id));return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Checkbox.ReadPretty,{value:e==null?void 0:e.departmentsUsers.isOwner})},schemaMemberActions={type:"void","x-component":"Space",properties:{remove:{type:"void",title:'{{t("Remove")}}',"x-component":"Action","x-component-props":{icon:"UserDeleteOutlined",confirm:{title:"{{t('Remove members')}}",content:"{{t('Are you sure you want to remove these members?')}}"},style:{marginRight:8},useAction:"{{ useBulkRemoveMembersAction }}"}},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined",style:{marginRight:8}}},create:{type:"void",title:tval("Add members"),"x-component":"Action","x-component-props":{type:"primary",icon:"UserAddOutlined"},properties:{drawer:{type:"void","x-component":"AddMembers"}}}}};function useRefreshActionProps(){const i=client.useResourceActionContext();return{onClick(){return P(this,null,function*(){var s;(s=i==null?void 0:i.refresh)==null||s.call(i)})}}}const ViewMemberActions=i=>{const{department:e}=i;return e?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{scope:{useRefreshActionProps},schema:schemaMemberActions}):null},schemaRowRemoveAction={type:"void",properties:{remove:{title:'{{ t("Remove") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Remove member')}}",content:"{{t('Are you sure you want to remove it?')}}"},useAction:"{{ useRemoveMemberAction }}"}}}},useRemoveMemberAction=()=>{const i=client.useAPIClient(),{department:e}=useContextDepartments(),{id:s}=client.useRecord(),{refresh:n}=client.useResourceActionContext();return{run(){return P(this,null,function*(){yield i.resource("departments.members",e.id).remove({values:[s]}),n()})}}},ViewRowRemoveAction=i=>{const{t:e}=useTranslation(),{department:s}=i;return s?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:schemaRowRemoveAction,scope:{t:e,useRemoveMemberAction}}):null},useBulkRemoveMembersAction=()=>{const{t:i}=useTranslation(),{message:e}=antd.App.useApp(),s=client.useAPIClient(),{state:n,setState:r,refresh:o}=client.useResourceActionContext(),{department:a}=useContextDepartments();return{run(){return P(this,null,function*(){const c=n==null?void 0:n.selectedRowKeys;if(!(c!=null&&c.length)){e.warning(i("Please select members"));return}yield s.resource("departments.members",a.id).remove({values:c}),r({selectedRowKeys:[]}),o()})}}},useMembersDataSource=i=>{const{user:e}=useContextDepartments(),s=client.useResourceActionContext(),{onSuccess:n}=i;return React.useEffect(()=>{if(e){i==null||i.onSuccess({data:[e]});return}s.loading||n==null||n(s.data)},[e,s.loading]),s},useShowTotal=()=>{var n;const i=client.useResourceActionContext(),{data:e}=i,{t:s}=useTranslation();return s("Total {{count}} members",{count:(n=e==null?void 0:e.meta)==null?void 0:n.count})},getSchemaDepartmentTable=i=>{const{useDataSource:e}=i;return{type:"void",properties:{[schema.uid()]:{type:"void","x-component":"RequestProvider","x-component-props":{useDataSource:e},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},departments:{type:"array","x-component":"InternalDepartmentTable","x-component-props":{useDisabled:"{{ useDisabled }}"}}}}}}},ContextFilterKeys=React.createContext({}),ProviderContextFilterKeys=ContextFilterKeys.Provider;function useContextFilterKeys(){return React.useContext(ContextFilterKeys)}const useDisabledDefault=()=>({disabled:()=>!1}),InternalDepartmentTable=({useDisabled:i=useDisabledDefault})=>{const{t:e}=useTranslation(),s=client.useResourceActionContext(),{run:n,data:r,loading:o,defaultRequest:a}=s,{resource:l,resourceOf:c,params:d}=a||{},{treeData:u,initData:p,loadData:m}=useGetDepTree({resource:l,resourceOf:c,params:d}),f=schema.useField(),{disabled:g}=i(),{hasFilter:x,expandedKeys:y,setExpandedKeys:E}=useContextFilterKeys();React.useEffect(()=>{x||p(r==null?void 0:r.data)},[r,p,o,x]);const{count:b,page:v,pageSize:A}=(r==null?void 0:r.meta)||{},D={defaultPageSize:d==null?void 0:d.pageSize,total:b,current:v,pageSize:A};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Table,{rowKey:"id",columns:[{dataIndex:"title",title:e("Department name"),render:(L,I)=>x?getDepartmentStr(I):L}],rowSelection:{selectedRowKeys:((f==null?void 0:f.value)||[]).map(L=>L.id),onChange:(L,I)=>{var O;return(O=f==null?void 0:f.setValue)==null?void 0:O.call(f,I)},getCheckboxProps:()=>({disabled:g()})},pagination:R(w({},D),{showSizeChanger:!0,onChange(L,I){var O;n(R(w({},((O=s==null?void 0:s.params)==null?void 0:O[0])||{}),{page:L,pageSize:I}))}}),dataSource:x?(r==null?void 0:r.data)||[]:u,expandable:{onExpand:(L,I)=>{const O=I;m({key:O.id,children:O.children})},expandedRowKeys:y,onExpandedRowsChange:L=>E(L)}})},collectionDepartments={name:"departments",fields:[{interface:"id",type:"bigInt",name:"id",primaryKey:!0,autoIncrement:!0,uiSchema:{type:"id",title:'{{t("ID")}}'}},{interface:"input",type:"string",name:"title",uiSchema:{type:"string",title:'{{t("Department name")}}',"x-component":"Input",required:!0}},{interface:"m2o",type:"belongsTo",name:"parent",collectionName:"departments",foreignKey:"parentId",target:"departments",targetKey:"id",treeParent:!0,uiSchema:{title:'{{t("Superior department")}}',"x-component":"DepartmentSelect"}},{interface:"m2m",type:"belongsToMany",name:"roles",target:"roles",collectionName:"departments",through:"departmentsRoles",foreignKey:"departmentId",otherKey:"roleName",targetKey:"name",sourceKey:"id",uiSchema:{title:'{{t("Roles")}}',"x-component":"AssociationField","x-component-props":{multiple:!0,fieldNames:{label:"title",value:"name"}}}},{interface:"m2m",type:"belongsToMany",name:"owners",collectionName:"departments",target:"users",through:"departmentsUsers",foreignKey:"departmentId",otherKey:"userId",targetKey:"id",sourceKey:"id",scope:{isOwner:!0},uiSchema:{title:'{{t("Owners")}}',"x-component":"AssociationField","x-component-props":{multiple:!0,fieldNames:{label:"nickname",value:"id"}}}}]},ProviderRequest=i=>{const[e,s]=React.useState([]),[n,r]=React.useState(!1),{useDataSource:o}=i,a=o({manual:!0});return React.useEffect(()=>{a.run({filter:{parentId:null},pageSize:10})},[]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ResourceActionContext.Provider,{value:a,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.CollectionProvider_deprecated,{collection:collectionDepartments,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ProviderContextFilterKeys,{value:{expandedKeys:e,setExpandedKeys:s,hasFilter:n,setHasFilter:r},children:i.children})})})},useFilterActionProps=()=>{const{setHasFilter:i,setExpandedKeys:e}=useContextFilterKeys(),{t:s}=useTranslation(),n=React.useContext(client.CollectionContext),r=client.useFilterFieldOptions(n.fields),o=client.useResourceActionContext(),{run:a,defaultRequest:l}=o,c=schema.useField(),{params:d}=l||{};return{options:r,onSubmit:u=>P(this,null,function*(){const p=d.filter,m=client.removeNullCondition(u==null?void 0:u.filter);a(R(w({},d),{page:1,pageSize:10,filter:client.mergeFilter([m,p])}));const f=(m==null?void 0:m.$and)||(m==null?void 0:m.$or);f!=null&&f.length?(c.title=s("{{count}} filter items",{count:(f==null?void 0:f.length)||0}),i(!0)):(c.title=s("Filter"),i(!1))}),onReset(){a(R(w({},d),{filter:R(w({},(d==null?void 0:d.filter)||{}),{parentId:null}),page:1,pageSize:10})),c.title=s("Filter"),i(!1),e([])}}},ViewDepartmentTable=({useDataSource:i,useDisabled:e})=>{const s=getSchemaDepartmentTable({useDataSource:i});return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:s,components:{RequestProvider:ProviderRequest,InternalDepartmentTable},scope:{useDisabled:e,useFilterActionProps}})},useDataSource$1=i=>{const e={resource:"departments",action:"list",params:{appends:["parent(recursively=true)"],sort:["createdAt"]}},s=client.useRequest(e,i);return R(w({},s),{defaultRequest:e})},schemaUserSelectDepartment={type:"void",properties:{drawer:{title:'{{t("Select Departments")}}',"x-decorator":"Form","x-component":"Action.Drawer",properties:{table:{type:"void","x-decorator":"FormItem","x-component":"DepartmentTable","x-component-props":{useDataSource:"{{ useDataSource }}",useDisabled:"{{ useDisabled }}"}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},confirm:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useAddDepartments }}"}}}}}}}},ViewUserSelectDepartment=i=>{const{t:e}=useTranslation(),{user:s,useAddDepartments:n,useDisabled:r}=i;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:schemaUserSelectDepartment,components:{DepartmentTable:ViewDepartmentTable},scope:{t:e,user:s,useDataSource:useDataSource$1,useAddDepartments:n,useDisabled:r}},2)},UserDepartmentsField=()=>{const{modal:i,message:e}=antd.App.useApp(),s=client.useAPIClient(),{t:n}=useTranslation(),[r,o]=React.useState(!1),a=client.useRecord(),l=schema.useField(),{refresh:c}=client.useResourceActionContext(),d=(E=[])=>E.map(b=>{var v,A;return R(w({},b),{title:getDepartmentStr(b),isMain:(v=b.departmentsUsers)==null?void 0:v.isMain,isOwner:(A=b.departmentsUsers)==null?void 0:A.isOwner})});client.useRequest(()=>s.resource("users.departments",a.id).list({appends:["parent(recursively=true)"],pagination:!1}).then(E=>{var v;const b=d((v=E==null?void 0:E.data)==null?void 0:v.data);l.setValue(b)}),{ready:a.id});const u=()=>{const E=client.useAPIClient(),b=schema.useForm(),{departments:v}=b.values||{};return{run(){return P(this,null,function*(){yield E.resource("users.departments",a.id).add({values:v.map(D=>D.id)}),b.reset(),l.setValue([...l.value,...v.map((D,L)=>R(w({},D),{isMain:L===0&&l.value.length===0,title:getDepartmentStr(D)}))]),o(!1),c()})}}},p=E=>{i.confirm({title:n("Remove department"),content:n("Are you sure you want to remove it?"),onOk:()=>P(this,null,function*(){yield s.resource("users.departments",a.id).remove({values:[E.id]}),e.success(n("Deleted successfully")),l.setValue(l.value.filter(b=>b.id!==E.id).map((b,v)=>R(w({},b),{isMain:E.isMain&&v===0||b.isMain}))),c()})})},m=E=>P(this,null,function*(){yield s.resource("users").setMainDepartment({values:{userId:a.id,departmentId:E.id}}),e.success(n("Set successfully")),l.setValue(l.value.map(b=>R(w({},b),{isMain:b.id===E.id}))),c()}),f=E=>P(this,null,function*(){yield s.resource("departments").setOwner({values:{userId:a.id,departmentId:E.id}}),e.success(n("Set successfully")),l.setValue(l.value.map(b=>R(w({},b),{isOwner:b.id===E.id?!0:b.isOwner}))),c()}),g=E=>P(this,null,function*(){yield s.resource("departments").removeOwner({values:{userId:a.id,departmentId:E.id}}),e.success(n("Set successfully")),l.setValue(l.value.map(b=>R(w({},b),{isOwner:b.id===E.id?!1:b.isOwner}))),c()}),x=(E,b)=>{switch(E){case"setMain":m(b);break;case"setOwner":f(b);break;case"removeOwner":g(b);break;case"remove":p(b)}},y=()=>({disabled:E=>E&&l.value.some(b=>b.id===E.id)});return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(client.ActionContextProvider,{value:{visible:r,setVisible:o},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(React.Fragment,{children:[((l==null?void 0:l.value)||[]).map(E=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Tag,{style:{padding:"5px 8px",background:"transparent",marginBottom:"5px"},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("span",{style:{marginRight:"5px"},children:E.title}),E.isMain?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Tag,{color:"processing",bordered:!1,children:n("Main")}):"",__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Dropdown,{menu:{items:[...E.isMain?[]:[{key:"setMain",label:n("Set as main department")}],{key:"remove",label:n("Remove")}],onClick:({key:b})=>x(b,E)},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{style:{float:"right"},children:[" ",__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.MoreOutlined,{})]})})]},E.id)),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.PlusOutlined,{}),onClick:()=>o(!0)},1)]}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ViewUserSelectDepartment,{user:a,useAddDepartments:u,useDisabled:y})]})},ViewDepartmentsUsersBlock=()=>{var p;const{t:i}=useTranslation(),{department:e,user:s,setShowChildren:n,showChildren:r}=useContextDepartments(),{data:o,setState:a,refresh:l}=client.useResourceActionContext(),c=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ViewMemberActions,{department:e}),d=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ViewRowRemoveAction,{department:e}),u=React.useMemo(()=>getSchemaDepartmentsUsersBlock(e,s,n),[e==null?void 0:e.id,s,n]);return React.useEffect(()=>{a==null||a({selectedRowKeys:[]})},[o,a]),React.useEffect(()=>{l==null||l()},[e==null?void 0:e.id,s,r]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("h2",{children:i(s?"Search results":(p=e==null?void 0:e.title)!=null?p:"All users")}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:u,components:{MemberActions:c,AddMembers:ViewAddMembers,RowRemoveAction:d,DepartmentField,IsOwnerField,UserDepartmentsField},scope:{useBulkRemoveMembersAction,useMembersDataSource,useShowTotal,useFilterActionProps:useDepartmentFilterActionProps}})]})},ProviderDepartmentsResource=({children:i})=>{const e=useContextDepartments(),{departmentsResource:s}=e,{service:n}=s||{};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ResourceActionContext.Provider,{value:w({},n),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.CollectionProvider_deprecated,{collection:collectionDepartments,children:i})})},collectionUsers={name:"users",fields:[{interface:"id",type:"bigInt",name:"id",primaryKey:!0,autoIncrement:!0,allowNull:!1,uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"InputNumber","x-read-pretty":!0}},{interface:"input",type:"string",name:"nickname",uiSchema:{type:"string",title:'{{t("Nickname")}}',"x-component":"Input"}},{interface:"input",type:"string",name:"username",unique:!0,uiSchema:{type:"string",title:'{{t("Username")}}',"x-component":"Input","x-validator":{username:!0},required:!0}},{interface:"email",type:"string",name:"email",unique:!0,uiSchema:{type:"string",title:'{{t("Email")}}',"x-component":"Input","x-validator":"email",required:!0}},{interface:"phone",type:"string",name:"phone",unique:!0,uiSchema:{type:"string",title:'{{t("Phone")}}',"x-component":"Input","x-validator":"phone",required:!0}},{interface:"m2m",type:"belongsToMany",name:"roles",target:"roles",foreignKey:"userId",otherKey:"roleName",onDelete:"CASCADE",sourceKey:"id",targetKey:"name",through:"rolesUsers",uiSchema:{type:"array",title:'{{t("Roles")}}',"x-component":"AssociationField","x-component-props":{multiple:!0,fieldNames:{label:"title",value:"name"}}}},{interface:"m2m",type:"belongsToMany",name:"departments",target:"departments",foreignKey:"userId",otherKey:"departmentId",onDelete:"CASCADE",sourceKey:"id",targetKey:"id",through:"departmentsUsers",uiSchema:{type:"array",title:'{{t("Departments")}}',"x-component":"DepartmentField"}},{interface:"m2m",type:"belongsToMany",name:"mainDepartment",target:"departments",foreignKey:"userId",otherKey:"departmentId",onDelete:"CASCADE",sourceKey:"id",targetKey:"id",through:"departmentsUsers",throughScope:{isMain:!0},uiSchema:{type:"array",title:'{{t("Main department")}}',"x-component":"DepartmentField"}}]},ProviderUserResource=({children:i})=>{const{usersResource:e}=useContextDepartments(),{service:s}=e||{};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ResourceActionContext.Provider,{value:w({},s),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.CollectionProvider_deprecated,{collection:collectionUsers,children:i})})},DepartmentManagement=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponentOptions,{components:{SuperiorDepartmentSelect,DepartmentSelect},scope:{useFilterActionProps:useDepartmentFilterActionProps},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Row,{gutter:48,style:{flexWrap:"nowrap"},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Col,{span:6,style:{borderRight:"1px solid #eee",minWidth:"300px"},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ProviderDepartmentsResource,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(DepartmentsBlock,{})})}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Col,{flex:"auto",style:{overflow:"hidden"},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ProviderUserResource,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ViewDepartmentsUsersBlock,{})})})]})}),schemaDepartmentManagement={type:"void",properties:{[schema.uid()]:{type:"void","x-decorator":"CardItem","x-component":"DepartmentManagement"}}},ViewDepartmentManagement=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:schemaDepartmentManagement,components:{DepartmentManagement}}),DepartmentIndex=()=>{const i=client.useSchemaComponentContext();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponentContext.Provider,{value:R(w({},i),{designable:!1}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ProviderDepartmentIndex,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ViewDepartmentManagement,{})})})};class KitMainTabDepartments extends client.Plugin{load(){return P(this,null,function*(){this.app.systemSettingsManager.add("id-auth.departments",{icon:"ApartmentOutlined",title:tval("Departments"),sort:2,aclSnippet:"pm.departments",Component:DepartmentIndex})})}}const getSchemaDepartments=()=>({type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{[schema.uid()]:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},actions:{type:"void","x-component":"Space",properties:{remove:{type:"void",title:'{{t("Remove")}}',"x-component":"Action","x-component-props":{icon:"MinusOutlined",confirm:{title:"{{t('Remove')}}",content:"{{t('Are you sure you want to remove these departments?')}}"},style:{marginRight:8},useAction:"{{ useBulkRemoveDepartments }}"}},create:{type:"void",title:'{{t("Add departments")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2",title:'{{t("Add departments")}}',properties:{table:{type:"void","x-decorator":"FormItem","x-component":"DepartmentTable","x-component-props":{useDataSource:"{{ useDataSource }}",useDisabled:"{{ useDisabled }}"}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useAddDepartments }}"}}}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void",title:'{{t("Department name")}}',"x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"DepartmentTitle"}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{remove:{type:"void",title:'{{ t("Remove") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Remove department')}}",content:"{{t('Are you sure you want to remove it?')}}"},useAction:"{{ useRemoveDepartment }}"}}}}}}}}}}),DepartmentTitle=()=>{const i=client.useRecord(),e=getTitle(i);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:e})};function getTitle(i){const{title:e,parent:s}=i;return s?getTitle(s)+" /"+e:e}const useAddDepartments=()=>{const{role:i}=React.useContext(PluginACLClient.RolesManagerContext),e=client.useAPIClient(),s=schema.useForm(),{setVisible:n}=client.useActionContext(),{refresh:r}=client.useResourceActionContext(),{departments:o}=s.values||{};return{run(){return P(this,null,function*(){yield e.resource("roles.departments",i.name).add({values:o.map(c=>c.id)}),s.reset(),n(!1),r()})}}},useBulkRemoveDepartments=()=>{const i=client.useAPIClient(),{t:e}=useTranslation(),{message:s}=antd.App.useApp(),{state:n,setState:r,refresh:o}=client.useResourceActionContext(),{role:a}=React.useContext(PluginACLClient.RolesManagerContext);return{run(){return P(this,null,function*(){const c=n==null?void 0:n.selectedRowKeys;if(!(c!=null&&c.length)){s.warning(e("Please select departments"));return}yield i.resource(`roles/${a==null?void 0:a.name}/departments`).remove({values:c}),r==null||r({selectedRowKeys:[]}),o()})}}},useDataSource=i=>{const e={resource:"departments",action:"list",params:{appends:["roles","parent(recursively=true)"],sort:["createdAt"]}},s=client.useRequest(e,i);return R(w({},s),{defaultRequest:e})},useDisabled=()=>{const{role:i}=React.useContext(PluginACLClient.RolesManagerContext);return{disabled:e=>{var s;return(s=e==null?void 0:e.roles)==null?void 0:s.some(n=>n.name===(i==null?void 0:i.name))}}},useRemoveDepartment=()=>{const i=client.useAPIClient(),{role:e}=React.useContext(PluginACLClient.RolesManagerContext),s=client.useRecord(),{refresh:n}=client.useResourceActionContext();return{run(){return P(this,null,function*(){yield i.resource(`roles/${e==null?void 0:e.name}/departments`).remove({values:[s.id]}),n()})}}},Departments=()=>{const{role:i}=React.useContext(PluginACLClient.RolesManagerContext),e=client.useRequest({resource:`roles/${i==null?void 0:i.name}/departments`,action:"list",params:{appends:["parent","parent.parent(recursively=true)"]}},{ready:!!i,refreshDeps:[i]}),s=React.useMemo(()=>getSchemaDepartments(),[i]);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ResourceActionContext.Provider,{value:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.CollectionProvider_deprecated,{collection:collectionDepartments,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:s,components:{DepartmentTable:ViewDepartmentTable,DepartmentTitle},scope:{useFilterActionProps:useDepartmentFilterActionProps,useRemoveDepartment,useBulkRemoveDepartments,useDataSource,useDisabled,useAddDepartments}})})})};class KitRoleAuth extends client.Plugin{load(){return P(this,null,function*(){this.app.pm.get(PluginACLClient).rolesManager.add("departments",{title:tval("Departments"),Component:Departments})})}}const enableLinkItem={name:"enableLink",type:"switch",useVisible(){return schema.useField().readPretty},useComponentProps(){var a;const{t:i}=useTranslation(),e=schema.useField(),{fieldSchema:s}=client.useColumnSchema(),n=schema.useFieldSchema(),r=s||n,{dn:o}=client.useDesignable();return{title:i("Enable link"),checked:((a=r["x-component-props"])==null?void 0:a.enableLink)!==!1,onChange(l){r["x-component-props"]=R(w({},r==null?void 0:r["x-component-props"]),{enableLink:l}),e.componentProps.enableLink=l,o.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component-props":w({},r==null?void 0:r["x-component-props"])}}),o.refresh()}}}},modeSelectItem={name:"fieldComponent",type:"select",useComponentProps(){const{t:i}=useTranslation(),e=schema.useField(),{fieldSchema:s,collectionField:n}=client.useColumnSchema(),r=schema.useFieldSchema(),o=s||r,a=client.useFieldModeOptions({fieldSchema:s,collectionField:n}),{dn:l}=client.useDesignable();return{title:i("Field component"),options:a,value:"Select",onChange(c){const d={"x-uid":o["x-uid"]};o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].mode=c,d["x-component-props"]=o["x-component-props"],e.componentProps=e.componentProps||{},e.componentProps.mode=c,l.emit("patch",{schema:d}),l.refresh()}}}},titleFieldItem={name:"titleField",type:"select",useComponentProps(){var p,m,f,g;const{t:i}=useTranslation(),e=schema.useField(),{dn:s}=client.useDesignable(),n=client.useTitleFieldOptions(),{fieldSchema:r,collectionField:o}=client.useColumnSchema(),a=schema.useFieldSchema(),l=r||a,c=client.useCollectionField(),d=o||c,u=((p=e==null?void 0:e.componentProps)==null?void 0:p.fieldNames)||((m=l==null?void 0:l["x-component-props"])==null?void 0:m.fieldNames)||((g=(f=d==null?void 0:d.uiSchema)==null?void 0:f["x-component-props"])==null?void 0:g.fieldNames);return{title:i("Title field"),options:n,value:u==null?void 0:u.label,onChange(x){var v,A,D,L,I,O;const y={"x-uid":l["x-uid"]},E=R(w(w({},(A=(v=d==null?void 0:d.uiSchema)==null?void 0:v["x-component-props"])==null?void 0:A.fieldNames),(D=l==null?void 0:l["x-component-props"])==null?void 0:D.fieldNames),{label:x});l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].fieldNames=E,y["x-component-props"]=l["x-component-props"],e.componentProps.fieldNames=(L=l["x-component-props"])==null?void 0:L.fieldNames;const b=(O=e.path)==null?void 0:O.splice(((I=e.path)==null?void 0:I.length)-1,1);e.form.query(`${b.concat("*."+l.name)}`).forEach(z=>{z.componentProps.fieldNames=E.label}),s.emit("patch",{schema:y}),s.refresh()}}}},DepartmentOwnersFieldSetting=new client.SchemaSettings({name:"fieldSettings:component:DepartmentOwnersField",items:[modeSelectItem,titleFieldItem,enableLinkItem]}),UserDepartmentsFieldSetting=new client.SchemaSettings({name:"fieldSettings:component:UserDepartmentsField",items:[modeSelectItem,titleFieldItem,enableLinkItem]}),UserMainDepartmentFieldSetting=new client.SchemaSettings({name:"fieldSettings:component:UserMainDepartmentField",items:[modeSelectItem,titleFieldItem,enableLinkItem]});class DepartmentsPlugin extends client.Plugin{afterAdd(){return P(this,null,function*(){this.pm.add(KitMainTabDepartments),this.pm.add(KitRoleAuth)})}load(){return P(this,null,function*(){this.app.addComponents({UserDepartmentsField:UserDepartmentsFieldNotSupport,UserMainDepartmentField:UserDepartmentsFieldNotSupport,DepartmentOwnersField:UserDepartmentsFieldNotSupport}),this.app.schemaSettingsManager.add(UserDepartmentsFieldSetting),this.app.schemaSettingsManager.add(UserMainDepartmentFieldSetting),this.app.schemaSettingsManager.add(DepartmentOwnersFieldSetting)})}}const EmbedLayout=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Layout,{style:{height:"100%"},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Layout.Content,{className:client.css`
52
+ `,e),children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ModalHeader,{title:s,onOk:o,onCancel:l}),r]}),document.body):null};ModalFullScreen.displayName="ModalFullScreen";const ExcelFileComponent=n=>{const{title:e,disabled:s,value:i,onChange:r}=n,o=React.useRef(),[l,a]=React.useState(!1),c=()=>{a(!0)},d=()=>{a(!1)},u=()=>{const f=o.current.getData();r(f),a(!1)};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{type:"primary",onClick:c,children:s?"查看":"编辑"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ModalFullScreen,{title:e!=null?e:"Excel",open:l,onOk:u,onCancel:d,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ExcelSheet,{ref:o,data:i||[]})})]})},ExcelFile=schema.connect(ExcelFileComponent,schema.mapProps(n=>A({},n))),GroupBlockContext=React.createContext({}),GroupSvg=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("svg",{viewBox:"0 0 1024 1024",width:"1em",height:"1em",fill:"currentColor",children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("path",{d:"M833.179846 36.584242h-73.160824a36.516572 36.516572 0 0 0 0 73.160824h73.160824c20.173491 0 36.516572 16.343081 36.516572 36.580412v768.060967a36.580412 36.580412 0 0 1-36.516572 36.580412H174.860114a36.580412 36.580412 0 0 1-36.580412-36.580412V146.325478c0-20.173491 16.343081-36.580412 36.580412-36.580412h73.160824a36.516572 36.516572 0 1 0 0-73.160824H174.860114A109.805076 109.805076 0 0 0 65.118879 146.325478v768.060967c0 60.584312 49.156923 109.741235 109.741235 109.741235h658.383572a109.805076 109.805076 0 0 0 109.677395-109.741235V146.325478A109.805076 109.805076 0 0 0 833.179846 36.584242z",fill:"#2C2C2C"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("path",{d:"M357.826013 146.325478h292.451774a36.516572 36.516572 0 0 0 36.580412-36.580412V36.584242A36.516572 36.516572 0 0 0 650.277787 0.00383H357.826013a36.516572 36.516572 0 0 0-36.580412 36.580412v73.160824c0 20.173491 16.343081 36.580412 36.580412 36.580412z m-36.708092 622.888443a36.580412 36.580412 0 0 0 36.580412-36.580412V512.065755a36.516572 36.516572 0 1 0-73.096984 0v220.567754c0 20.173491 16.279241 36.580412 36.516572 36.580412z m146.321647-330.308989v293.728577a36.580412 36.580412 0 1 0 73.160824 0V438.904932a36.580412 36.580412 0 1 0-73.160824 0z m182.838219-146.321647v440.050224a36.644252 36.644252 0 0 0 73.160824 0V292.583285a36.644252 36.644252 0 0 0-73.160824 0z",fill:"#2C2C2C"})]}),GroupIcon=n=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Icon,A({type:"",component:GroupSvg},n)),InternalGroupBlockProvider=n=>{const e=schema.useField(),{resource:s,service:i}=client.useBlockRequestContext(),[r,o]=React.useState(!1);return i.loading&&!e.loaded?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Spin,{}):(e.loaded=!0,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(GroupBlockContext.Provider,{value:{props:{resource:n.resource},field:e,service:i,resource:s,visible:r,setVisible:o},children:n.children}))},GroupBlockProvider=n=>{const e=A({},n.params);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.BlockProvider,I(A({name:"group"},n),{params:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(InternalGroupBlockProvider,I(A({},n),{params:e}))}))},createGroupBlockSchema=n=>{const{collection:e,groupField:s}=n,i=[];e==null||e.fields.forEach(o=>{(o.interface==="number"||o.interface==="formula"&&o.dataType==="double")&&i.push({label:o.uiSchema.title,field:[o.name],aggregation:"sum",display:!0})});const r={title:e.title,type:"void","x-acl-action":`${e.name}:list`,"x-decorator":"GroupBlockProvider","x-decorator-props":{collection:e.name,resource_deprecated:"charts",action:"query",groupField:s,params:{collection:e.name,measures:i}},"x-toolbar":"GroupBlockToolbar","x-settings":"groupBlockSettings","x-component":"CardItem",properties:{[client$2.uid()]:{type:"void","x-component":"GroupBlock"}}};return i.length||delete r["x-decorator-props"].resource_deprecated,e.template==="view"&&!i.length&&(delete r["x-decorator-props"].action,delete r["x-decorator-props"].groupField),r},GroupBlockInitializer=()=>{const{insert:n}=client.useSchemaInitializer(),e=client.useCollectionManager(),s=client.useSchemaInitializerItem();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockInitializer,I(A({},s),{icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(GroupIcon,{}),onCreateBlockSchema:r=>R(this,[r],function*({item:i}){const o=e.getCollection(i.name);n(createGroupBlockSchema({collection:o}))})}))},groupBlockSettings=new client.SchemaSettings({name:"groupBlockSettings",items:[{name:"Configure",Component:"GroupBlockConfigure"},{name:"remove",type:"remove"}]}),GroupBlockToolbar=n=>{const e=schema.useFieldSchema();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaToolbar,A({title:e.title,settings:e["x-settings"]},n))},GroupBlockConfigure=schema.connect(n=>{var f;const{t:e}=useTranslation(),s=schema.useFieldSchema(),{dn:i}=client.useDesignable(),{service:r}=client.useBlockRequestContext(),o=(f=s["x-decorator-props"])==null?void 0:f.params,l=o==null?void 0:o.measures,a=transformers.option.filter(m=>m.value==="decimal")[0].childrens,c=l.map(m=>({label:m.label,value:m.field[0]})),{scope:d}=React.useContext(GroupBlockContext),u=modalSchema(e,o,c,a);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponentOptions,{scope:A({},d),components:{ArrayItems:components$1.ArrayItems,FormItem:components$1.FormItem,Space:components$1.Space,PullRequestOutlined:icons.PullRequestOutlined},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:e("Configure"),onSubmit:m=>{s["x-decorator-props"].params.config=[...m.configField],i.emit("patch",{schema:{"x-uid":s["x-uid"],"x-decorator-props":s["x-decorator-props"]}}),i.refresh(),r==null||r.refresh()},schema:u},"configure")})}),fieldType=[{label:"字段配置",value:"field"},{label:"请求配置",value:"custom"}],styleOption=[{label:"描述",value:"describe"},{label:"表格",value:"table"}],modalSchema=(n,e,s,i)=>({title:n("Configure Group"),type:"object",properties:{configField:{title:"Config Field",type:"array","x-decorator":"FormItem","x-component":"ArrayItems",default:e.config,items:{type:"object","x-decorator":"ArrayItems.Item",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},type:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("type")}}'},enum:fieldType,required:!0},field:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("field")}}'},"x-visbile":!1,required:!1,enum:s,"x-reactions":{dependencies:[".type"],fulfill:{schema:{required:"{{$deps[0]==='field'}}","x-visible":"{{$deps[0]==='field'}}"}}}},reqUrl:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("reqUrl")}}',addonBefore:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.PullRequestOutlined,{})},required:!1,"x-visible":!1,"x-reactions":{dependencies:[".type"],fulfill:{schema:{required:"{{$deps[0]==='custom'}}","x-visible":"{{$deps[0]==='custom'}}"}}}},format:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("format")}}'},enum:transformers.option,required:!0},digits:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("digits")}}'},enum:i,"x-visible":!1,"x-reactions":{dependencies:[".format"],fulfill:{schema:{"x-visible":"{{$deps[0]==='decimal'}}"}}}},style:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("style")}}'},enum:styleOption,required:!0},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:"Add","x-component":"ArrayItems.Addition"}}}}}),CurrencyFormat=(n,e="en-US",s=!1)=>{const i={"zh-CN":"CNY","en-US":"USD","ja-JP":"JPY","ko-KR":"KRW","pt-BR":"BRL","ru-RU":"RUB","tr-TR":"TRY","es-ES":"EUR"}[e];return s&&n&&(n=-n),new Intl.NumberFormat(e,{style:"currency",currency:i}).format(n)},transformers={option:[{label:"Percent",value:"pertent",component:(n,e="en-US")=>new Intl.NumberFormat(e,{style:"percent",minimumFractionDigits:2,maximumFractionDigits:2}).format(n)},{label:"Currency",value:"currency",component:CurrencyFormat},{label:"CurrencyNegative",value:"currencyNegative",component:(n,e="en-US")=>CurrencyFormat(n,e,!0)},{label:"Exponential",value:"exponential",component:n=>(+n).toExponential()},{label:"Abbreviation",value:"abbreviation",component:(n,e="en-US")=>new Intl.NumberFormat(e,{notation:"compact"}).format(n)},{label:"Decimal",value:"decimal",childrens:[{label:"1.0",value:"OneDigits",component:n=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:1,maximumFractionDigits:1}).format(n)},{label:"1.00",value:"TwoDigits",component:n=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}).format(n)},{label:"1.000",value:"ThreeDigits",component:n=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:3,maximumFractionDigits:3}).format(n)},{label:"1.0000",value:"FourDigits",component:n=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:4,maximumFractionDigits:4}).format(n)},{label:"1.00000",value:"FiveDigits",component:n=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:5,maximumFractionDigits:5}).format(n)}]}]},GroupBlock=n=>{const e=schema.useField(),i=schema.useFieldSchema().parent["x-decorator-props"].params,{service:r}=client.useBlockRequestContext(),{getDataBlocks:o}=client.useFilterBlock();if(r.params.length||o().map(l=>{Object.keys(l.defaultFilter).length&&o().forEach(a=>{a.uid!==l.uid&&a.collection.name===l.collection.name&&(r.params=l.defaultFilter)})}),r.loading&&!e.loaded)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Spin,{});if(!(!(i!=null&&i.config)||!("map"in i.config)))return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{style:{fontWeight:600},children:"汇总:"}),i==null?void 0:i.config.map((l,a)=>{if(l)return React.createElement(InternalGroupBlock,I(A({},n),{configItem:l,service:r,key:a}))})]})},fieldTransformers=(n,e,s)=>{const{option:i}=transformers,r=s.auth.getLocale();if(n){const o=n.format,l=n==null?void 0:n.digits;if(o&&o!=="decimal"){const a=i.find(c=>c.value===o).component;return e=String(e).includes(",")?String(e).replace(/,/g,""):e,a(e,r)}else if(o&&o==="decimal"&&l){const a=i.filter(c=>c.value==="decimal")[0].childrens.filter(c=>c.value===l)[0].component;return e=String(e).includes(",")?String(e).replace(/,/g,""):e,a(e)}}},InternalGroupBlock=n=>{const{configItem:e,service:s}=n,r=schema.useFieldSchema().parent["x-decorator-props"].params,[o,l]=React.useState({}),a=client.useAPIClient();if(ahooks.useAsyncEffect(()=>R(this,null,function*(){var d;const c=s!=null&&s.params[0]?s.params[0].filter:s==null?void 0:s.params;e.reqUrl&&l((d=yield a.request({url:e.reqUrl,method:"POST",data:{filter:A({},c),collection:r.collection}}))!=null?d:{})}),[s.params,s.params[0]]),e.style==="describe"){const c=describeItem(e,o,s,r,a);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{style:{marginBottom:"10px"},items:c})}else if(e.style==="table"){const{columns:c,options:d}=tableItem(e,o,s,r,a);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Table,{style:{marginBottom:"10px"},columns:c,dataSource:d,pagination:!1})}},describeItem=(n,e,s,i,r)=>{var l,a,c;const o=[];if(n.type==="field"){const d=(l=s.data)==null?void 0:l.data;if(d){let u=d.map(m=>m[n.field])[0];u=fieldTransformers(n,u,r);const f=i.measures.find(m=>m.field[0]===n.field).label;o.push({key:n.field,label:f,children:u})}}else if(n.type==="custom"&&Object.keys(e).length&&(a=e==null?void 0:e.data)!=null&&a.data){const d=A({},(c=e==null?void 0:e.data)==null?void 0:c.data),u=d.labels;d.values.forEach((f,m)=>{let p="";u.forEach((g,x)=>{x!==0&&(p+=`${g}${fieldTransformers(n,f[x],r)} `)}),o.push({key:m,label:f[0],children:p})})}return o},tableItem=(n,e,s,i,r)=>{var a,c,d;const o=[],l=[];if(n.type==="custom"){if(Object.keys(e).length&&((a=e==null?void 0:e.data)!=null&&a.data)){const u=A({},(c=e==null?void 0:e.data)==null?void 0:c.data);u.labels.forEach((f,m)=>{o.push({title:f,dataIndex:"value"+m,key:m})}),u.values.forEach((f,m)=>{const p={key:m};o.forEach((g,x)=>{const E=typeof f[x]=="string"?f[x]:fieldTransformers(n,f[x],r);p[g.dataIndex]=E}),l.push(p)})}}else if(n.type==="field"){const u=(d=s.data)==null?void 0:d.data;if(u){let f=u.map(p=>p[n.field])[0];f=fieldTransformers(n,f,r);const m=i.measures.find(p=>p.field[0]===n.field).label;o.push({title:"名称",dataIndex:"name",key:"name"},{title:"数量",dataIndex:"number",key:"number"}),l.push({key:m,name:m,number:f})}}return{columns:o,options:l}};class PluginGroupBlock extends client.Plugin{load(){return R(this,null,function*(){this.app.schemaInitializerManager.addItem("page:addBlock","dataBlocks.groupBlock",{title:tval("Group"),Component:"GroupBlockInitializer"}),this.schemaSettingsManager.add(groupBlockSettings),this.app.addComponents({GroupBlock,GroupBlockConfigure,GroupBlockInitializer,GroupBlockProvider,GroupBlockToolbar})})}}const SchemaSettingsAppends=()=>{const n=schema.useFieldSchema(),{fieldSchema:e}=client.useColumnSchema(),s=e!=null?e:n,{t:i}=useTranslation(),r=client.useCollection(),{dn:o}=client.useDesignable();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:"设置加载关联字段",scope:{fieldFilter(l){return["belongsTo","hasOne"].includes(l.type)}},schema:{type:"object",title:"设置加载关联字段",properties:{appends:{default:_.get(s,"x-component-props.appends",[]),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{placeholder:i("Select context"),popupMatchSelectWidth:!1,collection:`${r.dataSource&&r.dataSource!=="main"?`${r.dataSource}:`:""}${r.name}`,multiple:!0,allowClear:!1}}}},onSubmit:({appends:l})=>{_.set(s["x-component-props"],"appends",l!=null?l:[]),o.emit("patch",{schema:{"x-uid":s["x-uid"],"x-component-props":s["x-component-props"]}}),o.refresh()}},"appends")},customFieldComponentFieldSettings=new client.SchemaSettings({name:"fieldSettings:component:CustomField",items:[{name:"appends",Component:SchemaSettingsAppends}]});class PluginCustomComponents extends client.Plugin{load(){return R(this,null,function*(){this.schemaSettingsManager.add(customFieldComponentFieldSettings)})}}const EmbedLayout=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Layout,{style:{height:"100%"},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Layout.Content,{className:client.css`
64
53
  display: flex;
65
54
  flex-direction: column;
66
55
  position: relative;
@@ -76,7 +65,7 @@
76
65
  z-index: 0;
77
66
  padding: 0px 50px;
78
67
  }
79
- `,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(reactRouterDom.Outlet,{})})});function NotAuthorityResult(){return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Result,{status:"403",title:"403",subTitle:"Sorry, you are not authorized to access this page."})}function useEmbedToken(){const i=new URL(window.location.href),e=client.useAPIClient(),s=i.searchParams.get("token");return s&&e.auth.setToken(s),e.auth.getToken()}const EmbedPage=()=>{const i=useEmbedToken(),e=reactRouterDom.useNavigate(),s=reactRouterDom.useLocation(),n=reactRouterDom.useMatch("/embed/:name");return React.useEffect(()=>()=>{setTimeout(()=>{n&&setTimeout(()=>{window.location.pathname!==s.pathname&&e("/embed/not-authorized")})})},[]),!i||s.pathname==="/embed/not-authorized"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(NotAuthorityResult,{}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.AdminProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(EmbedLayout,{})})};function EmbedSchemaComponent(){const i=reactRouterDom.useParams();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteSchemaComponent,{uid:i.name})}function usePageSettingsProps(){const i=reactRouterDom.useMatch("/admin/:name"),e=reactRouterDom.useMatch("/embed/:name"),s=i||e,n=schema.useFieldSchema(),{message:r,notification:o}=antd.App.useApp(),{t:a}=useTranslation();return{title:a("Copy embedded link"),onClick:()=>{const l=window.location.href.replace("/admin","/embed").replace(s.params.name,n["x-uid"]).replace(window.location.search||"","");navigator.clipboard.writeText(l).then(()=>{r.success(a("Copy successful"))}).catch(c=>{o.error({message:a("Copy Failed"),description:c.message,placement:"topRight"})})}}}const keyEmbed="embed",pathEmbed=`/${keyEmbed}`;class EmbedPlugin extends client.Plugin{load(){return P(this,null,function*(){this.router.add(keyEmbed,{path:pathEmbed,Component:EmbedPage}),this.router.add(`${keyEmbed}.page`,{path:`${pathEmbed}/:name`,Component:EmbedSchemaComponent}),this.router.add(`${keyEmbed}.notAuthorized`,{path:`${pathEmbed}/not-authorized`,element:null}),this.schemaSettingsManager.addItem("PageSettings",keyEmbed,{type:"item",useComponentProps:usePageSettingsProps})})}}const{defaultProps:defaultProps$3}=client.interfacesProperties;class ShowFieldCodeInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);C(this,"name","codeShow");C(this,"type","object");C(this,"group","advanced");C(this,"title","jsCode(显示)");C(this,"description","通过jsCode, 用于定制化显示用户界面内容.可使用的变量:scopes:{ form, path, recordData, result, setResult, formatFunc, dayjs}; handlers: { setResult, formatFunc }; modules: { dayjs }");C(this,"sortable",!0);C(this,"default",{type:"virtual",uiSchema:{type:"string","x-component":"ViewCode","x-component-props":{jsCode:"",prefix:"",suffix:"",decimal:""},"x-read-pretty":!0}});C(this,"properties",R(w({},defaultProps$3),{"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}]},"uiSchema.x-component-props.jsCode":{type:"string",title:"JSCode","x-decorator":"FormItem","x-component":"CodeMirror",default:"",required:!0}}))}}const ViewCode=i=>{const e=useAction$1(i);return typeof e=="string"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ShowValue$1,{value:e}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:e})},ShowValue$1=React.memo(i=>{const{value:e}=i;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value:e})});function useAction$1(i){var x,y,E,b;const e=schema.useForm(),s=schema.useFieldSchema(),n=schema.useField(),{jsCode:r,prefix:o,suffix:a,decimal:l}=i,c=n.path.entire,d=c==null?void 0:c.replace(`.${s.name}`,""),u=_.chain(e.values).get(d).value(),[p,m]=React.useState({items:[],childrenType:""}),f=v=>{let A=v;return typeof v=="number"&&(A=isNaN(v)?v:Number(v).toFixed(+l||0)),`${o}${A}${a}`};React.useEffect(()=>{dynamicCode({jsCode:r,form:e,path:c,recordData:u,result:p},{setResult:m,formatFunc:f})},[]);const g=(x=p==null?void 0:p.items)==null?void 0:x.map(v=>({label:v.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{children:v.children})}));return p.childrenType==="normal"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{items:g}):p.childrenType==="jsx"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:(y=p==null?void 0:p.items)==null?void 0:y.map(v=>v.children)}):(b=(E=p.items)==null?void 0:E[0])==null?void 0:b.children}function dynamicCode(l,c){return P(this,arguments,function*({jsCode:i,form:e,path:s,recordData:n,result:r},{setResult:o,formatFunc:a}){try{const d={data:{form:e,path:s,recordData:n,result:r,setResult:o,formatFunc:a},body:{}};yield evalSimulate(i,{ctx:d,lib:{log:console.log,JSON,dayjs}}),o(d.body)}catch(d){o({childrenType:"",items:[{key:"1",label:"数据异常",children:"请检查字段配置内容,error:"+d}]})}})}function evalSimulate(n,r){return P(this,arguments,function*(i,{ctx:e,lib:s}){const o=(function(){return P(this,null,function*(){})}).constructor;try{return yield new o("$root",`with($root) { ${i}; }`)({ctx:e,lib:s})}catch(a){console.log("err",a)}})}const{defaultProps:defaultProps$2}=client.interfacesProperties;class ShowFieldFormulaInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);C(this,"name","formulaShow");C(this,"type","object");C(this,"group","advanced");C(this,"title","公式(显示)");C(this,"description","通过公式, 用于定制化显示用户界面内容");C(this,"sortable",!0);C(this,"default",{type:"virtual",uiSchema:{type:"string","x-component":"Viewformula","x-component-props":{formulaString:"",prefix:"",suffix:"",decimal:""},"x-read-pretty":!0}});C(this,"properties",R(w({},defaultProps$2),{"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",required:!0,default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}]},"uiSchema.x-component-props.formulaString":{type:"string",title:"公式","x-decorator":"FormItem","x-component":"Input",default:"",required:!0}}))}}const ViewFormula=i=>{const{resultShowValue:e}=useAction(i);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ShowValue,{value:e})},ShowValue=React.memo(i=>{const{value:e}=i;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value:e})});function useAction(i){const e=schema.useForm(),s=schema.useFieldSchema(),n=schema.useField(),{formulaString:r,prefix:o,suffix:a,decimal:l}=i,c=n.path.entire,d=c==null?void 0:c.replace(`.${s.name}`,""),u=_.chain(e.values).get(d).value(),p=transformFormula(r),m=getEvaluateArray(p,u);return m?{resultShowValue:getResultShowValue(m,{prefix:o,suffix:a,decimal:l})}:{resultShowValue:""}}function transformFormula(i){return i?i.split(/([+\-*/?:()%])/).filter(s=>s):[]}function getEvaluateArray(i,e){var o;if(i.length<1)return;let s=0;const n=[],r={};for(let a=0;a<i.length;a++){const l=i[a];if(!l)continue;const c=isNumberFunc(l),d=isSymbolFunc(l);if(!c&&!d){let u;const p=/\${(.*?)}/g;if((o=l.match(p))!=null&&o.length){const g=l.match(p)[0].replace(/\${|}/g,""),x=l.split(".")[1],y=_.chain(e).get(g).value();u=_.chain(y).get(x,0).value()}else u=_.chain(e).get(l,0).value();const m=`var${s++}`,f=u!=null?u:0;n.push(`{{${m}}}`),r[m]=f}else n.push(l)}return[n.join(""),r]}function getResultShowValue(i,{prefix:e,suffix:s,decimal:n}){const r=client$1.evaluators.get("math.js"),o=r.evaluate.bind(r),[a,l]=i;let c;try{const d=o(a,l),u=isNaN(d)?d:Number(d).toFixed(+n||0);c=`${e}${u}${s}`}catch(d){c=`${a}`,console.warn("code: ",a," scopes: ",l,"error: ",c," error message ",d.message)}return c}function isNumberFunc(i){return typeof i=="number"&&!isNaN(i)}function isSymbolFunc(i){return["+","-","*","/","?",":","(",")","%"].includes(i)}class PluginFieldAppends extends client.Plugin{load(){return P(this,null,function*(){this.app.addComponents({Viewformula:ViewFormula,ViewCode}),this.app.dataSourceManager.addFieldInterfaces([ShowFieldFormulaInterface,ShowFieldCodeInterface])})}}const usePluginVersion=()=>{var e,s;const{data:i}=client.useRequest({url:"hera:version"});return(s=(e=i==null?void 0:i.data)==null?void 0:e.packageJson)==null?void 0:s.version},useHeraVersion=()=>{const i=usePluginVersion();return{key:"hera-version",eventKey:"hera-version",label:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:["赫拉系统 - ",i]})}},HeraVersionProvider=({children:i})=>{const{addMenuItem:e}=client.useCurrentUserSettingsMenu(),s=useHeraVersion();return React.useEffect(()=>{e(s,{before:"divider_1"})},[e,s]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:i})};class PluginHeraVersion extends client.Plugin{load(){return P(this,null,function*(){this.app.use(HeraVersionProvider)})}}const OutboundLinkActionInitializer=i=>{const e={title:tval("outbound"),"x-action":"outbound","x-component":"OutboundButton","x-designer":"Action.Designer","x-component-props":{icon:"ShareAltOutlined",useProps:"{{ useOutboundActionProps }}"}};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionInitializer,R(w({},i),{schema:e}))};OutboundLinkActionInitializer.displayName="OutboundLinkActionInitializer";const OutboundButton=i=>{const{onClick:e}=client.useProps(i),s=schema.useFieldSchema(),n=window.location.href.split("/",3).join("/"),{t:r}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Popover,{placement:"bottomRight",trigger:"click",autoAdjustOverflow:!0,content:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Space.Compact,{style:{width:"100%"},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{defaultValue:`${n}/r/${s["x-uid"]}`}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{type:"primary",onClick:e,children:r("Copy link")})]}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Button,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.ShareAltOutlined,{}),r("Outbound")]})})};OutboundButton.displayName="OutboundButton";const OutboundPage=()=>{const i=reactRouterDom.useParams();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.AdminProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteCollectionManagerProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteSchemaComponent,{uid:i.id})})})};var toggleSelection=function(){var i=document.getSelection();if(!i.rangeCount)return function(){};for(var e=document.activeElement,s=[],n=0;n<i.rangeCount;n++)s.push(i.getRangeAt(n));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return i.removeAllRanges(),function(){i.type==="Caret"&&i.removeAllRanges(),i.rangeCount||s.forEach(function(r){i.addRange(r)}),e&&e.focus()}},deselectCurrent=toggleSelection,clipboardToIE11Formatting={"text/plain":"Text","text/html":"Url",default:"Text"},defaultMessage="Copy to clipboard: #{key}, Enter";function format(i){var e=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return i.replace(/#{\s*key\s*}/g,e)}function copy(i,e){var s,n,r,o,a,l,c=!1;e||(e={}),s=e.debug||!1;try{r=deselectCurrent(),o=document.createRange(),a=document.getSelection(),l=document.createElement("span"),l.textContent=i,l.ariaHidden="true",l.style.all="unset",l.style.position="fixed",l.style.top=0,l.style.clip="rect(0, 0, 0, 0)",l.style.whiteSpace="pre",l.style.webkitUserSelect="text",l.style.MozUserSelect="text",l.style.msUserSelect="text",l.style.userSelect="text",l.addEventListener("copy",function(u){if(u.stopPropagation(),e.format)if(u.preventDefault(),typeof u.clipboardData=="undefined"){s&&console.warn("unable to use e.clipboardData"),s&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var p=clipboardToIE11Formatting[e.format]||clipboardToIE11Formatting.default;window.clipboardData.setData(p,i)}else u.clipboardData.clearData(),u.clipboardData.setData(e.format,i);e.onCopy&&(u.preventDefault(),e.onCopy(u.clipboardData))}),document.body.appendChild(l),o.selectNodeContents(l),a.addRange(o);var d=document.execCommand("copy");if(!d)throw new Error("copy command was unsuccessful");c=!0}catch(u){s&&console.error("unable to copy using execCommand: ",u),s&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(e.format||"text",i),e.onCopy&&e.onCopy(window.clipboardData),c=!0}catch(p){s&&console.error("unable to copy using clipboardData: ",p),s&&console.error("falling back to prompt"),n=format("message"in e?e.message:defaultMessage),window.prompt(n,i)}}finally{a&&(typeof a.removeRange=="function"?a.removeRange(o):a.removeAllRanges()),l&&document.body.removeChild(l),r()}return c}var copyToClipboard=copy;const copy$1=getDefaultExportFromCjs(copyToClipboard),useOutboundActionProps=()=>{let i=schema.useFieldSchema();const{t:e}=useTranslation();for(;!("x-decorator-props"in i);)i=i.parent;const s=window.location.href.split("/",3).join("/");return{onClick(){return P(this,null,function*(){copy$1(`${s}/r/${i["x-uid"]}`)?antd.message.success(e("Save link successful")):antd.message.success(e("Save link failed"))})}}};class PluginOutbound extends client.Plugin{load(){return P(this,null,function*(){this.app.router.add("outbound",{path:"/r/:id",Component:OutboundPage}),this.app.addScopes({useOutboundActionProps}),this.app.addComponents({OutboundButton,OutboundLinkActionInitializer});const e={type:"item",name:"enableActions.outbound",title:lang("outbound"),Component:"OutboundLinkActionInitializer",schema:{"x-align":"right"}};this.app.schemaInitializerManager.addItem("table:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("details:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("kanban:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("pdfViewer:configureActions",e.name,e)})}}const PDFViewerContext=React.createContext(null),usePDFViewerRef=()=>React.useContext(PDFViewerContext),PDFViewerProvider=i=>{const e=React.useRef(null),s=client.useApp(),{decorator:n}=i,r=s.getComponent(n);return r?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewerContext.Provider,{value:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(r,{children:i.children})}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewerContext.Provider,{value:e,children:i.children})},usePDFViewerPrintActionProps=()=>{const i=usePDFViewerRef();return{onClick:()=>P(this,null,function*(){i.current.print()})}},PDFViewerPrintActionInitializer=i=>{const e={title:tval("Print"),"x-action":"print","x-component":"Action","x-designer":"Action.Designer","x-component-props":{useProps:"{{ usePDFViewerPrintActionProps }}",icon:"PrinterOutlined"}};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionInitializer,R(w({},i),{schema:e}))},pdfViewActionInitializer=new client.SchemaInitializer({name:"pdfViewer:configureActions",title:"Configure actions",icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"enableActions",type:"itemGroup",title:tval("Enable actions"),children:[{name:"print",type:"item",title:tval("Print"),component:"PDFViewerPrintActionInitializer"},{name:"edit",title:tval("Edit"),Component:"UpdateActionInitializer",schema:{"x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{type:"primary"}}}]}]}),PDFViewerBlockInitializer=()=>{const{insert:i}=client.useSchemaInitializer(),e=client.useSchemaInitializerItem();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaInitializerItem,R(w({},e),{icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.PrinterOutlined,{}),onClick:()=>{var s;i({type:"void","x-designer":"Markdown.Void.Designer","x-decorator":"PDFViewerProvider","x-decorator-props":{decorator:(s=e.decorator)!=null?s:""},"x-component":"CardItem",properties:{actions:{type:"void","x-initializer":"pdfViewer:configureActions","x-component":"ActionBar","x-component-props":{},properties:{}},viewer:{type:"void","x-component":"PDFViwer","x-component-props":{target:e.target,usePdfPath:e.usePdfPath}}}})}}))},InternalPDFViewer=i=>{const{usePdfPath:e}=i,s=React.useRef(null),[n,r]=React.useState(0),[,o]=React.useState(0);React.useEffect(()=>{const d=_.debounce(()=>{s.current&&(r(s.current.offsetWidth),o(s.current.offsetHeight))},200),u=new ResizeObserver(()=>{d()});return s.current&&u.observe(s.current),()=>{u.disconnect()}},[s]);const a=usePDFViewerRef(),c=(e!=null?e:()=>"")();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{className:client.css`
68
+ `,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(reactRouterDom.Outlet,{})})});function NotAuthorityResult(){return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Result,{status:"403",title:"403",subTitle:"Sorry, you are not authorized to access this page."})}function useEmbedToken(){const n=new URL(window.location.href),e=client.useAPIClient(),s=n.searchParams.get("token");return s&&e.auth.setToken(s),e.auth.getToken()}const EmbedPage=()=>{const n=useEmbedToken(),e=reactRouterDom.useNavigate(),s=reactRouterDom.useLocation(),i=reactRouterDom.useMatch("/embed/:name");return React.useEffect(()=>()=>{setTimeout(()=>{i&&setTimeout(()=>{window.location.pathname!==s.pathname&&e("/embed/not-authorized")})})},[]),!n||s.pathname==="/embed/not-authorized"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(NotAuthorityResult,{}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.AdminProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(EmbedLayout,{})})};function EmbedSchemaComponent(){const n=reactRouterDom.useParams();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteSchemaComponent,{uid:n.name})}function usePageSettingsProps(){const n=reactRouterDom.useMatch("/admin/:name"),e=reactRouterDom.useMatch("/embed/:name"),s=n||e,i=schema.useFieldSchema(),{message:r,notification:o}=antd.App.useApp(),{t:l}=useTranslation();return{title:l("Copy embedded link"),onClick:()=>{const a=window.location.href.replace("/admin","/embed").replace(s.params.name,i["x-uid"]).replace(window.location.search||"","");navigator.clipboard.writeText(a).then(()=>{r.success(l("Copy successful"))}).catch(c=>{o.error({message:l("Copy Failed"),description:c.message,placement:"topRight"})})}}}const keyEmbed="embed",pathEmbed=`/${keyEmbed}`;class EmbedPlugin extends client.Plugin{load(){return R(this,null,function*(){this.router.add(keyEmbed,{path:pathEmbed,Component:EmbedPage}),this.router.add(`${keyEmbed}.page`,{path:`${pathEmbed}/:name`,Component:EmbedSchemaComponent}),this.router.add(`${keyEmbed}.notAuthorized`,{path:`${pathEmbed}/not-authorized`,element:null}),this.schemaSettingsManager.addItem("PageSettings",keyEmbed,{type:"item",useComponentProps:usePageSettingsProps})})}}const{defaultProps:defaultProps$3}=client.interfacesProperties;class ShowFieldCodeInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);b(this,"name","codeShow");b(this,"type","object");b(this,"group","advanced");b(this,"title","jsCode(显示)");b(this,"description","通过jsCode, 用于定制化显示用户界面内容.可使用的变量:scopes:{ form, path, recordData, result, setResult, formatFunc, dayjs}; handlers: { setResult, formatFunc }; modules: { dayjs }");b(this,"sortable",!0);b(this,"default",{type:"virtual",uiSchema:{type:"string","x-component":"ViewCode","x-component-props":{jsCode:"",prefix:"",suffix:"",decimal:""},"x-read-pretty":!0}});b(this,"properties",I(A({},defaultProps$3),{"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}]},"uiSchema.x-component-props.jsCode":{type:"string",title:"JSCode","x-decorator":"FormItem","x-component":"CodeMirror",default:"",required:!0}}))}}const ViewCode=n=>{const e=useAction$1(n);return typeof e=="string"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ShowValue$1,{value:e}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:e})},ShowValue$1=React.memo(n=>{const{value:e}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value:e})});function useAction$1(n){var x,E,v,y;const e=schema.useForm(),s=schema.useFieldSchema(),i=schema.useField(),{jsCode:r,prefix:o,suffix:l,decimal:a}=n,c=i.path.entire,d=c==null?void 0:c.replace(`.${s.name}`,""),u=_.chain(e.values).get(d).value(),[f,m]=React.useState({items:[],childrenType:""}),p=w=>{let S=w;return typeof w=="number"&&(S=isNaN(w)?w:Number(w).toFixed(+a||0)),`${o}${S}${l}`};React.useEffect(()=>{dynamicCode({jsCode:r,form:e,path:c,recordData:u,result:f},{setResult:m,formatFunc:p})},[]);const g=(x=f==null?void 0:f.items)==null?void 0:x.map(w=>({label:w.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{children:w.children})}));return f.childrenType==="normal"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{items:g}):f.childrenType==="jsx"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:(E=f==null?void 0:f.items)==null?void 0:E.map(w=>w.children)}):(y=(v=f.items)==null?void 0:v[0])==null?void 0:y.children}function dynamicCode(a,c){return R(this,arguments,function*({jsCode:n,form:e,path:s,recordData:i,result:r},{setResult:o,formatFunc:l}){try{const d={data:{form:e,path:s,recordData:i,result:r,setResult:o,formatFunc:l},body:{}};yield evalSimulate(n,{ctx:d,lib:{log:console.log,JSON,dayjs}}),o(d.body)}catch(d){o({childrenType:"",items:[{key:"1",label:"数据异常",children:"请检查字段配置内容,error:"+d}]})}})}function evalSimulate(i,r){return R(this,arguments,function*(n,{ctx:e,lib:s}){const o=(function(){return R(this,null,function*(){})}).constructor;try{return yield new o("$root",`with($root) { ${n}; }`)({ctx:e,lib:s})}catch(l){console.log("err",l)}})}const{defaultProps:defaultProps$2}=client.interfacesProperties;class ShowFieldFormulaInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);b(this,"name","formulaShow");b(this,"type","object");b(this,"group","advanced");b(this,"title","公式(显示)");b(this,"description","通过公式, 用于定制化显示用户界面内容");b(this,"sortable",!0);b(this,"default",{type:"virtual",uiSchema:{type:"string","x-component":"Viewformula","x-component-props":{formulaString:"",prefix:"",suffix:"",decimal:""},"x-read-pretty":!0}});b(this,"properties",I(A({},defaultProps$2),{"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",required:!0,default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}]},"uiSchema.x-component-props.formulaString":{type:"string",title:"公式","x-decorator":"FormItem","x-component":"Input",default:"",required:!0}}))}}const ViewFormula=n=>{const{resultShowValue:e}=useAction(n);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ShowValue,{value:e})},ShowValue=React.memo(n=>{const{value:e}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value:e})});function useAction(n){const e=schema.useForm(),s=schema.useFieldSchema(),i=schema.useField(),{formulaString:r,prefix:o,suffix:l,decimal:a}=n,c=i.path.entire,d=c==null?void 0:c.replace(`.${s.name}`,""),u=_.chain(e.values).get(d).value(),f=transformFormula(r),m=getEvaluateArray(f,u);return m?{resultShowValue:getResultShowValue(m,{prefix:o,suffix:l,decimal:a})}:{resultShowValue:""}}function transformFormula(n){return n?n.split(/([+\-*/?:()%])/).filter(s=>s):[]}function getEvaluateArray(n,e){var o;if(n.length<1)return;let s=0;const i=[],r={};for(let l=0;l<n.length;l++){const a=n[l];if(!a)continue;const c=isNumberFunc(a),d=isSymbolFunc(a);if(!c&&!d){let u;const f=/\${(.*?)}/g;if((o=a.match(f))!=null&&o.length){const g=a.match(f)[0].replace(/\${|}/g,""),x=a.split(".")[1],E=_.chain(e).get(g).value();u=_.chain(E).get(x,0).value()}else u=_.chain(e).get(a,0).value();const m=`var${s++}`,p=u!=null?u:0;i.push(`{{${m}}}`),r[m]=p}else i.push(a)}return[i.join(""),r]}function getResultShowValue(n,{prefix:e,suffix:s,decimal:i}){const r=client$1.evaluators.get("math.js"),o=r.evaluate.bind(r),[l,a]=n;let c;try{const d=o(l,a),u=isNaN(d)?d:Number(d).toFixed(+i||0);c=`${e}${u}${s}`}catch(d){c=`${l}`,console.warn("code: ",l," scopes: ",a,"error: ",c," error message ",d.message)}return c}function isNumberFunc(n){return typeof n=="number"&&!isNaN(n)}function isSymbolFunc(n){return["+","-","*","/","?",":","(",")","%"].includes(n)}class PluginFieldAppends extends client.Plugin{load(){return R(this,null,function*(){this.app.addComponents({Viewformula:ViewFormula,ViewCode}),this.app.dataSourceManager.addFieldInterfaces([ShowFieldFormulaInterface,ShowFieldCodeInterface])})}}const usePluginVersion=()=>{var e,s;const{data:n}=client.useRequest({url:"hera:version"});return(s=(e=n==null?void 0:n.data)==null?void 0:e.packageJson)==null?void 0:s.version},useHeraVersion=()=>{const n=usePluginVersion();return{key:"hera-version",eventKey:"hera-version",label:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:["赫拉系统 - ",n]})}},HeraVersionProvider=({children:n})=>{const{addMenuItem:e}=client.useCurrentUserSettingsMenu(),s=useHeraVersion();return React.useEffect(()=>{e(s,{before:"divider_1"})},[e,s]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:n})};class PluginHeraVersion extends client.Plugin{load(){return R(this,null,function*(){this.app.use(HeraVersionProvider)})}}const OutboundLinkActionInitializer=n=>{const e={title:tval("outbound"),"x-action":"outbound","x-component":"OutboundButton","x-designer":"Action.Designer","x-component-props":{icon:"ShareAltOutlined",useProps:"{{ useOutboundActionProps }}"}};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionInitializer,I(A({},n),{schema:e}))};OutboundLinkActionInitializer.displayName="OutboundLinkActionInitializer";const OutboundButton=n=>{const{onClick:e}=client.useProps(n),s=schema.useFieldSchema(),i=window.location.href.split("/",3).join("/"),{t:r}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Popover,{placement:"bottomRight",trigger:"click",autoAdjustOverflow:!0,content:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Space.Compact,{style:{width:"100%"},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{defaultValue:`${i}/r/${s["x-uid"]}`}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{type:"primary",onClick:e,children:r("Copy link")})]}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Button,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.ShareAltOutlined,{}),r("Outbound")]})})};OutboundButton.displayName="OutboundButton";const OutboundPage=()=>{const n=reactRouterDom.useParams();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.AdminProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteCollectionManagerProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteSchemaComponent,{uid:n.id})})})};var toggleSelection=function(){var n=document.getSelection();if(!n.rangeCount)return function(){};for(var e=document.activeElement,s=[],i=0;i<n.rangeCount;i++)s.push(n.getRangeAt(i));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return n.removeAllRanges(),function(){n.type==="Caret"&&n.removeAllRanges(),n.rangeCount||s.forEach(function(r){n.addRange(r)}),e&&e.focus()}},deselectCurrent=toggleSelection,clipboardToIE11Formatting={"text/plain":"Text","text/html":"Url",default:"Text"},defaultMessage="Copy to clipboard: #{key}, Enter";function format(n){var e=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return n.replace(/#{\s*key\s*}/g,e)}function copy(n,e){var s,i,r,o,l,a,c=!1;e||(e={}),s=e.debug||!1;try{r=deselectCurrent(),o=document.createRange(),l=document.getSelection(),a=document.createElement("span"),a.textContent=n,a.ariaHidden="true",a.style.all="unset",a.style.position="fixed",a.style.top=0,a.style.clip="rect(0, 0, 0, 0)",a.style.whiteSpace="pre",a.style.webkitUserSelect="text",a.style.MozUserSelect="text",a.style.msUserSelect="text",a.style.userSelect="text",a.addEventListener("copy",function(u){if(u.stopPropagation(),e.format)if(u.preventDefault(),typeof u.clipboardData=="undefined"){s&&console.warn("unable to use e.clipboardData"),s&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var f=clipboardToIE11Formatting[e.format]||clipboardToIE11Formatting.default;window.clipboardData.setData(f,n)}else u.clipboardData.clearData(),u.clipboardData.setData(e.format,n);e.onCopy&&(u.preventDefault(),e.onCopy(u.clipboardData))}),document.body.appendChild(a),o.selectNodeContents(a),l.addRange(o);var d=document.execCommand("copy");if(!d)throw new Error("copy command was unsuccessful");c=!0}catch(u){s&&console.error("unable to copy using execCommand: ",u),s&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(e.format||"text",n),e.onCopy&&e.onCopy(window.clipboardData),c=!0}catch(f){s&&console.error("unable to copy using clipboardData: ",f),s&&console.error("falling back to prompt"),i=format("message"in e?e.message:defaultMessage),window.prompt(i,n)}}finally{l&&(typeof l.removeRange=="function"?l.removeRange(o):l.removeAllRanges()),a&&document.body.removeChild(a),r()}return c}var copyToClipboard=copy;const copy$1=getDefaultExportFromCjs(copyToClipboard),useOutboundActionProps=()=>{let n=schema.useFieldSchema();const{t:e}=useTranslation();for(;!("x-decorator-props"in n);)n=n.parent;const s=window.location.href.split("/",3).join("/");return{onClick(){return R(this,null,function*(){copy$1(`${s}/r/${n["x-uid"]}`)?antd.message.success(e("Save link successful")):antd.message.success(e("Save link failed"))})}}};class PluginOutbound extends client.Plugin{load(){return R(this,null,function*(){this.app.router.add("outbound",{path:"/r/:id",Component:OutboundPage}),this.app.addScopes({useOutboundActionProps}),this.app.addComponents({OutboundButton,OutboundLinkActionInitializer});const e={type:"item",name:"enableActions.outbound",title:lang("outbound"),Component:"OutboundLinkActionInitializer",schema:{"x-align":"right"}};this.app.schemaInitializerManager.addItem("table:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("details:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("kanban:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("pdfViewer:configureActions",e.name,e)})}}const PDFViewerContext=React.createContext(null),usePDFViewerRef=()=>React.useContext(PDFViewerContext),PDFViewerProvider=n=>{const e=React.useRef(null),s=client.useApp(),{decorator:i}=n,r=s.getComponent(i);return r?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewerContext.Provider,{value:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(r,{children:n.children})}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewerContext.Provider,{value:e,children:n.children})},usePDFViewerPrintActionProps=()=>{const n=usePDFViewerRef();return{onClick:()=>R(this,null,function*(){n.current.print()})}},PDFViewerPrintActionInitializer=n=>{const e={title:tval("Print"),"x-action":"print","x-component":"Action","x-designer":"Action.Designer","x-component-props":{useProps:"{{ usePDFViewerPrintActionProps }}",icon:"PrinterOutlined"}};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionInitializer,I(A({},n),{schema:e}))},pdfViewActionInitializer=new client.SchemaInitializer({name:"pdfViewer:configureActions",title:"Configure actions",icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"enableActions",type:"itemGroup",title:tval("Enable actions"),children:[{name:"print",type:"item",title:tval("Print"),component:"PDFViewerPrintActionInitializer"},{name:"edit",title:tval("Edit"),Component:"UpdateActionInitializer",schema:{"x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{type:"primary"}}}]}]}),PDFViewerBlockInitializer=()=>{const{insert:n}=client.useSchemaInitializer(),e=client.useSchemaInitializerItem();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaInitializerItem,I(A({},e),{icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.PrinterOutlined,{}),onClick:()=>{var s;n({type:"void","x-designer":"Markdown.Void.Designer","x-decorator":"PDFViewerProvider","x-decorator-props":{decorator:(s=e.decorator)!=null?s:""},"x-component":"CardItem",properties:{actions:{type:"void","x-initializer":"pdfViewer:configureActions","x-component":"ActionBar","x-component-props":{},properties:{}},viewer:{type:"void","x-component":"PDFViwer","x-component-props":{target:e.target,usePdfPath:e.usePdfPath}}}})}}))},InternalPDFViewer=n=>{const{usePdfPath:e}=n,s=React.useRef(null),[i,r]=React.useState(0),[,o]=React.useState(0);React.useEffect(()=>{const d=_.debounce(()=>{s.current&&(r(s.current.offsetWidth),o(s.current.offsetHeight))},200),u=new ResizeObserver(()=>{d()});return s.current&&u.observe(s.current),()=>{u.disconnect()}},[s]);const l=usePDFViewerRef(),c=(e!=null?e:()=>"")();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{className:client.css`
80
69
  display: flex;
81
70
  `,children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{className:client.css`
82
71
  flex: 1;
@@ -90,4 +79,4 @@
90
79
  div::-webkit-scrollbar {
91
80
  display: none;
92
81
  }
93
- `,children:c?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewer,{file:c,width:n,ref:a}):""})]})};class PluginPDF extends client.Plugin{load(){return P(this,null,function*(){this.app.addScopes({usePDFViewerPrintActionProps}),this.app.addComponents({PDFViewerBlockInitializer,PDFViewerPrintActionInitializer,PDFViewerProvider,PDFViwer:InternalPDFViewer}),this.schemaInitializerManager.add(pdfViewActionInitializer);const e={title:tval("preview block"),name:"previewBlock",type:"itemGroup",children:[]};this.app.schemaInitializerManager.get("popup:common:addBlock").add(e.name,e)})}}const SheetBlockContext=React.createContext({}),InternalSheetBlockProvider=i=>{const e=schema.useField(),s=client.useDataBlockRequest();return s.loading&&!e.loaded?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Spin,{}):(e.loaded=!0,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(SheetBlockContext.Provider,{value:{field:e,service:s},children:i.children}))},SheetBlock=()=>{const i=React.useRef();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{style:{height:"70vh"},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:()=>console.log("data",i.current.getData()),children:"显示数据"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ExcelSheet,{ref:i})]})},SheetBlockProvider=i=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockProvider,R(w({name:"sheet"},i),{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(InternalSheetBlockProvider,w({},i))})),createSheetBlockSchema=i=>{const{collection:e}=i;return{title:e.title,type:"void","x-acl-action":`${e.name}:list`,"x-decorator":"SheetBlockProvider","x-decorator-props":{collection:e.name},"x-toolbar":"SheetBlockToolbar","x-settings":"sheetBlockSettings","x-component":"CardItem",properties:{[client$2.uid()]:{type:"void","x-component":"SheetBlock"}}}},SheetBlockInitializer=()=>{const{insert:i}=client.useSchemaInitializer(),e=client.useCollectionManager(),s=client.useSchemaInitializerItem();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockInitializer,R(w({},s),{icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.TableOutlined,{}),onCreateBlockSchema:r=>P(this,[r],function*({item:n}){const o=e.getCollection(n.name);i(createSheetBlockSchema({collection:o}))})}))},sheetBlockSettings=new client.SchemaSettings({name:"sheetBlockSettings",items:[{name:"remove",type:"remove"}]}),SheetBlockToolbar=i=>{const e=schema.useFieldSchema();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaToolbar,w({title:e.title,settings:e["x-settings"]},i))};class PluginSheet extends client.Plugin{load(){return P(this,null,function*(){this.app.addComponents({SheetBlock,SheetBlockInitializer,SheetBlockProvider,SheetBlockToolbar}),this.schemaSettingsManager.add(sheetBlockSettings),this.app.schemaInitializerManager.addItem("page:addBlock","dataBlocks.sheetBlock",{title:tval("Sheet"),Component:"SheetBlockInitializer"})})}}const useGetCustomAssociatedComponents=()=>useCustomComponent(CustomComponentType.CUSTOM_ASSOCIATED_FIELD),useGetCustomComponents=()=>useCustomComponent(CustomComponentType.CUSTOM_FIELD);class ExcelFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);C(this,"name","excelField");C(this,"type","json");C(this,"group","advanced");C(this,"order",3);C(this,"title",tval("Excel table"));C(this,"sortable",!0);C(this,"default",{interface:"json",type:"json",uiSchema:{type:"object","x-component":"ExcelFile"}});C(this,"availableTypes",["json"]);C(this,"hasDefaultValue",!1);C(this,"properties",w({},client.defaultProps))}}class AssociatedFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);C(this,"name","associated");C(this,"type","object");C(this,"group","relation");C(this,"order",10);C(this,"title","关联字段");C(this,"description","关联字段");C(this,"isAssociation",!0);C(this,"default",{type:"belongsTo",uiSchema:{"x-component":"AssociatedField"}});C(this,"availableTypes",["belongsTo"]);C(this,"properties",R(w({},client.defaultProps),{"uiSchema.x-component-props.collection":{type:"string",title:"关联数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0},"uiSchema.x-component-props.sourceCollection":{type:"string",title:"查询数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0},"uiSchema.x-component-props.sourceField":{type:"string",title:"查询数据表到关联数据表的路径","x-component":"Input","x-decorator":"FormItem",required:!0},"uiSchema.x-component-props.fieldExp":{type:"string",title:"关联字段",required:!0,"x-component":"Expression","x-decorator":"FormItem","x-component-props":{useCurrentFields:"{{ useCurrentFields }}"}},"uiSchema.x-component-props.dateFieldExp":{type:"string",title:"关联日期",required:!0,"x-component":"Expression","x-decorator":"FormItem","x-component-props":{useCurrentFields:"{{ useCurrentFields }}"}},target:{type:"string",title:"关联数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0,"x-display":"hidden","x-reactions":[{dependencies:["uiSchema.x-component-props.collection"],fulfill:{state:{value:"{{$deps[0]}}"}}}]},targetKey:{type:"string",title:"关联数据表键",required:!0,default:"id","x-display":"hidden","x-decorator":"FormItem","x-component":"Input"}}));C(this,"filterable",{nested:!0,children:[]})}}const{defaultProps:defaultProps$1}=client.interfacesProperties,formulaType=[{dependencies:["dataType"],fulfill:{state:{display:'{{["formula"].includes($deps[0]) ? "visible" : "none"}}'}}}],panelType=[{dependencies:["dataType"],fulfill:{state:{display:'{{["jsCode"].includes($deps[0]) ? "visible" : "none"}}'}}}];class CalcFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);C(this,"name","calc2");C(this,"type","object");C(this,"group","advanced");C(this,"title","数据计算(过期)");C(this,"description","数据字段计算");C(this,"sortable",!0);C(this,"default",{type:"virtual",uiSchema:{type:"string","x-component":"CalcResult","x-component-props":{formula:"",prefix:"",suffix:"",decimal:"",panel:""},"x-read-pretty":!0}});C(this,"properties",R(w({},defaultProps$1),{dataType:{type:"string",title:"计算类型","x-decorator":"FormItem","x-component":"Select",enum:[{value:"formula",label:"公式"},{value:"jsCode",label:"代码"}],required:!0,default:"formula",description:"公式:使用公式计算,代码:使用js代码计算"},"uiSchema.x-component-props.formula":{type:"string",title:"公式","x-decorator":"FormItem","x-component":"Input",default:"",required:!0,"x-reactions":formulaType},"uiSchema.x-component-props.panel":{type:"string",title:"jsCode","x-decorator":"FormItem","x-component":"Input.TextArea",description:"注意,此内容有值计算操作将以此内容为准,而不是公式,适用于面板中的计算",required:!0,"x-reactions":panelType},"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",required:!0,default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}],"x-reactions":formulaType}}))}}const{defaultProps}=client.interfacesProperties;class CustomFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);C(this,"name","custom");C(this,"type","object");C(this,"group","advanced");C(this,"title","组件字段");C(this,"description","组件字段");C(this,"sortable",!0);C(this,"default",{type:"virtual",uiSchema:{type:"string","x-component":"CustomField","x-read-pretty":!0}});C(this,"properties",R(w({},defaultProps),{"uiSchema.x-component-props.component":{type:"string",title:"组件","x-decorator":"FormItem","x-component":"Select",enum:" {{ useGetCustomComponents() }} ",required:!0,description:"需要在插件中注册相应的组件后可以使用"}}))}}class CustomAssociatedFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);C(this,"name","customAssociated");C(this,"type","object");C(this,"group","relation");C(this,"order",10);C(this,"title","自定义关联字段");C(this,"description","自定义关联字段");C(this,"isAssociation",!0);C(this,"default",{type:"virtual",uiSchema:{"x-component":"CustomAssociatedField"}});C(this,"availableTypes",["belongsTo"]);C(this,"properties",R(w({},client.defaultProps),{"uiSchema.x-component-props.component":{type:"string",title:"组件","x-decorator":"FormItem","x-component":"Select",enum:" {{ useGetCustomAssociatedComponents() }}",required:!0,description:"需要在插件中注册相应的组件后可以使用"},target:{type:"string",title:"关联数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0},targetKey:{type:"string",title:"关联数据表键",required:!0,default:"id","x-display":"hidden","x-decorator":"FormItem","x-component":"Input"}}));C(this,"filterable",{nested:!0,children:[]})}}class SignaturePadFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);C(this,"name","signatureSchema");C(this,"type","object");C(this,"group","advanced");C(this,"order",2);C(this,"title",tval("Signature input"));C(this,"sortable",!0);C(this,"default",{interface:"signature",type:"json",uiSchema:{type:"signature","x-component":"SignatureInput"}});C(this,"availableTypes",["json"]);C(this,"hasDefaultValue",!1);C(this,"properties",w({},client.defaultProps))}}class TstzrangeFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);C(this,"name","tstzrange");C(this,"type","object");C(this,"group","datetime");C(this,"order",2);C(this,"title",tval("Date range"));C(this,"sortable",!0);C(this,"default",{type:"tstzrange",uiSchema:{type:"object","x-component":"DatePicker.RangePicker","x-component-props":{utc:!1,valueType:"range"}}});C(this,"availableTypes",["tstzrange"]);C(this,"hasDefaultValue",!1);C(this,"properties",w({},client.defaultProps))}}const SettingBlockInitializer=()=>{const{insert:i}=client.useSchemaInitializer(),{t:e}=useTranslation(),s=React.useContext(schema.SchemaOptionsContext),{theme:n}=client.useGlobalTheme(),r=client.useSchemaInitializerItem(),o=client.useCollectionManager(),a=client.useAPIClient();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockInitializer,R(w({},r),{componentType:"FormItem",icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.FormOutlined,{}),onCreateBlockSchema:c=>P(this,[c],function*({item:l}){const d=o.getCollection(l.name),u=d.titleField,p=yield client.FormDialog(e("Pick a data entry for viewing and editing"),()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.APIClientProvider,{apiClient:a,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponentOptions,{scope:s.scope,components:w({},s.components),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(components$1.FormLayout,{layout:"vertical",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{properties:{id:{title:tval("Please select"),required:!0,"x-component":"RemoteSelect","x-component-props":{service:{resource:l.name},fieldNames:{label:u,value:"id"}},"x-decorator":"FormItem"}}}})})})}),n).open({initialValues:{}}),m=client.createFormBlockSchema({dataSource:l.dataSource,collection:d.name,action:"get",filterByTk:p.id,actionInitializers:"editForm:configureActions"});i(m)})}))},usePaginationVisible=()=>{var e;return((e=schema.useFieldSchema()["x-component-props"])==null?void 0:e.mode)==="SubTable"},EditTitle=()=>{var l;const{getCollectionJoinField:i}=client.useCollectionManager_deprecated(),{getField:e}=client.useCollection_deprecated(),s=schema.useField(),n=schema.useFieldSchema(),{t:r}=useTranslation(),{dn:o}=client.useDesignable(),a=e(n.name)||i(n["x-collection-field"]);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:r("Edit field title"),schema:{type:"object",title:r("Edit field title"),properties:{title:{title:r("Field title"),default:s==null?void 0:s.title,description:`${r("Original field title: ")}${a?(l=a==null?void 0:a.uiSchema)==null?void 0:l.title:n.name}`,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:({title:c})=>{c&&(s.title=c,n.title=c,o.emit("patch",{schema:{"x-uid":n["x-uid"],title:n.title}})),o.refresh()}},"edit-field-title")},IsTablePageSize=()=>{const{dn:i}=client.useDesignable(),e=schema.useFieldSchema(),{t:s}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsSwitchItem,{title:s("Pagination"),checked:e["x-component-props"].pagination,onChange:n=>{e["x-component-props"].pagination||(e["x-component-props"]=R(w({},e["x-component-props"]),{pagination:!1})),e["x-component-props"].pagination=n,i.emit("patch",{schema:{"x-uid":e["x-uid"],"x-component-props":w({},e==null?void 0:e["x-component-props"])}}),i.refresh()}})},SchemaSettingsDatePickerType=()=>{var l,c,d;const i=schema.useFieldSchema(),e=schema.useField(),{dn:s}=client.useDesignable(),{t:n}=useTranslation(),o=client.useCollectionManager().getCollectionField(i==null?void 0:i["x-collection-field"])||{},a=((l=i==null?void 0:i["x-component-props"])==null?void 0:l.picker)||((d=(c=o==null?void 0:o.uiSchema)==null?void 0:c["x-component-props"])==null?void 0:d.picker)||"";return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:n("Date picker type"),schema:{type:"object",properties:{picker:{type:"string",title:tval("Picker type"),"x-component":"Select","x-decorator":"FormItem","x-decorator-props":{},default:a,enum:[{label:n("default"),value:""},{label:n("year"),value:"year"},{label:n("quarter"),value:"quarter"},{label:n("month"),value:"month"},{label:n("week"),value:"week"}]}}},onSubmit:u=>{const p={"x-uid":i["x-uid"]};p["x-component-props"]=i["x-component-props"]||{},i["x-component-props"]=w(w({},i["x-component-props"]||{}),u),p["x-component-props"]=i["x-component-props"],e.componentProps=i["x-component-props"];const m=e.path.entire.split(".");m.pop();const f=m.join(".");e.query(`${f}.*[0:].${i.name}`).forEach(g=>{g.props.name===i.name&&g.setComponentProps(w({},u))}),s.emit("patch",{schema:p}),s.refresh()}})};SchemaSettingsDatePickerType.displayName="SchemaSettingsDatePickerType";const useCustomPresets1=()=>{const i=schema.useFieldSchema(),{t:e}=useTranslation(),s=getDateRanges(),n=[{label:e("This year"),value:s.thisYear},...Array(5).fill(0).map((r,o)=>({label:client$2.dayjs().year()-o-1+e("year"),value:s.year(client$2.dayjs().year()-o-1)})),{label:e("This month"),value:s.thisMonth},{label:e("Last month"),value:s.lastMonth}];return i.name==="presets"?"{{ useCustomPresets1() }}":n},useCustomPresets=i=>"{{ "+i+"() }}",SchemaSettingsDatePresets=()=>{var a,l,c;const i=schema.useFieldSchema(),{dn:e}=client.useDesignable(),{t:s}=useTranslation(),r=client.useCollectionManager().getCollectionField(i==null?void 0:i["x-collection-field"])||{},o=((a=i==null?void 0:i["x-component-props"])==null?void 0:a.presets)||((c=(l=r==null?void 0:r.uiSchema)==null?void 0:l["x-component-props"])==null?void 0:c.presets)||"";return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:s("Date presets"),schema:{type:"object",properties:{presets:{type:"string",title:tval("Date presets"),"x-component":"Select","x-decorator":"FormItem","x-decorator-props":{},default:o,enum:[{label:s("default"),value:""},{label:s("Chuangxing presets"),value:'{{ useCustomPresets("useCustomPresets1") }}'}]}}},onSubmit:d=>{d.presets||(d.presets=void 0);const u={"x-uid":i["x-uid"]};u["x-component-props"]=i["x-component-props"]||{},i["x-component-props"]=w(w({},i["x-component-props"]||{}),d),u["x-component-props"]=i["x-component-props"],e.emit("patch",{schema:u}),e.refresh()}})};SchemaSettingsDatePresets.displayName="SchemaSettingsDatePresets";const getDateRanges=()=>({now:()=>client$2.dayjs().toISOString(),today:()=>[getStart(0,"day"),getEnd(0,"day")],yesterday:()=>[getStart(-1,"day"),getEnd(-1,"day")],tomorrow:()=>[getStart(1,"day"),getEnd(1,"day")],thisWeek:()=>[getStart(0,"isoWeek"),getEnd(0,"isoWeek")],lastWeek:()=>[getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")],nextWeek:()=>[getStart(1,"isoWeek"),getEnd(1,"isoWeek")],year:i=>[getStart(i-client$2.dayjs().year(),"year"),getEnd(i-client$2.dayjs().year(),"year")],thisIsoWeek:()=>[getStart(0,"isoWeek"),getEnd(0,"isoWeek")],lastIsoWeek:()=>[getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")],nextIsoWeek:()=>[getStart(1,"isoWeek"),getEnd(1,"isoWeek")],thisMonth:()=>[getStart(0,"month"),getEnd(0,"month")],lastMonth:()=>[getStart(-1,"month"),getEnd(-1,"month")],nextMonth:()=>[getStart(1,"month"),getEnd(1,"month")],thisQuarter:()=>[getStart(0,"quarter"),getEnd(0,"quarter")],lastQuarter:()=>[getStart(-1,"quarter"),getEnd(-1,"quarter")],nextQuarter:()=>[getStart(1,"quarter"),getEnd(1,"quarter")],thisYear:()=>[getStart(0,"year"),getEnd(0,"year")],lastYear:()=>[getStart(-1,"year"),getEnd(-1,"year")],nextYear:()=>[getStart(1,"year"),getEnd(1,"year")],last7Days:()=>[getStart(-6,"days"),getEnd(0,"days")],next7Days:()=>[getStart(1,"day"),getEnd(7,"days")],last30Days:()=>[getStart(-29,"days"),getEnd(0,"days")],next30Days:()=>[getStart(1,"day"),getEnd(30,"days")],last90Days:()=>[getStart(-89,"days"),getEnd(0,"days")],next90Days:()=>[getStart(1,"day"),getEnd(90,"days")]}),getStart=(i,e)=>client$2.dayjs().add(i,e==="isoWeek"?"week":e).startOf(e),getEnd=(i,e)=>client$2.dayjs().add(i,e==="isoWeek"?"week":e).endOf(e),SchemaSettingsSubmitDataType=()=>{var n;const{dn:i}=client.useDesignable(),{t:e}=useTranslation(),s=schema.useFieldSchema();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsSwitchItem,{title:e("Select submit data type"),checked:!!((n=s==null?void 0:s["x-action-settings"])!=null&&n.isDeltaChanged),onChange:r=>{s["x-action-settings"].isDeltaChanged=r,i.emit("patch",{schema:{"x-uid":s["x-uid"],"x-action-settings":w({},s["x-action-settings"])}})}})};SchemaSettingsSubmitDataType.displayName="SchemaSettingsSubmitDataType";const LinkManager=()=>{const[i,e]=React.useState(!1),[s,n]=React.useState({}),[r,o]=React.useState([]),{data:a,run:l}=client.useRequest({url:"/link-manage:get"}),{run:c}=client.useRequest({url:"/link-manage:set",params:{id:s.id,link:s.link}});React.useEffect(()=>{a&&o(a.data)},[a]);const d=f=>{n(f),e(!0)},u=()=>{e(!1)},p=()=>{c();const f=r.map(g=>g.id===s.id?s:g);o(f),e(!1),n({})},m=[{title:"名称",dataIndex:"name",key:"name",render:f=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{children:f})},{title:"链接",dataIndex:"link",key:"link",render:f=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{children:f})},{title:"Action",key:"action",render:(f,g)=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Space,{size:"middle",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{onClick:()=>d(g),children:"编辑"})})}];return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:[r&&__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Table,{columns:m,dataSource:r}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Drawer,{title:"设定链接地址",width:720,onClose:u,open:i,styles:{body:{paddingBottom:80}},extra:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Space,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:u,children:"关闭"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:p,type:"primary",children:"提交"})]}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Form,{layout:"vertical",children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{name:"name",label:"Name",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{placeholder:"Please enter Name",defaultValue:s==null?void 0:s.name,disabled:!0})}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{name:"link",label:"Link",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{onChange:f=>n(R(w({},s),{link:f.target.value})),placeholder:"Please enter Link",defaultValue:s==null?void 0:s.link})})]})})]})},TokenConfigurationResourceKey="token-configuration",getSSKey=i=>`TACHYBASE_PLUGIN_TOKEN_CONFIGURATION_${i}`,useMapConfiguration=i=>{const e=React.useMemo(()=>{const n=sessionStorage.getItem(getSSKey(i));return n&&JSON.parse(n)},[i]),{data:s}=client.useRequest({resource:TokenConfigurationResourceKey,action:"get",params:{type:i}},{onSuccess(n){sessionStorage.setItem(getSSKey(i),JSON.stringify(n==null?void 0:n.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!e});return e||(s==null?void 0:s.data)},TokenTypes=[{label:"飞书",value:"feishu"}],BaseConfiguration=({type:i,children:e})=>{const[s,n]=ahooks.useBoolean(!1),r=client.useAPIClient(),[o]=antd.Form.useForm(),a=useMapConfiguration(i);React.useEffect(()=>{a&&(o.setFieldsValue(a),n.toggle())},[a]);const l=React.useMemo(()=>r.resource(TokenConfigurationResourceKey),[r]),c=d=>{l.set(R(w({},d),{type:i})).then(u=>{sessionStorage.removeItem(getSSKey(i)),n.toggle(),antd.message.success("保存成功")}).catch(u=>{antd.message.success("保存失败")})};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Form,{disabled:s,form:o,layout:"vertical",onFinish:c,children:[e,s?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{disabled:!1,onClick:n.toggle,children:"编辑"}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{disabled:!1,type:"primary",htmlType:"submit",children:"保存"})})]})},AMapConfiguration=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(BaseConfiguration,{type:"feishu",children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{required:!0,name:"app_id",label:"App ID",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{})}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{required:!0,name:"app_secret",label:"App Secret",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{})}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{required:!0,name:"chat_id",label:"Chat ID",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{})})]}),components={feishu:AMapConfiguration},tabList=TokenTypes.map(i=>R(w({},i),{component:components[i.value]})),Configuration=()=>{const i=reactRouterDom.useLocation(),e=new URLSearchParams(i.search);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Card,{bordered:!0,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Tabs,{type:"card",defaultActiveKey:e.get("tab"),children:tabList.map(s=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Tabs.TabPane,{tab:s.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(s.component,{type:s.value})},s.value))})})};class PluginSettingsHelper{constructor(e){this.app=e}load(){return P(this,null,function*(){this.app.systemSettingsManager.add("system-services.hera",{title:tval("Hera integration"),icon:"HomeOutlined"}),this.app.systemSettingsManager.add("system-services.hera.token",{title:tval("Third-party integration configuration"),icon:"ShareAltOutlined",Component:Configuration}),this.app.systemSettingsManager.add("system-services.hera.linkmanage",{title:tval("Link manager"),icon:"ShareAltOutlined",Component:LinkManager})})}}class PluginCoreClient extends client.Plugin{constructor(){super(...arguments);C(this,"locale")}afterAdd(){return P(this,null,function*(){yield this.app.pm.add(PluginGroupBlock),yield this.app.pm.add(EmbedPlugin),yield this.app.pm.add(DepartmentsPlugin),yield this.app.pm.add(PluginHeraVersion),yield this.app.pm.add(PluginPDF),yield this.app.pm.add(PluginOutbound),yield this.app.pm.add(PluginFieldAppends),yield this.app.pm.add(PluginCustomComponents),yield this.app.pm.add(PluginSheet)})}registerSettings(){return P(this,null,function*(){this.schemaSettingsManager.add(customComponentDispatcherSettings),this.schemaSettingsManager.addItem("fieldSettings:component:DatePicker","datePickerType",{Component:SchemaSettingsDatePickerType}),this.schemaSettingsManager.addItem("fieldSettings:component:DatePicker","datePresets",{Component:SchemaSettingsDatePresets}),this.schemaSettingsManager.addItem("actionSettings:updateSubmit","submitDataType",{Component:SchemaSettingsSubmitDataType}),this.schemaSettingsManager.addItem("FormItemSettings","hera-divider",{type:"divider",useVisible(){const s=client.useFormulaTitleVisible(),n=usePaginationVisible();return s||n}}),this.schemaSettingsManager.addItem("FormItemSettings","isTablePageSize",{Component:IsTablePageSize,useVisible:usePaginationVisible})})}registerScopesAndComponents(){return P(this,null,function*(){this.app.addScopes({useGetCustomAssociatedComponents,useGetCustomComponents,useCustomPresets1,useCustomPresets}),this.app.addComponents({AssociatedField,CalcResult,CodeMirror:components$1.CodeMirror,CustomAssociatedField,CustomComponentDispatcher,CustomComponentStub,CustomField,EditTitle,Expression,SettingBlock:SettingBlockInitializer,SignatureInput,ExcelFile})})}registerRouters(){return P(this,null,function*(){})}registerSchemaInitializer(){return P(this,null,function*(){const s={name:"setting",title:tval("System setting"),Component:"SettingBlock"},n={type:"item",name:"refreshAction",title:tval("Refresh"),Component:"RefreshActionInitializer",schema:{"x-align":"right"}};this.app.schemaInitializerManager.addItem("page:addBlock",s.name,s),this.app.schemaInitializerManager.addItem("kanban:configureActions",n.name,n);const r={name:"addCustomComponent",title:tval("Add custom component"),Component:"BlockItemInitializer",schema:{type:"void","x-editable":!1,"x-decorator":"FormItem","x-settings":"customComponentDispatcherSettings","x-component":"CustomComponentDispatcher","x-component-props":{component:"CustomComponentStub"}}};this.app.schemaInitializerManager.addItem("form:configureFields",r.name,r),this.app.schemaInitializerManager.addItem("details:configureFields",r.name,r)})}registerInterfaces(){return P(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([AssociatedFieldInterface,CalcFieldInterface,CustomFieldInterface,CustomAssociatedFieldInterface,SignaturePadFieldInterface,ExcelFieldInterface,TstzrangeFieldInterface])})}afterLoad(){return P(this,null,function*(){yield this.registerSchemaInitializer()})}load(){return P(this,null,function*(){this.locale=new Locale(this.app),yield new PluginSettingsHelper(this.app).load(),yield this.registerScopesAndComponents(),yield this.registerSettings(),yield this.registerRouters(),yield this.registerInterfaces()})}}exports.CustomComponentType=CustomComponentType,exports.PluginCoreClient=PluginCoreClient,exports.default=PluginCoreClient,exports.usePDFViewerRef=usePDFViewerRef,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
82
+ `,children:c?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewer,{file:c,width:i,ref:l}):""})]})};class PluginPDF extends client.Plugin{load(){return R(this,null,function*(){this.app.addScopes({usePDFViewerPrintActionProps}),this.app.addComponents({PDFViewerBlockInitializer,PDFViewerPrintActionInitializer,PDFViewerProvider,PDFViwer:InternalPDFViewer}),this.schemaInitializerManager.add(pdfViewActionInitializer);const e={title:tval("preview block"),name:"previewBlock",type:"itemGroup",children:[]};this.app.schemaInitializerManager.get("popup:common:addBlock").add(e.name,e)})}}const SheetBlockContext=React.createContext({}),InternalSheetBlockProvider=n=>{const e=schema.useField(),s=client.useDataBlockRequest();return s.loading&&!e.loaded?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Spin,{}):(e.loaded=!0,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(SheetBlockContext.Provider,{value:{field:e,service:s},children:n.children}))},SheetBlock=()=>{const n=React.useRef();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{style:{height:"70vh"},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:()=>console.log("data",n.current.getData()),children:"显示数据"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ExcelSheet,{ref:n})]})},SheetBlockProvider=n=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockProvider,I(A({name:"sheet"},n),{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(InternalSheetBlockProvider,A({},n))})),createSheetBlockSchema=n=>{const{collection:e}=n;return{title:e.title,type:"void","x-acl-action":`${e.name}:list`,"x-decorator":"SheetBlockProvider","x-decorator-props":{collection:e.name},"x-toolbar":"SheetBlockToolbar","x-settings":"sheetBlockSettings","x-component":"CardItem",properties:{[client$2.uid()]:{type:"void","x-component":"SheetBlock"}}}},SheetBlockInitializer=()=>{const{insert:n}=client.useSchemaInitializer(),e=client.useCollectionManager(),s=client.useSchemaInitializerItem();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockInitializer,I(A({},s),{icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.TableOutlined,{}),onCreateBlockSchema:r=>R(this,[r],function*({item:i}){const o=e.getCollection(i.name);n(createSheetBlockSchema({collection:o}))})}))},sheetBlockSettings=new client.SchemaSettings({name:"sheetBlockSettings",items:[{name:"remove",type:"remove"}]}),SheetBlockToolbar=n=>{const e=schema.useFieldSchema();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaToolbar,A({title:e.title,settings:e["x-settings"]},n))};class PluginSheet extends client.Plugin{load(){return R(this,null,function*(){this.app.addComponents({SheetBlock,SheetBlockInitializer,SheetBlockProvider,SheetBlockToolbar}),this.schemaSettingsManager.add(sheetBlockSettings),this.app.schemaInitializerManager.addItem("page:addBlock","dataBlocks.sheetBlock",{title:tval("Sheet"),Component:"SheetBlockInitializer"})})}}const useGetCustomAssociatedComponents=()=>useCustomComponent(CustomComponentType.CUSTOM_ASSOCIATED_FIELD),useGetCustomComponents=()=>useCustomComponent(CustomComponentType.CUSTOM_FIELD);class ExcelFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);b(this,"name","excelField");b(this,"type","json");b(this,"group","advanced");b(this,"order",3);b(this,"title",tval("Excel table"));b(this,"sortable",!0);b(this,"default",{interface:"json",type:"json",uiSchema:{type:"object","x-component":"ExcelFile"}});b(this,"availableTypes",["json"]);b(this,"hasDefaultValue",!1);b(this,"properties",A({},client.defaultProps))}}class AssociatedFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);b(this,"name","associated");b(this,"type","object");b(this,"group","relation");b(this,"order",10);b(this,"title","关联字段");b(this,"description","关联字段");b(this,"isAssociation",!0);b(this,"default",{type:"belongsTo",uiSchema:{"x-component":"AssociatedField"}});b(this,"availableTypes",["belongsTo"]);b(this,"properties",I(A({},client.defaultProps),{"uiSchema.x-component-props.collection":{type:"string",title:"关联数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0},"uiSchema.x-component-props.sourceCollection":{type:"string",title:"查询数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0},"uiSchema.x-component-props.sourceField":{type:"string",title:"查询数据表到关联数据表的路径","x-component":"Input","x-decorator":"FormItem",required:!0},"uiSchema.x-component-props.fieldExp":{type:"string",title:"关联字段",required:!0,"x-component":"Expression","x-decorator":"FormItem","x-component-props":{useCurrentFields:"{{ useCurrentFields }}"}},"uiSchema.x-component-props.dateFieldExp":{type:"string",title:"关联日期",required:!0,"x-component":"Expression","x-decorator":"FormItem","x-component-props":{useCurrentFields:"{{ useCurrentFields }}"}},target:{type:"string",title:"关联数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0,"x-display":"hidden","x-reactions":[{dependencies:["uiSchema.x-component-props.collection"],fulfill:{state:{value:"{{$deps[0]}}"}}}]},targetKey:{type:"string",title:"关联数据表键",required:!0,default:"id","x-display":"hidden","x-decorator":"FormItem","x-component":"Input"}}));b(this,"filterable",{nested:!0,children:[]})}}const{defaultProps:defaultProps$1}=client.interfacesProperties,formulaType=[{dependencies:["dataType"],fulfill:{state:{display:'{{["formula"].includes($deps[0]) ? "visible" : "none"}}'}}}],panelType=[{dependencies:["dataType"],fulfill:{state:{display:'{{["jsCode"].includes($deps[0]) ? "visible" : "none"}}'}}}];class CalcFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);b(this,"name","calc2");b(this,"type","object");b(this,"group","advanced");b(this,"title","数据计算(过期)");b(this,"description","数据字段计算");b(this,"sortable",!0);b(this,"default",{type:"virtual",uiSchema:{type:"string","x-component":"CalcResult","x-component-props":{formula:"",prefix:"",suffix:"",decimal:"",panel:""},"x-read-pretty":!0}});b(this,"properties",I(A({},defaultProps$1),{dataType:{type:"string",title:"计算类型","x-decorator":"FormItem","x-component":"Select",enum:[{value:"formula",label:"公式"},{value:"jsCode",label:"代码"}],required:!0,default:"formula",description:"公式:使用公式计算,代码:使用js代码计算"},"uiSchema.x-component-props.formula":{type:"string",title:"公式","x-decorator":"FormItem","x-component":"Input",default:"",required:!0,"x-reactions":formulaType},"uiSchema.x-component-props.panel":{type:"string",title:"jsCode","x-decorator":"FormItem","x-component":"Input.TextArea",description:"注意,此内容有值计算操作将以此内容为准,而不是公式,适用于面板中的计算",required:!0,"x-reactions":panelType},"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",required:!0,default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}],"x-reactions":formulaType}}))}}const{defaultProps}=client.interfacesProperties;class CustomFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);b(this,"name","custom");b(this,"type","object");b(this,"group","advanced");b(this,"title","组件字段");b(this,"description","组件字段");b(this,"sortable",!0);b(this,"default",{type:"virtual",uiSchema:{type:"string","x-component":"CustomField","x-read-pretty":!0}});b(this,"properties",I(A({},defaultProps),{"uiSchema.x-component-props.component":{type:"string",title:"组件","x-decorator":"FormItem","x-component":"Select",enum:" {{ useGetCustomComponents() }} ",required:!0,description:"需要在插件中注册相应的组件后可以使用"}}))}}class CustomAssociatedFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);b(this,"name","customAssociated");b(this,"type","object");b(this,"group","relation");b(this,"order",10);b(this,"title","自定义关联字段");b(this,"description","自定义关联字段");b(this,"isAssociation",!0);b(this,"default",{type:"virtual",uiSchema:{"x-component":"CustomAssociatedField"}});b(this,"availableTypes",["belongsTo"]);b(this,"properties",I(A({},client.defaultProps),{"uiSchema.x-component-props.component":{type:"string",title:"组件","x-decorator":"FormItem","x-component":"Select",enum:" {{ useGetCustomAssociatedComponents() }}",required:!0,description:"需要在插件中注册相应的组件后可以使用"},target:{type:"string",title:"关联数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0},targetKey:{type:"string",title:"关联数据表键",required:!0,default:"id","x-display":"hidden","x-decorator":"FormItem","x-component":"Input"}}));b(this,"filterable",{nested:!0,children:[]})}}class SignaturePadFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);b(this,"name","signatureSchema");b(this,"type","object");b(this,"group","advanced");b(this,"order",2);b(this,"title",tval("Signature input"));b(this,"sortable",!0);b(this,"default",{interface:"signature",type:"json",uiSchema:{type:"signature","x-component":"SignatureInput"}});b(this,"availableTypes",["json"]);b(this,"hasDefaultValue",!1);b(this,"properties",A({},client.defaultProps))}}class TstzrangeFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments);b(this,"name","tstzrange");b(this,"type","object");b(this,"group","datetime");b(this,"order",2);b(this,"title",tval("Date range"));b(this,"sortable",!0);b(this,"default",{type:"tstzrange",uiSchema:{type:"object","x-component":"DatePicker.RangePicker","x-component-props":{utc:!1,valueType:"range"}}});b(this,"availableTypes",["tstzrange"]);b(this,"hasDefaultValue",!1);b(this,"properties",A({},client.defaultProps))}}const SettingBlockInitializer=()=>{const{insert:n}=client.useSchemaInitializer(),{t:e}=useTranslation(),s=React.useContext(schema.SchemaOptionsContext),{theme:i}=client.useGlobalTheme(),r=client.useSchemaInitializerItem(),o=client.useCollectionManager(),l=client.useAPIClient();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockInitializer,I(A({},r),{componentType:"FormItem",icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.FormOutlined,{}),onCreateBlockSchema:c=>R(this,[c],function*({item:a}){const d=o.getCollection(a.name),u=d.titleField,f=yield client.FormDialog(e("Pick a data entry for viewing and editing"),()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.APIClientProvider,{apiClient:l,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponentOptions,{scope:s.scope,components:A({},s.components),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(components$1.FormLayout,{layout:"vertical",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{properties:{id:{title:tval("Please select"),required:!0,"x-component":"RemoteSelect","x-component-props":{service:{resource:a.name},fieldNames:{label:u,value:"id"}},"x-decorator":"FormItem"}}}})})})}),i).open({initialValues:{}}),m=client.createFormBlockSchema({dataSource:a.dataSource,collection:d.name,action:"get",filterByTk:f.id,actionInitializers:"editForm:configureActions"});n(m)})}))},usePaginationVisible=()=>{var e;return((e=schema.useFieldSchema()["x-component-props"])==null?void 0:e.mode)==="SubTable"},EditTitle=()=>{var a;const{getCollectionJoinField:n}=client.useCollectionManager_deprecated(),{getField:e}=client.useCollection_deprecated(),s=schema.useField(),i=schema.useFieldSchema(),{t:r}=useTranslation(),{dn:o}=client.useDesignable(),l=e(i.name)||n(i["x-collection-field"]);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:r("Edit field title"),schema:{type:"object",title:r("Edit field title"),properties:{title:{title:r("Field title"),default:s==null?void 0:s.title,description:`${r("Original field title: ")}${l?(a=l==null?void 0:l.uiSchema)==null?void 0:a.title:i.name}`,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:({title:c})=>{c&&(s.title=c,i.title=c,o.emit("patch",{schema:{"x-uid":i["x-uid"],title:i.title}})),o.refresh()}},"edit-field-title")},IsTablePageSize=()=>{const{dn:n}=client.useDesignable(),e=schema.useFieldSchema(),{t:s}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsSwitchItem,{title:s("Pagination"),checked:e["x-component-props"].pagination,onChange:i=>{e["x-component-props"].pagination||(e["x-component-props"]=I(A({},e["x-component-props"]),{pagination:!1})),e["x-component-props"].pagination=i,n.emit("patch",{schema:{"x-uid":e["x-uid"],"x-component-props":A({},e==null?void 0:e["x-component-props"])}}),n.refresh()}})},SchemaSettingsDatePickerType=()=>{var a,c,d;const n=schema.useFieldSchema(),e=schema.useField(),{dn:s}=client.useDesignable(),{t:i}=useTranslation(),o=client.useCollectionManager().getCollectionField(n==null?void 0:n["x-collection-field"])||{},l=((a=n==null?void 0:n["x-component-props"])==null?void 0:a.picker)||((d=(c=o==null?void 0:o.uiSchema)==null?void 0:c["x-component-props"])==null?void 0:d.picker)||"";return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:i("Date picker type"),schema:{type:"object",properties:{picker:{type:"string",title:tval("Picker type"),"x-component":"Select","x-decorator":"FormItem","x-decorator-props":{},default:l,enum:[{label:i("default"),value:""},{label:i("year"),value:"year"},{label:i("quarter"),value:"quarter"},{label:i("month"),value:"month"},{label:i("week"),value:"week"}]}}},onSubmit:u=>{const f={"x-uid":n["x-uid"]};f["x-component-props"]=n["x-component-props"]||{},n["x-component-props"]=A(A({},n["x-component-props"]||{}),u),f["x-component-props"]=n["x-component-props"],e.componentProps=n["x-component-props"];const m=e.path.entire.split(".");m.pop();const p=m.join(".");e.query(`${p}.*[0:].${n.name}`).forEach(g=>{g.props.name===n.name&&g.setComponentProps(A({},u))}),s.emit("patch",{schema:f}),s.refresh()}})};SchemaSettingsDatePickerType.displayName="SchemaSettingsDatePickerType";const useCustomPresets1=()=>{const n=schema.useFieldSchema(),{t:e}=useTranslation(),s=getDateRanges(),i=[{label:e("This year"),value:s.thisYear},...Array(5).fill(0).map((r,o)=>({label:client$2.dayjs().year()-o-1+e("year"),value:s.year(client$2.dayjs().year()-o-1)})),{label:e("This month"),value:s.thisMonth},{label:e("Last month"),value:s.lastMonth}];return n.name==="presets"?"{{ useCustomPresets1() }}":i},useCustomPresets=n=>"{{ "+n+"() }}",SchemaSettingsDatePresets=()=>{var l,a,c;const n=schema.useFieldSchema(),{dn:e}=client.useDesignable(),{t:s}=useTranslation(),r=client.useCollectionManager().getCollectionField(n==null?void 0:n["x-collection-field"])||{},o=((l=n==null?void 0:n["x-component-props"])==null?void 0:l.presets)||((c=(a=r==null?void 0:r.uiSchema)==null?void 0:a["x-component-props"])==null?void 0:c.presets)||"";return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:s("Date presets"),schema:{type:"object",properties:{presets:{type:"string",title:tval("Date presets"),"x-component":"Select","x-decorator":"FormItem","x-decorator-props":{},default:o,enum:[{label:s("default"),value:""},{label:s("Chuangxing presets"),value:'{{ useCustomPresets("useCustomPresets1") }}'}]}}},onSubmit:d=>{d.presets||(d.presets=void 0);const u={"x-uid":n["x-uid"]};u["x-component-props"]=n["x-component-props"]||{},n["x-component-props"]=A(A({},n["x-component-props"]||{}),d),u["x-component-props"]=n["x-component-props"],e.emit("patch",{schema:u}),e.refresh()}})};SchemaSettingsDatePresets.displayName="SchemaSettingsDatePresets";const getDateRanges=()=>({now:()=>client$2.dayjs().toISOString(),today:()=>[getStart(0,"day"),getEnd(0,"day")],yesterday:()=>[getStart(-1,"day"),getEnd(-1,"day")],tomorrow:()=>[getStart(1,"day"),getEnd(1,"day")],thisWeek:()=>[getStart(0,"isoWeek"),getEnd(0,"isoWeek")],lastWeek:()=>[getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")],nextWeek:()=>[getStart(1,"isoWeek"),getEnd(1,"isoWeek")],year:n=>[getStart(n-client$2.dayjs().year(),"year"),getEnd(n-client$2.dayjs().year(),"year")],thisIsoWeek:()=>[getStart(0,"isoWeek"),getEnd(0,"isoWeek")],lastIsoWeek:()=>[getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")],nextIsoWeek:()=>[getStart(1,"isoWeek"),getEnd(1,"isoWeek")],thisMonth:()=>[getStart(0,"month"),getEnd(0,"month")],lastMonth:()=>[getStart(-1,"month"),getEnd(-1,"month")],nextMonth:()=>[getStart(1,"month"),getEnd(1,"month")],thisQuarter:()=>[getStart(0,"quarter"),getEnd(0,"quarter")],lastQuarter:()=>[getStart(-1,"quarter"),getEnd(-1,"quarter")],nextQuarter:()=>[getStart(1,"quarter"),getEnd(1,"quarter")],thisYear:()=>[getStart(0,"year"),getEnd(0,"year")],lastYear:()=>[getStart(-1,"year"),getEnd(-1,"year")],nextYear:()=>[getStart(1,"year"),getEnd(1,"year")],last7Days:()=>[getStart(-6,"days"),getEnd(0,"days")],next7Days:()=>[getStart(1,"day"),getEnd(7,"days")],last30Days:()=>[getStart(-29,"days"),getEnd(0,"days")],next30Days:()=>[getStart(1,"day"),getEnd(30,"days")],last90Days:()=>[getStart(-89,"days"),getEnd(0,"days")],next90Days:()=>[getStart(1,"day"),getEnd(90,"days")]}),getStart=(n,e)=>client$2.dayjs().add(n,e==="isoWeek"?"week":e).startOf(e),getEnd=(n,e)=>client$2.dayjs().add(n,e==="isoWeek"?"week":e).endOf(e),SchemaSettingsSubmitDataType=()=>{var i;const{dn:n}=client.useDesignable(),{t:e}=useTranslation(),s=schema.useFieldSchema();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsSwitchItem,{title:e("Select submit data type"),checked:!!((i=s==null?void 0:s["x-action-settings"])!=null&&i.isDeltaChanged),onChange:r=>{s["x-action-settings"].isDeltaChanged=r,n.emit("patch",{schema:{"x-uid":s["x-uid"],"x-action-settings":A({},s["x-action-settings"])}})}})};SchemaSettingsSubmitDataType.displayName="SchemaSettingsSubmitDataType";const LinkManager=()=>{const[n,e]=React.useState(!1),[s,i]=React.useState({}),[r,o]=React.useState([]),{data:l,run:a}=client.useRequest({url:"/link-manage:get"}),{run:c}=client.useRequest({url:"/link-manage:set",params:{id:s.id,link:s.link}});React.useEffect(()=>{l&&o(l.data)},[l]);const d=p=>{i(p),e(!0)},u=()=>{e(!1)},f=()=>{c();const p=r.map(g=>g.id===s.id?s:g);o(p),e(!1),i({})},m=[{title:"名称",dataIndex:"name",key:"name",render:p=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{children:p})},{title:"链接",dataIndex:"link",key:"link",render:p=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{children:p})},{title:"Action",key:"action",render:(p,g)=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Space,{size:"middle",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{onClick:()=>d(g),children:"编辑"})})}];return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:[r&&__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Table,{columns:m,dataSource:r}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Drawer,{title:"设定链接地址",width:720,onClose:u,open:n,styles:{body:{paddingBottom:80}},extra:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Space,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:u,children:"关闭"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:f,type:"primary",children:"提交"})]}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Form,{layout:"vertical",children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{name:"name",label:"Name",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{placeholder:"Please enter Name",defaultValue:s==null?void 0:s.name,disabled:!0})}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{name:"link",label:"Link",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{onChange:p=>i(I(A({},s),{link:p.target.value})),placeholder:"Please enter Link",defaultValue:s==null?void 0:s.link})})]})})]})},TokenConfigurationResourceKey="token-configuration",getSSKey=n=>`TACHYBASE_PLUGIN_TOKEN_CONFIGURATION_${n}`,useMapConfiguration=n=>{const e=React.useMemo(()=>{const i=sessionStorage.getItem(getSSKey(n));return i&&JSON.parse(i)},[n]),{data:s}=client.useRequest({resource:TokenConfigurationResourceKey,action:"get",params:{type:n}},{onSuccess(i){sessionStorage.setItem(getSSKey(n),JSON.stringify(i==null?void 0:i.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!e});return e||(s==null?void 0:s.data)},TokenTypes=[{label:"飞书",value:"feishu"}],BaseConfiguration=({type:n,children:e})=>{const[s,i]=ahooks.useBoolean(!1),r=client.useAPIClient(),[o]=antd.Form.useForm(),l=useMapConfiguration(n);React.useEffect(()=>{l&&(o.setFieldsValue(l),i.toggle())},[l]);const a=React.useMemo(()=>r.resource(TokenConfigurationResourceKey),[r]),c=d=>{a.set(I(A({},d),{type:n})).then(u=>{sessionStorage.removeItem(getSSKey(n)),i.toggle(),antd.message.success("保存成功")}).catch(u=>{antd.message.success("保存失败")})};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Form,{disabled:s,form:o,layout:"vertical",onFinish:c,children:[e,s?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{disabled:!1,onClick:i.toggle,children:"编辑"}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{disabled:!1,type:"primary",htmlType:"submit",children:"保存"})})]})},AMapConfiguration=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(BaseConfiguration,{type:"feishu",children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{required:!0,name:"app_id",label:"App ID",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{})}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{required:!0,name:"app_secret",label:"App Secret",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{})}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{required:!0,name:"chat_id",label:"Chat ID",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{})})]}),components={feishu:AMapConfiguration},tabList=TokenTypes.map(n=>I(A({},n),{component:components[n.value]})),Configuration=()=>{const n=reactRouterDom.useLocation(),e=new URLSearchParams(n.search);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Card,{bordered:!0,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Tabs,{type:"card",defaultActiveKey:e.get("tab"),children:tabList.map(s=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Tabs.TabPane,{tab:s.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(s.component,{type:s.value})},s.value))})})};class PluginSettingsHelper{constructor(e){this.app=e}load(){return R(this,null,function*(){this.app.systemSettingsManager.add("system-services.hera",{title:tval("Hera integration"),icon:"HomeOutlined"}),this.app.systemSettingsManager.add("system-services.hera.token",{title:tval("Third-party integration configuration"),icon:"ShareAltOutlined",Component:Configuration}),this.app.systemSettingsManager.add("system-services.hera.linkmanage",{title:tval("Link manager"),icon:"ShareAltOutlined",Component:LinkManager})})}}class PluginCoreClient extends client.Plugin{constructor(){super(...arguments);b(this,"locale")}afterAdd(){return R(this,null,function*(){yield this.app.pm.add(PluginGroupBlock),yield this.app.pm.add(EmbedPlugin),yield this.app.pm.add(PluginHeraVersion),yield this.app.pm.add(PluginPDF),yield this.app.pm.add(PluginOutbound),yield this.app.pm.add(PluginFieldAppends),yield this.app.pm.add(PluginCustomComponents),yield this.app.pm.add(PluginSheet)})}registerSettings(){return R(this,null,function*(){this.schemaSettingsManager.add(customComponentDispatcherSettings),this.schemaSettingsManager.addItem("fieldSettings:component:DatePicker","datePickerType",{Component:SchemaSettingsDatePickerType}),this.schemaSettingsManager.addItem("fieldSettings:component:DatePicker","datePresets",{Component:SchemaSettingsDatePresets}),this.schemaSettingsManager.addItem("actionSettings:updateSubmit","submitDataType",{Component:SchemaSettingsSubmitDataType}),this.schemaSettingsManager.addItem("FormItemSettings","hera-divider",{type:"divider",useVisible(){const s=client.useFormulaTitleVisible(),i=usePaginationVisible();return s||i}}),this.schemaSettingsManager.addItem("FormItemSettings","isTablePageSize",{Component:IsTablePageSize,useVisible:usePaginationVisible})})}registerScopesAndComponents(){return R(this,null,function*(){this.app.addScopes({useGetCustomAssociatedComponents,useGetCustomComponents,useCustomPresets1,useCustomPresets}),this.app.addComponents({AssociatedField,CalcResult,CodeMirror:components$1.CodeMirror,CustomAssociatedField,CustomComponentDispatcher,CustomComponentStub,CustomField,EditTitle,Expression,SettingBlock:SettingBlockInitializer,SignatureInput,ExcelFile})})}registerRouters(){return R(this,null,function*(){})}registerSchemaInitializer(){return R(this,null,function*(){const s={name:"setting",title:tval("System setting"),Component:"SettingBlock"},i={type:"item",name:"refreshAction",title:tval("Refresh"),Component:"RefreshActionInitializer",schema:{"x-align":"right"}};this.app.schemaInitializerManager.addItem("page:addBlock",s.name,s),this.app.schemaInitializerManager.addItem("kanban:configureActions",i.name,i);const r={name:"addCustomComponent",title:tval("Add custom component"),Component:"BlockItemInitializer",schema:{type:"void","x-editable":!1,"x-decorator":"FormItem","x-settings":"customComponentDispatcherSettings","x-component":"CustomComponentDispatcher","x-component-props":{component:"CustomComponentStub"}}};this.app.schemaInitializerManager.addItem("form:configureFields",r.name,r),this.app.schemaInitializerManager.addItem("details:configureFields",r.name,r)})}registerInterfaces(){return R(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([AssociatedFieldInterface,CalcFieldInterface,CustomFieldInterface,CustomAssociatedFieldInterface,SignaturePadFieldInterface,ExcelFieldInterface,TstzrangeFieldInterface])})}afterLoad(){return R(this,null,function*(){yield this.registerSchemaInitializer()})}load(){return R(this,null,function*(){this.locale=new Locale(this.app),yield new PluginSettingsHelper(this.app).load(),yield this.registerScopesAndComponents(),yield this.registerSettings(),yield this.registerRouters(),yield this.registerInterfaces()})}}exports.CustomComponentType=CustomComponentType,exports.PluginCoreClient=PluginCoreClient,exports.default=PluginCoreClient,exports.usePDFViewerRef=usePDFViewerRef,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});