"use client"
//#region rolldown:runtime
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __copyProps = (to, from, except, desc) => {
	if (from && typeof from === "object" || typeof from === "function") {
		for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
			key = keys[i];
			if (!__hasOwnProp.call(to, key) && key !== except) {
				__defProp(to, key, {
					get: ((k) => from[k]).bind(null, key),
					enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
				});
			}
		}
	}
	return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
	value: mod,
	enumerable: true
}) : target, mod));

//#endregion
const require_const = require('./const-CvdZO0FN.js');
let react = require("react");
react = __toESM(react);
let react_jsx_runtime = require("react/jsx-runtime");
let _tanstack_react_query = require("@tanstack/react-query");
let axios = require("axios");
axios = __toESM(axios);
let _amplitude_unified = require("@amplitude/unified");

//#region recce-source/js/src/lib/api/axiosClient.ts
const axiosClient = axios.default.create({ baseURL: require_const.PUBLIC_API_URL });
const reactQueryClient = new _tanstack_react_query.QueryClient();

//#endregion
//#region recce-source/js/src/lib/api/track.ts
function track(eventInput, eventProperties, eventOptions) {
	if (!amplitudeInitialized) console.log("[Tracking]", eventInput, eventProperties, eventOptions);
	return (0, _amplitude_unified.track)(eventInput, eventProperties, eventOptions);
}
let amplitudeInitialized = false;
function trackMultiNodesAction(props) {
	track("[Web] multi_nodes_action", props);
}
function trackHistoryAction(props) {
	track("[Web] history_action", props);
}
function trackPreviewChange(props) {
	track("[Experiment] preview_change", props);
}
function trackPreviewChangeFeedback(props) {
	track("[Experiment] preview_change", props);
}
function trackSingleEnvironment(props) {
	track("[Experiment] single_environment", props);
}
function getExperimentTrackingBreakingChangeEnabled() {
	return false;
}
function trackColumnLevelLineage(props) {
	track("[Web] column_level_lineage", props);
}
function trackShareState(props) {
	track("[Web] share_state", props);
}
function trackStateAction(props) {
	track("[Web] state_action", props);
}
function trackCopyToClipboard(props) {
	track("[Click] copy_to_clipboard", props);
}
function trackNavigation(props) {
	track("[Web] navigation_change", props);
}
function trackLineageViewRender(props) {
	track("[Web] lineage_view_render", props);
}
function trackEnvironmentConfig(props) {
	track("[Web] environment_config", props);
}
const EXPLORE_ACTION = {
	ROW_COUNT: "row_count",
	ROW_COUNT_DIFF: "row_count_diff",
	PROFILE: "profile",
	PROFILE_DIFF: "profile_diff",
	VALUE_DIFF: "value_diff",
	SCHEMA_DIFF: "schema_diff",
	LINEAGE_DIFF: "lineage_diff",
	QUERY: "query",
	HISTOGRAM_DIFF: "histogram_diff",
	TOP_K_DIFF: "top_k_diff"
};
const EXPLORE_SOURCE = {
	LINEAGE_VIEW_TOP_BAR: "lineage_view_top_bar",
	LINEAGE_VIEW_CONTEXT_MENU: "lineage_view_context_menu",
	NODE_KEBAB_MENU: "node_kebab_menu",
	NODE_SIDEBAR_SINGLE_ENV: "node_sidebar_single_env",
	NODE_SIDEBAR_MULTI_ENV: "node_sidebar_multi_env",
	SCHEMA_ROW_COUNT_BUTTON: "schema_row_count_button",
	SCHEMA_COLUMN_MENU: "schema_column_menu"
};
function trackExploreAction(props) {
	track("[Web] explore_action", props);
}
const EXPLORE_FORM_EVENT = {
	EXECUTE: "execute",
	CANCEL: "cancel"
};
function trackExploreActionForm(props) {
	track("[Web] explore_action_form", props);
}
function isExploreAction(type) {
	return Object.values(EXPLORE_ACTION).includes(type);
}
const LINEAGE_SELECTION_ACTION = {
	SELECT_PARENT_NODES: "select_parent_nodes",
	SELECT_CHILD_NODES: "select_child_nodes",
	SELECT_ALL_UPSTREAM: "select_all_upstream",
	SELECT_ALL_DOWNSTREAM: "select_all_downstream"
};
function trackLineageSelection(props) {
	track("[Web] lineage_selection", props);
}

