import { jsxs as b, Fragment as W, jsx as n } from "react/jsx-runtime";
import { useEffect as B, Suspense as Q, lazy as M, useState as ie, useRef as we, Fragment as De } from "react";
import { useSensor as oe, PointerSensor as xe, KeyboardSensor as Se, useSensors as be, DndContext as Te } from "@dnd-kit/core";
import { snapCenterToCursor as Fe } from "@dnd-kit/modifiers";
import { odeServices as N, FOLDER as E, SORT_ORDER as Re, ResourceService as de, isActionAvailable as ne } from "@edifice.io/client";
import { findParentNode as ve, findNodeById as G, wrapTreeNode as Ee, useToast as U, moveNode as Le, useUser as ue, useEdificeClient as Z, useShareMutation as Ne, useUpdateMutation as Ae, addNode as Me, updateNode as ke, deleteNode as Pe, getAncestors as ae, LoadingScreen as H, FormControl as He, Input as Qe, SearchButton as Ue, Dropdown as K, useToggle as Ze, useScrollToTop as Oe, TreeView as qe, Button as Be, IconButton as Ve, useXitiTrackPageLoad as _e, AppHeader as Ke, Breadcrumb as $e, Grid as te } from "@edifice.io/react";
import { t as L } from "i18next";
import { createStore as ze, useStore as je } from "zustand";
import { useQuery as We, queryOptions as Ge, useQueryClient as P, useMutation as O, useInfiniteQuery as Je } from "@tanstack/react-query";
import { useTranslation as V } from "react-i18next";
const he = async (e) => {
  const t = await N.resource(e.application).searchContext(e);
  return {
    ...t,
    folders: t.folders.filter((s) => !s.trashed)
  };
}, Xe = async ({
  searchParams: e,
  name: t,
  parentId: s
}) => {
  const r = {
    name: t,
    parentId: s,
    application: e.application,
    type: e.types[0]
  };
  return await N.resource(e.application).createFolder(r);
}, Ye = async ({
  folderId: e,
  searchParams: t,
  parentId: s,
  name: r
}) => {
  const o = {
    folderId: e,
    name: r,
    parentId: s,
    application: t.application,
    type: t.types[0]
  };
  return await N.resource(t.application).updateFolder(o);
}, et = async ({
  searchParams: e,
  resourceIds: t,
  useAssetIds: s,
  folderIds: r
}) => {
  const o = {
    application: e.application,
    resourceType: e.types[0],
    resourceIds: t,
    folderIds: r
  };
  return await N.resource(e.application).trashAll(o, s);
}, tt = async ({
  searchParams: e,
  resourceIds: t,
  useAssetIds: s,
  folderIds: r
}) => {
  const o = {
    application: e.application,
    resourceType: e.types[0],
    resourceIds: t,
    folderIds: r
  };
  return await N.resource(e.application).deleteAll(o, s);
}, st = async ({
  searchParams: e,
  resourceIds: t,
  folderIds: s,
  useAssetIds: r
}) => {
  const o = {
    application: e.application,
    resourceType: e.types[0],
    resourceIds: t,
    folderIds: s
  };
  return await N.resource(e.application).restoreAll(o, r);
}, rt = async (e, t) => await N.resource(e.application).copy({
  application: e.application,
  resourceId: t
}), pe = async ({
  searchParams: e,
  resourceIds: t,
  folderId: s,
  folderIds: r,
  useAssetIds: o
}) => {
  const l = {
    application: e.application,
    folderId: s,
    resourceIds: t,
    folderIds: r
  };
  return await N.resource(e.application).moveToFolder(l, o);
}, ot = async (e) => await N.rights().sessionHasWorkflowRights(e), nt = ({
  searchParams: e,
  assetId: t
}) => {
  const s = N.resource(e.application).getViewUrl(t);
  window.open(s, "_self");
}, at = ({
  searchParams: e,
  params: t
}) => N.resource(e.application).create(t), ct = ({
  searchParams: e,
  assetId: t
}) => {
  const s = N.resource(e.application).getPrintUrl(t);
  return window.open(s, "_blank");
}, ds = ({
  searchParams: e,
  folderId: t
}) => {
  const s = N.resource(e.application).getFormUrl(t);
  return window.open(s, "_self");
}, us = ({
  searchParams: e,
  assetId: t
}) => {
  const s = N.resource(e.application).getEditUrl(t);
  return window.open(s, "_self");
}, hs = ({
  searchParams: e,
  assetId: t
}) => {
  const s = N.resource(e.application).getExportUrl(t);
  return window.open(s, "_self");
}, fe = {
  id: E.DEFAULT,
  name: L("explorer.filters.mine"),
  section: !0,
  children: []
}, lt = {
  config: void 0,
  searchConfig: {
    minLength: 1
  },
  searchParams: {
    filters: {
      folder: E.DEFAULT,
      owner: void 0,
      shared: void 0,
      public: void 0
    },
    orders: {
      updatedAt: Re.DESC
    },
    application: "",
    types: [],
    pagination: {
      startIdx: 0,
      pageSize: 48,
      maxIdx: 0
    },
    trashed: !1
  },
  treeData: fe,
  selectedNodeId: "default",
  currentFolder: {
    id: "default"
  },
  selectedFolders: [],
  selectedResources: [],
  folderIds: [],
  resourceIds: [],
  resourceIsTrash: !1,
  resourceOrFolderIsDraggable: {
    isDrag: !1,
    elementDrag: void 0
  },
  elementDragOver: {
    isOver: !1,
    isTreeview: !1,
    canMove: !0,
    overId: void 0
  },
  resourceActionDisable: !1,
  status: void 0
}, it = ze()((e, t) => ({
  ...lt,
  actions: {
    setConfig: (s) => e({
      config: s
    }),
    setSearchConfig: (s) => e((r) => ({
      searchConfig: {
        ...r.searchConfig,
        ...s
      }
    })),
    setTreeData: (s) => e(() => ({
      treeData: s
    })),
    setSearchParams: (s) => {
      e((r) => {
        const {
          searchParams: o
        } = r;
        return o.search !== s.search ? s.search ? {
          ...r,
          selectedFolders: [],
          selectedNodeId: void 0,
          selectedResources: [],
          currentFolder: void 0,
          searchParams: {
            ...o,
            ...s,
            trashed: !1,
            filters: {
              ...o.filters,
              folder: void 0
            }
          }
        } : {
          ...r,
          selectedFolders: [],
          selectedNodeId: "default",
          selectedResources: [],
          currentFolder: {
            id: "default"
          },
          searchParams: {
            ...o,
            ...s,
            trashed: !1,
            filters: {
              ...o.filters
            }
          }
        } : {
          searchParams: {
            ...o,
            ...s
          }
        };
      });
    },
    setSelectedFolders: (s) => e(() => ({
      selectedFolders: s
    })),
    setSelectedResources: (s) => e(() => ({
      selectedResources: s
    })),
    setFolderIds: (s) => e(() => ({
      folderIds: s
    })),
    setResourceIds: (s) => e(() => ({
      resourceIds: s
    })),
    setResourceIsTrash: (s) => e(() => ({
      resourceIsTrash: s
    })),
    setResourceOrFolderIsDraggable: (s) => e(() => ({
      resourceOrFolderIsDraggable: s
    })),
    setElementDragOver: (s) => e(() => ({
      elementDragOver: s
    })),
    setResourceActionDisable: (s) => e(() => ({
      resourceActionDisable: s
    })),
    clearSelectedItems: () => e(() => ({
      selectedFolders: [],
      selectedResources: []
    })),
    clearSelectedIds: () => e(() => ({
      resourceIds: [],
      folderIds: []
    })),
    openResource: (s) => {
      try {
        const {
          searchParams: r
        } = t();
        nt({
          searchParams: r,
          assetId: s.assetId
        });
      } catch (r) {
        console.error("explorer open failed: ", r);
      }
    },
    printSelectedResource: () => {
      try {
        const {
          searchParams: s,
          selectedResources: r,
          resourceIds: o
        } = t();
        if (r.length !== 1)
          throw new Error("Cannot open more than 1 resource");
        const l = r.find((a) => a.id === o[0]);
        ct({
          searchParams: s,
          assetId: l.assetId
        });
      } catch (s) {
        console.error("explorer print failed: ", s);
      }
    },
    openFolder: ({
      folderId: s,
      folder: r,
      queryClient: o
    }) => {
      const {
        searchParams: l
      } = t(), a = l.filters.folder, c = s;
      a !== s && (t().actions.fetchTreeData(s, o), e((p) => ({
        ...p,
        // reset selection when changing folder
        folderIds: [],
        resourceIds: [],
        selectedNodeId: c,
        currentFolder: r || {
          id: s
        },
        searchParams: {
          ...l,
          search: void 0,
          filters: {
            ...l.filters,
            folder: s
          },
          trashed: s === E.BIN
        }
      })));
    },
    foldTreeItem: () => e((s) => ({
      ...s,
      status: "fold"
    })),
    fetchTreeData: async (s, r) => {
      const o = G(t().treeData, s), l = o == null ? void 0 : o.id;
      if (Array.isArray(o == null ? void 0 : o.children) && o.children.length) return;
      const a = await r.fetchQuery({
        queryKey: ["prefetchContext", {
          folderId: l,
          trashed: !1
        }],
        queryFn: async () => await he({
          ...t().searchParams,
          filters: {
            ...t().searchParams.filters,
            folder: l
          }
        })
      });
      t().actions.setTreeData(Ee(t().treeData, a == null ? void 0 : a.folders, l || E.DEFAULT));
    },
    selectTreeItem: (s, r) => {
      const {
        treeData: o
      } = t(), {
        openFolder: l,
        fetchTreeData: a
      } = t().actions, c = G(o, s);
      a(s, r), e((p) => ({
        ...p,
        searchParams: {
          ...p.searchParams,
          search: void 0
        },
        status: "select",
        selectedResources: []
      })), l({
        folder: c,
        folderId: s
      });
    },
    gotoPreviousFolder: () => {
      const {
        selectedNodeId: s,
        treeData: r,
        searchParams: o
      } = t(), {
        openFolder: l
      } = t().actions;
      if (o.search && l({
        folder: fe,
        folderId: E.DEFAULT
      }), !s) return;
      const a = ve(r, s);
      l({
        folder: a,
        folderId: (a == null ? void 0 : a.id) || E.DEFAULT
      });
    },
    goToTrash: () => {
      e((s) => ({
        ...s,
        selectedNodeId: void 0,
        selectedResources: [],
        resourceIds: [],
        folderIds: [],
        status: "select",
        searchParams: {
          ...s.searchParams,
          search: void 0,
          filters: {
            folder: E.BIN
          },
          trashed: !0
        },
        currentFolder: {
          id: E.BIN
        }
      }));
    }
  }
}));
function T(e) {
  return je(it, e);
}
const dt = (e) => e.treeData, ut = (e) => e.actions, $ = () => T(dt), R = () => T(ut), A = () => T((e) => e.searchParams), se = () => T((e) => e.selectedNodeId), ps = () => T((e) => e.selectedFolders), fs = () => T((e) => e.selectedResources), ht = () => T((e) => e.searchConfig), J = () => T((e) => e.folderIds), X = () => T((e) => e.resourceIds), Y = () => T((e) => e.selectedResources.map((t) => t.assetId)), ee = () => T((e) => e.selectedResources.filter((t) => t.assetId === t.id)), z = () => T((e) => e.currentFolder), re = () => {
  const e = z();
  return (e == null ? void 0 : e.id) === E.BIN;
}, pt = () => T((e) => e.resourceIsTrash), gs = () => T((e) => e.resourceOrFolderIsDraggable), ft = () => T((e) => e.elementDragOver), gt = () => T((e) => e.resourceActionDisable), mt = () => {
  const e = z();
  return (e == null ? void 0 : e.id) === "default";
}, yt = () => T((e) => e.status), Ct = () => {
  const e = gt(), {
    clearSelectedIds: t,
    setResourceActionDisable: s,
    clearSelectedItems: r
  } = R();
  return {
    isActionDisableModalOpen: e,
    onActionDisableCancel: () => {
      t(), r(), s(!1);
    }
  };
}, It = () => {
  const e = pt(), {
    clearSelectedIds: t,
    setResourceIsTrash: s,
    clearSelectedItems: r
  } = R();
  return {
    isTrashedModalOpen: e,
    onTrashedCancel: () => {
      t(), r(), s(!1);
    }
  };
}, wt = 175, Dt = 10, ge = "blog", me = "blog";
class ye extends de {
  getEditUrl() {
    throw new Error("Method not implemented.");
  }
  async create(t) {
    const s = t.thumbnail ? await this.getThumbnailPath(t.thumbnail) : "", r = t.public ? "/blog/pub" : "/blog", o = await this.http.post(r, {
      title: t.name,
      description: t.description,
      visibility: t.public ? "PUBLIC" : "OWNER",
      thumbnail: s,
      trashed: !1,
      folder: t.folder,
      slug: t.public ? t.slug : "",
      "publish-type": t.publishType || "RESTRAINT",
      "comment-type": "IMMEDIATE",
      allowReplies: t.allowReplies
    });
    return this.checkHttpResponse(o), o;
  }
  async update(t) {
    const s = t.thumbnail ? await this.getThumbnailPath(t.thumbnail) : "", r = await this.http.put(`/blog/${t.entId}`, {
      trashed: t.trashed,
      _id: t.entId,
      title: t.name,
      thumbnail: s,
      description: t.description,
      visibility: t.public ? "PUBLIC" : "OWNER",
      slug: t.public ? t.slug : "",
      "publish-type": t["publish-type"] || "RESTRAINT",
      "comment-type": "IMMEDIATE",
      allowReplies: t.allowReplies
    });
    return this.checkHttpResponse(r), {
      thumbnail: s,
      entId: t.entId
    };
  }
  getResourceType() {
    return me;
  }
  getApplication() {
    return ge;
  }
  getFormUrl(t) {
    return t ? `/blog?folderid=${t}#/edit/new` : "/blog#/edit/new";
  }
  getViewUrl(t) {
    return `/blog/id/${t}`;
  }
  getPrintUrl(t) {
    return `/blog/print/${t}`;
  }
}
de.register({
  application: ge,
  resourceType: me
}, (e) => new ye(e));
const q = document.querySelector("[data-explorer-config]");
let ce;
function ms() {
  var e;
  if ((e = q == null ? void 0 : q.dataset) != null && e.explorerConfig) {
    const {
      explorerConfig: t
    } = q.dataset;
    try {
      const s = JSON.parse(t);
      ce = {
        ...s,
        service: ye,
        enableOnboarding: s.enableOnboarding !== void 0 ? s.enableOnboarding : !0
      };
    } catch (s) {
      console.error("[Explorer Config] could not parse app params from root data attributes:", q == null ? void 0 : q.dataset, s);
    }
  }
  return ce;
}
const xt = (e, t) => {
  const s = e.map((o) => o.workflow), r = new Set(s);
  return Ge({
    queryKey: [...r],
    queryFn: () => ot([...r]),
    select: (o) => e.filter((l) => o[l.workflow]).map((l) => ({
      ...l,
      available: !0
    })),
    staleTime: 1 / 0,
    enabled: !!t
  });
}, St = (e) => {
  const t = T((s) => s.config);
  return We(xt(e, t));
}, bt = () => {
  const e = T((a) => a.config), t = A(), {
    filters: s,
    trashed: r,
    search: o
  } = t, l = ["context", {
    folderId: s.folder,
    filters: s,
    trashed: r,
    search: o
  }];
  return Je({
    queryKey: l,
    queryFn: async ({
      pageParam: a
    }) => await he({
      ...t,
      application: e == null ? void 0 : e.app,
      types: e == null ? void 0 : e.types,
      pagination: {
        ...t.pagination,
        startIdx: a
      }
    }),
    staleTime: 5e3,
    initialPageParam: 0,
    enabled: !!e,
    retry: !1,
    getNextPageParam: (a) => a.pagination.startIdx + a.pagination.pageSize
  });
}, ys = () => {
  const e = U(), t = P(), s = A(), r = $(), o = J(), l = Y(), a = X(), c = ee().length > 0, p = c ? l : a, {
    clearSelectedItems: i,
    clearSelectedIds: d,
    setTreeData: h,
    setSearchParams: u
  } = R(), {
    filters: g,
    trashed: m
  } = s, I = ["context", {
    folderId: g.folder,
    filters: g,
    trashed: m
  }];
  return O({
    mutationFn: async () => await et({
      searchParams: s,
      folderIds: o,
      resourceIds: p,
      useAssetIds: c
    }),
    onError(C) {
      typeof C == "string" && e.error(L(C));
    },
    onSuccess: async (C) => {
      if (await t.cancelQueries({
        queryKey: I
      }), t.getQueryData(I))
        return e.success(L("explorer.trash.title")), t.setQueryData(I, (F) => {
          var k;
          if (F) {
            const S = {
              ...F,
              pages: F == null ? void 0 : F.pages.map((y) => {
                var f;
                return {
                  ...y,
                  folders: y.folders.filter((w) => !o.includes(w.id)),
                  pagination: {
                    ...y.pagination,
                    // @ts-ignore
                    maxIdx: ((f = y == null ? void 0 : y.pagination) == null ? void 0 : f.maxIdx) - C.resources.length
                  },
                  resources: y.resources.filter((w) => c ? !l.includes(w.assetId) : !p.includes(w.id))
                };
              })
            }, D = Pe(r, {
              folders: o
            });
            return h(D), u({
              ...s,
              pagination: {
                ...s.pagination,
                // @ts-ignore
                maxIdx: ((k = s.pagination) == null ? void 0 : k.maxIdx) - C.resources.length
              }
            }), S;
          }
        });
    },
    onSettled: () => {
      i(), d();
    }
  });
}, Cs = () => {
  const e = U(), t = P(), s = A(), r = J(), o = Y(), l = X(), a = ee().length > 0, c = a ? o : l, {
    setFolderIds: p,
    setResourceIds: i,
    setSelectedResources: d,
    setSelectedFolders: h
  } = R(), {
    filters: u,
    trashed: g
  } = s, m = ["context", {
    folderId: u.folder,
    filters: u,
    trashed: g
  }];
  return O({
    mutationFn: async () => await st({
      searchParams: s,
      folderIds: r,
      resourceIds: c,
      useAssetIds: a
    }),
    onError(I) {
      typeof I == "string" && e.error(L(I));
    },
    onSuccess: async () => {
      if (await t.cancelQueries({
        queryKey: m
      }), t.getQueryData(m))
        return e.success(L("explorer.trash.toast")), t.setQueryData(m, (C) => {
          if (C)
            return {
              ...C,
              pages: C == null ? void 0 : C.pages.map((x) => ({
                ...x,
                folders: x.folders.filter((F) => !r.includes(F.id)),
                resources: x.resources.filter((F) => a ? !o.includes(F.assetId) : !c.includes(F.id))
              }))
            };
        });
    },
    onSettled: () => {
      i([]), d([]), p([]), h([]);
    }
  });
}, Is = () => {
  const e = U(), t = P(), s = A(), r = J(), o = Y(), l = X(), a = ee().length > 0, c = a ? o : l, {
    clearSelectedItems: p,
    clearSelectedIds: i
  } = R(), {
    filters: d,
    trashed: h
  } = s, u = ["context", {
    folderId: d.folder,
    filters: d,
    trashed: h
  }];
  return O({
    mutationFn: async () => await tt({
      searchParams: s,
      folderIds: r,
      resourceIds: c,
      useAssetIds: a
    }),
    onError(g) {
      typeof g == "string" && e.error(L(g));
    },
    onSuccess: async () => {
      if (await t.cancelQueries({
        queryKey: u
      }), t.getQueryData(u))
        return e.success(L("explorer.removed.from.trash")), t.setQueryData(u, (m) => {
          if (m)
            return {
              ...m,
              pages: m == null ? void 0 : m.pages.map((C) => ({
                ...C,
                folders: C.folders.filter((x) => !r.includes(x.id)),
                resources: C.resources.filter((x) => a ? !o.includes(x.assetId) : !c.includes(x.id))
              }))
            };
        });
    },
    onSettled: () => {
      p(), i();
    }
  });
}, ws = () => {
  const e = U(), t = A(), s = P(), {
    user: r
  } = ue(), o = z(), {
    filters: l,
    trashed: a
  } = t, c = "duplicate_start", p = ["context", {
    folderId: l.folder,
    filters: l,
    trashed: a
  }];
  return O({
    mutationFn: async (i) => (e.info(L("duplicate.start"), {
      id: c
    }), await rt(t, i.assetId)),
    onSuccess: async (i, d) => {
      e.remove(c), e.success(L("duplicate.done")), await s.cancelQueries({
        queryKey: p
      });
      const h = s.getQueryData(p), u = {
        ...d,
        name: `${d.name}${L("duplicate.suffix")}`,
        assetId: i.duplicateId,
        id: i.duplicateId,
        creatorId: r == null ? void 0 : r.userId,
        creatorName: r == null ? void 0 : r.username,
        createdAt: Date.now(),
        slug: d.slug || "",
        modifiedAt: Date.now(),
        modifierId: (r == null ? void 0 : r.userId) || "",
        modifierName: (r == null ? void 0 : r.username) || "",
        updatedAt: Date.now(),
        trashed: !1,
        rights: [`creator:${r == null ? void 0 : r.userId}`]
      };
      h && s.setQueryData(p, (g) => {
        if (g)
          return {
            ...g,
            pages: g == null ? void 0 : g.pages.map((m) => ({
              ...m,
              resources: [u, ...m.resources]
            }))
          };
      }), o.id && o.id !== E.DEFAULT && pe({
        searchParams: t,
        resourceIds: [i.duplicateId],
        folderId: o.id,
        folderIds: [],
        useAssetIds: !0
      });
    },
    onError: (i) => {
      e.remove(c), typeof i == "string" && e.error(`${L("duplicate.error")}: ${i}`);
    }
  });
}, Tt = () => {
  const e = U(), t = P(), s = A(), r = $(), o = J(), l = Y(), a = X(), c = ee().length > 0, p = c ? l : a, {
    clearSelectedIds: i,
    clearSelectedItems: d,
    setTreeData: h,
    setSearchParams: u
  } = R(), {
    filters: g,
    trashed: m
  } = s, I = ["context", {
    folderId: g.folder,
    filters: g,
    trashed: m
  }];
  return O({
    mutationFn: async (C) => await pe({
      searchParams: s,
      folderId: C,
      folderIds: o,
      resourceIds: p,
      useAssetIds: c
    }),
    onError(C) {
      typeof C == "string" && e.error(L(C));
    },
    onSuccess: async (C, x) => {
      if (t.getQueryData(I))
        return t.setQueryData(I, (k) => {
          var S;
          if (k) {
            const D = Le(r, {
              destinationId: x,
              folders: o
            }), y = {
              ...k,
              pages: k == null ? void 0 : k.pages.map((f) => {
                var w;
                return {
                  ...f,
                  folders: f.folders.filter((v) => !o.includes(v.id)),
                  pagination: {
                    ...f.pagination,
                    // @ts-ignore
                    maxIdx: ((w = f.pagination) == null ? void 0 : w.maxIdx) - C.resources.length
                  },
                  resources: f.resources.filter((v) => c ? !l.includes(v.assetId) : !p.includes(v.id))
                };
              })
            };
            return h(D), u({
              ...s,
              pagination: {
                ...s.pagination,
                // @ts-ignore
                maxIdx: ((S = s.pagination) == null ? void 0 : S.maxIdx) - C.resources.length
              }
            }), y;
          }
        });
      t.invalidateQueries();
    },
    onSettled: () => {
      d(), i();
    }
  });
}, Ds = () => {
  const e = U(), t = P(), s = A(), r = $(), {
    setTreeData: o
  } = R(), {
    filters: l,
    trashed: a
  } = s, c = ["context", {
    folderId: l.folder,
    filters: l,
    trashed: a
  }];
  return O({
    mutationFn: async ({
      name: p,
      parentId: i
    }) => await Xe({
      searchParams: s,
      name: p,
      parentId: i
    }),
    onError(p) {
      typeof p == "string" && e.error(L(p));
    },
    onSuccess: async (p, i) => {
      await t.cancelQueries({
        queryKey: c
      });
      const d = t.getQueryData(c), h = {
        ...p,
        parentId: i.parentId,
        children: [],
        rights: [`creator:${p == null ? void 0 : p.creator_id}`]
      };
      if (d)
        return t.setQueryData(c, (u) => {
          if (u) {
            const g = {
              ...u,
              pages: u == null ? void 0 : u.pages.map((I) => ({
                ...I,
                folders: [...I.folders, h]
              }))
            }, m = Me(r, {
              parentId: i.parentId,
              newFolder: h
            });
            return o(m), g;
          }
        });
    }
  });
}, xs = () => {
  const e = U(), t = P(), s = A(), r = $(), {
    setFolderIds: o,
    setSelectedFolders: l,
    setTreeData: a
  } = R(), {
    filters: c,
    trashed: p
  } = s, i = ["context", {
    folderId: c.folder,
    filters: c,
    trashed: p
  }];
  return O({
    mutationFn: async ({
      folderId: d,
      name: h,
      parentId: u
    }) => await Ye({
      searchParams: s,
      folderId: d,
      parentId: u,
      name: h
    }),
    onError(d) {
      typeof d == "string" && e.error(L(d));
    },
    onSuccess: async (d, h) => {
      if (await t.cancelQueries({
        queryKey: i
      }), t.getQueryData(i))
        return t.setQueryData(i, (g) => {
          if (g) {
            const m = {
              ...g,
              pages: g == null ? void 0 : g.pages.map((C) => ({
                ...C,
                folders: C.folders.map((x) => x.id === d.id ? {
                  ...d,
                  parentId: h.parentId,
                  rights: x.rights
                } : x)
              }))
            }, I = ke(r, {
              folderId: h.folderId,
              newFolder: d
            });
            return a(I), m;
          }
        });
    },
    onSettled: () => {
      o([]), l([]);
    }
  });
}, Ss = (e) => {
  const t = P(), s = A(), {
    setResourceIds: r,
    setSelectedResources: o
  } = R(), {
    filters: l,
    trashed: a
  } = s, c = ["context", {
    folderId: l.folder,
    filters: l,
    trashed: a
  }];
  return Ne({
    application: e,
    options: {
      onSuccess: async (p, i) => {
        if (await t.cancelQueries({
          queryKey: c
        }), t.getQueryData(c))
          return t.setQueryData(c, (h) => {
            if (h)
              return {
                ...h,
                pages: h == null ? void 0 : h.pages.map((u) => ({
                  ...u,
                  resources: u.resources.map((g) => {
                    if (g.assetId === (i == null ? void 0 : i.resourceId)) {
                      let m = [`creator:${g.creatorId}`];
                      return (i == null ? void 0 : i.rights.length) >= 1 && (m = [...m, ...i.rights.flatMap((I) => I.actions.map((C) => `${I.type}:${I.id}:${C.id}`))]), {
                        ...g,
                        rights: m
                      };
                    } else
                      return g;
                  })
                }))
              };
          });
      },
      onSettled: () => {
        r([]), o([]);
      }
    }
  });
}, bs = (e) => {
  const t = P(), s = A(), {
    filters: r,
    trashed: o
  } = s, l = ["context", {
    folderId: r.folder,
    filters: r,
    trashed: o
  }];
  return Ae({
    application: e,
    options: {
      onSuccess: async (a, c) => {
        if (await t.cancelQueries({
          queryKey: l
        }), t.getQueryData(l))
          return t.setQueryData(l, (i) => {
            if (i)
              return {
                ...i,
                pages: i == null ? void 0 : i.pages.map((d) => ({
                  ...d,
                  resources: d.resources.map((h) => {
                    if (h.assetId === (c == null ? void 0 : c.entId)) {
                      const {
                        name: u,
                        thumbnail: g,
                        public: m,
                        description: I,
                        slug: C,
                        ...x
                      } = c;
                      return {
                        ...h,
                        ...x,
                        // add any custom field
                        name: u,
                        thumbnail: typeof g == "string" ? g : URL.createObjectURL(g),
                        public: m,
                        description: I,
                        slug: C
                      };
                    } else
                      return h;
                  })
                }))
              };
          });
      }
    }
  });
}, Ts = ({
  onResourceCreated: e
}) => {
  const t = U(), s = P(), r = A(), {
    user: o
  } = ue(), {
    appCode: l
  } = Z(), a = ["context", {
    folderId: r.filters.folder,
    filters: r.filters,
    trashed: r.trashed
  }];
  return O({
    mutationFn: async (c) => await at({
      searchParams: r,
      params: c
    }),
    onError(c) {
      typeof c == "string" && t.error(L(c));
    },
    onSuccess: async (c, p) => {
      var h, u, g;
      await s.cancelQueries({
        queryKey: a
      });
      const i = s.getQueryData(a), d = {
        ...p,
        thumbnail: c.thumbnail || "",
        application: l,
        assetId: c._id || c.entId || "",
        id: c._id || c.entId || "",
        creatorId: o == null ? void 0 : o.userId,
        creatorName: o == null ? void 0 : o.username,
        createdAt: Date.now(),
        slug: p.slug || "",
        modifiedAt: ((h = c.modified) == null ? void 0 : h.$date) || "",
        modifierId: ((u = c.author) == null ? void 0 : u.userId) || "",
        modifierName: ((g = c.author) == null ? void 0 : g.username) || "",
        updatedAt: Date.now(),
        trashed: !1,
        rights: [`creator:${o == null ? void 0 : o.userId}`]
      };
      if (e == null || e(d), i)
        return s.setQueryData(a, (m) => {
          if (m)
            return {
              ...m,
              pages: m == null ? void 0 : m.pages.map((I) => ({
                ...I,
                resources: [d, ...I.resources]
              }))
            };
        });
    }
  });
};
function le(e, t) {
  var r;
  const s = G(e, t);
  return (r = s == null ? void 0 : s.folder) != null && r.childrenIds ? [...(s == null ? void 0 : s.folder.childrenIds) || [], t] : t === E.BIN ? [E.BIN] : [E.DEFAULT];
}
function Ft() {
  const e = P(), t = Tt(), s = U(), {
    appCode: r
  } = Z(), {
    t: o
  } = V(["common", r]), l = o("explorer.filters.mine", {
    ns: r
  }), {
    setResourceOrFolderIsDraggable: a,
    setElementDragOver: c,
    setResourceIds: p,
    setFolderIds: i,
    fetchTreeData: d
  } = R(), h = $(), g = oe(xe, {
    activationConstraint: {
      delay: wt,
      tolerance: Dt
    }
  }), m = oe(Se), I = be(g, m), C = (S, D) => {
    var y;
    ((y = S.data.current) == null ? void 0 : y.type) === "resource" ? s.success(/* @__PURE__ */ b(W, { children: [
      o("explorer.dragged.resource"),
      " ",
      /* @__PURE__ */ n("strong", { children: D })
    ] })) : s.success(/* @__PURE__ */ b(W, { children: [
      o("explorer.dragged.folder"),
      " ",
      /* @__PURE__ */ n("strong", { children: D })
    ] }));
  };
  return {
    handleDragEnd: async (S) => {
      const {
        over: D,
        active: y
      } = S, f = D == null ? void 0 : D.data.current, w = y.data.current, v = ae(h, f == null ? void 0 : f.id), _ = le(h, f == null ? void 0 : f.id);
      if ((w == null ? void 0 : w.id) == (f == null ? void 0 : f.id) || v.includes(w == null ? void 0 : w.id) || _.includes(w == null ? void 0 : w.id))
        p([]), i([]);
      else {
        const j = (f == null ? void 0 : f.name) ?? l;
        if (D)
          try {
            await t.mutate(f == null ? void 0 : f.id), C(y, j);
          } catch (Ie) {
            console.error(Ie);
          } finally {
            c({
              isOver: !1,
              overId: void 0,
              canMove: !0,
              isTreeview: !1
            });
          }
      }
      a({
        isDrag: !1,
        elementDrag: void 0
      });
    },
    handleDragStart: (S) => {
      const {
        active: D
      } = S, y = D.data.current;
      (y == null ? void 0 : y.type) === "resource" ? p([y == null ? void 0 : y.id]) : (y == null ? void 0 : y.type) === "folder" && i([y == null ? void 0 : y.id]), a({
        isDrag: !0,
        elementDrag: y == null ? void 0 : y.id
      });
    },
    handleDragOver: (S) => {
      const {
        over: D,
        active: y
      } = S, f = D == null ? void 0 : D.data.current, w = y == null ? void 0 : y.data.current, v = ae(h, f == null ? void 0 : f.id), _ = le(h, f == null ? void 0 : f.id);
      if (D) {
        const j = {
          isOver: !0,
          canMove: !1,
          overId: f == null ? void 0 : f.id,
          isTreeview: f == null ? void 0 : f.isTreeview
        };
        (w == null ? void 0 : w.id) === (f == null ? void 0 : f.id) || v.includes(w == null ? void 0 : w.id) || _.includes(w == null ? void 0 : w.id) ? c({
          ...j,
          canMove: !1
        }) : (d(f == null ? void 0 : f.id, e), c({
          ...j,
          canMove: !0
        }));
      } else
        c({
          isOver: !1,
          overId: void 0,
          canMove: !0,
          isTreeview: !1
        });
    },
    sensors: I
  };
}
const Rt = /* @__PURE__ */ M(async () => await import("./EmptyScreenApp.js")), vt = /* @__PURE__ */ M(async () => await import("./EmptyScreenSearch.js")), Et = /* @__PURE__ */ M(async () => await import("./EmptyScreenError.js")), Lt = /* @__PURE__ */ M(async () => await import("./EmptyScreenNoContentInFolder.js")), Nt = /* @__PURE__ */ M(async () => await import("./EmptyScreenTrash.js")), At = /* @__PURE__ */ M(async () => await import("./FoldersList.js")), Mt = /* @__PURE__ */ M(async () => await import("./ResourcesList.js")), kt = () => {
  const e = mt(), t = re(), s = se(), r = A(), o = z(), l = U(), a = P(), {
    appCode: c
  } = Z(), {
    t: p
  } = V([c]), {
    setSearchParams: i,
    setSearchConfig: d,
    fetchTreeData: h
  } = R(), {
    data: u,
    isError: g,
    error: m,
    isLoading: I,
    isFetching: C,
    fetchNextPage: x
  } = bt(), F = (u == null ? void 0 : u.pages[0].folders.length) === 0, k = (u == null ? void 0 : u.pages[0].resources.length) === 0, S = F && k;
  return B(() => {
    var D, y;
    u && ((D = u == null ? void 0 : u.pages[0]) != null && D.searchConfig && d(u.pages[0].searchConfig), !r.search && o.id === "default" && h(o.id, a), i({
      ...r,
      pagination: (y = u == null ? void 0 : u.pages[(u == null ? void 0 : u.pages.length) - 1]) == null ? void 0 : y.pagination
    }));
  }, [u]), B(() => {
    m && typeof m == "string" && l.error(p(m));
  }, [m]), I ? /* @__PURE__ */ n(H, {}) : g ? /* @__PURE__ */ n(Q, { fallback: /* @__PURE__ */ n(H, {}), children: /* @__PURE__ */ n(Et, {}) }) : r.search && S ? /* @__PURE__ */ n(Q, { fallback: /* @__PURE__ */ n(H, {}), children: /* @__PURE__ */ n(vt, {}) }) : e && S ? /* @__PURE__ */ n(Q, { fallback: /* @__PURE__ */ n(H, {}), children: /* @__PURE__ */ n(Rt, {}) }) : s && S && !t ? /* @__PURE__ */ n(Q, { fallback: /* @__PURE__ */ n(H, {}), children: /* @__PURE__ */ n(Lt, {}) }) : t && (u == null ? void 0 : u.pages[0].resources.length) === 0 ? /* @__PURE__ */ n(Q, { fallback: /* @__PURE__ */ n(H, {}), children: /* @__PURE__ */ n(Nt, {}) }) : /* @__PURE__ */ b(Q, { fallback: /* @__PURE__ */ n(H, {}), children: [
    /* @__PURE__ */ n(At, { data: u, isFetching: C }),
    /* @__PURE__ */ n(Mt, { data: u, isFetching: C, fetchNextPage: x })
  ] });
}, Pt = ({
  title: e,
  titleId: t,
  ...s
}) => /* @__PURE__ */ b("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", viewBox: "0 0 24 24", "aria-hidden": "true", "aria-labelledby": t, ...s, children: [
  e ? /* @__PURE__ */ n("title", { id: t, children: e }) : null,
  /* @__PURE__ */ n("path", { fill: "currentColor", fillRule: "evenodd", d: "M4 12a1 1 0 0 1 1-1h14a1 1 0 1 1 0 2H5a1 1 0 0 1-1-1", clipRule: "evenodd" }),
  /* @__PURE__ */ n("path", { fill: "currentColor", fillRule: "evenodd", d: "M12.707 4.293a1 1 0 0 1 0 1.414L6.414 12l6.293 6.293a1 1 0 0 1-1.414 1.414l-7-7a1 1 0 0 1 0-1.414l7-7a1 1 0 0 1 1.414 0", clipRule: "evenodd" })
] }), Ht = ({
  title: e,
  titleId: t,
  ...s
}) => /* @__PURE__ */ b("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", viewBox: "0 0 24 24", "aria-hidden": "true", "aria-labelledby": t, ...s, children: [
  e ? /* @__PURE__ */ n("title", { id: t, children: e }) : null,
  /* @__PURE__ */ n("path", { fill: "currentColor", fillRule: "evenodd", d: "M9.461 3.689a.96.96 0 0 1 .675-.28h3.819a.955.955 0 0 1 .954.955v.954H9.182v-.954c0-.254.1-.496.28-.675m7.357.675v.954h3.818a.955.955 0 0 1 0 1.91h-.954v12.408a2.864 2.864 0 0 1-2.864 2.864H7.273a2.864 2.864 0 0 1-2.864-2.864V7.227h-.954a.955.955 0 1 1 0-1.909h3.818v-.954A2.864 2.864 0 0 1 10.136 1.5h3.819a2.864 2.864 0 0 1 2.863 2.864m-10.5 2.863v12.41a.954.954 0 0 0 .955.954h9.545a.955.955 0 0 0 .955-.955V7.227zm3.818 2.864c.528 0 .955.427.955.955v5.727a.955.955 0 1 1-1.91 0v-5.727c0-.528.428-.955.955-.955m4.773 6.682v-5.727a.955.955 0 0 0-1.909 0v5.727a.955.955 0 1 0 1.91 0", clipRule: "evenodd" })
] }), Qt = ({
  title: e,
  titleId: t,
  ...s
}) => /* @__PURE__ */ b("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", viewBox: "0 0 24 24", "aria-hidden": "true", "aria-labelledby": t, ...s, children: [
  e ? /* @__PURE__ */ n("title", { id: t, children: e }) : null,
  /* @__PURE__ */ n("path", { fill: "currentColor", fillRule: "evenodd", d: "M1.093 2.58A1 1 0 0 1 2 2h20a1 1 0 0 1 .764 1.646L15 12.826V21a1 1 0 0 1-1.447.894l-4-2A1 1 0 0 1 9 19v-6.174l-7.764-9.18a1 1 0 0 1-.143-1.067M4.155 4l6.609 7.814a1 1 0 0 1 .236.646v5.922l2 1V12.46a1 1 0 0 1 .236-.646L19.845 4z", clipRule: "evenodd" })
] }), Ut = ({
  title: e,
  titleId: t,
  ...s
}) => /* @__PURE__ */ b("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", viewBox: "0 0 24 24", "aria-hidden": "true", "aria-labelledby": t, ...s, children: [
  e ? /* @__PURE__ */ n("title", { id: t, children: e }) : null,
  /* @__PURE__ */ n("path", { fill: "currentColor", fillRule: "evenodd", d: "M13 4a1 1 0 1 0-2 0v7H4a1 1 0 1 0 0 2h7v7a1 1 0 1 0 2 0v-7h7a1 1 0 1 0 0-2h-7z", clipRule: "evenodd" })
] }), Ce = () => {
  const e = A(), [t, s] = ie(""), r = ht(), o = yt(), l = we(null), {
    setSearchParams: a
  } = R(), c = (d) => {
    const h = d.target.value;
    s(h.toString());
  }, p = (d) => {
    (d.key === "Enter" || d.key === "Return") && (d.preventDefault(), a({
      search: t || void 0
    }));
  }, i = (d) => {
    d.preventDefault(), a({
      search: t || void 0
    });
  };
  return B(() => {
    const h = t.length == 0 || t.length >= r.minLength ? {
      search: t || void 0
    } : {};
    a({
      ...e,
      ...h
    });
  }, [t, r.minLength]), B(() => {
    o === "select" && s("");
  }, [o]), B(() => {
    s(() => {
      var d;
      return ((d = e.search) == null ? void 0 : d.toString()) ?? "";
    });
  }, [e]), {
    formRef: l,
    inputSearch: t,
    handleInputSearchChange: c,
    handleKeyPress: p,
    handleSearchSubmit: i
  };
}, Zt = () => {
  const {
    appCode: e,
    currentApp: t
  } = Z(), {
    t: s
  } = V(), [r, o] = ie(""), l = (d) => {
    if (d === "0") {
      o("");
      return;
    }
    o(d);
  }, a = z(), c = A(), {
    setSearchParams: p
  } = R();
  B(() => {
    const d = () => r.includes("1") ? !0 : void 0, h = () => r.includes("2") ? !0 : void 0, u = () => r.includes("7") ? !0 : void 0;
    p({
      ...c,
      filters: {
        owner: d(),
        public: u(),
        shared: h(),
        folder: a ? a.id : "default"
      }
    });
  }, [a, p, r]);
  const i = [{
    label: s("explorer.filter.all", {
      ns: e
    }),
    value: "0"
  }, {
    label: s("explorer.filter.owner", {
      ns: e
    }),
    value: "1"
  }, {
    label: s("explorer.filter.shared", {
      ns: e
    }),
    value: "2"
  }, ...(t == null ? void 0 : t.displayName) == "exercizer" ? [{
    label: "Exercices interactifs",
    value: "3"
  }] : [], ...(t == null ? void 0 : t.displayName) == "exercizer" ? [{
    label: "Exercices à rendre",
    value: "4"
  }] : [], ...(t == null ? void 0 : t.displayName) == "pages" ? [{
    label: "Projets publics",
    value: "5"
  }] : [], ...(t == null ? void 0 : t.displayName) == "pages" ? [{
    label: "Projets internes",
    value: "6"
  }] : [], ...(t == null ? void 0 : t.displayName) == "blog" ? [{
    label: s("explorer.filter.public", {
      ns: e
    }),
    value: "7"
  }] : []];
  return {
    selectedFilters: r,
    options: i,
    handleOnSelectFilter: l
  };
}, Ot = () => {
  const {
    appCode: e
  } = Z(), {
    t
  } = V(), {
    selectedFilters: s,
    options: r,
    handleOnSelectFilter: o
  } = Zt(), {
    formRef: l,
    inputSearch: a,
    handleInputSearchChange: c,
    handleKeyPress: p,
    handleSearchSubmit: i
  } = Ce(), d = s.length > 0 ? s.length : void 0;
  return /* @__PURE__ */ b("form", { noValidate: !0, className: "bg-light p-16 ps-24 ms-n16 ms-lg-n24 me-n16 position-relative d-flex gap-8", ref: l, children: [
    /* @__PURE__ */ b(He, { id: "search", className: "input-group", children: [
      /* @__PURE__ */ n(Qe, { type: "search", placeholder: t("explorer.label.search", {
        ns: e
      }), size: "lg", noValidationIcon: !0, value: a, onChange: c, onKeyDown: p }),
      /* @__PURE__ */ n(Ue, { type: "submit", "aria-label": t("explorer.label.search", {
        ns: e
      }), onClick: i })
    ] }),
    /* @__PURE__ */ b(K, { placement: "bottom-end", children: [
      /* @__PURE__ */ n(K.Trigger, { label: t("explorer.filters"), icon: /* @__PURE__ */ n(Qt, { width: 20 }), variant: "ghost", badgeContent: d }),
      /* @__PURE__ */ n(K.Menu, { children: r.map((h) => h.value === "0" ? /* @__PURE__ */ b(De, { children: [
        /* @__PURE__ */ n(K.RadioItem, { value: h.value, model: s, onChange: () => o(h.value), children: h.label }),
        /* @__PURE__ */ n(K.Separator, {})
      ] }, "0") : /* @__PURE__ */ n(K.RadioItem, { value: h.value, model: s, onChange: () => o(h.value), children: h.label }, h.value)) })
    ] })
  ] });
}, qt = ({
  id: e,
  selected: t,
  onSelect: s
}) => {
  const {
    t: r
  } = V();
  return /* @__PURE__ */ n("div", { className: "treeview", children: /* @__PURE__ */ n("ul", { role: "tree", className: "m-0 p-0", children: /* @__PURE__ */ n("li", { id: e, role: "treeitem", "aria-selected": t, children: /* @__PURE__ */ n("div", { children: /* @__PURE__ */ n("div", { className: "action-container", children: /* @__PURE__ */ n("div", { onClick: s, role: "button", tabIndex: 0, children: /* @__PURE__ */ b("div", { className: "d-flex align-items-center gap-8 py-8 ps-24", children: [
    /* @__PURE__ */ n(Ht, { width: "20", height: "20" }),
    /* @__PURE__ */ n("span", { children: r("explorer.tree.trash") })
  ] }) }) }) }) }) }) });
}, Bt = /* @__PURE__ */ M(async () => await import("./FolderModal.js")), Vt = () => {
  const [e, t] = Ze(), s = P(), r = $(), o = re(), l = se(), a = ft(), c = Oe(), p = o ? E.BIN : l, {
    appCode: i
  } = Z(), {
    t: d
  } = V(["common", i]), h = {
    ...r,
    name: d("explorer.filters.mine", {
      ns: i
    })
  }, {
    goToTrash: u,
    selectTreeItem: g,
    clearSelectedItems: m,
    clearSelectedIds: I,
    fetchTreeData: C
  } = R(), x = (S) => {
    g(S, s), c();
  }, F = (S) => {
    var f, w;
    const D = G(r, S), y = (f = D == null ? void 0 : D.children) == null ? void 0 : f.some((v) => {
      var _;
      return Array.isArray(v == null ? void 0 : v.children) && ((_ = v.children) == null ? void 0 : _.length) > 0;
    });
    (w = D == null ? void 0 : D.children) == null || w.forEach((v) => {
      y || C(v.id, s);
    });
  }, k = () => {
    m(), I(), t();
  };
  return /* @__PURE__ */ b(W, { children: [
    /* @__PURE__ */ n(qe, { data: h, selectedNodeId: p, draggedNode: a != null && a.isTreeview ? a : void 0, onTreeItemClick: x, onTreeItemUnfold: F }),
    /* @__PURE__ */ n(qt, { id: E.BIN, selected: o, onSelect: u }),
    /* @__PURE__ */ n("div", { className: "d-grid my-16", children: /* @__PURE__ */ n(Be, { disabled: o, type: "button", color: "primary", variant: "outline", leftIcon: /* @__PURE__ */ n(Ut, {}), onClick: k, children: d("explorer.folder.new") }) }),
    /* @__PURE__ */ n(Q, { fallback: /* @__PURE__ */ n(H, {}), children: e && /* @__PURE__ */ n(Bt, { edit: !1, isOpen: e, onSuccess: t, onCancel: t }) })
  ] });
};
function _t() {
  const {
    appCode: e
  } = Z(), {
    gotoPreviousFolder: t
  } = R(), {
    t: s
  } = V(["common", e]), {
    inputSearch: r
  } = Ce(), o = se(), l = re(), a = z(), c = s("explorer.tree.trash"), p = s("explorer.tree.search"), i = s("explorer.filters.mine", {
    ns: e
  }), d = (a == null ? void 0 : a.name) || i;
  return /* @__PURE__ */ n("div", { className: "py-16", children: o && o !== "bin" && o !== "default" && !l ? /* @__PURE__ */ b("div", { className: "d-flex align-items-center gap-8", children: [
    /* @__PURE__ */ n(Ve, { icon: /* @__PURE__ */ n(Pt, {}), variant: "ghost", color: "tertiary", "aria-label": s("back"), className: "ms-n16", onClick: t }),
    /* @__PURE__ */ n("p", { className: "body py-8 text-truncate", children: /* @__PURE__ */ n("strong", { children: d }) })
  ] }) : /* @__PURE__ */ n("h2", { className: "body py-8 fw-bold", children: r.length !== 0 ? p : l ? c : i }) });
}
const Kt = "data:image/svg+xml,%3csvg%20width='300'%20height='214'%20viewBox='0%200%20300%20214'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='300'%20height='214'%20fill='white'/%3e%3cpath%20d='M240.604%2031H54.6988C49.9309%2031%2046.0662%2034.8647%2046.0662%2039.6327V135.326C46.0662%20140.094%2049.9309%20143.959%2054.6988%20143.959H240.6C245.368%20143.959%20249.233%20140.094%20249.233%20135.326V39.6327C249.233%2034.8647%20245.368%2031%20240.6%2031H240.604ZM133.102%20115.945C133.102%20119.76%20130.009%20122.853%20126.194%20122.853H71.4939C67.6787%20122.853%2064.5853%20119.76%2064.5853%20115.945V59.0139C64.5853%2055.1987%2067.6787%2052.1053%2071.4939%2052.1053H126.198C130.013%2052.1053%20133.106%2055.1987%20133.106%2059.0139V115.945H133.102ZM235.745%20121.212H196.768C194.945%20121.212%20193.469%20119.735%20193.469%20117.912C193.469%20116.089%20194.945%20114.613%20196.768%20114.613H235.745C237.568%20114.613%20239.045%20116.089%20239.045%20117.912C239.045%20119.735%20237.568%20121.212%20235.745%20121.212ZM234.335%2061.9464H153.205C150.574%2061.9464%20148.441%2059.814%20148.441%2057.1826C148.441%2054.5511%20150.574%2052.4187%20153.205%2052.4187H234.335C236.966%2052.4187%20239.099%2054.5511%20239.099%2057.1826C239.099%2059.814%20236.966%2061.9464%20234.335%2061.9464Z'%20fill='%23FFEFE3'/%3e%3cmask%20id='mask0_2657_113137'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='154'%20y='81'%20width='24'%20height='8'%3e%3cpath%20d='M171.836%2088.8962L177.833%2081.7153H160.732L155.672%2087.7702L155.556%2087.7372L154.595%2088.8962H171.832H171.836Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_2657_113137)'%3e%3cpath%20d='M186.738%2051.2433C191.947%2055.6153%20192.627%2063.3818%20188.259%2068.5911L136.554%20130.5L127.121%20122.585L186.742%2051.2433H186.738Z'%20fill='%23AADAED'/%3e%3cpath%20opacity='0.05'%20d='M139.12%20127.428L157.482%20105.44L155.878%2088.0011L138.819%20108.583L139.12%20127.428Z'%20fill='black'/%3e%3c/g%3e%3cpath%20d='M262.147%2088.8962H38.5883C36.6044%2088.8962%2035%2087.2876%2035%2085.3037C35%2083.3198%2036.6086%2081.7112%2038.5883%2081.7112H262.147C264.13%2081.7112%20265.735%2083.3198%20265.735%2085.3037C265.735%2087.2876%20264.126%2088.8962%20262.147%2088.8962Z'%20fill='%232A9CC8'/%3e%3cmask%20id='mask1_2657_113137'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='79'%20y='38'%20width='113'%20height='160'%3e%3cpath%20d='M79.5574%2038.317V197.586H191.959V38.317H79.5574ZM171.836%2088.8962H154.599L155.56%2087.7372L155.676%2087.7702L160.737%2081.7153H177.837L171.84%2088.8962H171.836Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask1_2657_113137)'%3e%3cpath%20d='M186.738%2051.2433C191.947%2055.6153%20192.627%2063.3818%20188.259%2068.5911L136.554%20130.5L127.121%20122.585L186.742%2051.2433H186.738Z'%20fill='%23AADAED'/%3e%3cpath%20opacity='0.05'%20d='M139.12%20127.428L157.482%20105.44L155.878%2088.0011L138.819%20108.583L139.12%20127.428Z'%20fill='black'/%3e%3cpath%20d='M154.092%2039.1419C147.291%2039.1419%20141.78%2044.6564%20141.78%2051.4536L141.603%20132.113H153.915L154.092%2039.1377V39.1419Z'%20fill='%23AADAED'/%3e%3cpath%20d='M106.26%20128.43C112.071%20127.84%20117.61%20125.687%20122.395%20122.338C124.3%20121.006%20126.202%20119.669%20128.107%20118.337C129.122%20117.624%20130.52%20117.822%20131.296%20118.791C133.713%20121.798%20136.15%20124.656%20138.567%20127.667C138.815%20127.976%20139.021%20129.387%20138.464%20130.748C137.965%20131.973%20137.128%20132.237%20135.461%20134.023C134.954%20134.567%20134.517%20135.132%20133.642%20136.271C130.92%20139.801%20127.34%20146.174%20124.968%20149.927C122.42%20153.957%20120.114%20156.786%20118.889%20158.275C114.389%20163.752%20111.597%20167.155%20107.732%20169.308C101.257%20172.913%2090.2894%20173.841%2084.4325%20168.124C76.5134%20160.395%2081.3432%20143.88%2089.2335%20136.06C94.6119%20130.731%20101.236%20128.941%20106.264%20128.43H106.26ZM91.0937%20159.698C94.3892%20163.596%20103.595%20161.764%20108.804%20157.104C113.486%20152.913%20116.728%20144.837%20113.502%20140.944C110.281%20137.054%20101.743%20138.7%2096.7566%20142.556C91.1473%20146.895%2087.7775%20155.78%2091.0937%20159.702V159.698Z'%20fill='%23AADAED'/%3e%3cpath%20d='M165.558%20152.909C161.739%20148.492%20159.186%20143.121%20158.006%20137.401C157.536%20135.124%20157.07%20132.847%20156.6%20130.57C156.348%20129.354%20155.197%20128.541%20153.968%20128.71C150.145%20129.238%20146.412%20129.642%20142.589%20130.17C142.197%20130.224%20141.079%20131.107%20140.547%20132.48C140.068%20133.713%20140.497%20134.481%20140.481%20136.926C140.477%20137.669%20140.407%20138.382%20140.262%20139.809C139.821%20144.247%20138.047%20151.338%20137.194%20155.693C136.278%20160.374%20136.014%20164.016%20135.882%20165.938C135.391%20173.008%20135.086%20177.4%20136.422%20181.62C138.658%20188.689%20145.995%20196.889%20154.178%20196.753C165.245%20196.567%20173.069%20181.245%20172.702%20170.141C172.45%20162.573%20168.862%20156.724%20165.558%20152.905V152.909ZM155.123%20186.058C150.05%20186.631%20144.614%20178.976%20144.028%20172.01C143.5%20165.749%20146.688%20157.652%20151.704%20157.034C156.715%20156.415%20161.796%20163.476%20162.774%20169.7C163.875%20176.703%20160.225%20185.48%20155.123%20186.054V186.058Z'%20fill='%23AADAED'/%3e%3c/g%3e%3c/svg%3e", $t = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='version_orange'%20data-name='version%20orange'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20576%20353.36'%3e%3cdefs%3e%3cstyle%3e%20.cls-1%20{%20fill:%20%23fff;%20}%20.cls-2%20{%20fill:%20%23aadaed;%20}%20.cls-3%20{%20fill:%20%23ffefe3;%20}%20.cls-4%20{%20fill:%20none;%20stroke:%20%23aadaed;%20stroke-miterlimit:%2010;%20stroke-width:%204px;%20}%20.cls-5%20{%20fill:%20%232a9cc8;%20}%20%3c/style%3e%3c/defs%3e%3cg%20id='ciseaux'%3e%3cpath%20class='cls-3'%20d='m512.64,45.09H61.92c-11.56,0-20.93,9.37-20.93,20.93v232.01c0,11.56,9.37,20.93,20.93,20.93h450.72c11.56,0,20.93-9.37,20.93-20.93V66.02c0-11.56-9.37-20.93-20.93-20.93ZM211.25,212.37c0,7.55-6.12,13.66-13.66,13.66h-108.21c-7.55,0-13.66-6.12-13.66-13.66v-112.62c0-7.55,6.12-13.66,13.66-13.66h108.21c7.55,0,13.66,6.12,13.66,13.66v112.62Zm150.21-41.03h-94.5c-4.42,0-8-3.58-8-8s3.58-8,8-8h94.5c4.42,0,8,3.58,8,8s-3.58,8-8,8Zm105.82,118.05H164.74c-4.42,0-8-3.58-8-8s3.58-8,8-8h302.55c4.42,0,8,3.58,8,8s-3.58,8-8,8Zm-3.54-169.27h-196.7c-6.38,0-11.55-5.17-11.55-11.55s5.17-11.55,11.55-11.55h196.7c6.38,0,11.55,5.17,11.55,11.55s-5.17,11.55-11.55,11.55Zm-332.66,158.93c0,13.56-10.99,24.55-24.55,24.55s-24.55-10.99-24.55-24.55,10.99-24.55,24.55-24.55,24.55,10.99,24.55,24.55Z'/%3e%3c/g%3e%3crect%20class='cls-5'%20x='420.8'%20y='58.38'%20width='100.39'%20height='100.39'%20rx='20'%20ry='20'/%3e%3cg%20id='ciseaux-2'%20data-name='ciseaux'%3e%3cpath%20class='cls-4'%20d='m513.58,45.09H60.99c-11.05,0-20,8.95-20,20v233.88c0,11.05,8.95,20,20,20h452.59c11.05,0,20-8.95,20-20V65.09c0-11.05-8.95-20-20-20Z'/%3e%3c/g%3e%3ccircle%20class='cls-1'%20cx='471'%20cy='84.02'%20r='7.02'/%3e%3ccircle%20class='cls-1'%20cx='471'%20cy='109.3'%20r='7.02'/%3e%3ccircle%20class='cls-1'%20cx='471'%20cy='133.13'%20r='7.02'/%3e%3cg%3e%3cpath%20class='cls-2'%20d='m449.99,215.32c-.39,0-.76-.08-1.12-.24l-9.44-4.22c-.69-.31-1.23-.9-1.48-1.62-.25-.72-.18-1.52.17-2.19l3.92-7.33-13.25-5.79c-.83-.36-1.43-1.11-1.6-2.01s.11-1.81.76-2.45l40.08-40.08c.52-.52,1.21-.81,1.94-.81,1.52,0,2.75,1.23,2.75,2.75v57.58c0,.75-.3,1.45-.83,1.97-.52.5-1.2.78-1.91.78h0c-.38,0-.75-.08-1.1-.23l-12.85-5.61-3.53,7.87c-.44.99-1.43,1.62-2.51,1.62Z'/%3e%3cpath%20class='cls-1'%20d='m469.97,150.6c.38,0,.75.3.75.75v57.58c0,.43-.35.75-.75.75-.1,0-.2-.02-.3-.06l-13.99-6.11c-.1-.04-.2-.06-.3-.06-.29,0-.56.16-.68.44l-4.03,9c-.12.28-.4.44-.68.44-.1,0-.21-.02-.3-.07l-9.44-4.22c-.4-.18-.56-.65-.35-1.04l4.56-8.53c.21-.38.04-.86-.36-1.04l-14.5-6.33c-.48-.21-.6-.84-.23-1.21l40.08-40.08c.15-.15.34-.22.52-.22m0-4c-1.26,0-2.45.49-3.35,1.39l-40.08,40.08c-1.11,1.11-1.6,2.7-1.31,4.24.29,1.54,1.33,2.84,2.77,3.47l11.27,4.92-2.9,5.42c-.62,1.16-.73,2.53-.31,3.78.42,1.24,1.36,2.26,2.55,2.8l9.44,4.22c.61.27,1.27.41,1.94.41,1.87,0,3.57-1.1,4.33-2.81l2.72-6.06,11.04,4.82c.6.26,1.24.4,1.9.4,2.62,0,4.75-2.13,4.75-4.75v-57.58c0-2.62-2.13-4.75-4.75-4.75h0Z'/%3e%3c/g%3e%3c/svg%3e", zt = "data:image/svg+xml,%3csvg%20width='300'%20height='214'%20viewBox='0%200%20300%20214'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='300'%20height='214'%20fill='white'/%3e%3cpath%20d='M187.994%20193.875H108.563C103.268%20193.875%2098.878%20189.768%2098.5214%20184.484L90.1194%2059.0277H209.67L198.01%20184.741C197.529%20189.915%20193.19%20193.875%20187.99%20193.875H187.994Z'%20fill='%23FFEFE3'/%3e%3cpath%20d='M150.47%20150.31L164.483%20157.961C166.929%20159.296%20169.995%20158.395%20171.33%20155.95C171.999%20154.726%20172.106%20153.35%20171.742%20152.111C171.378%20150.872%20170.539%20149.773%20169.319%20149.103C167.223%20147.96%20166.638%20146.217%20166.954%20144.029C168.388%20134.186%20188.167%20115.393%20171.091%20102.13L162.134%2097.2392C141.741%2090.047%20136.626%20116.845%20129.121%20123.372C127.456%20124.824%20125.672%20125.273%20123.577%20124.126C121.131%20122.791%20118.065%20123.692%20116.73%20126.137C116.061%20127.358%20115.954%20128.736%20116.318%20129.976C116.682%20131.215%20117.521%20132.314%20118.741%20132.983L131.537%20139.97L132.751%20140.632L150.467%20150.306L150.47%20150.31Z'%20fill='%23AADAED'/%3e%3cpath%20opacity='0.2'%20d='M171.095%20102.13L171.117%20102.144L171.095%20102.13Z'%20fill='%23AADAED'/%3e%3cpath%20d='M171.095%20102.13L171.117%20102.141C171.187%20102.034%20171.253%20101.924%20171.315%20101.81C172.676%2099.3167%20171.76%2096.1913%20169.267%2094.8308C166.774%2093.4703%20163.649%2094.3895%20162.288%2096.8789C162.226%2096.9929%20162.167%2097.1068%20162.115%2097.2245L162.137%2097.2355L171.095%20102.126V102.13Z'%20fill='%23AADAED'/%3e%3cpath%20d='M133.67%20142.455C138.56%20145.228%20143.451%20148%20148.341%20150.773C146.422%20154.365%20142.929%20156.483%20139.421%20156.23C138.921%20156.193%20136.292%20155.954%20134.328%20153.884C131.769%20151.188%20131.438%20146.563%20133.674%20142.459L133.67%20142.455Z'%20fill='%23AADAED'/%3e%3cpath%20d='M145.56%2088.6624C145.125%2086.8475%20143.302%2085.7288%20141.488%2086.1636C139.674%2086.5984%20138.556%2088.4221%20138.991%2090.2369L156.729%20164.233C157.164%20166.048%20158.987%20167.166%20160.801%20166.732C162.615%20166.297%20163.732%20164.473%20163.297%20162.658L145.56%2088.6624Z'%20fill='%232A9CC8'/%3e%3cpath%20d='M214.66%2037.9143H195.186L189.833%2028.707C187.068%2023.9526%20181.938%2021%20176.441%2021H125.492C120.44%2021%20115.693%2023.471%20112.796%2027.6149L105.592%2037.9143H85.1334C81.1916%2037.9143%2078%2041.1096%2078%2045.0477V46.592C78%2050.5338%2081.1953%2053.7254%2085.1334%2053.7254H214.66C218.602%2053.7254%20221.793%2050.5301%20221.793%2046.592V45.0477C221.793%2041.1059%20218.598%2037.9143%20214.66%2037.9143ZM122.437%2034.3586C123.132%2033.3621%20124.275%2032.7664%20125.489%2032.7664H176.437C177.761%2032.7664%20178.993%2033.4761%20179.658%2034.6196L181.574%2037.9143H119.947L122.433%2034.3586H122.437Z'%20fill='%23FFEFE3'/%3e%3cpath%20d='M187.064%2093.9335C187.56%2093.9777%20188.046%2093.7864%20188.542%2093.7313C189.038%2093.6761%20189.63%2093.8232%20189.822%2094.2828C190.108%2094.9778%20189.274%2095.6911%20189.369%2096.4376C189.424%2096.8604%20189.763%2097.1803%20190.079%2097.4635C190.719%2098.0334%20191.362%2098.607%20192.002%2099.177C192.164%2099.3204%20192.329%2099.4748%20192.384%2099.6807C192.454%2099.9307%20192.34%20100.192%20192.245%20100.434C191.829%20101.49%20191.789%20102.894%20192.723%20103.542C192.98%20103.722%20193.304%20103.828%20193.488%20104.086C193.693%20104.376%20193.66%20104.766%20193.605%20105.119C193.473%20105.994%20193.278%20106.858%20193.021%20107.708'%20stroke='white'%20stroke-width='6.05'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M105.681%20138.694C105.611%20140.003%20105.658%20141.562%20106.751%20142.29C106.993%20142.452%20107.276%20142.558%20107.493%20142.757C108.122%20143.331%20107.931%20144.353%20107.633%20145.151C107.335%20145.949%20106.982%20146.868%20107.409%20147.6C107.817%20148.298%20108.762%20148.493%20109.284%20149.111C109.813%20149.732%20109.828%20150.685%20110.387%20151.28C110.626%20151.534%20110.964%20151.721%20111.089%20152.049C111.189%20152.31%20111.126%20152.597%20111.126%20152.876C111.126%20153.63%20111.597%20154.321%20112.196%20154.781C112.796%20155.24%20113.516%20155.501%20114.226%20155.755'%20stroke='white'%20stroke-width='6.05'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e", jt = /* @__PURE__ */ M(async () => await import("./AppAction.js")), Wt = /* @__PURE__ */ M(async () => await import("./Library.js")), Gt = /* @__PURE__ */ M(async () => await import("./ActionBarContainer.js")), Jt = /* @__PURE__ */ M(async () => await import("./DisableModal.js")), Xt = /* @__PURE__ */ M(async () => await import("./TrashModal.js")), Yt = /* @__PURE__ */ M(async () => await import("./OnboardingModal.js")), Fs = ({
  config: e
}) => {
  const t = A(), {
    setConfig: s,
    setSearchParams: r
  } = R();
  B(() => {
    s(e || {}), r({
      ...t,
      application: e.app,
      types: e.types
    });
  }, [e]);
  const {
    currentApp: o
  } = Z(), {
    data: l
  } = St(e.actions), {
    isTrashedModalOpen: a,
    onTrashedCancel: c
  } = It(), {
    isActionDisableModalOpen: p,
    onActionDisableCancel: i
  } = Ct(), {
    handleDragEnd: d,
    handleDragOver: h,
    handleDragStart: u,
    sensors: g
  } = Ft();
  _e();
  const m = ne("publish", l), I = ne("create", l);
  return e && /* @__PURE__ */ b(W, { children: [
    /* @__PURE__ */ n(Ke, { render: () => I ? /* @__PURE__ */ n(Q, { fallback: /* @__PURE__ */ n(H, {}), children: /* @__PURE__ */ n(jt, { onResourceCreated: e.onResourceCreated }) }) : null, children: /* @__PURE__ */ n($e, { app: o }) }),
    /* @__PURE__ */ n(te, { className: "flex-grow-1", children: /* @__PURE__ */ b(Te, { sensors: g, modifiers: [Fe], onDragStart: u, onDragEnd: d, onDragOver: h, children: [
      /* @__PURE__ */ n(te.Col, { sm: "3", lg: "2", xl: "3", className: "border-end pt-16 pe-16 d-none d-lg-block", as: "aside", children: /* @__PURE__ */ b(Q, { fallback: /* @__PURE__ */ n(H, {}), children: [
        /* @__PURE__ */ n(Vt, {}),
        m && /* @__PURE__ */ n(Wt, {})
      ] }) }),
      /* @__PURE__ */ b(te.Col, { sm: "4", md: "8", lg: "6", xl: "9", children: [
        /* @__PURE__ */ n(Ot, {}),
        /* @__PURE__ */ n(_t, {}),
        /* @__PURE__ */ n(kt, {})
      ] }),
      /* @__PURE__ */ b(Q, { fallback: /* @__PURE__ */ n(H, {}), children: [
        /* @__PURE__ */ n(Gt, {}),
        e.enableOnboarding && /* @__PURE__ */ n(Yt, { id: "showOnboardingTrash", items: [{
          src: $t,
          alt: "explorer.modal.onboarding.trash.screen1.alt",
          text: "explorer.modal.onboarding.trash.screen1.title"
        }, {
          src: zt,
          alt: "explorer.modal.onboarding.trash.screen2.alt",
          text: "explorer.modal.onboarding.trash.screen2.alt"
        }, {
          src: Kt,
          alt: "explorer.modal.onboarding.trash.screen3.alt",
          text: "explorer.modal.onboarding.trash.screen3.title"
        }], modalOptions: {
          title: "explorer.modal.onboarding.trash.title",
          prevText: "explorer.modal.onboarding.trash.prev",
          nextText: "explorer.modal.onboarding.trash.next",
          closeText: "explorer.modal.onboarding.trash.close"
        } }),
        a && /* @__PURE__ */ n(Xt, { isOpen: a, onCancel: c }),
        p && /* @__PURE__ */ n(Jt, { isOpen: p, onCancel: i })
      ] })
    ] }) })
  ] });
};
export {
  bs as A,
  xs as B,
  Fs as E,
  Ut as S,
  ds as a,
  us as b,
  hs as c,
  ws as d,
  Ds as e,
  Ts as f,
  ms as g,
  z as h,
  Is as i,
  ft as j,
  J as k,
  re as l,
  Tt as m,
  X as n,
  pt as o,
  gs as p,
  Cs as q,
  A as r,
  ps as s,
  fs as t,
  St as u,
  Ss as v,
  R as w,
  T as x,
  ys as y,
  $ as z
};
