@rubytech/create-maxy-code 0.1.349 → 0.1.350
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/payload/platform/docs/superpowers/plans/2026-06-23-account-filesystem-schema.md +544 -0
- package/payload/platform/docs/superpowers/specs/2026-06-23-account-filesystem-schema-design.md +170 -0
- package/payload/platform/plugins/admin/hooks/__tests__/fs-schema-guard.test.sh +68 -0
- package/payload/platform/plugins/admin/hooks/fs-schema-guard.sh +108 -0
- package/payload/platform/scripts/lib/provision-account-dir.sh +22 -3
- package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js +45 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts +11 -0
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +18 -0
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/system-prompt.d.ts +1 -0
- package/payload/platform/services/claude-session-manager/dist/system-prompt.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/system-prompt.js +16 -0
- package/payload/platform/services/claude-session-manager/dist/system-prompt.js.map +1 -1
- package/payload/platform/templates/account-schema/SCHEMA.md +54 -0
- package/payload/server/public/assets/data-CBrgiyPM.js +1 -0
- package/payload/server/public/data.html +1 -1
- package/payload/server/server.js +60 -16
- package/payload/server/public/assets/data-CH6GNBO3.js +0 -1
package/payload/server/server.js
CHANGED
|
@@ -7254,6 +7254,7 @@ var CHANNEL_REPLY_TOOL = "mcp__channel__reply";
|
|
|
7254
7254
|
var CHANNEL_REPLY_DOCUMENT_TOOL = "mcp__channel__reply-document";
|
|
7255
7255
|
var SEND_USER_FILE_TOOL = "SendUserFile";
|
|
7256
7256
|
var CLI_MARKER_PREFIXES2 = ["<local-command-", "<command-name>", "<command-message>"];
|
|
7257
|
+
var HARNESS_LIFECYCLE_PREFIXES = ["<task-notification>"];
|
|
7257
7258
|
var CHANNEL_WRAPPER2 = /^<channel\b([^>]*)>\n?([\s\S]*?)\n?<\/channel>$/;
|
|
7258
7259
|
var SOURCE_ATTR2 = /\bsource="([^"]+)"/;
|
|
7259
7260
|
var SOURCE_MAP = {
|
|
@@ -7429,6 +7430,7 @@ function parseTranscript(lines, queuedPendingSuppress = /* @__PURE__ */ new Map(
|
|
|
7429
7430
|
const text = asString(msg.content);
|
|
7430
7431
|
if (text === null) continue;
|
|
7431
7432
|
if (CLI_MARKER_PREFIXES2.some((p) => text.startsWith(p))) continue;
|
|
7433
|
+
if (HARNESS_LIFECYCLE_PREFIXES.some((p) => text.startsWith(p))) continue;
|
|
7432
7434
|
const isChannel = row.isMeta === true && typeof row.origin === "object" && row.origin !== null && row.origin.kind === "channel";
|
|
7433
7435
|
if (isChannel) {
|
|
7434
7436
|
renderOrSuppressChannelInbound(unwrapChannel(text), ts, out, queuedPendingSuppress);
|
|
@@ -12718,7 +12720,7 @@ import { createReadStream as createReadStream2, createWriteStream as createWrite
|
|
|
12718
12720
|
import { readdir as readdir3, readFile as readFile5, stat as stat5, mkdir as mkdir3, unlink as unlink2, rename } from "fs/promises";
|
|
12719
12721
|
import { realpathSync as realpathSync6 } from "fs";
|
|
12720
12722
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
12721
|
-
import { basename as basename8, dirname as dirname6, join as join25, resolve as resolve24, sep as sep6 } from "path";
|
|
12723
|
+
import { basename as basename8, dirname as dirname6, join as join25, relative as relative4, resolve as resolve24, sep as sep6 } from "path";
|
|
12722
12724
|
import { Readable as Readable2 } from "stream";
|
|
12723
12725
|
|
|
12724
12726
|
// ../lib/graph-trash/src/index.ts
|
|
@@ -13871,6 +13873,26 @@ app20.get("/download", requireAdminSession, async (c) => {
|
|
|
13871
13873
|
});
|
|
13872
13874
|
var ZIP_MAX_FILES = 200;
|
|
13873
13875
|
var ZIP_MAX_TOTAL_BYTES = 256 * 1024 * 1024;
|
|
13876
|
+
function zipMaxFiles() {
|
|
13877
|
+
const override = Number(process.env.MAXY_ZIP_MAX_FILES);
|
|
13878
|
+
return Number.isFinite(override) && override > 0 ? override : ZIP_MAX_FILES;
|
|
13879
|
+
}
|
|
13880
|
+
function zipMaxTotalBytes() {
|
|
13881
|
+
const override = Number(process.env.MAXY_ZIP_MAX_TOTAL_BYTES);
|
|
13882
|
+
return Number.isFinite(override) && override > 0 ? override : ZIP_MAX_TOTAL_BYTES;
|
|
13883
|
+
}
|
|
13884
|
+
async function* walkRegularFiles(dirAbsolute) {
|
|
13885
|
+
const dirents = await readdir3(dirAbsolute, { withFileTypes: true });
|
|
13886
|
+
for (const d of dirents) {
|
|
13887
|
+
if (d.isSymbolicLink()) continue;
|
|
13888
|
+
const child = join25(dirAbsolute, d.name);
|
|
13889
|
+
if (d.isDirectory()) {
|
|
13890
|
+
yield* walkRegularFiles(child);
|
|
13891
|
+
continue;
|
|
13892
|
+
}
|
|
13893
|
+
if (d.isFile()) yield child;
|
|
13894
|
+
}
|
|
13895
|
+
}
|
|
13874
13896
|
app20.get("/download-zip", requireAdminSession, async (c) => {
|
|
13875
13897
|
const cacheKey = c.var.cacheKey;
|
|
13876
13898
|
const accountId = getAccountIdForSession(cacheKey);
|
|
@@ -13880,11 +13902,21 @@ app20.get("/download-zip", requireAdminSession, async (c) => {
|
|
|
13880
13902
|
}
|
|
13881
13903
|
const rawPaths = c.req.queries("path") ?? [];
|
|
13882
13904
|
if (rawPaths.length === 0) return c.json({ error: "path required" }, 400);
|
|
13883
|
-
|
|
13884
|
-
|
|
13905
|
+
const maxFiles = zipMaxFiles();
|
|
13906
|
+
const maxTotalBytes = zipMaxTotalBytes();
|
|
13907
|
+
if (rawPaths.length > maxFiles) {
|
|
13908
|
+
return c.json({ error: `Too many files (max ${maxFiles})` }, 413);
|
|
13885
13909
|
}
|
|
13886
13910
|
const entries = [];
|
|
13887
13911
|
let total = 0;
|
|
13912
|
+
let dirsWalked = 0;
|
|
13913
|
+
const addFile = async (absolute, size, member) => {
|
|
13914
|
+
if (entries.length >= maxFiles) return c.json({ error: `Too many files (max ${maxFiles})` }, 413);
|
|
13915
|
+
total += size;
|
|
13916
|
+
if (total > maxTotalBytes) return c.json({ error: "Selection too large to zip" }, 413);
|
|
13917
|
+
entries.push({ name: member, data: await readFile5(absolute) });
|
|
13918
|
+
return null;
|
|
13919
|
+
};
|
|
13888
13920
|
for (const rawPath of rawPaths) {
|
|
13889
13921
|
const resolution = resolveDataPath(rawPath);
|
|
13890
13922
|
if (!resolution.ok) {
|
|
@@ -13900,12 +13932,24 @@ app20.get("/download-zip", requireAdminSession, async (c) => {
|
|
|
13900
13932
|
}
|
|
13901
13933
|
try {
|
|
13902
13934
|
const info = await stat5(absolute);
|
|
13903
|
-
if (
|
|
13904
|
-
|
|
13905
|
-
|
|
13906
|
-
|
|
13935
|
+
if (info.isDirectory()) {
|
|
13936
|
+
dirsWalked++;
|
|
13937
|
+
const parentAbs = dirname6(absolute);
|
|
13938
|
+
for await (const fileAbs of walkRegularFiles(absolute)) {
|
|
13939
|
+
const within = relative4(absolute, fileAbs).split(sep6).join("/");
|
|
13940
|
+
const fileRel = relPath === "" || relPath === "." ? within : `${relPath}/${within}`;
|
|
13941
|
+
if (crossesForeignAccountPartition(fileRel, accountId)) continue;
|
|
13942
|
+
const fileInfo = await stat5(fileAbs);
|
|
13943
|
+
const member = relative4(parentAbs, fileAbs).split(sep6).join("/");
|
|
13944
|
+
const over = await addFile(fileAbs, fileInfo.size, member);
|
|
13945
|
+
if (over) return over;
|
|
13946
|
+
}
|
|
13947
|
+
} else if (info.isFile()) {
|
|
13948
|
+
const over = await addFile(absolute, info.size, basename8(absolute));
|
|
13949
|
+
if (over) return over;
|
|
13950
|
+
} else {
|
|
13951
|
+
return c.json({ error: "Path is not a file or directory" }, 400);
|
|
13907
13952
|
}
|
|
13908
|
-
entries.push({ name: basename8(absolute), data: await readFile5(absolute) });
|
|
13909
13953
|
} catch (err) {
|
|
13910
13954
|
const code = err.code;
|
|
13911
13955
|
if (code === "ENOENT") return c.json({ error: "Not found" }, 404);
|
|
@@ -13913,7 +13957,7 @@ app20.get("/download-zip", requireAdminSession, async (c) => {
|
|
|
13913
13957
|
}
|
|
13914
13958
|
}
|
|
13915
13959
|
const archive = buildZip(entries);
|
|
13916
|
-
console.error(`[data] file-download-zip files=${entries.length} bytes=${archive.length}`);
|
|
13960
|
+
console.error(`[data] file-download-zip dirs=${dirsWalked} files=${entries.length} bytes=${archive.length}`);
|
|
13917
13961
|
return new Response(new Uint8Array(archive), {
|
|
13918
13962
|
status: 200,
|
|
13919
13963
|
headers: {
|
|
@@ -16273,13 +16317,13 @@ var graph_default_view_default = app26;
|
|
|
16273
16317
|
|
|
16274
16318
|
// server/routes/admin/sidebar-artefacts.ts
|
|
16275
16319
|
import { readdir as readdir4, stat as stat6 } from "fs/promises";
|
|
16276
|
-
import { resolve as resolve25, relative as
|
|
16320
|
+
import { resolve as resolve25, relative as relative5, isAbsolute as isAbsolute2, sep as sep7, basename as basename9 } from "path";
|
|
16277
16321
|
import { existsSync as existsSync24 } from "fs";
|
|
16278
16322
|
var LIMIT = 50;
|
|
16279
16323
|
var ADMIN_AGENT_FILES = ["IDENTITY.md", "SOUL.md", "KNOWLEDGE.md"];
|
|
16280
16324
|
function toDataRootRelPath(absPath) {
|
|
16281
16325
|
if (absPath !== DATA_ROOT && !absPath.startsWith(DATA_ROOT + sep7)) return null;
|
|
16282
|
-
return
|
|
16326
|
+
return relative5(DATA_ROOT, absPath);
|
|
16283
16327
|
}
|
|
16284
16328
|
var app27 = new Hono();
|
|
16285
16329
|
app27.get("/", requireAdminSession, async (c) => {
|
|
@@ -16443,7 +16487,7 @@ async function readAgentTemplateRow(inp) {
|
|
|
16443
16487
|
}
|
|
16444
16488
|
}
|
|
16445
16489
|
function isWithin(target, root) {
|
|
16446
|
-
const rel =
|
|
16490
|
+
const rel = relative5(root, target);
|
|
16447
16491
|
return !rel.startsWith("..") && !isAbsolute2(rel);
|
|
16448
16492
|
}
|
|
16449
16493
|
var sidebar_artefacts_default = app27;
|
|
@@ -19590,7 +19634,7 @@ async function startFileWatcher(opts = {}) {
|
|
|
19590
19634
|
|
|
19591
19635
|
// app/lib/migrate-uploads.ts
|
|
19592
19636
|
import { mkdir as mkdir5, readdir as readdir5, rename as rename2, rm as rm3 } from "fs/promises";
|
|
19593
|
-
import { dirname as dirname8, relative as
|
|
19637
|
+
import { dirname as dirname8, relative as relative6, resolve as resolve31 } from "path";
|
|
19594
19638
|
var ACCOUNT_UUID_RE4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
19595
19639
|
async function walkFiles(dir) {
|
|
19596
19640
|
const out = [];
|
|
@@ -19620,13 +19664,13 @@ async function relocateTree(srcDir, destDir, dataRoot, accountId, session) {
|
|
|
19620
19664
|
const files = await walkFiles(srcDir);
|
|
19621
19665
|
let moved = 0;
|
|
19622
19666
|
for (const oldAbs of files) {
|
|
19623
|
-
const suffix =
|
|
19667
|
+
const suffix = relative6(srcDir, oldAbs);
|
|
19624
19668
|
const newAbs = resolve31(destDir, suffix);
|
|
19625
19669
|
await mkdir5(dirname8(newAbs), { recursive: true });
|
|
19626
19670
|
await rename2(oldAbs, newAbs);
|
|
19627
19671
|
moved++;
|
|
19628
|
-
const oldRel =
|
|
19629
|
-
const newRel =
|
|
19672
|
+
const oldRel = relative6(dataRoot, oldAbs);
|
|
19673
|
+
const newRel = relative6(dataRoot, newAbs);
|
|
19630
19674
|
let linked = false;
|
|
19631
19675
|
if (accountId && session) {
|
|
19632
19676
|
const fa = await session.run(
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CAM3fms7.js";import{A as t,B as n,C as r,D as i,E as a,F as o,M as s,O as c,P as ee,R as l,T as te,U as u,V as d,_ as ne,d as f,f as p,p as re,t as ie,v as m,w as ae}from"./OperatorConversations-DU8CqO-z.js";import{i as oe,t as se}from"./graph-labels-IGIEr-uc.js";var ce=l(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),le=l(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ue=l(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),de=l(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),fe=l(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),pe=l(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),me=l(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),h=d(),g=e(u(),1);function he(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||se.has(e)&&(t.add(e),n.push(e)));return n}var _=r(),ge=/\.(png|jpe?g|gif|webp|svg)$/i;function _e(e){return ge.test(e)}var ve=`maxy-data-view`;function ye(){return typeof window>`u`?`list`:window.localStorage.getItem(ve)===`grid`?`grid`:`list`}function be(){let[e,n]=(0,g.useState)(null),[r,i]=(0,g.useState)(!1);return(0,g.useEffect)(()=>{let e=!1,t=null;try{t=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!t){n(null),i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(t)}`).then(r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}n(t),i(!0)}}).catch(()=>{e||(n(t),i(!0))}),()=>{e=!0}},[]),r?e?(0,_.jsx)(m,{cacheKey:e,surface:`data`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=data`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,_.jsx)(`div`,{className:`data-page data-page-full`,children:(0,_.jsx)(xe,{cacheKey:e})})}):(0,_.jsx)(`div`,{className:`data-page`,children:(0,_.jsxs)(`div`,{className:`data-empty`,children:[(0,_.jsx)(`p`,{children:`You are not signed in.`}),(0,_.jsxs)(`p`,{children:[`Open the `,(0,_.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,_.jsx)(`div`,{className:`data-page`,children:(0,_.jsxs)(`div`,{className:`data-loading`,children:[(0,_.jsx)(t,{size:18,className:`spin`}),` Loading…`]})})}function xe({cacheKey:e}){let{adminFetch:t,cacheKey:r,sessionRefetchNonce:i}=n({initialCacheKey:e,surface:`data`});return(0,_.jsx)(y,{adminFetch:t,cacheKey:r,sessionRefetchNonce:i})}function Se(){if(typeof window>`u`)return`.`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`.`}function Ce(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function v(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function we(e){return new Promise((t,n)=>e.file(t,n))}async function Te(e,t=``){let n=[];for(let r of e){if(!r)continue;let e=t?`${t}/${r.name}`:r.name;if(r.isFile)n.push({file:await we(r),relpath:e});else if(r.isDirectory){let t=await v(r.createReader());n.push(...await Te(t,e))}}return n}function Ee(e,t){if(e===422&&typeof t==`string`){if(/exceeds the .* limit/i.test(t))return`size`;if(/unsupported file type/i.test(t))return`mime`}return`http=${e}`}function y({adminFetch:e,cacheKey:n,sessionRefetchNonce:r}){let[l,u]=(0,g.useState)(``),d=(0,g.useRef)(null),[m,se]=(0,g.useState)(``),[h,ge]=(0,g.useState)(null),[be,xe]=(0,g.useState)(`hybrid`),[v,we]=(0,g.useState)(!1),[y,b]=(0,g.useState)(null),[x,ke]=(0,g.useState)(null),[Me,Ne]=(0,g.useState)(0),[S,Pe]=(0,g.useState)(!1),[C,Fe]=(0,g.useState)(()=>Se()),[w,Ie]=(0,g.useState)(null),[T,Le]=(0,g.useState)(()=>ye()),[E,Re]=(0,g.useState)(null),[D,ze]=(0,g.useState)([]),[O,Be]=(0,g.useState)(!1),[Ve,He]=(0,g.useState)(null),[Ue,k]=(0,g.useState)(!1),[A,j]=(0,g.useState)(null),[We,M]=(0,g.useState)(null),[Ge,Ke]=(0,g.useState)(null),[qe,Je]=(0,g.useState)(!1),[Ye,Xe]=(0,g.useState)(null),N=(0,g.useRef)(null),[Ze,P]=(0,g.useState)(0),[Qe,F]=(0,g.useState)(!1),[$e,et]=(0,g.useState)(``),[I,L]=(0,g.useState)(null),[tt,nt]=(0,g.useState)(``),[rt,R]=(0,g.useState)(null),z=(()=>{let e=C===`.`?[]:C.split(`/`).filter(Boolean);return e.length>=2&&e[0]===`accounts`})();(0,g.useEffect)(()=>{console.info(`[data-ui] op=mount header=operator home=absent`)},[]);let it=(0,g.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),at=(0,g.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[B,ot]=(0,g.useState)([]),[st,ct]=(0,g.useState)(`files`);(0,g.useEffect)(()=>{if(!n)return;let e=!1;return fetch(`/api/whatsapp-reader/conversations?session_key=${encodeURIComponent(n)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||ot(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[n]);let lt=(0,g.useMemo)(()=>[...new Set(B.map(e=>e.channel))],[B]),[ut,dt]=(0,g.useState)(!1),ft=(0,g.useRef)(null),[pt,V]=(0,g.useState)(!1),mt=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=l.trim();if(!e){se(``),ge(null),b(null);return}Pe(!1);let t=setTimeout(()=>se(e),300);return()=>clearTimeout(t)},[l]),(0,g.useEffect)(()=>{if(!m){we(!1);return}let t=!1;return we(!0),b(null),e(`/api/admin/graph-search?q=${encodeURIComponent(m)}&labels=FileArtifact&limit=20${S?`&threshold=0`:``}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(ge(e.results),xe(e.mode??`hybrid`),Ne(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||b(e instanceof Error?e.message:String(e))}).finally(()=>{t||we(!1)}),()=>{t=!0}},[m,e,r,S]);let ht=(0,g.useMemo)(()=>h?he(h):[],[h]),H=x&&ht.includes(x)?x:null,gt=(0,g.useMemo)(()=>h?H?h.filter(e=>e.labels.includes(H)):h:null,[h,H]),_t=(0,g.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let r=`/api/admin/files/download?session_key=${encodeURIComponent(n)}&path=${encodeURIComponent(t)}`,i=document.createElement(`a`);i.href=r,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()},[n]);(0,g.useEffect)(()=>{if(!h)return;let e=h.filter(e=>{let t=e.properties.relativePath;return typeof t!=`string`||t.length===0});e.length>0&&console.warn(`[data-search] op=locate-link-missing nodeId=${e.map(e=>e.nodeId).join(`,`)}`)},[h]),(0,g.useEffect)(()=>{let t=!1;return Be(!0),He(null),e(`/api/admin/files?path=${encodeURIComponent(C===`.`?``:C)}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(Ie(e.entries),ze(e.displayPath??[]))}).catch(e=>{t||(Ie([]),ze([]),He(e instanceof Error?e.message:String(e)))}).finally(()=>{t||Be(!1)}),()=>{t=!0}},[e,C,Ze,r]),(0,g.useEffect)(()=>{Ce(C)},[C]);let vt=(0,g.useCallback)(()=>{P(e=>e+1)},[]),U=(0,g.useCallback)(e=>{dt(!1),Fe(e)},[]),yt=(0,g.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=t.lastIndexOf(`/`),r=n===-1?`.`:t.slice(0,n);console.log(`[data-search] op=locate nodeId=${e.nodeId} folder=${r}`),u(``),b(null),ke(null),U(r)},[U]),bt=(0,g.useCallback)(()=>{if(C===`.`||C===``)return;let e=C.split(`/`).filter(Boolean);e.pop(),Fe(e.length===0?`.`:e.join(`/`))},[C]),xt=(0,g.useCallback)(e=>{p(n,C===`.`?e.name:`${C}/${e.name}`)},[C,n]),[W,St]=(0,g.useState)(!1),[G,Ct]=(0,g.useState)(new Set),wt=(0,g.useRef)(null),K=(0,g.useRef)(!1),q=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,Tt=(0,g.useCallback)(e=>{St(!0),Ct(new Set([e])),console.info(`[data-ui] op=select-enter count=1`)},[]),J=(0,g.useCallback)(e=>{St(!1),Ct(new Set),console.info(`[data-ui] op=select-exit reason=${e}`)},[]),Y=(0,g.useCallback)(e=>{Ct(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Et=(0,g.useCallback)(e=>{K.current=!1,wt.current=setTimeout(()=>{K.current=!0,Tt(e)},500)},[Tt]),X=(0,g.useCallback)(()=>{wt.current&&=(clearTimeout(wt.current),null)},[]),Dt=(0,g.useCallback)(e=>{if(K.current){K.current=!1;return}if(W){Y(e.name);return}xt(e)},[W,Y,xt]),Ot=(0,g.useCallback)(e=>{Le(e),typeof window<`u`&&window.localStorage.setItem(ve,e),console.info(`[data] op=view-mode mode=${e}`)},[]),kt=(0,g.useCallback)(e=>{if(K.current){K.current=!1;return}if(W){Y(e.name);return}Re({src:f(n,C===`.`?e.name:`${C}/${e.name}`),alt:e.displayName??e.name})},[W,Y,C,n]),Z=(0,g.useCallback)(()=>(w??[]).filter(e=>e.kind===`file`&&G.has(e.name)),[w,G]),At=(0,g.useCallback)(()=>{let e=Z();e.length===1?xt(e[0]):e.length>1&&re(n,e.map(e=>C===`.`?e.name:`${C}/${e.name}`)),J(`action`)},[Z,xt,C,n,J]),jt=(0,g.useCallback)(async()=>{let t=Z(),n=t.filter(e=>!e.protected),r=t.length-n.length;Xe(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=C===`.`?t.name:`${C}/${t.name}`;try{let t=await e(`/api/admin/files?path=${encodeURIComponent(n)}`,{method:`DELETE`}),r=await t.json().catch(()=>({error:`HTTP ${t.status}`}));if(!t.ok)throw Error(r.error??`HTTP ${t.status}`)}catch(e){Xe(e instanceof Error?e.message:String(e))}}P(e=>e+1),J(`action`)},[Z,C,e,J]),Mt=(0,g.useCallback)(async()=>{let e=Z();if(console.info(`[data-ui] op=share supported=${q} count=${e.length}`),q)try{let t=await Promise.all(e.map(async e=>{let t=C===`.`?e.name:`${C}/${e.name}`,r=`/api/admin/files/download?session_key=${encodeURIComponent(n)}&path=${encodeURIComponent(t)}`,i=await(await fetch(r)).blob();return new File([i],e.name,{type:i.type||`application/octet-stream`})}));navigator.canShare({files:t})&&await navigator.share({files:t})}catch(e){console.warn(`[data-ui] op=share-failed err=${e instanceof Error?e.message:String(e)}`)}},[Z,q,C,n]),Nt=(0,g.useCallback)(()=>{N.current?.click()},[]),Q=(0,g.useCallback)((e,t={})=>{let r=new URLSearchParams({session_key:n,path:C===`.`?``:C,filename:e.name});return t.relpath&&r.set(`relpath`,t.relpath),t.token&&r.set(`token`,t.token),new Promise(n=>{let i=new XMLHttpRequest;i.open(`POST`,`/api/admin/files/upload?${r.toString()}`),i.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),t.onProgress&&(i.upload.onprogress=e=>{e.lengthComputable&&t.onProgress(e.loaded,e.total)}),i.onload=()=>{let e={};try{e=JSON.parse(i.responseText)}catch{}n({status:i.status,data:e})},i.onerror=()=>n({status:0,data:{}}),i.onabort=()=>n({status:0,data:{error:`aborted`}}),i.send(e)})},[n,C]),Pt=(0,g.useCallback)(async e=>{M(null),k(!0),j({loaded:0,total:e.size});try{let{status:t,data:n}=await Q(e,{onProgress:(e,t)=>j({loaded:e,total:t})});t>=200&&t<300&&n.path?(Fe(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),P(e=>e+1)):M(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{k(!1),j(null),N.current&&(N.current.value=``)}},[Q]),Ft=(0,g.useCallback)(e=>{z&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Je(!0))},[z]),It=(0,g.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Je(!1)},[]),Lt=(0,g.useCallback)(async e=>{e.preventDefault(),Je(!1);let t=Math.random().toString(16).slice(2,10),n=Array.from(e.dataTransfer.items);if(console.info(`[data-ui] op=drop-received token=${t} items=${n.length}`),n.length===0)return;if(!z){console.info(`[data-ui] op=drop-rejected token=${t} reason=no-write`),M(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);k(!0),M(null),Ke(null);let i=performance.now();try{let e=await Te(r),n=e.reduce((e,t)=>e+t.file.size,0),a=new Set(e.map(e=>e.relpath.split(`/`).slice(0,-1).join(`/`)).filter(Boolean)).size;console.info(`[data-ui] op=drop-walk token=${t} files=${e.length} dirs=${a} bytes=${n}`);let o=0,s=[];for(let n=0;n<e.length;n++){let{file:r,relpath:i}=e[n];console.info(`[data-ui] op=drop-file token=${t} rel="${i}" i=${n+1}/${e.length}`),j({loaded:0,total:r.size});let{status:a,data:c}=await Q(r,{relpath:i,token:t,onProgress:(e,t)=>j({loaded:e,total:t})});if(a>=200&&a<300)o++,console.info(`[data-ui] op=drop-file-ok token=${t} rel="${i}"`);else{let e=a===0?`http=0`:Ee(a,c.error);s.push(`${i} (${e})`),console.info(`[data-ui] op=drop-file-skip token=${t} rel="${i}" reason=${e}`)}}let c=Math.round(performance.now()-i);console.info(`[data-ui] op=drop-done token=${t} uploaded=${o} skipped=${s.length} ms=${c}`),Ke(`Uploaded ${o}, skipped ${s.length}${s.length?`: ${s.join(`, `)}`:``}`),P(e=>e+1)}catch(e){M(e instanceof Error?e.message:String(e))}finally{k(!1),j(null)}},[z,Q]),Rt=(0,g.useCallback)(async()=>{let t=$e.trim();if(t){R(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:C===`.`?``:C,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);F(!1),et(``),P(e=>e+1)}catch(e){R(e instanceof Error?e.message:String(e))}}},[e,$e,C]),zt=(0,g.useCallback)(async()=>{if(!I)return;let t=tt.trim();if(!t)return;R(null);let n=C===`.`?I:`${C}/${I}`;try{let r=await e(`/api/admin/files/rename`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n,newName:t})}),i=await r.json().catch(()=>({error:`HTTP ${r.status}`}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);L(null),nt(``),J(`action`),P(e=>e+1)}catch(e){R(e instanceof Error?e.message:String(e))}},[e,tt,I,C,J]);(0,g.useEffect)(()=>{if(!ut)return;let e=e=>{ft.current&&!ft.current.contains(e.target)&&dt(!1)},t=e=>{e.key===`Escape`&&dt(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[ut]),(0,g.useEffect)(()=>{if(!pt)return;let e=e=>{mt.current&&!mt.current.contains(e.target)&&V(!1)},t=e=>{e.key===`Escape`&&V(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[pt]);let $=(0,g.useCallback)(e=>D.slice(0,e+1).map(e=>e.name).join(`/`),[D]),Bt=D.length>=2,Vt=Bt?[{name:`.`,label:`data`},...D.slice(0,D.length-2).map((e,t)=>({name:$(t),label:e.displayName??e.name}))]:[];return(0,_.jsxs)(`main`,{className:`data-main`,children:[(0,_.jsx)(ne,{variant:`operator`,onNavigate:at,conversationsCount:B.length,conversationsChannels:lt,onOpenConversations:()=>ct(`conversations`),onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:it,onDisconnect:async()=>!0,disconnecting:!1}),st===`conversations`?(0,_.jsx)(ie,{conversations:B,sessionKey:n,onBack:()=>ct(`files`)}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`data-toolbar`,children:[W?(0,_.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>J(`cancel`),"aria-label":`Cancel selection`,children:[(0,_.jsx)(ae,{size:14}),` Cancel`]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`data-search-input`,children:[l===``&&(0,_.jsx)(oe,{size:14}),(0,_.jsx)(`input`,{ref:d,type:`text`,value:l,onChange:e=>u(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),v&&(0,_.jsx)(t,{size:14,className:`spin`}),l!==``&&(0,_.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{u(``),d.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,_.jsx)(ae,{size:14})})]}),(0,_.jsxs)(`div`,{className:`data-toolbar-actions`,ref:mt,children:[(0,_.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>V(e=>!e),"aria-haspopup":`menu`,"aria-expanded":pt,"aria-label":`File actions`,title:`File actions`,children:(0,_.jsx)(ee,{size:16})}),(0,_.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":pt?`true`:void 0,children:[(0,_.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{vt(),V(!1)},disabled:O,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[O?(0,_.jsx)(t,{size:16,className:`spin`}):(0,_.jsx)(i,{size:16}),(0,_.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,_.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Nt(),V(!1)},disabled:Ue||!z,title:z?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[Ue?A&&A.total>0?(0,_.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(A.loaded/A.total*100),`%`]}):(0,_.jsx)(t,{size:16,className:`spin`}):(0,_.jsx)(me,{size:16}),(0,_.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,_.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{F(e=>!e),et(``),R(null),V(!1)},disabled:Ue||!z,title:z?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,_.jsx)(le,{size:16}),(0,_.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,_.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Ot(T===`grid`?`list`:`grid`),V(!1)},title:T===`grid`?`List view`:`Grid view`,"aria-label":T===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":T===`grid`,children:[T===`grid`?(0,_.jsx)(fe,{size:16}):(0,_.jsx)(de,{size:16}),(0,_.jsx)(`span`,{className:`data-action-label`,children:T===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,_.jsxs)(`div`,{className:`data-breadcrumbs`,children:[C!==`.`&&(0,_.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:bt,title:`Up one level`,"aria-label":`Up one level`,children:(0,_.jsx)(ce,{size:14})}),Bt?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`span`,{className:`data-crumb-wrap`,ref:ft,children:[(0,_.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>dt(e=>!e),"aria-haspopup":`menu`,"aria-expanded":ut,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),ut&&(0,_.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Vt.map(e=>(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>U(e.name),title:e.label,children:e.label},e.name))})]}),[D.length-2,D.length-1].map(e=>{let t=D[e];return(0,_.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,_.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,_.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>U($(e)),title:t.name,children:t.displayName??t.name})]},$(e))})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>U(`.`),children:`data`}),D.map((e,t)=>(0,_.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,_.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,_.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>U($(t)),title:e.name,children:e.displayName??e.name})]},$(t)))]})]}),Qe&&(0,_.jsxs)(`div`,{className:`data-inline-form`,children:[(0,_.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:$e,autoFocus:!0,onChange:e=>et(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Rt(),e.key===`Escape`&&F(!1)}}),(0,_.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Rt,children:`Create`}),(0,_.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>F(!1),children:`Cancel`})]}),I&&(0,_.jsxs)(`div`,{className:`data-inline-form`,children:[(0,_.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:tt,autoFocus:!0,onChange:e=>nt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&zt(),e.key===`Escape`&&L(null)}}),(0,_.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:zt,children:`Rename`}),(0,_.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>L(null),children:`Cancel`})]}),rt&&(0,_.jsx)(`div`,{className:`data-error`,children:rt}),(0,_.jsx)(`input`,{type:`file`,ref:N,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Pt(t)}})]}),(0,_.jsxs)(`div`,{className:`data-body`,"data-drag-active":qe?`true`:void 0,onDragEnter:Ft,onDragOver:Ft,onDragLeave:It,onDrop:Lt,children:[(y!==null||h!==null)&&(0,_.jsxs)(`section`,{className:`data-panel`,children:[y&&(0,_.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,y]}),ht.length>0&&(0,_.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:ht.map(e=>{let t=e===H;return(0,_.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>ke(t?null:e),children:Oe([e])??e},e)})}),h&&!v&&(0,_.jsxs)(`div`,{className:`data-results-meta`,children:[gt.length,` of `,h.length,` result`,h.length===1?``:`s`]}),h&&!v&&!H&&Me>0&&!S&&(0,_.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>Pe(!0),children:[Me,` low-confidence result`,Me===1?``:`s`,` hidden — show all`]}),h&&!v&&!H&&S&&(0,_.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>Pe(!1),children:`Showing all results — hide low-confidence`}),h&&h.length===0&&!v&&(0,_.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),gt&>.length>0&&(0,_.jsx)(`ul`,{className:`data-results`,children:gt.map(e=>(0,_.jsx)(De,{hit:e,mode:be,onDownload:_t,onLocate:yt},e.nodeId))})]}),(0,_.jsxs)(`section`,{className:`data-panel`,children:[A&&(0,_.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":A.total>0?Math.round(A.loaded/A.total*100):void 0,children:[(0,_.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,_.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${A.total>0?Math.round(A.loaded/A.total*100):0}%`}})}),(0,_.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,A.total>0?`${Math.round(A.loaded/A.total*100)}%`:``]})]}),We&&(0,_.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,We]}),Ge&&(0,_.jsx)(`div`,{className:`data-status`,children:Ge}),Ye&&(0,_.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,Ye]}),Ve&&(0,_.jsx)(`div`,{className:`data-error`,children:Ve}),O&&(0,_.jsxs)(`div`,{className:`data-loading`,children:[(0,_.jsx)(t,{size:14,className:`spin`}),` Loading…`]}),!W&&!O&&w&&w.length>0&&(0,_.jsxs)(`div`,{className:`data-select-hint`,children:[(0,_.jsx)(pe,{size:13}),(0,_.jsx)(`span`,{children:`Press and hold a file to select, rename, or delete it.`})]}),!O&&w&&w.length===0&&!Ve&&(0,_.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!O&&w&&w.length>0&&T===`grid`&&(0,_.jsx)(`ul`,{className:`data-grid`,children:w.map(e=>{let t=e.displayName??e.name,r=W&&G.has(e.name);if(e.kind===`directory`)return(0,_.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,_.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>Et(e.name),onPointerUp:X,onPointerMove:X,onPointerLeave:X,onPointerCancel:X,onClick:()=>{if(K.current){K.current=!1;return}if(W){Y(e.name);return}U(C===`.`?e.name:`${C}/${e.name}`)},children:[W&&(0,_.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,_.jsx)(ue,{size:28,className:`data-grid-glyph`}),(0,_.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t})]})},e.name);if(e.kind===`file`){let i=_e(e.name),a=C===`.`?e.name:`${C}/${e.name}`;return(0,_.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,_.jsxs)(`button`,{type:`button`,className:`data-grid-tile${i?` data-grid-tile-image`:``}`,onPointerDown:()=>Et(e.name),onPointerUp:X,onPointerMove:X,onPointerLeave:X,onPointerCancel:X,onClick:()=>i?kt(e):Dt(e),title:W?void 0:i?`Preview ${t}`:`Download ${t}`,children:[W&&(0,_.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),i?(0,_.jsx)(`img`,{className:`data-grid-thumb`,src:f(n,a),alt:t,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${a}`)}):(0,_.jsx)(s,{size:28,className:`data-grid-glyph`}),(0,_.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t}),!i&&(0,_.jsx)(`span`,{className:`data-grid-sub`,children:Ae(e.sizeBytes)})]})},e.name)}return(0,_.jsx)(`li`,{className:`data-grid-cell`,children:(0,_.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,_.jsx)(s,{size:28,className:`data-grid-glyph`}),(0,_.jsx)(`span`,{className:`data-grid-label`,children:t}),(0,_.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!O&&w&&w.length>0&&T===`list`&&(0,_.jsx)(`ul`,{className:`data-entries`,children:w.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=W&&G.has(e.name);return(0,_.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,_.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>Et(e.name),onPointerUp:X,onPointerMove:X,onPointerLeave:X,onPointerCancel:X,onClick:()=>{if(K.current){K.current=!1;return}if(W){Y(e.name);return}U(C===`.`?e.name:`${C}/${e.name}`)},children:[W&&(0,_.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,_.jsx)(ue,{size:14}),(0,_.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=W&&G.has(e.name);return(0,_.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,_.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>Et(e.name),onPointerUp:X,onPointerMove:X,onPointerLeave:X,onPointerCancel:X,onClick:()=>Dt(e),title:W?void 0:`Download ${t}`,children:[W&&(0,_.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,_.jsxs)(`span`,{className:`data-entry-text`,children:[(0,_.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,_.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${je(e.modifiedAt)}`,children:[Ae(e.sizeBytes),` · `,je(e.modifiedAt)]})]})]})},e.name)}return(0,_.jsx)(`li`,{className:`data-entry`,children:(0,_.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,_.jsxs)(`span`,{className:`data-entry-text`,children:[(0,_.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,_.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]}),W&&(0,_.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,_.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Mt,disabled:!q||G.size===0,title:q?`Share selected files`:`Sharing is not supported on this device`,children:[(0,_.jsx)(a,{size:16}),` Share`]}),(0,_.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:At,disabled:G.size===0,children:[(0,_.jsx)(o,{size:16}),` Download`]}),(0,_.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=[...G][0];e&&(L(e),nt(e))},disabled:G.size!==1,children:[(0,_.jsx)(c,{size:16}),` Rename`]}),(0,_.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:jt,disabled:G.size===0,children:[(0,_.jsx)(te,{size:16}),` Delete`]})]})})]}),E&&(0,_.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":E.alt,onClick:()=>Re(null),children:(0,_.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:E.src,alt:E.alt})})]})}function De({hit:e,mode:t,onDownload:n,onLocate:r}){let i=b(e.properties),a=x(e.properties),o=Oe(e.labels),s=ke(e.properties),[c,ee]=(0,g.useState)(!1),l=a&&a.length>280,te=c||!l?a:a?.slice(0,280)+`…`,u=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`,d=e.properties.relativePath,ne=typeof d==`string`&&d.length>0,f=ne?d.lastIndexOf(`/`):-1,p=ne?f===-1?`data`:d.slice(0,f):null;return(0,_.jsxs)(`li`,{className:`data-result`,children:[(0,_.jsxs)(`div`,{role:`button`,tabIndex:0,className:`data-result-open`,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e))},"aria-label":`Download ${i??o??`file`}`,children:[o&&(0,_.jsx)(`div`,{className:`data-result-header`,children:(0,_.jsx)(`span`,{className:`data-result-labels`,children:o})}),i&&(0,_.jsx)(`div`,{className:`data-result-title`,children:i}),a&&(0,_.jsx)(`pre`,{className:`data-result-body`,children:te}),(0,_.jsxs)(`div`,{className:`data-result-scores`,children:[s&&(0,_.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,je(s),` · `]}),u]})]}),ne&&(0,_.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${p}`,"aria-label":`Locate in ${p}`,children:[(0,_.jsx)(ue,{size:12}),p]}),l&&(0,_.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>ee(e=>!e),children:c?`Show less`:`Show more`})]})}function Oe(e){if(e.length===0)return null;let t=e[0].replace(/([a-z])([A-Z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function b(e){for(let t of[`title`,`name`,`summary`,`headline`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n.length>140?n.slice(0,140)+`…`:n}return null}function x(e){for(let t of[`content`,`summary`,`body`,`description`,`text`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function ke(e){for(let t of[`updatedAt`,`modifiedAt`,`fetchedAt`,`createdAt`,`lastModified`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function Ae(e){return e==null?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function je(e){try{let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n=typeof navigator<`u`?navigator.languages&&navigator.languages.length>0?[...navigator.languages]:[navigator.language]:void 0;return t.toLocaleString(n,{dateStyle:`medium`,timeStyle:`short`})}catch{return`—`}}(0,h.createRoot)(document.getElementById(`root`)).render((0,_.jsx)(be,{}));
|