laif-ds 0.2.71 → 0.2.73

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.
@@ -1,10 +1,10 @@
1
1
  "use client";
2
- function i(t) {
2
+ function n(t) {
3
3
  if (!t) return "";
4
- const e = t.split(/[?#]/)[0].split("/").pop() || "", s = e.lastIndexOf(".");
5
- return s >= 0 ? e.substring(s + 1).toLowerCase() : "";
4
+ const s = t.split(/[?#]/)[0].split("/").pop() || "", e = s.lastIndexOf(".");
5
+ return e >= 0 ? s.substring(e + 1).toLowerCase() : "";
6
6
  }
7
- const o = /* @__PURE__ */ new Set([
7
+ const l = /* @__PURE__ */ new Set([
8
8
  "jpg",
9
9
  "jpeg",
10
10
  "png",
@@ -13,29 +13,108 @@ const o = /* @__PURE__ */ new Set([
13
13
  "bmp",
14
14
  "svg",
15
15
  "tiff"
16
- ]), a = /* @__PURE__ */ new Set(["pdf"]), r = /* @__PURE__ */ new Set(["txt", "md", "csv", "log", "json"]), c = /* @__PURE__ */ new Set(["mp3", "wav", "ogg", "m4a", "aac"]), f = /* @__PURE__ */ new Set(["mp4", "webm", "ogv", "mov"]);
17
- function p(t) {
16
+ ]), x = /* @__PURE__ */ new Set(["pdf"]), u = /* @__PURE__ */ new Set(["txt", "md", "csv", "log", "json"]), p = /* @__PURE__ */ new Set(["mp3", "wav", "ogg", "m4a", "aac"]), m = /* @__PURE__ */ new Set(["mp4", "webm", "ogv", "mov"]);
17
+ function h(t) {
18
18
  return !!t && /^(https?:)?\/\//i.test(t);
19
19
  }
20
- function u(t) {
20
+ function C(t) {
21
21
  return `https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(t)}`;
22
22
  }
23
- function d({
23
+ function v({
24
24
  mimeType: t,
25
- filename: n,
26
- url: e
25
+ filename: o,
26
+ url: s
27
27
  }) {
28
- const s = i(n || e);
29
- return t?.startsWith("image/") || o.has(s) ? "image" : t === "application/pdf" || a.has(s) ? "pdf" : t?.startsWith("audio/") || c.has(s) ? "audio" : t?.startsWith("video/") || f.has(s) ? "video" : r.has(s) || t?.startsWith("text/") ? "text" : "office";
28
+ const e = n(o || s);
29
+ return t?.startsWith("image/") || l.has(e) ? "image" : t === "application/pdf" || x.has(e) ? "pdf" : t?.startsWith("audio/") || p.has(e) ? "audio" : t?.startsWith("video/") || m.has(e) ? "video" : u.has(e) || t?.startsWith("text/") ? "text" : "office";
30
30
  }
31
+ const a = (t) => "type" in t && typeof t.type == "string" && t instanceof File, d = (t) => t.name || "url" in t && t.url || "", g = (t) => {
32
+ if (a(t)) return t.type || "";
33
+ const o = t.type;
34
+ return typeof o == "string" ? o : "";
35
+ }, N = (t, o) => {
36
+ const s = {
37
+ pdf: { iconName: "FileText", colorClass: "text-red-600" },
38
+ doc: { iconName: "FileText", colorClass: "text-blue-600" },
39
+ docx: { iconName: "FileText", colorClass: "text-blue-600" },
40
+ ppt: { iconName: "FileText", colorClass: "text-orange-600" },
41
+ pptx: { iconName: "FileText", colorClass: "text-orange-600" },
42
+ txt: { iconName: "FileText", colorClass: "text-gray-600" },
43
+ md: { iconName: "FileText", colorClass: "text-gray-600" }
44
+ }, e = (r, i) => r.forEach((c) => s[c] = i);
45
+ return e(["xls", "xlsx", "csv"], {
46
+ iconName: "FileSpreadsheet",
47
+ colorClass: "text-green-600"
48
+ }), e(["zip", "rar", "7z", "tar", "gz", "tgz"], {
49
+ iconName: "FileArchive",
50
+ colorClass: "text-amber-600"
51
+ }), e(["mp3", "wav", "ogg", "flac", "m4a"], {
52
+ iconName: "FileAudio",
53
+ colorClass: "text-violet-600"
54
+ }), e(["mp4", "mov", "avi", "mkv", "webm"], {
55
+ iconName: "FileVideo",
56
+ colorClass: "text-rose-600"
57
+ }), e(
58
+ [
59
+ "js",
60
+ "ts",
61
+ "jsx",
62
+ "tsx",
63
+ "json",
64
+ "xml",
65
+ "yml",
66
+ "yaml",
67
+ "html",
68
+ "css",
69
+ "scss"
70
+ ],
71
+ {
72
+ iconName: "FileCode",
73
+ colorClass: "text-indigo-600"
74
+ }
75
+ ), t && s[t] ? s[t] : o?.startsWith("audio/") ? { iconName: "FileAudio", colorClass: "text-violet-600" } : o?.startsWith("video/") ? { iconName: "FileVideo", colorClass: "text-rose-600" } : o?.startsWith("text/") ? {
76
+ iconName: "FileText",
77
+ colorClass: "text-gray-600 dark:text-gray-400"
78
+ } : o?.startsWith("image/") ? {
79
+ iconName: "FileImage",
80
+ colorClass: "text-teal-600 dark:text-teal-500"
81
+ } : { iconName: "FileIcon", colorClass: "text-d-secondary-foreground" };
82
+ }, f = (t) => {
83
+ if (!Number.isFinite(t) || t < 0) return "";
84
+ if (t === 0) return "0B";
85
+ const o = ["B", "KB", "MB", "GB", "TB"], s = Math.min(
86
+ Math.floor(Math.log(t) / Math.log(1024)),
87
+ o.length - 1
88
+ ), e = t / 1024 ** s, r = s > 0 && e < 100 ? 2 : 0;
89
+ return `${e.toFixed(r)}${o[s]}`;
90
+ }, F = (t) => {
91
+ const o = n(d(t));
92
+ if (o) return o.toUpperCase();
93
+ const s = g(t);
94
+ if (!s) return "";
95
+ if (s === "application/pdf") return "PDF";
96
+ const [e, r] = s.split("/");
97
+ return e === "image" ? r?.toUpperCase() || "IMAGE" : e === "audio" || e === "video" || e === "text" ? e.toUpperCase() : /(officedocument|msword|ms-excel|ms-powerpoint)/.test(s) ? "OFFICE" : "";
98
+ }, w = (t) => {
99
+ const o = a(t) ? f(t.size) : "", s = F(t);
100
+ return { sizeLabel: o, formatLabel: s };
101
+ }, b = (t, o) => t && o ? `${t} · ${o}` : t || o || null;
31
102
  export {
32
- c as audioExts,
33
- i as getExt,
34
- u as getOfficeEmbedUrl,
35
- d as guessKind,
36
- o as imageExts,
37
- p as isHttpUrl,
38
- a as pdfExts,
39
- r as textExts,
40
- f as videoExts
103
+ p as audioExts,
104
+ f as formatBytes,
105
+ b as formatMetadata,
106
+ n as getExt,
107
+ w as getFileMetadata,
108
+ N as getFormatIcon,
109
+ F as getFormatLabel,
110
+ g as getMimeFromFile,
111
+ d as getNameOrUrl,
112
+ C as getOfficeEmbedUrl,
113
+ v as guessKind,
114
+ l as imageExts,
115
+ a as isFile,
116
+ h as isHttpUrl,
117
+ x as pdfExts,
118
+ u as textExts,
119
+ m as videoExts
41
120
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __module as x } from "../../_virtual/index6.js";
2
+ import { __module as x } from "../../_virtual/index7.js";
3
3
  var w;
4
4
  function O() {
5
5
  return w ? x.exports : (w = 1, (function(d) {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __exports as r } from "../../../_virtual/index7.js";
2
+ import { __exports as r } from "../../../_virtual/index6.js";
3
3
  import { __require as c } from "../../inline-style-parser/index.js";
4
4
  var f;
5
5
  function j() {