import { E as T, F as N, S, p as P, U as _, q as w, r as F, s as x, t as R, v as I, C as M, h as L, I as k, w as U, i as O, j as z, k as V, l as q } from "./chunks/index-CPyEi9gS.js";
import { V as ca, D as fa, Q as ma, P as pa, M as ha, a8 as ga, z as Ca, G as Da, G as Ea, H as xa, T as Ta, a as ba, a7 as ya, a3 as va, O as Aa, N as Ba, ab as Na, a6 as Sa, a5 as Pa, a4 as _a, aa as wa, a9 as Fa, a0 as Ra, Z as Ia, L as Ma, X as La, K as ka, y as Ua, W as Oa, Y as za, A as Va, a2 as qa, $ as Ha, _ as Wa, a1 as ja, x as Ga, J as Qa, B as Ka } from "./chunks/index-CPyEi9gS.js";
import { a as Ya, C as $a, D as Ja, E as Za, P as ae, g as ee, d as se, h as re, b as oe, c as te, i as ne } from "./chunks/common-types-4bjoIgvm.js";
import { C as le } from "./chunks/calendar-preferences-dialog-6q51A6XC.js";
import { jsx as a, jsxs as d } from "react/jsx-runtime";
import { u as H, P as W, b as j, B as G, a as C, g as Q, d as K, e as X } from "./chunks/switch-Dkx2qEOr.js";
import { F as ue, q as ce, h as fe, i as me, k as pe, s as he, r as ge, w as Ce, x as De, p as Ee, j as xe, o as Te, t as be, n as ye, m as ve, l as Ae, y as Be, v as Ne, z as Se, D as Pe, A as _e, E as we, H as Fe, G as Re } from "./chunks/switch-Dkx2qEOr.js";
import * as m from "react";
import { useMemo as Y, useEffect as b } from "react";
import { ResourceManagementPanel as Me } from "./chunks/resource-management-panel-mJ84NxzC.js";
import { DEFAULT_CALENDAR_CONTEXT as ke, DEFAULT_SEMANTIC_DOMAIN_ACCESS as Ue } from "./types/index.js";
import { u as ze } from "./chunks/use-debounced-dirty-check-BwAbnX_5.js";
import "react-dom";
import "./chunks/index-CJdxSyQq.js";
import { A as qe, J as He, B as We, K as je, D as Ge, d as Qe, e as Ke, c as Xe, a as Ye, E as $e, N as Je, U as Ze, V as as, W as es, C as ss, G as rs, H as os, F as ts, t as ns, h as is, z as ls, j as ds, v as us, g as cs, w as fs, x as ms, o as ps, s as hs, q as gs, f as Cs, l as Ds, p as Es, y as xs, m as Ts, r as bs, k as ys, n as vs, i as As, u as Bs, b as Ns, I as Ss } from "./chunks/dashboard-briefing-launcher-ptERmNJr.js";
import { n as _s, s as ws } from "./chunks/normalize-dashboard-for-dirty-check-5KpZN8xr.js";
import "./chunks/index-CuHybtft.js";
function ta(e) {
  const { displayPreferences: s, cardId: t, ...l } = e, r = {
    ...l,
    id: e.dashboardId
    // override the id to the dashboard id so that the dashboard is not loaded
  };
  return /* @__PURE__ */ a(T, { FallbackComponent: N, children: /* @__PURE__ */ d(S, { dashboardProps: r, children: [
    /* @__PURE__ */ a(P, { componentType: "visual", componentId: e.cardId }),
    /* @__PURE__ */ a(_, { appearance: e.appearance, children: /* @__PURE__ */ a(w, { displayPreferences: s, children: /* @__PURE__ */ a(F, { type: "visual", cardId: t, ...r, children: /* @__PURE__ */ a($, { cardId: t }) }) }) })
  ] }) });
}
function $({ cardId: e }) {
  const s = H((r) => {
    var n;
    return (n = r.dashboard) == null ? void 0 : n.sheets;
  }), { card: t, frame: l } = Y(() => {
    const r = s == null ? void 0 : s.flatMap((o) => o.frames), n = r == null ? void 0 : r.flatMap((o) => o == null ? void 0 : o.cards), p = n == null ? void 0 : n.find((o) => (o == null ? void 0 : o.id) === e), h = r == null ? void 0 : r.find(
      (o) => {
        var f;
        return (f = o == null ? void 0 : o.cards) == null ? void 0 : f.find((u) => (u == null ? void 0 : u.id) === e);
      }
    );
    return { card: p, frame: h };
  }, [s, e]);
  return !t || !l ? /* @__PURE__ */ a(
    x,
    {
      error: new Error("Card not found"),
      resetErrorBoundary: () => {
      },
      customerFacingMessage: `Card not found with ID: ${e}`
    }
  ) : /* @__PURE__ */ a("main", { className: "flex h-full grow flex-col", children: /* @__PURE__ */ a(
    T,
    {
      FallbackComponent: ({
        error: r,
        resetErrorBoundary: n
      }) => /* @__PURE__ */ a(
        x,
        {
          error: r,
          resetErrorBoundary: n,
          customerFacingMessage: "Error creating visual. Please try again."
        }
      ),
      children: /* @__PURE__ */ a(R, { card: t, frame: l })
    }
  ) });
}
function na(e, s, t, l) {
  b(() => {
    e && !t && s && l(I(s));
  }, [e, t, s, l]);
}
function ia({
  name: e,
  items: s,
  value: t,
  onChange: l,
  isLoading: r,
  isError: n,
  refetch: p,
  className: h,
  icon: o,
  showNone: f = !1
}) {
  const u = m.useRef(null), [D, E] = m.useState(!1), [y, v] = m.useState("100%"), g = f ? [...s || [], { id: "none", name: "None" }] : s;
  m.useLayoutEffect(() => {
    u.current && v(u.current.offsetWidth);
  }, []);
  function A() {
    var i;
    return r ? "Loading..." : n ? "Error" : t ? (i = s == null ? void 0 : s.find((c) => c.id === t)) == null ? void 0 : i.name : `Select ${e}`;
  }
  function B(i, c) {
    l(c), E(!1);
  }
  return /* @__PURE__ */ d(W, { open: D, onOpenChange: E, children: [
    /* @__PURE__ */ a(j, { asChild: !0, children: /* @__PURE__ */ d(
      G,
      {
        ref: u,
        variant: "outline",
        role: "combobox",
        "aria-expanded": D,
        className: C("flex h-9 w-full justify-between", h),
        children: [
          /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
            o && /* @__PURE__ */ a("div", { className: "mr-2", children: o }),
            /* @__PURE__ */ a("span", { className: "max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap", children: A() })
          ] }),
          /* @__PURE__ */ a(Q, { className: "size-4 opacity-50" })
        ]
      }
    ) }),
    /* @__PURE__ */ a(
      K,
      {
        className: "w-full p-0",
        style: { minWidth: y },
        children: /* @__PURE__ */ d(M, { children: [
          /* @__PURE__ */ d("div", { className: "flex h-9 items-center justify-between border-b pr-1", children: [
            /* @__PURE__ */ a(L, { className: "h-9", placeholder: "Search..." }),
            /* @__PURE__ */ a(k, { className: "h-7", onClick: p, children: /* @__PURE__ */ a(
              U,
              {
                className: C(
                  "size-3.5 opacity-50",
                  r && "animate-spin"
                )
              }
            ) })
          ] }),
          /* @__PURE__ */ d(O, { children: [
            /* @__PURE__ */ d(z, { children: [
              "No ",
              e == null ? void 0 : e.toLowerCase(),
              " found."
            ] }),
            /* @__PURE__ */ a(V, { children: g == null ? void 0 : g.map((i) => /* @__PURE__ */ a(
              q,
              {
                className: "overflow-x-auto",
                value: i.name,
                onSelect: (c) => B(c, i.id),
                children: /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
                  /* @__PURE__ */ a(
                    X,
                    {
                      className: C(
                        "size-4",
                        t === i.id ? "opacity-100" : "opacity-0"
                      )
                    }
                  ),
                  /* @__PURE__ */ a("div", { title: i.name, children: i.name })
                ] })
              },
              i.id
            )) })
          ] })
        ] })
      }
    )
  ] });
}
function la(e, s) {
  b(() => (e && s && (window.__SEMAPHOR_PRINT_STATE__ = {
    ...s
  }), () => {
    e && window.__SEMAPHOR_PRINT_STATE__ && delete window.__SEMAPHOR_PRINT_STATE__;
  }), [e, s]);
}
export {
  qe as AdvancedModeToggle,
  He as BriefingAuthor,
  We as BriefingsApiError,
  Ya as CALCULATED_FIELD_ENTITY_MARKER,
  $a as CONTROL_CARD_DEFAULT_VALUE,
  le as CalendarPreferencesDialog,
  ca as CardSummary,
  ia as Combobox,
  Ja as DATE_FORMAT_VALUES,
  ke as DEFAULT_CALENDAR_CONTEXT,
  Ue as DEFAULT_SEMANTIC_DOMAIN_ACCESS,
  fa as Dashboard,
  je as DashboardBriefingLauncher,
  Ge as DashboardControlsSettings,
  ma as DashboardCreateDialogBase,
  pa as DashboardExportDialog,
  Qe as DashboardFilterControlsButton,
  Ke as DashboardFilterControlsLauncher,
  ha as DashboardWC,
  Xe as DocumentControlsSettings,
  Za as EMPTY_SELECTION,
  ga as ExportError,
  Ye as ExportNotificationItem,
  $e as ExportNotificationList,
  Je as NotificationBell,
  ae as PivotMarkerEnum,
  Me as ResourceManagementPanel,
  Ca as ResourceType,
  S as SemaphorContextProvider,
  Da as SemaphorDataProvider,
  Ea as SemaphorQueryClient,
  xa as ShareDialog,
  Ta as SummaryCard,
  ba as Surfboard,
  Ze as UnsavedChangesAlert,
  ta as Visual,
  as as VisualEditingControls,
  es as WatchDashboardButton,
  ss as applyBriefingFormPatch,
  rs as briefingFormDraftToCreateRequest,
  os as briefingFormDraftToUpdateRequest,
  ts as briefingToFormDraft,
  ns as cancelBriefingRun,
  ya as cancelExport,
  I as cloneDeep,
  is as createBriefing,
  ls as createBriefingFormDraft,
  ue as createEmptyKpiConfig,
  va as createExport,
  ce as createSqlGenConfig,
  ds as deleteBriefing,
  us as deleteBriefingRun,
  Aa as downloadDocumentPdf,
  Ba as downloadPdf,
  fe as emitDashboardLoad,
  me as emitDashboardUnload,
  pe as fmt,
  Na as formatFileSize,
  cs as getBriefing,
  fs as getBriefingArtifact,
  ms as getBriefingEvidence,
  ps as getBriefingPreviewRun,
  hs as getBriefingRun,
  he as getColumnDataType,
  Sa as getDownloadUrl,
  Pa as getExportStatus,
  _a as getExports,
  ee as getFieldRuntimeColumnName,
  ge as getFilterValueType,
  Ce as getFormattedTableNameForQuery,
  De as getQualifiedTableName,
  Ee as getSql,
  se as hasCalculatedFieldMarker,
  re as hasCalculatedFormulaInputs,
  xe as invalidateToken,
  Te as isBooleanDataType,
  oe as isCalculatedDimension,
  te as isCalculatedField,
  ne as isCalculatedMetric,
  be as isColumnInSqlGen,
  ye as isDateDataType,
  wa as isExportComplete,
  Fa as isExportInProgress,
  ve as isNumberDataType,
  Ae as isTextDataType,
  gs as listBriefingRuns,
  Cs as listBriefingTenantSummaries,
  Ds as listBriefings,
  _s as normalizeDashboardForDirtyCheck,
  Es as pauseBriefing,
  xs as polishBriefingText,
  Ts as previewBriefingPlan,
  Be as resolveDataType,
  Ne as resolveDatamodelName,
  bs as resumeBriefing,
  ys as runBriefingNow,
  vs as runBriefingPreview,
  ws as serializeDashboardForDirtyCheck,
  As as updateBriefing,
  Ra as useActiveExports,
  Ia as useAddNewFrame,
  Ma as useCard,
  La as useCardSummary,
  Se as useCurrentActiveCard,
  Pe as useCurrentCardConfig,
  _e as useCurrentSheetActiveCards,
  we as useDashboardActions,
  ka as useDashboardById,
  Ua as useDashboardQuery,
  H as useDashboardStore,
  Oa as useDashboardSummary,
  za as useDataColumns,
  Va as useDateFilterHook,
  ze as useDebouncedDirtyCheck,
  Fe as useEditorActions,
  qa as useEditorAside,
  Re as useEditorStore,
  Ha as useExportActions,
  Bs as useExportPolling,
  Ns as useExportRecovery,
  Wa as useExportStore,
  la as useExposePrintState,
  ja as useInProgressExportsCount,
  Ga as useManagementStore,
  na as usePristineSnapshotInitializer,
  Qa as useResourceManagement,
  Ka as useTextFilterHook,
  Ss as validateBriefingFormDraft
};
