PageSourceSearch

https://vcad.io/assets/DocumentPicker-0pN9XRdL.js

js vcad.io collected 2026-09-25 21:45:05 UTC 21,994 bytes, 157 lines download raw bytes

1import { b as e, k as t } from "./three-fiber-GW7QWJN8.js";
2import { cm as S, bj as L, b4 as b, ec as te, ed as ae, ee as z, ef as ne, d6 as se, eg as T, eh as le, ei as oe, bm as h, cY as re, bB as $, ej as ce, ek as de, bp as ie, bq as me, br as ue, bs as xe, bu as he, dL as P, bt as fe, bg as pe, bZ as ge, bh as D, dq as O, el as Ae, bA as be, em as Ze } from "./index-CO3RsAq4.js";
3import { m as we } from "./WifiSlash.es-D5CxRiuO.js";
4import "./three-tnxpQXqG.js";
5import "./three-drei-CobgFk8Q.js";
6const ye = /* @__PURE__ */ new Map([["bold", e.createElement(e.Fragment, null, e.createElement("path", { d: "M160,36A92.09,92.09,0,0,0,79,84.36,68,68,0,1,0,72,220h88a92,92,0,0,0,0-184Zm0,160H72a44,44,0,0,1-1.82-88A91.86,91.86,0,0,0,68,128a12,12,0,0,0,24,0,68,68,0,1,1,68,68Z" }))], ["duotone", e.createElement(e.Fragment, null, e.createElement("path", { d: "M240,128a80,80,0,0,1-80,80H72A56,56,0,1,1,85.92,97.74l0,.1A80,80,0,0,1,240,128Z", opacity: "0.2" }), e.createElement("path", { d: "M160,40A88.09,88.09,0,0,0,81.29,88.67,64,64,0,1,0,72,216h88a88,88,0,0,0,0-176Zm0,160H72a48,48,0,0,1,0-96c1.1,0,2.2,0,3.29.11A88,88,0,0,0,72,128a8,8,0,0,0,16,0,72,72,0,1,1,72,72Z" }))], ["fill", e.createElement(e.Fragment, null, e.createElement("path", { d: "M160.06,40A88.1,88.1,0,0,0,81.29,88.67h0A87.48,87.48,0,0,0,72,127.73,8.18,8.18,0,0,1,64.57,136,8,8,0,0,1,56,128a103.66,103.66,0,0,1,5.34-32.92,4,4,0,0,0-4.75-5.18A64.09,64.09,0,0,0,8,152c0,35.19,29.75,64,65,64H160a88.09,88.09,0,0,0,87.93-91.48C246.11,77.54,207.07,40,160.06,40Z" }))], ["light", e.createElement(e.Fragment, null, e.createElement("path", { d: "M160,42A86.11,86.11,0,0,0,82.43,90.88,62,62,0,1,0,72,214h88a86,86,0,0,0,0-172Zm0,160H72a50,50,0,0,1,0-100,50.67,50.67,0,0,1,5.91.35A85.61,85.61,0,0,0,74,128a6,6,0,0,0,12,0,74,74,0,1,1,74,74Z" }))], ["regular", e.createElement(e.Fragment, null, e.createElement("path", { d: "M160,40A88.09,88.09,0,0,0,81.29,88.67,64,64,0,1,0,72,216h88a88,88,0,0,0,0-176Zm0,160H72a48,48,0,0,1,0-96c1.1,0,2.2,0,3.29.11A88,88,0,0,0,72,128a8,8,0,0,0,16,0,72,72,0,1,1,72,72Z" }))], ["thin", e.createElement(e.Fragment, null, e.createElement("path", { d: "M160,44A84.11,84.11,0,0,0,83.59,93.12,60.71,60.71,0,0,0,72,92a60,60,0,0,0,0,120h88a84,84,0,0,0,0-168Zm0,160H72a52,52,0,1,1,8.55-103.3A83.66,83.66,0,0,0,76,128a4,4,0,0,0,8,0,76,76,0,1,1,76,76Z" }))]]), q = e.forwardRef((n, o) => e.createElement(S, { ref: o, ...n, weights: ye }));
7q.displayName = "CloudIcon";
8const R = q, He = /* @__PURE__ */ new Map([["bold", e.createElement(e.Fragment, null, e.createElement("path", { d: "M56.88,31.93A12,12,0,1,0,39.12,48.07L71.79,84A68,68,0,0,0,72,220h88a91.26,91.26,0,0,0,30.66-5.24l8.46,9.31a12,12,0,0,0,17.76-16.14ZM160,196H72a44,44,0,0,1-1.8-87.95A91.91,91.91,0,0,0,68,128a12,12,0,0,0,24,0,68.22,68.22,0,0,1,2.66-18.84l77.88,85.67A68.67,68.67,0,0,1,160,196Zm92-68a91.32,91.32,0,0,1-17.53,54,12,12,0,1,1-19.41-14.11,68,68,0,0,0-89.57-98.53,12,12,0,0,1-12.2-20.66A92,92,0,0,1,252,128Z" }))], ["duotone", e.createElement(e.Fragment, null, e.createElement("path", { d: "M240,128a80,80,0,0,1-80,80H72A56,56,0,1,1,85.92,97.74l0,.1A80,80,0,0,1,240,128Z", opacity: "0.2" }), e.createElement("path", { d: "M53.92,34.62A8,8,0,1,0,42.08,45.38L81.32,88.55l-.06.12A65,65,0,0,0,72,88a64,64,0,0,0,0,128h88a87.34,87.34,0,0,0,31.8-5.93l10.28,11.31a8,8,0,1,0,11.84-10.76ZM160,200H72a48,48,0,0,1,0-96c1.1,0,2.2,0,3.3.12A88.4,88.4,0,0,0,72,128a8,8,0,0,0,16,0,72.25,72.25,0,0,1,5.06-26.54l87,95.7A71.66,71.66,0,0,1,160,200Zm88-72a87.89,87.89,0,0,1-22.35,58.61A8,8,0,0,1,213.71,176,72,72,0,0,0,117.37,70a8,8,0,0,1-9.48-12.89A88,88,0,0,1,248,128Z" }))], ["fill", e.createElement(e.Fragment, null, e.createElement("path", { d: "M248,128.72A87.74,87.74,0,0,1,222.41,190a4,4,0,0,1-5.77-.16L103.78,65.67a4,4,0,0,1,.39-5.76A87.82,87.82,0,0,1,160.87,40C209.15,40.47,248.38,80.43,248,128.72ZM53.92,34.62A8,8,0,1,0,42.08,45.38L81.33,88.56l-.06.11A64,64,0,0,0,8,153c.53,35.12,29.84,63,65,63h87a87.65,87.65,0,0,0,31.78-5.95l10.3,11.33a8,8,0,0,0,11.33.52,8.32,8.32,0,0,0,.29-11.52Z" }))], ["light", e.createElement(e.Fragment, null, e.createElement("path", { d: "M52.44,36A6,6,0,0,0,43.56,44l40.18,44.2c-.45.87-.9,1.75-1.32,2.64A62,62,0,1,0,72,214h88a85.23,85.23,0,0,0,32.35-6.3L203.56,220a6,6,0,0,0,8.88-8.08ZM160,202H72a50,50,0,1,1,5.9-99.64A86.25,86.25,0,0,0,74,128a6,6,0,0,0,12,0,73.92,73.92,0,0,1,6.44-30.2l91.22,100.34A73.65,73.65,0,0,1,160,202Zm86-74a85.85,85.85,0,0,1-21.85,57.27,6,6,0,0,1-4.47,2,6,6,0,0,1-4.47-10,74,74,0,0,0-99-108.92,6,6,0,1,1-7.11-9.67A86,86,0,0,1,246,128Z" }))], ["regular", e.createElement(e.Fragment, null, e.createElement("path", { d: "M53.92,34.62A8,8,0,1,0,42.08,45.38L81.32,88.55l-.06.12A65,65,0,0,0,72,88a64,64,0,0,0,0,128h88a87.34,87.34,0,0,0,31.8-5.93l10.28,11.31a8,8,0,1,0,11.84-10.76ZM160,200H72a48,48,0,0,1,0-96c1.1,0,2.2,0,3.3.12A88.4,88.4,0,0,0,72,128a8,8,0,0,0,16,0,72.25,72.25,0,0,1,5.06-26.54l87,95.7A71.66,71.66,0,0,1,160,200Zm88-72a87.89,87.89,0,0,1-22.35,58.61A8,8,0,0,1,213.71,176,72,72,0,0,0,117.37,70a8,8,0,0,1-9.48-12.89A88,88,0,0,1,248,128Z" }))], ["thin", e.createElement(e.Fragment, null, e.createElement("path", { d: "M51,37.31A4,4,0,0,0,45,42.69L86.16,87.93q-1.38,2.55-2.59,5.19A60,60,0,1,0,72,212h88a83.19,83.19,0,0,0,32.88-6.69L205,218.69a4,4,0,1,0,5.92-5.38ZM160,204H72a52,52,0,0,1,0-104,52.92,52.92,0,0,1,8.54.72A84.21,84.21,0,0,0,76,128a4,4,0,0,0,8,0,76,76,0,0,1,7.9-33.76L187.13,199A75.37,75.37,0,0,1,160,204Zm84-76a83.86,83.86,0,0,1-21.34,55.94,4,4,0,1,1-6-5.33A76,76,0,0,0,115,66.75a4,4,0,0,1-4.74-6.45A84,84,0,0,1,244,128Z" }))]]), U = e.forwardRef((n, o) => e.createElement(S, { ref: o, ...n, weights: He }));
9U.displayName = "CloudSlashIcon";
10const Ee = U, Me = /* @__PURE__ */ new Map([["bold", e.createElement(e.Fragment, null, e.createElement("path", { d: "M216.49,79.52l-56-56A12,12,0,0,0,152,20H56A20,20,0,0,0,36,40V216a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V88A12,12,0,0,0,216.49,79.52ZM160,57l23,23H160ZM60,212V44h76V92a12,12,0,0,0,12,12h48V212Z" }))], ["duotone", e.createElement(e.Fragment, null, e.createElement("path", { d: "M208,88H152V32Z", op
10acity: "0.2" }), e.createElement("path", { d: "M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z" }))], ["fill", e.createElement(e.Fragment, null, e.createElement("path", { d: "M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM152,88V44l44,44Z" }))], ["light", e.createElement(e.Fragment, null, e.createElement("path", { d: "M212.24,83.76l-56-56A6,6,0,0,0,152,26H56A14,14,0,0,0,42,40V216a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V88A6,6,0,0,0,212.24,83.76ZM158,46.48,193.52,82H158ZM200,218H56a2,2,0,0,1-2-2V40a2,2,0,0,1,2-2h90V88a6,6,0,0,0,6,6h50V216A2,2,0,0,1,200,218Z" }))], ["regular", e.createElement(e.Fragment, null, e.createElement("path", { d: "M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216
10Z" }))], ["thin", e.createElement(e.Fragment, null, e.createElement("path", { d: "M210.83,85.17l-56-56A4,4,0,0,0,152,28H56A12,12,0,0,0,44,40V216a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V88A4,4,0,0,0,210.83,85.17ZM156,41.65,198.34,84H156ZM200,220H56a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h92V88a4,4,0,0,0,4,4h52V216A4,4,0,0,1,200,220Z" }))]]), K = e.forwardRef((n, o) => e.createElement(S, { ref: o, ...n, weights: Me }));
11K.displayName = "FileIcon";
12const _ = K, ve = /* @__PURE__ */ new Map([["bold", e.createElement(e.Fragment, null, e.createElement("path", { d: "M208,36H48A20,20,0,0,0,28,56V200a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V56A20,20,0,0,0,208,36Zm-4,24v56H52V60ZM52,196V140H204v56ZM160,88a16,16,0,1,1,16,16A16,16,0,0,1,160,88Zm32,80a16,16,0,1,1-16-16A16,16,0,0,1,192,168Z" }))], ["duotone", e.createElement(e.Fragment, null, e.createElement("path", { d: "M216,152v48a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V152a8,8,0,0,1,8-8H208A8,8,0,0,1,216,152ZM208,48H48a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8H208a8,8,0,0,0,8-8V56A8,8,0,0,0,208,48Z", opacity: "0.2" }), e.createElement("path", { d: "M208,136H48a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V152A16,16,0,0,0,208,136Zm0,64H48V152H208v48Zm0-160H48A16,16,0,0,0,32,56v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V56A16,16,0,0,0,208,40Zm0,64H48V56H208v48ZM192,80a12,12,0,1,1-12-12A12,12,0,0,1,192,80Zm0,96a12,12,0,1,1-12-12A12,12,0,0,1,192,176Z" }))], ["fill", e.createElement(e.Fragment, null, e.createElement("path", { d: "M208,40H48A16,16,0,0,0,32,56v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V56A16,16,0,0,0,208,40ZM180,92a12,12,0,1,1,12-12A12,12,0,0,1,180,92Z" }), e.createElement("path", { d: "M208,136H48a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V152A16,16,0,0,0,208,136Zm-28,52a12,12,0,1,1,12-12A12,12,0,0,1,180,188Z" }))], ["light", e.createElement(e.Fragment, null, e.createElement("path", { d: "M208,138H48a14,14,0,0,0-14,14v48a14,14,0,0,0,14,14H208a14,14,0,0,0,14-14V152A14,14,0,0,0,208,138Zm2,62a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V152a2,2,0,0,1,2-2H208a2,2,0,0,1,2,2ZM208,42H48A14,14,0,0,0,34,56v48a14,14,0,0,0,14,14H208a14,14,0,0,0,14-14V56A14,14,0,0,0,208,42Zm2,62a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2H208a2,2,0,0,1,2,2ZM190,80a10,10,0,1,1-10-10A10,10,0,0,1,190,80Zm0,96a10,10,0,1,1-10-10A10,10,0,0,1,190,176Z" }))], ["regular", e.createElement(e.Fragment, null, e.createElement("path", { d: "M208,136H48a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V152A16,16,0,0,0,208,136Zm0,64H48V152H208v48Zm0-160H48A16,16,0,0,0,32,56v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V56A16,16,0,0,0,208,40Zm0,64H48V56H208v48ZM192,80a12,12,0,1,1-12-12A12,12,0,0,1,192,80Zm0,96a12,12,0,1,1-12-12A12,12,0,0,1,192,176Z" }))], ["thin", e.createElement(e.Fragment, null, e.createElement("path", { d: "M208,140H48a12,12,0,0,0-12,12v48a12,12,0,0,0,12,12H208a12,12,0,0,0,12-12V152A12,12,0,0,0,208,140Zm4,60a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V152a4,4,0,0,1,4-4H208a4,4,0,0,1,4,4ZM208,44H48A12,12,0,0,0,36,56v48a12,12,0,0,0,12,12H208a12,12,0,0,0,12-12V56A12,12,0,0,0,208,44Zm4,60a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4H208a4,4,0,0,1,4,4Zm-24,72a8,8,0,1,1-8-8A8,8,0,0,1,188,176Zm0-96a8,8,0,1,1-8-8A8,8,0,0,1,188,80Z" }))]]), G = e.forwardRef((n, o) => e.createElement(S, { ref: o, ...n, weights: ve }));
13G.displayName = "HardDrivesIcon";
14const Se = G;
15function je(n) {
16  const o = new Date(n), r = (/* @__PURE__ */ new Date()).getTime() - o.getTime();
17  if (r < 3600 * 1e3) {
18    const s = Math.floor(r / 6e4);
19    return s <= 1 ? "Just now" : `${s}m ago`;
20  }
21  return r < 1440 * 60 * 1e3 ? `${Math.floor(r / 36e5)}h ago` : r < 10080 * 60 * 1e3 ? `${Math.floor(r / 864e5)}
21d ago` : o.toLocaleDateString(void 0, { month: "short", day: "numeric" });
22}
23function B(n) {
24  if (n === 0) return "0 B";
25  const o = 1024, d = ["B", "KB", "MB", "GB"], r = Math.floor(Math.log(n) / Math.log(o));
26  return parseFloat((n / Math.pow(o, r)).toFixed(1)) + " " + d[r];
27}
28function Ve({ doc: n, isSelected: o, isLocked: d, isDownloading: r, isLastOpened: s, onSelect: i, onOpen: f, onDelete: Z, onRename: g }) {
29  const [w, p] = e.useState(false), [A, y] = e.useState(n.name), H = e.useCallback(() => {
30    !d && !r && f();
31  }, [d, r, f]), E = e.useCallback(() => {
32    A.trim() && A !== n.name && g(A.trim()), p(false);
33  }, [A, n.name, g]), M = n.syncStatus === "cloud-only";
34  return t.jsxs("div", { className: D("group flex items-center gap-3 px-3 py-2 cursor-pointer border border-transparent", "hover:bg-surface/50", o && "bg-brand/10 border-brand/30", r && "opacity-60"), onClick: i, onDoubleClick: H, children: [t.jsx(_, { size: 16, weight: "regular", className: "text-text-muted shrink-0" }), t.jsxs("div", { className: "flex-1 min-w-0", children: [w ? t.jsx("input", { type: "text", value: A, onChange: (x) => y(x.target.value), onBlur: E, onKeyDown: (x) => {
35    x.key === "Enter" && E(), x.key === "Escape" && p(false);
36  }, className: "w-full bg-transparent border-b border-brand text-sm text-text outline-none", autoFocus: true }) : t.jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [t.jsx("div", { className: "text-sm text-text truncate", children: n.name }), s && t.jsx("span", { className: "shrink-0 text-[9px] uppercase tracking-wide font-medium text-brand bg-brand/10 px-1.5 py-0.5 rounded", title: "Will reopen on next launch", children: "Last opened" })] }), t.jsx("div", { className: "text-[10px] text-text-muted", children: je(n.modifiedAt) })] }), t.jsx("div", { className: "flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity", children: r ? t.jsx("span", { className: "text-[10px] text-text-muted px-2", children: "Downloading..." }) : d ? t.jsx("span", { className: "text-[10px] text-text-muted px-2", children: "In use" }) : M ? t.jsx("span", { className: "text-[10px] text-text-muted px-2", children: "Click to download" }) : t.jsxs(t.Fragment, { children: [t.jsx(O, { content: "Rename", side: "top", children: t.jsx("button", { onClick: (x) => {
37    x.stopPropagation(), y(n.name), p(true);
38  }, className: "p-1 text-text-muted hover:text-text hover:bg-border/50 transition-colors", children: t.jsx(Ae, { size: 14 }) }) }), t.jsx(O, { content: "Delete", side: "top", children: t.jsx("button", { onClick: (x) => {
39    x.stopPropagation(), Z();
40  }, className: "p-1 text-text-muted hover:text-danger hover:bg-border/50 transition-colors", children: t.jsx(be, { size: 14 }) }) })] }) }), t.jsx("div", { className: "text-text-muted shrink-0", title: n.syncStatus === "synced" ? "Synced" : n.syncStatus === "pending" ? "Pending sync" : n.syncStatus === "cloud-only" ? "Cloud only (click to download)" : "Local only", children: r ? t.jsx(P, { size: 14, className: "text-brand animate-spin" }) : n.syncStatus === "synced" ? t.jsx(R, { size: 14, className: "text-brand" }) : n.syncStatus === "pending" ? t.jsx(R, { size: 14, className: "text-warning" }) : n.syncStatus === "cloud-only" ? t.jsx(Ze, { size: 14, className: "text-brand" }) : t.jsx(Ee, { size: 14 }) })] });
41}
42function ze({ open: n, onOpenChange: o }) {
43  var _a;
44  const [d, r] = e.useState([]), [s, i] = e.useState(null), [f, Z] = e.useState(/* @__PURE__ */ new Set()), [g, w] = e.useState(/* @__PURE__ */ new Set()), [p, A] = e.useState({ used: 0, quota: 0, percentage: 0 }), [y, H] = e.useState(true), [E, M] = e.useState(false), [x, N] = e.useState(!navigator.onLine), J = L((a) => a.user), W = L((a) => a.isAnonymous), j = !!J && !W, v = b((a) => a.documentId), F = n ? te() : null;
45  e.useEffect(() => {
46    const a = () => N(false), u = () => N(true);
47    return window.addEventListener("online", a), window.addEventListener("offline", u), () => {
48      window.removeEventListener("online", a), window.removeEventListener("offline", u);
49    };
50  }, []);
51  const k = e.useCallback(async () => {
52    H(true);
53    try {
54      const a = await ae(), u = a.map((c) => ({ id: c.id, cloudId: c.cloudId, localId: c.id, name: c.name, modifiedAt: c.modifiedAt, source: c.cloudId ? "both" : "local", syncStatus: c.syncStatus }));
55      r(u);
56      const l = /* @__PURE__ */ new Set();
57      for (const c of a) await z(c.id) && l.add(c.id);
58      Z(l);
59      const m = await ne();
60      if (A(m), j && !x) {
61        M(true);
62        try {
63          const c = await se();
64          De(u, c, r);
65        } catch (c) {
66          console.error("Failed to load cloud documents:", c);
67        } finally {
68          M(false);
69        }
70      }
71    } catch (a) {
72      console.error("Failed to load documents:", a);
73    } finally {
74      H(false);
75    }
76  }, [j, x]);
77  e.useEffect(() => {
78    n && k();
79  }, [n, k]);
80  const Y = e.useCallback(async () => {
81    await T();
82    const a = await le(), u = oe();
83    b.getState().newDocument(u, a), o(false), h.getState().addToast(`Created "${a}"`, "success");
84  }, [o]), I = e.useCallback(async () => {
85    if (!s) return;
86    const a = d.find((l) => l.id === s);
87    if (!a) return;
88    if (await T(), a.syncStatus === "cloud-only" && a.cloudId) {
89      w((l) => new Set(l).add(s));
90      try {
91        const l = await re(a.cloudId);
92        r((c) => c.map((V) => V.id === s ? { ...V, id: l, localId: l, syncStatus: "synced", source: "both" } : V));
93        const m = await $(l);
94        m && (b.getState().loadDocument(m.document), b.getState().setDocumentMeta(m.id, m.name), o(false));
95      } catch (l) {
96        console.error("Failed to download document:", l), h.getState().addToast("Failed to download document", "error");
97      } finally {
98        w((l) => {
99          const m = new Set(l);
100          return m.delete(s), m;
101        });
102      }
103      return;
104    }
105    if (await z(s)) {
106      h.getState().addToast("Document is open in another tab", "error");
107      return;
108    }
109    try {
110      const l = await $(s);
111      if (!l) {
112        h.getState().addToast("Document not found", "error");
113        return;
114      }
115      b.getState().loadDocument(l.document), b.getState().setDocumentMeta(l.id, l.name), o(false);
116    } catch (l) {
117      console.error("Failed to open document:", l), h.getState().addToast("Failed to open document", "error");
118    }
119  }, [s, d, o]), Q = e.useCallback(async (a) => {
120    var _a2;
121    if (((_a2 = d.find((l) => l.id === a)) == null ? void 0 : _a2.syncStatus) === "cloud-only") {
122      h.getState().addToast("Download the document first to delete it", "error");
123      return;
124    }
125    if (a === v) {
126      h.getState().addToast("Cannot delete the current document", "error");
127      return;
128    }
129    try {
130      await ce(a), r((l) => l.filter((m) => m.id !== a)), s === a && i(null), h.getState().addToast("Document deleted", "success");
131    } catch (l) {
132      console.error("Failed to delete document:", l), h.getState().addToast("Failed to delete document", "error");
133    }
134  }, [s, v, d]), X = e.useCallback(async (a, u) => {
135    var _a2;
136    if (((_a2 = d.find((m) => m.id === a)) == null ? void 0 : _a2.syncStatus) === "cloud-only") {
137      h.getState().addToast("Download the document first to rename it", "error");
138      return;
139    }
140    try {
141      await de(a, u), r((m) => m.map((c) => c.id === a ? { ...c, name: u } : c)), a === v && b.getState().setDocumentMeta(a, u);
142    } catch (m) {
143      console.error("Failed to rename document:", m), h.getState().addToast("Failed to rename document", "error");
144    }
145  }, [v, d]), ee = ((_a = d.find((a) => a.id === s)) == null ? void 0 : _a.syncStatus) === "cloud-only", C = s ? g.has(s) : false;
146  return t.jsx(ie, { open: n, onOpenChange: o, children: t.jsxs(me, { children: [t.jsx(ue, { className: "fixed inset-0 z-50 bg-black/60" }), t.jsxs(xe, { className: D("fixed left-1/2 top-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2", "rounded-xl border border-border bg-card shadow-xl overflow-hidden", "max-h-[85vh] flex flex-col select-none", "focus:outline-none"), children: [t.jsxs("div", { "data-tauri-drag-region": "", className: "flex items-center justify-between p-4 border-b border-border", children: [t.jsxs("div", { className: "flex items-center gap-2", children: [t.jsx(he, { className: "text-sm font-bold text-text", children: "Documents" }), E && t.jsx(P, { size: 12, className: "text-brand animate-spin" }), x && j && t.jsxs("div", { className: "flex items-center gap-1 text-[10px] text-text-muted", title: "Offline - showing local documents only", children: [t.jsx(we, { size: 12 }), "Offline"] })] }), t.jsx(fe, { className: "p-1 text-text-muted hover:bg-border/50 hover:text-text transition-colors cursor-pointer", children: t.jsx(pe, { size: 16 }) })] }), t.jsx("div", { className: "p-3 border-b border-border", children: t.jsxs("button", { onClick: Y, className: "flex items-center gap-2 w-full px-3 py-2 text-sm text-text hover:bg-surface/50 transition-colors", children: [t.jsx(ge, { size: 16, className: "text-brand" }), "New Document"] }) }), t.jsx("div", { className: "flex-1 overflow-y-auto min-h-[200px]", children: y ? t.jsx("div", { className: "flex items-center justify-center h-full text-text-muted text-sm", children: "Loading..." }) : d.length === 0 ? t.jsxs("div", { className: "flex flex-col items-center justify-center h-full gap-2 text-text-muted", children: [t.jsx(_, { size: 32, weight: "thin" }
146), t.jsx("div", { className: "text-sm", children: "No saved documents" }), t.jsx("div", { className: "text-[10px]", children: "Create a new document to get started" })] }) : t.jsx("div", { className: "divide-y divide-border/50", children: d.map((a) => t.jsx(Ve, { doc: a, isSelected: s === a.id, isLocked: f.has(a.id), isDownloading: g.has(a.id), isLastOpened: F !== null && (a.localId ?? a.id) === F, onSelect: () => i(a.id), onOpen: I, onDelete: () => Q(a.id), onRename: (u) => X(a.id, u) }, a.id)) }) }), t.jsxs("div", { className: "flex items-center justify-between p-3 border-t border-border bg-surface/30", children: [t.jsxs("div", { className: "flex items-center gap-2 text-[10px] text-text-muted", children: [t.jsx(Se, { size: 14 }), t.jsxs("span", { children: [B(p.used), " / ", B(p.quota)] }), p.percentage >= 80 && t.jsxs("span", { className: "text-warning", children: ["(", p.percentage.toFixed(0), "%)"] })] }), t.jsx("button", { onClick: I, disabled: !s || f.has(s) || C, className: D("px-4 py-1.5 text-xs font-medium transition-colors", s && !f.has(s) && !C ? "bg-brand text-white hover:bg-brand/90" : "bg-border text-text-muted cursor-not-allowed"), children: ee ? "Download & Open" : "Open" })] })] })] }) });
147}
148function De(n, o, d) {
149  const r = new Set(n.filter((i) => i.cloudId).map((i) => i.cloudId)), s = o.filter((i) => !r.has(i.id)).map((i) => ({ id: i.id, cloudId: i.id, localId: void 0, name: i.name, modifiedAt: i.device_modified_at, source: "cloud", syncStatus: "cloud-only" }));
150  s.length > 0 && d((i) => {
151    const f = [...i, ...s];
152    return f.sort((Z, g) => g.modifiedAt - Z.modifiedAt), f;
153  });
154}
155export {
156  ze as DocumentPicker
157};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.