//#region src/routes.ts
var PathId = /* @__PURE__ */ function(PathId) {
	PathId["Request"] = "request";
	PathId["Examples"] = "examples";
	PathId["Cookies"] = "cookies";
	PathId["Collection"] = "collection";
	PathId["Schema"] = "schema";
	PathId["Environment"] = "environment";
	PathId["Servers"] = "servers";
	PathId["Workspace"] = "workspace";
	PathId["Settings"] = "settings";
	return PathId;
}({});
/** Tracks the active workspace in localStorage for when the client reloads */
var ACTIVE_WORKSPACE_KEY = "activeWorkspace";
/** Save the active workspace in localStorage for when the client reloads */
function saveActiveWorkspace(to) {
	const workspace = to.params[PathId.Workspace];
	if (workspace) localStorage.setItem(ACTIVE_WORKSPACE_KEY, `${workspace}`);
}
/** Redirect to the saved workspace or the default workspace */
function redirectToActiveWorkspace() {
	const activeWorkspace = localStorage.getItem(ACTIVE_WORKSPACE_KEY);
	if (!activeWorkspace) return { name: "workspace.default" };
	return {
		name: "request.root",
		params: { [PathId.Workspace]: activeWorkspace }
	};
}
/** Shared request routes between modal and app */
var requestRoutes = [{
	name: "request.root",
	path: "",
	component: () => import("./views/Request/RequestRoot.vue.js"),
	redirect: (to, _from) => ({
		name: "request",
		params: {
			...to.params,
			request: "default"
		}
	}),
	children: [
		{
			name: "request",
			path: `request/:${PathId.Request}`,
			component: () => import("./views/Request/Request.vue.js")
		},
		{
			name: "request.examples",
			path: `request/:${PathId.Request}/examples/:${PathId.Examples}`,
			component: () => import("./views/Request/Request.vue.js")
		},
		{
			name: "collection",
			path: `collection/:${PathId.Collection}`,
			component: () => import("./views/Collection/Collection.vue.js"),
			redirect: (_to, _from) => {
				return { name: "collection.overview" };
			},
			children: [
				{
					name: "collection.overview",
					path: "overview",
					component: () => import("./views/Collection/CollectionOverview.vue.js")
				},
				{
					name: "collection.servers",
					path: "servers",
					component: () => import("./views/Collection/CollectionServers.vue.js"),
					children: [{
						name: "collection.servers.edit",
						path: `:${PathId.Servers}`,
						component: () => import("./views/Collection/CollectionServers.vue.js")
					}]
				},
				{
					name: "collection.environment",
					path: "environment",
					component: () => import("./views/Collection/CollectionEnvironment.vue.js")
				},
				{
					name: "collection.authentication",
					path: "authentication",
					component: () => import("./views/Collection/CollectionAuthentication.vue.js")
				},
				{
					name: "collection.cookies",
					path: "cookies",
					component: () => import("./views/Collection/CollectionCookies.vue.js")
				},
				{
					name: "collection.scripts",
					path: "scripts",
					component: () => import("./views/Collection/CollectionScripts.vue.js")
				},
				{
					name: "collection.sync",
					path: "sync",
					component: () => import("./views/Collection/CollectionSync.vue.js")
				},
				{
					name: "collection.settings",
					path: "settings",
					component: () => import("./views/Collection/CollectionSettings.vue.js")
				}
			]
		}
	]
}];
/** Routes required by the API client modal */
var modalRoutes = [
	{
		name: "root",
		path: "/",
		redirect: redirectToActiveWorkspace
	},
	{
		name: "workspace.default",
		path: "/workspace",
		redirect: {
			name: "workspace",
			params: { [PathId.Workspace]: "default" }
		}
	},
	{
		name: "workspace",
		path: `/workspace/:${PathId.Workspace}`,
		redirect: { name: "request.root" },
		children: requestRoutes
	}
];
/** Routes for the API client app */
var routes = [
	{
		name: "root",
		path: "/",
		redirect: redirectToActiveWorkspace
	},
	{
		name: "workspace.default",
		path: "/workspace",
		redirect: {
			name: "request.root",
			params: { [PathId.Workspace]: "default" }
		}
	},
	{
		name: "workspace",
		path: `/workspace/:${PathId.Workspace}`,
		redirect: { name: "request.root" },
		children: [
			...requestRoutes,
			{
				name: "environment.default",
				path: "environment",
				redirect: (to, _from) => ({
					name: "environment",
					params: {
						...to.params,
						[PathId.Environment]: "default"
					}
				})
			},
			{
				name: "environment",
				path: `environment/:${PathId.Environment}`,
				component: () => import("./views/Environment/Environment.vue.js")
			},
			{
				name: "environment.collection",
				path: `environment/:${PathId.Collection}/:${PathId.Environment}`,
				component: () => import("./views/Environment/Environment.vue.js"),
				props: true
			},
			{
				name: "cookies.default",
				path: "cookies",
				redirect: (to, _from) => ({
					name: "cookies",
					params: {
						...to.params,
						[PathId.Cookies]: "default"
					}
				})
			},
			{
				name: "cookies",
				path: `cookies/:${PathId.Cookies}`,
				component: () => import("./views/Cookies/Cookies.vue.js")
			},
			{
				name: "servers.default",
				path: "servers",
				redirect: (to, _from) => ({
					name: "servers",
					params: {
						...to.params,
						[PathId.Collection]: "default",
						[PathId.Servers]: "default"
					}
				})
			},
			{
				name: "settings.default",
				path: "settings",
				redirect: (to, _from) => ({
					name: "settings",
					params: {
						...to.params,
						[PathId.Settings]: "general"
					}
				})
			},
			{
				name: "settings",
				path: `settings/:${PathId.Settings}`,
				component: () => import("./views/Settings/Settings.vue.js")
			}
		]
	}
];
//#endregion
export { PathId, modalRoutes, routes, saveActiveWorkspace };

//# sourceMappingURL=routes.js.map