@nocobase/plugin-file-manager 2.1.0-alpha.1 → 2.1.0-alpha.2
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/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +1 -1
- package/dist/client/models/UploadFieldModel.d.ts +22 -0
- package/dist/client/previewer/filePreviewTypes.d.ts +39 -0
- package/dist/client/schemas/storageTypes/ali-oss.d.ts +19 -0
- package/dist/client/schemas/storageTypes/common.d.ts +19 -0
- package/dist/client/schemas/storageTypes/index.d.ts +19 -0
- package/dist/client/templates/file.d.ts +2 -2
- package/dist/common/collections/storages.d.ts +11 -0
- package/dist/common/collections/storages.js +5 -0
- package/dist/externalVersion.js +9 -8
- package/dist/locale/en-US.json +2 -0
- package/dist/locale/zh-CN.json +3 -0
- package/dist/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +7858 -7858
- package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
- package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/index.js +7858 -7858
- package/dist/node_modules/@aws-sdk/lib-storage/package.json +1 -1
- package/dist/node_modules/ali-oss/lib/client.js +1 -1
- package/dist/node_modules/ali-oss/package.json +1 -1
- package/dist/node_modules/mime-match/package.json +1 -1
- package/dist/node_modules/mime-types/package.json +1 -1
- package/dist/node_modules/mkdirp/package.json +1 -1
- package/dist/node_modules/multer-cos/package.json +1 -1
- package/dist/node_modules/url-join/package.json +1 -1
- package/dist/server/actions/attachments.js +21 -1
- package/dist/server/storages/index.d.ts +1 -0
- package/dist/server/storages/index.js +2 -0
- package/dist/server/storages/local.d.ts +2 -0
- package/dist/server/storages/local.js +27 -5
- package/dist/server/storages/s3.d.ts +0 -1
- package/dist/server/storages/s3.js +0 -27
- package/dist/server/utils.js +20 -6
- package/package.json +2 -2
package/dist/client/index.d.ts
CHANGED
|
@@ -27,4 +27,7 @@ export declare class PluginFileManagerClient extends Plugin {
|
|
|
27
27
|
data?: any;
|
|
28
28
|
}>;
|
|
29
29
|
}
|
|
30
|
+
export { filePreviewTypes, wrapWithModalPreviewer } from './previewer/filePreviewTypes';
|
|
31
|
+
export type { FilePreviewType, FilePreviewerProps } from './previewer/filePreviewTypes';
|
|
32
|
+
export { CardUpload, UploadFieldModel } from './models/UploadFieldModel';
|
|
30
33
|
export default PluginFileManagerClient;
|
package/dist/client/index.js
CHANGED
|
@@ -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"),require("@nocobase/flow-engine"),require("lodash"),require("@formily/shared"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("antd"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-file-manager",["react","@nocobase/flow-engine","lodash","@formily/shared","@nocobase/client","@formily/react","@ant-design/icons","antd","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-file-manager"]=t(require("react"),require("@nocobase/flow-engine"),require("lodash"),require("@formily/shared"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("antd"),require("react-i18next")):e["@nocobase/plugin-file-manager"]=t(e.react,e["@nocobase/flow-engine"],e.lodash,e["@formily/shared"],e["@nocobase/client"],e["@formily/react"],e["@ant-design/icons"],e.antd,e["react-i18next"])}(self,function(e,t,n,r,o,i,a,l,c){var u={371:function(e,t,n){var r=n(275),o=/[\/\+\.]/;e.exports=function(e,t){function n(t){var n=r(t,e,o);return n&&n.length>=2}return t?n(t.split(";")[0]):n}},275:function(e){"use strict";function t(e,t){this.text=e=e||"",this.hasWild=~e.indexOf("*"),this.separator=t,this.parts=e.split(t)}t.prototype.match=function(e){var t,n,r=!0,o=this.parts,i=o.length;if("string"==typeof e||e instanceof String)if(this.hasWild||this.text==e){for(t=0,n=(e||"").split(this.separator);r&&t<i;t++)if("*"===o[t])continue;else r=t<n.length&&o[t]===n[t];r=r&&n}else r=!1;else if("function"==typeof e.splice)for(r=[],t=e.length;t--;)this.match(e[t])&&(r[r.length]=e[t]);else if("object"==typeof e)for(var a in r={},e)this.match(a)&&(r[a]=e[a]);return r},e.exports=function(e,n,r){var o=new t(e,r||/[\/\.]/);return void 0!==n?o.match(n):o}},482:function(e){"use strict";e.exports=a},505:function(e){"use strict";e.exports=i},875:function(e){"use strict";e.exports=r},772:function(e){"use strict";e.exports=o},667:function(e){"use strict";e.exports=t},721:function(e){"use strict";e.exports=l},467:function(e){"use strict";e.exports=n},156:function(t){"use strict";t.exports=e},238:function(e){"use strict";e.exports=c}},s={};function p(e){var t=s[e];if(void 0!==t)return t.exports;var n=s[e]={exports:{}};return u[e](n,n.exports,p),n.exports}p.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return p.d(t,{a:t}),t},p.d=function(e,t){for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},p.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var d={};return!function(){"use strict";p.r(d),p.d(d,{PluginFileManagerClient:function(){return eJ},default:function(){return eQ}});var e,t,n,r={};p.r(r),p.d(r,{useAttachmentFieldProps:function(){return v},useFileCollectionStorageRules:function(){return x},useStorageRules:function(){return h},useUploadFiles:function(){return b}});var o=p(772),i=Number.POSITIVE_INFINITY,a=p(156),l=p.n(a);function c(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}function u(){var e,t,n,r,i,l,c,u=(0,o.useCollectionField)(),s=(0,o.useCollectionManager)().getCollection(null==u?void 0:u.target),p=(0,o.useCollection)(),d=(0,o.usePlugin)(eQ),f=(t=null!=(e=(null==u?void 0:u.storage)||(null==p?void 0:p.getOption("storage"))||(null==s?void 0:s.getOption("storage")))?e:"",n="storages:getBasicInfo/".concat(t),i=(r=(0,o.useRequest)({url:n},{manual:!0,refreshDeps:[t],cacheKey:n})).loading,l=r.data,c=r.run,(0,a.useEffect)(function(){c()},[c]),!i&&(null==l?void 0:l.data)||null),m=d.getStorageType(null==f?void 0:f.type);return{storage:f,storageType:m}}function s(e){var t=u(),n=t.storage,r=t.storageType,o=null==r?void 0:r.useUploadProps,i=(null==o?void 0:o(c({storage:n,rules:n.rules},e)))||{};return c({rules:null==n?void 0:n.rules},i)}function f(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 m(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||y(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){if(e){if("string"==typeof e)return f(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 f(e,t)}}var b=function(){var e=(0,o.useDataBlockRequestGetter)().getDataBlockRequest,t=((0,o.useDataBlockProps)()||{}).association,n=(0,o.useActionContext)().setVisible,r=(0,o.useCollection)(),i=(0,o.useSourceId)(),l=(0,a.useMemo)(function(){var e="".concat(r.name,":create");if(t){var n,o=(n=t.split("."),function(e){if(Array.isArray(e))return e}(n)||function(e,t){var n,r,o=null==e?null:"undefined"!=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),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}}(n,2)||y(n,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=o[0],l=o[1];e="".concat(a,"/").concat(i,"/").concat(l,":create")}return e},[r.name,t,i]),c=((0,a.useContext)(o.RecordPickerContext)||{}).setSelectedRows,u={},p=0,d={action:l,onChange:function(t){t.forEach(function(n){if("uploading"!==n.status||u[n.uid]||(p++,u[n.uid]=!0),"uploading"!==n.status&&u[n.uid]&&(delete u[n.uid],0==--p)){var r,o;null==(o=e())||null==(r=o.refresh)||r.call(o),null==c||c(function(e){return m(e).concat(m(t.filter(function(e){return"done"===e.status}).map(function(e){return e.response.data})))})}}),t.every(function(e){return"done"===e.status})&&n(!1)}},f=s(d);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){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}({},d,f)},g=p(505);function h(e){var t,n=null!=e?e:"";(0,o.useAPIClient)();var r=(0,g.useField)(),i=(0,o.useRequest)({url:"storages:getBasicInfo/".concat(n)},{manual:!0,refreshDeps:[n],cacheKey:n}),l=i.loading,c=i.data,u=i.run;return(0,a.useEffect)(function(){"editable"===r.pattern&&u()},[r.pattern,u]),!l&&(null==c||null==(t=c.data)?void 0:t.rules)||null}function v(){var e=(0,o.useCollectionField)(),t="".concat(null==e?void 0:e.target,":create").concat((null==e?void 0:e.storage)?"?attachmentField=".concat(e.collectionName,".").concat(e.name):""),n=s({action: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){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}({action:t},n)}function x(){var e=(0,o.useCollectionField)(),t=(0,o.useCollectionManager)().getCollection(null==e?void 0:e.target);return h(null==t?void 0:t.getOption("storage"))}var O=function(e){var t,n,r={type:"void","x-action":"create",title:"{{t('Upload')}}","x-designer":"Action.Designer","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",icon:"UploadOutlined"},properties:{drawer:{type:"void",title:'{{ t("Upload files") }}',"x-component":"Action.Container",properties:{upload:{type:"void",title:'{{ t("Upload files") }}',"x-component":"Upload.DraggerV2","x-use-component-props":"useUploadFiles","x-component-props":{height:"50vh",multiple:!0,listType:"picture"}}}}}};return l().createElement(o.ActionInitializerItem,(t=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}({},e),n=n={schema:r},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))},w={dumpRules:{group:"user"},migrationRules:["schema-only","overwrite"],asStrategyResource:!0,shared:!0,name:"attachments",createdBy:!0,updatedBy:!0,template:"file",filterTargetKey:"id",fields:[{comment:"用户文件名(不含扩展名)",type:"string",name:"title"},{comment:"系统文件名(含扩展名)",type:"string",name:"filename"},{comment:"扩展名(含“.”)",type:"string",name:"extname"},{comment:"文件体积(字节)",type:"integer",name:"size"},{type:"string",name:"mimetype"},{type:"belongsTo",name:"storage",target:"storages",foreignKey:"storageId",deletable:!1,interface:"m2o",uiSchema:{type:"object",title:"{{t('Storage', { ns: '".concat("file-manager","' })}}"),"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"title"}},"x-read-pretty":!0}},{comment:"相对路径(含“/”前缀)",type:"text",name:"path"},{comment:"其他文件信息(如图片的宽高)",type:"jsonb",name:"meta",defaultValue:{}},{comment:"网络访问地址",type:"text",name:"url"}]},S={dumpRules:"required",migrationRules:["overwrite","schema-only"],name:"storages",shared:!0,fields:[{name:"id",type:"snowflakeId",primaryKey:!0,allowNull:!1},{title:"存储引擎名称",comment:"存储引擎名称",type:"string",name:"title",translation:!0,trim:!0},{title:"英文标识",type:"uid",name:"name",unique:!0,trim:!0},{comment:"类型标识,如 local/ali-oss 等",type:"string",name:"type"},{comment:"配置项",type:"jsonb",name:"options",defaultValue:{}},{comment:"文件规则",type:"jsonb",name:"rules",defaultValue:{}},{comment:"存储相对路径模板",type:"text",name:"path",defaultValue:"",trim:!0},{comment:"访问地址前缀",type:"string",name:"baseUrl",defaultValue:"",trim:!0},{comment:"重命名模式",type:"string",name:"renameMode",defaultValue:"appendRandomID"},{comment:"默认引擎",type:"radio",name:"default",defaultValue:!1},{type:"boolean",name:"paranoid",defaultValue:!1}]},j=function(e){return l().createElement(o.ExtendCollectionsProvider,{collections:[w,S]},l().createElement(o.SchemaComponentOptions,{scope:r,components:{UploadActionInitializer:O}},e.children))},P=p(721),E=[{value:1,label:"Byte"},{value:1024,label:"KB"},{value:1048576,label:"MB"},{value:0x40000000,label:"GB"}];function C(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1048576,n=e||t,r=E.length-1;r>=0;r--){var o=E[r];if(n%o.value==0)return o}return E[0]}function A(e,t,n){return Math.min(Math.max(t,e),n)}function I(e){var t,n=e.value,r=e.defaultUnit,o=void 0===r?1048576:r,c=e.min,u=void 0===c?1:c,s=e.max,p=void 0===s?i:s,d=e.step,f=e.onChange,m=null!=(t=e.defaultValue)?t:0x1400000,y=C(m,o),b=m/y.value,g=C(null!=n?n:m,o),h=null==n?n:n/g.value,v=(0,a.useCallback)(function(e){null==f||f(A(null==e?e:e*g.value,u,p))},[g.value]),x=(0,a.useCallback)(function(e){null==f||f(A(h*e,u,p))},[h]);return l().createElement(P.Space.Compact,null,l().createElement(P.InputNumber,{value:h,onChange:v,defaultValue:"".concat(b),step:void 0===d?1:d}),l().createElement(P.Select,{options:E,value:g.value,onChange:x,className:"auto-width"}))}var F=p(482),T=p(875),k=p(467),R=p.n(k),D=p(238),M="file-manager",B={name:"storages",fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{t("Title")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Storage name", { ns: "'.concat(M,'" })}}'),descriptions:'{{t("Will be used for API", { ns: "'.concat(M,'" })}}'),type:"string","x-component":"Input"}},{type:"string",name:"type",interface:"select",uiSchema:{title:'{{t("Storage type", { ns: "'.concat(M,'" })}}'),type:"string","x-component":"Select",required:!0,enum:"{{ storageTypeOptions }}"}},{type:"string",name:"baseUrl",interface:"input",uiSchema:{title:'{{t("Base URL", { ns: "'.concat(M,'" })}}'),type:"string","x-component":"TextAreaWithGlobalScope",required:!0}},{type:"string",name:"path",interface:"input",uiSchema:{title:'{{t("Path", { ns: "'.concat(M,'" })}}'),type:"string","x-component":"TextAreaWithGlobalScope"}},{type:"boolean",name:"default",interface:"boolean",uiSchema:{type:"boolean","x-component":"Checkbox"}},{type:"boolean",name:"paranoid",interface:"boolean",uiSchema:{type:"boolean","x-component":"Checkbox"}}]},_={type:"object",properties:(e={},t=(0,T.uid)(),n={type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:B,resourceName:"storages",request:{resource:"storages",action:"list",params:{pageSize:50,sort:["id"],appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:B},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"CreateStorage","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},default:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{t("Default storage", { ns: "'.concat(M,'" })}}'),properties:{default:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Edit")}}',"x-component":"EditStorage","x-component-props":{type:"primary"}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:'{{t("Delete")}}',content:'{{t("Are you sure you want to delete it?")}}'},useAction:"{{cm.useDestroyAction}}"}}}}}}}}}},t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e)},U={title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":"{{ !createOnly }}",required:!0,default:'{{ useNewId("s_") }}',description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'},baseUrl:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t(\'Base URL for file access, could be your CDN base URL. For example: "https://cdn.nocobase.com".\', { ns: "'.concat(M,'" })}}')},path:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t(\'Relative path the file will be saved to. Left blank as root path. The leading and trailing slashes "/" will be ignored. For example: "user/avatar".\', { ns: "'.concat(M,'" })}}')},rules:{type:"object","x-component":"fieldset",properties:{size:{type:"number",title:'{{t("File size limit", { ns: "'.concat(M,'" })}}'),description:'{{t("Minimum from 1 byte.", { ns: "'.concat(M,'" })}}'),"x-decorator":"FormItem","x-component":"FileSizeField",required:!0,default:0x1400000},mimetype:{type:"string",title:'{{t("File type allowed (in MIME type format)", { ns: "'.concat(M,'" })}}'),description:'{{t(\'Multi-types seperated with comma, for example: "image/*", "image/png", "image/*, application/pdf" etc.\', { ns: "'.concat(M,'" })}}'),"x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"*"}}}},default:{"x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Default storage", { ns: "'.concat(M,'" })}}')},paranoid:{"x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Keep file in storage when destroy the file record", { ns: "'.concat(M,'" })}}'),description:'{{t("Files are only removed when their corresponding records in the file collection are deleted. If a record from another collection includes an associating field referencing the file collection, the file will not be deleted unless cascade deletion is enabled for that association.", { ns: "'.concat(M,'" })}}')},renameMode:{title:'{{t("Renaming", { ns: "'.concat(M,'" })}}'),description:'{{t("Renaming strategy to avoid filename conflicts when uploading files.", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:'{{t("Append random ID", { ns: "'.concat(M,'" })}}'),value:"appendRandomID"},{label:'{{t("Random string", { ns: "'.concat(M,'" })}}'),value:"random"},{label:'{{t("Keep original filename (will be overwrite if filename is existed)", { ns: "'.concat(M,'" })}}'),value:"none"}],default:"appendRandomID"}},q={title:'{{t("Aliyun OSS", { ns: "'.concat(M,'" })}}'),name:"ali-oss",fieldset:{title:U.title,name:U.name,baseUrl:U.baseUrl,options:{type:"object","x-component":"fieldset",properties:{region:{title:'{{t("Region", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",description:'{{t(\'Aliyun OSS region part of the bucket. For example: "oss-cn-beijing".\', { ns: "'.concat(M,'" })}}'),required:!0},accessKeyId:{title:'{{t("AccessKey ID", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},accessKeySecret:{title:'{{t("AccessKey Secret", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},bucket:{title:'{{t("Bucket", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},timeout:{title:'{{t("Timeout", { ns: "'.concat(M,'" })}}'),description:"{{t('Upload timeout for a single file in milliseconds. Default is 600000.', { ns: \"".concat(M,'" })}}'),type:"number","x-decorator":"FormItem","x-component":"InputNumber",default:6e5},thumbnailRule:{title:'{{t("File pre-process parameters", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{placeholder:"?x-oss-process=image/auto-orient,1/resize,m_fill,w_94,h_94/quality,q_90"},description:'{{ renderThumbnailRuleDesc("ali-oss") }}'}}},path:U.path,renameMode:U.renameMode,rules:U.rules,default:U.default,paranoid:U.paranoid},thumbnailRuleLink:"https://help.aliyun.com/zh/oss/user-guide/resize-images-4"},z={local:{title:'{{t("Local storage", { ns: "'.concat(M,'" })}}'),name:"local",fieldset:{title:U.title,name:U.name,baseUrl:{"x-component":"CollectionField","x-decorator":"FormItem","x-display":"hidden",default:"/storage/uploads"},options:{type:"object","x-component":"div",properties:{documentRoot:{title:'{{t("Destination", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"Input","x-display":"hidden",default:"storage/uploads"}}},path:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{addonBefore:"storage/uploads/"}},renameMode:U.renameMode,rules:U.rules,default:U.default,paranoid:U.paranoid}},"ali-oss":q,s3:{title:'{{t("Amazon S3", { ns: "'.concat(M,'" })}}'),name:"s3",fieldset:{title:U.title,name:U.name,baseUrl:U.baseUrl,options:{type:"object","x-component":"fieldset",properties:{region:{title:'{{t("Region", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},accessKeyId:{title:'{{t("AccessKey ID", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},secretAccessKey:{title:'{{t("AccessKey Secret", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},bucket:{title:'{{t("Bucket", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},endpoint:{title:'{{t("Endpoint", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope"}}},path:U.path,renameMode:U.renameMode,rules:U.rules,default:U.default,paranoid:U.paranoid}},"tx-cos":{title:'{{t("Tencent COS", { ns: "'.concat(M,'" })}}'),name:"tx-cos",fieldset:{title:U.title,name:U.name,baseUrl:U.baseUrl,options:{type:"object","x-component":"fieldset",properties:{Region:{title:'{{t("Region", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},SecretId:{title:'{{t("SecretId", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},SecretKey:{title:'{{t("SecretKey", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},Bucket:{title:'{{t("Bucket", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},thumbnailRule:{title:"Thumbnail rule",type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{placeholder:"?imageMogr2/thumbnail/!50p"},description:'{{ renderThumbnailRuleDesc("tx-cos") }}'}}},path:U.path,renameMode:U.renameMode,rules:U.rules,default:U.default,paranoid:U.paranoid},thumbnailRuleLink:"https://cloud.tencent.com/document/product/436/42214"}};function N(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 K(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function L(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){K(e,t,n[t])})}return e}function G(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function V(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=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)||$(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 W(e){return function(e){if(Array.isArray(e))return N(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||$(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(e,t){if(e){if("string"==typeof e)return N(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 N(e,t)}}var Y=function(){var e=V((0,a.useState)({}),2),t=e[0],n=e[1],r=(0,o.usePlugin)(eQ),i=(0,o.useCompile)(),c=V((0,a.useState)(!1),2),u=c[0],s=c[1],p=(0,D.useTranslation)().t;return l().createElement("div",null,l().createElement(o.ActionContext.Provider,{value:{visible:u,setVisible:s}},l().createElement(P.Dropdown,{menu:{onClick:function(e){var t=r.storageTypes.get(e.key);s(!0),n({type:"object",properties:K({},(0,T.uid)(),{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{type:t.name}},title:i("{{t('Add new')}}")+" - "+i(t.title),properties:G(L({},R().cloneDeep(t.fieldset)),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}})})})},items:W(r.storageTypes.values()).map(function(e){return{key:e.name,label:i(e.title)}})}},l().createElement(P.Button,{type:"primary",icon:l().createElement(F.PlusOutlined,null)},p("Add new")," ",l().createElement(F.DownOutlined,null))),l().createElement(o.SchemaComponent,{scope:{createOnly:!0},schema:t})))},Z=function(){var e=(0,o.useRecord)(),t=V((0,a.useState)({}),2),n=t[0],r=t[1],i=(0,o.usePlugin)(eQ),c=(0,o.useCompile)(),u=V((0,a.useState)(!1),2),s=u[0],p=u[1],d=(0,D.useTranslation)().t,f=V(P.message.useMessage(),2),m=f[0],y=f[1],b=(0,a.useCallback)(function(){var t=i.storageTypes.get(e.type);if(!t)return void m.error(d("Storage type {{type}} is not registered, please check if related plugin is enabled.",{ns:M,type:e.type}));p(!0),t.fieldset.default&&(t.fieldset.default["x-reactions"]=function(e){e.initialValue?e.disabled=!0:e.disabled=!1}),r({type:"object",properties:K({},(0,T.uid)(),{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:L({},e)},title:c("{{t('Edit')}}")+" - "+c(t.title),properties:G(L({},R().cloneDeep(t.fieldset)),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}})})})},[c,i.storageTypes,e]);return l().createElement("div",null,y,l().createElement(o.ActionContext.Provider,{value:{visible:s,setVisible:p}},l().createElement("a",{onClick:b},d("Edit")),l().createElement(o.SchemaComponent,{scope:{createOnly:!1},schema:n})))};function H(e){var t=z[e];return(null==t?void 0:t.thumbnailRule)?l().createElement("div",null,l().createElement("a",{target:"_blank",href:t.thumbnailRuleLink,rel:"noreferrer"},o.i18n.t("See more"))):null}var X=function(){var e=(0,o.useCompile)(),t=W((0,o.usePlugin)(eQ).storageTypes.values()).map(function(t){return{value:t.name,label:e(t.title)}});return l().createElement(P.Card,{bordered:!1},l().createElement(o.SchemaComponent,{components:{CreateStorage:Y,EditStorage:Z},scope:{useNewId:function(e){return"".concat(e).concat((0,T.uid)())},storageTypeOptions:t,renderThumbnailRuleDesc:H},schema:_}))};function J(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Q(e){return(Q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ee(e,t){return(ee=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function et(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(et=function(){return!!e})()}var en=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,i,a;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=Q(t),J(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=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,et()?Reflect.construct(t,r||[],Q(this).constructor):t.apply(this,r)),"name","attachment"),J(e,"type","object"),J(e,"group","media"),J(e,"title",'{{t("Attachment", { ns: "'.concat(M,'" })}}')),J(e,"isAssociation",!0),J(e,"default",{type:"belongsToMany",target:"attachments",uiSchema:{type:"array","x-component":"Upload.Attachment","x-use-component-props":"useAttachmentFieldProps"}}),J(e,"availableTypes",["belongsToMany"]),J(e,"properties",(i=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){J(e,t,n[t])})}return e}({},o.interfacesProperties.defaultProps),a=a={"uiSchema.x-component-props.accept":{type:"string",title:'{{t("MIME type", { ns: "'.concat(M,'" })}}'),"x-component":"Input","x-component-props":{placeholder:"image/*"},"x-decorator":"FormItem",description:"Example: image/png"},"uiSchema.x-component-props.multiple":{type:"boolean","x-content":"{{t('Allow uploading multiple files', { ns: \"".concat(M,'" })}}'),"x-decorator":"FormItem","x-component":"Checkbox",default:!0},storage:{type:"string",title:'{{t("Storage", { ns: "'.concat(M,'" })}}'),description:"{{t('Default storage will be used when not selected', { ns: \"".concat(M,'" })}}'),"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{service:{resource:"storages",params:{}},manual:!1,fieldNames:{label:"title",value:"name"}}}},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(a)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(a)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))}),i)),J(e,"filterable",{children:[{name:"id",value:"id",title:'{{t("Exists")}}',label:'{{t("Exists")}}',operators:[{label:'{{t("exists")}}',value:"$exists",noValue:!0},{label:'{{t("not exists")}}',value:"$notExists",noValue:!0}],schema:{title:'{{t("Exists")}}',type:"string","x-component":"Input"}},{name:"filename",value:"filename",title:'{{t("Filename", { ns: "'.concat(M,'" })}}'),label:'{{t("Filename", { ns: "'.concat(M,'" })}}'),operators:o.interfacesProperties.operators.string,schema:{title:'{{t("Filename", { ns: "'.concat(M,'" })}}'),type:"string","x-component":"Input"}}]}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&ee(n,e),t=[{key:"schemaInitialize",value:function(e,t){var n=t.block;t.field,e["x-component-props"]||(e["x-component-props"]={}),["Table","Kanban"].includes(n)&&(e["x-component-props"].size="small"),e["x-use-component-props"]="useAttachmentFieldProps"}},{key:"initialize",value:function(e){e.through||(e.through="t_".concat((0,T.uid)())),e.foreignKey||(e.foreignKey="f_".concat((0,T.uid)())),e.otherKey||(e.otherKey="f_".concat((0,T.uid)())),e.sourceKey||(e.sourceKey="id"),e.targetKey||(e.targetKey="id")}}],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}(o.CollectionFieldInterface),er=p(667);function eo(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 ei(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ea(e){return(ea=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function el(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function ec(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){ei(e,t,n[t])})}return e}function eu(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function es(e,t){return(es=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ep(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function ed(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ed=function(){return!!e})()}function ef(){var e,t,n=(e=["\n .ant-image-img {\n border: 1px solid #d9d9d9;\n padding: 2px;\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return ef=function(){return n},n}var em=function(e){var t,n,r=e.file,i=e.size,a=e.showFileName,c="string"==typeof r?r:(null==r?void 0:r.preview)||(null==r?void 0:r.url);if(c){var u="string"==typeof r?c.split("/").pop():(null==r?void 0:r.name)||(null==r?void 0:r.filename)||(null==r||null==(t=r.url)?void 0:t.split("/").pop());null==(n=c.split(".").pop())||n.toLowerCase();var s={pdf:"/file-placeholder/pdf-200-200.png",mp4:"/file-placeholder/video-200-200.png",mov:"/file-placeholder/video-200-200.png",doc:"/file-placeholder/docx-200-200.png",docx:"/file-placeholder/docx-200-200.png",word:"/file-placeholder/docx-200-200.png",xls:"/file-placeholder/xlsx-200-200.png",xlsx:"/file-placeholder/xlsx-200-200.png",excel:"/file-placeholder/xlsx-200-200.png",ppt:"/file-placeholder/ppt-200-200.png",pptx:"/file-placeholder/ppt-200-200.png",jpg:"/file-placeholder/image-200-200.png",jpeg:"/file-placeholder/image-200-200.png",png:"/file-placeholder/image-200-200.png",gif:"/file-placeholder/image-200-200.png",default:"/file-placeholder/unknown-200-200.png"},p=s[function(e){var t="",n="",r=function(e){var t=e.split("?")[0].split("#")[0],n=t.lastIndexOf(".");return -1!==n?t.slice(n).toLowerCase():""};if("string"==typeof e?n=r(e):e&&(void 0===e?"undefined":ep(e))==="object"&&(t=e.mimetype||"",(n=(e.extname||"").toLowerCase())||!e.url||(n=r(e.url))),t){if(t.startsWith("image/"))return"image";if(t.startsWith("video/"))return"video";if(t.startsWith("audio/"))return"audio";if("application/pdf"===t)return"pdf";if(t.includes("spreadsheet"))return"excel";if(t.includes("word"))return"word";if(t.includes("presentation"))return"ppt"}return[".png",".jpg",".jpeg",".webp",".gif",".bmp"].includes(n)?"image":[".mp4",".avi",".mov",".wmv",".flv",".mkv"].includes(n)?"video":[".mp3",".wav",".aac",".ogg"].includes(n)?"audio":[".pdf"].includes(n)?"pdf":[".xls",".xlsx",".csv"].includes(n)?"excel":[".doc",".docx"].includes(n)?"word":[".ppt",".pptx"].includes(n)?"ppt":n?"file":"unknown"}(r)]||s.default,d=l().createElement("div",{className:(0,o.css)(ef())},l().createElement(P.Image,{src:c,fallback:p,width:i,height:i,preview:{mask:l().createElement(F.EyeOutlined,null)},style:{borderRadius:4,objectFit:"cover",boxShadow:"0 0 0 2px #fff"}}));return l().createElement("div",{style:{textAlign:"center",width:i,wordBreak:"break-all"}},d,a&&l().createElement(P.Tooltip,{title:u},l().createElement("div",{style:{fontSize:12,marginTop:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%"}},u)))}},ey=function(e){var t,n=e.value,r=void 0===n?[]:n,i=e.size,a=void 0===i?28:i,c=e.showFileName,u=(t=l().useState(0),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,o=null==e?null:"undefined"!=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),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}}(t,2)||function(e,t){if(e){if("string"==typeof e)return eo(e,2);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 eo(e,t)}}(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),s=u[0],p=u[1],d=(0,D.useTranslation)().t,f=function(e){var t,n=r[s].url||r[s],o=n.split("?")[0].split("#")[0],i=o?o.substring(o.lastIndexOf("/")+1):n,a=i.slice(i.lastIndexOf(".")),l="".concat(Date.now(),"_").concat(null==(t=r[s])?void 0:t.filename).concat(a);fetch(n).then(function(e){return e.blob()}).then(function(e){var t=URL.createObjectURL(new Blob([e])),n=document.createElement("a");n.href=t,n.download=l,document.body.appendChild(n),n.click(),URL.revokeObjectURL(t),n.remove()})};return l().createElement(P.Image.PreviewGroup,{preview:{toolbarRender:function(e,t){var n=t.transform.scale,o=t.actions,i=o.onActive,a=o.onFlipY,c=o.onFlipX,u=o.onRotateLeft,p=o.onRotateRight,d=o.onZoomOut,m=o.onZoomIn,y=o.onReset;return l().createElement(P.Space,{size:14,className:"toolbar-wrapper",style:{fontSize:"20px"}},l().createElement(F.LeftOutlined,{disabled:0===s,onClick:function(){return null==i?void 0:i(-1)}}),l().createElement(F.RightOutlined,{disabled:s===r.length-1,onClick:function(){return null==i?void 0:i(1)}}),l().createElement(F.DownloadOutlined,{onClick:f}),l().createElement(F.SwapOutlined,{rotate:90,onClick:a}),l().createElement(F.SwapOutlined,{onClick:c}),l().createElement(F.RotateLeftOutlined,{onClick:u}),l().createElement(F.RotateRightOutlined,{onClick:p}),l().createElement(F.ZoomOutOutlined,{disabled:1===n,onClick:d}),l().createElement(F.ZoomInOutlined,{disabled:50===n,onClick:m}),l().createElement(F.UndoOutlined,{onClick:y}))},onChange:function(e){p(e)},imageRender:function(e,t){p(t.current);var n=t.image;if((0,o.matchMimetype)(n,"application/pdf"))return l().createElement("iframe",{src:n.url||n.preview,width:"100%",height:"600px",style:{border:"none"}});if((0,o.matchMimetype)(n,"audio/*"))return l().createElement("audio",{controls:!0},l().createElement("source",{src:n.url||n.preview,type:n.type}),d("Your browser does not support the audio tag."));if((0,o.matchMimetype)(n,"video/*"))return l().createElement("video",{controls:!0,width:"100%"},l().createElement("source",{src:n.url||n.preview,type:n.type}),d("Your browser does not support the video tag."));if((0,o.matchMimetype)(n,"text/plain"))return l().createElement("iframe",{src:n.url||n.preview,width:"100%",height:"600px",style:{border:"none"}});if((0,o.matchMimetype)(n,"image/*"))return e;else return l().createElement(P.Alert,{type:"warning",description:l().createElement("span",null,d("File type is not supported for previewing,"),l().createElement("a",{onClick:f,style:{textDecoration:"underline",cursor:"pointer"}},d("download it to preview"))),showIcon:!0})}}},l().createElement(P.Space,{size:5,wrap:!0},Array.isArray(r)&&r.map(function(e,t){return l().createElement(em,{file:e,size:a,key:t,showFileName:c})})))},eb=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=ea(t),ei(e=function(e,t){if(t&&("object"===ep(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,ed()?Reflect.construct(t,r||[],ea(this).constructor):t.apply(this,r)),"disableTitleField",!0),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&es(n,e),t=[{key:"render",value:function(){var e=this,t=this.props,n=t.value,r=t.titleField,o=t.template,i=t.target;return r&&"file"!==o&&"attachments"!==i?(0,k.castArray)(n).flatMap(function(t,n){var o=null==t?void 0:t[r],i=o?l().createElement(ey,eu(ec({key:n},e.props),{value:(0,k.castArray)(o).filter(Boolean)})):l().createElement("span",{key:n},"N/A");return 0===n?[i]:[l().createElement("span",{key:"sep-".concat(n)},", "),i]}):l().createElement(ey,eu(ec({},this.props),{value:(0,k.castArray)(n).filter(Boolean)}))}}],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}(o.FieldModel);eb.registerFlow({key:"previewReadPrettySetting",sort:500,title:(0,er.tExpr)("Preview Settings"),steps:{size:{title:(0,er.tExpr)("Size"),uiMode:function(e){var t=e.t;return{type:"select",key:"size",props:{options:[{value:300,label:t("Large")},{value:100,label:t("Middle")},{value:28,label:t("Small")}]}}},hideInSettings:function(e){return el(e.model.parent,o.TableColumnModel)},defaultParams:function(e){return{size:el(e.model.parent,o.DetailsItemModel)?100:28}},handler:function(e,t){e.model.setProps("size",t.size)}},showFileName:{title:(0,er.tExpr)("Show file name"),uiMode:{type:"switch",key:"showFileName"},hideInSettings:function(e){return el(e.model.parent,o.TableColumnModel)},defaultParams:{showFileName:!1},handler:function(e,t){e.model.setProps("showFileName",t.showFileName)}}}}),eb.define({label:(0,er.tExpr)("Preview")}),er.DisplayItemModel.bindModelToInterface("DisplayPreviewFieldModel",["url","attachment","attachmentURL","m2m","m2o","o2o","o2m","oho","obo","mbm"],{isDefault:!0,when:function(e,t){return!t.targetCollection||"file"===t.targetCollection.template}});let eg="bits",eh="bytes",ev="jedec",ex={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};var eO=p(371),ew=p.n(eO);function eS(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 ej(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eP(e,t,n){return(eP="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=eE(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n||e):o.value}})(e,t,n||e)}function eE(e){return(eE=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eC(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){ej(e,t,n[t])})}return e}function eA(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eI(e,t){return(eI=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eF(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=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 eS(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 eS(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(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eT=function(){return!!e})()}var ek=function(e){var t,n,r=(0,er.useFlowContext)(),i=(0,a.useMemo)(function(){var t="".concat(e.context.collection.name,":create");if(null==(o=r.view)||null==(n=o.inputArgs)?void 0:n.sourceId){var n,o,i,a=eF(e.context.blockModel.association.resourceName.split("."),2),l=a[0],c=a[1];t="".concat(l,"/").concat(null==(i=r.view)?void 0:i.inputArgs.sourceId,"/").concat(c,":create")}return t},[e.context.collection.name,null==(n=r.view)||null==(t=n.inputArgs)?void 0:t.sourceId]),l={},c=0,u={action:i,onChange:function(t){var n=t.fileList;n.forEach(function(t){if("uploading"!==t.status||l[t.uid]||(c++,l[t.uid]=!0),"uploading"!==t.status&&l[t.uid]&&(delete l[t.uid],0==--c)){var n,r;null==(n=(r=e.context.blockModel.resource).refresh)||n.call(r)}}),n.every(function(e){return"done"===e.status})&&r.view.close()}},s=function(e,t){var n,r,i,l,c,u,s,p,d,f,m,y,b,g,h,v=(i=(r=(0,er.useFlowContext)()).collectionField,l=null==(n=r.collectionField)?void 0:n.targetCollection,c=(0,o.usePlugin)(eQ),u=t.context.blockModel.collection,p=null!=(s=(null==i?void 0:i.storage)||u.storage||l.storage)?s:"",d="storages:getBasicInfo/".concat(p),m=(f=(0,o.useRequest)({url:d},{manual:!0,refreshDeps:[p],cacheKey:d})).loading,y=f.data,b=f.run,(0,a.useEffect)(function(){b()},[b]),g=!m&&(null==y?void 0:y.data)||null,h=c.getStorageType(null==g?void 0:g.type),{storage:g,storageType:h}),x=v.storage,O=v.storageType,w=null==O?void 0:O.useUploadProps,S=(null==w?void 0:w(eC({storage:x,rules:x.rules},e)))||{};return eC({rules:null==x?void 0:x.rules},S)}(u,e);return eC({},u,s)},eR={size:function(e,t){var n=null!=t?t:0x1400000;return 0===n||e.size<=n?null:"File size exceeds the limit"},mimetype:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*",n=t.toString().trim();return n&&"*"!==n?n.split(",").filter(Boolean).some(ew()(e.type))?null:"File type is not allowed":null}};function eD(e){var t,n,r,o,i,c,u,s=e.model,p=(0,er.useFlowContext)(),d=ek(s),f=d.rules,m=null!=f?f:{},y=m.size;m.mimetype;var b=(t=null!=y?y:0x1400000,r=(n=(0,D.useTranslation)()).t,o=function(e,{bits:t=!1,pad:n=!1,base:r=-1,round:o=2,locale:i="",localeOptions:a={},separator:l="",spacer:c=" ",symbols:u={},standard:s="",output:p="string",fullform:d=!1,fullforms:f=[],exponent:m=-1,roundingMethod:y="round",precision:b=0}={}){let g=m,h=Number(e),v=[],x=0,O="";"si"===s?(r=10,s=ev):"iec"===s||s===ev?r=2:2===r?s="iec":(r=10,s=ev);let w=10===r?1e3:1024,S=h<0,j=Math[y];if("bigint"!=typeof e&&isNaN(e))throw TypeError("Invalid number");if("function"!=typeof j)throw TypeError("Invalid rounding method");if(S&&(h=-h),(-1===g||isNaN(g))&&(g=Math.floor(Math.log(h)/Math.log(w)))<0&&(g=0),g>8&&(b>0&&(b+=8-g),g=8),"exponent"===p)return g;if(0===h)v[0]=0,O=v[1]=ex.symbol[s][t?eg:eh][g];else{x=h/(2===r?Math.pow(2,10*g):Math.pow(1e3,g)),t&&(x*=8)>=w&&g<8&&(x/=w,g++);let e=Math.pow(10,g>0?o:0);v[0]=j(x*e)/e,v[0]===w&&g<8&&-1===m&&(v[0]=1,g++),O=v[1]=10===r&&1===g?t?"kbit":"kB":ex.symbol[s][t?eg:eh][g]}if(S&&(v[0]=-v[0]),b>0&&(v[0]=v[0].toPrecision(b)),v[1]=u[v[1]]||v[1],!0===i?v[0]=v[0].toLocaleString():i.length>0?v[0]=v[0].toLocaleString(i,a):l.length>0&&(v[0]=v[0].toString().replace(".",l)),n&&o>0){let e=v[0].toString(),t=l||(e.match(/(\D)/g)||[]).pop()||".",n=e.toString().split(t),r=n[1]||"",i=r.length;v[0]=`${n[0]}${t}${r.padEnd(i+(o-i),"0")}`}return!0===d&&(v[1]=f[g]?f[g]:ex.fullform[s][g]+(t?"bit":"byte")+(1===v[0]?"":"s")),"array"===p?v:"object"===p?{value:v[0],symbol:v[1],exponent:g,unit:O}:v.join(c)}(t,{base:2,standard:"jedec",locale:n.i18n.language}),0!==t?r("File size should not exceed {{size}}.",{size:o}):""),g=eF((0,a.useState)(!1),2),h=g[0],v=g[1],x=(0,a.useCallback)(function(e){e.fileList.some(function(e){return"uploading"===e.status})?v(!0):v(!1)},[]),O=p.view.Header,w=(i=(0,D.useTranslation)().t,(0,a.useCallback)(function(e,t){var n=function(e,t){if(!t)return null;var n=Object.keys(t);if(!n.length)return null;var r=!0,o=!1,i=void 0;try{for(var a,l=n[Symbol.iterator]();!(r=(a=l.next()).done);r=!0){var c=a.value,u=eR[c](e,t[c]);if(u)return u}}catch(e){o=!0,i=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw i}}return null}(e,f);return n?(e.status="error",e.response=i(n)):"error"===e.status&&(delete e.status,delete e.response),!n&&Promise.resolve(e)},[f]));return l().createElement("div",null,l().createElement(O,{title:p.t("Upload file")}),l().createElement("div",{style:{height:"50vh"},onClick:function(e){return e.stopPropagation()}},l().createElement(P.Upload.Dragger,eC({multiple:!0,listType:"picture"},(c=eA(eC({},d),{handleChange:x,beforeUpload:w}),u=(0,er.useFlowContext)(),eC({customRequest:function(e){var t=e.action,n=e.data,r=e.file,o=e.filename,i=e.headers,a=e.onError,l=e.onProgress,c=e.onSuccess,s=e.withCredentials,p=new FormData;return n&&Object.keys(n).forEach(function(e){p.append(e,n[e])}),p.append(o,r),u.api.axios.post(t,p,{withCredentials:s,headers:i,onUploadProgress:function(e){var t=e.total;l({percent:Math.round(e.loaded/t*100).toFixed(2)},r)}}).then(function(e){c(e.data,r)}).catch(a).finally(function(){}),{abort:function(){console.log("upload progress is aborted.")}}}},c))),l().createElement("p",{className:"ant-upload-drag-icon"},h?l().createElement(F.LoadingOutlined,{style:{fontSize:36},spin:!0}):l().createElement(F.InboxOutlined,null)),l().createElement("p",{className:"ant-upload-text"},p.t("Click or drag file to this area to upload")),l().createElement("ul",{style:{listStyleType:"none"}},l().createElement("li",{className:"ant-upload-hint"},p.t("Support for a single or bulk upload.")),l().createElement("li",{className:"ant-upload-hint"},b)))))}var eM=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=eE(t),ej(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=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,eT()?Reflect.construct(t,r||[],eE(this).constructor):t.apply(this,r)),"defaultProps",{type:"primary",title:(0,er.escapeT)("Upload"),icon:"UploadOutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&eI(n,e),t=[{key:"getAclActionName",value:function(){return"create"}},{key:"onInit",value:function(e){var t=this;eP(eE(n.prototype),"onInit",this).call(this,e),this.onUploadClick=function(e){t.dispatchEvent("openView",{event:e})}}},{key:"onUploadClick",set:function(e){this.setProps({onUploadClick:e})}},{key:"render",value:function(){var e=this.props,t=e.icon?l().createElement(o.Icon,{type:e.icon}):void 0;return l().createElement(P.Button,eA(eC({},e),{onClick:this.props.onUploadClick,icon:t}),e.children||e.title)}}],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}(o.ActionModel);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 e_(e){return(e_=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eU(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}function eq(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function ez(e,t){return(ez=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eN(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eN=function(){return!!e})()}ej(eM,"scene",o.ActionSceneEnum.collection),eM.define({label:(0,er.escapeT)("Upload"),hide:function(e){var t;return(null==(t=e.collection)?void 0:t.template)!=="file"}}),eM.registerFlow({key:"selectExitRecordSettings",title:(0,er.escapeT)("Selector setting"),on:{eventName:"openView"},steps:{openView:{title:(0,er.escapeT)("Edit popup"),uiSchema:function(e){return{mode:{type:"string",title:(0,er.escapeT)("Open mode"),enum:[{label:(0,er.escapeT)("Drawer"),value:"drawer"},{label:(0,er.escapeT)("Dialog"),value:"dialog"}],"x-decorator":"FormItem","x-component":"Radio.Group"},size:{type:"string",title:(0,er.escapeT)("Popup size"),enum:[{label:(0,er.escapeT)("Small"),value:"small"},{label:(0,er.escapeT)("Medium"),value:"medium"},{label:(0,er.escapeT)("Large"),value:"large"}],"x-decorator":"FormItem","x-component":"Radio.Group"}}},defaultParams:{mode:"drawer",size:"medium"},handler:function(e,t){var n,r=e.inputArgs.mode||t.mode||"drawer",o=e.inputArgs.size||t.size||"medium";e.viewer.open({type:r,width:{drawer:{small:"30%",medium:"50%",large:"70%"},dialog:{small:"40%",medium:"50%",large:"80%"},embed:{}}[r][o],inheritContext:!1,target:e.layoutContentElement,inputArgs:{sourceId:null==(n=e.resource)?void 0:n.getSourceId()},content:function(){return l().createElement(eD,{model:e.model})},styles:{content:eC({padding:0,backgroundColor:e.model.flowEngine.context.themeToken.colorBgLayout},"embed"===r?{position:"absolute",top:0,left:0,right:0,bottom:0}:{})}})}}}});var eK=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(){var e,n,r;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");return n=t,r=arguments,n=e_(n),eB(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=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,eN()?Reflect.construct(n,r||[],e_(this).constructor):n.apply(this,r)),"name","file"),eB(e,"title",'{{t("File collection", { ns: "'.concat(M,'" })}}')),eB(e,"order",3),eB(e,"color","blue"),eB(e,"default",{createdBy:!0,updatedBy:!0,fields:[{interface:"input",type:"string",name:"title",deletable:!1,uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"input",type:"string",name:"filename",deletable:!1,uiSchema:{type:"string",title:'{{t("File name", { ns: "'.concat(M,'" })}}'),"x-component":"Input","x-read-pretty":!0}},{interface:"input",type:"string",name:"extname",deletable:!1,uiSchema:{type:"string",title:'{{t("Extension name", { ns: "'.concat(M,'" })}}'),"x-component":"Input","x-read-pretty":!0}},{interface:"integer",type:"integer",name:"size",deletable:!1,uiSchema:{type:"number",title:'{{t("Size", { ns: "'.concat(M,'" })}}'),"x-component":"InputNumber","x-read-pretty":!0,"x-component-props":{stringMode:!0,step:"0"}}},{interface:"input",type:"string",name:"mimetype",deletable:!1,uiSchema:{type:"string",title:'{{t("MIME type", { ns: "'.concat(M,'" })}}'),"x-component":"Input","x-read-pretty":!0}},{interface:"input",type:"text",name:"path",deletable:!1,uiSchema:{type:"string",title:'{{t("Path", { ns: "'.concat(M,'" })}}'),"x-component":"TextAreaWithGlobalScope","x-read-pretty":!0}},{interface:"url",type:"text",name:"url",deletable:!1,uiSchema:{type:"string",title:'{{t("URL")}}',"x-component":"Input.URL","x-read-pretty":!0}},{interface:"url",type:"text",name:"preview",field:"url",deletable:!1,uiSchema:{type:"string",title:'{{t("Preview", { ns: "'.concat(M,'" })}}'),"x-component":"Preview","x-read-pretty":!0}},{type:"belongsTo",name:"storage",target:"storages",foreignKey:"storageId",deletable:!1,interface:"m2o",uiSchema:{type:"object",title:'{{t("Storage", { ns: "'.concat(M,'" })}}'),"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"title"}},"x-read-pretty":!0}},{type:"jsonb",name:"meta",deletable:!1,defaultValue:{}}]}),eB(e,"presetFieldsDisabled",!0),eB(e,"events",{filterPrimaryKeyCandidate:function(e){return"input"!==e.name},initPrimaryKeyFiledInterface:function(e){e.autoFill&&(e.autoFill["x-disabled"]=!0),e.autoIncrement&&(e.autoIncrement["x-disabled"]=!0)}}),eB(e,"configurableProperties",eU(eq(eU(eq(eU({},(0,o.getConfigurableProperties)("title","name")),{inherits:eq(eU({},(0,o.getConfigurableProperties)("inherits").inherits),{"x-reactions":["{{useAsyncDataSource(loadCollections)}}"]})}),(0,o.getConfigurableProperties)("category","description")),{storage:{type:"string",name:"storage",title:'{{t("File storage", { ns: "'.concat(M,'" })}}'),"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{service:{resource:"storages",params:{}},manual:!1,fieldNames:{label:"title",value:"name"}}}}),(0,o.getConfigurableProperties)("presetFields"))),e}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ez(t,e),t}(o.CollectionTemplate);function eL(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){eL(i,r,o,a,l,"next",e)}function l(e){eL(i,r,o,a,l,"throw",e)}a(void 0)})}}function eV(e,t,n){return(eV=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&&eY(o,n.prototype),o}).apply(null,arguments)}function eW(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function e$(e){return(e$=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eY(e,t){return(eY=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eZ(e){var t="function"==typeof Map?new Map:void 0;return(eZ=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 eV(e,arguments,e$(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),eY(n,e)})(e)}function eH(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eH=function(){return!!e})()}function eX(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){var c=[i,l];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var eJ=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=e$(t),eW(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=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(t,r||[],e$(this).constructor):t.apply(this,r)),"storageTypes",new Map),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&eY(n,e),t=[{key:"load",value:function(){var e=this;return eG(function(){var t;return eX(this,function(n){return e.app.dataSourceManager.addFieldInterfaces([en]),e.app.dataSourceManager.addCollectionTemplates([eK]),e.app.use(j),e.app.pluginSettingsManager.add(M,{title:'{{t("File manager", { ns: "'.concat(M,'" })}}'),icon:"FileOutlined",Component:X,aclSnippet:"pm.file-manager.storages"}),Object.values(z).forEach(function(t){e.registerStorageType(t.name,t)}),null==(t=e.app.schemaInitializerManager.get("table:configureActions"))||t.add("enableActions.upload",{title:"{{t('Upload')}}",Component:"UploadActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible:function(){return"file"===(0,o.useCollection)().template}}),e.app.addScopes({useAttachmentFieldProps:v,useFileCollectionStorageRules:x,useStorageCfg:u}),e.app.addComponents({FileSizeField:I}),e.flowEngine.registerModels({DisplayPreviewFieldModel:eb,UploadActionModel:eM}),[2]})})()}},{key:"registerStorageType",value:function(e,t){this.storageTypes.set(e,t)}},{key:"getStorageType",value:function(e){return this.storageTypes.get(e)}},{key:"uploadFile",value:function(e){var t=this;return eG(function(){var n,r,o,i,a,l,c,u,s,p,d,f,m,y;return eX(this,function(b){switch(b.label){case 0:if(!(null==e?void 0:e.file))return[2,{errorMessage:"Missing file"}];if(n=e.file,r=e.storageType,o=e.storageId,i=e.storageRules,l=void 0===(a=e.query)?{}:a,c=(null==e?void 0:e.fileCollectionName)||"attachments",!(null==(u=t.getStorageType(r))?void 0:u.upload))return[3,2];return[4,u.upload({file:n,apiClient:t.app.apiClient,storageType:r,storageId:o,storageRules:i,fileCollectionName:c,query:l})];case 1:return[2,b.sent()];case 2:return b.trys.push([2,4,,5]),(p=new FormData).append("file",n),f=(d=new URLSearchParams(l).toString())?"".concat(c,":create?").concat(d):"".concat(c,":create"),[4,t.app.apiClient.request({url:f,method:"post",data:p})];case 3:return[2,{data:null==(s=b.sent().data)?void 0:s.data}];case 4:return[2,{errorMessage:null!=(y=null==(m=b.sent())?void 0:m.message)?y:"Upload failed"}];case 5:return[2]}})})()}}],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}(eZ(o.Plugin));eW(eJ,"buildInStorage",["local","ali-oss","s3","tx-cos"]);var eQ=eJ}(),d});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@formily/antd-v5"),require("react"),require("@nocobase/flow-engine"),require("@emotion/css"),require("lodash"),require("@formily/shared"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("antd"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-file-manager",["@formily/antd-v5","react","@nocobase/flow-engine","@emotion/css","lodash","@formily/shared","@nocobase/client","@formily/react","@ant-design/icons","antd","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-file-manager"]=t(require("@formily/antd-v5"),require("react"),require("@nocobase/flow-engine"),require("@emotion/css"),require("lodash"),require("@formily/shared"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("antd"),require("react-i18next")):e["@nocobase/plugin-file-manager"]=t(e["@formily/antd-v5"],e.react,e["@nocobase/flow-engine"],e["@emotion/css"],e.lodash,e["@formily/shared"],e["@nocobase/client"],e["@formily/react"],e["@ant-design/icons"],e.antd,e["react-i18next"])}(self,function(e,t,n,o,r,i,l,a,c,u,s){var p={371:function(e,t,n){var o=n(275),r=/[\/\+\.]/;e.exports=function(e,t){function n(t){var n=o(t,e,r);return n&&n.length>=2}return t?n(t.split(";")[0]):n}},275:function(e){"use strict";function t(e,t){this.text=e=e||"",this.hasWild=~e.indexOf("*"),this.separator=t,this.parts=e.split(t)}t.prototype.match=function(e){var t,n,o=!0,r=this.parts,i=r.length;if("string"==typeof e||e instanceof String)if(this.hasWild||this.text==e){for(t=0,n=(e||"").split(this.separator);o&&t<i;t++)if("*"===r[t])continue;else o=t<n.length&&r[t]===n[t];o=o&&n}else o=!1;else if("function"==typeof e.splice)for(o=[],t=e.length;t--;)this.match(e[t])&&(o[o.length]=e[t]);else if("object"==typeof e)for(var l in o={},e)this.match(l)&&(o[l]=e[l]);return o},e.exports=function(e,n,o){var r=new t(e,o||/[\/\.]/);return void 0!==n?r.match(n):r}},482:function(e){"use strict";e.exports=c},964:function(e){"use strict";e.exports=o},632:function(t){"use strict";t.exports=e},505:function(e){"use strict";e.exports=a},875:function(e){"use strict";e.exports=i},772:function(e){"use strict";e.exports=l},667:function(e){"use strict";e.exports=n},721:function(e){"use strict";e.exports=u},467:function(e){"use strict";e.exports=r},156:function(e){"use strict";e.exports=t},238:function(e){"use strict";e.exports=s}},f={};function d(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return p[e](n,n.exports,d),n.exports}d.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return d.d(t,{a:t}),t},d.d=function(e,t){for(var n in t)d.o(t,n)&&!d.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},d.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},d.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var m={};return!function(){"use strict";d.r(m),d.d(m,{UploadFieldModel:function(){return eQ},default:function(){return tj},PluginFileManagerClient:function(){return tS},CardUpload:function(){return eH},filePreviewTypes:function(){return ei},wrapWithModalPreviewer:function(){return eh}});var e,t,n,o={};d.r(o),d.d(o,{useAttachmentFieldProps:function(){return v},useFileCollectionStorageRules:function(){return x},useStorageRules:function(){return h},useUploadFiles:function(){return b}});var r=d(772),i=Number.POSITIVE_INFINITY,l=d(156),a=d.n(l);function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}function u(){var e,t,n,o,i,a,c,u=(0,r.useCollectionField)(),s=(0,r.useCollectionManager)().getCollection(null==u?void 0:u.target),p=(0,r.useCollection)(),f=(0,r.usePlugin)(tj),d=(t=null!=(e=(null==u?void 0:u.storage)||(null==p?void 0:p.getOption("storage"))||(null==s?void 0:s.getOption("storage")))?e:"",n="storages:getBasicInfo/".concat(t),i=(o=(0,r.useRequest)({url:n},{manual:!0,refreshDeps:[t],cacheKey:n})).loading,a=o.data,c=o.run,(0,l.useEffect)(function(){c()},[c]),!i&&(null==a?void 0:a.data)||null),m=f.getStorageType(null==d?void 0:d.type);return{storage:d,storageType:m}}function s(e){var t=u(),n=t.storage,o=t.storageType,r=null==o?void 0:o.useUploadProps,i=(null==r?void 0:r(c({storage:n,rules:n.rules},e)))||{};return c({rules:null==n?void 0:n.rules},i)}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function f(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||y(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){if(e){if("string"==typeof e)return p(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 p(e,t)}}var b=function(){var e=(0,r.useDataBlockRequestGetter)().getDataBlockRequest,t=((0,r.useDataBlockProps)()||{}).association,n=(0,r.useActionContext)().setVisible,o=(0,r.useCollection)(),i=(0,r.useSourceId)(),a=(0,l.useMemo)(function(){var e="".concat(o.name,":create");if(t){var n,r=(n=t.split("."),function(e){if(Array.isArray(e))return e}(n)||function(e,t){var n,o,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i=[],l=!0,a=!1;try{for(r=r.call(e);!(l=(n=r.next()).done)&&(i.push(n.value),i.length!==t);l=!0);}catch(e){a=!0,o=e}finally{try{l||null==r.return||r.return()}finally{if(a)throw o}}return i}}(n,2)||y(n,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),l=r[0],a=r[1];e="".concat(l,"/").concat(i,"/").concat(a,":create")}return e},[o.name,t,i]),c=((0,l.useContext)(r.RecordPickerContext)||{}).setSelectedRows,u={},p=0,d={action:a,onChange:function(t){t.forEach(function(n){if("uploading"!==n.status||u[n.uid]||(p++,u[n.uid]=!0),"uploading"!==n.status&&u[n.uid]&&(delete u[n.uid],0==--p)){var o,r;null==(r=e())||null==(o=r.refresh)||o.call(r),null==c||c(function(e){return f(e).concat(f(t.filter(function(e){return"done"===e.status}).map(function(e){return e.response.data})))})}}),t.every(function(e){return"done"===e.status})&&n(!1)}},m=s(d);return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}({},d,m)},g=d(505);function h(e){var t,n=null!=e?e:"";(0,r.useAPIClient)();var o=(0,g.useField)(),i=(0,r.useRequest)({url:"storages:getBasicInfo/".concat(n)},{manual:!0,refreshDeps:[n],cacheKey:n}),a=i.loading,c=i.data,u=i.run;return(0,l.useEffect)(function(){"editable"===o.pattern&&u()},[o.pattern,u]),!a&&(null==c||null==(t=c.data)?void 0:t.rules)||null}function v(){var e=(0,r.useCollectionField)(),t="".concat(null==e?void 0:e.target,":create").concat((null==e?void 0:e.storage)?"?attachmentField=".concat(e.collectionName,".").concat(e.name):""),n=s({action:t});return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}({action:t},n)}function x(){var e=(0,r.useCollectionField)(),t=(0,r.useCollectionManager)().getCollection(null==e?void 0:e.target);return h(null==t?void 0:t.getOption("storage"))}var w=function(e){var t,n,o={type:"void","x-action":"create",title:"{{t('Upload')}}","x-designer":"Action.Designer","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",icon:"UploadOutlined"},properties:{drawer:{type:"void",title:'{{ t("Upload files") }}',"x-component":"Action.Container",properties:{upload:{type:"void",title:'{{ t("Upload files") }}',"x-component":"Upload.DraggerV2","x-use-component-props":"useUploadFiles","x-component-props":{height:"50vh",multiple:!0,listType:"picture"}}}}}};return a().createElement(r.ActionInitializerItem,(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}({},e),n=n={schema:o},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))},O={dumpRules:{group:"user"},migrationRules:["schema-only","overwrite"],asStrategyResource:!0,shared:!0,name:"attachments",createdBy:!0,updatedBy:!0,template:"file",filterTargetKey:"id",fields:[{comment:"用户文件名(不含扩展名)",type:"string",name:"title"},{comment:"系统文件名(含扩展名)",type:"string",name:"filename"},{comment:"扩展名(含“.”)",type:"string",name:"extname"},{comment:"文件体积(字节)",type:"integer",name:"size"},{type:"string",name:"mimetype"},{type:"belongsTo",name:"storage",target:"storages",foreignKey:"storageId",deletable:!1,interface:"m2o",uiSchema:{type:"object",title:"{{t('Storage', { ns: '".concat("file-manager","' })}}"),"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"title"}},"x-read-pretty":!0}},{comment:"相对路径(含“/”前缀)",type:"text",name:"path"},{comment:"其他文件信息(如图片的宽高)",type:"jsonb",name:"meta",defaultValue:{}},{comment:"网络访问地址",type:"text",name:"url"}]},S={dumpRules:"required",migrationRules:["overwrite","schema-only"],name:"storages",shared:!0,fields:[{name:"id",type:"snowflakeId",primaryKey:!0,allowNull:!1},{title:"存储引擎名称",comment:"存储引擎名称",type:"string",name:"title",translation:!0,trim:!0},{title:"英文标识",type:"uid",name:"name",unique:!0,trim:!0},{comment:"类型标识,如 local/ali-oss 等",type:"string",name:"type"},{comment:"配置项",type:"jsonb",name:"options",defaultValue:{}},{comment:"文件规则",type:"jsonb",name:"rules",defaultValue:{}},{comment:"存储相对路径模板",type:"text",name:"path",defaultValue:"",trim:!0},{comment:"访问地址前缀",type:"string",name:"baseUrl",defaultValue:"",trim:!0},{comment:"重命名模式",type:"string",name:"renameMode",defaultValue:"appendRandomID"},{comment:"默认引擎",type:"radio",name:"default",defaultValue:!1},{type:"boolean",name:"paranoid",defaultValue:!1},{type:"json",name:"settings",defaultValue:{}}]},j=function(e){return a().createElement(r.ExtendCollectionsProvider,{collections:[O,S]},a().createElement(r.SchemaComponentOptions,{scope:o,components:{UploadActionInitializer:w}},e.children))},P=d(721),E=[{value:1,label:"Byte"},{value:1024,label:"KB"},{value:1048576,label:"MB"},{value:0x40000000,label:"GB"}];function C(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1048576,n=e||t,o=E.length-1;o>=0;o--){var r=E[o];if(n%r.value==0)return r}return E[0]}function F(e,t,n){return Math.min(Math.max(t,e),n)}function k(e){var t,n=e.value,o=e.defaultUnit,r=void 0===o?1048576:o,c=e.min,u=void 0===c?1:c,s=e.max,p=void 0===s?i:s,f=e.step,d=e.onChange,m=null!=(t=e.defaultValue)?t:0x1400000,y=C(m,r),b=m/y.value,g=C(null!=n?n:m,r),h=null==n?n:n/g.value,v=(0,l.useCallback)(function(e){null==d||d(F(null==e?e:e*g.value,u,p))},[g.value]),x=(0,l.useCallback)(function(e){null==d||d(F(h*e,u,p))},[h]);return a().createElement(P.Space.Compact,null,a().createElement(P.InputNumber,{value:h,onChange:v,defaultValue:"".concat(b),step:void 0===f?1:f}),a().createElement(P.Select,{options:E,value:g.value,onChange:x,className:"auto-width"}))}var I=d(482),A=d(875),T=d(467),R=d.n(T),D=d(238),M="file-manager",U={name:"storages",fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{t("Title")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Storage name", { ns: "'.concat(M,'" })}}'),descriptions:'{{t("Will be used for API", { ns: "'.concat(M,'" })}}'),type:"string","x-component":"Input"}},{type:"string",name:"type",interface:"select",uiSchema:{title:'{{t("Storage type", { ns: "'.concat(M,'" })}}'),type:"string","x-component":"Select",required:!0,enum:"{{ storageTypeOptions }}"}},{type:"string",name:"baseUrl",interface:"input",uiSchema:{title:'{{t("Base URL", { ns: "'.concat(M,'" })}}'),type:"string","x-component":"TextAreaWithGlobalScope",required:!0}},{type:"string",name:"path",interface:"input",uiSchema:{title:'{{t("Path", { ns: "'.concat(M,'" })}}'),type:"string","x-component":"TextAreaWithGlobalScope"}},{type:"boolean",name:"default",interface:"boolean",uiSchema:{type:"boolean","x-component":"Checkbox"}},{type:"boolean",name:"paranoid",interface:"boolean",uiSchema:{type:"boolean","x-component":"Checkbox"}}]},B={type:"object",properties:(e={},t=(0,A.uid)(),n={type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:U,resourceName:"storages",request:{resource:"storages",action:"list",params:{pageSize:50,sort:["id"],appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:U},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"CreateStorage","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},default:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{t("Default storage", { ns: "'.concat(M,'" })}}'),properties:{default:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Edit")}}',"x-component":"EditStorage","x-component-props":{type:"primary"}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:'{{t("Delete")}}',content:'{{t("Are you sure you want to delete it?")}}'},useAction:"{{cm.useDestroyAction}}"}}}}}}}}}},t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e)},q={title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":"{{ !createOnly }}",required:!0,default:'{{ useNewId("s_") }}',description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'},baseUrl:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t(\'Base URL for file access, could be your CDN base URL. For example: "https://cdn.nocobase.com".\', { ns: "'.concat(M,'" })}}')},path:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t(\'Relative path the file will be saved to. Left blank as root path. The leading and trailing slashes "/" will be ignored. For example: "user/avatar".\', { ns: "'.concat(M,'" })}}')},rules:{type:"object","x-component":"fieldset",properties:{size:{type:"number",title:'{{t("File size limit", { ns: "'.concat(M,'" })}}'),description:'{{t("Minimum from 1 byte.", { ns: "'.concat(M,'" })}}'),"x-decorator":"FormItem","x-component":"FileSizeField",required:!0,default:0x1400000},mimetype:{type:"string",title:'{{t("File type allowed (in MIME type format)", { ns: "'.concat(M,'" })}}'),description:'{{t(\'Multi-types seperated with comma, for example: "image/*", "image/png", "image/*, application/pdf" etc.\', { ns: "'.concat(M,'" })}}'),"x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"*"}}}},default:{"x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Default storage", { ns: "'.concat(M,'" })}}')},paranoid:{"x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Keep file in storage when destroy the file record", { ns: "'.concat(M,'" })}}'),description:'{{t("Files are only removed when their corresponding records in the file collection are deleted. If a record from another collection includes an associating field referencing the file collection, the file will not be deleted unless cascade deletion is enabled for that association.", { ns: "'.concat(M,'" })}}')},renameMode:{title:'{{t("Renaming", { ns: "'.concat(M,'" })}}'),description:'{{t("Renaming strategy to avoid filename conflicts when uploading files.", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:'{{t("Append random ID", { ns: "'.concat(M,'" })}}'),value:"appendRandomID"},{label:'{{t("Random string", { ns: "'.concat(M,'" })}}'),value:"random"},{label:'{{t("Keep original filename (will be overwrite if filename is existed)", { ns: "'.concat(M,'" })}}'),value:"none"}],default:"appendRandomID"},settings:{type:"object",title:'{{t("Advanced Settings", { ns: "'.concat(M,'" })}}'),"x-component":"fieldset",properties:{requestOptions:{type:"object",title:'{{t("Request options", { ns: "'.concat(M,'" })}}'),description:'{{t("Additional options for HTTP requests when fetching files from remote storage on server side, such as headers.", { ns: "'.concat(M,'" })}}'),"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{autoSize:{minRows:5}}}}}},_={title:'{{t("Aliyun OSS", { ns: "'.concat(M,'" })}}'),name:"ali-oss",fieldset:{title:q.title,name:q.name,baseUrl:q.baseUrl,options:{type:"object","x-component":"fieldset",properties:{region:{title:'{{t("Region", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",description:'{{t(\'Aliyun OSS region part of the bucket. For example: "oss-cn-beijing".\', { ns: "'.concat(M,'" })}}'),required:!0},accessKeyId:{title:'{{t("AccessKey ID", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},accessKeySecret:{title:'{{t("AccessKey Secret", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},bucket:{title:'{{t("Bucket", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},timeout:{title:'{{t("Timeout", { ns: "'.concat(M,'" })}}'),description:"{{t('Upload timeout for a single file in milliseconds. Default is 600000.', { ns: \"".concat(M,'" })}}'),type:"number","x-decorator":"FormItem","x-component":"InputNumber",default:6e5},thumbnailRule:{title:'{{t("File pre-process parameters", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{placeholder:"?x-oss-process=image/auto-orient,1/resize,m_fill,w_94,h_94/quality,q_90"},description:'{{ renderThumbnailRuleDesc("ali-oss") }}'}}},path:q.path,renameMode:q.renameMode,rules:q.rules,default:q.default,paranoid:q.paranoid,settings:q.settings},thumbnailRuleLink:"https://help.aliyun.com/zh/oss/user-guide/resize-images-4"},z={local:{title:'{{t("Local storage", { ns: "'.concat(M,'" })}}'),name:"local",fieldset:{title:q.title,name:q.name,baseUrl:{"x-component":"CollectionField","x-decorator":"FormItem","x-display":"hidden",default:"/storage/uploads"},options:{type:"object","x-component":"div",properties:{documentRoot:{title:'{{t("Destination", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"Input","x-display":"hidden",default:"storage/uploads"}}},path:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{addonBefore:"storage/uploads/"}},renameMode:q.renameMode,rules:q.rules,default:q.default,paranoid:q.paranoid}},"ali-oss":_,s3:{title:'{{t("Amazon S3", { ns: "'.concat(M,'" })}}'),name:"s3",fieldset:{title:q.title,name:q.name,baseUrl:q.baseUrl,options:{type:"object","x-component":"fieldset",properties:{region:{title:'{{t("Region", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},accessKeyId:{title:'{{t("AccessKey ID", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},secretAccessKey:{title:'{{t("AccessKey Secret", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},bucket:{title:'{{t("Bucket", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},endpoint:{title:'{{t("Endpoint", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope"}}},path:q.path,renameMode:q.renameMode,rules:q.rules,default:q.default,paranoid:q.paranoid}},"tx-cos":{title:'{{t("Tencent COS", { ns: "'.concat(M,'" })}}'),name:"tx-cos",fieldset:{title:q.title,name:q.name,baseUrl:q.baseUrl,options:{type:"object","x-component":"fieldset",properties:{Region:{title:'{{t("Region", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},SecretId:{title:'{{t("SecretId", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},SecretKey:{title:'{{t("SecretKey", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},Bucket:{title:'{{t("Bucket", { ns: "'.concat(M,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},thumbnailRule:{title:"Thumbnail rule",type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{placeholder:"?imageMogr2/thumbnail/!50p"},description:'{{ renderThumbnailRuleDesc("tx-cos") }}'}}},path:q.path,renameMode:q.renameMode,rules:q.rules,default:q.default,paranoid:q.paranoid},thumbnailRuleLink:"https://cloud.tencent.com/document/product/436/42214"}};function N(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function L(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function K(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){L(e,t,n[t])})}return e}function V(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function G(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,o,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i=[],l=!0,a=!1;try{for(r=r.call(e);!(l=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){a=!0,o=e}finally{try{l||null==r.return||r.return()}finally{if(a)throw o}}return i}}(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 W(e){return function(e){if(Array.isArray(e))return N(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||$(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(e,t){if(e){if("string"==typeof e)return N(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 N(e,t)}}var Y=function(){var e=G((0,l.useState)({}),2),t=e[0],n=e[1],o=(0,r.usePlugin)(tj),i=(0,r.useCompile)(),c=G((0,l.useState)(!1),2),u=c[0],s=c[1],p=(0,D.useTranslation)().t;return a().createElement("div",null,a().createElement(r.ActionContext.Provider,{value:{visible:u,setVisible:s}},a().createElement(P.Dropdown,{menu:{onClick:function(e){var t=o.storageTypes.get(e.key);s(!0),n({type:"object",properties:L({},(0,A.uid)(),{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{type:t.name}},title:i("{{t('Add new')}}")+" - "+i(t.title),properties:V(K({},R().cloneDeep(t.fieldset)),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}})})})},items:W(o.storageTypes.values()).map(function(e){return{key:e.name,label:i(e.title)}})}},a().createElement(P.Button,{type:"primary",icon:a().createElement(I.PlusOutlined,null)},p("Add new")," ",a().createElement(I.DownOutlined,null))),a().createElement(r.SchemaComponent,{scope:{createOnly:!0},schema:t})))},Z=function(){var e=(0,r.useRecord)(),t=G((0,l.useState)({}),2),n=t[0],o=t[1],i=(0,r.usePlugin)(tj),c=(0,r.useCompile)(),u=G((0,l.useState)(!1),2),s=u[0],p=u[1],f=(0,D.useTranslation)().t,d=G(P.message.useMessage(),2),m=d[0],y=d[1],b=(0,l.useCallback)(function(){var t=i.storageTypes.get(e.type);if(!t)return void m.error(f("Storage type {{type}} is not registered, please check if related plugin is enabled.",{ns:M,type:e.type}));p(!0),t.fieldset.default&&(t.fieldset.default["x-reactions"]=function(e){e.initialValue?e.disabled=!0:e.disabled=!1}),o({type:"object",properties:L({},(0,A.uid)(),{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:K({},e)},title:c("{{t('Edit')}}")+" - "+c(t.title),properties:V(K({},R().cloneDeep(t.fieldset)),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}})})})},[c,i.storageTypes,e]);return a().createElement("div",null,y,a().createElement(r.ActionContext.Provider,{value:{visible:s,setVisible:p}},a().createElement("a",{onClick:b},f("Edit")),a().createElement(r.SchemaComponent,{scope:{createOnly:!1},schema:n})))};function H(e){var t=z[e];return(null==t?void 0:t.thumbnailRule)?a().createElement("div",null,a().createElement("a",{target:"_blank",href:t.thumbnailRuleLink,rel:"noreferrer"},r.i18n.t("See more"))):null}var Q=function(){var e=(0,r.useCompile)(),t=W((0,r.usePlugin)(tj).storageTypes.values()).map(function(t){return{value:t.name,label:e(t.title)}});return a().createElement(P.Card,{bordered:!1},a().createElement(r.SchemaComponent,{components:{CreateStorage:Y,EditStorage:Z},scope:{useNewId:function(e){return"".concat(e).concat((0,A.uid)())},storageTypeOptions:t,renderThumbnailRuleDesc:H},schema:B}))};function J(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function X(e){return(X=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ee(e,t){return(ee=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function et(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(et=function(){return!!e})()}var en=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,o,i,l;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,o=arguments,t=X(t),J(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=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,et()?Reflect.construct(t,o||[],X(this).constructor):t.apply(this,o)),"name","attachment"),J(e,"type","object"),J(e,"group","media"),J(e,"title",'{{t("Attachment", { ns: "'.concat(M,'" })}}')),J(e,"isAssociation",!0),J(e,"default",{type:"belongsToMany",target:"attachments",uiSchema:{type:"array","x-component":"Upload.Attachment","x-use-component-props":"useAttachmentFieldProps"}}),J(e,"availableTypes",["belongsToMany"]),J(e,"properties",(i=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){J(e,t,n[t])})}return e}({},r.interfacesProperties.defaultProps),l=l={"uiSchema.x-component-props.accept":{type:"string",title:'{{t("MIME type", { ns: "'.concat(M,'" })}}'),"x-component":"Input","x-component-props":{placeholder:"image/*"},"x-decorator":"FormItem",description:"Example: image/png"},"uiSchema.x-component-props.multiple":{type:"boolean","x-content":"{{t('Allow uploading multiple files', { ns: \"".concat(M,'" })}}'),"x-decorator":"FormItem","x-component":"Checkbox",default:!0},storage:{type:"string",title:'{{t("Storage", { ns: "'.concat(M,'" })}}'),description:"{{t('Default storage will be used when not selected', { ns: \"".concat(M,'" })}}'),"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{service:{resource:"storages",params:{}},manual:!1,fieldNames:{label:"title",value:"name"}}}},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(l)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(l)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(l,e))}),i)),J(e,"filterable",{children:[{name:"id",value:"id",title:'{{t("Exists")}}',label:'{{t("Exists")}}',operators:[{label:'{{t("exists")}}',value:"$exists",noValue:!0},{label:'{{t("not exists")}}',value:"$notExists",noValue:!0}],schema:{title:'{{t("Exists")}}',type:"string","x-component":"Input"}},{name:"filename",value:"filename",title:'{{t("Filename", { ns: "'.concat(M,'" })}}'),label:'{{t("Filename", { ns: "'.concat(M,'" })}}'),operators:r.interfacesProperties.operators.string,schema:{title:'{{t("Filename", { ns: "'.concat(M,'" })}}'),type:"string","x-component":"Input"}}]}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&ee(n,e),t=[{key:"schemaInitialize",value:function(e,t){var n=t.block;t.field,e["x-component-props"]||(e["x-component-props"]={}),["Table","Kanban"].includes(n)&&(e["x-component-props"].size="small"),e["x-use-component-props"]="useAttachmentFieldProps"}},{key:"initialize",value:function(e){e.through||(e.through="t_".concat((0,A.uid)())),e.foreignKey||(e.foreignKey="f_".concat((0,A.uid)())),e.otherKey||(e.otherKey="f_".concat((0,A.uid)())),e.sourceKey||(e.sourceKey="id"),e.targetKey||(e.targetKey="id")}}],function(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,t),n}(r.CollectionFieldInterface),eo=d(667);function er(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ei=new(function(){var e;function t(){if(!(this instanceof t))throw TypeError("Cannot call a class as a function");er(this,"types",[])}return e=[{key:"add",value:function(e){this.types.unshift(e)}},{key:"getTypeByFile",value:function(e){var t=el(e);return this.types.find(function(e){return e.match(t)})}}],function(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(t.prototype,e),t}());function el(e){return e&&"string"==typeof e?{url:e}:e}function ea(e){return e?"string"==typeof e?e:e.preview||e.url||"":""}function ec(e){return e?"string"==typeof e?e:e.url||e.preview||"":""}var eu={pdf:"/file-placeholder/pdf-200-200.png",mp4:"/file-placeholder/video-200-200.png",mov:"/file-placeholder/video-200-200.png",avi:"/file-placeholder/video-200-200.png",wmv:"/file-placeholder/video-200-200.png",flv:"/file-placeholder/video-200-200.png",mkv:"/file-placeholder/video-200-200.png",mp3:"/file-placeholder/audio-200-200.png",wav:"/file-placeholder/audio-200-200.png",aac:"/file-placeholder/audio-200-200.png",ogg:"/file-placeholder/audio-200-200.png",doc:"/file-placeholder/docx-200-200.png",docx:"/file-placeholder/docx-200-200.png",odt:"/file-placeholder/docx-200-200.png",xls:"/file-placeholder/xlsx-200-200.png",xlsx:"/file-placeholder/xlsx-200-200.png",csv:"/file-placeholder/xlsx-200-200.png",ppt:"/file-placeholder/pptx-200-200.png",pptx:"/file-placeholder/pptx-200-200.png",jpg:"/file-placeholder/jpeg-200-200.png",jpeg:"/file-placeholder/jpeg-200-200.png",png:"/file-placeholder/png-200-200.png",gif:"/file-placeholder/gif-200-200.png",webp:"/file-placeholder/png-200-200.png",bmp:"/file-placeholder/png-200-200.png",svg:"/file-placeholder/svg-200-200.png",default:"/file-placeholder/unknown-200-200.png"},es=function(e){return e.split("?")[0].split("#")[0]},ep=function(e){if(!e)return"";var t=es(e),n=t.lastIndexOf(".");return -1!==n?t.slice(n+1).toLowerCase():""},ef=function(e){if(!e)return"";var t=es(e),n=t.lastIndexOf("/");return -1!==n?t.slice(n+1):t},ed=function(e,t){if(e&&(void 0===e?"undefined":e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"){if(e.extname)return String(e.extname).replace(/^\./,"").toLowerCase();var n=ep(e.name||e.filename||e.title);if(n)return n}return ep(t)},em=function(e,t){var n=ef(t);return e&&"string"!=typeof e&&(e.name||e.filename||e.title)||n},ey=function(e,t){return eu[ed(e,t)]||eu.default},eb=function(e){var t,n=el(e),o=ea(n),i=(null!=(t=ei.getTypeByFile(n))?t:{}).getThumbnailURL,l=null==i?void 0:i(n);return l||((0,r.matchMimetype)(n,"image/*")?"":ey(n,o))},eg=function(e){var t=e.index,n=e.list,o=e.onSwitchIndex,r=e.onDownload,i=e.file,l="number"==typeof t&&!!o&&t>0,c="number"==typeof t&&!!o&&t<n.length-1;return a().createElement(P.Space,{size:14,style:{fontSize:"20px"}},a().createElement(I.LeftOutlined,{style:{cursor:l?"pointer":"not-allowed"},disabled:!l,onClick:function(){return l&&(null==o?void 0:o(t-1))}}),a().createElement(I.RightOutlined,{style:{cursor:c?"pointer":"not-allowed"},disabled:!c,onClick:function(){return c&&(null==o?void 0:o(t+1))}}),a().createElement(I.DownloadOutlined,{onClick:function(){return r(i)}}))},eh=function(e){return function(t){var n=t.open,o=t.onOpenChange,r=t.onClose,i=t.file;if("boolean"!=typeof n)return a().createElement(e,t);var l=em(i,ec(i));return a().createElement(P.Modal,{open:n,title:l,onCancel:function(){null==o||o(!1),null==r||r()},footer:eg(t),width:"90vw",centered:!0},a().createElement("div",{style:{maxWidth:"100%",maxHeight:"calc(100vh - 256px)",height:"80vh",width:"100%",background:"white",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",overflowY:"auto"}},a().createElement(e,t)))}};ei.add({match:function(){return!0},Previewer:eh(function(e){(0,D.useTranslation)().t;var t=e.file;return a().createElement(P.Alert,{type:"warning",description:a().createElement(D.Trans,{ns:M},"File type is not supported for previewing, please ",e.onDownload?a().createElement("a",{onClick:function(){var n;return null==(n=e.onDownload)?void 0:n.call(e,t)},style:{textDecoration:"underline",cursor:"pointer"}},"download it to preview"):a().createElement("span",null,"download it to preview")),showIcon:!0})})}),ei.add({match:function(e){return(0,r.matchMimetype)(e,"image/*")},getThumbnailURL:function(e){return ea(e)},Previewer:function(e){var t=e.file,n=e.list,o=e.index,r=e.open,i=e.onOpenChange,l=e.onSwitchIndex,c=e.onClose,u=e.onDownload;if("boolean"!=typeof r)return null;var s=ec(t);if(!s)return null;var p="number"==typeof o&&o>0,f="number"==typeof o&&o<n.length-1;return a().createElement(P.Image,{wrapperStyle:{display:"none"},preview:{visible:r,onVisibleChange:function(e){return null==i?void 0:i(e)},afterOpenChange:function(e){e||null==c||c()},toolbarRender:function(e,n){var r=n.transform.scale,i=n.actions,c=i.onFlipY,s=i.onFlipX,d=i.onRotateLeft,m=i.onRotateRight,y=i.onZoomOut,b=i.onZoomIn,g=i.onReset;return a().createElement(P.Space,{size:14,className:"toolbar-wrapper",style:{fontSize:"20px"}},a().createElement(I.LeftOutlined,{style:{cursor:p?"pointer":"not-allowed"},disabled:!p,onClick:function(){return p&&(null==l?void 0:l(o-1))}}),a().createElement(I.RightOutlined,{style:{cursor:f?"pointer":"not-allowed"},disabled:!f,onClick:function(){return f&&(null==l?void 0:l(o+1))}}),u?a().createElement(I.DownloadOutlined,{onClick:function(){return u(t)}}):null,a().createElement(I.SwapOutlined,{rotate:90,onClick:c}),a().createElement(I.SwapOutlined,{onClick:s}),a().createElement(I.RotateLeftOutlined,{onClick:d}),a().createElement(I.RotateRightOutlined,{onClick:m}),a().createElement(I.ZoomOutOutlined,{disabled:1===r,onClick:y}),a().createElement(I.ZoomInOutlined,{disabled:50===r,onClick:b}),a().createElement(I.UndoOutlined,{onClick:g}))}},src:s})}}),ei.add({match:function(e){return["text/plain","application/pdf","application/json"].some(function(t){return(0,r.matchMimetype)(e,t)})},Previewer:eh(function(e){var t=ec(e.file);return t?a().createElement("iframe",{src:t,width:"100%",height:"100%",style:{border:"none"}}):null})}),ei.add({match:function(e){return(0,r.matchMimetype)(e,"audio/*")},Previewer:eh(function(e){var t=e.file,n=(0,D.useTranslation)().t,o=ec(t);return o?a().createElement("audio",{controls:!0},a().createElement("source",{src:o,type:(null==t?void 0:t.type)||(null==t?void 0:t.mimetype)}),n("Your browser does not support the audio tag.")):null})}),ei.add({match:function(e){return(0,r.matchMimetype)(e,"video/*")},Previewer:eh(function(e){var t=e.file,n=(0,D.useTranslation)().t,o=ec(t);return o?a().createElement("video",{controls:!0,width:"100%",height:"100%"},a().createElement("source",{src:o,type:(null==t?void 0:t.type)||(null==t?void 0:t.mimetype)}),n("Your browser does not support the video tag.")):null})});var ev=function(e){var t,n,o,r=el(e.file);if(!r)return null;var i=(null!=(o=ei.getTypeByFile(r))?o:{}).Previewer;return i?a().createElement(i,(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){er(e,t,n[t])})}return e}({},e),n=n={file:r},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t)):null};function ex(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function ew(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eO(e){return(eO=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eS(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function ej(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){ew(e,t,n[t])})}return e}function eP(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eE(e,t){return(eE=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eC(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,o,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i=[],l=!0,a=!1;try{for(r=r.call(e);!(l=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){a=!0,o=e}finally{try{l||null==r.return||r.return()}finally{if(a)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ex(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 ex(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 eF(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eF=function(){return!!e})()}function ek(){var e,t,n=(e=["\n .ant-image-img {\n border: 1px solid #d9d9d9;\n padding: 2px;\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return ek=function(){return n},n}var eI=function(e){var t=e.file,n=e.size,o=e.showFileName,i=e.onClick,l=el(t),c=ea(l);if(c){var u=em(l,c),s=ey(l,c),p=eb(l)||s,f=a().createElement("div",{className:(0,r.css)(ek())},a().createElement(P.Image,{src:p,fallback:s,width:n,height:n,preview:!1,style:{borderRadius:4,objectFit:"cover",boxShadow:"0 0 0 2px #fff"}}));return a().createElement("div",{onClick:i,style:{textAlign:"center",width:n,wordBreak:"break-all",cursor:i?"pointer":"default"}},f,o&&a().createElement(P.Tooltip,{title:u},a().createElement("div",{style:{fontSize:12,marginTop:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%"}},u)))}},eA=function(e){var t=e.value,n=void 0===t?[]:t,o=e.size,r=void 0===o?28:o,i=e.showFileName,l=eC(a().useState(0),2),c=l[0],u=l[1],s=eC(a().useState(!1),2),p=s[0],f=s[1],d=a().useMemo(function(){return(0,T.castArray)(n).filter(Boolean).map(el).filter(function(e){return ea(e)})},[n]);a().useEffect(function(){c>=d.length&&d.length&&u(0)},[c,d.length]),a().useEffect(function(){!d.length&&p&&f(!1)},[d.length,p]);var m=a().useCallback(function(e){var t=e||d[c];if(t){var n=t.url||t.preview;if(n){var o=em(t,n),r=ed(t,n);o&&r&&!o.toLowerCase().endsWith(".".concat(r))&&(o="".concat(o,".").concat(r));var i="".concat(Date.now(),"_").concat(o||"file");fetch(n).then(function(e){return e.blob()}).then(function(e){var t=URL.createObjectURL(new Blob([e])),n=document.createElement("a");n.href=t,n.download=i,document.body.appendChild(n),n.click(),URL.revokeObjectURL(t),n.remove()})}}},[c,d]),y=a().useCallback(function(e){u(e),f(!0)},[]),b=a().useCallback(function(e){e<0||e>=d.length||u(e)},[d.length]);return a().createElement(a().Fragment,null,a().createElement(P.Space,{wrap:!0},d.map(function(e,t){return a().createElement(eI,{file:e,size:r,key:t,showFileName:i,onClick:function(){return y(t)}})})),d[c]?a().createElement(ev,{open:p,file:d[c],index:c,list:d,onOpenChange:f,onClose:function(){return f(!1)},onSwitchIndex:b,onDownload:m}):null)},eT=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,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,o=arguments,t=eO(t),ew(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=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,eF()?Reflect.construct(t,o||[],eO(this).constructor):t.apply(this,o)),"disableTitleField",!0),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&eE(n,e),t=[{key:"render",value:function(){var e=this,t=this.props,n=t.value,o=t.titleField,r=t.template,i=t.target;return o&&"file"!==r&&"attachments"!==i?(0,T.castArray)(n).flatMap(function(t,n){var r=null==t?void 0:t[o],i=r?a().createElement(eA,eP(ej({key:n},e.props),{value:(0,T.castArray)(r).filter(Boolean)})):a().createElement("span",{key:n},"N/A");return 0===n?[i]:[a().createElement("span",{key:"sep-".concat(n)},", "),i]}):a().createElement(eA,eP(ej({},this.props),{value:(0,T.castArray)(n).filter(Boolean)}))}}],function(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,t),n}(r.FieldModel);eT.registerFlow({key:"previewReadPrettySetting",sort:500,title:(0,eo.tExpr)("Preview Settings"),steps:{size:{title:(0,eo.tExpr)("Size"),uiMode:function(e){var t=e.t;return{type:"select",key:"size",props:{options:[{value:300,label:t("Large")},{value:100,label:t("Middle")},{value:28,label:t("Small")}]}}},hideInSettings:function(e){return eS(e.model.parent,r.TableColumnModel)},defaultParams:function(e){return{size:eS(e.model.parent,r.DetailsItemModel)?100:28}},handler:function(e,t){e.model.setProps("size",t.size)}},showFileName:{title:(0,eo.tExpr)("Show file name"),uiMode:{type:"switch",key:"showFileName"},hideInSettings:function(e){return eS(e.model.parent,r.TableColumnModel)},defaultParams:{showFileName:!1},handler:function(e,t){e.model.setProps("showFileName",t.showFileName)}}}}),eT.define({label:(0,eo.tExpr)("Preview")}),eo.DisplayItemModel.bindModelToInterface("DisplayPreviewFieldModel",["url","attachment","attachmentURL","m2m","m2o","o2o","o2m","oho","obo","mbm"],{isDefault:!0,when:function(e,t){return!t.targetCollection||"file"===t.targetCollection.template}});var eR=d(964),eD=d(632);function eM(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function eU(e,t,n,o,r,i,l){try{var a=e[i](l),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(o,r)}function eB(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var i=e.apply(t,n);function l(e){eU(i,o,r,l,a,"next",e)}function a(e){eU(i,o,r,l,a,"throw",e)}l(void 0)})}}function eq(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function e_(e,t,n){return(e_="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=ez(e)););return e}(e,t);if(o){var r=Object.getOwnPropertyDescriptor(o,t);return r.get?r.get.call(n||e):r.value}})(e,t,n||e)}function ez(e){return(ez=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eN(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){eq(e,t,n[t])})}return e}function eL(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eK(e,t){return(eK=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eV(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,o,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i=[],l=!0,a=!1;try{for(r=r.call(e);!(l=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){a=!0,o=e}finally{try{l||null==r.return||r.return()}finally{if(a)throw o}}return i}}(e,t)||eW(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 eG(e){return function(e){if(Array.isArray(e))return eM(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||eW(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eW(e,t){if(e){if("string"==typeof e)return eM(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 eM(e,t)}}function e$(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(e$=function(){return!!e})()}function eY(e,t){var n,o,r,i,l={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var c=[i,a];if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,o&&(r=2&c[0]?o.return:c[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,c[1])).done)return r;switch(o=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,o=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(r=(r=l.trys).length>0&&r[r.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){l.label=c[1];break}if(6===c[0]&&l.label<r[1]){l.label=r[1],r=c;break}if(r&&l.label<r[2]){l.label=r[2],l.ops.push(c);break}r[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],o=0}finally{n=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function eZ(){var e,t,n=(e=["\n .ant-upload-list-picture-card {\n margin-bottom: 10px;\n .ant-upload-list-item-container {\n margin: ",";\n }\n }\n .ant-upload-select {\n margin: ",";\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return eZ=function(){return n},n}var eH=function(e){var t,n=e.allowSelectExistingRecord,o=e.multiple,r=e.value,i=e.disabled,c=e.onSelectExitRecordClick,u=e.quickUpload,s=e.showFileName,p=eV((0,l.useState)((0,T.castArray)(r||[])),2),f=p[0],d=p[1],m=eV((0,l.useState)(!1),2),y=m[0],b=m[1],h=eV((0,l.useState)(null),2),v=h[0],x=h[1],w=eV((0,l.useState)(0),2),O=w[0],S=w[1],j=(0,D.useTranslation)().t;(0,l.useEffect)(function(){d(E((0,T.castArray)(r||[])))},[r]);var P=(t=eB(function(e){var t;return eY(this,function(n){switch(n.label){case 0:var o;if(t=+e.uid,!(!e.url&&!e.preview))return[3,2];return[4,(o=e.originFileObj,new Promise(function(e,t){var n=new FileReader;n.readAsDataURL(o),n.onload=function(){return e(n.result)},n.onerror=function(e){return t(e)}}))];case 1:e.preview=n.sent(),n.label=2;case 2:return x(e),S(t),b(!0),[2]}})}),function(e){return t.apply(this,arguments)}),E=function(e){return e.map(function(e){return eL(eN({},e),{thumbUrl:eb(e)})})};return a().createElement(g.FieldContext.Provider,{value:{value:f}},a().createElement("div",{style:{display:"flex"},className:(0,eR.css)(eZ(),s?"8px 0px":"0px",s?"8px 0px":"0px")},a().createElement(eD.Upload,eL(eN({onPreview:P},e),{listType:"picture-card",fileList:f,onChange:function(t){d(t);var n=t.filter(function(e){return"done"===e.status||e.id});if(t.every(function(e){return"done"===e.status||e.id}))if(1===e.maxCount){var o=n[0];e.onChange(o?o.response:null)}else e.onChange(n.map(function(e){return e.response||e}).filter(Boolean))},itemRender:function(e,t){return a().createElement(a().Fragment,null,e,s&&a().createElement("div",{style:{fontSize:12,whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden"},title:t.filename},t.filename))}}),(void 0===u||u)&&a().createElement(I.UploadOutlined,{style:{fontSize:20}})),v&&a().createElement(ev,{open:y,file:v,list:f,index:O,onOpenChange:b,onClose:function(){return x(null)},onSwitchIndex:function(e){e<0||e>=f.length||(S(e),x(f[e]))},onDownload:function(e){var t=e||v;if(t){var n=t.url||t.preview;if(n){var o=n.split("?")[0].split("#")[0],r=o?o.substring(o.lastIndexOf("/")+1):n,i=r.slice(r.lastIndexOf(".")),l="".concat(Date.now(),"_").concat(t.filename).concat(i);fetch(n).then(function(e){return e.blob()}).then(function(e){var t=URL.createObjectURL(new Blob([e])),n=document.createElement("a");n.href=t,n.download=l,document.body.appendChild(n),n.click(),URL.revokeObjectURL(t),n.remove()})}}}}),n?a().createElement("div",{style:{marginLeft:5}},a().createElement(eD.Upload,{disabled:i,multiple:o,listType:"picture-card",showUploadList:!1},a().createElement("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},onClick:function(e){i||(e.stopPropagation(),e.preventDefault(),c())}},a().createElement(I.PlusOutlined,null),j("Select")))):null))},eQ=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,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,o=arguments,t=ez(t),eq(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=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,e$()?Reflect.construct(t,o||[],ez(this).constructor):t.apply(this,o)),"selectedRows",eo.observable.ref([])),eq(e,"_closeView",void 0),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&eK(n,e),t=[{key:"customRequest",set:function(e){this.setProps({customRequest:e})}},{key:"onInit",value:function(e){var t=this;e_(ez(n.prototype),"onInit",this).call(this,e),this.onSelectExitRecordClick=function(e){t.dispatchEvent("openView",{event:e})}}},{key:"onSelectExitRecordClick",set:function(e){this.setProps({onSelectExitRecordClick:e})}},{key:"change",value:function(){this.props.onChange(this.selectedRows.value)}},{key:"render",value:function(){return a().createElement(eH,this.props)}}],function(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,t),n}(r.FieldModel);(eQ=function(e,t,n,o){var r,i=arguments.length,l=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(l=(i<3?r(l):i>3?r(t,n,l):r(t,n))||l);return i>3&&l&&Object.defineProperty(t,n,l),l}([(0,eo.largeField)()],eQ)).registerFlow({key:"uploadSettings",title:(0,eo.tExpr)("Upload file settings"),steps:{quickUpload:{title:(0,eo.tExpr)("Quick upload"),uiMode:{type:"switch",key:"quickUpload"},hideInSettings:function(e){return!e.collectionField.isAssociationField()||!e.collectionField.targetCollection},defaultParams:function(e){return{quickUpload:!0}},handler:function(e,t){e.model.setProps({quickUpload:t.quickUpload})}},allowMultiple:{title:(0,eo.tExpr)("Allow multiple"),uiMode:{type:"switch",key:"multiple"},hideInSettings:function(e){return!e.collectionField||!["belongsToMany","hasMany","belongsToArray"].includes(e.collectionField.type)},defaultParams:function(e){return{multiple:e.collectionField&&["belongsToMany","hasMany","belongsToArray"].includes(e.model.context.collectionField.type)}},handler:function(e,t){e.model.setProps({multiple:null==t?void 0:t.multiple,maxCount:(null==t?void 0:t.multiple)?null:1})}},showFileName:{title:(0,eo.tExpr)("Show file name"),uiMode:{type:"switch",key:"showFileName"},defaultParams:{showFileName:!1},handler:function(e,t){e.model.setProps("showFileName",t.showFileName)}},allowSelectExistingRecord:{title:(0,eo.tExpr)("Allow selection of existing file"),uiMode:{type:"switch",key:"allowSelectExistingRecord"},hideInSettings:function(e){return!e.collectionField.isAssociationField()||!e.collectionField.targetCollection},defaultParams:function(e){return{allowSelectExistingRecord:e.collectionField.targetCollection&&e.collectionField.isAssociationField()}},handler:function(e,t){e.model.setProps({allowSelectExistingRecord:t.allowSelectExistingRecord})}}}}),eQ.registerFlow({key:"eventSettings",sort:300,steps:{bindEvent:{handler:function(e,t){e.model.customRequest=function(t){e.model.dispatchEvent("customRequest",{apiClient:e.app.apiClient,fileData:t})}}}}}),eQ.registerFlow({key:"customRequestSettings",on:"customRequest",steps:{step1:{handler:function(e,t){return eB(function(){var t,n,o,r,i,l,a,c,u,s,p,f,d,m,y,b,g,h,v,x,w,O,S,j,P,E,C,F;return eY(this,function(k){switch(k.label){case 0:if(n=(t=e.inputArgs.fileData).file,o=t.onSuccess,r=t.onError,i=t.onProgress,l=e.app.pm.get("@nocobase/plugin-file-manager"),a=e.model.props.target,c=e.collectionField,!l)return[2,o(n)];k.label=1;case 1:return k.trys.push([1,6,,7]),[4,e.api.resource("storages").check({fileCollectionName:a,storageName:c.options.storage})];case 2:if(!(null==(v=k.sent().data)||null==(u=v.data)?void 0:u.isSupportToUploadFiles))return w=e.t('The current storage "{{storageName}}" does not support file uploads.',{storageName:null==(x=v.data.storage)?void 0:x.title}).replaceAll(">",">"),null==r||r(Error(w)),[2];if(O=l.getStorageType(null==v||null==(p=v.data)||null==(s=p.storage)?void 0:s.type)||{},S=null==v||null==(f=v.data)?void 0:f.storage,!O.createUploadCustomRequest||"function"!=typeof(j=O.createUploadCustomRequest(eL(eN({},e.model.props),{api:e.api,action:"".concat(a,":create?attachmentField=").concat(c.collectionName,".").concat(c.name),storage:S}))))return[3,4];return[4,j({file:n,onProgress:i,onSuccess:o,onError:r})];case 3:return k.sent(),[2];case 4:return[4,l.uploadFile({file:n,fileCollectionName:a,storageId:null==v||null==(m=v.data)||null==(d=m.storage)?void 0:d.id,storageType:null==v||null==(b=v.data)||null==(y=b.storage)?void 0:y.type,storageRules:null==v||null==(h=v.data)||null==(g=h.storage)?void 0:g.rules,onProgress:function(e){null==i||i({percent:e})},query:{attachmentField:"".concat(c.collectionName,".").concat(c.name)}})];case 5:if(E=(P=k.sent()).data,C=P.errorMessage)return null==r||r(Error(C)),[2];if(!E)return null==r||r(Error("上传成功但响应数据为空")),[2];return o(E),[3,7];case 6:return F=k.sent(),null==r||r(F),[3,7];case 7:return[2]}})})()}}}}),eQ.registerFlow({key:"selectExitRecordSettings",title:(0,eo.tExpr)("Selector setting"),on:{eventName:"openView"},steps:{openView:{title:(0,eo.tExpr)("Edit popup"),hideInSettings:function(e){var t,n,o;return!1===(null==(n=(o=e.model).getStepParams)||null==(t=n.call(o,"uploadSettings","allowSelectExistingRecord"))?void 0:t.allowSelectExistingRecord)},uiSchema:function(e){return{mode:{type:"string",title:(0,eo.tExpr)("Open mode"),enum:[{label:(0,eo.tExpr)("Drawer"),value:"drawer"},{label:(0,eo.tExpr)("Dialog"),value:"dialog"}],"x-decorator":"FormItem","x-component":"Radio.Group"},size:{type:"string",title:(0,eo.tExpr)("Popup size"),enum:[{label:(0,eo.tExpr)("Small"),value:"small"},{label:(0,eo.tExpr)("Medium"),value:"medium"},{label:(0,eo.tExpr)("Large"),value:"large"}],"x-decorator":"FormItem","x-component":"Radio.Group"}}},defaultParams:{mode:"drawer",size:"medium"},handler:function(e,t){var n,o,i,l,c,u=["belongsTo","hasOne"].includes(e.collectionField.type),s=e.isMobileLayout?"embed":e.inputArgs.mode||t.mode||"drawer",p=e.inputArgs.size||t.size||"medium",f=(null==(n=e.model.props)?void 0:n.sourceFieldModelUid)||e.model.uid,d=(null==(o=e.model.parent)?void 0:o.use)==="QuickEditFormModel"?null==(i=e.model.parent)?void 0:i.viewContainer:null;null==d||null==(l=d.update)||l.call(d,{preventClose:!0}),e.viewer.open({type:s,width:{drawer:{small:"30%",medium:"50%",large:"70%"},dialog:{small:"40%",medium:"50%",large:"80%"},embed:{}}[s][p],inheritContext:!1,target:e.layoutContentElement,onClose:function(){setTimeout(function(){var e;null==d||null==(e=d.update)||e.call(d,{preventClose:!1})},0)},inputArgs:{parentId:f,scene:"select",dataSourceKey:e.collection.dataSourceKey,collectionName:null==(c=e.collectionField)?void 0:c.target,collectionField:e.collectionField,rowSelectionProps:{type:u?"radio":"checkbox",defaultSelectedRows:function(){return e.model.props.value},renderCell:void 0,selectedRowKeys:void 0,onChange:function(t,n){if(u){var o,r;e.model.selectedRows.value=null==n?void 0:n[0],e.model.change(),null==(o=(r=e.model)._closeView)||o.call(r)}else{var i=eG(e.model.props.value||[]).concat(eG(n)).filter(function(t,n,o){return n===o.findIndex(function(n){return n[e.collection.filterTargetKey]===t[e.collection.filterTargetKey]})});e.model.selectedRows.value=i}}}},content:function(){return a().createElement(r.RecordPickerContent,{model:e.model})},styles:{content:eN({padding:0,backgroundColor:e.model.flowEngine.context.themeToken.colorBgLayout},"embed"===s?{position:"absolute",top:0,left:0,right:0,bottom:0}:{}),body:{padding:0}}})}}}}),eQ.define({label:(0,eo.tExpr)("File picker")}),eo.EditableItemModel.bindModelToInterface("UploadFieldModel",["attachment","m2m","m2o","o2o","o2m","oho","obo","updatedBy","createdBy","mbm"],{isDefault:!0,order:30,when:function(e,t){return!t.targetCollection||"file"===t.targetCollection.template}});let eJ="bits",eX="bytes",e0="jedec",e1={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};var e2=d(371),e3=d.n(e2);function e4(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function e8(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function e5(e,t,n){return(e5="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=e6(e)););return e}(e,t);if(o){var r=Object.getOwnPropertyDescriptor(o,t);return r.get?r.get.call(n||e):r.value}})(e,t,n||e)}function e6(e){return(e6=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function e7(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){e8(e,t,n[t])})}return e}function e9(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function te(e,t){return(te=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,o,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i=[],l=!0,a=!1;try{for(r=r.call(e);!(l=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){a=!0,o=e}finally{try{l||null==r.return||r.return()}finally{if(a)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return e4(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 e4(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 tn(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(tn=function(){return!!e})()}var to=function(e){var t,n,o=(0,eo.useFlowContext)(),i=(0,l.useMemo)(function(){var t="".concat(e.context.collection.name,":create");if(null==(r=o.view)||null==(n=r.inputArgs)?void 0:n.sourceId){var n,r,i,l=tt(e.context.blockModel.association.resourceName.split("."),2),a=l[0],c=l[1];t="".concat(a,"/").concat(null==(i=o.view)?void 0:i.inputArgs.sourceId,"/").concat(c,":create")}return t},[e.context.collection.name,null==(n=o.view)||null==(t=n.inputArgs)?void 0:t.sourceId]),a={},c=0,u={action:i,onChange:function(t){var n=t.fileList;n.forEach(function(t){if("uploading"!==t.status||a[t.uid]||(c++,a[t.uid]=!0),"uploading"!==t.status&&a[t.uid]&&(delete a[t.uid],0==--c)){var n,o;null==(n=(o=e.context.blockModel.resource).refresh)||n.call(o)}}),n.every(function(e){return"done"===e.status})&&o.view.close()}},s=function(e,t){var n,o,i,a,c,u,s,p,f,d,m,y,b,g,h,v=(i=(o=(0,eo.useFlowContext)()).collectionField,a=null==(n=o.collectionField)?void 0:n.targetCollection,c=(0,r.usePlugin)(tj),u=t.context.blockModel.collection,p=null!=(s=(null==i?void 0:i.storage)||u.storage||a.storage)?s:"",f="storages:getBasicInfo/".concat(p),m=(d=(0,r.useRequest)({url:f},{manual:!0,refreshDeps:[p],cacheKey:f})).loading,y=d.data,b=d.run,(0,l.useEffect)(function(){b()},[b]),g=!m&&(null==y?void 0:y.data)||null,h=c.getStorageType(null==g?void 0:g.type),{storage:g,storageType:h}),x=v.storage,w=v.storageType,O=null==w?void 0:w.useUploadProps,S=(null==O?void 0:O(e7({storage:x,rules:x.rules},e)))||{};return e7({rules:null==x?void 0:x.rules},S)}(u,e);return e7({},u,s)},tr={size:function(e,t){var n=null!=t?t:0x1400000;return 0===n||e.size<=n?null:"File size exceeds the limit"},mimetype:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*",n=t.toString().trim();return n&&"*"!==n?n.split(",").filter(Boolean).some(e3()(e.type))?null:"File type is not allowed":null}};function ti(e){var t,n,o,r,i,c,u,s=e.model,p=(0,eo.useFlowContext)(),f=to(s),d=f.rules,m=null!=d?d:{},y=m.size;m.mimetype;var b=(t=null!=y?y:0x1400000,o=(n=(0,D.useTranslation)()).t,r=function(e,{bits:t=!1,pad:n=!1,base:o=-1,round:r=2,locale:i="",localeOptions:l={},separator:a="",spacer:c=" ",symbols:u={},standard:s="",output:p="string",fullform:f=!1,fullforms:d=[],exponent:m=-1,roundingMethod:y="round",precision:b=0}={}){let g=m,h=Number(e),v=[],x=0,w="";"si"===s?(o=10,s=e0):"iec"===s||s===e0?o=2:2===o?s="iec":(o=10,s=e0);let O=10===o?1e3:1024,S=h<0,j=Math[y];if("bigint"!=typeof e&&isNaN(e))throw TypeError("Invalid number");if("function"!=typeof j)throw TypeError("Invalid rounding method");if(S&&(h=-h),(-1===g||isNaN(g))&&(g=Math.floor(Math.log(h)/Math.log(O)))<0&&(g=0),g>8&&(b>0&&(b+=8-g),g=8),"exponent"===p)return g;if(0===h)v[0]=0,w=v[1]=e1.symbol[s][t?eJ:eX][g];else{x=h/(2===o?Math.pow(2,10*g):Math.pow(1e3,g)),t&&(x*=8)>=O&&g<8&&(x/=O,g++);let e=Math.pow(10,g>0?r:0);v[0]=j(x*e)/e,v[0]===O&&g<8&&-1===m&&(v[0]=1,g++),w=v[1]=10===o&&1===g?t?"kbit":"kB":e1.symbol[s][t?eJ:eX][g]}if(S&&(v[0]=-v[0]),b>0&&(v[0]=v[0].toPrecision(b)),v[1]=u[v[1]]||v[1],!0===i?v[0]=v[0].toLocaleString():i.length>0?v[0]=v[0].toLocaleString(i,l):a.length>0&&(v[0]=v[0].toString().replace(".",a)),n&&r>0){let e=v[0].toString(),t=a||(e.match(/(\D)/g)||[]).pop()||".",n=e.toString().split(t),o=n[1]||"",i=o.length;v[0]=`${n[0]}${t}${o.padEnd(i+(r-i),"0")}`}return!0===f&&(v[1]=d[g]?d[g]:e1.fullform[s][g]+(t?"bit":"byte")+(1===v[0]?"":"s")),"array"===p?v:"object"===p?{value:v[0],symbol:v[1],exponent:g,unit:w}:v.join(c)}(t,{base:2,standard:"jedec",locale:n.i18n.language}),0!==t?o("File size should not exceed {{size}}.",{size:r}):""),g=tt((0,l.useState)(!1),2),h=g[0],v=g[1],x=(0,l.useCallback)(function(e){e.fileList.some(function(e){return"uploading"===e.status})?v(!0):v(!1)},[]),w=p.view.Header,O=(i=(0,D.useTranslation)().t,(0,l.useCallback)(function(e,t){var n=function(e,t){if(!t)return null;var n=Object.keys(t);if(!n.length)return null;var o=!0,r=!1,i=void 0;try{for(var l,a=n[Symbol.iterator]();!(o=(l=a.next()).done);o=!0){var c=l.value,u=tr[c](e,t[c]);if(u)return u}}catch(e){r=!0,i=e}finally{try{o||null==a.return||a.return()}finally{if(r)throw i}}return null}(e,d);return n?(e.status="error",e.response=i(n)):"error"===e.status&&(delete e.status,delete e.response),!n&&Promise.resolve(e)},[d]));return a().createElement("div",null,a().createElement(w,{title:p.t("Upload file")}),a().createElement("div",{style:{height:"50vh"},onClick:function(e){return e.stopPropagation()}},a().createElement(P.Upload.Dragger,e7({multiple:!0,listType:"picture"},(c=e9(e7({},f),{handleChange:x,beforeUpload:O}),u=(0,eo.useFlowContext)(),e7({customRequest:function(e){var t=e.action,n=e.data,o=e.file,r=e.filename,i=e.headers,l=e.onError,a=e.onProgress,c=e.onSuccess,s=e.withCredentials,p=new FormData;return n&&Object.keys(n).forEach(function(e){p.append(e,n[e])}),p.append(r,o),u.api.axios.post(t,p,{withCredentials:s,headers:i,onUploadProgress:function(e){var t=e.total;a({percent:Math.round(e.loaded/t*100).toFixed(2)},o)}}).then(function(e){c(e.data,o)}).catch(l).finally(function(){}),{abort:function(){console.log("upload progress is aborted.")}}}},c))),a().createElement("p",{className:"ant-upload-drag-icon"},h?a().createElement(I.LoadingOutlined,{style:{fontSize:36},spin:!0}):a().createElement(I.InboxOutlined,null)),a().createElement("p",{className:"ant-upload-text"},p.t("Click or drag file to this area to upload")),a().createElement("ul",{style:{listStyleType:"none"}},a().createElement("li",{className:"ant-upload-hint"},p.t("Support for a single or bulk upload.")),a().createElement("li",{className:"ant-upload-hint"},b)))))}var tl=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,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,o=arguments,t=e6(t),e8(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=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,tn()?Reflect.construct(t,o||[],e6(this).constructor):t.apply(this,o)),"defaultProps",{type:"primary",title:(0,eo.escapeT)("Upload"),icon:"UploadOutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&te(n,e),t=[{key:"getAclActionName",value:function(){return"create"}},{key:"onInit",value:function(e){var t=this;e5(e6(n.prototype),"onInit",this).call(this,e),this.onUploadClick=function(e){t.dispatchEvent("openView",{event:e})}}},{key:"onUploadClick",set:function(e){this.setProps({onUploadClick:e})}},{key:"render",value:function(){var e=this.props,t=e.icon?a().createElement(r.Icon,{type:e.icon}):void 0;return a().createElement(P.Button,e9(e7({},e),{onClick:this.props.onUploadClick,icon:t}),e.children||e.title)}}],function(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,t),n}(r.ActionModel);function ta(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tc(e){return(tc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function tu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){ta(e,t,n[t])})}return e}function ts(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function tp(e,t){return(tp=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tf(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(tf=function(){return!!e})()}e8(tl,"scene",r.ActionSceneEnum.collection),tl.define({label:(0,eo.escapeT)("Upload"),hide:function(e){var t;return(null==(t=e.collection)?void 0:t.template)!=="file"}}),tl.registerFlow({key:"selectExitRecordSettings",title:(0,eo.escapeT)("Selector setting"),on:{eventName:"openView"},steps:{openView:{title:(0,eo.escapeT)("Edit popup"),uiSchema:function(e){return{mode:{type:"string",title:(0,eo.escapeT)("Open mode"),enum:[{label:(0,eo.escapeT)("Drawer"),value:"drawer"},{label:(0,eo.escapeT)("Dialog"),value:"dialog"}],"x-decorator":"FormItem","x-component":"Radio.Group"},size:{type:"string",title:(0,eo.escapeT)("Popup size"),enum:[{label:(0,eo.escapeT)("Small"),value:"small"},{label:(0,eo.escapeT)("Medium"),value:"medium"},{label:(0,eo.escapeT)("Large"),value:"large"}],"x-decorator":"FormItem","x-component":"Radio.Group"}}},defaultParams:{mode:"drawer",size:"medium"},handler:function(e,t){var n,o=e.inputArgs.mode||t.mode||"drawer",r=e.inputArgs.size||t.size||"medium";e.viewer.open({type:o,width:{drawer:{small:"30%",medium:"50%",large:"70%"},dialog:{small:"40%",medium:"50%",large:"80%"},embed:{}}[o][r],inheritContext:!1,target:e.layoutContentElement,inputArgs:{sourceId:null==(n=e.resource)?void 0:n.getSourceId()},content:function(){return a().createElement(ti,{model:e.model})},styles:{content:e7({padding:0,backgroundColor:e.model.flowEngine.context.themeToken.colorBgLayout},"embed"===o?{position:"absolute",top:0,left:0,right:0,bottom:0}:{})}})}}}});var td=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(){var e,n,o;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");return n=t,o=arguments,n=tc(n),ta(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=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,tf()?Reflect.construct(n,o||[],tc(this).constructor):n.apply(this,o)),"name","file"),ta(e,"title",'{{t("File collection", { ns: "'.concat(M,'" })}}')),ta(e,"order",3),ta(e,"color","blue"),ta(e,"default",{createdBy:!0,updatedBy:!0,fields:[{interface:"input",type:"string",name:"title",deletable:!1,uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"input",type:"string",name:"filename",deletable:!1,uiSchema:{type:"string",title:'{{t("File name", { ns: "'.concat(M,'" })}}'),"x-component":"Input","x-read-pretty":!0}},{interface:"input",type:"string",name:"extname",deletable:!1,uiSchema:{type:"string",title:'{{t("Extension name", { ns: "'.concat(M,'" })}}'),"x-component":"Input","x-read-pretty":!0}},{interface:"integer",type:"integer",name:"size",deletable:!1,uiSchema:{type:"number",title:'{{t("Size", { ns: "'.concat(M,'" })}}'),"x-component":"InputNumber","x-read-pretty":!0,"x-component-props":{stringMode:!0,step:"0"}}},{interface:"input",type:"string",name:"mimetype",deletable:!1,uiSchema:{type:"string",title:'{{t("MIME type", { ns: "'.concat(M,'" })}}'),"x-component":"Input","x-read-pretty":!0}},{interface:"input",type:"text",name:"path",deletable:!1,uiSchema:{type:"string",title:'{{t("Path", { ns: "'.concat(M,'" })}}'),"x-component":"TextAreaWithGlobalScope","x-read-pretty":!0}},{interface:"url",type:"text",name:"url",deletable:!1,uiSchema:{type:"string",title:'{{t("URL")}}',"x-component":"Input.URL","x-read-pretty":!0}},{interface:"url",type:"text",name:"preview",field:"url",deletable:!1,uiSchema:{type:"string",title:'{{t("Preview", { ns: "'.concat(M,'" })}}'),"x-component":"Preview","x-read-pretty":!0}},{type:"belongsTo",name:"storage",target:"storages",foreignKey:"storageId",deletable:!1,interface:"m2o",uiSchema:{type:"object",title:'{{t("Storage", { ns: "'.concat(M,'" })}}'),"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"title"}},"x-read-pretty":!0}},{type:"jsonb",name:"meta",deletable:!1,defaultValue:{}}]}),ta(e,"presetFieldsDisabled",!0),ta(e,"events",{filterPrimaryKeyCandidate:function(e){return"input"!==e.name},initPrimaryKeyFiledInterface:function(e){e.autoFill&&(e.autoFill["x-disabled"]=!0),e.autoIncrement&&(e.autoIncrement["x-disabled"]=!0)}}),ta(e,"configurableProperties",tu(ts(tu(ts(tu({},(0,r.getConfigurableProperties)("title","name")),{inherits:ts(tu({},(0,r.getConfigurableProperties)("inherits").inherits),{"x-reactions":["{{useAsyncDataSource(loadCollections)}}"]})}),(0,r.getConfigurableProperties)("category","description")),{storage:{type:"string",name:"storage",title:'{{t("File storage", { ns: "'.concat(M,'" })}}'),"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{service:{resource:"storages",params:{}},manual:!1,fieldNames:{label:"title",value:"name"}}}}),(0,r.getConfigurableProperties)("presetFields"))),e}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&tp(t,e),t}(r.CollectionTemplate);function tm(e,t,n,o,r,i,l){try{var a=e[i](l),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(o,r)}function ty(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var i=e.apply(t,n);function l(e){tm(i,o,r,l,a,"next",e)}function a(e){tm(i,o,r,l,a,"throw",e)}l(void 0)})}}function tb(e,t,n){return(tb=tw()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var r=new(Function.bind.apply(e,o));return n&&tv(r,n.prototype),r}).apply(null,arguments)}function tg(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function th(e){return(th=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function tv(e,t){return(tv=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tx(e){var t="function"==typeof Map?new Map:void 0;return(tx=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 tb(e,arguments,th(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),tv(n,e)})(e)}function tw(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(tw=function(){return!!e})()}function tO(e,t){var n,o,r,i,l={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var c=[i,a];if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,o&&(r=2&c[0]?o.return:c[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,c[1])).done)return r;switch(o=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,o=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(r=(r=l.trys).length>0&&r[r.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){l.label=c[1];break}if(6===c[0]&&l.label<r[1]){l.label=r[1],r=c;break}if(r&&l.label<r[2]){l.label=r[2],l.ops.push(c);break}r[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],o=0}finally{n=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var tS=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,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,o=arguments,t=th(t),tg(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=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,tw()?Reflect.construct(t,o||[],th(this).constructor):t.apply(this,o)),"storageTypes",new Map),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&tv(n,e),t=[{key:"load",value:function(){var e=this;return ty(function(){var t;return tO(this,function(n){return e.app.dataSourceManager.addFieldInterfaces([en]),e.app.dataSourceManager.addCollectionTemplates([td]),e.app.use(j),e.app.pluginSettingsManager.add(M,{title:'{{t("File manager", { ns: "'.concat(M,'" })}}'),icon:"FileOutlined",Component:Q,aclSnippet:"pm.file-manager.storages"}),Object.values(z).forEach(function(t){e.registerStorageType(t.name,t)}),null==(t=e.app.schemaInitializerManager.get("table:configureActions"))||t.add("enableActions.upload",{title:"{{t('Upload')}}",Component:"UploadActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible:function(){return"file"===(0,r.useCollection)().template}}),e.app.addScopes({useAttachmentFieldProps:v,useFileCollectionStorageRules:x,useStorageCfg:u}),e.app.addComponents({FileSizeField:k}),e.flowEngine.registerModels({DisplayPreviewFieldModel:eT,UploadActionModel:tl,UploadFieldModel:eQ}),[2]})})()}},{key:"registerStorageType",value:function(e,t){this.storageTypes.set(e,t)}},{key:"getStorageType",value:function(e){return this.storageTypes.get(e)}},{key:"uploadFile",value:function(e){var t=this;return ty(function(){var n,o,r,i,l,a,c,u,s,p,f,d,m,y;return tO(this,function(b){switch(b.label){case 0:if(!(null==e?void 0:e.file))return[2,{errorMessage:"Missing file"}];if(n=e.file,o=e.storageType,r=e.storageId,i=e.storageRules,a=void 0===(l=e.query)?{}:l,c=(null==e?void 0:e.fileCollectionName)||"attachments",!(null==(u=t.getStorageType(o))?void 0:u.upload))return[3,2];return[4,u.upload({file:n,apiClient:t.app.apiClient,storageType:o,storageId:r,storageRules:i,fileCollectionName:c,query:a})];case 1:return[2,b.sent()];case 2:return b.trys.push([2,4,,5]),(p=new FormData).append("file",n),d=(f=new URLSearchParams(a).toString())?"".concat(c,":create?").concat(f):"".concat(c,":create"),[4,t.app.apiClient.request({url:d,method:"post",data:p})];case 3:return[2,{data:null==(s=b.sent().data)?void 0:s.data}];case 4:return[2,{errorMessage:null!=(y=null==(m=b.sent())?void 0:m.message)?y:"Upload failed"}];case 5:return[2]}})})()}}],function(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,t),n}(tx(r.Plugin));tg(tS,"buildInStorage",["local","ali-oss","s3","tx-cos"]);var tj=tS}(),m});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { FieldModel } from '@nocobase/client';
|
|
11
|
+
export declare const CardUpload: (props: any) => React.JSX.Element;
|
|
12
|
+
export declare class UploadFieldModel extends FieldModel {
|
|
13
|
+
selectedRows: {
|
|
14
|
+
value: any[];
|
|
15
|
+
};
|
|
16
|
+
_closeView: any;
|
|
17
|
+
set customRequest(fn: any);
|
|
18
|
+
onInit(options: any): void;
|
|
19
|
+
set onSelectExitRecordClick(fn: any);
|
|
20
|
+
change(): void;
|
|
21
|
+
render(): React.JSX.Element;
|
|
22
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
export interface FilePreviewerProps {
|
|
11
|
+
file: any;
|
|
12
|
+
index: number;
|
|
13
|
+
list: any[];
|
|
14
|
+
open?: boolean;
|
|
15
|
+
onOpenChange?: (open: boolean) => void;
|
|
16
|
+
onSwitchIndex?: (index: number) => void;
|
|
17
|
+
onClose?: () => void;
|
|
18
|
+
onDownload: (file: any) => void;
|
|
19
|
+
}
|
|
20
|
+
export interface FilePreviewType {
|
|
21
|
+
match(file: any): boolean;
|
|
22
|
+
getThumbnailURL?: (file: any) => string | null;
|
|
23
|
+
Previewer?: React.ComponentType<FilePreviewerProps>;
|
|
24
|
+
}
|
|
25
|
+
export declare class FilePreviewTypes {
|
|
26
|
+
types: FilePreviewType[];
|
|
27
|
+
add(type: FilePreviewType): void;
|
|
28
|
+
getTypeByFile(file: any): Omit<FilePreviewType, 'match'> | undefined;
|
|
29
|
+
}
|
|
30
|
+
export declare const filePreviewTypes: FilePreviewTypes;
|
|
31
|
+
export declare function normalizePreviewFile(file: any): any;
|
|
32
|
+
export declare function getPreviewFileUrl(file: any): any;
|
|
33
|
+
export declare function getFileUrl(file: any): any;
|
|
34
|
+
export declare const getFileExt: (file: any, url?: string) => string;
|
|
35
|
+
export declare const getFileName: (file: any, url?: string) => any;
|
|
36
|
+
export declare const getFallbackIcon: (file: any, url?: string) => string;
|
|
37
|
+
export declare const getPreviewThumbnailUrl: (file: any) => string;
|
|
38
|
+
export declare const wrapWithModalPreviewer: (Previewer: React.ComponentType<FilePreviewerProps>) => (props: FilePreviewerProps) => React.JSX.Element;
|
|
39
|
+
export declare const FilePreviewRenderer: (props: FilePreviewerProps) => React.JSX.Element;
|
|
@@ -136,6 +136,25 @@ declare const _default: {
|
|
|
136
136
|
'x-content': string;
|
|
137
137
|
description: string;
|
|
138
138
|
};
|
|
139
|
+
settings: {
|
|
140
|
+
type: string;
|
|
141
|
+
title: string;
|
|
142
|
+
'x-component': string;
|
|
143
|
+
properties: {
|
|
144
|
+
requestOptions: {
|
|
145
|
+
type: string;
|
|
146
|
+
title: string;
|
|
147
|
+
description: string;
|
|
148
|
+
'x-decorator': string;
|
|
149
|
+
'x-component': string;
|
|
150
|
+
'x-component-props': {
|
|
151
|
+
autoSize: {
|
|
152
|
+
minRows: number;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
};
|
|
139
158
|
};
|
|
140
159
|
thumbnailRuleLink: string;
|
|
141
160
|
};
|
|
@@ -77,5 +77,24 @@ declare const _default: {
|
|
|
77
77
|
}[];
|
|
78
78
|
default: string;
|
|
79
79
|
};
|
|
80
|
+
settings: {
|
|
81
|
+
type: string;
|
|
82
|
+
title: string;
|
|
83
|
+
'x-component': string;
|
|
84
|
+
properties: {
|
|
85
|
+
requestOptions: {
|
|
86
|
+
type: string;
|
|
87
|
+
title: string;
|
|
88
|
+
description: string;
|
|
89
|
+
'x-decorator': string;
|
|
90
|
+
'x-component': string;
|
|
91
|
+
'x-component-props': {
|
|
92
|
+
autoSize: {
|
|
93
|
+
minRows: number;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
};
|
|
80
99
|
};
|
|
81
100
|
export default _default;
|
|
@@ -230,6 +230,25 @@ export declare const storageTypes: {
|
|
|
230
230
|
'x-content': string;
|
|
231
231
|
description: string;
|
|
232
232
|
};
|
|
233
|
+
settings: {
|
|
234
|
+
type: string;
|
|
235
|
+
title: string;
|
|
236
|
+
'x-component': string;
|
|
237
|
+
properties: {
|
|
238
|
+
requestOptions: {
|
|
239
|
+
type: string;
|
|
240
|
+
title: string;
|
|
241
|
+
description: string;
|
|
242
|
+
'x-decorator': string;
|
|
243
|
+
'x-component': string;
|
|
244
|
+
'x-component-props': {
|
|
245
|
+
autoSize: {
|
|
246
|
+
minRows: number;
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
};
|
|
233
252
|
};
|
|
234
253
|
thumbnailRuleLink: string;
|
|
235
254
|
};
|
|
@@ -129,11 +129,11 @@ export declare class FileCollectionTemplate extends CollectionTemplate {
|
|
|
129
129
|
updatedAt: any;
|
|
130
130
|
title: any;
|
|
131
131
|
description: any;
|
|
132
|
+
updatedBy: any;
|
|
133
|
+
createdBy: any;
|
|
132
134
|
inherits: any;
|
|
133
135
|
category: any;
|
|
134
136
|
autoGenId: any;
|
|
135
|
-
createdBy: any;
|
|
136
|
-
updatedBy: any;
|
|
137
137
|
sortable: any;
|
|
138
138
|
simplePaginate: any;
|
|
139
139
|
presetFields: any;
|