@nocobase/plugin-file-manager 2.4.0-alpha.1 → 2.4.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/client/pdfjs/pdf.min.mjs +4 -4
  3. package/dist/client/pdfjs/pdf.worker.min.mjs +4 -4
  4. package/dist/client/pdfjs/standard_fonts/LICENSE_LIBERATION +362 -101
  5. package/dist/client/templates/file.d.ts +1 -1
  6. package/dist/client-v2/125.a8dd12309b00dcab.js +10 -0
  7. package/dist/client-v2/index.d.ts +1 -1
  8. package/dist/client-v2/index.js +1 -1
  9. package/dist/externalVersion.js +13 -13
  10. package/dist/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +672 -730
  11. package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
  12. package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/index.js +675 -733
  13. package/dist/node_modules/@aws-sdk/lib-storage/package.json +1 -1
  14. package/dist/node_modules/@aws-sdk/s3-request-presigner/package.json +1 -1
  15. package/dist/node_modules/ali-oss/lib/client.js +14 -14
  16. package/dist/node_modules/ali-oss/package.json +1 -1
  17. package/dist/node_modules/cos-nodejs-sdk-v5/index.js +7 -7
  18. package/dist/node_modules/cos-nodejs-sdk-v5/package.json +1 -1
  19. package/dist/node_modules/mime-match/package.json +1 -1
  20. package/dist/node_modules/mime-types/package.json +1 -1
  21. package/dist/node_modules/mkdirp/package.json +1 -1
  22. package/dist/node_modules/url-join/package.json +1 -1
  23. package/dist/server/actions/attachments.js +1 -1
  24. package/dist/server/actions/get-file.js +1 -0
  25. package/dist/server/file-reference.d.ts +16 -0
  26. package/dist/server/file-reference.js +108 -0
  27. package/dist/server/index.d.ts +2 -0
  28. package/dist/server/index.js +4 -1
  29. package/package.json +3 -3
  30. package/dist/client-v2/125.9cdb7cf3ef4712ef.js +0 -10