//#endregion
//#region recce-source/js/src/lib/api/types.ts
function isQueryRun(run) {
	return run.type === "query";
}
function isQueryBaseRun(run) {
	return run.type === "query_base";
}
function isQueryDiffRun(run) {
	return run.type === "query_diff";
}
function isValueDiffRun(run) {
	return run.type === "value_diff";
}
function isValueDiffDetailRun(run) {
	return run.type === "value_diff_detail";
}
function isProfileRun(run) {
	return run.type === "profile";
}
function isProfileDiffRun(run) {
	return run.type === "profile_diff";
}
function isRowCountRun(run) {
	return run.type === "row_count";
}
function isRowCountDiffRun(run) {
	return run.type === "row_count_diff";
}
function isTopKDiffRun(run) {
	return run.type === "top_k_diff";
}
function isHistogramDiffRun(run) {
	return run.type === "histogram_diff";
}

//#endregion
//#region recce-source/js/src/lib/hooks/ApiConfigContext.tsx
const defaultConfig = {
	apiPrefix: "",
	authToken: void 0,
	baseUrl: void 0
};
const ApiConfigContext = (0, react.createContext)(null);
/**
* Creates an axios instance configured with the given API config.
*
* The instance has interceptors that:
* 1. Replace /api prefix with the configured apiPrefix (if provided)
* 2. Add Authorization header with Bearer token (if authToken provided)
*/
function createApiClient(config) {
	const { apiPrefix, authToken, baseUrl } = config;
	const client = axios.default.create({ baseURL: baseUrl ?? require_const.PUBLIC_API_URL });
	client.interceptors.request.use((requestConfig) => {
		try {
			if (apiPrefix && requestConfig.url) {
				if (requestConfig.url === "/api") requestConfig.url = apiPrefix;
				else if (requestConfig.url.startsWith("/api/")) requestConfig.url = apiPrefix + requestConfig.url.slice(4);
			}
			if (authToken) requestConfig.headers.Authorization = `Bearer ${authToken}`;
			return requestConfig;
		} catch (error) {
			console.warn("API request interceptor error, proceeding with unmodified request:", error);
			return requestConfig;
		}
	}, (error) => {
		return Promise.reject(error);
	});
	return client;
}
function ApiConfigProvider({ children, apiPrefix = defaultConfig.apiPrefix, authToken = defaultConfig.authToken, baseUrl = defaultConfig.baseUrl }) {
	const config = (0, react.useMemo)(() => ({
		apiPrefix,
		authToken,
		baseUrl
	}), [
		apiPrefix,
		authToken,
		baseUrl
	]);
	const apiClient = (0, react.useMemo)(() => createApiClient(config), [config]);
	const contextValue = (0, react.useMemo)(() => ({
		...config,
		apiClient
	}), [config, apiClient]);
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiConfigContext.Provider, {
		value: contextValue,
		children
	});
}
const defaultApiConfigContext = {
	apiPrefix: "",
	authToken: void 0,
	baseUrl: void 0,
	apiClient: axios.default.create({ baseURL: require_const.PUBLIC_API_URL })
};
/**
* Hook to access the API configuration and configured axios client.
*
* When used outside ApiConfigProvider, returns default config with
* standard axiosClient (for OSS backward compatibility).
*
* @returns ApiConfigContextType with apiPrefix, authToken, and apiClient
*/
function useApiConfig() {
	return (0, react.useContext)(ApiConfigContext) ?? defaultApiConfigContext;
}
/**
* Hook to get the configured axios client.
* Convenience wrapper around useApiConfig().apiClient
*
* @returns AxiosInstance configured with API prefix and auth token
*/
function useApiClient() {
	return useApiConfig().apiClient;
}
/**
* Safe version of useApiConfig that returns null if outside provider.
* Useful for components that need to detect if ApiConfigProvider is present.
*/
function useApiConfigSafe() {
	return (0, react.useContext)(ApiConfigContext);
}

//#endregion
//#region recce-source/js/src/lib/api/cacheKeys.ts
const cacheKeys = {
	rowCount: (model) => ["row_count", model],
	lineage: () => ["lineage"],
	checks: () => ["checks", "list"],
	check: (checkId) => ["checks", checkId],
	checkEvents: (checkId) => [
		"checks",
		checkId,
		"events"
	],
	runs: () => ["runs"],
	run: (runId) => ["runs", runId],
	runsAggregated: () => ["runs_aggregated"],
	flag: () => ["flag"],
	instanceInfo: () => ["instance_info"],
	user: () => ["user"]
};

