@nocobase/plugin-action-import 2.1.2 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client-v2.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from './dist/client-v2';
2
+ export { buildImportFieldOptions } from './src/client-v2/buildImportFieldOptions';
3
+ export type { ImportFieldOption, ImportFieldOptionSource } from './src/client-v2/buildImportFieldOptions';
2
4
  export { default } from './dist/client-v2';
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@emotion/css"),require("react-dom"),require("@formily/antd-v5"),require("@formily/reactive"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/client-v2"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-import",["react-i18next","@emotion/css","react-dom","@formily/antd-v5","@formily/reactive","@formily/react","@ant-design/icons","@nocobase/flow-engine","@nocobase/client-v2","@formily/shared","react","antd","@nocobase/client","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-action-import"]=t(require("react-i18next"),require("@emotion/css"),require("react-dom"),require("@formily/antd-v5"),require("@formily/reactive"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/client-v2"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-action-import"]=t(e["react-i18next"],e["@emotion/css"],e["react-dom"],e["@formily/antd-v5"],e["@formily/reactive"],e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e["@nocobase/client-v2"],e["@formily/shared"],e.react,e.antd,e["@nocobase/client"],e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,n,r,o,i,a,l,c,u,s,p,m,d,f){return function(){var y={574:function(e,t,n){var r,o;void 0===(o="function"==typeof(r=function(){"use strict";function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){l(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function r(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function o(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n.g&&n.g.global===n.g?n.g:void 0,a=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(e,n,a){var l=i.URL||i.webkitURL,c=document.createElement("a");c.download=n=n||e.name||"download",c.rel="noopener","string"==typeof e?(c.href=e,c.origin===location.origin?o(c):r(c.href)?t(e,n,a):o(c,c.target="_blank")):(c.href=l.createObjectURL(e),setTimeout(function(){l.revokeObjectURL(c.href)},4e4),setTimeout(function(){o(c)},0))}:"msSaveOrOpenBlob"in navigator?function(e,n,i){if(n=n||e.name||"download","string"!=typeof e){var a;navigator.msSaveOrOpenBlob((void 0===(a=i)?a={autoBom:!1}:"object"!=typeof a&&(console.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e),n)}else if(r(e))t(e,n,i);else{var l=document.createElement("a");l.href=e,l.target="_blank",setTimeout(function(){o(l)})}}:function(e,n,r,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var l="application/octet-stream"===e.type,c=/constructor/i.test(i.HTMLElement)||i.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||l&&c||a)&&"u">typeof FileReader){var s=new FileReader;s.onloadend=function(){var e=s.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=e:location=e,o=null},s.readAsDataURL(e)}else{var p=i.URL||i.webkitURL,m=p.createObjectURL(e);o?o.location=m:location.href=m,o=null,setTimeout(function(){p.revokeObjectURL(m)},4e4)}});i.saveAs=l.saveAs=l,e.exports=l})?r.apply(t,[]):r)||(e.exports=o)},375:function(e){"use strict";e.exports=a},477:function(e){"use strict";e.exports=t},418:function(e){"use strict";e.exports=r},230:function(e){"use strict";e.exports=i},992:function(e){"use strict";e.exports=o},166:function(e){"use strict";e.exports=u},342:function(e){"use strict";e.exports=m},485:function(e){"use strict";e.exports=c},694:function(e){"use strict";e.exports=l},768:function(e){"use strict";e.exports=d},59:function(e){"use strict";e.exports=p},773:function(e){"use strict";e.exports=f},155:function(e){"use strict";e.exports=s},514:function(e){"use strict";e.exports=n},953:function(t){"use strict";t.exports=e}},v={};function b(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return y[e].call(n.exports,n,n.exports,b),n.exports}b.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return b.d(t,{a:t}),t},b.d=function(e,t){for(var n in t)b.o(t,n)&&!b.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},b.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),b.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},b.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},b.g.importScripts&&(g=b.g.location+"");var g,h=b.g.document;if(!g&&h&&(h.currentScript&&"SCRIPT"===h.currentScript.tagName.toUpperCase()&&(g=h.currentScript.src),!g)){var x=h.getElementsByTagName("script");if(x.length)for(var w=x.length-1;w>-1&&(!g||!/^http(s?):/.test(g));)g=x[w--].src}if(!g)throw Error("Automatic publicPath is not supported in this browser");b.p=g.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var S={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-action-import/dist/client/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",a=i.indexOf(o);e=a>=0?i.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-import/dist/client/"}b.p=e}(),!function(){"use strict";b.r(S),b.d(S,{useImportStartAction:function(){return Q},default:function(){return eV},ImportActionInitializer:function(){return x},ImportContextProvider:function(){return em},DownloadTips:function(){return h},ImportPluginProvider:function(){return ep},ImportDesigner:function(){return F},ImportWarning:function(){return g},ImportActionModel:function(){return eD},PluginActionImportClient:function(){return e$},buildImportFieldOptions:function(){return s},initImportSettings:function(){return v},useDownloadXlsxTemplateAction:function(){return J}});var e=b(166),t=b(342),n=b(155),r=b.n(n),o=["createdAt","createdBy","updatedAt","updatedBy"],i=["hasOne","belongsTo","hasMany","belongsToMany","belongsToArray"],a=function(e){return(null==e?void 0:e.target)&&i.includes(e.type)},l=function(e){return!(null==e?void 0:e.interface)||o.includes(e.interface)},c=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{name:e.name,title:t(e),schema:null==e?void 0:e.uiSchema,disabled:n}},u=function(e,t,n){var r,o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(l(e))return null;if(!a(e))return c(e,t);var s=(n(e)||[]).map(function(e){return l(e)?null:a(e)?i>=1?c(e,t,!0):u(e,t,n,i+1):u(e,t,n)}).filter(Boolean);return s.length?(r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},c(e,t)),o=o={children:s},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r):c(e,t,!0)},s=function(e,t,n){return(e||[]).map(function(e){return u(e,t,n,+!!a(e))}).filter(Boolean)},p=function(e){var n=(0,t.useCollectionManager_deprecated)().getCollectionFields,r=n(e),o=(0,t.useCompile)();return s(r,function(e){var t;return o(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return n(e.target)})},m=b(768),d=b(59),f=b(953),y="action-import",v=function(e){return{importColumns:null==e?void 0:e.filter(function(e){return!e.children&&!e.disabled}).map(function(e){return{dataIndex:[e.name]}}),explain:""}},g=function(){var e=(0,f.useTranslation)([y,"client"],{nsMode:"fallback"}).t;return r().createElement(d.Alert,{type:"warning",style:{marginBottom:"10px"},message:e("Import warnings",{limit:2e3})})},h=function(){var e=(0,f.useTranslation)([y,"client"],{nsMode:"fallback"}).t;return r().createElement(d.Alert,{type:"info",style:{marginBottom:"10px",whiteSpace:"pre-line"},message:e("Download tips")})},x=function(){var n=(0,t.useSchemaInitializerItem)(),o=(0,t.useSchemaInitializer)().insert,i=p((0,t.useCollection_deprecated)().name),a={type:"void",title:'{{ t("Import") }}',"x-component":"ImportAction","x-action":"importXlsx","x-settings":"actionSettings:import","x-toolbar":"ActionSchemaToolbar"};return r().createElement(t.SchemaInitializerItem,{title:n.title,onClick:function(){m.lodash.set(a,"x-action-settings.importSettings",v(i));var t,r=(0,e.merge)(a||{},n.schema||{});null==n||null==(t=n.schemaInitialize)||t.call(n,r),o(r)}})},w=b(418),O=b(230);function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function j(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function A(){var e=j(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return A=function(){return e},e}function E(){var e=j(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return E=function(){return e},e}var P=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],C=function(){var e=(0,f.useTranslation)(y).t,n=p((0,t.useCollection_deprecated)().name),r=(0,t.useCompile)();return{importSettingsSchema:{type:"void","x-component":"Grid",properties:{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(y,'"}) }}'),"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:(0,t.css)(A())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":t.Cascader,required:!0,"x-use-component-props":function(){return{options:r(n)}},"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(y,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(y,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,t.css)(E())}}}}}},beforeUploadHandler:function(){return!1},uploadValidator:function(t,n){if(t.length>1)return{type:"error",message:e("Only one file is allowed to be uploaded")};var r,o=null!=(r=t[0])?r:{};return P.includes(o.type)?"":{type:"error",message:e("Please upload the file of Excel")}},validateUpload:function(e,t,n){var r,o,i,a=(function(e){if(Array.isArray(e))return e}(n)||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),1!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(n)||function(e){if(e){if("string"==typeof e)return I(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return I(e,1)}}(n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];t.disabled=(null==a?void 0:a.length)===0,r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},t.componentProps),o=o={disabled:(null==a?void 0:a.length)===0||(null==(i=e.errors)?void 0:i.length)>0},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),t.componentProps=r}}};function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function T(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){T(e,t,n[t])})}return e}var F=function(){var e,o,i,a,l,c,u,s=(0,O.useField)(),p=(0,O.useFieldSchema)(),m=(0,f.useTranslation)().t,d=(0,t.useDesignable)().dn,y=function(e){if(Array.isArray(e))return e}(e=(0,n.useState)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return k(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return k(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),v=y[0],b=y[1],g=C().importSettingsSchema;return(0,n.useEffect)(function(){b(g)},[s.address,null==p||null==(i=p["x-action-settings"])?void 0:i.importSettings]),r().createElement(t.GeneralSchemaDesigner,{disableInitializer:!0},r().createElement(t.SchemaSettingsModalItem,{title:m("Edit button"),schema:{type:"object",title:m("Edit button"),properties:{title:{"x-decorator":"FormItem","x-component":"Input",title:m("Button title"),default:p.title,"x-component-props":{}},icon:{"x-decorator":"FormItem","x-component":"IconPicker",title:m("Button icon"),default:null==p||null==(a=p["x-component-props"])?void 0:a.icon,"x-component-props":{}},type:{"x-decorator":"FormItem","x-component":"Radio.Group",title:m("Button background color"),default:(null==p||null==(l=p["x-component-props"])?void 0:l.danger)?"danger":(null==p||null==(c=p["x-component-props"])?void 0:c.type)==="primary"?"primary":"default",enum:[{value:"default",label:'{{t("Default")}}'},{value:"primary",label:'{{t("Highlight")}}'},{value:"danger",label:'{{t("Danger red")}}'}]}}},onSubmit:function(e){var t,n=e.title,r=e.icon,o=e.type;p.title=n,s.title=n,s.componentProps.icon=r,s.componentProps.danger="danger"===o,s.componentProps.type=o,p["x-component-props"]=p["x-component-props"]||{},p["x-component-props"].icon=r,p["x-component-props"].danger="danger"===o,p["x-component-props"].type=o,d.emit("patch",{schema:(T(t={},"x-uid",p["x-uid"]),T(t,"title",n),T(t,"x-component-props",M({},p["x-component-props"])),t)}),d.refresh()}}),r().createElement(t.SchemaSettingsActionModalItem,{title:m("Importable fields"),schema:v,initialValues:M({},null!=(o=null==p||null==(u=p["x-action-settings"])?void 0:u.importSettings)?o:{}),components:{ArrayItems:w.ArrayItems},onSubmit:function(e){var t,n=e.importColumns,r=e.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title}});p["x-action-settings"].importSettings={importColumns:o,explain:r},d.emit("patch",{schema:(T(t={},"x-uid",p["x-uid"]),T(t,"x-action-settings",p["x-action-settings"]),t)}),d.refresh()}}),r().createElement(t.SchemaSettingsDivider,null),r().createElement(t.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:function(e){return"Space"===e["x-component"]||e["x-component"].endsWith("ActionBar")},confirm:{title:m("Delete action")}}))},D=b(514),_=(0,n.createContext)(null);_.displayName="ImportContext";var B=function(){return(0,n.useContext)(_)},R=b(375),N=b(574);function q(){var e,t,n=(e=["\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return q=function(){return n},n}var U=function(e){var n=(0,f.useTranslation)(y).t,o=B(),i=o.importModalVisible,a=o.importStatus,l=o.importResult,c=o.setImportModalVisible,u=null!=l?l:{},s=u.data,p=u.meta,m=function(){c(!1)};return r().createElement(d.Modal,{title:n("Import Data"),width:"50%",styles:{body:{height:"calc(80vh - 200px)"}},open:i,footer:null,closable:2===a,onCancel:m},r().createElement("div",{className:(0,t.css)(q())},1===a&&r().createElement(d.Spin,{indicator:r().createElement(R.LoadingOutlined,{style:{fontSize:24},spin:!0}),tip:n("Excel data importing")}),2===a&&r().createElement(d.Space,{direction:"vertical",align:"center"},r().createElement(R.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),r().createElement("p",null,function(e){if(!e)return null;var t=e.data,r=e.meta;if(r)return n("{{successCount}} records have been successfully imported",function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},null!=r?r:{}));var o=["".concat(n("Total records"),": ").concat(t.total||0),"".concat(n("Successfully imported"),": ").concat(t.success||0)];return t.skipped>0&&o.push("".concat(n("Skipped"),": ").concat(t.skipped)),t.updated>0&&o.push("".concat(n("Updated"),": ").concat(t.updated)),o.join(", ")}(l)),r().createElement(d.Space,null,(null==p?void 0:p.failureCount)>0&&r().createElement(d.Button,{onClick:function(){var e=new Blob([new Int8Array(null==s?void 0:s.data)],{type:"application/x-xls"});(0,N.saveAs)(e,"fail.xlsx")}},n("To download the failure data")),r().createElement(d.Button,{type:"primary",onClick:m},n("Done"))))))},L=b(773),z=b.n(L);function X(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function H(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){X(i,r,o,a,l,"next",e)}function l(e){X(i,r,o,a,l,"throw",e)}a(void 0)})}}function $(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var V=function(){for(var e=(0,t.useActionContext)().fieldSchema,n=(0,O.useFieldSchema)(),r=e||n;r&&"importXlsx"!==r["x-action"];)console.log("schema",r=r.parent);return{schema:r}},G=function(e){return e&&Array.isArray(e)?e:[]},W=function(e){if(!e)return"";if("string"==typeof e){var t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||e}if("string"==typeof e.message)return e.message;if(e.error)return W(e.error);var n=e.errors||e.messages;return Array.isArray(n)?n.map(W).filter(Boolean).join("\n"):""},K=function(e){var t;return W(null==e||null==(t=e.response)?void 0:t.data)||W(null==e?void 0:e.data)||(null==e?void 0:e.message)||"Import failed"},J=function(){var e=(0,t.useBlockRequestContext)().resource,n=(0,t.useCompile)(),r=(0,t.useCollectionManager_deprecated)(),o=r.getCollectionJoinField,i=r.getCollectionField,a=(0,t.useCollection_deprecated)(),l=a.name,c=a.title,u=V().schema;return{run:function(){return H(function(){var t,r,a,s,p,m,d;return $(this,function(f){switch(f.label){case 0:return s=(a=z().cloneDeep(null!=(t=null==u||null==(r=u["x-action-settings"])?void 0:r.importSettings)?t:{})).importColumns,p=a.explain,m=G(s).map(function(e){var t=i("".concat(l,".").concat(e.dataIndex[0]));if(t){if(e.defaultTitle=n(null==t||null==(r=t.uiSchema)?void 0:r.title)||t.name,e.dataIndex.length>1){var r,a,c=o("".concat(l,".").concat(e.dataIndex.join(".")));if(!c)return;e.defaultTitle=e.defaultTitle+"/"+n(null==c||null==(a=c.uiSchema)?void 0:a.title)||c.name}return"chinaRegion"===t.interface&&e.dataIndex.push("name"),e}}).filter(Boolean),[4,e.downloadXlsxTemplate({values:{title:n(c),explain:p,columns:n(m)}},{method:"post",responseType:"blob"})];case 1:return d=new Blob([f.sent().data],{type:"application/x-xls"}),(0,N.saveAs)(d,"".concat(n(c),".xlsx")),[2]}})})()}}},Q=function(){var e,r=(0,t.useBlockRequestContext)().service,o=(0,t.useCompile)(),i=(0,t.useCollectionManager_deprecated)(),a=i.getCollectionJoinField,l=i.getCollectionField,c=(0,t.useCollection_deprecated)().name,u=V().schema,s=(0,O.useForm)(),p=(0,t.useActionContext)(),m=p.setVisible,d=p.setErrorMessage,f=B(),y=f.setImportModalVisible,v=f.setImportStatus,b=f.setImportResult,g=s.values.upload,h=(0,t.useDataBlockResource)();return(0,n.useEffect)(function(){s.reset()},[s]),{run:function(){return H(function(){var e,t,n,i,p,f,g,x,w,S,O,I,j,A,E;return $(this,function(P){switch(P.label){case 0:f=(p=z().cloneDeep(null!=(e=null==u||null==(t=u["x-action-settings"])?void 0:t.importSettings)?e:{})).importColumns,g=p.explain,x=G(f).map(function(e){var t=l("".concat(c,".").concat(e.dataIndex[0]));if(t){if(e.defaultTitle=o(null==t||null==(n=t.uiSchema)?void 0:n.title)||t.name,e.dataIndex.length>1){var n,r,i=a("".concat(c,".").concat(e.dataIndex.join(".")));if(!i)return;e.defaultTitle=e.defaultTitle+"/"+o(null==i||null==(r=i.uiSchema)?void 0:r.title)||i.name}return"chinaRegion"===t.interface&&e.dataIndex.push("name"),e}}).filter(Boolean),w=new FormData,S=s.values.upload.map(function(e){return e.originFileObj}),w.append("file",S[0]),w.append("columns",JSON.stringify(x)),w.append("explain",g),O=(null==u||null==(n=u["x-action-settings"])?void 0:n.importMode)||"auto",I=(null==u||null==(i=u["x-action-settings"])?void 0:i.timeout)||6e5,null==d||d(""),m(!1),y(!0),v(1),P.label=1;case 1:return P.trys.push([1,6,,7]),[4,h.importXlsx({values:w,mode:O,timeout:I},{skipNotify:!0})];case 2:if(j=P.sent().data,null==d||d(""),s.reset(),j.data.taskId)return[3,4];return b(j),[4,null==r||null==(A=r.refresh)?void 0:A.call(r)];case 3:return P.sent(),v(2),[3,5];case 4:y(!1),m(!1),P.label=5;case 5:return[3,7];case 6:return E=P.sent(),null==d||d(K(E)),y(!1),m(!0),[3,7];case 7:return[2]}})})()},disabled:(null==g?void 0:g.length)===0||(null==(e=s.errors)?void 0:e.length)>0}},Y=b(477);function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ee(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Z(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function et(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function en(){var e=et(["\n max-height: min(42vh, 420px);\n overflow: auto;\n white-space: pre-wrap;\n word-break: break-word;\n line-height: 1.6;\n padding-right: 8px;\n "]);return en=function(){return e},e}function er(){var e=et(["\n margin-bottom: 16px;\n "]);return er=function(){return e},e}function eo(){var e=et(["\n .ant-formily-item-label {\n height: var(--controlHeightLG);\n }\n "]);return eo=function(){return e},e}function ei(){var e=et(["\n margin-top: 5px;\n "]);return ei=function(){return e},e}var ea=function(e){var t=e.errorMessage,n=(0,f.useTranslation)(y).t;return t?r().createElement(d.Alert,{type:"error",showIcon:!0,message:n("Import failed"),description:r().createElement("div",{className:(0,Y.css)(en())},t),className:(0,Y.css)(er())}):null},el={type:"void",name:"import-modal",title:'{{ t("Import Data", {ns: "'.concat(y,'" }) }}'),"x-component":"Action.Modal","x-decorator":"Form","x-component-props":{width:"100%",style:{maxWidth:"750px"},className:(0,Y.css)(eo())},properties:{formLayout:{type:"void","x-component":"FormLayout",properties:{importError:{type:"void","x-component":"ImportErrorAlert","x-visible":"{{ !!importErrorMessage }}","x-component-props":{errorMessage:"{{ importErrorMessage }}"}},warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:'{{ t("Step 1: Download template", {ns: "'.concat(y,'" }) }}'),"x-component":"FormItem","x-acl-ignore":!0,properties:{tip:{type:"void","x-component":"DownloadTips"},downloadAction:{type:"void",title:'{{ t("Download template", {ns: "'.concat(y,'" }) }}'),"x-component":"Action","x-component-props":{className:(0,Y.css)(ei()),useAction:"{{ useDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:'{{ t("Step 2: Upload Excel", {ns: "'.concat(y,'" }) }}'),"x-decorator":"FormItem","x-acl-ignore":!0,"x-component":"Upload.Dragger","x-validator":"{{ uploadValidator }}","x-component-props":{action:"",height:"150px",tipContent:'{{ t("Upload placeholder", {ns: "'.concat(y,'" }) }}'),beforeUpload:"{{ beforeUploadHandler }}"}}}},footer:{"x-component":"Action.Modal.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{cancel:{type:"void",title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},startImport:{type:"void",title:'{{ t("Start import", {ns: "'.concat(y,'" }) }}'),"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useImportStartAction }}"},"x-reactions":{dependencies:["upload"],fulfill:{run:"validateUpload($form, $self, $deps)"}}}}}}}}},ec=function(e){var o,i,a=ee((0,n.useState)(!1),2),l=a[0],c=a[1],u=ee((0,n.useState)(""),2),s=u[0],p=u[1],m=(0,t.useCompile)(),d=(0,O.useFieldSchema)();return r().createElement(t.ActionContextProvider,{value:{visible:l,setVisible:c,fieldSchema:d,errorMessage:s,setErrorMessage:p}},r().createElement(t.Action,(o=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({icon:e.icon||"uploadoutlined",title:m((null==d?void 0:d.title)||"t('Import')")},e),i=i={onClick:function(){p(""),c(!0)}},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))}),o)),r().createElement(t.SchemaComponent,{schema:el,components:{ImportErrorAlert:ea},scope:{importErrorMessage:s}}))};function eu(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function es(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return eu(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eu(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var ep=function(e){var n=C(),o=n.uploadValidator,i=n.beforeUploadHandler,a=n.validateUpload;return r().createElement(t.SchemaComponentOptions,{components:{ImportActionInitializer:x,ImportDesigner:F,ImportWarning:g,DownloadTips:h,ImportAction:ec},scope:{uploadValidator:o,validateUpload:a,beforeUploadHandler:i,useDownloadXlsxTemplateAction:J,useImportStartAction:Q}},r().createElement(em,null,e.children))},em=function(e){var t=es((0,n.useState)(!1),2),o=t[0],i=t[1],a=es((0,n.useState)(1),2),l=a[0],c=a[1],u=es((0,n.useState)(null),2),s=u[0],p=u[1];return r().createElement(_.Provider,{value:{importModalVisible:o,setImportModalVisible:i,importStatus:l,setImportStatus:c,importResult:s,setImportResult:p}},(0,D.createPortal)(r().createElement(U,null),document.body),e.children)},ed=b(992),ef=b(485),ey=b(694);function ev(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eb(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function eg(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){eb(i,r,o,a,l,"next",e)}function l(e){eb(i,r,o,a,l,"throw",e)}a(void 0)})}}function eh(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ex(e){return(ex=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ew(e,t){return(ew=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eS(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||eI(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eO(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function eI(e,t){if(e){if("string"==typeof e)return ev(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ev(e,t)}}function ej(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ej=function(){return!!e})()}function eA(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function eE(){var e=eO(["\n max-height: min(42vh, 420px);\n overflow: auto;\n white-space: pre-wrap;\n word-break: break-word;\n line-height: 1.6;\n padding-right: 8px;\n "]);return eE=function(){return e},e}function eP(){var e=eO(["\n .import-warning {\n margin-bottom: ","px;\n }\n\n .import-step {\n margin-bottom: ","px;\n }\n\n .import-step-title {\n margin-bottom: ","px;\n color: ",";\n line-height: ",";\n }\n\n .import-download-action {\n margin-top: ","px;\n }\n\n .import-upload-wrapper {\n margin-bottom: ","px;\n }\n\n .import-upload-dragger-shell {\n height: 150px;\n border: 1px dashed ",";\n border-radius: ","px;\n background: ",";\n transition: border-color 0.2s;\n }\n\n .import-upload-dragger-shell:hover {\n border-color: ",";\n }\n\n .import-upload-dragger-shell .ant-upload-wrapper,\n .import-upload-dragger-shell .ant-upload,\n .import-upload-dragger-shell .ant-upload-drag {\n width: 100%;\n height: 100%;\n border: 0;\n background: transparent;\n }\n\n .import-upload-dragger-shell .ant-upload-drag-container {\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .import-upload-dragger-shell .ant-upload-list {\n display: none;\n }\n\n .import-upload-file {\n display: flex;\n align-items: center;\n column-gap: ","px;\n min-height: ","px;\n margin-top: ","px;\n padding: 0 ","px;\n border-radius: ","px;\n color: ",";\n line-height: ",";\n transition: background-color 0.2s;\n }\n\n .import-upload-file:hover {\n background: ",";\n }\n\n .import-upload-file-icon {\n color: ",";\n font-size: ","px;\n }\n\n .import-upload-file-name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .import-upload-file-remove {\n color: ",";\n }\n\n .import-upload-file-remove:hover {\n color: ",";\n background: transparent;\n }\n\n .import-upload-placeholder {\n padding: 0 ","px;\n color: ",";\n line-height: ",";\n text-align: center;\n }\n\n .import-upload-error {\n margin-top: ","px;\n margin-bottom: ","px;\n color: ",";\n line-height: ",";\n word-break: break-word;\n }\n\n .import-footer {\n display: flex;\n justify-content: flex-end;\n gap: ","px;\n margin-top: ","px;\n }\n "]);return eP=function(){return e},e}function eC(){var e=eO(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return eC=function(){return e},e}function ek(){var e=eO(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return ek=function(){return e},e}var eT=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],eM=function(e){if(!e)return"";if("string"==typeof e){var t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||e}if("string"==typeof e.message)return e.message;if(e.error)return eM(e.error);var n=e.errors||e.messages;return Array.isArray(n)?n.map(eM).filter(Boolean).join("\n"):""},eF=function(e){var t;return eM(null==e||null==(t=e.response)?void 0:t.data)||eM(null==e?void 0:e.data)||(null==e?void 0:e.message)||"Import failed"},eD=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=ex(t),eh(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,ej()?Reflect.construct(t,r||[],ex(this).constructor):t.apply(this,r)),"defaultProps",{title:(0,ey.escapeT)("Import"),type:"default",icon:"uploadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&ew(n,e),t=[{key:"getAclActionName",value:function(){return"importXlsx"}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(ef.ActionModel);function e_(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eB(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eR(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){eB(e,t,n[t])})}return e}eh(eD,"scene",ef.ActionSceneEnum.collection),eD.define({label:(0,ey.escapeT)("Import")}),eD.registerFlow({key:"importSettings",title:(0,ey.escapeT)("Import settings"),on:"click",steps:{import:{handler:function(e){return eg(function(){var t,n,o,i,a,l,c,u,s,p,m,f;return eA(this,function(v){switch(v.label){case 0:var b;return t=(0,ed.observable)({status:"",result:null,errorMessage:""}),o=(n=e.model.context.blockModel).resource,a=(i=n.collection).title,l=i.name,u=(c=e.model.getProps().importSettings).explain,s=(!(b=c.importColumns)||!Array.isArray(b)?[]:b).map(function(t){var r=e.model.context.dataSourceManager.getCollectionField("".concat(n.collection.dataSourceKey,".").concat(l,".").concat(t.dataIndex[0]));if(r){if(t.defaultTitle=e.t(null==r||null==(o=r.uiSchema)?void 0:o.title)||r.name,t.dataIndex.length>1){var o,i,a=e.model.context.dataSourceManager.getCollectionField("".concat(e.model.context.collection.dataSourceKey,".").concat(l,".").concat(t.dataIndex.join(".")));if(!a)return;t.defaultTitle=t.defaultTitle+"/"+e.t(null==a||null==(i=a.uiSchema)?void 0:i.title)||a.name}return t}}).filter(Boolean),p=function(){return eg(function(){var t;return eA(this,function(n){switch(n.label){case 0:return[4,o.runAction("downloadXlsxTemplate",{data:{title:e.t(a),explain:u,columns:function(e){if(Array.isArray(e))return ev(e)}(s)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(s)||eI(s)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},responseType:"blob",method:"post"})];case 1:return t=new Blob([n.sent()],{type:"application/x-xls"}),(0,N.saveAs)(t,"".concat(e.t(a),".xlsx")),[2]}})})()},m=function(t){if(0===t.length)return"";if(t.length>1)return e.t("Only one file is allowed to be uploaded",{ns:y});var n,r,o=null!=(n=t[0])?n:{},i=o.type||(null==(r=o.originFileObj)?void 0:r.type);return eT.includes(i)?"":e.t("Please upload the file of Excel",{ns:y})},f=(0,ey.observer)(function(i){var a=i.popover,c=e.t,f=d.theme.useToken().token,v=eS(r().useState([]),2),b=v[0],g=v[1],h=eS(r().useState(""),2),x=h[0],w=h[1],S=function(){a.close(),t.status="",t.result=null,t.errorMessage="",g([]),w("")};if("importing"===t.status)return r().createElement("div",{style:{display:"flex",justifyContent:"center",padding:40}},r().createElement(d.Spin,{tip:c("Excel data importing"),indicator:r().createElement(R.LoadingOutlined,{spin:!0,style:{fontSize:24}})}));if("imported"===t.status){var O,I=null==(O=t.result)?void 0:O.meta;return r().createElement(d.Space,{direction:"vertical",align:"center",style:{width:"100%",padding:24}},r().createElement(R.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),r().createElement("p",null,function(e){if(!e)return null;var t=((null==e?void 0:e.data)||e).successCount;if(t)return c("{{successCount}} records have been successfully imported",{successCount:t,ns:y})}(t.result)),r().createElement(d.Space,null,(null==I?void 0:I.failureCount)>0&&r().createElement(d.Button,{onClick:function(){var e,n,r=new Blob([new Int8Array(null==(n=t.result)||null==(e=n.data)?void 0:e.data)],{type:"application/x-xls"});(0,N.saveAs)(r,"fail.xlsx")}},c("To download the failure data")),r().createElement(d.Button,{type:"primary",onClick:S},c("Done"))))}if("error"===t.status)return r().createElement(d.Space,{direction:"vertical",style:{width:"100%"},size:f.marginLG},r().createElement(d.Alert,{type:"error",showIcon:!0,message:c("Import failed",{ns:y}),description:r().createElement("div",{className:(0,Y.css)(eE())},t.errorMessage)}),r().createElement(d.Space,{style:{width:"100%",justifyContent:"flex-end"}},r().createElement(d.Button,{onClick:S},c("Close")),r().createElement(d.Button,{type:"primary",onClick:function(){t.status="",t.errorMessage=""}},c("Back"))));var j=!b.length||!!x;return r().createElement("div",{className:(0,Y.css)(eP(),f.marginLG,f.marginLG,f.marginXS,f.colorText,f.lineHeight,f.marginXS,x?f.marginMD:0,f.colorBorder,f.borderRadius,f.colorBgContainer,f.colorPrimary,f.marginXXS,f.controlHeight,f.marginSM,f.paddingXXS,f.borderRadiusSM,f.colorText,f.lineHeight,f.colorFillAlter,f.colorTextSecondary,f.fontSizeLG,f.colorTextTertiary,f.colorText,f.padding,f.colorTextDescription,f.lineHeight,b.length?f.marginXXS:f.marginSM,f.marginMD,f.colorError,f.lineHeight,f.marginXS,f.marginLG)},r().createElement(d.Alert,{className:"import-warning",type:"warning",message:c("Import warnings",{ns:y,limit:2e3})}),r().createElement("div",{className:"import-step"},r().createElement("div",{className:"import-step-title"},c("Step 1: Download template",{ns:y})),r().createElement(d.Alert,{type:"info",style:{whiteSpace:"pre-line"},message:c("Download tips",{ns:y})}),r().createElement(d.Button,{className:"import-download-action",onClick:p},c("Download template",{ns:y}))),r().createElement("div",{className:"import-step"},r().createElement("div",{className:"import-step-title"},c("Step 2: Upload Excel",{ns:y})),r().createElement("div",{className:"import-upload-wrapper"},r().createElement("div",{className:"import-upload-dragger-shell"},r().createElement(d.Upload.Dragger,{action:"",maxCount:1,fileList:b,beforeUpload:function(){return!1},showUploadList:!1,onChange:function(e){var t=e.fileList.slice(-1);g(t),w(m(t))}},r().createElement("div",{className:"import-upload-placeholder"},c("Upload placeholder",{ns:y})))),b[0]&&r().createElement("div",{className:"import-upload-file"},r().createElement(R.PaperClipOutlined,{className:"import-upload-file-icon"}),r().createElement("span",{className:"import-upload-file-name",title:b[0].name},b[0].name),r().createElement(d.Button,{type:"text",size:"small",className:"import-upload-file-remove",icon:r().createElement(R.DeleteOutlined,null),onClick:function(){g([]),w("")}})),x&&r().createElement("div",{className:"import-upload-error"},x))),r().createElement("div",{className:"import-footer"},r().createElement(d.Button,{onClick:function(){return a.close()}},c("Cancel")),r().createElement(d.Button,{type:"primary",onClick:function(){return eg(function(){var r,i,c,p,d,f,y,v,h,x,S,O,I,j;return eA(this,function(A){switch(A.label){case 0:if(w(r=m(b)),r||!b.length)return[2];i=new FormData,c=b.map(function(e){return e.originFileObj}),i.append("file",c[0]),i.append("columns",JSON.stringify(s)),i.append("explain",u),p=e.model.getProps().importMode,t.status="importing",t.errorMessage="",A.label=1;case 1:return A.trys.push([1,6,,7]),h=(null==(d=o.getResourceName)?void 0:d.call(o))||l,x=null==(f=o.getSourceId)?void 0:f.call(o),O=(S=(null==(y=o.getDataSourceKey)?void 0:y.call(o))||n.collection.dataSourceKey)?{"X-Data-Source":S}:void 0,[4,e.api.resource(h,x,O).importXlsx({values:i,mode:p,timeout:6e5},{skipNotify:!0})];case 2:if(null==(I=A.sent().data)||null==(v=I.data)?void 0:v.taskId)return[3,4];return t.result=I,t.status="imported",[4,null==o||null==(j=o.refresh)?void 0:j.call(o)];case 3:return A.sent(),g([]),w(""),[3,5];case 4:a.close(),g([]),w(""),A.label=5;case 5:return[3,7];case 6:return t.errorMessage=eF(A.sent()),t.status="error",[3,7];case 7:return[2]}})})()},disabled:j},c("Start import",{ns:"".concat(y)}))))}),[4,e.viewer.open({type:"dialog",placement:"center",width:800,title:e.t("Import Data",{ns:"".concat(y)}),content:function(e){return r().createElement(f,{popover:e})}})];case 1:return v.sent(),[2]}})})()}}}}),eD.registerFlow({key:"importActionSetting",title:(0,ey.escapeT)("Import action settings",{ns:y}),steps:{importSetting:{title:(0,ey.escapeT)("Importable fields"),uiSchema:function(e){var t,n,r=(t=e.model.context.blockModel.collection.getFields(),n=e.t,s(t,function(e){var t;return n(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return e.targetCollection&&e.targetCollection.getFields()||[]}));return{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(y,'"}) }}'),"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:(0,Y.css)(eC())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":d.Cascader,required:!0,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1,options:r}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(y,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(y,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,Y.css)(ek())}}}}}},defaultParams:function(e){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){eh(e,t,n[t])})}return e}({},v(e.model.context.blockModel.collection.getFields()))},handler:function(e,t){var n=t.importColumns,r=t.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});e.model.setProps("importSettings",{importColumns:o,explain:r})}}}});var eN=new t.SchemaSettings({name:"actionSettings:import",items:[{name:"editButton",Component:t.ButtonEditor,useComponentProps:function(){return(0,t.useSchemaToolbar)().buttonEditorProps}},{name:"linkageRules",Component:t.SchemaSettingsLinkageRules,useComponentProps:function(){return eR({},(0,t.useSchemaToolbar)().linkageRulesProps)}},{name:"importableFields",type:"actionModal",useComponentProps:function(){var e,r,o,i,a=(0,O.useField)(),l=(0,O.useFieldSchema)(),c=(0,f.useTranslation)().t,u=(0,t.useDesignable)().dn,s=function(e){if(Array.isArray(e))return e}(e=(0,n.useState)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return e_(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return e_(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),p=s[0],m=s[1],d=C().importSettingsSchema;return(0,n.useEffect)(function(){m(d)},[a.address,null==l||null==(o=l["x-action-settings"])?void 0:o.importSettings]),{title:c("Importable fields"),schema:eR({},p),initialValues:eR({},null!=(r=null==l||null==(i=l["x-action-settings"])?void 0:i.importSettings)?r:{}),components:{ArrayItems:w.ArrayItems},onSubmit:function(e){var t,n=e.importColumns,r=e.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});l["x-action-settings"].importSettings={importColumns:o,explain:r},u.emit("patch",{schema:(eB(t={},"x-uid",l["x-uid"]),eB(t,"x-action-settings",l["x-action-settings"]),t)}),u.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps:function(){return{removeParentsIfNoChildren:!0,breakRemoveOn:function(e){return"Space"===e["x-component"]||e["x-component"].endsWith("ActionBar")},confirm:{title:(0,(0,f.useTranslation)().t)("Delete action")}}}}]});function eq(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function eU(e,t,n){return(eU=eH()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&ez(o,n.prototype),o}).apply(null,arguments)}function eL(e){return(eL=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ez(e,t){return(ez=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eX(e){var t="function"==typeof Map?new Map:void 0;return(eX=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return eU(e,arguments,eL(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),ez(n,e)})(e)}function eH(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eH=function(){return!!e})()}var e$=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=eL(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eH()?Reflect.construct(e,t||[],eL(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&ez(r,e),n=[{key:"load",value:function(){var e;return(e=function(){var e,n;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){return this.app.use(ep),e={title:"{{t('Import')}}",Component:"ImportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"importXlsx","x-acl-action-props":{skipScopeCheck:!0}},useVisible:function(){return(0,t.useActionAvailable)("importXlsx")}},null==(n=this.app.schemaInitializerManager.get("table:configureActions"))||n.add("enableActions.import",e),this.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.import",e),this.app.schemaSettingsManager.add(eN),this.app.flowEngine.registerModels({ImportActionModel:eD}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){eq(i,r,o,a,l,"next",e)}function l(e){eq(i,r,o,a,l,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,n),r}(eX(t.Plugin)),eV=e$}(),S}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@emotion/css"),require("react-dom"),require("@formily/antd-v5"),require("@formily/reactive"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/client-v2"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-import",["react-i18next","@emotion/css","react-dom","@formily/antd-v5","@formily/reactive","@formily/react","@ant-design/icons","@nocobase/flow-engine","@nocobase/client-v2","@formily/shared","react","antd","@nocobase/client","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-action-import"]=t(require("react-i18next"),require("@emotion/css"),require("react-dom"),require("@formily/antd-v5"),require("@formily/reactive"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/client-v2"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-action-import"]=t(e["react-i18next"],e["@emotion/css"],e["react-dom"],e["@formily/antd-v5"],e["@formily/reactive"],e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e["@nocobase/client-v2"],e["@formily/shared"],e.react,e.antd,e["@nocobase/client"],e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,n,r,o,i,a,l,c,u,s,p,m,f,d){return function(){var y={574:function(e,t,n){var r,o;void 0===(o="function"==typeof(r=function(){"use strict";function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){l(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function r(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function o(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n.g&&n.g.global===n.g?n.g:void 0,a=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(e,n,a){var l=i.URL||i.webkitURL,c=document.createElement("a");c.download=n=n||e.name||"download",c.rel="noopener","string"==typeof e?(c.href=e,c.origin===location.origin?o(c):r(c.href)?t(e,n,a):o(c,c.target="_blank")):(c.href=l.createObjectURL(e),setTimeout(function(){l.revokeObjectURL(c.href)},4e4),setTimeout(function(){o(c)},0))}:"msSaveOrOpenBlob"in navigator?function(e,n,i){if(n=n||e.name||"download","string"!=typeof e){var a;navigator.msSaveOrOpenBlob((void 0===(a=i)?a={autoBom:!1}:"object"!=typeof a&&(console.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e),n)}else if(r(e))t(e,n,i);else{var l=document.createElement("a");l.href=e,l.target="_blank",setTimeout(function(){o(l)})}}:function(e,n,r,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var l="application/octet-stream"===e.type,c=/constructor/i.test(i.HTMLElement)||i.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||l&&c||a)&&"u">typeof FileReader){var s=new FileReader;s.onloadend=function(){var e=s.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=e:location=e,o=null},s.readAsDataURL(e)}else{var p=i.URL||i.webkitURL,m=p.createObjectURL(e);o?o.location=m:location.href=m,o=null,setTimeout(function(){p.revokeObjectURL(m)},4e4)}});i.saveAs=l.saveAs=l,e.exports=l})?r.apply(t,[]):r)||(e.exports=o)},375:function(e){"use strict";e.exports=a},477:function(e){"use strict";e.exports=t},418:function(e){"use strict";e.exports=r},230:function(e){"use strict";e.exports=i},992:function(e){"use strict";e.exports=o},166:function(e){"use strict";e.exports=u},342:function(e){"use strict";e.exports=m},485:function(e){"use strict";e.exports=c},694:function(e){"use strict";e.exports=l},768:function(e){"use strict";e.exports=f},59:function(e){"use strict";e.exports=p},773:function(e){"use strict";e.exports=d},155:function(e){"use strict";e.exports=s},514:function(e){"use strict";e.exports=n},953:function(t){"use strict";t.exports=e}},v={};function b(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return y[e].call(n.exports,n,n.exports,b),n.exports}b.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return b.d(t,{a:t}),t},b.d=function(e,t){for(var n in t)b.o(t,n)&&!b.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},b.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),b.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},b.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},b.g.importScripts&&(g=b.g.location+"");var g,h=b.g.document;if(!g&&h&&(h.currentScript&&"SCRIPT"===h.currentScript.tagName.toUpperCase()&&(g=h.currentScript.src),!g)){var x=h.getElementsByTagName("script");if(x.length)for(var w=x.length-1;w>-1&&(!g||!/^http(s?):/.test(g));)g=x[w--].src}if(!g)throw Error("Automatic publicPath is not supported in this browser");b.p=g.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var S={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-action-import/dist/client/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",a=i.indexOf(o);e=a>=0?i.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-import/dist/client/"}b.p=e}(),!function(){"use strict";b.r(S),b.d(S,{useImportStartAction:function(){return Q},default:function(){return eV},ImportActionInitializer:function(){return x},ImportContextProvider:function(){return em},DownloadTips:function(){return h},ImportPluginProvider:function(){return ep},ImportDesigner:function(){return F},ImportWarning:function(){return g},ImportActionModel:function(){return eD},PluginActionImportClient:function(){return e$},buildImportFieldOptions:function(){return s},initImportSettings:function(){return v},useDownloadXlsxTemplateAction:function(){return J}});var e=b(166),t=b(342),n=b(155),r=b.n(n),o=["createdAt","createdBy","updatedAt","updatedBy"],i=["hasOne","belongsTo","hasMany","belongsToMany","belongsToArray"],a=function(e){return!!((null==e?void 0:e.target)&&i.includes(e.type||""))},l=function(e){return!(null==e?void 0:e.interface)||o.includes(e.interface)},c=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{name:e.name,title:t(e),schema:e.uiSchema,disabled:n}},u=function(e,t,n){var r,o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(l(e))return null;if(!a(e))return c(e,t);var s=(n(e)||[]).map(function(e){return l(e)?null:a(e)?i>=1?c(e,t,!0):u(e,t,n,i+1):u(e,t,n)}).filter(function(e){return!!e});return s.length?(r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},c(e,t)),o=o={children:s},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r):c(e,t,!0)},s=function(e,t,n){return(e||[]).map(function(e){return u(e,t,n,+!!a(e))}).filter(function(e){return!!e})},p=function(e){var n=(0,t.useCollectionManager_deprecated)().getCollectionFields,r=n(e),o=(0,t.useCompile)();return s(r,function(e){var t;return o(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return n(e.target)})},m=b(768),f=b(59),d=b(953),y="action-import",v=function(e){return{importColumns:null==e?void 0:e.filter(function(e){return!e.children&&!e.disabled}).map(function(e){return{dataIndex:[e.name]}}),explain:""}},g=function(){var e=(0,d.useTranslation)([y,"client"],{nsMode:"fallback"}).t;return r().createElement(f.Alert,{type:"warning",style:{marginBottom:"10px"},message:e("Import warnings",{limit:2e3})})},h=function(){var e=(0,d.useTranslation)([y,"client"],{nsMode:"fallback"}).t;return r().createElement(f.Alert,{type:"info",style:{marginBottom:"10px",whiteSpace:"pre-line"},message:e("Download tips")})},x=function(){var n=(0,t.useSchemaInitializerItem)(),o=(0,t.useSchemaInitializer)().insert,i=p((0,t.useCollection_deprecated)().name),a={type:"void",title:'{{ t("Import") }}',"x-component":"ImportAction","x-action":"importXlsx","x-settings":"actionSettings:import","x-toolbar":"ActionSchemaToolbar"};return r().createElement(t.SchemaInitializerItem,{title:n.title,onClick:function(){m.lodash.set(a,"x-action-settings.importSettings",v(i));var t,r=(0,e.merge)(a||{},n.schema||{});null==n||null==(t=n.schemaInitialize)||t.call(n,r),o(r)}})},w=b(418),O=b(230);function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function j(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function A(){var e=j(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return A=function(){return e},e}function E(){var e=j(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return E=function(){return e},e}var P=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],C=function(){var e=(0,d.useTranslation)(y).t,n=p((0,t.useCollection_deprecated)().name),r=(0,t.useCompile)();return{importSettingsSchema:{type:"void","x-component":"Grid",properties:{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(y,'"}) }}'),"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:(0,t.css)(A())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":t.Cascader,required:!0,"x-use-component-props":function(){return{options:r(n)}},"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(y,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(y,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,t.css)(E())}}}}}},beforeUploadHandler:function(){return!1},uploadValidator:function(t,n){if(t.length>1)return{type:"error",message:e("Only one file is allowed to be uploaded")};var r,o=null!=(r=t[0])?r:{};return P.includes(o.type)?"":{type:"error",message:e("Please upload the file of Excel")}},validateUpload:function(e,t,n){var r,o,i,a=(function(e){if(Array.isArray(e))return e}(n)||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),1!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(n)||function(e){if(e){if("string"==typeof e)return I(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return I(e,1)}}(n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];t.disabled=(null==a?void 0:a.length)===0,r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},t.componentProps),o=o={disabled:(null==a?void 0:a.length)===0||(null==(i=e.errors)?void 0:i.length)>0},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),t.componentProps=r}}};function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function T(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){T(e,t,n[t])})}return e}var F=function(){var e,o,i,a,l,c,u,s=(0,O.useField)(),p=(0,O.useFieldSchema)(),m=(0,d.useTranslation)().t,f=(0,t.useDesignable)().dn,y=function(e){if(Array.isArray(e))return e}(e=(0,n.useState)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return k(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return k(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),v=y[0],b=y[1],g=C().importSettingsSchema;return(0,n.useEffect)(function(){b(g)},[s.address,null==p||null==(i=p["x-action-settings"])?void 0:i.importSettings]),r().createElement(t.GeneralSchemaDesigner,{disableInitializer:!0},r().createElement(t.SchemaSettingsModalItem,{title:m("Edit button"),schema:{type:"object",title:m("Edit button"),properties:{title:{"x-decorator":"FormItem","x-component":"Input",title:m("Button title"),default:p.title,"x-component-props":{}},icon:{"x-decorator":"FormItem","x-component":"IconPicker",title:m("Button icon"),default:null==p||null==(a=p["x-component-props"])?void 0:a.icon,"x-component-props":{}},type:{"x-decorator":"FormItem","x-component":"Radio.Group",title:m("Button background color"),default:(null==p||null==(l=p["x-component-props"])?void 0:l.danger)?"danger":(null==p||null==(c=p["x-component-props"])?void 0:c.type)==="primary"?"primary":"default",enum:[{value:"default",label:'{{t("Default")}}'},{value:"primary",label:'{{t("Highlight")}}'},{value:"danger",label:'{{t("Danger red")}}'}]}}},onSubmit:function(e){var t,n=e.title,r=e.icon,o=e.type;p.title=n,s.title=n,s.componentProps.icon=r,s.componentProps.danger="danger"===o,s.componentProps.type=o,p["x-component-props"]=p["x-component-props"]||{},p["x-component-props"].icon=r,p["x-component-props"].danger="danger"===o,p["x-component-props"].type=o,f.emit("patch",{schema:(T(t={},"x-uid",p["x-uid"]),T(t,"title",n),T(t,"x-component-props",M({},p["x-component-props"])),t)}),f.refresh()}}),r().createElement(t.SchemaSettingsActionModalItem,{title:m("Importable fields"),schema:v,initialValues:M({},null!=(o=null==p||null==(u=p["x-action-settings"])?void 0:u.importSettings)?o:{}),components:{ArrayItems:w.ArrayItems},onSubmit:function(e){var t,n=e.importColumns,r=e.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title}});p["x-action-settings"].importSettings={importColumns:o,explain:r},f.emit("patch",{schema:(T(t={},"x-uid",p["x-uid"]),T(t,"x-action-settings",p["x-action-settings"]),t)}),f.refresh()}}),r().createElement(t.SchemaSettingsDivider,null),r().createElement(t.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:function(e){return"Space"===e["x-component"]||e["x-component"].endsWith("ActionBar")},confirm:{title:m("Delete action")}}))},D=b(514),_=(0,n.createContext)(null);_.displayName="ImportContext";var B=function(){return(0,n.useContext)(_)},R=b(375),N=b(574);function q(){var e,t,n=(e=["\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return q=function(){return n},n}var U=function(e){var n=(0,d.useTranslation)(y).t,o=B(),i=o.importModalVisible,a=o.importStatus,l=o.importResult,c=o.setImportModalVisible,u=null!=l?l:{},s=u.data,p=u.meta,m=function(){c(!1)};return r().createElement(f.Modal,{title:n("Import Data"),width:"50%",styles:{body:{height:"calc(80vh - 200px)"}},open:i,footer:null,closable:2===a,onCancel:m},r().createElement("div",{className:(0,t.css)(q())},1===a&&r().createElement(f.Spin,{indicator:r().createElement(R.LoadingOutlined,{style:{fontSize:24},spin:!0}),tip:n("Excel data importing")}),2===a&&r().createElement(f.Space,{direction:"vertical",align:"center"},r().createElement(R.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),r().createElement("p",null,function(e){if(!e)return null;var t=e.data,r=e.meta;if(r)return n("{{successCount}} records have been successfully imported",function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},null!=r?r:{}));var o=["".concat(n("Total records"),": ").concat(t.total||0),"".concat(n("Successfully imported"),": ").concat(t.success||0)];return t.skipped>0&&o.push("".concat(n("Skipped"),": ").concat(t.skipped)),t.updated>0&&o.push("".concat(n("Updated"),": ").concat(t.updated)),o.join(", ")}(l)),r().createElement(f.Space,null,(null==p?void 0:p.failureCount)>0&&r().createElement(f.Button,{onClick:function(){var e=new Blob([new Int8Array(null==s?void 0:s.data)],{type:"application/x-xls"});(0,N.saveAs)(e,"fail.xlsx")}},n("To download the failure data")),r().createElement(f.Button,{type:"primary",onClick:m},n("Done"))))))},L=b(773),z=b.n(L);function X(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function H(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){X(i,r,o,a,l,"next",e)}function l(e){X(i,r,o,a,l,"throw",e)}a(void 0)})}}function $(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var V=function(){for(var e=(0,t.useActionContext)().fieldSchema,n=(0,O.useFieldSchema)(),r=e||n;r&&"importXlsx"!==r["x-action"];)console.log("schema",r=r.parent);return{schema:r}},G=function(e){return e&&Array.isArray(e)?e:[]},W=function(e){if(!e)return"";if("string"==typeof e){var t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||e}if("string"==typeof e.message)return e.message;if(e.error)return W(e.error);var n=e.errors||e.messages;return Array.isArray(n)?n.map(W).filter(Boolean).join("\n"):""},K=function(e){var t;return W(null==e||null==(t=e.response)?void 0:t.data)||W(null==e?void 0:e.data)||(null==e?void 0:e.message)||"Import failed"},J=function(){var e=(0,t.useBlockRequestContext)().resource,n=(0,t.useCompile)(),r=(0,t.useCollectionManager_deprecated)(),o=r.getCollectionJoinField,i=r.getCollectionField,a=(0,t.useCollection_deprecated)(),l=a.name,c=a.title,u=V().schema;return{run:function(){return H(function(){var t,r,a,s,p,m,f;return $(this,function(d){switch(d.label){case 0:return s=(a=z().cloneDeep(null!=(t=null==u||null==(r=u["x-action-settings"])?void 0:r.importSettings)?t:{})).importColumns,p=a.explain,m=G(s).map(function(e){var t=i("".concat(l,".").concat(e.dataIndex[0]));if(t){if(e.defaultTitle=n(null==t||null==(r=t.uiSchema)?void 0:r.title)||t.name,e.dataIndex.length>1){var r,a,c=o("".concat(l,".").concat(e.dataIndex.join(".")));if(!c)return;e.defaultTitle=e.defaultTitle+"/"+n(null==c||null==(a=c.uiSchema)?void 0:a.title)||c.name}return"chinaRegion"===t.interface&&e.dataIndex.push("name"),e}}).filter(Boolean),[4,e.downloadXlsxTemplate({values:{title:n(c),explain:p,columns:n(m)}},{method:"post",responseType:"blob"})];case 1:return f=new Blob([d.sent().data],{type:"application/x-xls"}),(0,N.saveAs)(f,"".concat(n(c),".xlsx")),[2]}})})()}}},Q=function(){var e,r=(0,t.useBlockRequestContext)().service,o=(0,t.useCompile)(),i=(0,t.useCollectionManager_deprecated)(),a=i.getCollectionJoinField,l=i.getCollectionField,c=(0,t.useCollection_deprecated)().name,u=V().schema,s=(0,O.useForm)(),p=(0,t.useActionContext)(),m=p.setVisible,f=p.setErrorMessage,d=B(),y=d.setImportModalVisible,v=d.setImportStatus,b=d.setImportResult,g=s.values.upload,h=(0,t.useDataBlockResource)();return(0,n.useEffect)(function(){s.reset()},[s]),{run:function(){return H(function(){var e,t,n,i,p,d,g,x,w,S,O,I,j,A,E;return $(this,function(P){switch(P.label){case 0:d=(p=z().cloneDeep(null!=(e=null==u||null==(t=u["x-action-settings"])?void 0:t.importSettings)?e:{})).importColumns,g=p.explain,x=G(d).map(function(e){var t=l("".concat(c,".").concat(e.dataIndex[0]));if(t){if(e.defaultTitle=o(null==t||null==(n=t.uiSchema)?void 0:n.title)||t.name,e.dataIndex.length>1){var n,r,i=a("".concat(c,".").concat(e.dataIndex.join(".")));if(!i)return;e.defaultTitle=e.defaultTitle+"/"+o(null==i||null==(r=i.uiSchema)?void 0:r.title)||i.name}return"chinaRegion"===t.interface&&e.dataIndex.push("name"),e}}).filter(Boolean),w=new FormData,S=s.values.upload.map(function(e){return e.originFileObj}),w.append("file",S[0]),w.append("columns",JSON.stringify(x)),w.append("explain",g),O=(null==u||null==(n=u["x-action-settings"])?void 0:n.importMode)||"auto",I=(null==u||null==(i=u["x-action-settings"])?void 0:i.timeout)||6e5,null==f||f(""),m(!1),y(!0),v(1),P.label=1;case 1:return P.trys.push([1,6,,7]),[4,h.importXlsx({values:w,mode:O,timeout:I},{skipNotify:!0})];case 2:if(j=P.sent().data,null==f||f(""),s.reset(),j.data.taskId)return[3,4];return b(j),[4,null==r||null==(A=r.refresh)?void 0:A.call(r)];case 3:return P.sent(),v(2),[3,5];case 4:y(!1),m(!1),P.label=5;case 5:return[3,7];case 6:return E=P.sent(),null==f||f(K(E)),y(!1),m(!0),[3,7];case 7:return[2]}})})()},disabled:(null==g?void 0:g.length)===0||(null==(e=s.errors)?void 0:e.length)>0}},Y=b(477);function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ee(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Z(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function et(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function en(){var e=et(["\n max-height: min(42vh, 420px);\n overflow: auto;\n white-space: pre-wrap;\n word-break: break-word;\n line-height: 1.6;\n padding-right: 8px;\n "]);return en=function(){return e},e}function er(){var e=et(["\n margin-bottom: 16px;\n "]);return er=function(){return e},e}function eo(){var e=et(["\n .ant-formily-item-label {\n height: var(--controlHeightLG);\n }\n "]);return eo=function(){return e},e}function ei(){var e=et(["\n margin-top: 5px;\n "]);return ei=function(){return e},e}var ea=function(e){var t=e.errorMessage,n=(0,d.useTranslation)(y).t;return t?r().createElement(f.Alert,{type:"error",showIcon:!0,message:n("Import failed"),description:r().createElement("div",{className:(0,Y.css)(en())},t),className:(0,Y.css)(er())}):null},el={type:"void",name:"import-modal",title:'{{ t("Import Data", {ns: "'.concat(y,'" }) }}'),"x-component":"Action.Modal","x-decorator":"Form","x-component-props":{width:"100%",style:{maxWidth:"750px"},className:(0,Y.css)(eo())},properties:{formLayout:{type:"void","x-component":"FormLayout",properties:{importError:{type:"void","x-component":"ImportErrorAlert","x-visible":"{{ !!importErrorMessage }}","x-component-props":{errorMessage:"{{ importErrorMessage }}"}},warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:'{{ t("Step 1: Download template", {ns: "'.concat(y,'" }) }}'),"x-component":"FormItem","x-acl-ignore":!0,properties:{tip:{type:"void","x-component":"DownloadTips"},downloadAction:{type:"void",title:'{{ t("Download template", {ns: "'.concat(y,'" }) }}'),"x-component":"Action","x-component-props":{className:(0,Y.css)(ei()),useAction:"{{ useDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:'{{ t("Step 2: Upload Excel", {ns: "'.concat(y,'" }) }}'),"x-decorator":"FormItem","x-acl-ignore":!0,"x-component":"Upload.Dragger","x-validator":"{{ uploadValidator }}","x-component-props":{action:"",height:"150px",tipContent:'{{ t("Upload placeholder", {ns: "'.concat(y,'" }) }}'),beforeUpload:"{{ beforeUploadHandler }}"}}}},footer:{"x-component":"Action.Modal.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{cancel:{type:"void",title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},startImport:{type:"void",title:'{{ t("Start import", {ns: "'.concat(y,'" }) }}'),"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useImportStartAction }}"},"x-reactions":{dependencies:["upload"],fulfill:{run:"validateUpload($form, $self, $deps)"}}}}}}}}},ec=function(e){var o,i,a=ee((0,n.useState)(!1),2),l=a[0],c=a[1],u=ee((0,n.useState)(""),2),s=u[0],p=u[1],m=(0,t.useCompile)(),f=(0,O.useFieldSchema)();return r().createElement(t.ActionContextProvider,{value:{visible:l,setVisible:c,fieldSchema:f,errorMessage:s,setErrorMessage:p}},r().createElement(t.Action,(o=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({icon:e.icon||"uploadoutlined",title:m((null==f?void 0:f.title)||"t('Import')")},e),i=i={onClick:function(){p(""),c(!0)}},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))}),o)),r().createElement(t.SchemaComponent,{schema:el,components:{ImportErrorAlert:ea},scope:{importErrorMessage:s}}))};function eu(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function es(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return eu(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eu(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var ep=function(e){var n=C(),o=n.uploadValidator,i=n.beforeUploadHandler,a=n.validateUpload;return r().createElement(t.SchemaComponentOptions,{components:{ImportActionInitializer:x,ImportDesigner:F,ImportWarning:g,DownloadTips:h,ImportAction:ec},scope:{uploadValidator:o,validateUpload:a,beforeUploadHandler:i,useDownloadXlsxTemplateAction:J,useImportStartAction:Q}},r().createElement(em,null,e.children))},em=function(e){var t=es((0,n.useState)(!1),2),o=t[0],i=t[1],a=es((0,n.useState)(1),2),l=a[0],c=a[1],u=es((0,n.useState)(null),2),s=u[0],p=u[1];return r().createElement(_.Provider,{value:{importModalVisible:o,setImportModalVisible:i,importStatus:l,setImportStatus:c,importResult:s,setImportResult:p}},(0,D.createPortal)(r().createElement(U,null),document.body),e.children)},ef=b(992),ed=b(485),ey=b(694);function ev(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eb(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function eg(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){eb(i,r,o,a,l,"next",e)}function l(e){eb(i,r,o,a,l,"throw",e)}a(void 0)})}}function eh(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ex(e){return(ex=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ew(e,t){return(ew=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eS(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||eI(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eO(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function eI(e,t){if(e){if("string"==typeof e)return ev(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ev(e,t)}}function ej(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ej=function(){return!!e})()}function eA(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function eE(){var e=eO(["\n max-height: min(42vh, 420px);\n overflow: auto;\n white-space: pre-wrap;\n word-break: break-word;\n line-height: 1.6;\n padding-right: 8px;\n "]);return eE=function(){return e},e}function eP(){var e=eO(["\n .import-warning {\n margin-bottom: ","px;\n }\n\n .import-step {\n margin-bottom: ","px;\n }\n\n .import-step-title {\n margin-bottom: ","px;\n color: ",";\n line-height: ",";\n }\n\n .import-download-action {\n margin-top: ","px;\n }\n\n .import-upload-wrapper {\n margin-bottom: ","px;\n }\n\n .import-upload-dragger-shell {\n height: 150px;\n border: 1px dashed ",";\n border-radius: ","px;\n background: ",";\n transition: border-color 0.2s;\n }\n\n .import-upload-dragger-shell:hover {\n border-color: ",";\n }\n\n .import-upload-dragger-shell .ant-upload-wrapper,\n .import-upload-dragger-shell .ant-upload,\n .import-upload-dragger-shell .ant-upload-drag {\n width: 100%;\n height: 100%;\n border: 0;\n background: transparent;\n }\n\n .import-upload-dragger-shell .ant-upload-drag-container {\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .import-upload-dragger-shell .ant-upload-list {\n display: none;\n }\n\n .import-upload-file {\n display: flex;\n align-items: center;\n column-gap: ","px;\n min-height: ","px;\n margin-top: ","px;\n padding: 0 ","px;\n border-radius: ","px;\n color: ",";\n line-height: ",";\n transition: background-color 0.2s;\n }\n\n .import-upload-file:hover {\n background: ",";\n }\n\n .import-upload-file-icon {\n color: ",";\n font-size: ","px;\n }\n\n .import-upload-file-name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .import-upload-file-remove {\n color: ",";\n }\n\n .import-upload-file-remove:hover {\n color: ",";\n background: transparent;\n }\n\n .import-upload-placeholder {\n padding: 0 ","px;\n color: ",";\n line-height: ",";\n text-align: center;\n }\n\n .import-upload-error {\n margin-top: ","px;\n margin-bottom: ","px;\n color: ",";\n line-height: ",";\n word-break: break-word;\n }\n\n .import-footer {\n display: flex;\n justify-content: flex-end;\n gap: ","px;\n margin-top: ","px;\n }\n "]);return eP=function(){return e},e}function eC(){var e=eO(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return eC=function(){return e},e}function ek(){var e=eO(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return ek=function(){return e},e}var eT=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],eM=function(e){if(!e)return"";if("string"==typeof e){var t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||e}if("string"==typeof e.message)return e.message;if(e.error)return eM(e.error);var n=e.errors||e.messages;return Array.isArray(n)?n.map(eM).filter(Boolean).join("\n"):""},eF=function(e){var t;return eM(null==e||null==(t=e.response)?void 0:t.data)||eM(null==e?void 0:e.data)||(null==e?void 0:e.message)||"Import failed"},eD=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=ex(t),eh(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,ej()?Reflect.construct(t,r||[],ex(this).constructor):t.apply(this,r)),"defaultProps",{title:(0,ey.escapeT)("Import"),type:"default",icon:"uploadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&ew(n,e),t=[{key:"getAclActionName",value:function(){return"importXlsx"}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(ed.ActionModel);function e_(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eB(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eR(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){eB(e,t,n[t])})}return e}eh(eD,"scene",ed.ActionSceneEnum.collection),eD.define({label:(0,ey.escapeT)("Import")}),eD.registerFlow({key:"importSettings",title:(0,ey.escapeT)("Import settings"),on:"click",steps:{import:{handler:function(e){return eg(function(){var t,n,o,i,a,l,c,u,s,p,m,d;return eA(this,function(v){switch(v.label){case 0:var b;return t=(0,ef.observable)({status:"",result:null,errorMessage:""}),o=(n=e.model.context.blockModel).resource,a=(i=n.collection).title,l=i.name,u=(c=e.model.getProps().importSettings).explain,s=(!(b=c.importColumns)||!Array.isArray(b)?[]:b).map(function(t){var r=e.model.context.dataSourceManager.getCollectionField("".concat(n.collection.dataSourceKey,".").concat(l,".").concat(t.dataIndex[0]));if(r){if(t.defaultTitle=e.t(null==r||null==(o=r.uiSchema)?void 0:o.title)||r.name,t.dataIndex.length>1){var o,i,a=e.model.context.dataSourceManager.getCollectionField("".concat(e.model.context.collection.dataSourceKey,".").concat(l,".").concat(t.dataIndex.join(".")));if(!a)return;t.defaultTitle=t.defaultTitle+"/"+e.t(null==a||null==(i=a.uiSchema)?void 0:i.title)||a.name}return t}}).filter(Boolean),p=function(){return eg(function(){var t;return eA(this,function(n){switch(n.label){case 0:return[4,o.runAction("downloadXlsxTemplate",{data:{title:e.t(a),explain:u,columns:function(e){if(Array.isArray(e))return ev(e)}(s)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(s)||eI(s)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},responseType:"blob",method:"post"})];case 1:return t=new Blob([n.sent()],{type:"application/x-xls"}),(0,N.saveAs)(t,"".concat(e.t(a),".xlsx")),[2]}})})()},m=function(t){if(0===t.length)return"";if(t.length>1)return e.t("Only one file is allowed to be uploaded",{ns:y});var n,r,o=null!=(n=t[0])?n:{},i=o.type||(null==(r=o.originFileObj)?void 0:r.type);return eT.includes(i)?"":e.t("Please upload the file of Excel",{ns:y})},d=(0,ey.observer)(function(i){var a=i.popover,c=e.t,d=f.theme.useToken().token,v=eS(r().useState([]),2),b=v[0],g=v[1],h=eS(r().useState(""),2),x=h[0],w=h[1],S=function(){a.close(),t.status="",t.result=null,t.errorMessage="",g([]),w("")};if("importing"===t.status)return r().createElement("div",{style:{display:"flex",justifyContent:"center",padding:40}},r().createElement(f.Spin,{tip:c("Excel data importing"),indicator:r().createElement(R.LoadingOutlined,{spin:!0,style:{fontSize:24}})}));if("imported"===t.status){var O,I=null==(O=t.result)?void 0:O.meta;return r().createElement(f.Space,{direction:"vertical",align:"center",style:{width:"100%",padding:24}},r().createElement(R.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),r().createElement("p",null,function(e){if(!e)return null;var t=((null==e?void 0:e.data)||e).successCount;if(t)return c("{{successCount}} records have been successfully imported",{successCount:t,ns:y})}(t.result)),r().createElement(f.Space,null,(null==I?void 0:I.failureCount)>0&&r().createElement(f.Button,{onClick:function(){var e,n,r=new Blob([new Int8Array(null==(n=t.result)||null==(e=n.data)?void 0:e.data)],{type:"application/x-xls"});(0,N.saveAs)(r,"fail.xlsx")}},c("To download the failure data")),r().createElement(f.Button,{type:"primary",onClick:S},c("Done"))))}if("error"===t.status)return r().createElement(f.Space,{direction:"vertical",style:{width:"100%"},size:d.marginLG},r().createElement(f.Alert,{type:"error",showIcon:!0,message:c("Import failed",{ns:y}),description:r().createElement("div",{className:(0,Y.css)(eE())},t.errorMessage)}),r().createElement(f.Space,{style:{width:"100%",justifyContent:"flex-end"}},r().createElement(f.Button,{onClick:S},c("Close")),r().createElement(f.Button,{type:"primary",onClick:function(){t.status="",t.errorMessage=""}},c("Back"))));var j=!b.length||!!x;return r().createElement("div",{className:(0,Y.css)(eP(),d.marginLG,d.marginLG,d.marginXS,d.colorText,d.lineHeight,d.marginXS,x?d.marginMD:0,d.colorBorder,d.borderRadius,d.colorBgContainer,d.colorPrimary,d.marginXXS,d.controlHeight,d.marginSM,d.paddingXXS,d.borderRadiusSM,d.colorText,d.lineHeight,d.colorFillAlter,d.colorTextSecondary,d.fontSizeLG,d.colorTextTertiary,d.colorText,d.padding,d.colorTextDescription,d.lineHeight,b.length?d.marginXXS:d.marginSM,d.marginMD,d.colorError,d.lineHeight,d.marginXS,d.marginLG)},r().createElement(f.Alert,{className:"import-warning",type:"warning",message:c("Import warnings",{ns:y,limit:2e3})}),r().createElement("div",{className:"import-step"},r().createElement("div",{className:"import-step-title"},c("Step 1: Download template",{ns:y})),r().createElement(f.Alert,{type:"info",style:{whiteSpace:"pre-line"},message:c("Download tips",{ns:y})}),r().createElement(f.Button,{className:"import-download-action",onClick:p},c("Download template",{ns:y}))),r().createElement("div",{className:"import-step"},r().createElement("div",{className:"import-step-title"},c("Step 2: Upload Excel",{ns:y})),r().createElement("div",{className:"import-upload-wrapper"},r().createElement("div",{className:"import-upload-dragger-shell"},r().createElement(f.Upload.Dragger,{action:"",maxCount:1,fileList:b,beforeUpload:function(){return!1},showUploadList:!1,onChange:function(e){var t=e.fileList.slice(-1);g(t),w(m(t))}},r().createElement("div",{className:"import-upload-placeholder"},c("Upload placeholder",{ns:y})))),b[0]&&r().createElement("div",{className:"import-upload-file"},r().createElement(R.PaperClipOutlined,{className:"import-upload-file-icon"}),r().createElement("span",{className:"import-upload-file-name",title:b[0].name},b[0].name),r().createElement(f.Button,{type:"text",size:"small",className:"import-upload-file-remove",icon:r().createElement(R.DeleteOutlined,null),onClick:function(){g([]),w("")}})),x&&r().createElement("div",{className:"import-upload-error"},x))),r().createElement("div",{className:"import-footer"},r().createElement(f.Button,{onClick:function(){return a.close()}},c("Cancel")),r().createElement(f.Button,{type:"primary",onClick:function(){return eg(function(){var r,i,c,p,f,d,y,v,h,x,S,O,I,j;return eA(this,function(A){switch(A.label){case 0:if(w(r=m(b)),r||!b.length)return[2];i=new FormData,c=b.map(function(e){return e.originFileObj}),i.append("file",c[0]),i.append("columns",JSON.stringify(s)),i.append("explain",u),p=e.model.getProps().importMode,t.status="importing",t.errorMessage="",A.label=1;case 1:return A.trys.push([1,6,,7]),h=(null==(f=o.getResourceName)?void 0:f.call(o))||l,x=null==(d=o.getSourceId)?void 0:d.call(o),O=(S=(null==(y=o.getDataSourceKey)?void 0:y.call(o))||n.collection.dataSourceKey)?{"X-Data-Source":S}:void 0,[4,e.api.resource(h,x,O).importXlsx({values:i,mode:p,timeout:6e5},{skipNotify:!0})];case 2:if(null==(I=A.sent().data)||null==(v=I.data)?void 0:v.taskId)return[3,4];return t.result=I,t.status="imported",[4,null==o||null==(j=o.refresh)?void 0:j.call(o)];case 3:return A.sent(),g([]),w(""),[3,5];case 4:a.close(),g([]),w(""),A.label=5;case 5:return[3,7];case 6:return t.errorMessage=eF(A.sent()),t.status="error",[3,7];case 7:return[2]}})})()},disabled:j},c("Start import",{ns:"".concat(y)}))))}),[4,e.viewer.open({type:"dialog",placement:"center",width:800,title:e.t("Import Data",{ns:"".concat(y)}),content:function(e){return r().createElement(d,{popover:e})}})];case 1:return v.sent(),[2]}})})()}}}}),eD.registerFlow({key:"importActionSetting",title:(0,ey.escapeT)("Import action settings",{ns:y}),steps:{importSetting:{title:(0,ey.escapeT)("Importable fields"),uiSchema:function(e){var t,n,r=(t=e.model.context.blockModel.collection.getFields(),n=e.t,s(t,function(e){var t;return n(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return e.targetCollection&&e.targetCollection.getFields()||[]}));return{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(y,'"}) }}'),"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:(0,Y.css)(eC())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":f.Cascader,required:!0,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1,options:r}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(y,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(y,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,Y.css)(ek())}}}}}},defaultParams:function(e){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){eh(e,t,n[t])})}return e}({},v(e.model.context.blockModel.collection.getFields()))},handler:function(e,t){var n=t.importColumns,r=t.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});e.model.setProps("importSettings",{importColumns:o,explain:r})}}}});var eN=new t.SchemaSettings({name:"actionSettings:import",items:[{name:"editButton",Component:t.ButtonEditor,useComponentProps:function(){return(0,t.useSchemaToolbar)().buttonEditorProps}},{name:"linkageRules",Component:t.SchemaSettingsLinkageRules,useComponentProps:function(){return eR({},(0,t.useSchemaToolbar)().linkageRulesProps)}},{name:"importableFields",type:"actionModal",useComponentProps:function(){var e,r,o,i,a=(0,O.useField)(),l=(0,O.useFieldSchema)(),c=(0,d.useTranslation)().t,u=(0,t.useDesignable)().dn,s=function(e){if(Array.isArray(e))return e}(e=(0,n.useState)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return e_(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return e_(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),p=s[0],m=s[1],f=C().importSettingsSchema;return(0,n.useEffect)(function(){m(f)},[a.address,null==l||null==(o=l["x-action-settings"])?void 0:o.importSettings]),{title:c("Importable fields"),schema:eR({},p),initialValues:eR({},null!=(r=null==l||null==(i=l["x-action-settings"])?void 0:i.importSettings)?r:{}),components:{ArrayItems:w.ArrayItems},onSubmit:function(e){var t,n=e.importColumns,r=e.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});l["x-action-settings"].importSettings={importColumns:o,explain:r},u.emit("patch",{schema:(eB(t={},"x-uid",l["x-uid"]),eB(t,"x-action-settings",l["x-action-settings"]),t)}),u.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps:function(){return{removeParentsIfNoChildren:!0,breakRemoveOn:function(e){return"Space"===e["x-component"]||e["x-component"].endsWith("ActionBar")},confirm:{title:(0,(0,d.useTranslation)().t)("Delete action")}}}}]});function eq(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function eU(e,t,n){return(eU=eH()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&ez(o,n.prototype),o}).apply(null,arguments)}function eL(e){return(eL=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ez(e,t){return(ez=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eX(e){var t="function"==typeof Map?new Map:void 0;return(eX=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return eU(e,arguments,eL(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),ez(n,e)})(e)}function eH(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eH=function(){return!!e})()}var e$=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=eL(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eH()?Reflect.construct(e,t||[],eL(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&ez(r,e),n=[{key:"load",value:function(){var e;return(e=function(){var e,n;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){return this.app.use(ep),e={title:"{{t('Import')}}",Component:"ImportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"importXlsx","x-acl-action-props":{skipScopeCheck:!0}},useVisible:function(){return(0,t.useActionAvailable)("importXlsx")}},null==(n=this.app.schemaInitializerManager.get("table:configureActions"))||n.add("enableActions.import",e),this.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.import",e),this.app.schemaSettingsManager.add(eN),this.app.flowEngine.registerModels({ImportActionModel:eD}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){eq(i,r,o,a,l,"next",e)}function l(e){eq(i,r,o,a,l,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,n),r}(eX(t.Plugin)),eV=e$}(),S}()});
@@ -6,4 +6,4 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- export declare const useFields: (collectionName: string) => any;
9
+ export declare const useFields: (collectionName: string) => import("../client-v2/buildImportFieldOptions").ImportFieldOption[];
@@ -6,4 +6,25 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- export declare const buildImportFieldOptions: (fields: any, getTitle: any, getTargetFields: any) => any;
9
+ export type ImportFieldOptionSource = {
10
+ name?: string;
11
+ type?: string;
12
+ target?: string;
13
+ interface?: string;
14
+ uiSchema?: {
15
+ title?: unknown;
16
+ [key: string]: unknown;
17
+ };
18
+ targetCollection?: {
19
+ getFields: () => ImportFieldOptionSource[];
20
+ };
21
+ [key: string]: unknown;
22
+ };
23
+ export type ImportFieldOption = {
24
+ name?: string;
25
+ title: unknown;
26
+ schema: unknown;
27
+ disabled?: boolean;
28
+ children?: ImportFieldOption[];
29
+ };
30
+ export declare const buildImportFieldOptions: <T extends ImportFieldOptionSource>(fields: T[], getTitle: (field: T) => unknown, getTargetFields: (field: T) => ImportFieldOptionSource[] | null | undefined) => ImportFieldOption[];
@@ -6,4 +6,4 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- export declare const getOptionFields: (fields: any, t: any) => any;
9
+ export declare const getOptionFields: (fields: any, t: any) => import("./buildImportFieldOptions").ImportFieldOption[];
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/reactive"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-import/client-v2",["react-i18next","@emotion/css","@nocobase/client-v2","@formily/reactive","react","antd","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-action-import/client-v2"]=t(require("react-i18next"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/reactive"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["@nocobase/plugin-action-import/client-v2"]=t(e["react-i18next"],e["@emotion/css"],e["@nocobase/client-v2"],e["@formily/reactive"],e.react,e.antd,e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o,i,a,l){return function(){var c={574:function(e,t,n){var r,o;void 0===(o="function"==typeof(r=function(){"use strict";function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){l(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function r(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function o(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n.g&&n.g.global===n.g?n.g:void 0,a=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(e,n,a){var l=i.URL||i.webkitURL,c=document.createElement("a");c.download=n=n||e.name||"download",c.rel="noopener","string"==typeof e?(c.href=e,c.origin===location.origin?o(c):r(c.href)?t(e,n,a):o(c,c.target="_blank")):(c.href=l.createObjectURL(e),setTimeout(function(){l.revokeObjectURL(c.href)},4e4),setTimeout(function(){o(c)},0))}:"msSaveOrOpenBlob"in navigator?function(e,n,i){if(n=n||e.name||"download","string"!=typeof e){var a;navigator.msSaveOrOpenBlob((void 0===(a=i)?a={autoBom:!1}:"object"!=typeof a&&(console.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e),n)}else if(r(e))t(e,n,i);else{var l=document.createElement("a");l.href=e,l.target="_blank",setTimeout(function(){o(l)})}}:function(e,n,r,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var l="application/octet-stream"===e.type,c=/constructor/i.test(i.HTMLElement)||i.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||l&&c||a)&&"u">typeof FileReader){var s=new FileReader;s.onloadend=function(){var e=s.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=e:location=e,o=null},s.readAsDataURL(e)}else{var p=i.URL||i.webkitURL,f=p.createObjectURL(e);o?o.location=f:location.href=f,o=null,setTimeout(function(){p.revokeObjectURL(f)},4e4)}});i.saveAs=l.saveAs=l,e.exports=l})?r.apply(t,[]):r)||(e.exports=o)},375:function(e){"use strict";e.exports=a},477:function(e){"use strict";e.exports=t},992:function(e){"use strict";e.exports=r},485:function(e){"use strict";e.exports=n},694:function(e){"use strict";e.exports=l},59:function(e){"use strict";e.exports=i},155:function(e){"use strict";e.exports=o},953:function(t){"use strict";t.exports=e}},u={};function s(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return c[e].call(n.exports,n,n.exports,s),n.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(p=s.g.location+"");var p,f=s.g.document;if(!p&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(p=f.currentScript.src),!p)){var d=f.getElementsByTagName("script");if(d.length)for(var m=d.length-1;m>-1&&(!p||!/^http(s?):/.test(p));)p=d[m--].src}if(!p)throw Error("Automatic publicPath is not supported in this browser");s.p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var g={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-action-import/dist/client-v2/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",a=i.indexOf(o);e=a>=0?i.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-import/dist/client-v2/"}s.p=e}(),!function(){"use strict";s.r(g),s.d(g,{PluginActionImportClient:function(){return $},default:function(){return z},buildImportFieldOptions:function(){return b},ImportActionModel:function(){return R}});var e=s(485),t=s(375),n=s(477),r=s(992),o=s(694),i=s(59),a=s(574),l=s(155),c=s.n(l);s(953);var u="action-import",p=["createdAt","createdBy","updatedAt","updatedBy"],f=["hasOne","belongsTo","hasMany","belongsToMany","belongsToArray"],d=function(e){return(null==e?void 0:e.target)&&f.includes(e.type)},m=function(e){return!(null==e?void 0:e.interface)||p.includes(e.interface)},y=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{name:e.name,title:t(e),schema:null==e?void 0:e.uiSchema,disabled:n}},v=function(e,t,n){var r,o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(m(e))return null;if(!d(e))return y(e,t);var a=(n(e)||[]).map(function(e){return m(e)?null:d(e)?i>=1?y(e,t,!0):v(e,t,n,i+1):v(e,t,n)}).filter(Boolean);return a.length?(r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},y(e,t)),o=o={children:a},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r):y(e,t,!0)},b=function(e,t,n){return(e||[]).map(function(e){return v(e,t,n,+!!d(e))}).filter(Boolean)};function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function w(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function x(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){w(i,r,o,a,l,"next",e)}function l(e){w(i,r,o,a,l,"throw",e)}a(void 0)})}}function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function E(e,t){return(E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function j(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||A(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function A(e,t){if(e){if("string"==typeof e)return h(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return h(e,t)}}function I(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(I=function(){return!!e})()}function T(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function P(){var e=k(["\n max-height: min(42vh, 420px);\n overflow: auto;\n white-space: pre-wrap;\n word-break: break-word;\n line-height: 1.6;\n padding-right: 8px;\n "]);return P=function(){return e},e}function _(){var e=k(["\n .import-warning {\n margin-bottom: ","px;\n }\n\n .import-step {\n margin-bottom: ","px;\n }\n\n .import-step-title {\n margin-bottom: ","px;\n color: ",";\n line-height: ",";\n }\n\n .import-download-action {\n margin-top: ","px;\n }\n\n .import-upload-wrapper {\n margin-bottom: ","px;\n }\n\n .import-upload-dragger-shell {\n height: 150px;\n border: 1px dashed ",";\n border-radius: ","px;\n background: ",";\n transition: border-color 0.2s;\n }\n\n .import-upload-dragger-shell:hover {\n border-color: ",";\n }\n\n .import-upload-dragger-shell .ant-upload-wrapper,\n .import-upload-dragger-shell .ant-upload,\n .import-upload-dragger-shell .ant-upload-drag {\n width: 100%;\n height: 100%;\n border: 0;\n background: transparent;\n }\n\n .import-upload-dragger-shell .ant-upload-drag-container {\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .import-upload-dragger-shell .ant-upload-list {\n display: none;\n }\n\n .import-upload-file {\n display: flex;\n align-items: center;\n column-gap: ","px;\n min-height: ","px;\n margin-top: ","px;\n padding: 0 ","px;\n border-radius: ","px;\n color: ",";\n line-height: ",";\n transition: background-color 0.2s;\n }\n\n .import-upload-file:hover {\n background: ",";\n }\n\n .import-upload-file-icon {\n color: ",";\n font-size: ","px;\n }\n\n .import-upload-file-name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .import-upload-file-remove {\n color: ",";\n }\n\n .import-upload-file-remove:hover {\n color: ",";\n background: transparent;\n }\n\n .import-upload-placeholder {\n padding: 0 ","px;\n color: ",";\n line-height: ",";\n text-align: center;\n }\n\n .import-upload-error {\n margin-top: ","px;\n margin-bottom: ","px;\n color: ",";\n line-height: ",";\n word-break: break-word;\n }\n\n .import-footer {\n display: flex;\n justify-content: flex-end;\n gap: ","px;\n margin-top: ","px;\n }\n "]);return _=function(){return e},e}function C(){var e=k(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return C=function(){return e},e}function M(){var e=k(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return M=function(){return e},e}var B=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],F=function(e){if(!e)return"";if("string"==typeof e){var t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||e}if("string"==typeof e.message)return e.message;if(e.error)return F(e.error);var n=e.errors||e.messages;return Array.isArray(n)?n.map(F).filter(Boolean).join("\n"):""},N=function(e){var t;return F(null==e||null==(t=e.response)?void 0:t.data)||F(null==e?void 0:e.data)||(null==e?void 0:e.message)||"Import failed"},R=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=O(t),S(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,I()?Reflect.construct(t,r||[],O(this).constructor):t.apply(this,r)),"defaultProps",{title:(0,o.escapeT)("Import"),type:"default",icon:"uploadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&E(n,e),t=[{key:"getAclActionName",value:function(){return"importXlsx"}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(e.ActionModel);function L(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function D(e,t,n){return(D=H()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&U(o,n.prototype),o}).apply(null,arguments)}S(R,"scene",e.ActionSceneEnum.collection),R.define({label:(0,o.escapeT)("Import")}),R.registerFlow({key:"importSettings",title:(0,o.escapeT)("Import settings"),on:"click",steps:{import:{handler:function(e){return x(function(){var l,s,p,f,d,m,g,y,v,b,w,S;return T(this,function(O){switch(O.label){case 0:var E;return l=(0,r.observable)({status:"",result:null,errorMessage:""}),p=(s=e.model.context.blockModel).resource,d=(f=s.collection).title,m=f.name,y=(g=e.model.getProps().importSettings).explain,v=(!(E=g.importColumns)||!Array.isArray(E)?[]:E).map(function(t){var n=e.model.context.dataSourceManager.getCollectionField("".concat(s.collection.dataSourceKey,".").concat(m,".").concat(t.dataIndex[0]));if(n){if(t.defaultTitle=e.t(null==n||null==(r=n.uiSchema)?void 0:r.title)||n.name,t.dataIndex.length>1){var r,o,i=e.model.context.dataSourceManager.getCollectionField("".concat(e.model.context.collection.dataSourceKey,".").concat(m,".").concat(t.dataIndex.join(".")));if(!i)return;t.defaultTitle=t.defaultTitle+"/"+e.t(null==i||null==(o=i.uiSchema)?void 0:o.title)||i.name}return t}}).filter(Boolean),b=function(){return x(function(){var t;return T(this,function(n){switch(n.label){case 0:return[4,p.runAction("downloadXlsxTemplate",{data:{title:e.t(d),explain:y,columns:function(e){if(Array.isArray(e))return h(e)}(v)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(v)||A(v)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},responseType:"blob",method:"post"})];case 1:return t=new Blob([n.sent()],{type:"application/x-xls"}),(0,a.saveAs)(t,"".concat(e.t(d),".xlsx")),[2]}})})()},w=function(t){if(0===t.length)return"";if(t.length>1)return e.t("Only one file is allowed to be uploaded",{ns:u});var n,r,o=null!=(n=t[0])?n:{},i=o.type||(null==(r=o.originFileObj)?void 0:r.type);return B.includes(i)?"":e.t("Please upload the file of Excel",{ns:u})},S=(0,o.observer)(function(r){var o=r.popover,f=e.t,d=i.theme.useToken().token,g=j(c().useState([]),2),h=g[0],S=g[1],O=j(c().useState(""),2),E=O[0],k=O[1],A=function(){o.close(),l.status="",l.result=null,l.errorMessage="",S([]),k("")};if("importing"===l.status)return c().createElement("div",{style:{display:"flex",justifyContent:"center",padding:40}},c().createElement(i.Spin,{tip:f("Excel data importing"),indicator:c().createElement(t.LoadingOutlined,{spin:!0,style:{fontSize:24}})}));if("imported"===l.status){var I,C=null==(I=l.result)?void 0:I.meta;return c().createElement(i.Space,{direction:"vertical",align:"center",style:{width:"100%",padding:24}},c().createElement(t.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),c().createElement("p",null,function(e){if(!e)return null;var t=((null==e?void 0:e.data)||e).successCount;if(t)return f("{{successCount}} records have been successfully imported",{successCount:t,ns:u})}(l.result)),c().createElement(i.Space,null,(null==C?void 0:C.failureCount)>0&&c().createElement(i.Button,{onClick:function(){var e,t,n=new Blob([new Int8Array(null==(t=l.result)||null==(e=t.data)?void 0:e.data)],{type:"application/x-xls"});(0,a.saveAs)(n,"fail.xlsx")}},f("To download the failure data")),c().createElement(i.Button,{type:"primary",onClick:A},f("Done"))))}if("error"===l.status)return c().createElement(i.Space,{direction:"vertical",style:{width:"100%"},size:d.marginLG},c().createElement(i.Alert,{type:"error",showIcon:!0,message:f("Import failed",{ns:u}),description:c().createElement("div",{className:(0,n.css)(P())},l.errorMessage)}),c().createElement(i.Space,{style:{width:"100%",justifyContent:"flex-end"}},c().createElement(i.Button,{onClick:A},f("Close")),c().createElement(i.Button,{type:"primary",onClick:function(){l.status="",l.errorMessage=""}},f("Back"))));var M=!h.length||!!E;return c().createElement("div",{className:(0,n.css)(_(),d.marginLG,d.marginLG,d.marginXS,d.colorText,d.lineHeight,d.marginXS,E?d.marginMD:0,d.colorBorder,d.borderRadius,d.colorBgContainer,d.colorPrimary,d.marginXXS,d.controlHeight,d.marginSM,d.paddingXXS,d.borderRadiusSM,d.colorText,d.lineHeight,d.colorFillAlter,d.colorTextSecondary,d.fontSizeLG,d.colorTextTertiary,d.colorText,d.padding,d.colorTextDescription,d.lineHeight,h.length?d.marginXXS:d.marginSM,d.marginMD,d.colorError,d.lineHeight,d.marginXS,d.marginLG)},c().createElement(i.Alert,{className:"import-warning",type:"warning",message:f("Import warnings",{ns:u,limit:2e3})}),c().createElement("div",{className:"import-step"},c().createElement("div",{className:"import-step-title"},f("Step 1: Download template",{ns:u})),c().createElement(i.Alert,{type:"info",style:{whiteSpace:"pre-line"},message:f("Download tips",{ns:u})}),c().createElement(i.Button,{className:"import-download-action",onClick:b},f("Download template",{ns:u}))),c().createElement("div",{className:"import-step"},c().createElement("div",{className:"import-step-title"},f("Step 2: Upload Excel",{ns:u})),c().createElement("div",{className:"import-upload-wrapper"},c().createElement("div",{className:"import-upload-dragger-shell"},c().createElement(i.Upload.Dragger,{action:"",maxCount:1,fileList:h,beforeUpload:function(){return!1},showUploadList:!1,onChange:function(e){var t=e.fileList.slice(-1);S(t),k(w(t))}},c().createElement("div",{className:"import-upload-placeholder"},f("Upload placeholder",{ns:u})))),h[0]&&c().createElement("div",{className:"import-upload-file"},c().createElement(t.PaperClipOutlined,{className:"import-upload-file-icon"}),c().createElement("span",{className:"import-upload-file-name",title:h[0].name},h[0].name),c().createElement(i.Button,{type:"text",size:"small",className:"import-upload-file-remove",icon:c().createElement(t.DeleteOutlined,null),onClick:function(){S([]),k("")}})),E&&c().createElement("div",{className:"import-upload-error"},E))),c().createElement("div",{className:"import-footer"},c().createElement(i.Button,{onClick:function(){return o.close()}},f("Cancel")),c().createElement(i.Button,{type:"primary",onClick:function(){return x(function(){var t,n,r,i,a,c,u,f,d,g,b,x,O,E;return T(this,function(j){switch(j.label){case 0:if(k(t=w(h)),t||!h.length)return[2];n=new FormData,r=h.map(function(e){return e.originFileObj}),n.append("file",r[0]),n.append("columns",JSON.stringify(v)),n.append("explain",y),i=e.model.getProps().importMode,l.status="importing",l.errorMessage="",j.label=1;case 1:return j.trys.push([1,6,,7]),d=(null==(a=p.getResourceName)?void 0:a.call(p))||m,g=null==(c=p.getSourceId)?void 0:c.call(p),x=(b=(null==(u=p.getDataSourceKey)?void 0:u.call(p))||s.collection.dataSourceKey)?{"X-Data-Source":b}:void 0,[4,e.api.resource(d,g,x).importXlsx({values:n,mode:i,timeout:6e5},{skipNotify:!0})];case 2:if(null==(O=j.sent().data)||null==(f=O.data)?void 0:f.taskId)return[3,4];return l.result=O,l.status="imported",[4,null==p||null==(E=p.refresh)?void 0:E.call(p)];case 3:return j.sent(),S([]),k(""),[3,5];case 4:o.close(),S([]),k(""),j.label=5;case 5:return[3,7];case 6:return l.errorMessage=N(j.sent()),l.status="error",[3,7];case 7:return[2]}})})()},disabled:M},f("Start import",{ns:"".concat(u)}))))}),[4,e.viewer.open({type:"dialog",placement:"center",width:800,title:e.t("Import Data",{ns:"".concat(u)}),content:function(e){return c().createElement(S,{popover:e})}})];case 1:return O.sent(),[2]}})})()}}}}),R.registerFlow({key:"importActionSetting",title:(0,o.escapeT)("Import action settings",{ns:u}),steps:{importSetting:{title:(0,o.escapeT)("Importable fields"),uiSchema:function(e){var t,r,o=(t=e.model.context.blockModel.collection.getFields(),r=e.t,b(t,function(e){var t;return r(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return e.targetCollection&&e.targetCollection.getFields()||[]}));return{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(u,'"}) }}'),"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:(0,n.css)(C())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":i.Cascader,required:!0,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1,options:o}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(u,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(u,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,n.css)(M())}}}}}},defaultParams:function(e){var t;return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){S(e,t,n[t])})}return e}({},{importColumns:null==(t=e.model.context.blockModel.collection.getFields())?void 0:t.filter(function(e){return!e.children&&!e.disabled}).map(function(e){return{dataIndex:[e.name]}}),explain:""})},handler:function(e,t){var n=t.importColumns,r=t.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});e.model.setProps("importSettings",{importColumns:o,explain:r})}}}});function q(e){return(q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function U(e,t){return(U=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function X(e){var t="function"==typeof Map?new Map:void 0;return(X=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return D(e,arguments,q(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),U(n,e)})(e)}function H(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(H=function(){return!!e})()}var $=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=q(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,H()?Reflect.construct(e,t||[],q(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&U(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return this.app.flowEngine.registerModels({ImportActionModel:R}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){L(i,r,o,a,l,"next",e)}function l(e){L(i,r,o,a,l,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(X(e.Plugin)),z=$}(),g}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/reactive"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-import/client-v2",["react-i18next","@emotion/css","@nocobase/client-v2","@formily/reactive","react","antd","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-action-import/client-v2"]=t(require("react-i18next"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/reactive"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["@nocobase/plugin-action-import/client-v2"]=t(e["react-i18next"],e["@emotion/css"],e["@nocobase/client-v2"],e["@formily/reactive"],e.react,e.antd,e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o,i,a,l){return function(){var c={574:function(e,t,n){var r,o;void 0===(o="function"==typeof(r=function(){"use strict";function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){l(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function r(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function o(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n.g&&n.g.global===n.g?n.g:void 0,a=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(e,n,a){var l=i.URL||i.webkitURL,c=document.createElement("a");c.download=n=n||e.name||"download",c.rel="noopener","string"==typeof e?(c.href=e,c.origin===location.origin?o(c):r(c.href)?t(e,n,a):o(c,c.target="_blank")):(c.href=l.createObjectURL(e),setTimeout(function(){l.revokeObjectURL(c.href)},4e4),setTimeout(function(){o(c)},0))}:"msSaveOrOpenBlob"in navigator?function(e,n,i){if(n=n||e.name||"download","string"!=typeof e){var a;navigator.msSaveOrOpenBlob((void 0===(a=i)?a={autoBom:!1}:"object"!=typeof a&&(console.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e),n)}else if(r(e))t(e,n,i);else{var l=document.createElement("a");l.href=e,l.target="_blank",setTimeout(function(){o(l)})}}:function(e,n,r,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var l="application/octet-stream"===e.type,c=/constructor/i.test(i.HTMLElement)||i.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||l&&c||a)&&"u">typeof FileReader){var s=new FileReader;s.onloadend=function(){var e=s.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=e:location=e,o=null},s.readAsDataURL(e)}else{var p=i.URL||i.webkitURL,f=p.createObjectURL(e);o?o.location=f:location.href=f,o=null,setTimeout(function(){p.revokeObjectURL(f)},4e4)}});i.saveAs=l.saveAs=l,e.exports=l})?r.apply(t,[]):r)||(e.exports=o)},375:function(e){"use strict";e.exports=a},477:function(e){"use strict";e.exports=t},992:function(e){"use strict";e.exports=r},485:function(e){"use strict";e.exports=n},694:function(e){"use strict";e.exports=l},59:function(e){"use strict";e.exports=i},155:function(e){"use strict";e.exports=o},953:function(t){"use strict";t.exports=e}},u={};function s(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return c[e].call(n.exports,n,n.exports,s),n.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(p=s.g.location+"");var p,f=s.g.document;if(!p&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(p=f.currentScript.src),!p)){var d=f.getElementsByTagName("script");if(d.length)for(var m=d.length-1;m>-1&&(!p||!/^http(s?):/.test(p));)p=d[m--].src}if(!p)throw Error("Automatic publicPath is not supported in this browser");s.p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var g={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-action-import/dist/client-v2/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",a=i.indexOf(o);e=a>=0?i.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-import/dist/client-v2/"}s.p=e}(),!function(){"use strict";s.r(g),s.d(g,{PluginActionImportClient:function(){return $},default:function(){return z},buildImportFieldOptions:function(){return b},ImportActionModel:function(){return R}});var e=s(485),t=s(375),n=s(477),r=s(992),o=s(694),i=s(59),a=s(574),l=s(155),c=s.n(l);s(953);var u="action-import",p=["createdAt","createdBy","updatedAt","updatedBy"],f=["hasOne","belongsTo","hasMany","belongsToMany","belongsToArray"],d=function(e){return!!((null==e?void 0:e.target)&&f.includes(e.type||""))},m=function(e){return!(null==e?void 0:e.interface)||p.includes(e.interface)},y=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{name:e.name,title:t(e),schema:e.uiSchema,disabled:n}},v=function(e,t,n){var r,o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(m(e))return null;if(!d(e))return y(e,t);var a=(n(e)||[]).map(function(e){return m(e)?null:d(e)?i>=1?y(e,t,!0):v(e,t,n,i+1):v(e,t,n)}).filter(function(e){return!!e});return a.length?(r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},y(e,t)),o=o={children:a},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r):y(e,t,!0)},b=function(e,t,n){return(e||[]).map(function(e){return v(e,t,n,+!!d(e))}).filter(function(e){return!!e})};function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function w(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function x(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){w(i,r,o,a,l,"next",e)}function l(e){w(i,r,o,a,l,"throw",e)}a(void 0)})}}function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function E(e,t){return(E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function j(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||A(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function A(e,t){if(e){if("string"==typeof e)return h(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return h(e,t)}}function I(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(I=function(){return!!e})()}function T(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function P(){var e=k(["\n max-height: min(42vh, 420px);\n overflow: auto;\n white-space: pre-wrap;\n word-break: break-word;\n line-height: 1.6;\n padding-right: 8px;\n "]);return P=function(){return e},e}function _(){var e=k(["\n .import-warning {\n margin-bottom: ","px;\n }\n\n .import-step {\n margin-bottom: ","px;\n }\n\n .import-step-title {\n margin-bottom: ","px;\n color: ",";\n line-height: ",";\n }\n\n .import-download-action {\n margin-top: ","px;\n }\n\n .import-upload-wrapper {\n margin-bottom: ","px;\n }\n\n .import-upload-dragger-shell {\n height: 150px;\n border: 1px dashed ",";\n border-radius: ","px;\n background: ",";\n transition: border-color 0.2s;\n }\n\n .import-upload-dragger-shell:hover {\n border-color: ",";\n }\n\n .import-upload-dragger-shell .ant-upload-wrapper,\n .import-upload-dragger-shell .ant-upload,\n .import-upload-dragger-shell .ant-upload-drag {\n width: 100%;\n height: 100%;\n border: 0;\n background: transparent;\n }\n\n .import-upload-dragger-shell .ant-upload-drag-container {\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .import-upload-dragger-shell .ant-upload-list {\n display: none;\n }\n\n .import-upload-file {\n display: flex;\n align-items: center;\n column-gap: ","px;\n min-height: ","px;\n margin-top: ","px;\n padding: 0 ","px;\n border-radius: ","px;\n color: ",";\n line-height: ",";\n transition: background-color 0.2s;\n }\n\n .import-upload-file:hover {\n background: ",";\n }\n\n .import-upload-file-icon {\n color: ",";\n font-size: ","px;\n }\n\n .import-upload-file-name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .import-upload-file-remove {\n color: ",";\n }\n\n .import-upload-file-remove:hover {\n color: ",";\n background: transparent;\n }\n\n .import-upload-placeholder {\n padding: 0 ","px;\n color: ",";\n line-height: ",";\n text-align: center;\n }\n\n .import-upload-error {\n margin-top: ","px;\n margin-bottom: ","px;\n color: ",";\n line-height: ",";\n word-break: break-word;\n }\n\n .import-footer {\n display: flex;\n justify-content: flex-end;\n gap: ","px;\n margin-top: ","px;\n }\n "]);return _=function(){return e},e}function C(){var e=k(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return C=function(){return e},e}function M(){var e=k(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return M=function(){return e},e}var F=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],B=function(e){if(!e)return"";if("string"==typeof e){var t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||e}if("string"==typeof e.message)return e.message;if(e.error)return B(e.error);var n=e.errors||e.messages;return Array.isArray(n)?n.map(B).filter(Boolean).join("\n"):""},N=function(e){var t;return B(null==e||null==(t=e.response)?void 0:t.data)||B(null==e?void 0:e.data)||(null==e?void 0:e.message)||"Import failed"},R=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=O(t),S(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,I()?Reflect.construct(t,r||[],O(this).constructor):t.apply(this,r)),"defaultProps",{title:(0,o.escapeT)("Import"),type:"default",icon:"uploadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&E(n,e),t=[{key:"getAclActionName",value:function(){return"importXlsx"}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(e.ActionModel);function L(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function D(e,t,n){return(D=H()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&U(o,n.prototype),o}).apply(null,arguments)}S(R,"scene",e.ActionSceneEnum.collection),R.define({label:(0,o.escapeT)("Import")}),R.registerFlow({key:"importSettings",title:(0,o.escapeT)("Import settings"),on:"click",steps:{import:{handler:function(e){return x(function(){var l,s,p,f,d,m,g,y,v,b,w,S;return T(this,function(O){switch(O.label){case 0:var E;return l=(0,r.observable)({status:"",result:null,errorMessage:""}),p=(s=e.model.context.blockModel).resource,d=(f=s.collection).title,m=f.name,y=(g=e.model.getProps().importSettings).explain,v=(!(E=g.importColumns)||!Array.isArray(E)?[]:E).map(function(t){var n=e.model.context.dataSourceManager.getCollectionField("".concat(s.collection.dataSourceKey,".").concat(m,".").concat(t.dataIndex[0]));if(n){if(t.defaultTitle=e.t(null==n||null==(r=n.uiSchema)?void 0:r.title)||n.name,t.dataIndex.length>1){var r,o,i=e.model.context.dataSourceManager.getCollectionField("".concat(e.model.context.collection.dataSourceKey,".").concat(m,".").concat(t.dataIndex.join(".")));if(!i)return;t.defaultTitle=t.defaultTitle+"/"+e.t(null==i||null==(o=i.uiSchema)?void 0:o.title)||i.name}return t}}).filter(Boolean),b=function(){return x(function(){var t;return T(this,function(n){switch(n.label){case 0:return[4,p.runAction("downloadXlsxTemplate",{data:{title:e.t(d),explain:y,columns:function(e){if(Array.isArray(e))return h(e)}(v)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(v)||A(v)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},responseType:"blob",method:"post"})];case 1:return t=new Blob([n.sent()],{type:"application/x-xls"}),(0,a.saveAs)(t,"".concat(e.t(d),".xlsx")),[2]}})})()},w=function(t){if(0===t.length)return"";if(t.length>1)return e.t("Only one file is allowed to be uploaded",{ns:u});var n,r,o=null!=(n=t[0])?n:{},i=o.type||(null==(r=o.originFileObj)?void 0:r.type);return F.includes(i)?"":e.t("Please upload the file of Excel",{ns:u})},S=(0,o.observer)(function(r){var o=r.popover,f=e.t,d=i.theme.useToken().token,g=j(c().useState([]),2),h=g[0],S=g[1],O=j(c().useState(""),2),E=O[0],k=O[1],A=function(){o.close(),l.status="",l.result=null,l.errorMessage="",S([]),k("")};if("importing"===l.status)return c().createElement("div",{style:{display:"flex",justifyContent:"center",padding:40}},c().createElement(i.Spin,{tip:f("Excel data importing"),indicator:c().createElement(t.LoadingOutlined,{spin:!0,style:{fontSize:24}})}));if("imported"===l.status){var I,C=null==(I=l.result)?void 0:I.meta;return c().createElement(i.Space,{direction:"vertical",align:"center",style:{width:"100%",padding:24}},c().createElement(t.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),c().createElement("p",null,function(e){if(!e)return null;var t=((null==e?void 0:e.data)||e).successCount;if(t)return f("{{successCount}} records have been successfully imported",{successCount:t,ns:u})}(l.result)),c().createElement(i.Space,null,(null==C?void 0:C.failureCount)>0&&c().createElement(i.Button,{onClick:function(){var e,t,n=new Blob([new Int8Array(null==(t=l.result)||null==(e=t.data)?void 0:e.data)],{type:"application/x-xls"});(0,a.saveAs)(n,"fail.xlsx")}},f("To download the failure data")),c().createElement(i.Button,{type:"primary",onClick:A},f("Done"))))}if("error"===l.status)return c().createElement(i.Space,{direction:"vertical",style:{width:"100%"},size:d.marginLG},c().createElement(i.Alert,{type:"error",showIcon:!0,message:f("Import failed",{ns:u}),description:c().createElement("div",{className:(0,n.css)(P())},l.errorMessage)}),c().createElement(i.Space,{style:{width:"100%",justifyContent:"flex-end"}},c().createElement(i.Button,{onClick:A},f("Close")),c().createElement(i.Button,{type:"primary",onClick:function(){l.status="",l.errorMessage=""}},f("Back"))));var M=!h.length||!!E;return c().createElement("div",{className:(0,n.css)(_(),d.marginLG,d.marginLG,d.marginXS,d.colorText,d.lineHeight,d.marginXS,E?d.marginMD:0,d.colorBorder,d.borderRadius,d.colorBgContainer,d.colorPrimary,d.marginXXS,d.controlHeight,d.marginSM,d.paddingXXS,d.borderRadiusSM,d.colorText,d.lineHeight,d.colorFillAlter,d.colorTextSecondary,d.fontSizeLG,d.colorTextTertiary,d.colorText,d.padding,d.colorTextDescription,d.lineHeight,h.length?d.marginXXS:d.marginSM,d.marginMD,d.colorError,d.lineHeight,d.marginXS,d.marginLG)},c().createElement(i.Alert,{className:"import-warning",type:"warning",message:f("Import warnings",{ns:u,limit:2e3})}),c().createElement("div",{className:"import-step"},c().createElement("div",{className:"import-step-title"},f("Step 1: Download template",{ns:u})),c().createElement(i.Alert,{type:"info",style:{whiteSpace:"pre-line"},message:f("Download tips",{ns:u})}),c().createElement(i.Button,{className:"import-download-action",onClick:b},f("Download template",{ns:u}))),c().createElement("div",{className:"import-step"},c().createElement("div",{className:"import-step-title"},f("Step 2: Upload Excel",{ns:u})),c().createElement("div",{className:"import-upload-wrapper"},c().createElement("div",{className:"import-upload-dragger-shell"},c().createElement(i.Upload.Dragger,{action:"",maxCount:1,fileList:h,beforeUpload:function(){return!1},showUploadList:!1,onChange:function(e){var t=e.fileList.slice(-1);S(t),k(w(t))}},c().createElement("div",{className:"import-upload-placeholder"},f("Upload placeholder",{ns:u})))),h[0]&&c().createElement("div",{className:"import-upload-file"},c().createElement(t.PaperClipOutlined,{className:"import-upload-file-icon"}),c().createElement("span",{className:"import-upload-file-name",title:h[0].name},h[0].name),c().createElement(i.Button,{type:"text",size:"small",className:"import-upload-file-remove",icon:c().createElement(t.DeleteOutlined,null),onClick:function(){S([]),k("")}})),E&&c().createElement("div",{className:"import-upload-error"},E))),c().createElement("div",{className:"import-footer"},c().createElement(i.Button,{onClick:function(){return o.close()}},f("Cancel")),c().createElement(i.Button,{type:"primary",onClick:function(){return x(function(){var t,n,r,i,a,c,u,f,d,g,b,x,O,E;return T(this,function(j){switch(j.label){case 0:if(k(t=w(h)),t||!h.length)return[2];n=new FormData,r=h.map(function(e){return e.originFileObj}),n.append("file",r[0]),n.append("columns",JSON.stringify(v)),n.append("explain",y),i=e.model.getProps().importMode,l.status="importing",l.errorMessage="",j.label=1;case 1:return j.trys.push([1,6,,7]),d=(null==(a=p.getResourceName)?void 0:a.call(p))||m,g=null==(c=p.getSourceId)?void 0:c.call(p),x=(b=(null==(u=p.getDataSourceKey)?void 0:u.call(p))||s.collection.dataSourceKey)?{"X-Data-Source":b}:void 0,[4,e.api.resource(d,g,x).importXlsx({values:n,mode:i,timeout:6e5},{skipNotify:!0})];case 2:if(null==(O=j.sent().data)||null==(f=O.data)?void 0:f.taskId)return[3,4];return l.result=O,l.status="imported",[4,null==p||null==(E=p.refresh)?void 0:E.call(p)];case 3:return j.sent(),S([]),k(""),[3,5];case 4:o.close(),S([]),k(""),j.label=5;case 5:return[3,7];case 6:return l.errorMessage=N(j.sent()),l.status="error",[3,7];case 7:return[2]}})})()},disabled:M},f("Start import",{ns:"".concat(u)}))))}),[4,e.viewer.open({type:"dialog",placement:"center",width:800,title:e.t("Import Data",{ns:"".concat(u)}),content:function(e){return c().createElement(S,{popover:e})}})];case 1:return O.sent(),[2]}})})()}}}}),R.registerFlow({key:"importActionSetting",title:(0,o.escapeT)("Import action settings",{ns:u}),steps:{importSetting:{title:(0,o.escapeT)("Importable fields"),uiSchema:function(e){var t,r,o=(t=e.model.context.blockModel.collection.getFields(),r=e.t,b(t,function(e){var t;return r(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return e.targetCollection&&e.targetCollection.getFields()||[]}));return{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(u,'"}) }}'),"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:(0,n.css)(C())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":i.Cascader,required:!0,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1,options:o}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(u,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(u,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,n.css)(M())}}}}}},defaultParams:function(e){var t;return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){S(e,t,n[t])})}return e}({},{importColumns:null==(t=e.model.context.blockModel.collection.getFields())?void 0:t.filter(function(e){return!e.children&&!e.disabled}).map(function(e){return{dataIndex:[e.name]}}),explain:""})},handler:function(e,t){var n=t.importColumns,r=t.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});e.model.setProps("importSettings",{importColumns:o,explain:r})}}}});function q(e){return(q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function U(e,t){return(U=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function X(e){var t="function"==typeof Map?new Map:void 0;return(X=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return D(e,arguments,q(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),U(n,e)})(e)}function H(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(H=function(){return!!e})()}var $=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=q(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,H()?Reflect.construct(e,t||[],q(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&U(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return this.app.flowEngine.registerModels({ImportActionModel:R}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){L(i,r,o,a,l,"next",e)}function l(e){L(i,r,o,a,l,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(X(e.Plugin)),z=$}(),g}()});
@@ -10,26 +10,26 @@
10
10
  module.exports = {
11
11
  "@emotion/css": "11.13.0",
12
12
  "@formily/react": "2.3.7",
13
- "@nocobase/client": "2.1.2",
13
+ "@nocobase/client": "2.1.4",
14
14
  "antd": "5.24.2",
15
15
  "react": "18.2.0",
16
16
  "react-i18next": "11.18.6",
17
17
  "@ant-design/icons": "5.6.1",
18
18
  "@formily/shared": "2.3.7",
19
- "@nocobase/utils": "2.1.2",
19
+ "@nocobase/utils": "2.1.4",
20
20
  "@formily/antd-v5": "1.2.3",
21
21
  "react-dom": "18.2.0",
22
22
  "lodash": "4.18.1",
23
23
  "@formily/core": "2.3.7",
24
24
  "@formily/reactive": "2.3.7",
25
- "@nocobase/client-v2": "2.1.2",
26
- "@nocobase/flow-engine": "2.1.2",
27
- "@nocobase/server": "2.1.2",
28
- "@nocobase/actions": "2.1.2",
29
- "@nocobase/database": "2.1.2",
25
+ "@nocobase/client-v2": "2.1.4",
26
+ "@nocobase/flow-engine": "2.1.4",
27
+ "@nocobase/server": "2.1.4",
28
+ "@nocobase/actions": "2.1.4",
29
+ "@nocobase/database": "2.1.4",
30
30
  "async-mutex": "0.5.0",
31
- "@nocobase/data-source-manager": "2.1.2",
31
+ "@nocobase/data-source-manager": "2.1.4",
32
32
  "sequelize": "6.35.2",
33
- "@nocobase/logger": "2.1.2",
33
+ "@nocobase/logger": "2.1.4",
34
34
  "mathjs": "15.1.0"
35
35
  };
@@ -1 +1 @@
1
- {"name":"exceljs","version":"4.4.0","description":"Excel Workbook Manager - Read and Write xlsx and csv Files.","private":false,"license":"MIT","author":{"name":"Guyon Roche","email":"guyon@live.com"},"repository":{"type":"git","url":"https://github.com/exceljs/exceljs.git"},"engines":{"node":">=8.3.0"},"main":"./excel.js","browser":"./dist/exceljs.min.js","types":"./index.d.ts","files":["dist","lib","excel.js","LICENSE","README.md","README_zh.md","index.ts","index.d.ts"],"scripts":{"test":"npm run test:full","test:es5":"export EXCEL_BUILD=es5 && npm run test:full","test:full":"npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:jasmine","test:version":"npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:browser && npm run test:dist","test:all":"npm run test:native && npm run test:es5","test:native":"npm run test:full","test:unit":"mocha --require spec/config/setup --require spec/config/setup-unit spec/unit --recursive","test:integration":"mocha --require spec/config/setup spec/integration --recursive","test:end-to-end":"mocha --require spec/config/setup spec/end-to-end --recursive","test:browser":"if [ ! -f .disable-test-browser ]; then npm run build && npm run test:jasmine; fi","test:jasmine":"grunt jasmine","test:unit:es5":"export EXCEL_BUILD=es5 && npm run test:unit","test:integration:es5":"export EXCEL_BUILD=es5 && npm run test:integration","test:end-to-end:es5":"export EXCEL_BUILD=es5 && npm run test:end-to-end","test:dist":"mocha --require spec/config/setup spec/dist --recursive","test:manual":"node spec/manual/app.js","test:typescript":"mocha -r ts-node/register spec/typescript/**/*.spec.ts","clean-build":"npm run clean && npm run build","lint":"eslint --format node_modules/eslint-friendly-formatter .","lint:fix":"prettier-eslint --write $(pwd)'/**/*.js'","lint:staged":"lint-staged","clean":"rm -rf build/ && rm -rf dist","benchmark":"node --expose-gc benchmark","benchmark:debug":"node --expose-gc --inspect-brk --trace-deopt benchmark","build":"grunt build","install-build":"npm install && grunt build","preversion":"npm run clean && npm run build && npm run test:version","postversion":"git push --no-verify && git push --tags --no-verify"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.js":["prettier-eslint --write","eslint --format node_modules/eslint-friendly-formatter","git add"]},"keywords":["xlsx","json","csv","excel","font","border","fill","number","format","number format","alignment","office","spreadsheet","workbook","defined names","data validations","rich text","in-cell format","outlineLevel","views","frozen","split","pageSetup"],"dependencies":{"archiver":"^5.0.0","dayjs":"^1.8.34","fast-csv":"^4.3.1","jszip":"^3.10.1","readable-stream":"^3.6.0","saxes":"^5.0.1","tmp":"^0.2.0","unzipper":"^0.10.11","uuid":"^8.3.0"},"devDependencies":{"@babel/cli":"^7.10.5","@babel/core":"^7.11.4","@babel/preset-env":"^7.11.0","@types/chai":"^4.2.12","@types/mocha":"^8.0.3","@types/node":"^14.11.2","babelify":"^10.0.0","browserify":"^16.5.2","chai":"^4.2.0","chai-datetime":"^1.7.0","chai-xml":"^0.3.2","core-js":"^3.6.5","dirty-chai":"^2.0.1","eslint":"^6.5.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.12.0","eslint-friendly-formatter":"^4.0.1","eslint-plugin-import":"^2.22.0","eslint-plugin-node":"^11.1.0","express":"^4.16.4","got":"^9.0.0","grunt":"^1.3.0","grunt-babel":"^8.0.0","grunt-browserify":"^5.3.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-jasmine":"^2.2.0","grunt-contrib-watch":"^1.1.0","grunt-exorcise":"^2.1.1","grunt-terser":"^1.0.0","husky":"^4.3.0","lint-staged":"^10.2.13","mocha":"^7.2.0","prettier-eslint":"^11.0.0","prettier-eslint-cli":"^5.0.0","regenerator-runtime":"^0.13.7","sax":"^1.2.4","ts-node":"^8.10.2","typescript":"^3.9.7"},"_lastModified":"2026-06-11T23:23:08.908Z"}
1
+ {"name":"exceljs","version":"4.4.0","description":"Excel Workbook Manager - Read and Write xlsx and csv Files.","private":false,"license":"MIT","author":{"name":"Guyon Roche","email":"guyon@live.com"},"repository":{"type":"git","url":"https://github.com/exceljs/exceljs.git"},"engines":{"node":">=8.3.0"},"main":"./excel.js","browser":"./dist/exceljs.min.js","types":"./index.d.ts","files":["dist","lib","excel.js","LICENSE","README.md","README_zh.md","index.ts","index.d.ts"],"scripts":{"test":"npm run test:full","test:es5":"export EXCEL_BUILD=es5 && npm run test:full","test:full":"npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:jasmine","test:version":"npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:browser && npm run test:dist","test:all":"npm run test:native && npm run test:es5","test:native":"npm run test:full","test:unit":"mocha --require spec/config/setup --require spec/config/setup-unit spec/unit --recursive","test:integration":"mocha --require spec/config/setup spec/integration --recursive","test:end-to-end":"mocha --require spec/config/setup spec/end-to-end --recursive","test:browser":"if [ ! -f .disable-test-browser ]; then npm run build && npm run test:jasmine; fi","test:jasmine":"grunt jasmine","test:unit:es5":"export EXCEL_BUILD=es5 && npm run test:unit","test:integration:es5":"export EXCEL_BUILD=es5 && npm run test:integration","test:end-to-end:es5":"export EXCEL_BUILD=es5 && npm run test:end-to-end","test:dist":"mocha --require spec/config/setup spec/dist --recursive","test:manual":"node spec/manual/app.js","test:typescript":"mocha -r ts-node/register spec/typescript/**/*.spec.ts","clean-build":"npm run clean && npm run build","lint":"eslint --format node_modules/eslint-friendly-formatter .","lint:fix":"prettier-eslint --write $(pwd)'/**/*.js'","lint:staged":"lint-staged","clean":"rm -rf build/ && rm -rf dist","benchmark":"node --expose-gc benchmark","benchmark:debug":"node --expose-gc --inspect-brk --trace-deopt benchmark","build":"grunt build","install-build":"npm install && grunt build","preversion":"npm run clean && npm run build && npm run test:version","postversion":"git push --no-verify && git push --tags --no-verify"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.js":["prettier-eslint --write","eslint --format node_modules/eslint-friendly-formatter","git add"]},"keywords":["xlsx","json","csv","excel","font","border","fill","number","format","number format","alignment","office","spreadsheet","workbook","defined names","data validations","rich text","in-cell format","outlineLevel","views","frozen","split","pageSetup"],"dependencies":{"archiver":"^5.0.0","dayjs":"^1.8.34","fast-csv":"^4.3.1","jszip":"^3.10.1","readable-stream":"^3.6.0","saxes":"^5.0.1","tmp":"^0.2.0","unzipper":"^0.10.11","uuid":"^8.3.0"},"devDependencies":{"@babel/cli":"^7.10.5","@babel/core":"^7.11.4","@babel/preset-env":"^7.11.0","@types/chai":"^4.2.12","@types/mocha":"^8.0.3","@types/node":"^14.11.2","babelify":"^10.0.0","browserify":"^16.5.2","chai":"^4.2.0","chai-datetime":"^1.7.0","chai-xml":"^0.3.2","core-js":"^3.6.5","dirty-chai":"^2.0.1","eslint":"^6.5.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.12.0","eslint-friendly-formatter":"^4.0.1","eslint-plugin-import":"^2.22.0","eslint-plugin-node":"^11.1.0","express":"^4.16.4","got":"^9.0.0","grunt":"^1.3.0","grunt-babel":"^8.0.0","grunt-browserify":"^5.3.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-jasmine":"^2.2.0","grunt-contrib-watch":"^1.1.0","grunt-exorcise":"^2.1.1","grunt-terser":"^1.0.0","husky":"^4.3.0","lint-staged":"^10.2.13","mocha":"^7.2.0","prettier-eslint":"^11.0.0","prettier-eslint-cli":"^5.0.0","regenerator-runtime":"^0.13.7","sax":"^1.2.4","ts-node":"^8.10.2","typescript":"^3.9.7"},"_lastModified":"2026-06-13T06:59:22.557Z"}
@@ -1 +1 @@
1
- {"name":"xlsx","version":"0.20.3","author":"sheetjs","description":"SheetJS Spreadsheet data parser and writer","keywords":["excel","xls","xlsx","xlsb","xlsm","ods","csv","dbf","dif","sylk","office","spreadsheet"],"bin":{"xlsx":"./bin/xlsx.njs"},"main":"xlsx.js","module":"xlsx.mjs","unpkg":"dist/xlsx.full.min.js","jsdelivr":"dist/xlsx.full.min.js","types":"types/index.d.ts","exports":{".":{"import":"./xlsx.mjs","require":"./xlsx.js","types":"./types/index.d.ts"},"./xlsx.mjs":{"import":"./xlsx.mjs","types":"./types/index.d.ts"},"./xlsx.js":{"require":"./xlsx.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min.js":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min.js":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min.js":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.zahl":{"import":"./dist/xlsx.zahl.mjs","require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.mjs":{"import":"./dist/xlsx.zahl.mjs","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.js":{"require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/cpexcel":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.js":{"require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full.mjs":{"import":"./dist/cpexcel.full.mjs","types":"./dist/cpexcel.d.ts"}},"browser":{"buffer":false,"crypto":false,"stream":false,"process":false,"fs":false},"sideEffects":false,"dependencies":{},"devDependencies":{"@sheetjs/uglify-js":"~2.7.3","@types/node":"^8.5.9","acorn":"7.4.1","adler-32":"~1.3.1","alex":"8.1.1","blanket":"~1.2.3","cfb":"~1.2.2","codepage":"~1.15.0","commander":"~2.17.1","crc-32":"~1.2.2","dtslint":"^0.1.2","eslint":"7.23.0","eslint-plugin-html":"^6.1.2","eslint-plugin-json":"^2.1.2","exit-on-epipe":"~1.0.1","fflate":"^0.7.1","jsdom":"~11.1.0","markdown-spellcheck":"^1.3.1","mocha":"~2.5.3","sinon":"^1.17.7","ssf":"~0.11.2","typescript":"2.2.0","wmf":"~1.0.1","word":"~0.3.0"},"repository":{"type":"git","url":"https://git.sheetjs.com/SheetJS/sheetjs"},"scripts":{"pretest":"npm run lint","test":"npm run tests-only","pretest-only":"git submodule init && git submodule update","tests-only":"make travis","build":"make","lint":"make fullint","dtslint":"dtslint types"},"config":{"blanket":{"pattern":"xlsx.js"}},"alex":{"allow":["chinese","special","simple","just","crash","wtf","holes"]},"homepage":"https://sheetjs.com/","files":["CHANGELOG.md","LICENSE","README.md","bower.json","package.json","xlsx.js","xlsx.mjs","xlsxworker.js","bin/xlsx.njs","dist/LICENSE","dist/*.mjs","dist/*.js","dist/*.map","dist/*.d.ts","types/index.d.ts","types/tsconfig.json"],"bugs":{"url":"https://git.sheetjs.com/SheetJS/sheetjs/issues"},"license":"Apache-2.0","engines":{"node":">=0.8"},"_lastModified":"2026-06-11T23:23:11.453Z"}
1
+ {"name":"xlsx","version":"0.20.3","author":"sheetjs","description":"SheetJS Spreadsheet data parser and writer","keywords":["excel","xls","xlsx","xlsb","xlsm","ods","csv","dbf","dif","sylk","office","spreadsheet"],"bin":{"xlsx":"./bin/xlsx.njs"},"main":"xlsx.js","module":"xlsx.mjs","unpkg":"dist/xlsx.full.min.js","jsdelivr":"dist/xlsx.full.min.js","types":"types/index.d.ts","exports":{".":{"import":"./xlsx.mjs","require":"./xlsx.js","types":"./types/index.d.ts"},"./xlsx.mjs":{"import":"./xlsx.mjs","types":"./types/index.d.ts"},"./xlsx.js":{"require":"./xlsx.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min.js":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min.js":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min.js":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.zahl":{"import":"./dist/xlsx.zahl.mjs","require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.mjs":{"import":"./dist/xlsx.zahl.mjs","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.js":{"require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/cpexcel":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.js":{"require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full.mjs":{"import":"./dist/cpexcel.full.mjs","types":"./dist/cpexcel.d.ts"}},"browser":{"buffer":false,"crypto":false,"stream":false,"process":false,"fs":false},"sideEffects":false,"dependencies":{},"devDependencies":{"@sheetjs/uglify-js":"~2.7.3","@types/node":"^8.5.9","acorn":"7.4.1","adler-32":"~1.3.1","alex":"8.1.1","blanket":"~1.2.3","cfb":"~1.2.2","codepage":"~1.15.0","commander":"~2.17.1","crc-32":"~1.2.2","dtslint":"^0.1.2","eslint":"7.23.0","eslint-plugin-html":"^6.1.2","eslint-plugin-json":"^2.1.2","exit-on-epipe":"~1.0.1","fflate":"^0.7.1","jsdom":"~11.1.0","markdown-spellcheck":"^1.3.1","mocha":"~2.5.3","sinon":"^1.17.7","ssf":"~0.11.2","typescript":"2.2.0","wmf":"~1.0.1","word":"~0.3.0"},"repository":{"type":"git","url":"https://git.sheetjs.com/SheetJS/sheetjs"},"scripts":{"pretest":"npm run lint","test":"npm run tests-only","pretest-only":"git submodule init && git submodule update","tests-only":"make travis","build":"make","lint":"make fullint","dtslint":"dtslint types"},"config":{"blanket":{"pattern":"xlsx.js"}},"alex":{"allow":["chinese","special","simple","just","crash","wtf","holes"]},"homepage":"https://sheetjs.com/","files":["CHANGELOG.md","LICENSE","README.md","bower.json","package.json","xlsx.js","xlsx.mjs","xlsxworker.js","bin/xlsx.njs","dist/LICENSE","dist/*.mjs","dist/*.js","dist/*.map","dist/*.d.ts","types/index.d.ts","types/tsconfig.json"],"bugs":{"url":"https://git.sheetjs.com/SheetJS/sheetjs/issues"},"license":"Apache-2.0","engines":{"node":">=0.8"},"_lastModified":"2026-06-13T06:59:25.010Z"}
@@ -9,5 +9,5 @@
9
9
  /// <reference types="node" />
10
10
  import { Context, Next } from '@nocobase/actions';
11
11
  import * as XLSX from 'xlsx';
12
- export declare function readImportWorkbook(buffer: Buffer, sheetRows: number): XLSX.WorkBook;
12
+ export declare function readImportWorkbook(file: Buffer | string, sheetRows: number): XLSX.WorkBook;
13
13
  export declare function importXlsx(ctx: Context, next: Next): Promise<void>;
@@ -43,16 +43,26 @@ module.exports = __toCommonJS(import_xlsx_exports);
43
43
  var XLSX = __toESM(require("xlsx"));
44
44
  var import_async_mutex = require("async-mutex");
45
45
  var import_xlsx_importer = require("../services/xlsx-importer");
46
+ var import_fs = __toESM(require("fs"));
46
47
  const IMPORT_LIMIT_COUNT = 2e3;
47
48
  const mutex = new import_async_mutex.Mutex();
48
- function readImportWorkbook(buffer, sheetRows) {
49
- return XLSX.read(buffer, {
50
- type: "buffer",
49
+ function readImportWorkbook(file, sheetRows) {
50
+ const options = {
51
51
  sheetRows,
52
52
  // Keep Excel date cells as serial numbers. SheetJS `cellDates: true` converts
53
53
  // them to local-time Date objects through a timezone-sensitive path, which can
54
54
  // shift date-only values in non-UTC environments (for example Asia/Shanghai).
55
55
  cellDates: false
56
+ };
57
+ if (typeof file === "string") {
58
+ return XLSX.read(import_fs.default.readFileSync(file), {
59
+ type: "buffer",
60
+ ...options
61
+ });
62
+ }
63
+ return XLSX.read(file, {
64
+ type: "buffer",
65
+ ...options
56
66
  });
57
67
  }
58
68
  async function importXlsxAction(ctx, next) {
@@ -66,24 +76,31 @@ async function importXlsxAction(ctx, next) {
66
76
  if (ctx.request.body.explain) {
67
77
  readLimit += 1;
68
78
  }
69
- const workbook = readImportWorkbook(ctx.file.buffer, readLimit);
70
- const repository = ctx.getCurrentRepository();
71
- const dataSource = ctx.dataSource;
72
- const collection = repository.collection;
73
- const importer = new import_xlsx_importer.XlsxImporter({
74
- collectionManager: dataSource.collectionManager,
75
- collection,
76
- columns,
77
- workbook,
78
- explain: ctx.request.body.explain,
79
- repository,
80
- rowDefaultValues: ((_a = ctx.action.params) == null ? void 0 : _a.rowDefaultValues) || {}
81
- });
82
- const importedCount = await importer.run({
83
- context: ctx
84
- });
85
- ctx.bodyMeta = { successCount: importedCount };
86
- ctx.body = ctx.bodyMeta;
79
+ const uploadedFilePath = ctx.file.path;
80
+ try {
81
+ const workbook = readImportWorkbook(uploadedFilePath || ctx.file.buffer, readLimit);
82
+ const repository = ctx.getCurrentRepository();
83
+ const dataSource = ctx.dataSource;
84
+ const collection = repository.collection;
85
+ const importer = new import_xlsx_importer.XlsxImporter({
86
+ collectionManager: dataSource.collectionManager,
87
+ collection,
88
+ columns,
89
+ workbook,
90
+ explain: ctx.request.body.explain,
91
+ repository,
92
+ rowDefaultValues: ((_a = ctx.action.params) == null ? void 0 : _a.rowDefaultValues) || {}
93
+ });
94
+ const importedCount = await importer.run({
95
+ context: ctx
96
+ });
97
+ ctx.bodyMeta = { successCount: importedCount };
98
+ ctx.body = ctx.bodyMeta;
99
+ } finally {
100
+ if (uploadedFilePath) {
101
+ await import_fs.default.promises.rm(uploadedFilePath, { force: true });
102
+ }
103
+ }
87
104
  }
88
105
  async function importXlsx(ctx, next) {
89
106
  if (mutex.isLocked()) {
@@ -7,9 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
+ var __create = Object.create;
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
13
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
16
  var __export = (target, all) => {
15
17
  for (var name in all)
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
23
25
  }
24
26
  return to;
25
27
  };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
26
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
37
  var middleware_exports = {};
28
38
  __export(middleware_exports, {
@@ -30,11 +40,27 @@ __export(middleware_exports, {
30
40
  });
31
41
  module.exports = __toCommonJS(middleware_exports);
32
42
  var import_utils = require("@nocobase/utils");
43
+ var import_fs = __toESM(require("fs"));
44
+ var import_path = __toESM(require("path"));
45
+ function getUploadDir() {
46
+ return import_path.default.join(process.cwd(), "storage", "tmp");
47
+ }
33
48
  async function importMiddleware(ctx, next) {
34
49
  if (ctx.action.actionName !== "importXlsx") {
35
50
  return next();
36
51
  }
37
- const upload = (0, import_utils.koaMulter)().single("file");
52
+ const storage = import_utils.koaMulter.diskStorage({
53
+ destination(req, file, cb) {
54
+ const dir = getUploadDir();
55
+ import_fs.default.mkdirSync(dir, { recursive: true });
56
+ cb(null, dir);
57
+ },
58
+ filename(req, file, cb) {
59
+ const ext = import_path.default.extname(file.originalname || ".xlsx") || ".xlsx";
60
+ cb(null, `import-${Date.now()}-${Math.random().toString(36).slice(2)}${ext}`);
61
+ }
62
+ });
63
+ const upload = (0, import_utils.koaMulter)({ storage }).single("file");
38
64
  return upload(ctx, next);
39
65
  }
40
66
  // Annotate the CommonJS export names for ESM import in node:
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Import records using excel templates. You can configure which fields to import and templates will be generated automatically.",
7
7
  "description.ru-RU": "Импорт записей с помощью шаблонов Excel: можно настроить, какие поля импортировать, шаблоны будут генерироваться автоматически.",
8
8
  "description.zh-CN": "使用 Excel 模板导入数据,可以配置导入哪些字段,自动生成模板。",
9
- "version": "2.1.2",
9
+ "version": "2.1.4",
10
10
  "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/action-import",
@@ -47,7 +47,7 @@
47
47
  "@nocobase/test": "2.x",
48
48
  "@nocobase/utils": "2.x"
49
49
  },
50
- "gitHead": "e1b28561425c5c34ff3bc6ae1f81c66b72f02872",
50
+ "gitHead": "73c01b1e842afdaafdffd6fa4bb090c1da9b0816",
51
51
  "keywords": [
52
52
  "Actions"
53
53
  ]