@@ -1 +1 @@
1
- {"name":"cos-nodejs-sdk-v5","version":"2.12.6","description":"cos nodejs sdk v5","main":"index.js","types":"index.d.ts","scripts":{"prettier":"prettier --write sdk demo/demo.js test/test.js index.d.ts","demo":"node demo/demo.js","demo-sts":"node demo/demo-sts.js","demo-sts-scope":"node demo/demo-sts-scope.js","test":"mocha test/test.js","cov":"istanbul cover _mocha -- -u exports 'test/test.js'","nyc":"nyc --reporter=clover --reporter=cobertura mocha --reporter xunit --reporter-options output=mocha.xml test/test.js","csp":"mocha test/csp.js"},"repository":{"type":"git","url":"git+https://github.com/tencentyun/cos-nodejs-sdk-v5.git"},"keywords":["tencent","tencent cloud","qcloud","cos","cos-sdk"],"author":"carsonxu","license":"ISC","bugs":{"url":"https://github.com/tencentyun/cos-nodejs-sdk-v5/issues"},"homepage":"https://github.com/tencentyun/cos-nodejs-sdk-v5#readme","dependencies":{"conf":"^9.0.0","fast-xml-parser":"4.2.5","mime-types":"^2.1.24","request":"^2.88.2"},"devDependencies":{"@types/node":"^14.14.20","batch":"^0.6.1","crc64-ecma182.js":"^1.0.0","mocha":"^4.0.1","nyc":"^15.1.0","prettier":"^3.0.1","qcloud-cos-sts":"^3.0.0"},"engines":{"node":">= 6"},"_lastModified":"2026-09-02T04:19:14.336Z"}
1
+ {"name":"cos-nodejs-sdk-v5","version":"2.12.6","description":"cos nodejs sdk v5","main":"index.js","types":"index.d.ts","scripts":{"prettier":"prettier --write sdk demo/demo.js test/test.js index.d.ts","demo":"node demo/demo.js","demo-sts":"node demo/demo-sts.js","demo-sts-scope":"node demo/demo-sts-scope.js","test":"mocha test/test.js","cov":"istanbul cover _mocha -- -u exports 'test/test.js'","nyc":"nyc --reporter=clover --reporter=cobertura mocha --reporter xunit --reporter-options output=mocha.xml test/test.js","csp":"mocha test/csp.js"},"repository":{"type":"git","url":"git+https://github.com/tencentyun/cos-nodejs-sdk-v5.git"},"keywords":["tencent","tencent cloud","qcloud","cos","cos-sdk"],"author":"carsonxu","license":"ISC","bugs":{"url":"https://github.com/tencentyun/cos-nodejs-sdk-v5/issues"},"homepage":"https://github.com/tencentyun/cos-nodejs-sdk-v5#readme","dependencies":{"conf":"^9.0.0","fast-xml-parser":"4.2.5","mime-types":"^2.1.24","request":"^2.88.2"},"devDependencies":{"@types/node":"^14.14.20","batch":"^0.6.1","crc64-ecma182.js":"^1.0.0","mocha":"^4.0.1","nyc":"^15.1.0","prettier":"^3.0.1","qcloud-cos-sts":"^3.0.0"},"engines":{"node":">= 6"},"_lastModified":"2026-10-16T01:30:44.031Z"}
@@ -1 +1 @@
1
- {"name":"mime-match","version":"1.0.2","description":"A simple function to check whether a mimetype matches the specified mimetype (with wildcard support)","main":"index.js","scripts":{"test":"node test.js","gendocs":"gendocs > README.md"},"repository":{"type":"git","url":"https://github.com/DamonOehlman/mime-match.git"},"keywords":["mime","wildcard"],"author":"Damon Oehlman <damon.oehlman@gmail.com>","license":"ISC","bugs":{"url":"https://github.com/DamonOehlman/mime-match/issues"},"homepage":"https://github.com/DamonOehlman/mime-match","dependencies":{"wildcard":"^1.1.0"},"devDependencies":{"tape":"^4.5.1"},"_lastModified":"2026-09-02T04:19:03.595Z"}
1
+ {"name":"mime-match","version":"1.0.2","description":"A simple function to check whether a mimetype matches the specified mimetype (with wildcard support)","main":"index.js","scripts":{"test":"node test.js","gendocs":"gendocs > README.md"},"repository":{"type":"git","url":"https://github.com/DamonOehlman/mime-match.git"},"keywords":["mime","wildcard"],"author":"Damon Oehlman <damon.oehlman@gmail.com>","license":"ISC","bugs":{"url":"https://github.com/DamonOehlman/mime-match/issues"},"homepage":"https://github.com/DamonOehlman/mime-match","dependencies":{"wildcard":"^1.1.0"},"devDependencies":{"tape":"^4.5.1"},"_lastModified":"2026-10-16T01:30:32.501Z"}
@@ -1 +1 @@
1
- {"name":"mime-types","description":"The ultimate javascript content-type utility.","version":"3.0.1","contributors":["Douglas Christopher Wilson <doug@somethingdoug.com>","Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)","Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"],"license":"MIT","keywords":["mime","types"],"repository":"jshttp/mime-types","dependencies":{"mime-db":"^1.54.0"},"devDependencies":{"eslint":"8.33.0","eslint-config-standard":"14.1.1","eslint-plugin-import":"2.27.5","eslint-plugin-markdown":"3.0.0","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"6.1.1","eslint-plugin-standard":"4.1.0","mocha":"10.2.0","nyc":"15.1.0"},"files":["HISTORY.md","LICENSE","index.js","mimeScore.js"],"engines":{"node":">= 0.6"},"scripts":{"lint":"eslint .","test":"mocha --reporter spec test/test.js","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_lastModified":"2026-09-02T04:19:03.886Z"}
1
+ {"name":"mime-types","description":"The ultimate javascript content-type utility.","version":"3.0.1","contributors":["Douglas Christopher Wilson <doug@somethingdoug.com>","Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)","Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"],"license":"MIT","keywords":["mime","types"],"repository":"jshttp/mime-types","dependencies":{"mime-db":"^1.54.0"},"devDependencies":{"eslint":"8.33.0","eslint-config-standard":"14.1.1","eslint-plugin-import":"2.27.5","eslint-plugin-markdown":"3.0.0","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"6.1.1","eslint-plugin-standard":"4.1.0","mocha":"10.2.0","nyc":"15.1.0"},"files":["HISTORY.md","LICENSE","index.js","mimeScore.js"],"engines":{"node":">= 0.6"},"scripts":{"lint":"eslint .","test":"mocha --reporter spec test/test.js","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_lastModified":"2026-10-16T01:30:32.814Z"}
@@ -1 +1 @@
1
- {"name":"mkdirp","description":"Recursively mkdir, like `mkdir -p`","version":"0.5.6","publishConfig":{"tag":"legacy"},"author":"James Halliday <mail@substack.net> (http://substack.net)","main":"index.js","keywords":["mkdir","directory"],"repository":{"type":"git","url":"https://github.com/substack/node-mkdirp.git"},"scripts":{"test":"tap test/*.js"},"dependencies":{"minimist":"^1.2.6"},"devDependencies":{"tap":"^16.0.1"},"bin":"bin/cmd.js","license":"MIT","files":["bin","index.js"],"_lastModified":"2026-09-02T04:19:08.506Z"}
1
+ {"name":"mkdirp","description":"Recursively mkdir, like `mkdir -p`","version":"0.5.6","publishConfig":{"tag":"legacy"},"author":"James Halliday <mail@substack.net> (http://substack.net)","main":"index.js","keywords":["mkdir","directory"],"repository":{"type":"git","url":"https://github.com/substack/node-mkdirp.git"},"scripts":{"test":"tap test/*.js"},"dependencies":{"minimist":"^1.2.6"},"devDependencies":{"tap":"^16.0.1"},"bin":"bin/cmd.js","license":"MIT","files":["bin","index.js"],"_lastModified":"2026-10-16T01:30:37.856Z"}
@@ -1 +1 @@
1
- {"name":"url-join","version":"4.0.1","description":"Join urls and normalize as in path.join.","main":"lib/url-join.js","scripts":{"test":"mocha --require should"},"repository":{"type":"git","url":"git://github.com/jfromaniello/url-join.git"},"keywords":["url","join"],"author":"José F. Romaniello <jfromaniello@gmail.com> (http://joseoncode.com)","license":"MIT","devDependencies":{"conventional-changelog":"^1.1.10","mocha":"^3.2.0","should":"~1.2.1"},"_lastModified":"2026-09-02T04:19:03.687Z"}
1
+ {"name":"url-join","version":"4.0.1","description":"Join urls and normalize as in path.join.","main":"lib/url-join.js","scripts":{"test":"mocha --require should"},"repository":{"type":"git","url":"git://github.com/jfromaniello/url-join.git"},"keywords":["url","join"],"author":"José F. Romaniello <jfromaniello@gmail.com> (http://joseoncode.com)","license":"MIT","devDependencies":{"conventional-changelog":"^1.1.10","mocha":"^3.2.0","should":"~1.2.1"},"_lastModified":"2026-10-16T01:30:32.607Z"}
@@ -217,7 +217,7 @@ async function createMiddleware(ctx, next) {
217
217
  if (((_a = collection == null ? void 0 : collection.options) == null ? void 0 : _a.template) !== "file" || !["upload", "create", "update"].includes(actionName)) {
218
218
  return next();
219
219
  }
220
- const storageName = resourceName === "attachments" ? (_c = (_b = ctx.db.getFieldByPath(attachmentField)) == null ? void 0 : _b.options) == null ? void 0 : _c.storage : collection.options.storage;
220
+ const storageName = ((_c = (_b = ctx.db.getFieldByPath(attachmentField)) == null ? void 0 : _b.options) == null ? void 0 : _c.storage) || collection.options.storage;
221
221
  const plugin = ctx.app.pm.get(import__.default);
222
222
  const storage = Array.from(plugin.storagesCache.values()).find(
223
223
  (storage2) => storageName ? storage2.name === storageName : storage2.default
@@ -129,6 +129,7 @@ async function getFile(ctx, next) {
129
129
  download
130
130
  })) || await plugin.getFileURL(file, preview, { download });
131
131
  const finalUrl = preserveSubAppInLocalURL(storageUrl, (_l = ctx.state.fileAccess) == null ? void 0 : _l.appName);
132
+ ctx.set("Cache-Control", "private, no-store");
132
133
  ctx.status = 302;
133
134
  ctx.redirect(finalUrl);
134
135
  await next();
@@ -0,0 +1,16 @@
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
+ export type PermanentFileReference = {
10
+ appName: string;
11
+ dataSourceKey: string;
12
+ collectionName: string;
13
+ id: string;
14
+ extname?: string;
15
+ };
16
+ export declare function parsePermanentFileReference(value: unknown, origin?: string): PermanentFileReference | null;
@@ -0,0 +1,108 @@
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
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var file_reference_exports = {};
28
+ __export(file_reference_exports, {
29
+ parsePermanentFileReference: () => parsePermanentFileReference
30
+ });
31
+ module.exports = __toCommonJS(file_reference_exports);
32
+ var import_utils = require("./utils");
33
+ const IDENTIFIER_PATTERN = /^[A-Za-z0-9_][A-Za-z0-9_-]*$/;
34
+ function invalidFileURL() {
35
+ return Object.assign(new Error("Invalid file URL"), { status: 404 });
36
+ }
37
+ function stripPublicPath(pathname) {
38
+ const publicPath = (0, import_utils.trimPublicPath)(process.env.APP_PUBLIC_PATH);
39
+ if (publicPath && (pathname === publicPath || pathname.startsWith(`${publicPath}/`))) {
40
+ return pathname.slice(publicPath.length) || "/";
41
+ }
42
+ return pathname;
43
+ }
44
+ function getURLOrigin(value) {
45
+ if (typeof value !== "string" || !value) {
46
+ return null;
47
+ }
48
+ try {
49
+ return new URL(value).origin;
50
+ } catch (error) {
51
+ return null;
52
+ }
53
+ }
54
+ function parsePermanentFileReference(value, origin) {
55
+ if (typeof value !== "string" || !value || value.startsWith("//")) {
56
+ return null;
57
+ }
58
+ let url;
59
+ if (value.startsWith("/")) {
60
+ url = new URL(value, "http://localhost");
61
+ } else {
62
+ try {
63
+ url = new URL(value);
64
+ } catch (error) {
65
+ return null;
66
+ }
67
+ const configuredOrigin = process.env.APP_PUBLIC_ORIGIN;
68
+ const trustedOrigin = configuredOrigin ? getURLOrigin(configuredOrigin) : getURLOrigin(origin);
69
+ if (!trustedOrigin || url.origin !== trustedOrigin) {
70
+ return null;
71
+ }
72
+ }
73
+ if (url.searchParams.has("temporaryAccessToken")) {
74
+ return null;
75
+ }
76
+ const segments = stripPublicPath(url.pathname).split("/").filter(Boolean);
77
+ if (segments[0] !== "files") {
78
+ return null;
79
+ }
80
+ if (segments.length !== 5) {
81
+ throw invalidFileURL();
82
+ }
83
+ try {
84
+ const appName = decodeURIComponent(segments[1]);
85
+ const dataSourceKey = decodeURIComponent(segments[2]);
86
+ const collectionName = decodeURIComponent(segments[3]);
87
+ const fileIdSegment = decodeURIComponent(segments[4]);
88
+ const extnameIndex = fileIdSegment.lastIndexOf(".");
89
+ const extname = extnameIndex > 0 ? (0, import_utils.normalizeFileAccessExtname)(fileIdSegment.slice(extnameIndex)) : "";
90
+ const id = extname ? fileIdSegment.slice(0, extnameIndex) : fileIdSegment;
91
+ if (!IDENTIFIER_PATTERN.test(appName) || !IDENTIFIER_PATTERN.test(dataSourceKey) || !IDENTIFIER_PATTERN.test(collectionName) || !id || id.includes("/") || id.includes("\\") || id.includes("\0")) {
92
+ throw invalidFileURL();
93
+ }
94
+ return {
95
+ appName,
96
+ dataSourceKey,
97
+ collectionName,
98
+ id,
99
+ extname: extname || void 0
100
+ };
101
+ } catch (error) {
102
+ throw invalidFileURL();
103
+ }
104
+ }
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ parsePermanentFileReference
108
+ });
@@ -10,6 +10,8 @@ import { StorageEngine } from 'multer';
10
10
  export * from '../constants';
11
11
  export { AttachmentModel, default, PluginFileManagerServer, StorageModel } from './server';
12
12
  export type { FileAccessAuthorizeParams, FileAccessAuthorizer } from './server';
13
+ export { parsePermanentFileReference } from './file-reference';
14
+ export type { PermanentFileReference } from './file-reference';
13
15
  export { cloudFilenameGetter } from './utils';
14
16
  export { appendDownloadResponse, getDownloadContentDisposition, StorageType, GetFileStreamOptions, GetFileURLOptions, } from './storages';
15
17
  export { StorageEngine };
@@ -47,12 +47,14 @@ __export(server_exports, {
47
47
  appendDownloadResponse: () => import_storages.appendDownloadResponse,
48
48
  cloudFilenameGetter: () => import_utils.cloudFilenameGetter,
49
49
  default: () => import_server.default,
50
- getDownloadContentDisposition: () => import_storages.getDownloadContentDisposition
50
+ getDownloadContentDisposition: () => import_storages.getDownloadContentDisposition,
51
+ parsePermanentFileReference: () => import_file_reference.parsePermanentFileReference
51
52
  });
52
53
  module.exports = __toCommonJS(server_exports);
53
54
  var import_multer = require("multer");
54
55
  __reExport(server_exports, require("../constants"), module.exports);
55
56
  var import_server = __toESM(require("./server"));
57
+ var import_file_reference = require("./file-reference");
56
58
  var import_utils = require("./utils");
57
59
  var import_storages = require("./storages");
58
60
  // Annotate the CommonJS export names for ESM import in node:
@@ -67,5 +69,6 @@ var import_storages = require("./storages");
67
69
  appendDownloadResponse,
68
70
  cloudFilenameGetter,
69
71
  getDownloadContentDisposition,
72
+ parsePermanentFileReference,
70
73
  ...require("../constants")
71
74
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-file-manager",
3
- "version": "2.4.0-alpha.1",
3
+ "version": "2.4.0-alpha.11",
4
4
  "displayName": "File manager",
5
5
  "displayName.ru-RU": "Менеджер файлов",
6
6
  "displayName.zh-CN": "文件管理器",
@@ -35,7 +35,7 @@
35
35
  "multer": "^2.1.1",
36
36
  "multer-s3": "^3.0.1",
37
37
  "multistream": "^4.1.0",
38
- "pdfjs-dist": "^5.3.31",
38
+ "pdfjs-dist": "^6.2.108",
39
39
  "react": "^18.2.0",
40
40
  "react-i18next": "^11.15.1",
41
41
  "supertest": "^6.1.6",
@@ -62,5 +62,5 @@
62
62
  "Collections",
63
63
  "Collection fields"
64
64
  ],
65
- "gitHead": "82ecd3aed067e4cc98c32e7a0039b6e55cee76a7"
65
+ "gitHead": "99aeb1bc859eb31d9710073d761ac72c97341e9d"
66
66
  }