//#endregion
//#region recce-source/js/src/lib/api/flag.ts
async function getServerFlag(client = axiosClient) {
	return (await client.get("/api/flag")).data;
}
async function markOnboardingCompleted(client = axiosClient) {
	try {
		await client.post("/api/onboarding/completed");
	} catch (_error) {}
}
async function markRelaunchHintCompleted(client = axiosClient) {
	try {
		await client.post("/api/relaunch-hint/completed");
	} catch (_error) {}
}

//#endregion
//#region recce-source/js/src/lib/api/info.ts
async function getLineage(base = false) {
	return (await axiosClient.get(`/api/lineage?base=${base}`)).data;
}
async function getLineageWithError(base = false) {
	try {
		return { data: await getLineage(base) };
	} catch (err) {
		if (err instanceof axios.AxiosError) {
			const detail = (err.response?.data)?.detail;
			if (detail) return { error: detail };
			else return { error: err.message };
		} else if (err instanceof Error) return { error: err.message };
		else return { error: "An unknown error occurred" };
	}
}
async function getLineageDiff() {
	const [base, current] = await Promise.all([getLineageWithError(true), getLineageWithError(false)]);
	return {
		base: base.data,
		current: current.data,
		base_error: base.error,
		current_error: current.error
	};
}
async function getServerInfo(client = axiosClient) {
	return (await client.get(`/api/info`)).data;
}
async function getModelInfo(model) {
	return (await axiosClient.get(`/api/model/${model}`)).data;
}

//#endregion
//#region recce-source/js/src/lib/api/runs.ts
function mutateAddKey(run) {
	if (run.result == null) return run;
	if (isQueryRun(run)) run.result.columns = run.result.columns.map((c) => {
		if (c.key) return c;
		c.key = c.name;
		return c;
	});
	return run;
}
async function submitRun(type, params, options, client = axiosClient) {
	const track_props = options?.trackProps ? { ...options.trackProps } : {};
	if (getExperimentTrackingBreakingChangeEnabled()) track_props.breaking_change_analysis = true;
	return (await client.post("/api/runs", {
		type,
		params,
		nowait: options?.nowait,
		track_props
	})).data;
}
async function getRun(runId, client = axiosClient) {
	return (await client.get(`/api/runs/${runId}`)).data;
}
async function waitRun(runId, timeout, client = axiosClient) {
	return mutateAddKey((await client.get(`/api/runs/${runId}/wait`, { params: { timeout } })).data);
}
async function cancelRun(runId, client = axiosClient) {
	return await client.post(`/api/runs/${runId}/cancel`);
}
async function submitRunFromCheck(checkId, options, client = axiosClient) {
	return (await client.post(`/api/checks/${checkId}/run`, { nowait: options?.nowait })).data;
}
async function searchRuns(type, params, limit, client = axiosClient) {
	return (await client.post(`/api/runs/search`, {
		type,
		params,
		limit
	})).data;
}
async function listRuns(client = axiosClient) {
	return (await client.get("/api/runs")).data;
}
async function aggregateRuns(client = axiosClient) {
	return (await client.post(`/api/runs/aggregate`, {})).data;
}

//#endregion
//#region recce-source/js/src/lib/api/state.ts
async function saveAs(input, client = axiosClient) {
	return (await client.post("/api/save-as", input)).data;
}
async function rename(input, client = axiosClient) {
	return (await client.post("/api/rename", input)).data;
}
async function exportState(client = axiosClient) {
	return (await client.post("/api/export")).data;
}
async function importState(file, checksOnly, client = axiosClient) {
	const formData = new FormData();
	formData.append("file", file);
	formData.append("checks_only", (!!checksOnly).toString());
	return (await client.post("/api/import", formData)).data;
}
async function isStateSyncing(client = axiosClient) {
	return (await client.get("/api/sync")).status === 208;
}
async function syncState(input, client = axiosClient) {
	try {
		const response = await client.post("/api/sync", input);
		if (response.status === 202) return { status: "accepted" };
		if (response.status === 208) return { status: "syncing" };
	} catch (error) {
		if ((0, axios.isAxiosError)(error)) {
			if (error.response?.status === 409) return { status: "conflict" };
		}
	}
	throw new Error("Failed to sync state");
}
async function shareState(client = axiosClient) {
	return (await client.post("/api/share")).data;
}

