@athenaintel/react 0.10.33 → 0.10.34
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/dist/index.cjs +466 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +466 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -47692,8 +47692,8 @@ const MentionExtension = Node$1.create({
|
|
|
47692
47692
|
};
|
|
47693
47693
|
}
|
|
47694
47694
|
});
|
|
47695
|
-
const ATHENA_APP_HOSTNAMES = /* @__PURE__ */ new Set(["app.athenaintel.com", "staging-app.athenaintel.com"]);
|
|
47696
|
-
const ATHENA_PREVIEW_HOSTNAME_SUFFIX = ".previews.athenaintel.com";
|
|
47695
|
+
const ATHENA_APP_HOSTNAMES$1 = /* @__PURE__ */ new Set(["app.athenaintel.com", "staging-app.athenaintel.com"]);
|
|
47696
|
+
const ATHENA_PREVIEW_HOSTNAME_SUFFIX$1 = ".previews.athenaintel.com";
|
|
47697
47697
|
const ATHENA_WORKSPACE_HOSTNAME_SUFFIXES = [".app.athenaintel.com", ".staging-app.athenaintel.com"];
|
|
47698
47698
|
const ASSET_TYPE_ALIASES = {
|
|
47699
47699
|
document: "document",
|
|
@@ -47713,7 +47713,7 @@ const normalizeAssetType = (value) => {
|
|
|
47713
47713
|
const normalizedValue = value.trim().replace(/^athena\//, "").toLowerCase().replace(/-/g, "_");
|
|
47714
47714
|
return ASSET_TYPE_ALIASES[normalizedValue] ?? null;
|
|
47715
47715
|
};
|
|
47716
|
-
const getOrigin = (value) => {
|
|
47716
|
+
const getOrigin$1 = (value) => {
|
|
47717
47717
|
if (!value) {
|
|
47718
47718
|
return null;
|
|
47719
47719
|
}
|
|
@@ -47737,7 +47737,7 @@ const matchesHostnameOrSubdomain = ({
|
|
|
47737
47737
|
hostname,
|
|
47738
47738
|
candidateHostname
|
|
47739
47739
|
}) => hostname === candidateHostname || hostname.endsWith(`.${candidateHostname}`);
|
|
47740
|
-
const getCurrentOrigin = () => {
|
|
47740
|
+
const getCurrentOrigin$1 = () => {
|
|
47741
47741
|
if (typeof window === "undefined") {
|
|
47742
47742
|
return null;
|
|
47743
47743
|
}
|
|
@@ -47747,7 +47747,7 @@ const parseUrl = ({
|
|
|
47747
47747
|
href,
|
|
47748
47748
|
appUrl
|
|
47749
47749
|
}) => {
|
|
47750
|
-
const fallbackBase = appUrl ?? getCurrentOrigin() ?? "https://app.athenaintel.com";
|
|
47750
|
+
const fallbackBase = appUrl ?? getCurrentOrigin$1() ?? "https://app.athenaintel.com";
|
|
47751
47751
|
try {
|
|
47752
47752
|
return new URL(href, fallbackBase);
|
|
47753
47753
|
} catch {
|
|
@@ -47759,18 +47759,18 @@ const isAthenaAppUrl = ({
|
|
|
47759
47759
|
appUrl
|
|
47760
47760
|
}) => {
|
|
47761
47761
|
const hostname = url.hostname.toLowerCase();
|
|
47762
|
-
if (ATHENA_APP_HOSTNAMES.has(hostname) || hostname.endsWith(ATHENA_PREVIEW_HOSTNAME_SUFFIX) || ATHENA_WORKSPACE_HOSTNAME_SUFFIXES.some((suffix) => hostname.endsWith(suffix))) {
|
|
47762
|
+
if (ATHENA_APP_HOSTNAMES$1.has(hostname) || hostname.endsWith(ATHENA_PREVIEW_HOSTNAME_SUFFIX$1) || ATHENA_WORKSPACE_HOSTNAME_SUFFIXES.some((suffix) => hostname.endsWith(suffix))) {
|
|
47763
47763
|
return true;
|
|
47764
47764
|
}
|
|
47765
47765
|
const configuredHostname = getHostname(appUrl);
|
|
47766
47766
|
if (configuredHostname && matchesHostnameOrSubdomain({ hostname, candidateHostname: configuredHostname })) {
|
|
47767
47767
|
return true;
|
|
47768
47768
|
}
|
|
47769
|
-
const configuredOrigin = getOrigin(appUrl);
|
|
47769
|
+
const configuredOrigin = getOrigin$1(appUrl);
|
|
47770
47770
|
if (configuredOrigin && url.origin === configuredOrigin) {
|
|
47771
47771
|
return true;
|
|
47772
47772
|
}
|
|
47773
|
-
const currentOrigin = getCurrentOrigin();
|
|
47773
|
+
const currentOrigin = getCurrentOrigin$1();
|
|
47774
47774
|
return !!currentOrigin && url.origin === currentOrigin;
|
|
47775
47775
|
};
|
|
47776
47776
|
const parseAthenaCitationLink = ({
|
|
@@ -52051,6 +52051,12 @@ function getNumberField(source, keys2) {
|
|
|
52051
52051
|
}
|
|
52052
52052
|
return null;
|
|
52053
52053
|
}
|
|
52054
|
+
function asRecord(value) {
|
|
52055
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
52056
|
+
return null;
|
|
52057
|
+
}
|
|
52058
|
+
return value;
|
|
52059
|
+
}
|
|
52054
52060
|
const PRESENTATION_CODE_SLIDE_NUMBER_KEYS = [
|
|
52055
52061
|
"slideNumber",
|
|
52056
52062
|
"slide_number",
|
|
@@ -53804,6 +53810,374 @@ const UpdateSheetRangeToolUI = React.memo(
|
|
|
53804
53810
|
UpdateSheetRangeToolUIImpl
|
|
53805
53811
|
);
|
|
53806
53812
|
UpdateSheetRangeToolUI.displayName = "UpdateSheetRangeToolUI";
|
|
53813
|
+
function parseJsonArray(text2) {
|
|
53814
|
+
try {
|
|
53815
|
+
const parsed = JSON.parse(text2);
|
|
53816
|
+
return Array.isArray(parsed) ? parsed : null;
|
|
53817
|
+
} catch {
|
|
53818
|
+
return null;
|
|
53819
|
+
}
|
|
53820
|
+
}
|
|
53821
|
+
function getFirstSheetCellStyle(operation) {
|
|
53822
|
+
const cells = operation.cells;
|
|
53823
|
+
const rows = typeof cells === "string" ? parseJsonArray(cells) : cells;
|
|
53824
|
+
if (!Array.isArray(rows)) {
|
|
53825
|
+
return null;
|
|
53826
|
+
}
|
|
53827
|
+
for (const row of rows) {
|
|
53828
|
+
if (!Array.isArray(row)) {
|
|
53829
|
+
continue;
|
|
53830
|
+
}
|
|
53831
|
+
for (const cell of row) {
|
|
53832
|
+
const cellRecord = asRecord(cell);
|
|
53833
|
+
const style2 = asRecord(
|
|
53834
|
+
(cellRecord == null ? void 0 : cellRecord.cellStyles) ?? (cellRecord == null ? void 0 : cellRecord.cell_styles) ?? (cellRecord == null ? void 0 : cellRecord.style)
|
|
53835
|
+
);
|
|
53836
|
+
if (style2) {
|
|
53837
|
+
return style2;
|
|
53838
|
+
}
|
|
53839
|
+
}
|
|
53840
|
+
}
|
|
53841
|
+
return null;
|
|
53842
|
+
}
|
|
53843
|
+
function summarizeSheetCellStyle(style2) {
|
|
53844
|
+
if (!style2) {
|
|
53845
|
+
return "Cell formatting";
|
|
53846
|
+
}
|
|
53847
|
+
const parts = [];
|
|
53848
|
+
const textFormat = asRecord(style2.textFormat ?? style2.text_format);
|
|
53849
|
+
if ((textFormat == null ? void 0 : textFormat.bold) === true) {
|
|
53850
|
+
parts.push("bold");
|
|
53851
|
+
}
|
|
53852
|
+
if ((textFormat == null ? void 0 : textFormat.italic) === true) {
|
|
53853
|
+
parts.push("italic");
|
|
53854
|
+
}
|
|
53855
|
+
if ((textFormat == null ? void 0 : textFormat.underline) === true) {
|
|
53856
|
+
parts.push("underline");
|
|
53857
|
+
}
|
|
53858
|
+
const fontSize = getNumberField(textFormat, ["fontSize", "font_size"]);
|
|
53859
|
+
if (fontSize != null) {
|
|
53860
|
+
parts.push(`${fontSize} pt`);
|
|
53861
|
+
}
|
|
53862
|
+
const textColor = getStringField(textFormat, [
|
|
53863
|
+
"color_hex",
|
|
53864
|
+
"colorHex",
|
|
53865
|
+
"foregroundColor_hex",
|
|
53866
|
+
"foregroundColorHex"
|
|
53867
|
+
]);
|
|
53868
|
+
if (textColor) {
|
|
53869
|
+
parts.push(`text ${textColor}`);
|
|
53870
|
+
}
|
|
53871
|
+
const fillColor = getStringField(style2, [
|
|
53872
|
+
"backgroundColor_hex",
|
|
53873
|
+
"backgroundColorHex",
|
|
53874
|
+
"background_color_hex"
|
|
53875
|
+
]);
|
|
53876
|
+
if (fillColor) {
|
|
53877
|
+
parts.push(`fill ${fillColor}`);
|
|
53878
|
+
}
|
|
53879
|
+
const numberFormat = asRecord(style2.numberFormat ?? style2.number_format);
|
|
53880
|
+
const numberPattern = getStringField(numberFormat, ["pattern"]);
|
|
53881
|
+
const numberType = getStringField(numberFormat, ["type"]);
|
|
53882
|
+
if (numberPattern) {
|
|
53883
|
+
parts.push(numberPattern);
|
|
53884
|
+
} else if (numberType) {
|
|
53885
|
+
parts.push(numberType.toLowerCase());
|
|
53886
|
+
}
|
|
53887
|
+
const horizontalAlignment = getStringField(style2, [
|
|
53888
|
+
"horizontalAlignment",
|
|
53889
|
+
"horizontal_alignment"
|
|
53890
|
+
]);
|
|
53891
|
+
if (horizontalAlignment) {
|
|
53892
|
+
parts.push(`${horizontalAlignment.toLowerCase()} align`);
|
|
53893
|
+
}
|
|
53894
|
+
return parts.length > 0 ? parts.slice(0, 5).join(", ") : "Cell formatting";
|
|
53895
|
+
}
|
|
53896
|
+
function parseSheetFormatOperations(operationsValue) {
|
|
53897
|
+
const operations = typeof operationsValue === "string" ? parseJsonArray(operationsValue) : operationsValue;
|
|
53898
|
+
if (!Array.isArray(operations)) {
|
|
53899
|
+
return [];
|
|
53900
|
+
}
|
|
53901
|
+
return operations.flatMap((operation) => {
|
|
53902
|
+
const record2 = asRecord(operation);
|
|
53903
|
+
if (!record2) {
|
|
53904
|
+
return [];
|
|
53905
|
+
}
|
|
53906
|
+
const range = getStringField(record2, ["range"]) ?? "";
|
|
53907
|
+
if (!range) {
|
|
53908
|
+
return [];
|
|
53909
|
+
}
|
|
53910
|
+
const assetId = getStringField(record2, ["asset_id", "assetId", "id"]);
|
|
53911
|
+
return [
|
|
53912
|
+
{
|
|
53913
|
+
assetId: (assetId == null ? void 0 : assetId.startsWith("asset_")) ? assetId : null,
|
|
53914
|
+
explanation: getStringField(record2, ["explanation", "summary"]),
|
|
53915
|
+
range,
|
|
53916
|
+
styleSummary: summarizeSheetCellStyle(getFirstSheetCellStyle(record2))
|
|
53917
|
+
}
|
|
53918
|
+
];
|
|
53919
|
+
});
|
|
53920
|
+
}
|
|
53921
|
+
function getSpreadsheetAssetIdFromOperations(operations) {
|
|
53922
|
+
var _a2;
|
|
53923
|
+
return ((_a2 = operations.find((operation) => operation.assetId)) == null ? void 0 : _a2.assetId) ?? null;
|
|
53924
|
+
}
|
|
53925
|
+
function getSpreadsheetAssetIdFromArgs(args) {
|
|
53926
|
+
const assetId = getStringField(args, ["asset_id", "assetId", "id"]);
|
|
53927
|
+
return (assetId == null ? void 0 : assetId.startsWith("asset_")) ? assetId : null;
|
|
53928
|
+
}
|
|
53929
|
+
function summarizeSheetRanges(ranges) {
|
|
53930
|
+
if (ranges.length === 0) {
|
|
53931
|
+
return void 0;
|
|
53932
|
+
}
|
|
53933
|
+
const visible = ranges.slice(0, 4);
|
|
53934
|
+
const remaining = ranges.length - visible.length;
|
|
53935
|
+
return remaining > 0 ? `${visible.join(", ")} +${remaining} more` : visible.join(", ");
|
|
53936
|
+
}
|
|
53937
|
+
const BulkFormatSheetRangeToolUIImpl = ({
|
|
53938
|
+
toolName,
|
|
53939
|
+
args,
|
|
53940
|
+
result,
|
|
53941
|
+
status
|
|
53942
|
+
}) => {
|
|
53943
|
+
const typedArgs = args;
|
|
53944
|
+
const data = React.useMemo(() => normalizeResult(result), [result]);
|
|
53945
|
+
const operations = React.useMemo(
|
|
53946
|
+
() => parseSheetFormatOperations(typedArgs == null ? void 0 : typedArgs.operations),
|
|
53947
|
+
[typedArgs == null ? void 0 : typedArgs.operations]
|
|
53948
|
+
);
|
|
53949
|
+
const resultAssetId = extractAssetId(result);
|
|
53950
|
+
const argsAssetId = getSpreadsheetAssetIdFromArgs(typedArgs);
|
|
53951
|
+
const operationsAssetId = getSpreadsheetAssetIdFromOperations(operations);
|
|
53952
|
+
const effectiveAssetId = resultAssetId ?? argsAssetId ?? operationsAssetId;
|
|
53953
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
53954
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
53955
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
53956
|
+
const totalCount = getNumberField(data, ["total"]) ?? operations.length;
|
|
53957
|
+
const succeededCount = getNumberField(data, ["succeeded", "success_count", "successCount"]) ?? (isComplete && totalCount > 0 ? Math.max(totalCount - (getNumberField(data, ["failed"]) ?? 0), 0) : null);
|
|
53958
|
+
const failedCount = getNumberField(data, [
|
|
53959
|
+
"failed",
|
|
53960
|
+
"failure_count",
|
|
53961
|
+
"failureCount"
|
|
53962
|
+
]);
|
|
53963
|
+
const rangesSummary = summarizeSheetRanges(
|
|
53964
|
+
operations.map((operation) => operation.range)
|
|
53965
|
+
);
|
|
53966
|
+
const visibleOperations = operations.slice(0, 24);
|
|
53967
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
53968
|
+
const title = isRunning ? totalCount > 0 ? `Formatting ${totalCount} sheet ${totalCount === 1 ? "range" : "ranges"}...` : "Formatting spreadsheet ranges..." : failedCount && failedCount > 0 ? `Formatted ${succeededCount ?? 0} of ${totalCount} sheet ranges` : totalCount > 0 ? `Formatted ${totalCount} sheet ${totalCount === 1 ? "range" : "ranges"}` : "Formatted spreadsheet ranges";
|
|
53969
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
53970
|
+
ToolCard,
|
|
53971
|
+
{
|
|
53972
|
+
icon: TableProperties,
|
|
53973
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
53974
|
+
title: truncate(title, 80),
|
|
53975
|
+
subtitle: rangesSummary,
|
|
53976
|
+
toolName,
|
|
53977
|
+
args: typedArgs,
|
|
53978
|
+
result,
|
|
53979
|
+
badge: failedCount && failedCount > 0 ? `${failedCount} failed` : totalCount > 0 ? `${totalCount} ops` : void 0,
|
|
53980
|
+
error: errorMsg,
|
|
53981
|
+
children: [
|
|
53982
|
+
operations.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
53983
|
+
ExpandableSection,
|
|
53984
|
+
{
|
|
53985
|
+
label: `Show formatting operations (${operations.length})`,
|
|
53986
|
+
defaultOpen: operations.length <= 6,
|
|
53987
|
+
children: [
|
|
53988
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full text-[11px]", children: [
|
|
53989
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "border-b border-border/40 text-left text-muted-foreground", children: [
|
|
53990
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-20 pb-1.5 pr-3 font-medium", children: "Range" }),
|
|
53991
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "pb-1.5 pr-3 font-medium", children: "Purpose" }),
|
|
53992
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "pb-1.5 font-medium", children: "Style" })
|
|
53993
|
+
] }) }),
|
|
53994
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: visibleOperations.map((operation, index2) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
53995
|
+
"tr",
|
|
53996
|
+
{
|
|
53997
|
+
className: "border-t border-border/25 first:border-t-0",
|
|
53998
|
+
children: [
|
|
53999
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "whitespace-nowrap py-1.5 pr-3 font-mono text-foreground/80", children: operation.range }),
|
|
54000
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "max-w-[220px] py-1.5 pr-3 text-foreground/75", children: operation.explanation ? truncate(operation.explanation, 72) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground/40", children: "-" }) }),
|
|
54001
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "max-w-[260px] py-1.5 text-muted-foreground", children: truncate(operation.styleSummary, 80) })
|
|
54002
|
+
]
|
|
54003
|
+
},
|
|
54004
|
+
`${operation.range}-${index2}`
|
|
54005
|
+
)) })
|
|
54006
|
+
] }) }),
|
|
54007
|
+
operations.length > visibleOperations.length && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-2 text-[10px] text-muted-foreground", children: [
|
|
54008
|
+
"Showing first ",
|
|
54009
|
+
visibleOperations.length,
|
|
54010
|
+
" of ",
|
|
54011
|
+
operations.length,
|
|
54012
|
+
" operations"
|
|
54013
|
+
] })
|
|
54014
|
+
]
|
|
54015
|
+
}
|
|
54016
|
+
),
|
|
54017
|
+
effectiveAssetId && isComplete && !errorMsg && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
54018
|
+
"button",
|
|
54019
|
+
{
|
|
54020
|
+
type: "button",
|
|
54021
|
+
onClick: () => openAsset(effectiveAssetId, { type: "spreadsheet" }),
|
|
54022
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
54023
|
+
children: [
|
|
54024
|
+
/* @__PURE__ */ jsxRuntime.jsx(ExternalLink, { className: "size-3" }),
|
|
54025
|
+
"Open spreadsheet"
|
|
54026
|
+
]
|
|
54027
|
+
}
|
|
54028
|
+
) })
|
|
54029
|
+
]
|
|
54030
|
+
}
|
|
54031
|
+
);
|
|
54032
|
+
};
|
|
54033
|
+
const BulkFormatSheetRangeToolUI = React.memo(
|
|
54034
|
+
BulkFormatSheetRangeToolUIImpl
|
|
54035
|
+
);
|
|
54036
|
+
BulkFormatSheetRangeToolUI.displayName = "BulkFormatSheetRangeToolUI";
|
|
54037
|
+
function formatDimensionUnit(unit) {
|
|
54038
|
+
if (!unit) {
|
|
54039
|
+
return "";
|
|
54040
|
+
}
|
|
54041
|
+
const normalized = unit.toLowerCase();
|
|
54042
|
+
if (normalized === "pixels" || normalized === "pixel") {
|
|
54043
|
+
return "pixels";
|
|
54044
|
+
}
|
|
54045
|
+
if (normalized === "points" || normalized === "point") {
|
|
54046
|
+
return "points";
|
|
54047
|
+
}
|
|
54048
|
+
return unit;
|
|
54049
|
+
}
|
|
54050
|
+
function formatShortDimensionUnit(unit) {
|
|
54051
|
+
const normalized = unit == null ? void 0 : unit.toLowerCase();
|
|
54052
|
+
if (normalized === "pixels" || normalized === "pixel") {
|
|
54053
|
+
return "px";
|
|
54054
|
+
}
|
|
54055
|
+
if (normalized === "points" || normalized === "point") {
|
|
54056
|
+
return "pt";
|
|
54057
|
+
}
|
|
54058
|
+
return unit ?? "";
|
|
54059
|
+
}
|
|
54060
|
+
function parseDimensionMeasurement(value) {
|
|
54061
|
+
const record2 = asRecord(value);
|
|
54062
|
+
if (record2) {
|
|
54063
|
+
const numericValue = getNumberField(record2, ["value"]);
|
|
54064
|
+
const stringValue = getStringField(record2, ["value"]);
|
|
54065
|
+
const rawValue = numericValue != null ? String(numericValue) : stringValue ? stringValue : null;
|
|
54066
|
+
if (!rawValue) {
|
|
54067
|
+
return null;
|
|
54068
|
+
}
|
|
54069
|
+
const unit = getStringField(record2, ["type", "unit"]);
|
|
54070
|
+
const formattedUnit = formatDimensionUnit(unit);
|
|
54071
|
+
const shortUnit = formatShortDimensionUnit(unit);
|
|
54072
|
+
return {
|
|
54073
|
+
value: formattedUnit ? `${rawValue} ${formattedUnit}` : rawValue,
|
|
54074
|
+
shortValue: shortUnit ? `${rawValue} ${shortUnit}` : rawValue
|
|
54075
|
+
};
|
|
54076
|
+
}
|
|
54077
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
54078
|
+
return { value: String(value), shortValue: String(value) };
|
|
54079
|
+
}
|
|
54080
|
+
if (typeof value === "string" && value.trim()) {
|
|
54081
|
+
return { value, shortValue: value };
|
|
54082
|
+
}
|
|
54083
|
+
return null;
|
|
54084
|
+
}
|
|
54085
|
+
function getSheetDimensionSummary(args) {
|
|
54086
|
+
const width = parseDimensionMeasurement(args == null ? void 0 : args.width);
|
|
54087
|
+
if (width) {
|
|
54088
|
+
return {
|
|
54089
|
+
kind: "column width",
|
|
54090
|
+
shortValue: width.shortValue,
|
|
54091
|
+
value: width.value
|
|
54092
|
+
};
|
|
54093
|
+
}
|
|
54094
|
+
const height = parseDimensionMeasurement(args == null ? void 0 : args.height);
|
|
54095
|
+
if (height) {
|
|
54096
|
+
return {
|
|
54097
|
+
kind: "row height",
|
|
54098
|
+
shortValue: height.shortValue,
|
|
54099
|
+
value: height.value
|
|
54100
|
+
};
|
|
54101
|
+
}
|
|
54102
|
+
return {
|
|
54103
|
+
kind: "row and column dimensions",
|
|
54104
|
+
shortValue: null,
|
|
54105
|
+
value: null
|
|
54106
|
+
};
|
|
54107
|
+
}
|
|
54108
|
+
function getToolResultText(result, data) {
|
|
54109
|
+
if (typeof result === "string" && result.trim()) {
|
|
54110
|
+
return result;
|
|
54111
|
+
}
|
|
54112
|
+
return getStringField(data, ["message", "result", "summary"]);
|
|
54113
|
+
}
|
|
54114
|
+
const SetRowColumnDimensionsToolUIImpl = ({
|
|
54115
|
+
toolName,
|
|
54116
|
+
args,
|
|
54117
|
+
result,
|
|
54118
|
+
status
|
|
54119
|
+
}) => {
|
|
54120
|
+
const typedArgs = args;
|
|
54121
|
+
const data = React.useMemo(() => normalizeResult(result), [result]);
|
|
54122
|
+
const range = getStringField(typedArgs, ["range"]) ?? "";
|
|
54123
|
+
const dimension = getSheetDimensionSummary(typedArgs);
|
|
54124
|
+
const effectiveAssetId = extractAssetId(result) ?? getSpreadsheetAssetIdFromArgs(typedArgs);
|
|
54125
|
+
const resultText = getToolResultText(result, data);
|
|
54126
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
54127
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
54128
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
54129
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
54130
|
+
const title = isRunning ? `Setting ${dimension.kind}...` : range ? `Set ${dimension.kind} for ${range}` : `Set ${dimension.kind}`;
|
|
54131
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
54132
|
+
ToolCard,
|
|
54133
|
+
{
|
|
54134
|
+
icon: TableProperties,
|
|
54135
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
54136
|
+
title: truncate(title, 80),
|
|
54137
|
+
subtitle: dimension.value ? `Value: ${dimension.value}` : void 0,
|
|
54138
|
+
toolName,
|
|
54139
|
+
args: typedArgs,
|
|
54140
|
+
result,
|
|
54141
|
+
badge: dimension.shortValue ?? void 0,
|
|
54142
|
+
error: errorMsg,
|
|
54143
|
+
children: [
|
|
54144
|
+
(range || dimension.value || resultText) && isComplete && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
|
|
54145
|
+
/* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "grid gap-2 text-[11px] sm:grid-cols-3", children: [
|
|
54146
|
+
range && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
54147
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-muted-foreground", children: "Range" }),
|
|
54148
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "mt-0.5 font-mono text-foreground/80", children: range })
|
|
54149
|
+
] }),
|
|
54150
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
54151
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-muted-foreground", children: "Dimension" }),
|
|
54152
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "mt-0.5 text-foreground/80", children: dimension.kind })
|
|
54153
|
+
] }),
|
|
54154
|
+
dimension.value && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
54155
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-muted-foreground", children: "Value" }),
|
|
54156
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "mt-0.5 text-foreground/80", children: dimension.value })
|
|
54157
|
+
] })
|
|
54158
|
+
] }),
|
|
54159
|
+
resultText && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-[11px] leading-relaxed text-muted-foreground", children: truncate(resultText, 160) })
|
|
54160
|
+
] }),
|
|
54161
|
+
effectiveAssetId && isComplete && !errorMsg && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
54162
|
+
"button",
|
|
54163
|
+
{
|
|
54164
|
+
type: "button",
|
|
54165
|
+
onClick: () => openAsset(effectiveAssetId, { type: "spreadsheet" }),
|
|
54166
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
54167
|
+
children: [
|
|
54168
|
+
/* @__PURE__ */ jsxRuntime.jsx(ExternalLink, { className: "size-3" }),
|
|
54169
|
+
"Open spreadsheet"
|
|
54170
|
+
]
|
|
54171
|
+
}
|
|
54172
|
+
) })
|
|
54173
|
+
]
|
|
54174
|
+
}
|
|
54175
|
+
);
|
|
54176
|
+
};
|
|
54177
|
+
const SetRowColumnDimensionsToolUI = React.memo(
|
|
54178
|
+
SetRowColumnDimensionsToolUIImpl
|
|
54179
|
+
);
|
|
54180
|
+
SetRowColumnDimensionsToolUI.displayName = "SetRowColumnDimensionsToolUI";
|
|
53807
54181
|
function createAssetToolUI(config2) {
|
|
53808
54182
|
const Component = (props) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
53809
54183
|
CreateAssetToolUIImpl,
|
|
@@ -54225,6 +54599,8 @@ const TOOL_UI_REGISTRY = {
|
|
|
54225
54599
|
capture_moment: CaptureMomentToolUI,
|
|
54226
54600
|
capture_slide_screenshot: CaptureSlideScreenshotToolUI,
|
|
54227
54601
|
// Spreadsheet toolkit
|
|
54602
|
+
bulk_format_sheet_range: BulkFormatSheetRangeToolUI,
|
|
54603
|
+
set_row_column_dimensions: SetRowColumnDimensionsToolUI,
|
|
54228
54604
|
update_sheet_range: UpdateSheetRangeToolUI,
|
|
54229
54605
|
// Database toolkit
|
|
54230
54606
|
describe_database: DescribeDatabaseToolUI,
|
|
@@ -55918,19 +56294,93 @@ const AthenaUserMessage = ({
|
|
|
55918
56294
|
}
|
|
55919
56295
|
);
|
|
55920
56296
|
const embedCache = /* @__PURE__ */ new Map();
|
|
56297
|
+
const ATHENA_APP_HOSTNAMES = /* @__PURE__ */ new Set(["app.athenaintel.com", "staging-app.athenaintel.com"]);
|
|
56298
|
+
const ATHENA_PREVIEW_HOSTNAME_SUFFIX = ".previews.athenaintel.com";
|
|
56299
|
+
const ATHENA_WORKSPACE_HOSTNAME_PATTERN = /^.+--(\d+)\.(?:app\.athenaintel\.com|staging-app\.athenaintel\.com)$/;
|
|
56300
|
+
const OLYMPUS_WORKSPACE_PORT = "8082";
|
|
56301
|
+
const getUrl = (value) => {
|
|
56302
|
+
if (!value) {
|
|
56303
|
+
return null;
|
|
56304
|
+
}
|
|
56305
|
+
try {
|
|
56306
|
+
return new URL(value);
|
|
56307
|
+
} catch {
|
|
56308
|
+
return null;
|
|
56309
|
+
}
|
|
56310
|
+
};
|
|
56311
|
+
const getCurrentOrigin = () => {
|
|
56312
|
+
if (typeof window === "undefined") {
|
|
56313
|
+
return null;
|
|
56314
|
+
}
|
|
56315
|
+
return window.location.origin;
|
|
56316
|
+
};
|
|
56317
|
+
const getOrigin = (value) => {
|
|
56318
|
+
var _a2;
|
|
56319
|
+
return ((_a2 = getUrl(value)) == null ? void 0 : _a2.origin) ?? null;
|
|
56320
|
+
};
|
|
56321
|
+
const getAthenaWorkspacePort = (url) => {
|
|
56322
|
+
const match2 = url.hostname.toLowerCase().match(ATHENA_WORKSPACE_HOSTNAME_PATTERN);
|
|
56323
|
+
return (match2 == null ? void 0 : match2[1]) ?? null;
|
|
56324
|
+
};
|
|
56325
|
+
const isEmbedCapableAthenaHost = (url) => {
|
|
56326
|
+
const hostname = url.hostname.toLowerCase();
|
|
56327
|
+
if (ATHENA_APP_HOSTNAMES.has(hostname) || hostname.endsWith(ATHENA_PREVIEW_HOSTNAME_SUFFIX)) {
|
|
56328
|
+
return true;
|
|
56329
|
+
}
|
|
56330
|
+
return getAthenaWorkspacePort(url) === OLYMPUS_WORKSPACE_PORT;
|
|
56331
|
+
};
|
|
56332
|
+
const shouldPreferDerivedEmbedAppUrl = ({
|
|
56333
|
+
appUrl,
|
|
56334
|
+
derivedAppUrl,
|
|
56335
|
+
currentOrigin
|
|
56336
|
+
}) => {
|
|
56337
|
+
if (!derivedAppUrl) {
|
|
56338
|
+
return false;
|
|
56339
|
+
}
|
|
56340
|
+
const resolvedAppUrl = getUrl(appUrl);
|
|
56341
|
+
if (!resolvedAppUrl) {
|
|
56342
|
+
return true;
|
|
56343
|
+
}
|
|
56344
|
+
const workspacePort = getAthenaWorkspacePort(resolvedAppUrl);
|
|
56345
|
+
if (workspacePort && workspacePort !== OLYMPUS_WORKSPACE_PORT) {
|
|
56346
|
+
return true;
|
|
56347
|
+
}
|
|
56348
|
+
if (isEmbedCapableAthenaHost(resolvedAppUrl)) {
|
|
56349
|
+
return false;
|
|
56350
|
+
}
|
|
56351
|
+
const resolvedCurrentOrigin = getOrigin(currentOrigin ?? getCurrentOrigin());
|
|
56352
|
+
return !!resolvedCurrentOrigin && resolvedAppUrl.origin === resolvedCurrentOrigin;
|
|
56353
|
+
};
|
|
56354
|
+
const resolveEmbedAppUrl = ({
|
|
56355
|
+
appUrl,
|
|
56356
|
+
backendUrl,
|
|
56357
|
+
currentOrigin
|
|
56358
|
+
}) => {
|
|
56359
|
+
const derivedAppUrl = deriveAthenaAppUrl({ backendUrl });
|
|
56360
|
+
if (!appUrl) {
|
|
56361
|
+
return derivedAppUrl;
|
|
56362
|
+
}
|
|
56363
|
+
if (shouldPreferDerivedEmbedAppUrl({ appUrl, derivedAppUrl, currentOrigin })) {
|
|
56364
|
+
return derivedAppUrl;
|
|
56365
|
+
}
|
|
56366
|
+
return appUrl;
|
|
56367
|
+
};
|
|
55921
56368
|
function resolveAssetEmbedUrl({
|
|
55922
56369
|
embedUrl,
|
|
55923
|
-
appUrl
|
|
56370
|
+
appUrl,
|
|
56371
|
+
backendUrl,
|
|
56372
|
+
currentOrigin
|
|
55924
56373
|
}) {
|
|
55925
|
-
if (!appUrl) {
|
|
55926
|
-
return embedUrl;
|
|
55927
|
-
}
|
|
55928
56374
|
try {
|
|
55929
56375
|
const resolvedEmbedUrl = new URL(embedUrl);
|
|
55930
|
-
const resolvedAppUrl = new URL(appUrl);
|
|
55931
56376
|
if (!resolvedEmbedUrl.pathname.startsWith("/embed/")) {
|
|
55932
56377
|
return embedUrl;
|
|
55933
56378
|
}
|
|
56379
|
+
const embedAppUrl = resolveEmbedAppUrl({ appUrl, backendUrl, currentOrigin });
|
|
56380
|
+
if (!embedAppUrl) {
|
|
56381
|
+
return embedUrl;
|
|
56382
|
+
}
|
|
56383
|
+
const resolvedAppUrl = new URL(embedAppUrl);
|
|
55934
56384
|
resolvedEmbedUrl.protocol = resolvedAppUrl.protocol;
|
|
55935
56385
|
resolvedEmbedUrl.host = resolvedAppUrl.host;
|
|
55936
56386
|
return resolvedEmbedUrl.toString();
|
|
@@ -55965,7 +56415,7 @@ function useAssetEmbed(assetId, options = {
|
|
|
55965
56415
|
return;
|
|
55966
56416
|
}
|
|
55967
56417
|
const authContext = hasToken ? "token" : apiKey ?? "anon";
|
|
55968
|
-
const cacheKey = `${assetId}:${readOnly}:${authContext}:${appUrl ?? ""}`;
|
|
56418
|
+
const cacheKey = `${assetId}:${readOnly}:${authContext}:${backendUrl}:${appUrl ?? ""}`;
|
|
55969
56419
|
const cached2 = embedCache.get(cacheKey);
|
|
55970
56420
|
if (cached2 && cached2.expiresAt > Date.now() / 1e3) {
|
|
55971
56421
|
setEmbedUrl(cached2.url);
|
|
@@ -56005,7 +56455,8 @@ function useAssetEmbed(assetId, options = {
|
|
|
56005
56455
|
}).then((data) => {
|
|
56006
56456
|
const resolvedEmbedUrl = resolveAssetEmbedUrl({
|
|
56007
56457
|
embedUrl: data.embed_url,
|
|
56008
|
-
appUrl
|
|
56458
|
+
appUrl,
|
|
56459
|
+
backendUrl
|
|
56009
56460
|
});
|
|
56010
56461
|
embedCache.set(cacheKey, { url: resolvedEmbedUrl, expiresAt: data.expires_at });
|
|
56011
56462
|
setEmbedUrl(resolvedEmbedUrl);
|