@@ -1,10 +0,0 @@
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
-
10
- "use strict";(self.webpackChunk_nocobase_plugin_file_manager_client_v2=self.webpackChunk_nocobase_plugin_file_manager_client_v2||[]).push([["125"],{212:function(e,t,n){n.r(t),n.d(t,{DisplayPreviewFieldModel:function(){return _},FilePreview:function(){return E},getFileCollectionReference:function(){return j}});var r=n(477),o=n(485),l=n(694),i=n(59),a=n(773),c=n(155),u=n.n(c),f=n(23);function s(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 p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function y(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){p(e,t,n[t])})}return e}function b(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],i=!0,a=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);i=!0);}catch(e){a=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return s(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 s(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 g(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function w(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(w=function(){return!!e})()}function O(){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 O=function(){return n},n}var S=function(e){return"string"==typeof e&&e.length>0},j=function(e,t){if((null==e?void 0:e.interface)==="attachmentURL"&&e.target)return{dataSourceKey:(null==t?void 0:t.dataSourceKey)||"main",collectionName:e.target};var n=(null==e?void 0:e.targetCollection)||((null==t?void 0:t.template)==="file"?t:null);return n?{dataSourceKey:n.dataSourceKey||"main",collectionName:n.name}:void 0},P=function(e,t){if(!S(e)||!(t&&(void 0===t?"undefined":g(t))==="object"&&!Array.isArray(t)))return e;var n=t.url,r=t.preview;return n!==e&&r!==e?e:b(y({},t),{url:S(n)?n:e,preview:S(r)?r:e})},E=function(e){var t=e.file,n=e.size,o=e.showFileName,l=e.onClick,a=(0,f._H)(t),c=(0,f.q)(a);if(!c)return null;var s=(0,f.WP)(a,c),p=(0,f._Y)(a,c),d=(0,f.qk)(a)||p,m={border:"1px solid #d9d9d9",padding:2,borderRadius:4,objectFit:"cover",boxShadow:"0 0 0 2px #fff"},y=(0,f._b)(a,"image/*"),b=u().createElement("div",{className:(0,r.css)(O())},y?u().createElement("img",{src:d,alt:s,width:n,height:n,style:m}):u().createElement(i.Image,{src:d,fallback:p,width:n,height:n,preview:!1,style:m}));return u().createElement("div",{onClick:l,style:{textAlign:"center",width:n,wordBreak:"break-all",cursor:l?"pointer":"default"}},b,o&&u().createElement(i.Tooltip,{title:s},u().createElement("div",{style:{fontSize:12,marginTop:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%"}},s)))},k=function(e){var t=e.value,n=void 0===t?[]:t,r=e.size,o=void 0===r?28:r,l=e.showFileName,c=e.record,s=e.fileCollection,p=v(u().useState(0),2),d=p[0],m=p[1],y=v(u().useState(!1),2),b=y[0],h=y[1],g=u().useMemo(function(){return(0,a.castArray)(n).filter(Boolean).map(function(e){return P(e,c)}).map(f._H).filter(function(e){return(0,f.q)(e)})},[c,n]);u().useEffect(function(){d>=g.length&&g.length&&m(0)},[d,g.length]),u().useEffect(function(){!g.length&&b&&h(!1)},[g.length,b]);var w=u().useCallback(function(e){var t=e||g[d];if(t){var n=t.url||t.preview;n&&(0,f.Ns)(n,(0,f.ub)(t,n))}},[d,g]),O=u().useCallback(function(e){m(e),h(!0)},[]),S=u().useCallback(function(e){e<0||e>=g.length||m(e)},[g.length]);return u().createElement(u().Fragment,null,u().createElement(i.Space,{wrap:!0},g.map(function(e,t){return u().createElement(E,{file:e,size:o,key:t,showFileName:l,onClick:function(){return O(t)}})})),g[d]?u().createElement(f.Mo,{open:b,file:g[d],index:d,list:g,fileCollection:s,onOpenChange:h,onClose:function(){return h(!1)},onSwitchIndex:S,onDownload:w}):null)},_=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=d(t),p(e=function(e,t){if(t&&("object"===g(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,w()?Reflect.construct(t,r||[],d(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&&h(n,e),t=[{key:"render",value:function(){var e=this,t=this.props,n=t.value,r=t.titleField,o=t.template,l=t.target,i=this.context.record,c=j(this.context.collectionField,this.context.collection);return r&&"file"!==o&&"attachments"!==l?(0,a.castArray)(n).flatMap(function(t,n){var o=null==t?void 0:t[r],l=o?u().createElement(k,b(y({key:n},e.props),{fileCollection:c,record:t,value:(0,a.castArray)(o).filter(Boolean)})):u().createElement("span",{key:n},"N/A");return 0===n?[l]:[u().createElement("span",{key:"sep-".concat(n)},", "),l]}):u().createElement(k,b(y({},this.props),{fileCollection:c,record:i,value:(0,a.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);_.registerFlow({key:"previewReadPrettySetting",sort:500,title:(0,l.tExpr)("Preview Settings"),steps:{size:{title:(0,l.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 m(e.model.parent,o.TableColumnModel)},defaultParams:function(e){return{size:m(e.model.parent,o.DetailsItemModel)?100:28}},handler:function(e,t){e.model.setProps("size",t.size)}},showFileName:{title:(0,l.tExpr)("Show file name"),uiMode:{type:"switch",key:"showFileName"},hideInSettings:function(e){return m(e.model.parent,o.TableColumnModel)},defaultParams:{showFileName:!1},handler:function(e,t){e.model.setProps("showFileName",t.showFileName)}}}}),_.define({label:(0,l.tExpr)("Preview")}),l.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}})}}]);