//#endregion
Object.defineProperty(exports, 'ApiConfigProvider', {
  enumerable: true,
  get: function () {
    return ApiConfigProvider;
  }
});
Object.defineProperty(exports, 'EXPLORE_ACTION', {
  enumerable: true,
  get: function () {
    return EXPLORE_ACTION;
  }
});
Object.defineProperty(exports, 'EXPLORE_FORM_EVENT', {
  enumerable: true,
  get: function () {
    return EXPLORE_FORM_EVENT;
  }
});
Object.defineProperty(exports, 'EXPLORE_SOURCE', {
  enumerable: true,
  get: function () {
    return EXPLORE_SOURCE;
  }
});
Object.defineProperty(exports, 'LINEAGE_SELECTION_ACTION', {
  enumerable: true,
  get: function () {
    return LINEAGE_SELECTION_ACTION;
  }
});
Object.defineProperty(exports, '__commonJSMin', {
  enumerable: true,
  get: function () {
    return __commonJSMin;
  }
});
Object.defineProperty(exports, '__toESM', {
  enumerable: true,
  get: function () {
    return __toESM;
  }
});
Object.defineProperty(exports, 'aggregateRuns', {
  enumerable: true,
  get: function () {
    return aggregateRuns;
  }
});
Object.defineProperty(exports, 'axiosClient', {
  enumerable: true,
  get: function () {
    return axiosClient;
  }
});
Object.defineProperty(exports, 'cacheKeys', {
  enumerable: true,
  get: function () {
    return cacheKeys;
  }
});
Object.defineProperty(exports, 'cancelRun', {
  enumerable: true,
  get: function () {
    return cancelRun;
  }
});
Object.defineProperty(exports, 'exportState', {
  enumerable: true,
  get: function () {
    return exportState;
  }
});
Object.defineProperty(exports, 'getExperimentTrackingBreakingChangeEnabled', {
  enumerable: true,
  get: function () {
    return getExperimentTrackingBreakingChangeEnabled;
  }
});
Object.defineProperty(exports, 'getLineage', {
  enumerable: true,
  get: function () {
    return getLineage;
  }
});
Object.defineProperty(exports, 'getLineageDiff', {
  enumerable: true,
  get: function () {
    return getLineageDiff;
  }
});
Object.defineProperty(exports, 'getLineageWithError', {
  enumerable: true,
  get: function () {
    return getLineageWithError;
  }
});
Object.defineProperty(exports, 'getModelInfo', {
  enumerable: true,
  get: function () {
    return getModelInfo;
  }
});
Object.defineProperty(exports, 'getRun', {
  enumerable: true,
  get: function () {
    return getRun;
  }
});
Object.defineProperty(exports, 'getServerFlag', {
  enumerable: true,
  get: function () {
    return getServerFlag;
  }
});
Object.defineProperty(exports, 'getServerInfo', {
  enumerable: true,
  get: function () {
    return getServerInfo;
  }
});
Object.defineProperty(exports, 'importState', {
  enumerable: true,
  get: function () {
    return importState;
  }
});
Object.defineProperty(exports, 'isExploreAction', {
  enumerable: true,
  get: function () {
    return isExploreAction;
  }
});
Object.defineProperty(exports, 'isHistogramDiffRun', {
  enumerable: true,
  get: function () {
    return isHistogramDiffRun;
  }
});
Object.defineProperty(exports, 'isProfileDiffRun', {
  enumerable: true,
  get: function () {
    return isProfileDiffRun;
  }
});
Object.defineProperty(exports, 'isProfileRun', {
  enumerable: true,
  get: function () {
    return isProfileRun;
  }
});
Object.defineProperty(exports, 'isQueryBaseRun', {
  enumerable: true,
  get: function () {
    return isQueryBaseRun;
  }
});
Object.defineProperty(exports, 'isQueryDiffRun', {
  enumerable: true,
  get: function () {
    return isQueryDiffRun;
  }
});
Object.defineProperty(exports, 'isQueryRun', {
  enumerable: true,
  get: function () {
    return isQueryRun;
  }
});
Object.defineProperty(exports, 'isRowCountDiffRun', {
  enumerable: true,
  get: function () {
    return isRowCountDiffRun;
  }
});
Object.defineProperty(exports, 'isRowCountRun', {
  enumerable: true,
  get: function () {
    return isRowCountRun;
  }
});
Object.defineProperty(exports, 'isStateSyncing', {
  enumerable: true,
  get: function () {
    return isStateSyncing;
  }
});
Object.defineProperty(exports, 'isTopKDiffRun', {
  enumerable: true,
  get: function () {
    return isTopKDiffRun;
  }
});
Object.defineProperty(exports, 'isValueDiffDetailRun', {
  enumerable: true,
  get: function () {
    return isValueDiffDetailRun;
  }
});
Object.defineProperty(exports, 'isValueDiffRun', {
  enumerable: true,
  get: function () {
    return isValueDiffRun;
  }
});
Object.defineProperty(exports, 'listRuns', {
  enumerable: true,
  get: function () {
    return listRuns;
  }
});
Object.defineProperty(exports, 'markOnboardingCompleted', {
  enumerable: true,
  get: function () {
    return markOnboardingCompleted;
  }
});
Object.defineProperty(exports, 'markRelaunchHintCompleted', {
  enumerable: true,
  get: function () {
    return markRelaunchHintCompleted;
  }
});
Object.defineProperty(exports, 'reactQueryClient', {
  enumerable: true,
  get: function () {
    return reactQueryClient;
  }
});
Object.defineProperty(exports, 'rename', {
  enumerable: true,
  get: function () {
    return rename;
  }
});
Object.defineProperty(exports, 'saveAs', {
  enumerable: true,
  get: function () {
    return saveAs;
  }
});
Object.defineProperty(exports, 'searchRuns', {
  enumerable: true,
  get: function () {
    return searchRuns;
  }
});
Object.defineProperty(exports, 'shareState', {
  enumerable: true,
  get: function () {
    return shareState;
  }
});
Object.defineProperty(exports, 'submitRun', {
  enumerable: true,
  get: function () {
    return submitRun;
  }
});
Object.defineProperty(exports, 'submitRunFromCheck', {
  enumerable: true,
  get: function () {
    return submitRunFromCheck;
  }
});
Object.defineProperty(exports, 'syncState', {
  enumerable: true,
  get: function () {
    return syncState;
  }
});
Object.defineProperty(exports, 'trackColumnLevelLineage', {
  enumerable: true,
  get: function () {
    return trackColumnLevelLineage;
  }
});
Object.defineProperty(exports, 'trackCopyToClipboard', {
  enumerable: true,
  get: function () {
    return trackCopyToClipboard;
  }
});
Object.defineProperty(exports, 'trackEnvironmentConfig', {
  enumerable: true,
  get: function () {
    return trackEnvironmentConfig;
  }
});
Object.defineProperty(exports, 'trackExploreAction', {
  enumerable: true,
  get: function () {
    return trackExploreAction;
  }
});
Object.defineProperty(exports, 'trackExploreActionForm', {
  enumerable: true,
  get: function () {
    return trackExploreActionForm;
  }
});
Object.defineProperty(exports, 'trackHistoryAction', {
  enumerable: true,
  get: function () {
    return trackHistoryAction;
  }
});
Object.defineProperty(exports, 'trackLineageSelection', {
  enumerable: true,
  get: function () {
    return trackLineageSelection;
  }
});
Object.defineProperty(exports, 'trackLineageViewRender', {
  enumerable: true,
  get: function () {
    return trackLineageViewRender;
  }
});
Object.defineProperty(exports, 'trackMultiNodesAction', {
  enumerable: true,
  get: function () {
    return trackMultiNodesAction;
  }
});
Object.defineProperty(exports, 'trackNavigation', {
  enumerable: true,
  get: function () {
    return trackNavigation;
  }
});
Object.defineProperty(exports, 'trackPreviewChange', {
  enumerable: true,
  get: function () {
    return trackPreviewChange;
  }
});
Object.defineProperty(exports, 'trackPreviewChangeFeedback', {
  enumerable: true,
  get: function () {
    return trackPreviewChangeFeedback;
  }
});
Object.defineProperty(exports, 'trackShareState', {
  enumerable: true,
  get: function () {
    return trackShareState;
  }
});
Object.defineProperty(exports, 'trackSingleEnvironment', {
  enumerable: true,
  get: function () {
    return trackSingleEnvironment;
  }
});
Object.defineProperty(exports, 'trackStateAction', {
  enumerable: true,
  get: function () {
    return trackStateAction;
  }
});
Object.defineProperty(exports, 'useApiClient', {
  enumerable: true,
  get: function () {
    return useApiClient;
  }
});
Object.defineProperty(exports, 'useApiConfig', {
  enumerable: true,
  get: function () {
    return useApiConfig;
  }
});
Object.defineProperty(exports, 'useApiConfigSafe', {
  enumerable: true,
  get: function () {
    return useApiConfigSafe;
  }
});
Object.defineProperty(exports, 'waitRun', {
  enumerable: true,
  get: function () {
    return waitRun;
  }
});
//# sourceMappingURL=state-CTITyT0R.js.map