@ozguraltan/strapi-content-input 1.0.8 → 1.0.9

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.
@@ -2,8 +2,8 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import React, { useState, useMemo, useRef, createContext, useContext, useEffect } from "react";
3
3
  import { createPortal } from "react-dom";
4
4
  import cloneDeep from "lodash/cloneDeep";
5
- import { M as MaterialIcon } from "./index-BIwC3VPC.mjs";
6
- import { useFetchClient } from "@strapi/strapi/admin";
5
+ import { M as MaterialIcon } from "./index-DzJ89qyO.mjs";
6
+ import { useFetchClient, useStrapiApp } from "@strapi/strapi/admin";
7
7
  const ROW_PRESETS = [
8
8
  {
9
9
  id: "12",
@@ -3183,6 +3183,9 @@ const RichHtmlEditor = ({
3183
3183
  const tr = locale === "tr";
3184
3184
  const effectivePlaceholder = placeholder || (tr ? "Metin içeriğinizi buraya yazın..." : "Type your text content here...");
3185
3185
  const { get, post } = useFetchClient();
3186
+ const components = useStrapiApp("RichHtmlEditor", (state) => state.components);
3187
+ const NativeMediaLibraryDialog = components?.["media-library"];
3188
+ const [nativePickerOpen, setNativePickerOpen] = useState(false);
3186
3189
  const [sourceMode, setSourceMode] = useState(false);
3187
3190
  const editorRef = useRef(null);
3188
3191
  const isFocusedRef = useRef(false);
@@ -3292,9 +3295,14 @@ const RichHtmlEditor = ({
3292
3295
  setLinkDownload(false);
3293
3296
  setLinkDownloadName("");
3294
3297
  }
3295
- setShowMediaBrowser(openWithMedia);
3296
- if (openWithMedia) {
3297
- loadMediaLibrary();
3298
+ if (openWithMedia && NativeMediaLibraryDialog) {
3299
+ setShowMediaBrowser(false);
3300
+ setNativePickerOpen(true);
3301
+ } else {
3302
+ setShowMediaBrowser(openWithMedia);
3303
+ if (openWithMedia) {
3304
+ loadMediaLibrary();
3305
+ }
3298
3306
  }
3299
3307
  setLinkModalOpen(true);
3300
3308
  };
@@ -3782,7 +3790,7 @@ const RichHtmlEditor = ({
3782
3790
  position: "fixed",
3783
3791
  inset: 0,
3784
3792
  background: "rgba(15, 23, 42, 0.55)",
3785
- zIndex: 11e3,
3793
+ zIndex: 260,
3786
3794
  display: "flex",
3787
3795
  alignItems: "center",
3788
3796
  justifyContent: "center",
@@ -3907,6 +3915,10 @@ const RichHtmlEditor = ({
3907
3915
  {
3908
3916
  type: "button",
3909
3917
  onClick: () => {
3918
+ if (NativeMediaLibraryDialog) {
3919
+ setNativePickerOpen(true);
3920
+ return;
3921
+ }
3910
3922
  const next = !showMediaBrowser;
3911
3923
  setShowMediaBrowser(next);
3912
3924
  if (next && mediaFiles.length === 0) {
@@ -4383,6 +4395,20 @@ const RichHtmlEditor = ({
4383
4395
  }
4384
4396
  ),
4385
4397
  document.body
4398
+ ),
4399
+ nativePickerOpen && NativeMediaLibraryDialog && /* @__PURE__ */ jsx(
4400
+ NativeMediaLibraryDialog,
4401
+ {
4402
+ allowedTypes: ["files", "images", "videos", "audios"],
4403
+ multiple: false,
4404
+ onClose: () => setNativePickerOpen(false),
4405
+ onSelectAssets: (selectedAssets) => {
4406
+ if (Array.isArray(selectedAssets) && selectedAssets.length > 0) {
4407
+ selectMediaFileForLink(selectedAssets[0]);
4408
+ }
4409
+ setNativePickerOpen(false);
4410
+ }
4411
+ }
4386
4412
  )
4387
4413
  ]
4388
4414
  }
@@ -5353,7 +5379,7 @@ const TabAccordionEditor = ({ widget, onChange }) => {
5353
5379
  style: {
5354
5380
  position: "fixed",
5355
5381
  inset: 0,
5356
- zIndex: 10030,
5382
+ zIndex: 215,
5357
5383
  background: "rgba(15, 23, 42, 0.65)",
5358
5384
  display: "flex",
5359
5385
  alignItems: "center",
@@ -6905,6 +6931,24 @@ function resolveYoutubeVideoId(raw) {
6905
6931
  if (extracted === "dQw4w9WgXcQ") return "M7lc1UVf-VE";
6906
6932
  return extracted;
6907
6933
  }
6934
+ function buildSharpImageUrl(rawUrl, imageSettings) {
6935
+ if (!rawUrl) return "";
6936
+ if (!imageSettings || !imageSettings.process) return rawUrl;
6937
+ const proc = String(imageSettings.process).toLowerCase();
6938
+ if (proc !== "fit" && proc !== "widen") return rawUrl;
6939
+ const w = Number(imageSettings.cWidth) || 0;
6940
+ const h = Number(imageSettings.cHeight) || 0;
6941
+ if (w <= 0 && h <= 0) return rawUrl;
6942
+ if (rawUrl.includes("/api/content-input/image") || rawUrl.includes("/content-input/image")) {
6943
+ return rawUrl;
6944
+ }
6945
+ const params = new URLSearchParams();
6946
+ params.set("src", rawUrl);
6947
+ params.set("process", proc);
6948
+ if (w > 0) params.set("w", String(w));
6949
+ if (proc === "fit" && h > 0) params.set("h", String(h));
6950
+ return `/api/content-input/image?${params.toString()}`;
6951
+ }
6908
6952
  const WidgetPreview = ({
6909
6953
  widget,
6910
6954
  isEditing,
@@ -7154,7 +7198,7 @@ const WidgetPreview = ({
7154
7198
  const imgProcess = imageSettings.process || "";
7155
7199
  const customW = Number(imageSettings.cWidth) || 0;
7156
7200
  const customH = Number(imageSettings.cHeight) || 0;
7157
- const imgObjectFit = imgProcess === "fit" ? "contain" : "cover";
7201
+ const imgObjectFit = "cover";
7158
7202
  if (images.length === 0) {
7159
7203
  return /* @__PURE__ */ jsxs(
7160
7204
  "div",
@@ -7192,7 +7236,7 @@ const WidgetPreview = ({
7192
7236
  position: "fixed",
7193
7237
  inset: 0,
7194
7238
  background: "rgba(15, 23, 42, 0.86)",
7195
- zIndex: 11500,
7239
+ zIndex: 280,
7196
7240
  display: "flex",
7197
7241
  alignItems: "center",
7198
7242
  justifyContent: "center",
@@ -7385,7 +7429,7 @@ const WidgetPreview = ({
7385
7429
  children: /* @__PURE__ */ jsx(
7386
7430
  "img",
7387
7431
  {
7388
- src: img.target_url || img.url,
7432
+ src: buildSharpImageUrl(img.target_url || img.url, imageSettings),
7389
7433
  alt: img.caption || `${t("widgets.gallery.label")} ${i + 1}`,
7390
7434
  style: {
7391
7435
  width: "100%",
@@ -7415,18 +7459,17 @@ const WidgetPreview = ({
7415
7459
  const itemIndex = (safeIdx + offset) % images.length;
7416
7460
  return { item: images[itemIndex], index: itemIndex };
7417
7461
  });
7418
- const containerHeight = customH > 0 ? Math.min(customH, 380) : 220;
7462
+ const slideAspectRatio = imgProcess === "fit" && customW > 0 && customH > 0 ? `${customW} / ${customH}` : slidesPerView > 1 ? "4 / 3" : "16 / 9";
7419
7463
  return /* @__PURE__ */ jsxs(Fragment, { children: [
7420
7464
  /* @__PURE__ */ jsxs(
7421
7465
  "div",
7422
7466
  {
7423
7467
  style: {
7424
7468
  position: "relative",
7469
+ width: "100%",
7425
7470
  borderRadius: 6,
7426
7471
  overflow: "hidden",
7427
7472
  background: "#0f172a",
7428
- height: containerHeight,
7429
- maxWidth: customW > 0 ? `${customW}px` : void 0,
7430
7473
  cursor: grabCursor ? "grab" : isPopupEnabled ? "zoom-in" : "default"
7431
7474
  },
7432
7475
  children: [
@@ -7435,15 +7478,15 @@ const WidgetPreview = ({
7435
7478
  {
7436
7479
  style: {
7437
7480
  display: "grid",
7438
- gridTemplateColumns: `repeat(${slidesPerView}, 1fr)`,
7481
+ gridTemplateColumns: `repeat(${slidesPerView}, minmax(0, 1fr))`,
7439
7482
  gap: spaceBetween,
7440
7483
  width: "100%",
7441
- height: "100%",
7442
7484
  padding: slidesPerView > 1 && spaceBetween > 0 ? 4 : 0,
7443
7485
  boxSizing: "border-box"
7444
7486
  },
7445
7487
  children: visibleSlides.map(({ item, index }) => {
7446
- const slideUrl = item?.target_url || item?.url || "";
7488
+ const rawSlideUrl = item?.target_url || item?.url || "";
7489
+ const slideUrl = buildSharpImageUrl(rawSlideUrl, imageSettings);
7447
7490
  return /* @__PURE__ */ jsx(
7448
7491
  "div",
7449
7492
  {
@@ -7456,7 +7499,7 @@ const WidgetPreview = ({
7456
7499
  style: {
7457
7500
  position: "relative",
7458
7501
  width: "100%",
7459
- height: "100%",
7502
+ aspectRatio: slideAspectRatio,
7460
7503
  overflow: "hidden",
7461
7504
  borderRadius: slidesPerView > 1 ? 4 : 0,
7462
7505
  background: "#1e293b"
@@ -7891,7 +7934,7 @@ const WidgetPreview = ({
7891
7934
  position: "fixed",
7892
7935
  inset: 0,
7893
7936
  background: "rgba(15, 23, 42, 0.82)",
7894
- zIndex: 11500,
7937
+ zIndex: 280,
7895
7938
  display: "flex",
7896
7939
  alignItems: "center",
7897
7940
  justifyContent: "center",
@@ -11471,11 +11514,17 @@ const UnitInput = ({
11471
11514
  function getFileKey(file) {
11472
11515
  return String(file?.id ?? file?.documentId ?? file?.url ?? file?.name ?? "");
11473
11516
  }
11474
- function mapStrapiFileToAsset(file) {
11475
- const srcset = file?.formats ? Object.values(file.formats).filter((f) => f && f.url && f.width).map((f) => `${f.url} ${f.width}w`).join(", ") : "";
11517
+ function mapStrapiFileToAsset(file, cacheBust) {
11518
+ const appendBust = (u) => {
11519
+ if (!u || !cacheBust) return u;
11520
+ const sep = u.includes("?") ? "&" : "?";
11521
+ return `${u}${sep}v=${Date.now()}`;
11522
+ };
11523
+ const srcset = file?.formats ? Object.values(file.formats).filter((f) => f && f.url && f.width).map((f) => `${appendBust(f.url)} ${f.width}w`).join(", ") : "";
11524
+ const finalUrl = appendBust(file.url || "");
11476
11525
  return {
11477
- target_url: file.url || "",
11478
- url: file.url || "",
11526
+ target_url: finalUrl,
11527
+ url: finalUrl,
11479
11528
  filename: file.name || file.filename || "media",
11480
11529
  mime_type: file.mime || file.mime_type || "application/octet-stream",
11481
11530
  size: file.size || 0,
@@ -11485,6 +11534,14 @@ function mapStrapiFileToAsset(file) {
11485
11534
  srcset: srcset || void 0
11486
11535
  };
11487
11536
  }
11537
+ const ASPECT_PRESETS = [
11538
+ { label: "Free", ratio: null },
11539
+ { label: "1:1", ratio: 1 },
11540
+ { label: "16:9", ratio: 16 / 9 },
11541
+ { label: "4:3", ratio: 4 / 3 },
11542
+ { label: "3:2", ratio: 3 / 2 },
11543
+ { label: "4:5", ratio: 4 / 5 }
11544
+ ];
11488
11545
  const StrapiMediaPicker = ({
11489
11546
  value,
11490
11547
  onChange,
@@ -11492,16 +11549,43 @@ const StrapiMediaPicker = ({
11492
11549
  multiple = false,
11493
11550
  onSelectMultiple
11494
11551
  }) => {
11495
- const { t } = useEditorTranslator();
11496
- const { get, post } = useFetchClient();
11552
+ const { t, locale } = useEditorTranslator();
11553
+ const tr = locale === "tr";
11554
+ const { get, post, put, del } = useFetchClient();
11497
11555
  const [modalOpen, setModalOpen] = useState(false);
11498
11556
  const [files, setFiles] = useState([]);
11557
+ const [folders, setFolders] = useState([]);
11558
+ const [currentFolderId, setCurrentFolderId] = useState(null);
11499
11559
  const [selectedFiles, setSelectedFiles] = useState([]);
11500
11560
  const [loading, setLoading] = useState(false);
11501
11561
  const [uploading, setUploading] = useState(false);
11502
11562
  const [search, setSearch] = useState("");
11503
- const [urlInput, setUrlInput] = useState(value?.target_url || value?.url || "");
11563
+ const [typeFilter, setTypeFilter] = useState("all");
11564
+ const [sortBy, setSortBy] = useState(
11565
+ "newest"
11566
+ );
11567
+ const [creatingFolder, setCreatingFolder] = useState(false);
11568
+ const [newFolderName, setNewFolderName] = useState("");
11569
+ const [editingFile, setEditingFile] = useState(null);
11570
+ const [editTab, setEditTab] = useState("crop");
11571
+ const [editName, setEditName] = useState("");
11572
+ const [editAlt, setEditAlt] = useState("");
11573
+ const [editCaption, setEditCaption] = useState("");
11574
+ const [editFolderId, setEditFolderId] = useState(null);
11575
+ const [savingDetails, setSavingDetails] = useState(false);
11576
+ const [naturalSize, setNaturalSize] = useState({
11577
+ width: 0,
11578
+ height: 0
11579
+ });
11580
+ const [cropRect, setCropRect] = useState({ x: 0, y: 0, width: 100, height: 100 });
11581
+ const [cropRotate, setCropRotate] = useState(0);
11582
+ const [aspectPreset, setAspectPreset] = useState(null);
11583
+ const [croppingBusy, setCroppingBusy] = useState(false);
11584
+ const [cropError, setCropError] = useState(null);
11585
+ const cropImgRef = useRef(null);
11586
+ const cropBoxRef = useRef(null);
11504
11587
  const fileInputRef = useRef(null);
11588
+ const [urlInput, setUrlInput] = useState(value?.target_url || value?.url || "");
11505
11589
  const effectiveLabel = label !== void 0 ? label : t("media.selectImage", "Select Image");
11506
11590
  useEffect(() => {
11507
11591
  setUrlInput(value?.target_url || value?.url || "");
@@ -11511,33 +11595,71 @@ const StrapiMediaPicker = ({
11511
11595
  try {
11512
11596
  const res = await get("/content-input/media");
11513
11597
  const primaryList = Array.isArray(res?.data?.data) ? res.data.data : Array.isArray(res?.data) ? res.data : null;
11598
+ const folderList = Array.isArray(res?.data?.folders) ? res.data.folders : [];
11599
+ if (folderList.length > 0) {
11600
+ setFolders(folderList);
11601
+ }
11514
11602
  if (primaryList) {
11515
11603
  setFiles(primaryList);
11516
- return;
11604
+ setLoading(false);
11605
+ return primaryList;
11517
11606
  }
11518
11607
  } catch {
11519
11608
  }
11520
11609
  try {
11521
- const fallbackRes = await get("/upload/files?pageSize=100&page=1");
11610
+ const fallbackRes = await get("/upload/files?pageSize=200&page=1");
11522
11611
  const fallbackList = Array.isArray(fallbackRes?.data?.results) ? fallbackRes.data.results : Array.isArray(fallbackRes?.data) ? fallbackRes.data : [];
11523
11612
  setFiles(fallbackList);
11613
+ return fallbackList;
11524
11614
  } catch {
11525
11615
  setFiles([]);
11616
+ return [];
11526
11617
  } finally {
11527
11618
  setLoading(false);
11528
11619
  }
11529
11620
  };
11530
- useEffect(() => {
11531
- if (!modalOpen) return;
11532
- setLoading(false);
11533
- }, [files, modalOpen]);
11621
+ const openEditorForFile = (file, initialTab = "crop") => {
11622
+ setEditingFile(file);
11623
+ setEditTab(file?.mime?.startsWith("image/") ? initialTab : "details");
11624
+ setEditName(file?.name || "");
11625
+ setEditAlt(file?.alternativeText || "");
11626
+ setEditCaption(file?.caption || "");
11627
+ setEditFolderId(file?.folder?.id ?? file?.folder ?? null);
11628
+ setCropRotate(0);
11629
+ setAspectPreset(null);
11630
+ setCropError(null);
11631
+ const w = Number(file?.width) || 800;
11632
+ const h = Number(file?.height) || 600;
11633
+ setNaturalSize({ width: w, height: h });
11634
+ setCropRect({
11635
+ x: 0,
11636
+ y: 0,
11637
+ width: w,
11638
+ height: h
11639
+ });
11640
+ };
11534
11641
  const handleOpenModal = (e) => {
11535
11642
  e.preventDefault();
11536
11643
  e.stopPropagation();
11537
11644
  setSelectedFiles([]);
11645
+ setEditingFile(null);
11538
11646
  setModalOpen(true);
11539
11647
  loadLibrary().finally(() => setLoading(false));
11540
11648
  };
11649
+ const handleOpenCropCurrent = async (e) => {
11650
+ e.preventDefault();
11651
+ e.stopPropagation();
11652
+ const currentUrl = (value?.target_url || value?.url || "").split("?")[0];
11653
+ if (!currentUrl) return;
11654
+ setModalOpen(true);
11655
+ const loaded = files.length > 0 ? files : await loadLibrary();
11656
+ const match = loaded.find(
11657
+ (f) => f.url && f.url.split("?")[0] === currentUrl || value?.filename && f.name === value.filename
11658
+ );
11659
+ if (match) {
11660
+ openEditorForFile(match, "crop");
11661
+ }
11662
+ };
11541
11663
  const toggleFileSelection = (file) => {
11542
11664
  const key = getFileKey(file);
11543
11665
  setSelectedFiles((prev) => {
@@ -11550,7 +11672,7 @@ const StrapiMediaPicker = ({
11550
11672
  };
11551
11673
  const handleConfirmMultiple = () => {
11552
11674
  if (selectedFiles.length === 0) return;
11553
- const assets = selectedFiles.map(mapStrapiFileToAsset);
11675
+ const assets = selectedFiles.map((f) => mapStrapiFileToAsset(f));
11554
11676
  if (onSelectMultiple) {
11555
11677
  onSelectMultiple(assets);
11556
11678
  } else {
@@ -11568,19 +11690,26 @@ const StrapiMediaPicker = ({
11568
11690
  for (let i = 0; i < inputFiles.length; i++) {
11569
11691
  formData.append("files", inputFiles[i]);
11570
11692
  }
11693
+ if (currentFolderId) {
11694
+ formData.append("fileInfo", JSON.stringify({ folder: currentFolderId }));
11695
+ }
11571
11696
  const res = await post("/upload", formData);
11572
11697
  const uploadedList = Array.isArray(res?.data) ? res.data : Array.isArray(res?.data?.data) ? res.data.data : [];
11573
11698
  await loadLibrary();
11574
11699
  if (uploadedList.length > 0) {
11575
- if (multiple) {
11576
- const assets = uploadedList.map(mapStrapiFileToAsset);
11577
- if (onSelectMultiple) {
11578
- onSelectMultiple(assets);
11700
+ if (!modalOpen) {
11701
+ if (multiple) {
11702
+ const assets = uploadedList.map((f) => mapStrapiFileToAsset(f));
11703
+ if (onSelectMultiple) {
11704
+ onSelectMultiple(assets);
11705
+ } else {
11706
+ assets.forEach((a) => onChange(a));
11707
+ }
11579
11708
  } else {
11580
- assets.forEach((a) => onChange(a));
11709
+ onChange(mapStrapiFileToAsset(uploadedList[0]));
11581
11710
  }
11582
- setSelectedFiles([]);
11583
- setModalOpen(false);
11711
+ } else if (multiple) {
11712
+ setSelectedFiles((prev) => [...prev, ...uploadedList]);
11584
11713
  } else {
11585
11714
  onChange(mapStrapiFileToAsset(uploadedList[0]));
11586
11715
  setModalOpen(false);
@@ -11593,6 +11722,175 @@ const StrapiMediaPicker = ({
11593
11722
  if (fileInputRef.current) fileInputRef.current.value = "";
11594
11723
  }
11595
11724
  };
11725
+ const handleCreateFolder = async () => {
11726
+ const trimmed = newFolderName.trim();
11727
+ if (!trimmed) return;
11728
+ try {
11729
+ const res = await post("/content-input/media/folder", {
11730
+ name: trimmed,
11731
+ parent: currentFolderId
11732
+ });
11733
+ const created = res?.data?.data || res?.data;
11734
+ setNewFolderName("");
11735
+ setCreatingFolder(false);
11736
+ await loadLibrary();
11737
+ if (created?.id) {
11738
+ setCurrentFolderId(Number(created.id));
11739
+ }
11740
+ } catch {
11741
+ }
11742
+ };
11743
+ const handleSaveDetails = async () => {
11744
+ if (!editingFile?.id) return;
11745
+ setSavingDetails(true);
11746
+ try {
11747
+ const res = await put(`/content-input/media/${editingFile.id}`, {
11748
+ name: editName.trim() || editingFile.name,
11749
+ alternativeText: editAlt,
11750
+ caption: editCaption,
11751
+ folder: editFolderId
11752
+ });
11753
+ const updated = res?.data?.data || res?.data;
11754
+ await loadLibrary();
11755
+ if (updated) {
11756
+ setEditingFile(updated);
11757
+ }
11758
+ } catch {
11759
+ } finally {
11760
+ setSavingDetails(false);
11761
+ }
11762
+ };
11763
+ const handleDeleteAsset = async (file, e) => {
11764
+ if (e) {
11765
+ e.preventDefault();
11766
+ e.stopPropagation();
11767
+ }
11768
+ if (!file?.id) return;
11769
+ const confirmMsg = tr ? `"${file.name}" dosyasını Strapi Medya Kütüphanesinden kalıcı olarak silmek istediğinize emin misiniz?` : `Are you sure you want to permanently delete "${file.name}" from the Strapi Media Library?`;
11770
+ if (typeof window !== "undefined" && !window.confirm(confirmMsg)) return;
11771
+ try {
11772
+ await del(`/content-input/media/${file.id}`);
11773
+ setSelectedFiles((prev) => prev.filter((f) => getFileKey(f) !== getFileKey(file)));
11774
+ if (editingFile?.id === file.id) {
11775
+ setEditingFile(null);
11776
+ }
11777
+ await loadLibrary();
11778
+ } catch {
11779
+ }
11780
+ };
11781
+ const handleExecuteCrop = async (mode) => {
11782
+ if (!editingFile?.id) return;
11783
+ setCroppingBusy(true);
11784
+ setCropError(null);
11785
+ try {
11786
+ const res = await post("/content-input/media/crop", {
11787
+ id: editingFile.id,
11788
+ mode,
11789
+ x: Math.round(cropRect.x),
11790
+ y: Math.round(cropRect.y),
11791
+ width: Math.round(cropRect.width),
11792
+ height: Math.round(cropRect.height),
11793
+ rotate: cropRotate,
11794
+ name: editName.trim() || editingFile.name,
11795
+ alternativeText: editAlt,
11796
+ caption: editCaption
11797
+ });
11798
+ const resultFile = res?.data?.data || res?.data;
11799
+ await loadLibrary();
11800
+ if (resultFile) {
11801
+ const mapped = mapStrapiFileToAsset(resultFile, true);
11802
+ if (multiple && onSelectMultiple) {
11803
+ onSelectMultiple([mapped]);
11804
+ } else {
11805
+ onChange(mapped);
11806
+ }
11807
+ setEditingFile(null);
11808
+ setModalOpen(false);
11809
+ }
11810
+ } catch (err) {
11811
+ setCropError(err?.message || (tr ? "Kırpma işlemi başarısız oldu" : "Crop operation failed"));
11812
+ } finally {
11813
+ setCroppingBusy(false);
11814
+ }
11815
+ };
11816
+ const applyAspectPreset = (ratio) => {
11817
+ setAspectPreset(ratio);
11818
+ if (!ratio || !naturalSize.width || !naturalSize.height) return;
11819
+ let newW = naturalSize.width;
11820
+ let newH = Math.round(newW / ratio);
11821
+ if (newH > naturalSize.height) {
11822
+ newH = naturalSize.height;
11823
+ newW = Math.round(newH * ratio);
11824
+ }
11825
+ const newX = Math.max(0, Math.round((naturalSize.width - newW) / 2));
11826
+ const newY = Math.max(0, Math.round((naturalSize.height - newH) / 2));
11827
+ setCropRect({ x: newX, y: newY, width: newW, height: newH });
11828
+ };
11829
+ const startCropDrag = (e, dragType) => {
11830
+ e.preventDefault();
11831
+ e.stopPropagation();
11832
+ const container = cropBoxRef.current;
11833
+ if (!container || !naturalSize.width || !naturalSize.height) return;
11834
+ const bounds = container.getBoundingClientRect();
11835
+ if (!bounds.width || !bounds.height) return;
11836
+ const scaleX = naturalSize.width / bounds.width;
11837
+ const scaleY = naturalSize.height / bounds.height;
11838
+ const startClientX = e.clientX;
11839
+ const startClientY = e.clientY;
11840
+ const initial = { ...cropRect };
11841
+ const onMove = (ev) => {
11842
+ const dx = (ev.clientX - startClientX) * scaleX;
11843
+ const dy = (ev.clientY - startClientY) * scaleY;
11844
+ if (dragType === "move") {
11845
+ const nextX = Math.max(
11846
+ 0,
11847
+ Math.min(naturalSize.width - initial.width, Math.round(initial.x + dx))
11848
+ );
11849
+ const nextY = Math.max(
11850
+ 0,
11851
+ Math.min(naturalSize.height - initial.height, Math.round(initial.y + dy))
11852
+ );
11853
+ setCropRect({ ...initial, x: nextX, y: nextY });
11854
+ return;
11855
+ }
11856
+ let x = initial.x;
11857
+ let y = initial.y;
11858
+ let w = initial.width;
11859
+ let h = initial.height;
11860
+ if (dragType.includes("e")) {
11861
+ w = Math.max(20, Math.min(naturalSize.width - x, Math.round(initial.width + dx)));
11862
+ }
11863
+ if (dragType.includes("s")) {
11864
+ h = Math.max(20, Math.min(naturalSize.height - y, Math.round(initial.height + dy)));
11865
+ }
11866
+ if (dragType.includes("w")) {
11867
+ const maxDx = initial.width - 20;
11868
+ const clampedDx = Math.max(-initial.x, Math.min(maxDx, Math.round(dx)));
11869
+ x = initial.x + clampedDx;
11870
+ w = initial.width - clampedDx;
11871
+ }
11872
+ if (dragType.includes("n")) {
11873
+ const maxDy = initial.height - 20;
11874
+ const clampedDy = Math.max(-initial.y, Math.min(maxDy, Math.round(dy)));
11875
+ y = initial.y + clampedDy;
11876
+ h = initial.height - clampedDy;
11877
+ }
11878
+ if (aspectPreset) {
11879
+ h = Math.round(w / aspectPreset);
11880
+ if (y + h > naturalSize.height) {
11881
+ h = naturalSize.height - y;
11882
+ w = Math.round(h * aspectPreset);
11883
+ }
11884
+ }
11885
+ setCropRect({ x, y, width: Math.max(16, w), height: Math.max(16, h) });
11886
+ };
11887
+ const onUp = () => {
11888
+ window.removeEventListener("mousemove", onMove);
11889
+ window.removeEventListener("mouseup", onUp);
11890
+ };
11891
+ window.addEventListener("mousemove", onMove);
11892
+ window.addEventListener("mouseup", onUp);
11893
+ };
11596
11894
  const handleUrlApply = () => {
11597
11895
  const trimmed = urlInput.trim();
11598
11896
  if (!trimmed) {
@@ -11628,9 +11926,39 @@ const StrapiMediaPicker = ({
11628
11926
  };
11629
11927
  const previewUrl = value?.target_url || value?.url || "";
11630
11928
  const q = search.trim().toLowerCase();
11631
- const filteredFiles = files.filter(
11632
- (f) => !q || (f.name || "").toLowerCase().includes(q) || (f.ext || "").toLowerCase().includes(q) || (f.mime || "").toLowerCase().includes(q)
11633
- );
11929
+ const visibleFolders = folders.filter((fld) => {
11930
+ const parentId = fld.parent?.id ?? fld.parent ?? null;
11931
+ return parentId === currentFolderId;
11932
+ });
11933
+ const currentFolderObj = currentFolderId !== null ? folders.find((f) => Number(f.id) === currentFolderId) : null;
11934
+ const filteredFiles = files.filter((f) => {
11935
+ if (!q && currentFolderId !== null) {
11936
+ const fileFolderId = f.folder?.id ?? f.folder ?? null;
11937
+ if (Number(fileFolderId) !== currentFolderId) return false;
11938
+ }
11939
+ if (typeFilter === "image" && !f.mime?.startsWith("image/")) return false;
11940
+ if (typeFilter === "video" && !f.mime?.startsWith("video/")) return false;
11941
+ if (typeFilter === "audio" && !f.mime?.startsWith("audio/")) return false;
11942
+ if (typeFilter === "doc" && (f.mime?.startsWith("image/") || f.mime?.startsWith("video/") || f.mime?.startsWith("audio/"))) {
11943
+ return false;
11944
+ }
11945
+ if (!q) return true;
11946
+ return (f.name || "").toLowerCase().includes(q) || (f.alternativeText || "").toLowerCase().includes(q) || (f.caption || "").toLowerCase().includes(q) || (f.ext || "").toLowerCase().includes(q) || (f.mime || "").toLowerCase().includes(q);
11947
+ }).sort((a, b) => {
11948
+ if (sortBy === "oldest") {
11949
+ return new Date(a.createdAt || 0).getTime() - new Date(b.createdAt || 0).getTime();
11950
+ }
11951
+ if (sortBy === "nameAsc") {
11952
+ return String(a.name || "").localeCompare(String(b.name || ""));
11953
+ }
11954
+ if (sortBy === "nameDesc") {
11955
+ return String(b.name || "").localeCompare(String(a.name || ""));
11956
+ }
11957
+ if (sortBy === "sizeDesc") {
11958
+ return (Number(b.size) || 0) - (Number(a.size) || 0);
11959
+ }
11960
+ return new Date(b.createdAt || 0).getTime() - new Date(a.createdAt || 0).getTime();
11961
+ });
11634
11962
  return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
11635
11963
  effectiveLabel && /* @__PURE__ */ jsx("label", { style: { fontSize: 12, fontWeight: 600, color: "#475569" }, children: effectiveLabel }),
11636
11964
  previewUrl ? /* @__PURE__ */ jsxs(
@@ -11676,7 +12004,7 @@ const StrapiMediaPicker = ({
11676
12004
  children: value?.filename || t("common.image", "Image")
11677
12005
  }
11678
12006
  ),
11679
- /* @__PURE__ */ jsx(
12007
+ /* @__PURE__ */ jsxs(
11680
12008
  "div",
11681
12009
  {
11682
12010
  style: {
@@ -11686,10 +12014,33 @@ const StrapiMediaPicker = ({
11686
12014
  textOverflow: "ellipsis",
11687
12015
  whiteSpace: "nowrap"
11688
12016
  },
11689
- children: previewUrl
12017
+ children: [
12018
+ value?.width && value?.height ? `${value.width}×${value.height} · ` : "",
12019
+ previewUrl
12020
+ ]
11690
12021
  }
11691
12022
  )
11692
12023
  ] }),
12024
+ /* @__PURE__ */ jsx(
12025
+ "button",
12026
+ {
12027
+ type: "button",
12028
+ onClick: handleOpenCropCurrent,
12029
+ title: tr ? "Görseli Kırp / Düzenle" : "Crop / Edit Image",
12030
+ style: {
12031
+ border: "1px solid #cbd5e1",
12032
+ borderRadius: 4,
12033
+ background: "#ffffff",
12034
+ color: "#2669a0",
12035
+ cursor: "pointer",
12036
+ padding: 4,
12037
+ display: "inline-flex",
12038
+ alignItems: "center",
12039
+ justifyContent: "center"
12040
+ },
12041
+ children: /* @__PURE__ */ jsx(MaterialIcon, { name: "crop", size: 15, color: "#2669a0" })
12042
+ }
12043
+ ),
11693
12044
  /* @__PURE__ */ jsx(
11694
12045
  "button",
11695
12046
  {
@@ -11738,6 +12089,44 @@ const StrapiMediaPicker = ({
11738
12089
  }
11739
12090
  }
11740
12091
  ),
12092
+ /* @__PURE__ */ jsx(
12093
+ "input",
12094
+ {
12095
+ ref: fileInputRef,
12096
+ type: "file",
12097
+ multiple,
12098
+ onChange: handleFileUpload,
12099
+ style: { display: "none" }
12100
+ }
12101
+ ),
12102
+ /* @__PURE__ */ jsx(
12103
+ "button",
12104
+ {
12105
+ type: "button",
12106
+ disabled: uploading,
12107
+ onClick: (e) => {
12108
+ e.preventDefault();
12109
+ e.stopPropagation();
12110
+ fileInputRef.current?.click();
12111
+ },
12112
+ title: t("media.uploadNew", "Upload New File(s)"),
12113
+ style: {
12114
+ display: "inline-flex",
12115
+ alignItems: "center",
12116
+ justifyContent: "center",
12117
+ padding: "6px 9px",
12118
+ fontSize: 12,
12119
+ fontWeight: 600,
12120
+ background: "#ffffff",
12121
+ color: "#2669a0",
12122
+ border: "1px solid #cbd5e1",
12123
+ borderRadius: 5,
12124
+ cursor: uploading ? "wait" : "pointer",
12125
+ whiteSpace: "nowrap"
12126
+ },
12127
+ children: /* @__PURE__ */ jsx(MaterialIcon, { name: "upload_file", size: 16, color: "#2669a0" })
12128
+ }
12129
+ ),
11741
12130
  /* @__PURE__ */ jsxs(
11742
12131
  "button",
11743
12132
  {
@@ -11772,27 +12161,31 @@ const StrapiMediaPicker = ({
11772
12161
  style: {
11773
12162
  position: "fixed",
11774
12163
  inset: 0,
11775
- background: "rgba(15, 23, 42, 0.6)",
11776
- zIndex: 11e3,
12164
+ background: "rgba(15, 23, 42, 0.65)",
12165
+ zIndex: 310,
11777
12166
  display: "flex",
11778
12167
  alignItems: "center",
11779
12168
  justifyContent: "center",
11780
- padding: 24
12169
+ padding: 20
11781
12170
  },
11782
12171
  onClick: (e) => {
11783
12172
  e.stopPropagation();
11784
- setModalOpen(false);
12173
+ if (editingFile) {
12174
+ setEditingFile(null);
12175
+ } else {
12176
+ setModalOpen(false);
12177
+ }
11785
12178
  },
11786
12179
  children: /* @__PURE__ */ jsxs(
11787
12180
  "div",
11788
12181
  {
11789
12182
  style: {
11790
12183
  width: "100%",
11791
- maxWidth: 780,
11792
- maxHeight: "84vh",
12184
+ maxWidth: 960,
12185
+ height: "min(720px, 90vh)",
11793
12186
  background: "#fff",
11794
- borderRadius: 8,
11795
- boxShadow: "0 24px 48px rgba(0,0,0,0.3)",
12187
+ borderRadius: 10,
12188
+ boxShadow: "0 24px 56px rgba(0,0,0,0.35)",
11796
12189
  display: "flex",
11797
12190
  flexDirection: "column",
11798
12191
  overflow: "hidden"
@@ -11809,86 +12202,125 @@ const StrapiMediaPicker = ({
11809
12202
  padding: "12px 18px",
11810
12203
  borderBottom: "1px solid #e2e8f0",
11811
12204
  background: "#f8fafc",
11812
- gap: 10
12205
+ gap: 10,
12206
+ flexWrap: "wrap"
11813
12207
  },
11814
12208
  children: [
11815
12209
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
11816
- /* @__PURE__ */ jsx(MaterialIcon, { name: "collections", size: 18, color: "#2669a0" }),
11817
- /* @__PURE__ */ jsxs("strong", { style: { fontSize: 14, color: "#0f172a" }, children: [
11818
- t("media.libraryTitle", "Strapi Media Library"),
11819
- " (",
11820
- files.length,
11821
- " ",
11822
- t("media.filesCount", "files"),
11823
- ")"
11824
- ] })
11825
- ] }),
11826
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
11827
- /* @__PURE__ */ jsxs(
12210
+ editingFile ? /* @__PURE__ */ jsxs(
11828
12211
  "button",
11829
12212
  {
11830
12213
  type: "button",
11831
- onClick: () => loadLibrary().finally(() => setLoading(false)),
11832
- title: t("media.refresh", "Refresh"),
12214
+ onClick: () => setEditingFile(null),
11833
12215
  style: {
11834
12216
  display: "inline-flex",
11835
12217
  alignItems: "center",
11836
12218
  gap: 4,
11837
- padding: "6px 10px",
12219
+ padding: "4px 8px",
12220
+ borderRadius: 5,
12221
+ border: "1px solid #cbd5e1",
11838
12222
  background: "#ffffff",
11839
12223
  color: "#334155",
11840
- border: "1px solid #cbd5e1",
11841
- borderRadius: 5,
11842
12224
  fontSize: 12,
11843
12225
  fontWeight: 600,
11844
12226
  cursor: "pointer"
11845
12227
  },
11846
12228
  children: [
11847
- /* @__PURE__ */ jsx(MaterialIcon, { name: "refresh", size: 15 }),
11848
- t("media.refresh", "Refresh")
12229
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "arrow_back", size: 15 }),
12230
+ tr ? "Kütüphaneye Dön" : "Back to Library"
11849
12231
  ]
11850
12232
  }
11851
- ),
12233
+ ) : /* @__PURE__ */ jsx(MaterialIcon, { name: "collections", size: 18, color: "#2669a0" }),
12234
+ /* @__PURE__ */ jsx("strong", { style: { fontSize: 14, color: "#0f172a" }, children: editingFile ? `${tr ? "Görsel Düzenle & Kırp" : "Edit & Crop Asset"}: ${editingFile.name}` : `${t("media.libraryTitle", "Strapi Media Library")} (${filteredFiles.length} ${t(
12235
+ "media.filesCount",
12236
+ "files"
12237
+ )})` })
12238
+ ] }),
12239
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
12240
+ !editingFile && /* @__PURE__ */ jsxs(Fragment, { children: [
12241
+ /* @__PURE__ */ jsxs(
12242
+ "button",
12243
+ {
12244
+ type: "button",
12245
+ onClick: () => setCreatingFolder((v) => !v),
12246
+ style: {
12247
+ display: "inline-flex",
12248
+ alignItems: "center",
12249
+ gap: 4,
12250
+ padding: "6px 10px",
12251
+ background: "#ffffff",
12252
+ color: "#334155",
12253
+ border: "1px solid #cbd5e1",
12254
+ borderRadius: 5,
12255
+ fontSize: 12,
12256
+ fontWeight: 600,
12257
+ cursor: "pointer"
12258
+ },
12259
+ children: [
12260
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "create_new_folder", size: 15, color: "#2669a0" }),
12261
+ tr ? "Yeni Klasör" : "New Folder"
12262
+ ]
12263
+ }
12264
+ ),
12265
+ /* @__PURE__ */ jsxs(
12266
+ "button",
12267
+ {
12268
+ type: "button",
12269
+ onClick: () => loadLibrary().finally(() => setLoading(false)),
12270
+ title: t("media.refresh", "Refresh"),
12271
+ style: {
12272
+ display: "inline-flex",
12273
+ alignItems: "center",
12274
+ gap: 4,
12275
+ padding: "6px 10px",
12276
+ background: "#ffffff",
12277
+ color: "#334155",
12278
+ border: "1px solid #cbd5e1",
12279
+ borderRadius: 5,
12280
+ fontSize: 12,
12281
+ fontWeight: 600,
12282
+ cursor: "pointer"
12283
+ },
12284
+ children: [
12285
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "refresh", size: 15 }),
12286
+ t("media.refresh", "Refresh")
12287
+ ]
12288
+ }
12289
+ ),
12290
+ /* @__PURE__ */ jsxs(
12291
+ "button",
12292
+ {
12293
+ type: "button",
12294
+ disabled: uploading,
12295
+ onClick: () => fileInputRef.current?.click(),
12296
+ style: {
12297
+ display: "inline-flex",
12298
+ alignItems: "center",
12299
+ gap: 5,
12300
+ padding: "6px 12px",
12301
+ background: "#2669a0",
12302
+ color: "#fff",
12303
+ border: "none",
12304
+ borderRadius: 5,
12305
+ fontSize: 12,
12306
+ fontWeight: 600,
12307
+ cursor: "pointer"
12308
+ },
12309
+ children: [
12310
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "upload_file", size: 15, color: "#fff" }),
12311
+ uploading ? t("media.uploading", "Uploading...") : t("media.uploadNew", "Upload New File(s)")
12312
+ ]
12313
+ }
12314
+ )
12315
+ ] }),
11852
12316
  /* @__PURE__ */ jsx(
11853
- "input",
11854
- {
11855
- ref: fileInputRef,
11856
- type: "file",
11857
- multiple: true,
11858
- onChange: handleFileUpload,
11859
- style: { display: "none" }
11860
- }
11861
- ),
11862
- /* @__PURE__ */ jsxs(
11863
12317
  "button",
11864
12318
  {
11865
12319
  type: "button",
11866
- disabled: uploading,
11867
- onClick: () => fileInputRef.current?.click(),
11868
- style: {
11869
- display: "inline-flex",
11870
- alignItems: "center",
11871
- gap: 5,
11872
- padding: "6px 12px",
11873
- background: "#2669a0",
11874
- color: "#fff",
11875
- border: "none",
11876
- borderRadius: 5,
11877
- fontSize: 12,
11878
- fontWeight: 600,
11879
- cursor: "pointer"
12320
+ onClick: () => {
12321
+ setEditingFile(null);
12322
+ setModalOpen(false);
11880
12323
  },
11881
- children: [
11882
- /* @__PURE__ */ jsx(MaterialIcon, { name: "upload_file", size: 15, color: "#fff" }),
11883
- uploading ? t("media.uploading", "Uploading...") : t("media.uploadNew", "Upload New File")
11884
- ]
11885
- }
11886
- ),
11887
- /* @__PURE__ */ jsx(
11888
- "button",
11889
- {
11890
- type: "button",
11891
- onClick: () => setModalOpen(false),
11892
12324
  style: {
11893
12325
  border: "none",
11894
12326
  background: "transparent",
@@ -11903,329 +12335,1258 @@ const StrapiMediaPicker = ({
11903
12335
  ]
11904
12336
  }
11905
12337
  ),
11906
- /* @__PURE__ */ jsxs(
11907
- "div",
11908
- {
11909
- style: {
11910
- padding: "10px 18px",
11911
- borderBottom: "1px solid #f1f5f9",
11912
- display: "flex",
11913
- alignItems: "center",
11914
- gap: 8
11915
- },
11916
- children: [
11917
- /* @__PURE__ */ jsx(
11918
- "input",
11919
- {
11920
- type: "text",
11921
- value: search,
11922
- onChange: (e) => setSearch(e.target.value),
11923
- placeholder: t("media.searchPlaceholder", "Search file name or extension..."),
11924
- style: {
11925
- flex: 1,
11926
- padding: "7px 10px",
11927
- fontSize: 12,
11928
- border: "1px solid #cbd5e1",
11929
- borderRadius: 5
11930
- }
11931
- }
11932
- ),
11933
- multiple && filteredFiles.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
11934
- /* @__PURE__ */ jsx(
11935
- "button",
12338
+ editingFile ? /* @__PURE__ */ jsxs("div", { style: { display: "flex", flex: 1, minHeight: 0, overflow: "hidden" }, children: [
12339
+ /* @__PURE__ */ jsxs(
12340
+ "div",
12341
+ {
12342
+ style: {
12343
+ flex: 1,
12344
+ background: "repeating-conic-gradient(#e2e8f0 0% 25%, #f8fafc 0% 50%) 50% / 20px 20px",
12345
+ display: "flex",
12346
+ flexDirection: "column",
12347
+ minWidth: 0,
12348
+ borderRight: "1px solid #e2e8f0"
12349
+ },
12350
+ children: [
12351
+ editingFile.mime?.startsWith("image/") && /* @__PURE__ */ jsxs(
12352
+ "div",
11936
12353
  {
11937
- type: "button",
11938
- onClick: () => {
11939
- const existingKeys = new Set(selectedFiles.map(getFileKey));
11940
- const additions = filteredFiles.filter(
11941
- (f) => !existingKeys.has(getFileKey(f))
11942
- );
11943
- setSelectedFiles([...selectedFiles, ...additions]);
11944
- },
11945
12354
  style: {
11946
- padding: "6px 10px",
11947
- fontSize: 11,
11948
- fontWeight: 600,
11949
- border: "1px solid #cbd5e1",
11950
- borderRadius: 5,
12355
+ display: "flex",
12356
+ alignItems: "center",
12357
+ justifyContent: "space-between",
12358
+ padding: "8px 14px",
11951
12359
  background: "#ffffff",
11952
- color: "#334155",
11953
- cursor: "pointer",
11954
- whiteSpace: "nowrap"
12360
+ borderBottom: "1px solid #e2e8f0",
12361
+ gap: 8,
12362
+ flexWrap: "wrap"
11955
12363
  },
11956
- children: t("selectAllVisible", "Select All")
12364
+ children: [
12365
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
12366
+ /* @__PURE__ */ jsx(
12367
+ "span",
12368
+ {
12369
+ style: {
12370
+ fontSize: 11,
12371
+ fontWeight: 700,
12372
+ color: "#475569",
12373
+ marginRight: 4
12374
+ },
12375
+ children: tr ? "En-Boy Oranı:" : "Aspect Ratio:"
12376
+ }
12377
+ ),
12378
+ ASPECT_PRESETS.map((preset) => {
12379
+ const active = aspectPreset === preset.ratio;
12380
+ return /* @__PURE__ */ jsx(
12381
+ "button",
12382
+ {
12383
+ type: "button",
12384
+ onClick: () => applyAspectPreset(preset.ratio),
12385
+ style: {
12386
+ padding: "4px 8px",
12387
+ fontSize: 11,
12388
+ fontWeight: 600,
12389
+ borderRadius: 4,
12390
+ border: active ? "1.5px solid #2669a0" : "1px solid #cbd5e1",
12391
+ background: active ? "#2669a0" : "#ffffff",
12392
+ color: active ? "#ffffff" : "#334155",
12393
+ cursor: "pointer"
12394
+ },
12395
+ children: preset.label === "Free" ? tr ? "Serbest" : "Free" : preset.label
12396
+ },
12397
+ preset.label
12398
+ );
12399
+ })
12400
+ ] }),
12401
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
12402
+ /* @__PURE__ */ jsxs(
12403
+ "button",
12404
+ {
12405
+ type: "button",
12406
+ onClick: () => setCropRotate((r) => (r - 90 + 360) % 360),
12407
+ title: tr ? "Sola Döndür (-90°)" : "Rotate Left (-90°)",
12408
+ style: {
12409
+ display: "inline-flex",
12410
+ alignItems: "center",
12411
+ gap: 3,
12412
+ padding: "4px 8px",
12413
+ fontSize: 11,
12414
+ fontWeight: 600,
12415
+ border: "1px solid #cbd5e1",
12416
+ borderRadius: 4,
12417
+ background: "#fff",
12418
+ color: "#334155",
12419
+ cursor: "pointer"
12420
+ },
12421
+ children: [
12422
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "rotate_left", size: 15 }),
12423
+ /* @__PURE__ */ jsx("span", { children: "-90°" })
12424
+ ]
12425
+ }
12426
+ ),
12427
+ /* @__PURE__ */ jsxs(
12428
+ "button",
12429
+ {
12430
+ type: "button",
12431
+ onClick: () => setCropRotate((r) => (r + 90) % 360),
12432
+ title: tr ? "Sağa Döndür (+90°)" : "Rotate Right (+90°)",
12433
+ style: {
12434
+ display: "inline-flex",
12435
+ alignItems: "center",
12436
+ gap: 3,
12437
+ padding: "4px 8px",
12438
+ fontSize: 11,
12439
+ fontWeight: 600,
12440
+ border: "1px solid #cbd5e1",
12441
+ borderRadius: 4,
12442
+ background: "#fff",
12443
+ color: "#334155",
12444
+ cursor: "pointer"
12445
+ },
12446
+ children: [
12447
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "rotate_right", size: 15 }),
12448
+ /* @__PURE__ */ jsx("span", { children: "+90°" })
12449
+ ]
12450
+ }
12451
+ ),
12452
+ /* @__PURE__ */ jsx(
12453
+ "button",
12454
+ {
12455
+ type: "button",
12456
+ onClick: () => {
12457
+ setCropRotate(0);
12458
+ setAspectPreset(null);
12459
+ setCropRect({
12460
+ x: 0,
12461
+ y: 0,
12462
+ width: naturalSize.width,
12463
+ height: naturalSize.height
12464
+ });
12465
+ },
12466
+ style: {
12467
+ padding: "4px 8px",
12468
+ fontSize: 11,
12469
+ fontWeight: 600,
12470
+ border: "1px solid #cbd5e1",
12471
+ borderRadius: 4,
12472
+ background: "#fff",
12473
+ color: "#64748b",
12474
+ cursor: "pointer"
12475
+ },
12476
+ children: tr ? "Sıfırla" : "Reset"
12477
+ }
12478
+ )
12479
+ ] })
12480
+ ]
11957
12481
  }
11958
12482
  ),
11959
- selectedFiles.length > 0 && /* @__PURE__ */ jsx(
11960
- "button",
12483
+ /* @__PURE__ */ jsx(
12484
+ "div",
11961
12485
  {
11962
- type: "button",
11963
- onClick: () => setSelectedFiles([]),
11964
12486
  style: {
11965
- padding: "6px 10px",
11966
- fontSize: 11,
11967
- fontWeight: 600,
11968
- border: "1px solid #fecaca",
11969
- borderRadius: 5,
11970
- background: "#fef2f2",
11971
- color: "#dc2626",
11972
- cursor: "pointer",
11973
- whiteSpace: "nowrap"
12487
+ flex: 1,
12488
+ display: "flex",
12489
+ alignItems: "center",
12490
+ justifyContent: "center",
12491
+ padding: 24,
12492
+ overflow: "hidden",
12493
+ position: "relative"
12494
+ },
12495
+ children: editingFile.mime?.startsWith("image/") ? /* @__PURE__ */ jsxs(
12496
+ "div",
12497
+ {
12498
+ ref: cropBoxRef,
12499
+ style: {
12500
+ position: "relative",
12501
+ display: "inline-block",
12502
+ maxWidth: "100%",
12503
+ maxHeight: "100%",
12504
+ boxShadow: "0 8px 24px rgba(15, 23, 42, 0.2)",
12505
+ userSelect: "none"
12506
+ },
12507
+ children: [
12508
+ /* @__PURE__ */ jsx(
12509
+ "img",
12510
+ {
12511
+ ref: cropImgRef,
12512
+ src: editingFile.url,
12513
+ alt: editingFile.name,
12514
+ onLoad: (e) => {
12515
+ const img = e.currentTarget;
12516
+ const nw = img.naturalWidth || editingFile.width || 800;
12517
+ const nh = img.naturalHeight || editingFile.height || 600;
12518
+ setNaturalSize({ width: nw, height: nh });
12519
+ setCropRect({ x: 0, y: 0, width: nw, height: nh });
12520
+ },
12521
+ style: {
12522
+ display: "block",
12523
+ maxWidth: "540px",
12524
+ maxHeight: "440px",
12525
+ width: "auto",
12526
+ height: "auto",
12527
+ transform: cropRotate ? `rotate(${cropRotate}deg)` : void 0,
12528
+ pointerEvents: "none"
12529
+ }
12530
+ }
12531
+ ),
12532
+ naturalSize.width > 0 && naturalSize.height > 0 && /* @__PURE__ */ jsxs(
12533
+ "div",
12534
+ {
12535
+ onMouseDown: (e) => startCropDrag(e, "move"),
12536
+ style: {
12537
+ position: "absolute",
12538
+ left: `${cropRect.x / naturalSize.width * 100}%`,
12539
+ top: `${cropRect.y / naturalSize.height * 100}%`,
12540
+ width: `${cropRect.width / naturalSize.width * 100}%`,
12541
+ height: `${cropRect.height / naturalSize.height * 100}%`,
12542
+ border: "2px dashed #38bdf8",
12543
+ boxShadow: "0 0 0 9999px rgba(15, 23, 42, 0.55)",
12544
+ cursor: "move",
12545
+ boxSizing: "border-box"
12546
+ },
12547
+ children: [
12548
+ /* @__PURE__ */ jsxs(
12549
+ "div",
12550
+ {
12551
+ style: {
12552
+ position: "absolute",
12553
+ top: 6,
12554
+ left: 6,
12555
+ background: "rgba(15, 23, 42, 0.85)",
12556
+ color: "#ffffff",
12557
+ fontSize: 10,
12558
+ fontWeight: 700,
12559
+ padding: "2px 6px",
12560
+ borderRadius: 4,
12561
+ pointerEvents: "none",
12562
+ whiteSpace: "nowrap"
12563
+ },
12564
+ children: [
12565
+ Math.round(cropRect.width),
12566
+ " × ",
12567
+ Math.round(cropRect.height),
12568
+ " px"
12569
+ ]
12570
+ }
12571
+ ),
12572
+ [
12573
+ { pos: "nw", top: -6, left: -6, cursor: "nwse-resize" },
12574
+ { pos: "ne", top: -6, right: -6, cursor: "nesw-resize" },
12575
+ { pos: "sw", bottom: -6, left: -6, cursor: "nesw-resize" },
12576
+ { pos: "se", bottom: -6, right: -6, cursor: "nwse-resize" }
12577
+ ].map((h) => /* @__PURE__ */ jsx(
12578
+ "div",
12579
+ {
12580
+ onMouseDown: (e) => startCropDrag(e, h.pos),
12581
+ style: {
12582
+ position: "absolute",
12583
+ top: "top" in h ? h.top : void 0,
12584
+ bottom: "bottom" in h ? h.bottom : void 0,
12585
+ left: "left" in h ? h.left : void 0,
12586
+ right: "right" in h ? h.right : void 0,
12587
+ width: 12,
12588
+ height: 12,
12589
+ background: "#ffffff",
12590
+ border: "2px solid #0284c7",
12591
+ borderRadius: 2,
12592
+ cursor: h.cursor
12593
+ }
12594
+ },
12595
+ h.pos
12596
+ ))
12597
+ ]
12598
+ }
12599
+ )
12600
+ ]
12601
+ }
12602
+ ) : /* @__PURE__ */ jsxs("div", { style: { textAlign: "center", color: "#475569" }, children: [
12603
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "description", size: 56, color: "#64748b" }),
12604
+ /* @__PURE__ */ jsx("div", { style: { marginTop: 8, fontWeight: 600 }, children: editingFile.name })
12605
+ ] })
12606
+ }
12607
+ )
12608
+ ]
12609
+ }
12610
+ ),
12611
+ /* @__PURE__ */ jsxs(
12612
+ "div",
12613
+ {
12614
+ style: {
12615
+ width: 320,
12616
+ background: "#ffffff",
12617
+ display: "flex",
12618
+ flexDirection: "column",
12619
+ overflowY: "auto",
12620
+ padding: 16,
12621
+ gap: 14
12622
+ },
12623
+ children: [
12624
+ editingFile.mime?.startsWith("image/") && /* @__PURE__ */ jsxs(
12625
+ "div",
12626
+ {
12627
+ style: {
12628
+ padding: 12,
12629
+ borderRadius: 8,
12630
+ background: "#f8fafc",
12631
+ border: "1px solid #cbd5e1",
12632
+ display: "flex",
12633
+ flexDirection: "column",
12634
+ gap: 10
12635
+ },
12636
+ children: [
12637
+ /* @__PURE__ */ jsxs(
12638
+ "div",
12639
+ {
12640
+ style: {
12641
+ fontSize: 11,
12642
+ fontWeight: 700,
12643
+ color: "#1e3a8a",
12644
+ textTransform: "uppercase",
12645
+ display: "flex",
12646
+ alignItems: "center",
12647
+ gap: 5
12648
+ },
12649
+ children: [
12650
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "crop", size: 15, color: "#2669a0" }),
12651
+ /* @__PURE__ */ jsx("span", { children: tr ? "Kırpma Boyutları (Sharp)" : "Crop Coordinates (Sharp)" })
12652
+ ]
12653
+ }
12654
+ ),
12655
+ /* @__PURE__ */ jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [
12656
+ /* @__PURE__ */ jsxs("div", { children: [
12657
+ /* @__PURE__ */ jsx("label", { style: { fontSize: 10, fontWeight: 600, color: "#64748b" }, children: tr ? "Genişlik (W px)" : "Width (W px)" }),
12658
+ /* @__PURE__ */ jsx(
12659
+ "input",
12660
+ {
12661
+ type: "number",
12662
+ min: 16,
12663
+ max: naturalSize.width || 1e4,
12664
+ value: Math.round(cropRect.width),
12665
+ onChange: (e) => setCropRect((prev) => ({
12666
+ ...prev,
12667
+ width: Math.max(16, Number(e.target.value) || 16)
12668
+ })),
12669
+ style: {
12670
+ width: "100%",
12671
+ padding: "5px 8px",
12672
+ fontSize: 12,
12673
+ border: "1px solid #cbd5e1",
12674
+ borderRadius: 4
12675
+ }
12676
+ }
12677
+ )
12678
+ ] }),
12679
+ /* @__PURE__ */ jsxs("div", { children: [
12680
+ /* @__PURE__ */ jsx("label", { style: { fontSize: 10, fontWeight: 600, color: "#64748b" }, children: tr ? "Yükseklik (H px)" : "Height (H px)" }),
12681
+ /* @__PURE__ */ jsx(
12682
+ "input",
12683
+ {
12684
+ type: "number",
12685
+ min: 16,
12686
+ max: naturalSize.height || 1e4,
12687
+ value: Math.round(cropRect.height),
12688
+ onChange: (e) => setCropRect((prev) => ({
12689
+ ...prev,
12690
+ height: Math.max(16, Number(e.target.value) || 16)
12691
+ })),
12692
+ style: {
12693
+ width: "100%",
12694
+ padding: "5px 8px",
12695
+ fontSize: 12,
12696
+ border: "1px solid #cbd5e1",
12697
+ borderRadius: 4
12698
+ }
12699
+ }
12700
+ )
12701
+ ] }),
12702
+ /* @__PURE__ */ jsxs("div", { children: [
12703
+ /* @__PURE__ */ jsx("label", { style: { fontSize: 10, fontWeight: 600, color: "#64748b" }, children: "X (Sol / Left px)" }),
12704
+ /* @__PURE__ */ jsx(
12705
+ "input",
12706
+ {
12707
+ type: "number",
12708
+ min: 0,
12709
+ value: Math.round(cropRect.x),
12710
+ onChange: (e) => setCropRect((prev) => ({
12711
+ ...prev,
12712
+ x: Math.max(0, Number(e.target.value) || 0)
12713
+ })),
12714
+ style: {
12715
+ width: "100%",
12716
+ padding: "5px 8px",
12717
+ fontSize: 12,
12718
+ border: "1px solid #cbd5e1",
12719
+ borderRadius: 4
12720
+ }
12721
+ }
12722
+ )
12723
+ ] }),
12724
+ /* @__PURE__ */ jsxs("div", { children: [
12725
+ /* @__PURE__ */ jsx("label", { style: { fontSize: 10, fontWeight: 600, color: "#64748b" }, children: "Y (Üst / Top px)" }),
12726
+ /* @__PURE__ */ jsx(
12727
+ "input",
12728
+ {
12729
+ type: "number",
12730
+ min: 0,
12731
+ value: Math.round(cropRect.y),
12732
+ onChange: (e) => setCropRect((prev) => ({
12733
+ ...prev,
12734
+ y: Math.max(0, Number(e.target.value) || 0)
12735
+ })),
12736
+ style: {
12737
+ width: "100%",
12738
+ padding: "5px 8px",
12739
+ fontSize: 12,
12740
+ border: "1px solid #cbd5e1",
12741
+ borderRadius: 4
12742
+ }
12743
+ }
12744
+ )
12745
+ ] })
12746
+ ] }),
12747
+ cropError && /* @__PURE__ */ jsx(
12748
+ "div",
12749
+ {
12750
+ style: {
12751
+ padding: "6px 8px",
12752
+ borderRadius: 4,
12753
+ background: "#fef2f2",
12754
+ color: "#dc2626",
12755
+ fontSize: 11
12756
+ },
12757
+ children: cropError
12758
+ }
12759
+ ),
12760
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 6 }, children: [
12761
+ /* @__PURE__ */ jsxs(
12762
+ "button",
12763
+ {
12764
+ type: "button",
12765
+ disabled: croppingBusy,
12766
+ onClick: () => handleExecuteCrop("duplicate"),
12767
+ style: {
12768
+ padding: "8px 12px",
12769
+ fontSize: 12,
12770
+ fontWeight: 700,
12771
+ borderRadius: 5,
12772
+ border: "none",
12773
+ background: "#2669a0",
12774
+ color: "#ffffff",
12775
+ cursor: croppingBusy ? "wait" : "pointer",
12776
+ display: "flex",
12777
+ alignItems: "center",
12778
+ justifyContent: "center",
12779
+ gap: 6
12780
+ },
12781
+ children: [
12782
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "content_copy", size: 15, color: "#fff" }),
12783
+ /* @__PURE__ */ jsx("span", { children: croppingBusy ? tr ? "İşleniyor..." : "Processing..." : tr ? "Kopyasını Oluştur & Kırp" : "Duplicate & Crop Asset" })
12784
+ ]
12785
+ }
12786
+ ),
12787
+ /* @__PURE__ */ jsxs(
12788
+ "button",
12789
+ {
12790
+ type: "button",
12791
+ disabled: croppingBusy,
12792
+ onClick: () => handleExecuteCrop("replace"),
12793
+ style: {
12794
+ padding: "7px 12px",
12795
+ fontSize: 12,
12796
+ fontWeight: 600,
12797
+ borderRadius: 5,
12798
+ border: "1px solid #2669a0",
12799
+ background: "#eff6ff",
12800
+ color: "#1e3a8a",
12801
+ cursor: croppingBusy ? "wait" : "pointer",
12802
+ display: "flex",
12803
+ alignItems: "center",
12804
+ justifyContent: "center",
12805
+ gap: 6
12806
+ },
12807
+ children: [
12808
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "crop", size: 15, color: "#1e3a8a" }),
12809
+ /* @__PURE__ */ jsx("span", { children: tr ? "Orijinal Görseli Kırp (Üzerine Yaz)" : "Crop Original Asset" })
12810
+ ]
12811
+ }
12812
+ )
12813
+ ] })
12814
+ ]
12815
+ }
12816
+ ),
12817
+ /* @__PURE__ */ jsxs(
12818
+ "div",
12819
+ {
12820
+ style: {
12821
+ display: "flex",
12822
+ flexDirection: "column",
12823
+ gap: 8,
12824
+ borderTop: "1px solid #e2e8f0",
12825
+ paddingTop: 12
12826
+ },
12827
+ children: [
12828
+ /* @__PURE__ */ jsx(
12829
+ "div",
12830
+ {
12831
+ style: {
12832
+ fontSize: 11,
12833
+ fontWeight: 700,
12834
+ color: "#334155",
12835
+ textTransform: "uppercase"
12836
+ },
12837
+ children: tr ? "Dosya Bilgileri (Metadata)" : "Asset Metadata"
12838
+ }
12839
+ ),
12840
+ /* @__PURE__ */ jsxs("div", { children: [
12841
+ /* @__PURE__ */ jsx("label", { style: { fontSize: 11, fontWeight: 600, color: "#475569" }, children: tr ? "Dosya Adı" : "File Name" }),
12842
+ /* @__PURE__ */ jsx(
12843
+ "input",
12844
+ {
12845
+ type: "text",
12846
+ value: editName,
12847
+ onChange: (e) => setEditName(e.target.value),
12848
+ style: {
12849
+ width: "100%",
12850
+ padding: "6px 8px",
12851
+ fontSize: 12,
12852
+ border: "1px solid #cbd5e1",
12853
+ borderRadius: 4,
12854
+ marginTop: 2
12855
+ }
12856
+ }
12857
+ )
12858
+ ] }),
12859
+ /* @__PURE__ */ jsxs("div", { children: [
12860
+ /* @__PURE__ */ jsx("label", { style: { fontSize: 11, fontWeight: 600, color: "#475569" }, children: tr ? "Alternatif Metin (Alt Text / SEO)" : "Alternative Text (Alt / SEO)" }),
12861
+ /* @__PURE__ */ jsx(
12862
+ "input",
12863
+ {
12864
+ type: "text",
12865
+ value: editAlt,
12866
+ onChange: (e) => setEditAlt(e.target.value),
12867
+ style: {
12868
+ width: "100%",
12869
+ padding: "6px 8px",
12870
+ fontSize: 12,
12871
+ border: "1px solid #cbd5e1",
12872
+ borderRadius: 4,
12873
+ marginTop: 2
12874
+ }
12875
+ }
12876
+ )
12877
+ ] }),
12878
+ /* @__PURE__ */ jsxs("div", { children: [
12879
+ /* @__PURE__ */ jsx("label", { style: { fontSize: 11, fontWeight: 600, color: "#475569" }, children: tr ? "Altyazı (Caption)" : "Caption" }),
12880
+ /* @__PURE__ */ jsx(
12881
+ "input",
12882
+ {
12883
+ type: "text",
12884
+ value: editCaption,
12885
+ onChange: (e) => setEditCaption(e.target.value),
12886
+ style: {
12887
+ width: "100%",
12888
+ padding: "6px 8px",
12889
+ fontSize: 12,
12890
+ border: "1px solid #cbd5e1",
12891
+ borderRadius: 4,
12892
+ marginTop: 2
12893
+ }
12894
+ }
12895
+ )
12896
+ ] }),
12897
+ folders.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
12898
+ /* @__PURE__ */ jsx("label", { style: { fontSize: 11, fontWeight: 600, color: "#475569" }, children: tr ? "Klasör Konumu" : "Folder Location" }),
12899
+ /* @__PURE__ */ jsxs(
12900
+ "select",
12901
+ {
12902
+ value: editFolderId ?? "",
12903
+ onChange: (e) => setEditFolderId(e.target.value ? Number(e.target.value) : null),
12904
+ style: {
12905
+ width: "100%",
12906
+ padding: "6px 8px",
12907
+ fontSize: 12,
12908
+ border: "1px solid #cbd5e1",
12909
+ borderRadius: 4,
12910
+ marginTop: 2,
12911
+ background: "#fff"
12912
+ },
12913
+ children: [
12914
+ /* @__PURE__ */ jsx("option", { value: "", children: tr ? "Ana Dizin (Root)" : "Media Library Root" }),
12915
+ folders.map((fld) => /* @__PURE__ */ jsx("option", { value: fld.id, children: fld.name }, fld.id))
12916
+ ]
12917
+ }
12918
+ )
12919
+ ] }),
12920
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 6, marginTop: 4 }, children: [
12921
+ /* @__PURE__ */ jsx(
12922
+ "button",
12923
+ {
12924
+ type: "button",
12925
+ disabled: savingDetails,
12926
+ onClick: handleSaveDetails,
12927
+ style: {
12928
+ flex: 1,
12929
+ padding: "7px 10px",
12930
+ fontSize: 12,
12931
+ fontWeight: 600,
12932
+ borderRadius: 5,
12933
+ border: "1px solid #cbd5e1",
12934
+ background: "#f8fafc",
12935
+ color: "#0f172a",
12936
+ cursor: "pointer"
12937
+ },
12938
+ children: savingDetails ? tr ? "Kaydediliyor..." : "Saving..." : tr ? "Bilgileri Kaydet" : "Save Metadata"
12939
+ }
12940
+ ),
12941
+ /* @__PURE__ */ jsx(
12942
+ "button",
12943
+ {
12944
+ type: "button",
12945
+ onClick: (e) => handleDeleteAsset(editingFile, e),
12946
+ title: tr ? "Dosyayı Kütüphaneden Sil" : "Delete from Media Library",
12947
+ style: {
12948
+ padding: "7px 10px",
12949
+ fontSize: 12,
12950
+ fontWeight: 600,
12951
+ borderRadius: 5,
12952
+ border: "1px solid #fecaca",
12953
+ background: "#fef2f2",
12954
+ color: "#dc2626",
12955
+ cursor: "pointer"
12956
+ },
12957
+ children: /* @__PURE__ */ jsx(MaterialIcon, { name: "delete_outline", size: 16, color: "#dc2626" })
12958
+ }
12959
+ )
12960
+ ] })
12961
+ ]
12962
+ }
12963
+ )
12964
+ ]
12965
+ }
12966
+ )
12967
+ ] }) : (
12968
+ /* VIEW 2: MEDIA LIBRARY BROWSER (Folders, Filters, Sort, Multi-Select, Item Actions) */
12969
+ /* @__PURE__ */ jsxs(Fragment, { children: [
12970
+ creatingFolder && /* @__PURE__ */ jsxs(
12971
+ "div",
12972
+ {
12973
+ style: {
12974
+ padding: "8px 18px",
12975
+ background: "#eff6ff",
12976
+ borderBottom: "1px solid #bfdbfe",
12977
+ display: "flex",
12978
+ alignItems: "center",
12979
+ gap: 8
12980
+ },
12981
+ children: [
12982
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "folder", size: 16, color: "#2669a0" }),
12983
+ /* @__PURE__ */ jsx(
12984
+ "input",
12985
+ {
12986
+ type: "text",
12987
+ value: newFolderName,
12988
+ onChange: (e) => setNewFolderName(e.target.value),
12989
+ onKeyDown: (e) => {
12990
+ if (e.key === "Enter") {
12991
+ e.preventDefault();
12992
+ handleCreateFolder();
12993
+ }
12994
+ },
12995
+ placeholder: tr ? "Yeni klasör adı yazın..." : "Enter new folder name...",
12996
+ style: {
12997
+ flex: 1,
12998
+ padding: "5px 10px",
12999
+ fontSize: 12,
13000
+ border: "1px solid #93c5fd",
13001
+ borderRadius: 4,
13002
+ background: "#fff"
13003
+ }
13004
+ }
13005
+ ),
13006
+ /* @__PURE__ */ jsx(
13007
+ "button",
13008
+ {
13009
+ type: "button",
13010
+ onClick: handleCreateFolder,
13011
+ style: {
13012
+ padding: "5px 12px",
13013
+ fontSize: 12,
13014
+ fontWeight: 600,
13015
+ background: "#2669a0",
13016
+ color: "#fff",
13017
+ border: "none",
13018
+ borderRadius: 4,
13019
+ cursor: "pointer"
13020
+ },
13021
+ children: tr ? "Oluştur" : "Create"
13022
+ }
13023
+ ),
13024
+ /* @__PURE__ */ jsx(
13025
+ "button",
13026
+ {
13027
+ type: "button",
13028
+ onClick: () => setCreatingFolder(false),
13029
+ style: {
13030
+ padding: "5px 10px",
13031
+ fontSize: 12,
13032
+ border: "1px solid #cbd5e1",
13033
+ background: "#fff",
13034
+ borderRadius: 4,
13035
+ cursor: "pointer"
13036
+ },
13037
+ children: tr ? "İptal" : "Cancel"
13038
+ }
13039
+ )
13040
+ ]
13041
+ }
13042
+ ),
13043
+ /* @__PURE__ */ jsxs(
13044
+ "div",
13045
+ {
13046
+ style: {
13047
+ padding: "10px 18px",
13048
+ borderBottom: "1px solid #f1f5f9",
13049
+ display: "flex",
13050
+ alignItems: "center",
13051
+ gap: 8,
13052
+ flexWrap: "wrap"
13053
+ },
13054
+ children: [
13055
+ /* @__PURE__ */ jsx(
13056
+ "input",
13057
+ {
13058
+ type: "text",
13059
+ value: search,
13060
+ onChange: (e) => setSearch(e.target.value),
13061
+ placeholder: t("media.searchPlaceholder", "Search file name or extension..."),
13062
+ style: {
13063
+ flex: 1,
13064
+ minWidth: 180,
13065
+ padding: "7px 10px",
13066
+ fontSize: 12,
13067
+ border: "1px solid #cbd5e1",
13068
+ borderRadius: 5
13069
+ }
13070
+ }
13071
+ ),
13072
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: 4 }, children: [
13073
+ { key: "all", label: tr ? "Tümü" : "All" },
13074
+ { key: "image", label: tr ? "Görsel" : "Images" },
13075
+ { key: "video", label: tr ? "Video" : "Videos" },
13076
+ { key: "doc", label: tr ? "Belge" : "Docs" }
13077
+ ].map((tf) => {
13078
+ const active = typeFilter === tf.key;
13079
+ return /* @__PURE__ */ jsx(
13080
+ "button",
13081
+ {
13082
+ type: "button",
13083
+ onClick: () => setTypeFilter(tf.key),
13084
+ style: {
13085
+ padding: "5px 9px",
13086
+ fontSize: 11,
13087
+ fontWeight: 600,
13088
+ borderRadius: 5,
13089
+ border: active ? "1.5px solid #2669a0" : "1px solid #cbd5e1",
13090
+ background: active ? "#eff6ff" : "#ffffff",
13091
+ color: active ? "#2669a0" : "#475569",
13092
+ cursor: "pointer"
13093
+ },
13094
+ children: tf.label
13095
+ },
13096
+ tf.key
13097
+ );
13098
+ }) }),
13099
+ /* @__PURE__ */ jsxs(
13100
+ "select",
13101
+ {
13102
+ value: sortBy,
13103
+ onChange: (e) => setSortBy(e.target.value),
13104
+ style: {
13105
+ padding: "6px 8px",
13106
+ fontSize: 11,
13107
+ fontWeight: 600,
13108
+ border: "1px solid #cbd5e1",
13109
+ borderRadius: 5,
13110
+ background: "#ffffff",
13111
+ color: "#334155"
13112
+ },
13113
+ children: [
13114
+ /* @__PURE__ */ jsx("option", { value: "newest", children: tr ? "En Yeni" : "Newest first" }),
13115
+ /* @__PURE__ */ jsx("option", { value: "oldest", children: tr ? "En Eski" : "Oldest first" }),
13116
+ /* @__PURE__ */ jsx("option", { value: "nameAsc", children: tr ? "Ad (A - Z)" : "Name (A - Z)" }),
13117
+ /* @__PURE__ */ jsx("option", { value: "nameDesc", children: tr ? "Ad (Z - A)" : "Name (Z - A)" }),
13118
+ /* @__PURE__ */ jsx("option", { value: "sizeDesc", children: tr ? "Boyut (Büyükten)" : "Size (Largest)" })
13119
+ ]
13120
+ }
13121
+ ),
13122
+ multiple && filteredFiles.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
13123
+ /* @__PURE__ */ jsx(
13124
+ "button",
13125
+ {
13126
+ type: "button",
13127
+ onClick: () => {
13128
+ const existingKeys = new Set(selectedFiles.map(getFileKey));
13129
+ const additions = filteredFiles.filter(
13130
+ (f) => !existingKeys.has(getFileKey(f))
13131
+ );
13132
+ setSelectedFiles([...selectedFiles, ...additions]);
13133
+ },
13134
+ style: {
13135
+ padding: "6px 10px",
13136
+ fontSize: 11,
13137
+ fontWeight: 600,
13138
+ border: "1px solid #cbd5e1",
13139
+ borderRadius: 5,
13140
+ background: "#ffffff",
13141
+ color: "#334155",
13142
+ cursor: "pointer",
13143
+ whiteSpace: "nowrap"
13144
+ },
13145
+ children: t("selectAllVisible", "Select All")
13146
+ }
13147
+ ),
13148
+ selectedFiles.length > 0 && /* @__PURE__ */ jsx(
13149
+ "button",
13150
+ {
13151
+ type: "button",
13152
+ onClick: () => setSelectedFiles([]),
13153
+ style: {
13154
+ padding: "6px 10px",
13155
+ fontSize: 11,
13156
+ fontWeight: 600,
13157
+ border: "1px solid #fecaca",
13158
+ borderRadius: 5,
13159
+ background: "#fef2f2",
13160
+ color: "#dc2626",
13161
+ cursor: "pointer",
13162
+ whiteSpace: "nowrap"
13163
+ },
13164
+ children: t("clearSelection", "Clear Selection")
13165
+ }
13166
+ )
13167
+ ] })
13168
+ ]
13169
+ }
13170
+ ),
13171
+ (folders.length > 0 || currentFolderId !== null) && /* @__PURE__ */ jsxs(
13172
+ "div",
13173
+ {
13174
+ style: {
13175
+ padding: "8px 18px",
13176
+ borderBottom: "1px solid #f1f5f9",
13177
+ background: "#f8fafc",
13178
+ display: "flex",
13179
+ alignItems: "center",
13180
+ gap: 6,
13181
+ flexWrap: "wrap"
13182
+ },
13183
+ children: [
13184
+ /* @__PURE__ */ jsxs(
13185
+ "button",
13186
+ {
13187
+ type: "button",
13188
+ onClick: () => setCurrentFolderId(null),
13189
+ style: {
13190
+ display: "inline-flex",
13191
+ alignItems: "center",
13192
+ gap: 4,
13193
+ padding: "4px 8px",
13194
+ fontSize: 11,
13195
+ fontWeight: 700,
13196
+ borderRadius: 4,
13197
+ border: currentFolderId === null ? "1.5px solid #2669a0" : "1px solid #cbd5e1",
13198
+ background: currentFolderId === null ? "#2669a0" : "#ffffff",
13199
+ color: currentFolderId === null ? "#ffffff" : "#334155",
13200
+ cursor: "pointer"
13201
+ },
13202
+ children: [
13203
+ /* @__PURE__ */ jsx(
13204
+ MaterialIcon,
13205
+ {
13206
+ name: "folder",
13207
+ size: 14,
13208
+ color: currentFolderId === null ? "#ffffff" : "#2669a0"
13209
+ }
13210
+ ),
13211
+ /* @__PURE__ */ jsx("span", { children: tr ? "Ana Dizin" : "Media Library" })
13212
+ ]
13213
+ }
13214
+ ),
13215
+ currentFolderObj && /* @__PURE__ */ jsxs(Fragment, { children: [
13216
+ /* @__PURE__ */ jsx("span", { style: { color: "#94a3b8", fontSize: 12 }, children: "/" }),
13217
+ /* @__PURE__ */ jsx(
13218
+ "span",
13219
+ {
13220
+ style: {
13221
+ fontSize: 12,
13222
+ fontWeight: 700,
13223
+ color: "#1e3a8a",
13224
+ padding: "3px 8px",
13225
+ background: "#dbeafe",
13226
+ borderRadius: 4
13227
+ },
13228
+ children: currentFolderObj.name
13229
+ }
13230
+ )
13231
+ ] }),
13232
+ visibleFolders.map((fld) => /* @__PURE__ */ jsxs(
13233
+ "button",
13234
+ {
13235
+ type: "button",
13236
+ onClick: () => setCurrentFolderId(Number(fld.id)),
13237
+ style: {
13238
+ display: "inline-flex",
13239
+ alignItems: "center",
13240
+ gap: 5,
13241
+ padding: "4px 10px",
13242
+ fontSize: 11,
13243
+ fontWeight: 600,
13244
+ borderRadius: 4,
13245
+ border: "1px solid #cbd5e1",
13246
+ background: "#ffffff",
13247
+ color: "#1e293b",
13248
+ cursor: "pointer"
13249
+ },
13250
+ children: [
13251
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "folder", size: 14, color: "#f59e0b" }),
13252
+ /* @__PURE__ */ jsx("span", { children: fld.name })
13253
+ ]
13254
+ },
13255
+ fld.id
13256
+ ))
13257
+ ]
13258
+ }
13259
+ ),
13260
+ /* @__PURE__ */ jsx("div", { style: { padding: 18, overflowY: "auto", flex: 1 }, children: loading ? /* @__PURE__ */ jsx(
13261
+ "div",
13262
+ {
13263
+ style: {
13264
+ textAlign: "center",
13265
+ padding: 32,
13266
+ color: "#64748b",
13267
+ fontSize: 13
13268
+ },
13269
+ children: t("media.loadingFiles", "Loading media files...")
13270
+ }
13271
+ ) : filteredFiles.length === 0 ? /* @__PURE__ */ jsx(
13272
+ "div",
13273
+ {
13274
+ style: {
13275
+ textAlign: "center",
13276
+ padding: 32,
13277
+ color: "#64748b",
13278
+ fontSize: 13
13279
+ },
13280
+ children: t(
13281
+ "media.noMatchingFiles",
13282
+ "No matching files found in the media library. Use the Upload New File button above to upload from your computer."
13283
+ )
13284
+ }
13285
+ ) : /* @__PURE__ */ jsx(
13286
+ "div",
13287
+ {
13288
+ style: {
13289
+ display: "grid",
13290
+ gridTemplateColumns: "repeat(auto-fill, minmax(160px, 1fr))",
13291
+ gap: 12
13292
+ },
13293
+ children: filteredFiles.map((file) => {
13294
+ const fileKey = getFileKey(file);
13295
+ const multiIndex = multiple ? selectedFiles.findIndex((f) => getFileKey(f) === fileKey) : -1;
13296
+ const isMultiSelected = multiIndex !== -1;
13297
+ const isCurrent = multiple ? isMultiSelected : Boolean(
13298
+ previewUrl && (file.url === previewUrl.split("?")[0] || file.name === value?.filename)
13299
+ );
13300
+ const thumbSrc = file.formats?.thumbnail?.url || file.formats?.small?.url || file.url || "";
13301
+ return /* @__PURE__ */ jsxs(
13302
+ "div",
13303
+ {
13304
+ onClick: () => {
13305
+ if (multiple) {
13306
+ toggleFileSelection(file);
13307
+ } else {
13308
+ onChange(mapStrapiFileToAsset(file));
13309
+ setModalOpen(false);
13310
+ }
13311
+ },
13312
+ onDoubleClick: () => {
13313
+ if (multiple) {
13314
+ const asset = mapStrapiFileToAsset(file);
13315
+ const listToCommit = selectedFiles.length > 0 ? selectedFiles.map((f) => mapStrapiFileToAsset(f)) : [asset];
13316
+ if (onSelectMultiple) {
13317
+ onSelectMultiple(listToCommit);
13318
+ } else {
13319
+ listToCommit.forEach((a) => onChange(a));
13320
+ }
13321
+ setSelectedFiles([]);
13322
+ setModalOpen(false);
13323
+ }
13324
+ },
13325
+ style: {
13326
+ border: isCurrent ? "2px solid #2669a0" : "1px solid #e2e8f0",
13327
+ borderRadius: 6,
13328
+ overflow: "hidden",
13329
+ cursor: "pointer",
13330
+ background: isCurrent ? "#eff6ff" : "#fff",
13331
+ boxShadow: isCurrent ? "0 0 0 2px rgba(38, 105, 160, 0.16)" : "0 1px 3px rgba(0,0,0,0.04)",
13332
+ userSelect: "none",
13333
+ display: "flex",
13334
+ flexDirection: "column"
13335
+ },
13336
+ children: [
13337
+ /* @__PURE__ */ jsxs(
13338
+ "div",
13339
+ {
13340
+ style: {
13341
+ height: 112,
13342
+ background: "#f1f5f9",
13343
+ display: "flex",
13344
+ alignItems: "center",
13345
+ justifyContent: "center",
13346
+ position: "relative"
13347
+ },
13348
+ children: [
13349
+ file.mime?.startsWith("image/") ? /* @__PURE__ */ jsx(
13350
+ "img",
13351
+ {
13352
+ src: thumbSrc,
13353
+ alt: file.name,
13354
+ style: { width: "100%", height: "100%", objectFit: "cover" }
13355
+ }
13356
+ ) : /* @__PURE__ */ jsx(MaterialIcon, { name: "description", size: 30, color: "#64748b" }),
13357
+ multiple ? /* @__PURE__ */ jsx(
13358
+ "span",
13359
+ {
13360
+ style: {
13361
+ position: "absolute",
13362
+ top: 6,
13363
+ left: 6,
13364
+ minWidth: 22,
13365
+ height: 22,
13366
+ padding: isMultiSelected ? "0 6px" : 0,
13367
+ borderRadius: 11,
13368
+ background: isMultiSelected ? "#2669a0" : "rgba(255, 255, 255, 0.9)",
13369
+ border: isMultiSelected ? "1.5px solid #ffffff" : "1.5px solid #94a3b8",
13370
+ color: "#ffffff",
13371
+ fontSize: 10,
13372
+ fontWeight: 700,
13373
+ display: "inline-flex",
13374
+ alignItems: "center",
13375
+ justifyContent: "center",
13376
+ boxShadow: "0 1px 3px rgba(0,0,0,0.2)"
13377
+ },
13378
+ children: isMultiSelected ? `✓ ${multiIndex + 1}` : ""
13379
+ }
13380
+ ) : isCurrent && /* @__PURE__ */ jsx(
13381
+ "span",
13382
+ {
13383
+ style: {
13384
+ position: "absolute",
13385
+ top: 5,
13386
+ left: 5,
13387
+ background: "#2669a0",
13388
+ color: "#fff",
13389
+ fontSize: 9,
13390
+ fontWeight: 700,
13391
+ padding: "2px 6px",
13392
+ borderRadius: 4
13393
+ },
13394
+ children: t("media.selectedBadge", "SELECTED")
13395
+ }
13396
+ ),
13397
+ /* @__PURE__ */ jsxs(
13398
+ "div",
13399
+ {
13400
+ style: {
13401
+ position: "absolute",
13402
+ top: 5,
13403
+ right: 5,
13404
+ display: "flex",
13405
+ gap: 4
13406
+ },
13407
+ onClick: (e) => e.stopPropagation(),
13408
+ children: [
13409
+ /* @__PURE__ */ jsx(
13410
+ "button",
13411
+ {
13412
+ type: "button",
13413
+ onClick: (e) => {
13414
+ e.stopPropagation();
13415
+ openEditorForFile(file, "crop");
13416
+ },
13417
+ title: file.mime?.startsWith("image/") ? tr ? "Görseli Kırp & Düzenle" : "Crop & Edit Image" : tr ? "Dosya Bilgilerini Düzenle" : "Edit File Details",
13418
+ style: {
13419
+ width: 24,
13420
+ height: 24,
13421
+ borderRadius: 4,
13422
+ border: "1px solid rgba(15,23,42,0.15)",
13423
+ background: "rgba(255,255,255,0.92)",
13424
+ color: "#1e293b",
13425
+ display: "inline-flex",
13426
+ alignItems: "center",
13427
+ justifyContent: "center",
13428
+ cursor: "pointer",
13429
+ padding: 0
13430
+ },
13431
+ children: /* @__PURE__ */ jsx(
13432
+ MaterialIcon,
13433
+ {
13434
+ name: file.mime?.startsWith("image/") ? "crop" : "edit",
13435
+ size: 14,
13436
+ color: "#2669a0"
13437
+ }
13438
+ )
13439
+ }
13440
+ ),
13441
+ /* @__PURE__ */ jsx(
13442
+ "button",
13443
+ {
13444
+ type: "button",
13445
+ onClick: (e) => handleDeleteAsset(file, e),
13446
+ title: tr ? "Kütüphaneden Sil" : "Delete from Library",
13447
+ style: {
13448
+ width: 24,
13449
+ height: 24,
13450
+ borderRadius: 4,
13451
+ border: "1px solid rgba(15,23,42,0.15)",
13452
+ background: "rgba(255,255,255,0.92)",
13453
+ color: "#dc2626",
13454
+ display: "inline-flex",
13455
+ alignItems: "center",
13456
+ justifyContent: "center",
13457
+ cursor: "pointer",
13458
+ padding: 0
13459
+ },
13460
+ children: /* @__PURE__ */ jsx(MaterialIcon, { name: "delete_outline", size: 14, color: "#dc2626" })
13461
+ }
13462
+ )
13463
+ ]
13464
+ }
13465
+ ),
13466
+ file.ext && /* @__PURE__ */ jsx(
13467
+ "span",
13468
+ {
13469
+ style: {
13470
+ position: "absolute",
13471
+ bottom: 4,
13472
+ right: 4,
13473
+ background: "rgba(15,23,42,0.75)",
13474
+ color: "#fff",
13475
+ fontSize: 9,
13476
+ fontWeight: 700,
13477
+ padding: "1px 5px",
13478
+ borderRadius: 3,
13479
+ textTransform: "uppercase"
13480
+ },
13481
+ children: file.ext.replace(".", "")
13482
+ }
13483
+ )
13484
+ ]
13485
+ }
13486
+ ),
13487
+ /* @__PURE__ */ jsxs("div", { style: { padding: "6px 8px" }, children: [
13488
+ /* @__PURE__ */ jsx(
13489
+ "div",
13490
+ {
13491
+ style: {
13492
+ fontSize: 11,
13493
+ fontWeight: 600,
13494
+ color: "#1e293b",
13495
+ overflow: "hidden",
13496
+ textOverflow: "ellipsis",
13497
+ whiteSpace: "nowrap"
13498
+ },
13499
+ title: file.name,
13500
+ children: file.name
13501
+ }
13502
+ ),
13503
+ (file.width || file.size) && /* @__PURE__ */ jsxs("div", { style: { fontSize: 10, color: "#64748b", marginTop: 2 }, children: [
13504
+ file.width && file.height ? `${file.width}×${file.height}` : "",
13505
+ file.width && file.size ? " · " : "",
13506
+ file.size ? `${Math.round(Number(file.size))} KB` : ""
13507
+ ] })
13508
+ ] })
13509
+ ]
11974
13510
  },
11975
- children: t("clearSelection", "Clear Selection")
11976
- }
11977
- )
11978
- ] })
11979
- ]
11980
- }
11981
- ),
11982
- /* @__PURE__ */ jsx("div", { style: { padding: 18, overflowY: "auto", flex: 1 }, children: loading ? /* @__PURE__ */ jsx(
11983
- "div",
11984
- {
11985
- style: { textAlign: "center", padding: 32, color: "#64748b", fontSize: 13 },
11986
- children: t("media.loadingFiles", "Loading media files...")
11987
- }
11988
- ) : filteredFiles.length === 0 ? /* @__PURE__ */ jsx(
11989
- "div",
11990
- {
11991
- style: { textAlign: "center", padding: 32, color: "#64748b", fontSize: 13 },
11992
- children: t(
11993
- "media.noMatchingFiles",
11994
- "No matching files found in the media library. Use the Upload New File button above to upload from your computer."
11995
- )
11996
- }
11997
- ) : /* @__PURE__ */ jsx(
11998
- "div",
11999
- {
12000
- style: {
12001
- display: "grid",
12002
- gridTemplateColumns: "repeat(auto-fill, minmax(145px, 1fr))",
12003
- gap: 12
12004
- },
12005
- children: filteredFiles.map((file) => {
12006
- const fileKey = getFileKey(file);
12007
- const multiIndex = multiple ? selectedFiles.findIndex((f) => getFileKey(f) === fileKey) : -1;
12008
- const isMultiSelected = multiIndex !== -1;
12009
- const isCurrent = multiple ? isMultiSelected : Boolean(
12010
- previewUrl && (file.url === previewUrl || file.name === value?.filename)
12011
- );
12012
- const thumbSrc = file.formats?.thumbnail?.url || file.formats?.small?.url || file.url || "";
12013
- return /* @__PURE__ */ jsxs(
12014
- "div",
12015
- {
12016
- onClick: () => {
12017
- if (multiple) {
12018
- toggleFileSelection(file);
12019
- } else {
12020
- onChange(mapStrapiFileToAsset(file));
12021
- setModalOpen(false);
12022
- }
12023
- },
12024
- onDoubleClick: () => {
12025
- if (multiple) {
12026
- const asset = mapStrapiFileToAsset(file);
12027
- const listToCommit = selectedFiles.length > 0 ? selectedFiles.map(mapStrapiFileToAsset) : [asset];
12028
- if (onSelectMultiple) {
12029
- onSelectMultiple(listToCommit);
12030
- } else {
12031
- listToCommit.forEach((a) => onChange(a));
13511
+ fileKey
13512
+ );
13513
+ })
13514
+ }
13515
+ ) }),
13516
+ /* @__PURE__ */ jsxs(
13517
+ "div",
13518
+ {
13519
+ style: {
13520
+ display: "flex",
13521
+ alignItems: "center",
13522
+ justifyContent: "space-between",
13523
+ padding: "12px 18px",
13524
+ borderTop: "1px solid #e2e8f0",
13525
+ background: "#f8fafc",
13526
+ gap: 12
13527
+ },
13528
+ children: [
13529
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "#475569", fontWeight: 500 }, children: multiple ? selectedFiles.length > 0 ? /* @__PURE__ */ jsxs("span", { style: { color: "#0f172a", fontWeight: 700 }, children: [
13530
+ selectedFiles.length,
13531
+ " ",
13532
+ t("selectedCountLabel", "selected")
13533
+ ] }) : /* @__PURE__ */ jsx("span", { children: t("multiSelectHint", "Click multiple images to select them in order") }) : /* @__PURE__ */ jsx("span", { children: tr ? "Seçmek için görsele tıklayın; kırpmak veya düzenlemek için sağ üstteki Kırp ikonunu kullanın." : "Click an image to select it, or click the Crop icon on any card to crop/edit." }) }),
13534
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
13535
+ /* @__PURE__ */ jsx(
13536
+ "button",
13537
+ {
13538
+ type: "button",
13539
+ onClick: () => {
13540
+ setSelectedFiles([]);
13541
+ setModalOpen(false);
13542
+ },
13543
+ style: {
13544
+ padding: "7px 14px",
13545
+ fontSize: 12,
13546
+ fontWeight: 600,
13547
+ border: "1px solid #cbd5e1",
13548
+ borderRadius: 5,
13549
+ background: "#ffffff",
13550
+ color: "#475569",
13551
+ cursor: "pointer"
13552
+ },
13553
+ children: t("cancel", "Cancel")
12032
13554
  }
12033
- setSelectedFiles([]);
12034
- setModalOpen(false);
12035
- }
12036
- },
12037
- style: {
12038
- border: isCurrent ? "2px solid #2669a0" : "1px solid #e2e8f0",
12039
- borderRadius: 6,
12040
- overflow: "hidden",
12041
- cursor: "pointer",
12042
- background: isCurrent ? "#eff6ff" : "#fff",
12043
- boxShadow: isCurrent ? "0 0 0 2px rgba(38, 105, 160, 0.16)" : "0 1px 3px rgba(0,0,0,0.04)",
12044
- userSelect: "none"
12045
- },
12046
- children: [
12047
- /* @__PURE__ */ jsxs(
12048
- "div",
13555
+ ),
13556
+ multiple && /* @__PURE__ */ jsxs(
13557
+ "button",
12049
13558
  {
13559
+ type: "button",
13560
+ disabled: selectedFiles.length === 0,
13561
+ onClick: handleConfirmMultiple,
12050
13562
  style: {
12051
- height: 100,
12052
- background: "#f1f5f9",
12053
- display: "flex",
13563
+ display: "inline-flex",
12054
13564
  alignItems: "center",
12055
- justifyContent: "center",
12056
- position: "relative"
13565
+ gap: 6,
13566
+ padding: "7px 16px",
13567
+ fontSize: 12,
13568
+ fontWeight: 700,
13569
+ border: "none",
13570
+ borderRadius: 5,
13571
+ background: selectedFiles.length > 0 ? "#2669a0" : "#94a3b8",
13572
+ color: "#ffffff",
13573
+ cursor: selectedFiles.length > 0 ? "pointer" : "not-allowed"
12057
13574
  },
12058
13575
  children: [
12059
- file.mime?.startsWith("image/") ? /* @__PURE__ */ jsx(
12060
- "img",
12061
- {
12062
- src: thumbSrc,
12063
- alt: file.name,
12064
- style: { width: "100%", height: "100%", objectFit: "cover" }
12065
- }
12066
- ) : /* @__PURE__ */ jsx(MaterialIcon, { name: "description", size: 30, color: "#64748b" }),
12067
- multiple ? /* @__PURE__ */ jsx(
12068
- "span",
12069
- {
12070
- style: {
12071
- position: "absolute",
12072
- top: 6,
12073
- left: 6,
12074
- minWidth: 22,
12075
- height: 22,
12076
- padding: isMultiSelected ? "0 6px" : 0,
12077
- borderRadius: 11,
12078
- background: isMultiSelected ? "#2669a0" : "rgba(255, 255, 255, 0.88)",
12079
- border: isMultiSelected ? "1.5px solid #ffffff" : "1.5px solid #94a3b8",
12080
- color: "#ffffff",
12081
- fontSize: 10,
12082
- fontWeight: 700,
12083
- display: "inline-flex",
12084
- alignItems: "center",
12085
- justifyContent: "center",
12086
- boxShadow: "0 1px 3px rgba(0,0,0,0.2)"
12087
- },
12088
- children: isMultiSelected ? `✓ ${multiIndex + 1}` : ""
12089
- }
12090
- ) : isCurrent && /* @__PURE__ */ jsx(
12091
- "span",
12092
- {
12093
- style: {
12094
- position: "absolute",
12095
- top: 5,
12096
- left: 5,
12097
- background: "#2669a0",
12098
- color: "#fff",
12099
- fontSize: 9,
12100
- fontWeight: 700,
12101
- padding: "2px 6px",
12102
- borderRadius: 4
12103
- },
12104
- children: t("media.selectedBadge", "SELECTED")
12105
- }
12106
- ),
12107
- file.ext && /* @__PURE__ */ jsx(
12108
- "span",
12109
- {
12110
- style: {
12111
- position: "absolute",
12112
- bottom: 4,
12113
- right: 4,
12114
- background: "rgba(15,23,42,0.75)",
12115
- color: "#fff",
12116
- fontSize: 9,
12117
- fontWeight: 700,
12118
- padding: "1px 5px",
12119
- borderRadius: 3,
12120
- textTransform: "uppercase"
12121
- },
12122
- children: file.ext.replace(".", "")
12123
- }
12124
- )
13576
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "check", size: 16, color: "#ffffff" }),
13577
+ /* @__PURE__ */ jsxs("span", { children: [
13578
+ t("addSelectedMedia", "Add Selected"),
13579
+ " ",
13580
+ selectedFiles.length > 0 ? `(${selectedFiles.length})` : ""
13581
+ ] })
12125
13582
  ]
12126
13583
  }
12127
- ),
12128
- /* @__PURE__ */ jsxs("div", { style: { padding: "6px 8px" }, children: [
12129
- /* @__PURE__ */ jsx(
12130
- "div",
12131
- {
12132
- style: {
12133
- fontSize: 11,
12134
- fontWeight: 600,
12135
- color: "#1e293b",
12136
- overflow: "hidden",
12137
- textOverflow: "ellipsis",
12138
- whiteSpace: "nowrap"
12139
- },
12140
- title: file.name,
12141
- children: file.name
12142
- }
12143
- ),
12144
- (file.width || file.size) && /* @__PURE__ */ jsxs("div", { style: { fontSize: 10, color: "#64748b", marginTop: 2 }, children: [
12145
- file.width && file.height ? `${file.width}×${file.height}` : "",
12146
- file.width && file.size ? " · " : "",
12147
- file.size ? `${Math.round(Number(file.size))} KB` : ""
12148
- ] })
12149
- ] })
12150
- ]
12151
- },
12152
- fileKey
12153
- );
12154
- })
12155
- }
12156
- ) }),
12157
- multiple && /* @__PURE__ */ jsxs(
12158
- "div",
12159
- {
12160
- style: {
12161
- display: "flex",
12162
- alignItems: "center",
12163
- justifyContent: "space-between",
12164
- padding: "12px 18px",
12165
- borderTop: "1px solid #e2e8f0",
12166
- background: "#f8fafc",
12167
- gap: 12
12168
- },
12169
- children: [
12170
- /* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "#475569", fontWeight: 500 }, children: selectedFiles.length > 0 ? /* @__PURE__ */ jsxs("span", { style: { color: "#0f172a", fontWeight: 700 }, children: [
12171
- selectedFiles.length,
12172
- " ",
12173
- t("selectedCountLabel", "selected")
12174
- ] }) : /* @__PURE__ */ jsx("span", { children: t("multiSelectHint", "Click multiple images to select them in order") }) }),
12175
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
12176
- /* @__PURE__ */ jsx(
12177
- "button",
12178
- {
12179
- type: "button",
12180
- onClick: () => {
12181
- setSelectedFiles([]);
12182
- setModalOpen(false);
12183
- },
12184
- style: {
12185
- padding: "7px 14px",
12186
- fontSize: 12,
12187
- fontWeight: 600,
12188
- border: "1px solid #cbd5e1",
12189
- borderRadius: 5,
12190
- background: "#ffffff",
12191
- color: "#475569",
12192
- cursor: "pointer"
12193
- },
12194
- children: t("cancel", "Cancel")
12195
- }
12196
- ),
12197
- /* @__PURE__ */ jsxs(
12198
- "button",
12199
- {
12200
- type: "button",
12201
- disabled: selectedFiles.length === 0,
12202
- onClick: handleConfirmMultiple,
12203
- style: {
12204
- display: "inline-flex",
12205
- alignItems: "center",
12206
- gap: 6,
12207
- padding: "7px 16px",
12208
- fontSize: 12,
12209
- fontWeight: 700,
12210
- border: "none",
12211
- borderRadius: 5,
12212
- background: selectedFiles.length > 0 ? "#2669a0" : "#94a3b8",
12213
- color: "#ffffff",
12214
- cursor: selectedFiles.length > 0 ? "pointer" : "not-allowed"
12215
- },
12216
- children: [
12217
- /* @__PURE__ */ jsx(MaterialIcon, { name: "check", size: 16, color: "#ffffff" }),
12218
- /* @__PURE__ */ jsxs("span", { children: [
12219
- t("addSelectedMedia", "Add Selected"),
12220
- " ",
12221
- selectedFiles.length > 0 ? `(${selectedFiles.length})` : ""
12222
- ] })
12223
- ]
12224
- }
12225
- )
12226
- ] })
12227
- ]
12228
- }
13584
+ )
13585
+ ] })
13586
+ ]
13587
+ }
13588
+ )
13589
+ ] })
12229
13590
  )
12230
13591
  ]
12231
13592
  }
@@ -16335,6 +17696,9 @@ const VisualEditorModal = ({ open, onClose }) => {
16335
17696
  useEffect(() => {
16336
17697
  if (!open) return;
16337
17698
  const onKeyDown = (e) => {
17699
+ if (typeof document !== "undefined" && document.querySelector('[role="dialog"], [data-radix-popper-content-wrapper]')) {
17700
+ return;
17701
+ }
16338
17702
  const target = e.target;
16339
17703
  const isInput = target && (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.tagName === "SELECT" || target.isContentEditable);
16340
17704
  if (e.key === "Escape") {
@@ -16493,7 +17857,7 @@ const VisualEditorModal = ({ open, onClose }) => {
16493
17857
  style: {
16494
17858
  position: "fixed",
16495
17859
  inset: 0,
16496
- zIndex: 9999,
17860
+ zIndex: 200,
16497
17861
  background: "#f8fafc",
16498
17862
  display: "flex",
16499
17863
  flexDirection: "column",
@@ -16747,7 +18111,7 @@ const CIContextMenu = () => {
16747
18111
  position: "fixed",
16748
18112
  left: pos.left,
16749
18113
  top: pos.top,
16750
- zIndex: 10500,
18114
+ zIndex: 250,
16751
18115
  minWidth: 235,
16752
18116
  background: "#ffffff",
16753
18117
  border: "1px solid #cbd5e1",
@@ -18314,7 +19678,7 @@ const InnerContentBuilder = ({
18314
19678
  position: "fixed",
18315
19679
  inset: 0,
18316
19680
  background: "rgba(15, 23, 42, 0.5)",
18317
- zIndex: 10200,
19681
+ zIndex: 230,
18318
19682
  display: "flex",
18319
19683
  alignItems: "center",
18320
19684
  justifyContent: "center",
@@ -18438,7 +19802,7 @@ const InnerContentBuilder = ({
18438
19802
  position: "fixed",
18439
19803
  inset: 0,
18440
19804
  background: "rgba(15, 23, 42, 0.5)",
18441
- zIndex: 10200,
19805
+ zIndex: 230,
18442
19806
  display: "flex",
18443
19807
  alignItems: "center",
18444
19808
  justifyContent: "center",